> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_38/session_04_dream_scheduling_and_setup.md).

# Session 04: Dream Scheduling and Setup

**Session ID**: `phase38-session04-dream-scheduling-and-setup` **Status**: Not Started **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Add real Windows Dream scheduling while preserving macOS/Linux behavior and improving setup auth guidance.

***

## Non-Negotiable Delivery Bar

Windows scheduling is complete only when the scheduled task can be registered, queried, run, and removed through the real Windows Task Scheduler path or a faithful harness, and when the task runs an AI OS Dream runner that writes real Dream output and refreshed live data.

***

## Source Items

* 1.3 `ADAPT`: Windows Task Scheduler for Dream cron.
* 1.4 `ADAPT`: setup script headless-auth warning and Windows install.

***

## Scope

### In Scope (MVP)

* Adapt upstream Task Scheduler mechanics into `/home/aiwithapex/projects/aios/scripts/install-dream-cron.ts`.
* Wire Windows scheduling to AI OS runners: `/home/aiwithapex/projects/aios/scripts/dashboard-dream-run.ts` or `/home/aiwithapex/projects/aios/scripts/scheduler-runner.ts --job dream`.
* Integrate with AI OS scheduler modules under `/home/aiwithapex/projects/aios/scripts/lib/scheduler/`.
* Add platform-correct install, query, run, uninstall, and verification messaging.
* Update Linux cron guidance so aggregate refresh ordering matches AI OS behavior.
* Update `/home/aiwithapex/projects/aios/scripts/setup.ts` with Windows install support and readiness-based headless-auth warnings.

### Out of Scope

* Copying upstream `scripts/run-dream.ts` runner wiring.
* Browser Dream engine selector.
* Voice or Intelligence portal work.
* Replacing AI OS Dream execution modules.

***

## Detailed Port Items

### 1.3 Windows Task Scheduler For Dream Cron

AI OS `scripts/install-dream-cron.ts` is still essentially the v2.7 macOS-`launchctl` version. It prints a manual Windows "use Task Scheduler" hint instead of installing a task. Upstream v2.8.1 adds real scheduling support, platform-safe binary resolution, and headless-auth notices.

* Upstream sources: `/home/aiwithapex/projects/claudeos/claude-os-v2.7/scripts/install-dream-cron.ts` and `/home/aiwithapex/projects/claudeos/claude-os-v2.8.1/scripts/install-dream-cron.ts`.
* Patch line: 1002.
* AI OS targets: `/home/aiwithapex/projects/aios/scripts/install-dream-cron.ts`, `/home/aiwithapex/projects/aios/scripts/lib/scheduler/`, and `/home/aiwithapex/projects/aios/scripts/scheduler-runner.ts`.
* Critical adaptation: upstream schedules `bun run scripts/run-dream.ts`; AI OS must schedule `scripts/dashboard-dream-run.ts` or `scripts/scheduler-runner.ts --job dream` instead.
* Port only the Windows scheduling mechanics: Task Scheduler registration, task naming, query/run verification, uninstall, and a `.cmd` or equivalent wrapper for quoted paths.
* Raw `schtasks` is acceptable only if quoting and test harness prove it.
* Known upstream bugs to avoid:
  * Do not print `launchctl kickstart` verification text on Windows.
  * Do not use Hermes presence as the only auth warning condition.
  * Do not copy the unused `readChosenEngine()` type gap that omits `openrouter`.
  * Do not copy contradictory Linux messaging about what is auto-installable.
* Linux gap to fix: emitted Linux cron guidance must refresh aggregate data before the cloud Dream run, matching AI OS behavior.
* Risk: medium due to OS-specific quoting and scheduler behavior.

### 1.4 Setup Script Headless-Auth Warning And Windows Install

Upstream `scripts/setup.ts` adds Windows cron install support and a visible `claude -p` headless-auth warning.

* Upstream sources: `/home/aiwithapex/projects/claudeos/claude-os-v2.7/scripts/setup.ts` and `/home/aiwithapex/projects/claudeos/claude-os-v2.8.1/scripts/setup.ts`.
* Patch line: 1779.
* AI OS target: `/home/aiwithapex/projects/aios/scripts/setup.ts`.
* Adaptation: add the Windows branch and auth warning, but use platform-correct verification hints such as `schtasks /Query` on Windows.
* Readiness modules to prefer over upstream `ANTHROPIC_API_KEY`-only tests: `/home/aiwithapex/projects/aios/scripts/lib/hermes-provider-readiness.ts`, `/home/aiwithapex/projects/aios/scripts/lib/codex-app-server-readiness.ts`, and `/home/aiwithapex/projects/aios/scripts/lib/claude-oauth-usage.ts`.
* Avoid false warnings after valid `claude setup-token` or configured provider readiness.
* Risk: low-medium.

***

## Prerequisites

* [ ] Sessions 02 and 03 completed.
* [ ] Current AI OS Dream runner command and scheduler job path selected for Windows scheduling.
* [ ] Current setup readiness modules identified.
* [ ] Existing macOS `launchctl` behavior characterized before edits.

***

## Deliverables

1. Windows install, query, run, and uninstall support for scheduled Dream runs.
2. Scheduling command that invokes AI OS Dream runners, not upstream `scripts/run-dream.ts`.
3. Platform-correct verification and recovery messaging.
4. Linux cron guidance with aggregate refresh ordering corrected.
5. Setup flow that offers Windows scheduling and readiness-based auth guidance.
6. Tests for `schtasks` argv, missing-tool/auth messaging, setup readiness, and macOS regression.

***

## Success Criteria

* [ ] On Windows or a faithful harness, `bun run install-dream` registers a Task Scheduler task and `schtasks /Query` can verify it.
* [ ] The task runs the AI OS Dream runner and writes real Dream output plus refreshed `src/data/live-data.json`.
* [ ] `bun run uninstall-dream` removes the Windows task.
* [ ] macOS `launchctl` behavior remains unchanged by regression tests.
* [ ] Linux guidance refreshes aggregate before Dream run.
* [ ] Missing Bun, Hermes, auth, or scheduler support prints platform-correct actionable recovery copy.
* [ ] Setup auth warnings appear only when readiness checks prove auth is missing.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_38/session_04_dream_scheduling_and_setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
