@ours.network/fleet 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/dist/application/capabilities.d.ts +6 -0
- package/dist/application/capabilities.js +37 -0
- package/dist/application/errors.d.ts +31 -0
- package/dist/application/errors.js +51 -0
- package/dist/application/fleet-query-service.d.ts +42 -0
- package/dist/application/fleet-query-service.js +188 -0
- package/dist/application/log-service.d.ts +28 -0
- package/dist/application/log-service.js +146 -0
- package/dist/application/role-command-service.d.ts +37 -0
- package/dist/application/role-command-service.js +82 -0
- package/dist/application/role-creation-service.d.ts +142 -0
- package/dist/application/role-creation-service.js +374 -0
- package/dist/application/role-repository.d.ts +20 -0
- package/dist/application/role-repository.js +168 -0
- package/dist/application/session-control.d.ts +55 -0
- package/dist/application/session-control.js +115 -0
- package/dist/application/types.d.ts +156 -0
- package/dist/application/types.js +1 -0
- package/dist/cli.js +341 -3
- package/dist/config.d.ts +9 -2
- package/dist/config.js +21 -5
- package/dist/creation.d.ts +11 -0
- package/dist/creation.js +22 -5
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +56 -0
- package/dist/duration.d.ts +5 -0
- package/dist/duration.js +20 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +9 -1
- package/dist/ops.d.ts +16 -0
- package/dist/ops.js +112 -3
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +1 -0
- package/dist/resolved-plan.js +7 -0
- package/dist/runner.js +10 -2
- package/dist/session/control.d.ts +4 -2
- package/dist/session/control.js +45 -13
- package/dist/spawn.d.ts +20 -2
- package/dist/spawn.js +94 -24
- package/dist/supervisor/launchd.js +17 -0
- package/dist/supervisor/none.js +17 -0
- package/dist/supervisor/systemd.js +4 -0
- package/dist/supervisor/types.d.ts +6 -0
- package/dist/tmux.d.ts +2 -0
- package/dist/tmux.js +8 -0
- package/dist/watchdog/alerts.d.ts +34 -0
- package/dist/watchdog/alerts.js +78 -0
- package/dist/watchdog/briefing.d.ts +65 -0
- package/dist/watchdog/briefing.js +181 -0
- package/dist/watchdog/config.d.ts +49 -0
- package/dist/watchdog/config.js +114 -0
- package/dist/watchdog/query.d.ts +78 -0
- package/dist/watchdog/query.js +124 -0
- package/dist/watchdog/report.d.ts +53 -0
- package/dist/watchdog/report.js +126 -0
- package/dist/watchdog/run.d.ts +61 -0
- package/dist/watchdog/run.js +318 -0
- package/dist/watchdog/scheduler.d.ts +105 -0
- package/dist/watchdog/scheduler.js +244 -0
- package/dist/watchdog/service.d.ts +46 -0
- package/dist/watchdog/service.js +179 -0
- package/dist/watchdog/store.d.ts +85 -0
- package/dist/watchdog/store.js +226 -0
- package/dist/web/audit.d.ts +22 -0
- package/dist/web/audit.js +54 -0
- package/dist/web/auth.d.ts +61 -0
- package/dist/web/auth.js +186 -0
- package/dist/web/control.d.ts +14 -0
- package/dist/web/control.js +110 -0
- package/dist/web/device-store.d.ts +27 -0
- package/dist/web/device-store.js +155 -0
- package/dist/web/events.d.ts +15 -0
- package/dist/web/events.js +34 -0
- package/dist/web/lock.d.ts +5 -0
- package/dist/web/lock.js +69 -0
- package/dist/web/runtime.d.ts +12 -0
- package/dist/web/runtime.js +214 -0
- package/dist/web/server.d.ts +37 -0
- package/dist/web/server.js +279 -0
- package/dist/web/service.d.ts +42 -0
- package/dist/web/service.js +180 -0
- package/dist/web/terminal/bridge.d.ts +27 -0
- package/dist/web/terminal/bridge.js +317 -0
- package/dist/web-app/assets/TerminalView-BvcIkuIF.js +9 -0
- package/dist/web-app/assets/index-B-jtLAkp.css +1 -0
- package/dist/web-app/assets/index-CUN7ksTw.js +9 -0
- package/dist/web-app/icons/ours-fleet-maskable.svg +4 -0
- package/dist/web-app/icons/ours-fleet.svg +4 -0
- package/dist/web-app/index.html +17 -0
- package/dist/web-app/manifest.webmanifest +15 -0
- package/dist/web-app/offline.html +18 -0
- package/dist/web-app/sw.js +51 -0
- package/package.json +26 -3
package/dist/docs.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Keep this concise enough to place directly in an agent context. Unlike
|
|
5
5
|
* Commander's per-command help, this describes how the pieces compose.
|
|
6
6
|
*/
|
|
7
|
-
export declare const AI_DOCS = "# ours-fleet reference\n\nours-fleet runs persistent or temporary, identity-bound AI roles. A role selects\na harness independently from its session backend:\n\n- harness: `claude-code` or `codex`\n- session: `tmux` (default) or `acp`\n- lifetime: permanent (supervised, restartable) or `spawn --temp`\n\n## Discover and validate\n\n```sh\nours-fleet docs # this complete reference (`man` is an alias)\nours-fleet help <command> # exact flags for one command\nours-fleet config [-c FILE] # validate and print the merged plan; no changes\nours-fleet doctor [-c FILE] [--harness codex|claude-code]\n```\n\nDefault configuration is `~/fleet.yaml` plus sorted `~/fleet.d/*.yaml` role\ndrop-ins. An explicit `-c FILE` replaces `~/fleet.yaml`; fleet.d still adds\nroles. Validate with `config` and `doctor` before starting or restarting.\n\n## Lifecycle and console commands\n\n```sh\nours-fleet init\nours-fleet up|down [Name...]\nours-fleet restart [Name...] # preserve/resume harness context\nours-fleet force-restart [Name...] # fresh context; briefing is reloaded\nours-fleet ls\nours-fleet status|peek|attach|logs Name\nours-fleet logs -f Name\nours-fleet send Name \"prompt\"\nours-fleet send Name --key Enter # tmux only\nours-fleet rm Name\n```\n\n`peek`, `attach`, and text `send` work with tmux and ACP. ACP attachment\nalso accepts `/permit <permission-id> <option-id>`, `/interrupt`, and\n`/detach`. Raw `--key` input is tmux-only.\n\n## Spawn\n\n```sh\nours-fleet spawn [--temp] Name \\\n --harness codex|claude-code --session tmux|acp \\\n --mission \"one line\" --cwd /absolute/path --identity Identity \\\n --coordinator Coordinator --model MODEL \\\n --approval ask|allow|deny \\\n --filesystem read-only|workspace|unrestricted \\\n --unattended deny|wait \\\n --bio-file /path/bio.md --persona-file /path/persona.md\n```\n\nPermanent spawn writes `~/fleet.d/Name.yaml` and starts a supervised role.\n`--temp` writes ephemeral state, starts a detached supervisor, and removes the\nrole after exit/reboot. Both lifetimes support `--session acp`.\n\nCodex-specific spawn flags: `--sandbox`, `--permission-mode`, `--launcher`,\n`--profile`, `--search`, repeatable `--codex-config key=value`, repeatable\n`--add-dir`, and legacy `--monitor` (consent for the native Codex monitor,\nnot the `monitor.mode` wake-owner selector). Run `ours-fleet help spawn` for\nexact values.\n\n## fleet.yaml\n\n```yaml\nvars:\n work_root: /home/me/work\nstart_stagger_ms: 0\ndefaults:\n harness: codex\n session: acp\n model: gpt-model-id\n permissions:\n approval: ask\n filesystem: workspace\n unattended: deny\n monitor:\n mode: fleet # fleet (default) | native\nroles:\n Coordinator:\n harness: codex\n session: acp\n identity: Coordinator\n cwd: ${work_root}/project\n mission: Coordinate work and delegate implementation.\n model: gpt-model-id\n permissions:\n approval: ask\n filesystem: workspace\n unattended: deny\n session_options: # advanced overrides; normally omit\n # acp:\n # command: [/custom/codex-acp, --flag]\n tmux:\n boot_grace_ms: 10000\n monitor:\n mode: fleet # fleet supervisor | native harness monitor\n interrupt: false # true cancels active work before every configured wake\n wake_sources: [message_received, file_received, local_contact_request, pending_message]\n batch_ms: 2000\n inject: notification\n turn_fail_threshold: 3\n harness_options:\n launcher: auto\n sandbox: workspace-write\n approval: on-request\n search: false\n profile: fleet\n add_dirs: [/data/shared]\n config:\n model_reasoning_effort: high\n bio: Public role card and when peers should engage it.\n persona: Local operating contract, boundaries, and escalation policy.\n briefing_file: /absolute/custom-briefing.md\n coordinator: AnotherCoordinator\n env:\n KEY: value\n oversee:\n - { role: Worker, interval: 5m }\n```\n\nRole values override defaults. `${name}` substitutes entries from `vars`.\nOther role fields include `max_tokens`, `autocompact_pct`, and `isolation`.\nUse README.md for the complete isolation policy and resource-cap schema.\n\n## Permissions\n\nPrefer the harness-neutral `permissions` block:\n\n- `approval: ask|allow|deny`: whether actions may request or receive approval\n- `filesystem: read-only|workspace|unrestricted`: filesystem intent\n- `unattended: deny|wait`: what ACP does when no console can answer a request\n\nThe backend translates this common intent. Harness-native settings in\n`harness_options` take precedence where supplied. Do not choose\n`allow`/`unrestricted`, Codex `never`/`danger-full-access`, or Claude\n`bypassPermissions` without explicit authorization.\n\n### Creation-time isolation\n\n`ours-fleet spawn --isolation-file <path>` supplies a role's sandbox policy at\ncreation, so the FIRST launch is already confined \u2014 a role that only gains\n`isolation:` on a later `up` ran unsandboxed until then.\n\nThe file holds exactly the `isolation:` mapping documented above and nothing\nelse \u2014 the same schema, validated by the same code, so a policy written here\ncannot mean something different from the identical block in fleet.yaml:\n\n```yaml\nnetwork: deny\nfs:\n read: [/opt/reference]\nresources:\n mem: 2G\n```\n\nInvalid files are rejected before anything is created: no config, no state\ndirectory, no identity reservation. Works for both permanent and `--temp` roles.\n\n### Never-prompt failure\n\nThe failure this section exists to prevent leaves no error message anywhere.\n\nAn unattended role has no console. When the harness needs a permission decision\nthere is nobody to ask, so the request is refused INSIDE the harness \u2014 no\nprompt, no error, no log line. The agent simply does less than its briefing told\nit to, reports success, and nothing distinguishes that from having done the\nwork. Two settings produce it:\n\n1. a permission mode that suppresses the prompt without granting the action\n (Claude `dontAsk`, which is why neutral `allow` maps to\n `bypassPermissions` instead); and\n2. `unattended: deny`, which refuses every request that reaches it.\n\n**Automatic decisions are now recorded.** Every permission request decided\nwithout a human emits a completed event into\n`~/.ours-fleet/agents/<Name>/.session-events.jsonl` carrying the decision,\nwhether policy or a person made it, the policy that produced it\n(`permissions.unattended=deny` vs `permissions.approval=deny`/`=allow`),\nthe reason, and the option selected. `ours-fleet peek` and `attach` render\nthem. Automatic denial asks for a one-shot rejection, never a standing one, so a\nsingle unattended refusal cannot disable a tool for the rest of the session.\n\nA role that can auto-deny logs one line at startup saying so.\n\nTo detect an under-permissioned role BEFORE it runs, use the capability floor\nbelow: `ours-fleet doctor` fails such a role rather than letting it discover\nthe problem silently at work.\n\n### The unattended capability floor\n\nAn unattended role has no console, so a permission request cannot be answered \u2014\nit is refused, silently, inside the harness. The agent then does less than it\nwas told to and reports no error. To make that visible before launch,\n`ours-fleet config` and `ours-fleet doctor` resolve each role's neutral\npermissions through its harness and check the result against a fixed floor:\n\n- `read-state` \u2014 read its briefing, ROUTINES.md, and WORKLOG.md\n- `write-state` \u2014 append its WORKLOG and its own state files\n- `messaging` \u2014 bind its identity, send and receive ours mail\n- `monitor` \u2014 arm and observe its mail monitor\n- `workspace-edit` \u2014 edit and test files in its working directory\n- `status-commands` \u2014 run the inspection commands its briefing prescribes\n\n`doctor` reports this per role as `unattended floor: <Role>`. A role with\n`unattended: deny` that cannot meet the floor FAILS doctor, because it will\ndeny those requests with nobody to see it; with `unattended: wait` it warns,\nbecause a human can still attach and answer.\n\nSecurity meaning: `approval: allow` maps to Claude's `bypassPermissions`,\nwhich genuinely permits the actions the role was authorized to take \u2014\n`dontAsk` only suppresses the prompt while still refusing the action. Nothing\nother than an explicit `allow` is elevated: `ask` stays on Claude's default\nmode and `deny` maps to `plan`. `allow` is therefore a real grant and\nrequires explicit authorization; per-role `isolation:` remains the outer\nboundary that a permission mode cannot cross.\n\nSee also: `spawn --approval/--filesystem/--unattended` set this intent at\ncreation, and `ours-fleet config` prints each role's neutral settings, their\nnative translation, and any warning \u2014 the same text `doctor` reports.\n\nClaude `harness_options`: `permission_mode` (default, acceptEdits, plan,\ndontAsk, bypassPermissions), `plugins`, `mem_palace`, and\n`mem_palace_midsession_autosave`.\n\nCodex `harness_options`: `launcher` (auto, ours-codex, codex), `sandbox`\n(read-only, workspace-write, danger-full-access), `approval` or\n`permission_mode` (untrusted, on-request, never), `profile`, `search`,\n`config`, `add_dirs`, and `monitor`.\n\n## ACP adapters\n\nThe maintained `@agentclientprotocol/codex-acp` and\n`@agentclientprotocol/claude-agent-acp` runtimes are bundled automatically as\noptional ours-fleet dependencies. The supervisor resolves their executable\nentrypoints internally, so default ACP roles do not depend on global PATH.\nThe maintained Claude adapter requires Node 22; tmux and Codex ACP continue to\nwork on the ours-fleet core minimum of Node 20.\n\nOverride an adapter only when necessary with `session_options.acp.command`\n(string or argv list). If optional dependencies were deliberately omitted,\nours-fleet falls back to a compatible globally installed `codex-acp` or\n`claude-agent-acp`. `ours-fleet doctor -c FILE` verifies the resolved adapter.\n\n## Reliable mail wake\n\n`monitor.mode` selects exactly one wake owner:\n\n- `fleet` (default): the ours-fleet supervisor consumes body-free daemon\n events and advances its durable cursor only after delivery is accepted. ACP\n uses live steering when supported and falls back to structured\n `session/prompt`; tmux uses verified console injection.\n- `native`: ours-fleet starts no supervisor monitor; the generated briefing\n instructs Claude Code or Codex to arm its harness-native wake mechanism.\n\nSet `monitor.interrupt: true` in fleet mode to cancel active work before every\nconfigured wake. The policy is content-blind because the supervisor cannot\ninspect encrypted message bodies. Message bodies are released only when the\nrole calls the ours `get_messages` tool.\n\nLegacy `monitor.enabled: true|false` remains accepted as an alias for\n`mode: fleet|native`; use `mode` in new configuration. Codex's separate\n`harness_options.monitor: true` is native-monitor consent, not monitor-owner\nselection.\nInspect `ours-fleet status Name`, `peek Name`, role logs, and\n`~/.ours-fleet/agents/Name/.monitor-status` when diagnosing delivery.\n\n## Stable config and YAML migration\n\n`ours-fleet config --json` emits schemaVersion 1 resolved plans. Environment\nvalues and mission/persona/bio bodies are withheld; environment keys are sorted\nand values are marked redacted. Additive fields may appear in schema 1, while a\nremoval or semantic reuse requires a new schema version.\n\nYAML parsing always rejects duplicate keys. The current default\n`--yaml-mode compat` warns with file/line/column for anchors, aliases, explicit\ntags, non-scalar keys, and multiple documents. Use `--yaml-mode strict` in CI\nnow; strict becomes the next-major default and compat is the temporary migration\nescape hatch.\n\n## Bounded worklogs, auth proxy, and model recovery\n\nAn optional `worklog: { max_kb, keep_tail_kb, max_archives }` policy rotates a\nstable snapshot at fleet-owned lifecycle points. Concurrent changes defer\nrotation. Archives remain beside WORKLOG.md with the same sensitive-state\nboundary; retention deletes only recognized fleet archive names.\n\n`auth_proxy: { kind: anthropic, base_url, required, health_url }` is Claude-only\nand loopback-only. Fleet injects only ANTHROPIC_BASE_URL and doctor rejects\ncredential env keys. The privileged reference companion is\n`contrib/anthropic-auth-proxy.mjs`; deploy it separately as a dedicated account\nwith a 0600 token file and per-role listener access. Fleet never installs it or\nreads its credential.\n\n`model_chain` is an ordered authorization list and its first entry must equal\n`model`. Only sustained high-confidence entitlement/quota 429 evidence advances\none entry. Transient 429, overload, auth, policy, and unknown errors never\ndown-shift. Runtime state is atomic in .model-recovery.json; exhaustion is\nfail-closed and held down. Change the declared chain/model and restart to\nreconcile explicitly; no chain preserves detection-only behavior.\n";
|
|
7
|
+
export declare const AI_DOCS = "# ours-fleet reference\n\nours-fleet runs persistent or temporary, identity-bound AI roles. A role selects\na harness independently from its session backend:\n\n- harness: `claude-code` or `codex`\n- session: `tmux` (default) or `acp`\n- lifetime: permanent (supervised, restartable) or `spawn --temp`\n\n## Discover and validate\n\n```sh\nours-fleet docs # this complete reference (`man` is an alias)\nours-fleet help <command> # exact flags for one command\nours-fleet config [-c FILE] # validate and print the merged plan; no changes\nours-fleet doctor [-c FILE] [--harness codex|claude-code]\n```\n\nDefault configuration is `~/fleet.yaml` plus sorted `~/fleet.d/*.yaml` role\ndrop-ins. An explicit `-c FILE` replaces `~/fleet.yaml`; fleet.d still adds\nroles. Validate with `config` and `doctor` before starting or restarting.\n\n## Lifecycle and console commands\n\n```sh\nours-fleet init\nours-fleet up|down [Name...]\nours-fleet restart [Name...] # preserve/resume harness context\nours-fleet force-restart [Name...] # fresh context; briefing is reloaded\nours-fleet ls\nours-fleet status|peek|attach|logs Name\nours-fleet logs -f Name\nours-fleet send Name \"prompt\"\nours-fleet send Name --key Enter # tmux only\nours-fleet rm Name\nours-fleet watchdog-report <name> [run-id] [--list] [--json]\nours-fleet watchdog-run <name>\n```\n\n`peek`, `attach`, and text `send` work with tmux and ACP. ACP attachment\nalso accepts `/permit <permission-id> <option-id>`, `/interrupt`, and\n`/detach`. Raw `--key` input is tmux-only.\n\n## Local web console\n\nThe npm package includes the web console; installed users do not clone the repo\nor run `npm run build`:\n\n```sh\nnpm i -g @ours.network/fleet\nours-fleet init\nours-fleet doctor\nours-fleet web # install/update service, start, pair browser\n```\n\nThe normal command uses stable `http://127.0.0.1:49271/`, installs an\nowner-level systemd user service (Linux) or LaunchAgent (macOS), and opens a\nfive-minute one-use pairing link in the local browser. After pairing, bookmark\nthe plain URL or install the PWA. To pair a new, signed-out, or revoked browser,\nrun `ours-fleet web open`.\n\n```sh\nours-fleet web status\nours-fleet web start|stop|restart\nours-fleet web open\nours-fleet web revoke-all # revoke every browser and active session\nours-fleet web uninstall\nours-fleet web serve --port 0 --no-open # isolated foreground/testing mode\n```\n\nThe console is intentionally IPv4-loopback-only. It has no LAN/Internet host,\nproxy, TLS, or remote-access mode. Do not expose port 49271 through a reverse\nproxy. Browser credentials are HttpOnly/SameSite, and `revoke-all` invalidates\nall trusted devices. Role creation offers harness-scoped known-model choices\nwhile still accepting a typed model ID; blank explicitly uses the selected\nharness's own default.\n\n## Spawn\n\n```sh\nours-fleet spawn [--temp] Name \\\n --harness codex|claude-code --session tmux|acp \\\n --mission \"one line\" --cwd /absolute/path --identity Identity \\\n --coordinator Coordinator --model MODEL \\\n --approval ask|allow|deny \\\n --filesystem read-only|workspace|unrestricted \\\n --unattended deny|wait \\\n --bio-file /path/bio.md --persona-file /path/persona.md\n```\n\nPermanent spawn writes `~/fleet.d/Name.yaml` and starts a supervised role.\n`--temp` writes ephemeral state, starts a detached supervisor, and removes the\nrole after exit/reboot. Both lifetimes support `--session acp`.\n\nCodex-specific spawn flags: `--sandbox`, `--permission-mode`, `--launcher`,\n`--profile`, `--search`, repeatable `--codex-config key=value`, repeatable\n`--add-dir`, and legacy `--monitor` (consent for the native Codex monitor,\nnot the `monitor.mode` wake-owner selector). Run `ours-fleet help spawn` for\nexact values.\n\n## fleet.yaml\n\n```yaml\nvars:\n work_root: /home/me/work\nstart_stagger_ms: 0\ndefaults:\n harness: codex\n session: acp\n model: gpt-model-id\n permissions:\n approval: ask\n filesystem: workspace\n unattended: deny\n monitor:\n mode: fleet # fleet (default) | native\nroles:\n Coordinator:\n harness: codex\n session: acp\n identity: Coordinator\n cwd: ${work_root}/project\n mission: Coordinate work and delegate implementation.\n model: gpt-model-id\n permissions:\n approval: ask\n filesystem: workspace\n unattended: deny\n session_options: # advanced overrides; normally omit\n # acp:\n # command: [/custom/codex-acp, --flag]\n tmux:\n boot_grace_ms: 10000\n monitor:\n mode: fleet # fleet supervisor | native harness monitor\n interrupt: false # true cancels active work before every configured wake\n wake_sources: [message_received, file_received, local_contact_request, pending_message]\n batch_ms: 2000\n inject: notification\n turn_fail_threshold: 3\n harness_options:\n launcher: auto\n sandbox: workspace-write\n approval: on-request\n search: false\n profile: fleet\n add_dirs: [/data/shared]\n config:\n model_reasoning_effort: high\n bio: Public role card and when peers should engage it.\n persona: Local operating contract, boundaries, and escalation policy.\n briefing_file: /absolute/custom-briefing.md\n coordinator: AnotherCoordinator\n env:\n KEY: value\n oversee:\n - { role: Worker, interval: 5m }\nwatchdogs:\n nightwatch: # [A-Za-z0-9_-], must not collide with a role name\n coordinator: FleetCoordinator # required \u2014 where alerts go\n # everything below is optional\n enabled: true # default true; false = configured but never scheduled\n interval: 10m # default 10m; 30s | 10m | 2h, minimum 1m\n watch: [Alice, CodexReviewer] # default: every role in the merged config\n harness: claude-code # default: defaults.harness\n model: claude-fable-5 # default: same resolution rule roles use (resolveRoleModel)\n session: acp # default: defaults.session\n identity: Watchdog-nightwatch # default: Watchdog-<name>\n timeout: 5m # default 5m; a run past this is killed and recorded as error\n keep_reports: 50 # default 50 reports retained per watchdog\n alert_cooldown: 60m # default 60m before the same finding alerts again\n prompt_file: /abs/extra.md # optional extra focus, APPENDED to the fixed contract\n```\n\nA watchdog observes and reports; it never restarts, stops, spawns, or removes a\nrole, answers a pending permission, edits a workspace, or approves anything on\nthe owner's behalf. `watchdogs:` may appear only in the base config\n(`~/fleet.yaml` or `-c FILE`), not in `~/fleet.d/*.yaml` drop-ins.\n\nRole values override defaults. `${name}` substitutes entries from `vars`.\nOther role fields include `max_tokens`, `autocompact_pct`, and `isolation`.\nUse README.md for the complete isolation policy and resource-cap schema.\n\n## Permissions\n\nPrefer the harness-neutral `permissions` block:\n\n- `approval: ask|allow|deny`: whether actions may request or receive approval\n- `filesystem: read-only|workspace|unrestricted`: filesystem intent\n- `unattended: deny|wait`: what ACP does when no console can answer a request\n\nThe backend translates this common intent. Harness-native settings in\n`harness_options` take precedence where supplied. Do not choose\n`allow`/`unrestricted`, Codex `never`/`danger-full-access`, or Claude\n`bypassPermissions` without explicit authorization.\n\n### Creation-time isolation\n\n`ours-fleet spawn --isolation-file <path>` supplies a role's sandbox policy at\ncreation, so the FIRST launch is already confined \u2014 a role that only gains\n`isolation:` on a later `up` ran unsandboxed until then.\n\nThe file holds exactly the `isolation:` mapping documented above and nothing\nelse \u2014 the same schema, validated by the same code, so a policy written here\ncannot mean something different from the identical block in fleet.yaml:\n\n```yaml\nnetwork: deny\nfs:\n read: [/opt/reference]\nresources:\n mem: 2G\n```\n\nInvalid files are rejected before anything is created: no config, no state\ndirectory, no identity reservation. Works for both permanent and `--temp` roles.\n\n### Never-prompt failure\n\nThe failure this section exists to prevent leaves no error message anywhere.\n\nAn unattended role has no console. When the harness needs a permission decision\nthere is nobody to ask, so the request is refused INSIDE the harness \u2014 no\nprompt, no error, no log line. The agent simply does less than its briefing told\nit to, reports success, and nothing distinguishes that from having done the\nwork. Two settings produce it:\n\n1. a permission mode that suppresses the prompt without granting the action\n (Claude `dontAsk`, which is why neutral `allow` maps to\n `bypassPermissions` instead); and\n2. `unattended: deny`, which refuses every request that reaches it.\n\n**Automatic decisions are now recorded.** Every permission request decided\nwithout a human emits a completed event into\n`~/.ours-fleet/agents/<Name>/.session-events.jsonl` carrying the decision,\nwhether policy or a person made it, the policy that produced it\n(`permissions.unattended=deny` vs `permissions.approval=deny`/`=allow`),\nthe reason, and the option selected. `ours-fleet peek` and `attach` render\nthem. Automatic denial asks for a one-shot rejection, never a standing one, so a\nsingle unattended refusal cannot disable a tool for the rest of the session.\n\nA role that can auto-deny logs one line at startup saying so.\n\nTo detect an under-permissioned role BEFORE it runs, use the capability floor\nbelow: `ours-fleet doctor` fails such a role rather than letting it discover\nthe problem silently at work.\n\n### The unattended capability floor\n\nAn unattended role has no console, so a permission request cannot be answered \u2014\nit is refused, silently, inside the harness. The agent then does less than it\nwas told to and reports no error. To make that visible before launch,\n`ours-fleet config` and `ours-fleet doctor` resolve each role's neutral\npermissions through its harness and check the result against a fixed floor:\n\n- `read-state` \u2014 read its briefing, ROUTINES.md, and WORKLOG.md\n- `write-state` \u2014 append its WORKLOG and its own state files\n- `messaging` \u2014 bind its identity, send and receive ours mail\n- `monitor` \u2014 arm and observe its mail monitor\n- `workspace-edit` \u2014 edit and test files in its working directory\n- `status-commands` \u2014 run the inspection commands its briefing prescribes\n\n`doctor` reports this per role as `unattended floor: <Role>`. A role with\n`unattended: deny` that cannot meet the floor FAILS doctor, because it will\ndeny those requests with nobody to see it; with `unattended: wait` it warns,\nbecause a human can still attach and answer.\n\nSecurity meaning: `approval: allow` maps to Claude's `bypassPermissions`,\nwhich genuinely permits the actions the role was authorized to take \u2014\n`dontAsk` only suppresses the prompt while still refusing the action. Nothing\nother than an explicit `allow` is elevated: `ask` stays on Claude's default\nmode and `deny` maps to `plan`. `allow` is therefore a real grant and\nrequires explicit authorization; per-role `isolation:` remains the outer\nboundary that a permission mode cannot cross.\n\nSee also: `spawn --approval/--filesystem/--unattended` set this intent at\ncreation, and `ours-fleet config` prints each role's neutral settings, their\nnative translation, and any warning \u2014 the same text `doctor` reports.\n\nClaude `harness_options`: `permission_mode` (default, acceptEdits, plan,\ndontAsk, bypassPermissions), `plugins`, `mem_palace`, and\n`mem_palace_midsession_autosave`.\n\nCodex `harness_options`: `launcher` (auto, ours-codex, codex), `sandbox`\n(read-only, workspace-write, danger-full-access), `approval` or\n`permission_mode` (untrusted, on-request, never), `profile`, `search`,\n`config`, `add_dirs`, and `monitor`.\n\n## ACP adapters\n\nThe maintained `@agentclientprotocol/codex-acp` and\n`@agentclientprotocol/claude-agent-acp` runtimes are bundled automatically as\noptional ours-fleet dependencies. The supervisor resolves their executable\nentrypoints internally, so default ACP roles do not depend on global PATH.\nThe maintained Claude adapter requires Node 22; tmux and Codex ACP continue to\nwork on the ours-fleet core minimum of Node 20.\n\nOverride an adapter only when necessary with `session_options.acp.command`\n(string or argv list). If optional dependencies were deliberately omitted,\nours-fleet falls back to a compatible globally installed `codex-acp` or\n`claude-agent-acp`. `ours-fleet doctor -c FILE` verifies the resolved adapter.\n\n## Reliable mail wake\n\n`monitor.mode` selects exactly one wake owner:\n\n- `fleet` (default): the ours-fleet supervisor consumes body-free daemon\n events and advances its durable cursor only after delivery is accepted. ACP\n uses live steering when supported and falls back to structured\n `session/prompt`; tmux uses verified console injection.\n- `native`: ours-fleet starts no supervisor monitor; the generated briefing\n instructs Claude Code or Codex to arm its harness-native wake mechanism.\n\nSet `monitor.interrupt: true` in fleet mode to cancel active work before every\nconfigured wake. The policy is content-blind because the supervisor cannot\ninspect encrypted message bodies. Message bodies are released only when the\nrole calls the ours `get_messages` tool.\n\nLegacy `monitor.enabled: true|false` remains accepted as an alias for\n`mode: fleet|native`; use `mode` in new configuration. Codex's separate\n`harness_options.monitor: true` is native-monitor consent, not monitor-owner\nselection.\nInspect `ours-fleet status Name`, `peek Name`, role logs, and\n`~/.ours-fleet/agents/Name/.monitor-status` when diagnosing delivery.\n\n## Stable config and YAML migration\n\n`ours-fleet config --json` emits schemaVersion 1 resolved plans. Environment\nvalues and mission/persona/bio bodies are withheld; environment keys are sorted\nand values are marked redacted. Additive fields may appear in schema 1, while a\nremoval or semantic reuse requires a new schema version.\n\nYAML parsing always rejects duplicate keys. The current default\n`--yaml-mode compat` warns with file/line/column for anchors, aliases, explicit\ntags, non-scalar keys, and multiple documents. Use `--yaml-mode strict` in CI\nnow; strict becomes the next-major default and compat is the temporary migration\nescape hatch.\n\n## Bounded worklogs, auth proxy, and model recovery\n\nAn optional `worklog: { max_kb, keep_tail_kb, max_archives }` policy rotates a\nstable snapshot at fleet-owned lifecycle points. Concurrent changes defer\nrotation. Archives remain beside WORKLOG.md with the same sensitive-state\nboundary; retention deletes only recognized fleet archive names.\n\n`auth_proxy: { kind: anthropic, base_url, required, health_url }` is Claude-only\nand loopback-only. Fleet injects only ANTHROPIC_BASE_URL and doctor rejects\ncredential env keys. The privileged reference companion is\n`contrib/anthropic-auth-proxy.mjs`; deploy it separately as a dedicated account\nwith a 0600 token file and per-role listener access. Fleet never installs it or\nreads its credential.\n\n`model_chain` is an ordered authorization list and its first entry must equal\n`model`. Only sustained high-confidence entitlement/quota 429 evidence advances\none entry. Transient 429, overload, auth, policy, and unknown errors never\ndown-shift. Runtime state is atomic in .model-recovery.json; exhaustion is\nfail-closed and held down. Change the declared chain/model and restart to\nreconcile explicitly; no chain preserves detection-only behavior.\n";
|
|
8
8
|
/**
|
|
9
9
|
* What every shipped spawn-skill variant must say, and must not say (7.1).
|
|
10
10
|
*
|
package/dist/docs.js
CHANGED
|
@@ -39,12 +39,48 @@ ours-fleet logs -f Name
|
|
|
39
39
|
ours-fleet send Name "prompt"
|
|
40
40
|
ours-fleet send Name --key Enter # tmux only
|
|
41
41
|
ours-fleet rm Name
|
|
42
|
+
ours-fleet watchdog-report <name> [run-id] [--list] [--json]
|
|
43
|
+
ours-fleet watchdog-run <name>
|
|
42
44
|
\`\`\`
|
|
43
45
|
|
|
44
46
|
\`peek\`, \`attach\`, and text \`send\` work with tmux and ACP. ACP attachment
|
|
45
47
|
also accepts \`/permit <permission-id> <option-id>\`, \`/interrupt\`, and
|
|
46
48
|
\`/detach\`. Raw \`--key\` input is tmux-only.
|
|
47
49
|
|
|
50
|
+
## Local web console
|
|
51
|
+
|
|
52
|
+
The npm package includes the web console; installed users do not clone the repo
|
|
53
|
+
or run \`npm run build\`:
|
|
54
|
+
|
|
55
|
+
\`\`\`sh
|
|
56
|
+
npm i -g @ours.network/fleet
|
|
57
|
+
ours-fleet init
|
|
58
|
+
ours-fleet doctor
|
|
59
|
+
ours-fleet web # install/update service, start, pair browser
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
The normal command uses stable \`http://127.0.0.1:49271/\`, installs an
|
|
63
|
+
owner-level systemd user service (Linux) or LaunchAgent (macOS), and opens a
|
|
64
|
+
five-minute one-use pairing link in the local browser. After pairing, bookmark
|
|
65
|
+
the plain URL or install the PWA. To pair a new, signed-out, or revoked browser,
|
|
66
|
+
run \`ours-fleet web open\`.
|
|
67
|
+
|
|
68
|
+
\`\`\`sh
|
|
69
|
+
ours-fleet web status
|
|
70
|
+
ours-fleet web start|stop|restart
|
|
71
|
+
ours-fleet web open
|
|
72
|
+
ours-fleet web revoke-all # revoke every browser and active session
|
|
73
|
+
ours-fleet web uninstall
|
|
74
|
+
ours-fleet web serve --port 0 --no-open # isolated foreground/testing mode
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
The console is intentionally IPv4-loopback-only. It has no LAN/Internet host,
|
|
78
|
+
proxy, TLS, or remote-access mode. Do not expose port 49271 through a reverse
|
|
79
|
+
proxy. Browser credentials are HttpOnly/SameSite, and \`revoke-all\` invalidates
|
|
80
|
+
all trusted devices. Role creation offers harness-scoped known-model choices
|
|
81
|
+
while still accepting a typed model ID; blank explicitly uses the selected
|
|
82
|
+
harness's own default.
|
|
83
|
+
|
|
48
84
|
## Spawn
|
|
49
85
|
|
|
50
86
|
\`\`\`sh
|
|
@@ -125,8 +161,28 @@ roles:
|
|
|
125
161
|
KEY: value
|
|
126
162
|
oversee:
|
|
127
163
|
- { role: Worker, interval: 5m }
|
|
164
|
+
watchdogs:
|
|
165
|
+
nightwatch: # [A-Za-z0-9_-], must not collide with a role name
|
|
166
|
+
coordinator: FleetCoordinator # required — where alerts go
|
|
167
|
+
# everything below is optional
|
|
168
|
+
enabled: true # default true; false = configured but never scheduled
|
|
169
|
+
interval: 10m # default 10m; 30s | 10m | 2h, minimum 1m
|
|
170
|
+
watch: [Alice, CodexReviewer] # default: every role in the merged config
|
|
171
|
+
harness: claude-code # default: defaults.harness
|
|
172
|
+
model: claude-fable-5 # default: same resolution rule roles use (resolveRoleModel)
|
|
173
|
+
session: acp # default: defaults.session
|
|
174
|
+
identity: Watchdog-nightwatch # default: Watchdog-<name>
|
|
175
|
+
timeout: 5m # default 5m; a run past this is killed and recorded as error
|
|
176
|
+
keep_reports: 50 # default 50 reports retained per watchdog
|
|
177
|
+
alert_cooldown: 60m # default 60m before the same finding alerts again
|
|
178
|
+
prompt_file: /abs/extra.md # optional extra focus, APPENDED to the fixed contract
|
|
128
179
|
\`\`\`
|
|
129
180
|
|
|
181
|
+
A watchdog observes and reports; it never restarts, stops, spawns, or removes a
|
|
182
|
+
role, answers a pending permission, edits a workspace, or approves anything on
|
|
183
|
+
the owner's behalf. \`watchdogs:\` may appear only in the base config
|
|
184
|
+
(\`~/fleet.yaml\` or \`-c FILE\`), not in \`~/fleet.d/*.yaml\` drop-ins.
|
|
185
|
+
|
|
130
186
|
Role values override defaults. \`\${name}\` substitutes entries from \`vars\`.
|
|
131
187
|
Other role fields include \`max_tokens\`, \`autocompact_pct\`, and \`isolation\`.
|
|
132
188
|
Use README.md for the complete isolation policy and resource-cap schema.
|
package/dist/duration.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Parse `30s | 10m | 2h` duration strings to milliseconds (spec §2). */
|
|
2
|
+
const UNIT_MS = { s: 1_000, m: 60_000, h: 3_600_000 };
|
|
3
|
+
const RE = /^(\d+)([smh])$/;
|
|
4
|
+
export function parseDuration(text, opts = {}) {
|
|
5
|
+
const label = opts.name ?? 'duration';
|
|
6
|
+
const m = RE.exec(text);
|
|
7
|
+
if (!m)
|
|
8
|
+
throw new Error(`${label}: invalid duration '${text}' (expected e.g. 30s, 10m, 2h)`);
|
|
9
|
+
const ms = Number(m[1]) * UNIT_MS[m[2]];
|
|
10
|
+
if (opts.minMs !== undefined && ms < opts.minMs)
|
|
11
|
+
throw new Error(`${label}: '${text}' is below the minimum ${formatDuration(opts.minMs)}`);
|
|
12
|
+
return ms;
|
|
13
|
+
}
|
|
14
|
+
export function formatDuration(ms) {
|
|
15
|
+
if (ms % 3_600_000 === 0 && ms >= 3_600_000)
|
|
16
|
+
return `${ms / 3_600_000}h`;
|
|
17
|
+
if (ms % 60_000 === 0 && ms >= 60_000)
|
|
18
|
+
return `${ms / 60_000}m`;
|
|
19
|
+
return `${Math.round(ms / 1_000)}s`;
|
|
20
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,16 @@ export { generateBriefing } from './briefing.js';
|
|
|
11
11
|
export { pickBackend } from './supervisor/index.js';
|
|
12
12
|
export type { SupervisorBackend } from './supervisor/types.js';
|
|
13
13
|
export { up, down, restartRoles, rmRole, applyRole } from './ops.js';
|
|
14
|
-
export { spawnPermanent, spawnTemp } from './spawn.js';
|
|
14
|
+
export { spawnPermanent, spawnTemp, buildRoleConfig, profileValues, validateSpawnOpts, } from './spawn.js';
|
|
15
|
+
export { RoleRepository } from './application/role-repository.js';
|
|
16
|
+
export { FleetQueryService } from './application/fleet-query-service.js';
|
|
17
|
+
export { AcpRoleSessionAdapter, TmuxRoleSessionAdapter } from './application/session-control.js';
|
|
18
|
+
export { RoleCreationService } from './application/role-creation-service.js';
|
|
19
|
+
export { RoleCommandService } from './application/role-command-service.js';
|
|
20
|
+
export { StructuredLogService } from './application/log-service.js';
|
|
21
|
+
export { roleCapabilities } from './application/capabilities.js';
|
|
22
|
+
export { FleetError, normalizeError } from './application/errors.js';
|
|
23
|
+
export type * from './application/types.js';
|
|
15
24
|
export { doctor } from './doctor.js';
|
|
16
25
|
export { runOnce, runTemp } from './runner.js';
|
|
17
26
|
export { Tmux } from './tmux.js';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,15 @@ export { codexAdapter, makeCodexAdapter } from './harness/codex.js';
|
|
|
7
7
|
export { generateBriefing } from './briefing.js';
|
|
8
8
|
export { pickBackend } from './supervisor/index.js';
|
|
9
9
|
export { up, down, restartRoles, rmRole, applyRole } from './ops.js';
|
|
10
|
-
export { spawnPermanent, spawnTemp } from './spawn.js';
|
|
10
|
+
export { spawnPermanent, spawnTemp, buildRoleConfig, profileValues, validateSpawnOpts, } from './spawn.js';
|
|
11
|
+
export { RoleRepository } from './application/role-repository.js';
|
|
12
|
+
export { FleetQueryService } from './application/fleet-query-service.js';
|
|
13
|
+
export { AcpRoleSessionAdapter, TmuxRoleSessionAdapter } from './application/session-control.js';
|
|
14
|
+
export { RoleCreationService } from './application/role-creation-service.js';
|
|
15
|
+
export { RoleCommandService } from './application/role-command-service.js';
|
|
16
|
+
export { StructuredLogService } from './application/log-service.js';
|
|
17
|
+
export { roleCapabilities } from './application/capabilities.js';
|
|
18
|
+
export { FleetError, normalizeError } from './application/errors.js';
|
|
11
19
|
export { doctor } from './doctor.js';
|
|
12
20
|
export { runOnce, runTemp } from './runner.js';
|
|
13
21
|
export { Tmux } from './tmux.js';
|
package/dist/ops.d.ts
CHANGED
|
@@ -16,6 +16,22 @@ export interface OpsDeps {
|
|
|
16
16
|
* `ours-fleet up` has no transaction to tell.
|
|
17
17
|
*/
|
|
18
18
|
onInstalled?(outcome: InstallOutcome): void;
|
|
19
|
+
/**
|
|
20
|
+
* Optional: supervises the single watchdog-scheduler process (Task 10).
|
|
21
|
+
* Absent for callers that predate watchdogs — `up`/`down` must never throw
|
|
22
|
+
* just because this hook is missing.
|
|
23
|
+
*/
|
|
24
|
+
watchdogService?: {
|
|
25
|
+
/** `changed` is true when the unit/plist content itself differs from what's on disk (or was absent). */
|
|
26
|
+
install(binPath: string, configPath?: string): Promise<{
|
|
27
|
+
changed: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
stop(): Promise<void>;
|
|
31
|
+
/** Bounces an already-running scheduler so a config change actually reaches it — `start()` is a no-op on an active unit. */
|
|
32
|
+
restart(): Promise<void>;
|
|
33
|
+
supervised(): boolean;
|
|
34
|
+
};
|
|
19
35
|
}
|
|
20
36
|
/** Materialize a role's state dir from config: briefing + markers. Returns the dir. */
|
|
21
37
|
export declare function applyRole(role: ResolvedRole, opts?: {
|
package/dist/ops.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync, unlinkSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync, unlinkSync, } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { agentDir, fleetDDir } from './paths.js';
|
|
3
|
+
import { randomUUID, createHash } from 'node:crypto';
|
|
4
|
+
import { agentDir, fleetDDir, watchdogsRoot } from './paths.js';
|
|
5
5
|
import { findRole } from './config.js';
|
|
6
6
|
import { getAdapter } from './harness/registry.js';
|
|
7
7
|
import { generateBriefing } from './briefing.js';
|
|
@@ -75,8 +75,103 @@ export async function up(cfg, names, deps, configPath, identityGuarantee) {
|
|
|
75
75
|
outcomes.push(outcome);
|
|
76
76
|
deps.log(`↑ up: ${role.name} (harness: ${role.harness}, identity: ${role.identity}${role.cwd ? `, cwd: ${role.cwd}` : ''})`);
|
|
77
77
|
}
|
|
78
|
+
await reconcileWatchdogScheduler(cfg, deps, configPath);
|
|
78
79
|
return outcomes;
|
|
79
80
|
}
|
|
81
|
+
const WATCHDOG_FINGERPRINT_FILE = '.config-fingerprint';
|
|
82
|
+
/** Deterministic JSON: object keys sorted recursively, so key-insertion order never affects the hash. */
|
|
83
|
+
function stableStringify(value) {
|
|
84
|
+
return JSON.stringify(value, (_key, v) => {
|
|
85
|
+
if (v !== null && typeof v === 'object' && !Array.isArray(v)) {
|
|
86
|
+
return Object.keys(v).sort()
|
|
87
|
+
.reduce((acc, k) => { acc[k] = v[k]; return acc; }, {});
|
|
88
|
+
}
|
|
89
|
+
return v;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** sha256 over the resolved enabled-watchdog set, stable regardless of config source order (finding #4). */
|
|
93
|
+
function watchdogFingerprint(enabled) {
|
|
94
|
+
const sorted = [...enabled].sort((a, b) => a.name.localeCompare(b.name));
|
|
95
|
+
return createHash('sha256').update(stableStringify(sorted)).digest('hex');
|
|
96
|
+
}
|
|
97
|
+
function fingerprintPath() {
|
|
98
|
+
return join(watchdogsRoot(), WATCHDOG_FINGERPRINT_FILE);
|
|
99
|
+
}
|
|
100
|
+
function readStoredFingerprint() {
|
|
101
|
+
try {
|
|
102
|
+
return readFileSync(fingerprintPath(), 'utf8').trim();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function writeFingerprint(fingerprint) {
|
|
109
|
+
mkdirSync(watchdogsRoot(), { recursive: true, mode: 0o700 });
|
|
110
|
+
writeFileSync(fingerprintPath(), fingerprint + '\n', { mode: 0o600 });
|
|
111
|
+
chmodSync(fingerprintPath(), 0o600); // mkdirSync/writeFileSync's mode is masked by umask; force it
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Install/start (or stop) the single supervised watchdog-scheduler process
|
|
115
|
+
* (Task 10) to match the config's enabled watchdogs. Runs on every `up`,
|
|
116
|
+
* including a named `up <Role>` — cheap and idempotent, and the alternative
|
|
117
|
+
* (only reconciling on a whole-fleet `up`) would leave a newly-enabled
|
|
118
|
+
* watchdog unscheduled until the next bare `up`. Never throws: a scheduler
|
|
119
|
+
* hiccup must not fail the role installs that already succeeded.
|
|
120
|
+
*
|
|
121
|
+
* Restarts ONLY when something the scheduler actually needs to pick up
|
|
122
|
+
* changed (finding #4): an unconditional `restart()` on every `up` —
|
|
123
|
+
* including a named `up <SomeUnrelatedRole>` — interrupted whatever the
|
|
124
|
+
* scheduler was mid-run (a 15s stop timeout can kill a long check without a
|
|
125
|
+
* report). Two independent signals decide: `svc.install()`'s own `changed`
|
|
126
|
+
* (the unit/plist content — binPath/configPath — differs), and a config
|
|
127
|
+
* fingerprint over the resolved enabled-watchdog set (sha256, stored at
|
|
128
|
+
* `<watchdogsRoot>/.config-fingerprint`) — needed because interval/watch/etc.
|
|
129
|
+
* never appear in the unit content itself (the unit just re-execs `-c
|
|
130
|
+
* <configPath>`), so `install()` alone can never see them change. Either
|
|
131
|
+
* signal true -> restart(); neither -> the idempotent start() (a no-op if
|
|
132
|
+
* already active, otherwise brings up a stopped unit).
|
|
133
|
+
*/
|
|
134
|
+
async function reconcileWatchdogScheduler(cfg, deps, configPath) {
|
|
135
|
+
const svc = deps.watchdogService;
|
|
136
|
+
if (!svc)
|
|
137
|
+
return;
|
|
138
|
+
const enabled = cfg.watchdogs.filter(w => w.enabled);
|
|
139
|
+
try {
|
|
140
|
+
// Check supervised() before any stop (final review #3): on an
|
|
141
|
+
// unsupervised platform/config, the scheduler was never installed, so
|
|
142
|
+
// stopping it is not just a no-op — on Linux, stop() throws for a unit
|
|
143
|
+
// that was never loaded. A watchdog-less fleet must not see that
|
|
144
|
+
// failure surface as a spurious "! watchdogs scheduler: ..." warning.
|
|
145
|
+
if (!enabled.length) {
|
|
146
|
+
if (svc.supervised())
|
|
147
|
+
await svc.stop();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!svc.supervised()) {
|
|
151
|
+
deps.log("! watchdogs configured but OURS_FLEET_SUPERVISOR=none — run 'ours-fleet _run-watchdogs' in the foreground");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const { changed: unitChanged } = await svc.install(deps.binPath, configPath);
|
|
155
|
+
const fingerprint = watchdogFingerprint(enabled);
|
|
156
|
+
const fingerprintChanged = readStoredFingerprint() !== fingerprint;
|
|
157
|
+
if (unitChanged || fingerprintChanged) {
|
|
158
|
+
// restart(), not start(): start() is a no-op on an already-active unit,
|
|
159
|
+
// so a config change (new/changed watchdogs) would never reach a
|
|
160
|
+
// scheduler that's already running (final review #4).
|
|
161
|
+
await svc.restart();
|
|
162
|
+
deps.log(`↑ watchdogs scheduler (${enabled.map(w => w.name).join(', ')})`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Idempotent: a no-op on an already-active unit, but still brings up a
|
|
166
|
+
// stopped one (e.g. the scheduler crashed and systemd gave up retrying).
|
|
167
|
+
await svc.start();
|
|
168
|
+
}
|
|
169
|
+
writeFingerprint(fingerprint);
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
deps.log(` ! watchdogs scheduler: ${e instanceof Error ? e.message : String(e)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
80
175
|
export async function down(cfg, names, deps) {
|
|
81
176
|
for (const role of selectRoles(cfg, names)) {
|
|
82
177
|
// Never swallow the backend's reason. "maybe not running" hid real stop
|
|
@@ -89,6 +184,20 @@ export async function down(cfg, names, deps) {
|
|
|
89
184
|
deps.log(` ! could not stop ${role.name}: ${e instanceof Error ? e.message : String(e)}`);
|
|
90
185
|
}
|
|
91
186
|
}
|
|
187
|
+
// Only a whole-fleet `down` (no names) stops the scheduler — stopping one
|
|
188
|
+
// named role is not a decision to stop watching the others (tolerate
|
|
189
|
+
// absence/errors: a never-installed scheduler must not fail `down`).
|
|
190
|
+
// supervised() gates the call itself (final review #3): on an
|
|
191
|
+
// unsupervised platform/config there is nothing installed to stop, and
|
|
192
|
+
// Linux's stop() throws for a unit that was never loaded.
|
|
193
|
+
if (names.length === 0 && deps.watchdogService?.supervised()) {
|
|
194
|
+
try {
|
|
195
|
+
await deps.watchdogService.stop();
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
deps.log(` ! could not stop watchdogs scheduler: ${e instanceof Error ? e.message : String(e)}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
92
201
|
}
|
|
93
202
|
/** Re-sync from config + bounce. mode 'keep' resumes context; 'fresh' wipes it. */
|
|
94
203
|
export async function restartRoles(cfg, names, deps, mode, configPath) {
|
package/dist/paths.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const stateRoot: () => string;
|
|
|
14
14
|
export declare const agentsRoot: () => string;
|
|
15
15
|
export declare const tmpRoot: () => string;
|
|
16
16
|
export declare const logsRoot: () => string;
|
|
17
|
+
export declare const watchdogsRoot: () => string;
|
|
17
18
|
export declare const agentDir: (name: string, temp?: boolean) => string;
|
|
18
19
|
export declare const defaultConfigPath: () => string;
|
|
19
20
|
export declare const fleetDDir: () => string;
|
package/dist/paths.js
CHANGED
|
@@ -24,6 +24,7 @@ export const stateRoot = () => join(home(), '.ours-fleet');
|
|
|
24
24
|
export const agentsRoot = () => join(stateRoot(), 'agents');
|
|
25
25
|
export const tmpRoot = () => join(stateRoot(), 'tmp');
|
|
26
26
|
export const logsRoot = () => join(stateRoot(), 'logs');
|
|
27
|
+
export const watchdogsRoot = () => join(stateRoot(), 'watchdogs');
|
|
27
28
|
export const agentDir = (name, temp = false) => join(temp ? tmpRoot() : agentsRoot(), name);
|
|
28
29
|
export const defaultConfigPath = () => join(home(), 'fleet.yaml');
|
|
29
30
|
export const fleetDDir = () => join(home(), 'fleet.d');
|
package/dist/resolved-plan.js
CHANGED
|
@@ -20,6 +20,13 @@ export function resolvedPlan(cfg) {
|
|
|
20
20
|
startStaggerMs: cfg.startStaggerMs,
|
|
21
21
|
diagnostics: cfg.diagnostics.map(diagnostic => ({ ...diagnostic })),
|
|
22
22
|
roles: cfg.roles.map(resolvedRolePlan),
|
|
23
|
+
watchdogs: cfg.watchdogs.map(w => sortedObject({
|
|
24
|
+
name: w.name, sourceFile: w.sourceFile, enabled: w.enabled,
|
|
25
|
+
intervalMs: w.intervalMs, coordinator: w.coordinator, watch: [...w.watch],
|
|
26
|
+
harness: w.harness, session: w.session, model: w.model ?? null,
|
|
27
|
+
identity: w.identity, timeoutMs: w.timeoutMs, keepReports: w.keepReports,
|
|
28
|
+
alertCooldownMs: w.alertCooldownMs, promptFile: w.promptFile ?? null,
|
|
29
|
+
})),
|
|
23
30
|
};
|
|
24
31
|
}
|
|
25
32
|
export function resolvedRolePlan(role) {
|
package/dist/runner.js
CHANGED
|
@@ -60,8 +60,16 @@ export function recordMonitorOwner(dir, owner) {
|
|
|
60
60
|
* still sees the real exit code.
|
|
61
61
|
*/
|
|
62
62
|
export function buildPaneCommand(launch, roleEnv, exitStatusPath, paneArgv = launch.argv) {
|
|
63
|
-
const env = {
|
|
64
|
-
|
|
63
|
+
const env = {
|
|
64
|
+
PATH: process.env.PATH ?? '', COLORTERM: 'truecolor', ...launch.env, ...(roleEnv ?? {}),
|
|
65
|
+
};
|
|
66
|
+
// Interactive panes should advertise colour even when the supervisor itself
|
|
67
|
+
// was launched with NO_COLOR. A role may still deliberately opt back in to
|
|
68
|
+
// NO_COLOR (or replace COLORTERM) through its explicit env block.
|
|
69
|
+
const unsetNoColor = Object.prototype.hasOwnProperty.call(roleEnv ?? {}, 'NO_COLOR')
|
|
70
|
+
? '' : '-u NO_COLOR ';
|
|
71
|
+
const envPfx = 'env ' + unsetNoColor
|
|
72
|
+
+ Object.entries(env).map(([k, v]) => `${k}=${shq(v)}`).join(' ');
|
|
65
73
|
const cmd = paneArgv.map(shq).join(' ');
|
|
66
74
|
// Write a structured record, not a bare number: the wait status alone cannot
|
|
67
75
|
// say whether the file is missing because the program never exited or because
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { type Socket } from 'node:net';
|
|
2
2
|
import type { ControlFailureKind, SessionHandle } from './types.js';
|
|
3
3
|
export interface ControlRequest {
|
|
4
|
-
version: 1;
|
|
4
|
+
version: 1 | 2;
|
|
5
5
|
id: string;
|
|
6
6
|
token: string;
|
|
7
|
-
command: 'status' | 'snapshot' | 'submit_prompt' | 'respond_permission' | 'interrupt' | 'follow';
|
|
7
|
+
command: 'status' | 'snapshot' | 'submit_prompt' | 'respond_permission' | 'interrupt' | 'follow' | 'events_since';
|
|
8
8
|
text?: string;
|
|
9
9
|
permissionId?: string;
|
|
10
10
|
optionId?: string;
|
|
11
11
|
since?: number;
|
|
12
|
+
/** Existing clients omit this and remain interactive controllers. */
|
|
13
|
+
controller?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export interface ControlResponse {
|
|
14
16
|
version: 1;
|
package/dist/session/control.js
CHANGED
|
@@ -132,6 +132,7 @@ export class RoleControlServer {
|
|
|
132
132
|
socket.setEncoding('utf8');
|
|
133
133
|
let buffer = '';
|
|
134
134
|
let unsubscribe;
|
|
135
|
+
let controllerAttached = false;
|
|
135
136
|
socket.on('data', chunk => {
|
|
136
137
|
buffer += chunk;
|
|
137
138
|
if (Buffer.byteLength(buffer) > MAX_LINE_BYTES) {
|
|
@@ -146,13 +147,15 @@ export class RoleControlServer {
|
|
|
146
147
|
buffer = buffer.slice(newline + 1);
|
|
147
148
|
if (!line.trim())
|
|
148
149
|
continue;
|
|
149
|
-
void this.handle(line, socket).then(
|
|
150
|
-
if (
|
|
150
|
+
void this.handle(line, socket).then(follow => {
|
|
151
|
+
if (follow) {
|
|
151
152
|
if (unsubscribe) {
|
|
152
153
|
unsubscribe();
|
|
153
|
-
|
|
154
|
+
if (controllerAttached)
|
|
155
|
+
this.session.setControllerAttached(false);
|
|
154
156
|
}
|
|
155
|
-
unsubscribe = stop;
|
|
157
|
+
unsubscribe = follow.stop;
|
|
158
|
+
controllerAttached = follow.controller;
|
|
156
159
|
}
|
|
157
160
|
});
|
|
158
161
|
}
|
|
@@ -161,7 +164,8 @@ export class RoleControlServer {
|
|
|
161
164
|
this.sockets.delete(socket);
|
|
162
165
|
if (unsubscribe) {
|
|
163
166
|
unsubscribe();
|
|
164
|
-
|
|
167
|
+
if (controllerAttached)
|
|
168
|
+
this.session.setControllerAttached(false);
|
|
165
169
|
}
|
|
166
170
|
});
|
|
167
171
|
socket.on('error', error => this.log(`control socket: ${error.message}`));
|
|
@@ -175,7 +179,7 @@ export class RoleControlServer {
|
|
|
175
179
|
this.write(socket, { version: 1, id: '?', ok: false, error: 'invalid JSON' });
|
|
176
180
|
return;
|
|
177
181
|
}
|
|
178
|
-
if (request.version !== 1 || typeof request.id !== 'string'
|
|
182
|
+
if ((request.version !== 1 && request.version !== 2) || typeof request.id !== 'string'
|
|
179
183
|
|| !sameToken(this.token, request.token ?? '')) {
|
|
180
184
|
this.write(socket, { version: 1, id: request.id ?? '?', ok: false, error: 'unauthorized' });
|
|
181
185
|
return;
|
|
@@ -184,7 +188,13 @@ export class RoleControlServer {
|
|
|
184
188
|
switch (request.command) {
|
|
185
189
|
case 'status':
|
|
186
190
|
case 'snapshot':
|
|
187
|
-
this.write(socket, {
|
|
191
|
+
this.write(socket, {
|
|
192
|
+
version: 1, id: request.id, ok: true,
|
|
193
|
+
result: {
|
|
194
|
+
...this.session.snapshot(), protocolVersion: 2,
|
|
195
|
+
features: ['events_since', 'observer_follow', 'retained_range'],
|
|
196
|
+
},
|
|
197
|
+
});
|
|
188
198
|
return;
|
|
189
199
|
case 'submit_prompt': {
|
|
190
200
|
if (!request.text?.trim())
|
|
@@ -217,17 +227,39 @@ export class RoleControlServer {
|
|
|
217
227
|
await this.session.interrupt();
|
|
218
228
|
this.write(socket, { version: 1, id: request.id, ok: true });
|
|
219
229
|
return;
|
|
220
|
-
case '
|
|
230
|
+
case 'events_since': {
|
|
221
231
|
const since = Number.isFinite(request.since) ? Number(request.since) : 0;
|
|
232
|
+
const events = this.session.eventsSince(since);
|
|
233
|
+
const all = this.session.eventsSince(0);
|
|
222
234
|
this.write(socket, {
|
|
223
235
|
version: 1, id: request.id, ok: true,
|
|
224
|
-
result: {
|
|
236
|
+
result: {
|
|
237
|
+
events, snapshot: this.session.snapshot(),
|
|
238
|
+
firstSeq: all[0]?.seq ?? 0, lastSeq: all.at(-1)?.seq ?? 0,
|
|
239
|
+
truncated: Boolean(all[0] && since > 0 && since < all[0].seq - 1),
|
|
240
|
+
},
|
|
225
241
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
case 'follow': {
|
|
245
|
+
const since = Number.isFinite(request.since) ? Number(request.since) : 0;
|
|
246
|
+
const events = this.session.eventsSince(since);
|
|
247
|
+
const all = this.session.eventsSince(0);
|
|
248
|
+
this.write(socket, {
|
|
249
|
+
version: 1, id: request.id, ok: true,
|
|
250
|
+
result: {
|
|
251
|
+
events, snapshot: this.session.snapshot(),
|
|
252
|
+
firstSeq: all[0]?.seq ?? 0, lastSeq: all.at(-1)?.seq ?? 0,
|
|
253
|
+
truncated: Boolean(all[0] && since > 0 && since < all[0].seq - 1),
|
|
254
|
+
},
|
|
230
255
|
});
|
|
256
|
+
const controller = request.controller !== false;
|
|
257
|
+
if (controller)
|
|
258
|
+
this.session.setControllerAttached(true);
|
|
259
|
+
return { controller, stop: this.session.subscribe(event => {
|
|
260
|
+
if (!socket.destroyed)
|
|
261
|
+
socket.write(JSON.stringify({ version: 1, event }) + '\n');
|
|
262
|
+
}) };
|
|
231
263
|
}
|
|
232
264
|
}
|
|
233
265
|
}
|
package/dist/spawn.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { IsolationConfig } from './isolation/types.js';
|
|
2
|
-
import { type ApprovalMode, type FilesystemMode, type ResolvedRole, type RoleConfig, type SessionBackendId, type UnattendedMode } from './config.js';
|
|
2
|
+
import { type ApprovalMode, type FilesystemMode, type ResolvedRole, type RoleConfig, type MonitorConfig, type SessionBackendId, type UnattendedMode } from './config.js';
|
|
3
3
|
import { type OpsDeps } from './ops.js';
|
|
4
4
|
import { type CreationDeps, type CreationProvenance } from './creation.js';
|
|
5
|
+
import './harness/claude-code.js';
|
|
6
|
+
import './harness/codex.js';
|
|
5
7
|
/**
|
|
6
8
|
* The provenance record written by the most recent spawn in this process, so
|
|
7
9
|
* the CLI can print the same summary it persisted rather than rebuilding it.
|
|
@@ -17,7 +19,8 @@ export interface SpawnOpts {
|
|
|
17
19
|
identity?: string;
|
|
18
20
|
cwd?: string;
|
|
19
21
|
coordinator?: string;
|
|
20
|
-
|
|
22
|
+
/** null explicitly selects the harness default; undefined retains normal fleet inheritance. */
|
|
23
|
+
model?: string | null;
|
|
21
24
|
permissionMode?: string;
|
|
22
25
|
approval?: ApprovalMode;
|
|
23
26
|
filesystem?: FilesystemMode;
|
|
@@ -29,8 +32,16 @@ export interface SpawnOpts {
|
|
|
29
32
|
codexConfig?: Record<string, string | number | boolean>;
|
|
30
33
|
addDirs?: string[];
|
|
31
34
|
monitor?: boolean;
|
|
35
|
+
/** Typed external monitor configuration used by trusted creation surfaces. */
|
|
36
|
+
monitorConfig?: Partial<MonitorConfig>;
|
|
32
37
|
bioFile?: string;
|
|
33
38
|
personaFile?: string;
|
|
39
|
+
/** Inline profile values for trusted typed callers such as the local web service. */
|
|
40
|
+
bio?: string;
|
|
41
|
+
persona?: string;
|
|
42
|
+
/** Internal, non-sensitive provenance correlation for typed presentation layers. */
|
|
43
|
+
surface?: 'cli' | 'web';
|
|
44
|
+
creationActionId?: string;
|
|
34
45
|
/**
|
|
35
46
|
* Path to a file holding exactly the existing `isolation:` mapping — the same
|
|
36
47
|
* schema fleet.yaml uses, not a second policy language. The ONE new operator
|
|
@@ -42,6 +53,12 @@ export interface SpawnOpts {
|
|
|
42
53
|
dryRun?: boolean;
|
|
43
54
|
json?: boolean;
|
|
44
55
|
}
|
|
56
|
+
export declare function profileValues(o: SpawnOpts): {
|
|
57
|
+
bio?: string;
|
|
58
|
+
persona?: string;
|
|
59
|
+
};
|
|
60
|
+
/** Pure option-to-role mapping shared by CLI and application services. */
|
|
61
|
+
export declare function buildRoleConfig(o: SpawnOpts, defaultHarness?: string): RoleConfig;
|
|
45
62
|
/**
|
|
46
63
|
* Read and validate an `--isolation-file`. The file is the existing
|
|
47
64
|
* `isolation:` mapping and nothing else — the same schema, the same validator
|
|
@@ -52,6 +69,7 @@ export interface SpawnOpts {
|
|
|
52
69
|
* must fail before any artifact exists.
|
|
53
70
|
*/
|
|
54
71
|
export declare function readIsolationFile(path: string): IsolationConfig;
|
|
72
|
+
export declare function validateSpawnOpts(o: SpawnOpts): void;
|
|
55
73
|
/** Read mission text without trimming or newline rewriting. */
|
|
56
74
|
export declare function readMissionFile(path: string): string;
|
|
57
75
|
/** The ours identity a spawn will bind: explicit, else the role name. */
|