Galaxy Shell / docs
Docs / Interface and features

Scheduled intents

openspec/specs/scheduled-intents/spec.md · Edit on GitHub ↗

On this page

Scheduled intents

Purpose

A scheduled intent is a stored prompt that the core sends as a normal conversation turn at a local time. This spec indexes its limits, its approval flow and its run rules.

Requirements

Requirement: Schedule has no command field

A schedule SHALL have a prompt of 1 to 2000 characters and a typed recurrence (daily, weekdays, or a list of mon to sun, plus a local HH:MM). There is no cron syntax and no command field; the only action is to send the prompt to the agent. Full text: section Contract.

Scenario: Schedule has no command field

  • WHEN a schedule is created
  • THEN it has a typed recurrence and a prompt and no command field

Requirement: Run target

The target SHALL be a new conversation per run (named Agendado: <start of prompt>) or an existing open conversation chosen by name. A missing target records a failed result. Full text: section Contract.

Scenario: Run target

  • WHEN the chosen conversation does not exist
  • THEN a failed result is recorded

Requirement: Schedule storage

The core SHALL store schedules in schedules.json in the profile data directory with mode 0600, written atomically. An unreadable file is renamed to schedules.invalid-<ms>.json, the core starts without schedules and the original is never overwritten. Full text: section Contract.

Scenario: Schedule storage

  • WHEN schedules.json is unreadable
  • THEN it is renamed and the core starts without schedules

Requirement: Agent changes only propose

The three change tools (schedule_create, schedule_update, schedule_delete) SHALL only propose and return awaiting_host_approval. Nothing is created, changed or deleted until the user allows it. Generated HTML gets none of the tools. Full text: section Who can change a schedule.

Scenario: Agent changes only propose

  • WHEN the agent calls schedule_create
  • THEN the core returns awaiting_host_approval and creates nothing

Requirement: Host approval dialog

The protected host SHALL show the proposal in a modal dialog (Permitir or Recusar; Esc refuses) and "Permitir" arms 1.5 s after the proposal shows. The host calls POST /api/schedule-approval, which needs the host CSRF token. Full text: section Who can change a schedule.

Scenario: Host approval dialog

  • WHEN the user presses Esc on the dialog
  • THEN the proposal is refused

Requirement: Proposal and schedule limits

Proposals SHALL NOT be saved, so a core restart drops them. At most 10 proposals wait at once and at most 50 schedules exist. Full text: section Who can change a schedule.

Scenario: Proposal and schedule limits

  • WHEN the core restarts
  • THEN pending proposals are dropped

Requirement: A scheduled turn cannot change schedules

A scheduled turn MUST NOT change schedules: the change tools return an error in that turn. Full text: section Who can change a schedule.

Scenario: A scheduled turn cannot change schedules

  • WHEN a scheduled turn calls a change tool
  • THEN the tool returns an error

Requirement: User controls and prompt editing

The user can enable, disable and delete a schedule directly in the quick settings panel with no card. Editing the prompt text SHALL stay agent-only, through a proposal. Full text: section Who can change a schedule.

Scenario: User controls and prompt editing

  • WHEN the user disables a schedule in the quick settings
  • THEN it is disabled with no approval card

Requirement: Run is a normal turn

A run SHALL send [Scheduled task] <prompt> as the user message with scheduled: true. The turn is a normal turn, tool approvals go through the protected host as usual and the core approves nothing by itself. Full text: section When a run happens.

Scenario: Run is a normal turn

  • WHEN a scheduled turn needs a tool approval
  • THEN the protected host asks as usual

Requirement: Run is recorded before it starts

The core SHALL record the run (lastRunAt, lastResult: started) and save the file before it starts the turn, so a crash cannot repeat a run. A failed start is recorded as failed and is not retried. Full text: section When a run happens.

Scenario: Run is recorded before it starts

  • WHEN the core crashes after the run was recorded
  • THEN the run is not repeated

Requirement: Missed runs collapse

When the core was down or the machine asleep, all slots that passed SHALL collapse to the latest one. If it is less than 12 hours old the schedule runs once; if it is older the core skips it and records skipped with the reason "perdido por mais de 12 horas". Full text: section When a run happens.

Scenario: Missed runs collapse

  • WHEN the latest missed slot is older than 12 hours
  • THEN the core skips it and records skipped

Requirement: Busy turn waits, one waiting run per schedule

If a turn, a model change, a login or a change process is active, or the session is locked, the slot SHALL wait and run when the core is idle and unlocked. At most one run per schedule waits; a new slot that arrives meanwhile is skipped and recorded. Full text: section When a run happens.

Scenario: Busy turn waits, one waiting run per schedule

  • WHEN the next slot arrives while a run still waits
  • THEN the new slot is skipped and the older waiting run is kept

Status

Doc status: current contract. Scheduled intents with host approval. Checked 2026-11-10.

Introduction

A scheduled intent is a stored prompt that the core sends as a normal conversation turn at a local time. Example: "every weekday at 9:00, open my development workspace". The code is in web-shell/core/schedules.js. The wiring is in core/server.js.

Contract

  • A schedule has: id, prompt (1 to 2000 characters), recurrence, target, enabled, createdAt, lastRunAt, nextRunAt, waitingSince and lastResult.
  • The recurrence is typed: daily, weekdays, or a list of mon to sun, plus a local HH:MM. There is no cron syntax and no command field. The only action is to send the prompt to the agent.
  • The target is a new conversation per run (named Agendado: <start of prompt>) or an existing open conversation chosen by name. A conversation is a workspace, so a run switches to it first. A missing target records a failed result.
  • The core stores schedules in schedules.json in the profile data directory. The file has mode 0600 and is written atomically (atomicJSON from core/changes.js). An unreadable file is renamed to schedules.invalid-<ms>.json and the core starts without schedules. The original is never overwritten.
  • Schedules are not part of the change journal (core/changes.js). They do not change the UI, frames or model, so they need no checkpoint. The profile lock (.instance.guard) already gives one writer.

Who can change a schedule

  • The agent has four authenticated tools: schedule_list, schedule_create, schedule_update, schedule_delete. Generated HTML gets none of them.
  • The three change tools only propose. The core keeps the proposal in memory and returns awaiting_host_approval. Nothing is created, changed or deleted until the user allows it.
  • The protected host shows the proposal in a modal dialog in the top layer, outside the ShadowRoot (Permitir or Recusar; Esc refuses). "Permitir" arms 1.5 s after the proposal shows. See openspec/specs/self-maintenance/spec.md, section The tool approval dialog. The card text is plain text built from the stored proposal. The host calls POST /api/schedule-approval, which needs the host CSRF token. Generated HTML has no token.
  • Proposals are not saved. A core restart drops them. At most 10 proposals wait at once. At most 50 schedules exist.
  • A scheduled turn cannot change schedules. The change tools return an error in that turn. This stops a schedule from creating more schedules.
  • The user can enable, disable and delete a schedule directly in the quick settings panel (Agendamentos). No card is needed for the user's own action. Editing the prompt text stays agent-only (through a proposal).

When a run happens

  • The core checks the schedules every 5 seconds and when a turn ends. AGENT_NATIVE_SCHEDULER_TICK_MS changes the interval (minimum 100 ms, for tests).
  • The run sends [Scheduled task] <prompt> as the user message. The history keeps the prefix, and the message carries scheduled: true. The interface labels it "Agendado" and hides the prefix, also in the overview preview of the conversation. The agent sees the prefix and knows the source.
  • The turn is a normal turn. Tool approvals go through the protected host as usual. The core approves nothing by itself.
  • The core records the run (lastRunAt, lastResult: started) and saves the file before it starts the turn. A crash cannot repeat a run. A failed start is recorded as failed and is not retried.
  • Local time and DST: the next slot comes from wall-clock time with the Date constructor. A skipped time (spring forward) runs once at the shifted instant. A repeated time (fall back) runs once at its first occurrence.
  • Missed runs (core down or machine asleep): all slots that passed collapse to the latest one. If it is less than 12 hours old, the schedule runs once. If it is older, the core skips it and records skipped with the reason "perdido por mais de 12 horas". Stored reasons are Portuguese text, because the host shows them as they are. Then the normal schedule continues.
  • Busy turn: if a turn, a model change, a login or a change process is active, or the session is locked, the slot waits (waitingSince) and runs when the core is idle and the session is unlocked. If the next slot arrives while a run still waits, the core skips the new slot and records skipped with the reason "a execução anterior ainda aguarda um turno livre". The older waiting run is kept. At most one run per schedule waits.
  • The core also waits until it is ready (OpenCode up). A schedule that is due at start runs after the runtime is ready.

Evidence

  • web-shell/test/schedules.test.js: 15 unit tests with a fake clock and TZ=America/New_York (recurrence, DST, approval flow, missed runs, busy and skipped slots, failure, crash safety, invalid file).
  • web-shell/test/schedules-http.test.js: a synthetic core with the fixture OpenCode backend. A due schedule starts exactly one turn. The turn is marked as scheduled. The tool refusal inside it, the host approval, the settings actions and the 0600 file mode are checked. No provider receives a message.
  • Not proven: the Electron host card and the quick settings list in a real window, a real DST change, a run on the live session, and a run with a real model.