@ours.network/fleet 1.2.0-nightly.7 → 1.2.0-nightly.70
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 +279 -68
- package/dist/account-origin.d.ts +2 -0
- package/dist/account-origin.js +6 -0
- package/dist/agent-ours/bridge.js +26 -9
- package/dist/agent-ours/correspondence.d.ts +10 -0
- package/dist/agent-ours/correspondence.js +1 -0
- package/dist/agent-ours/file-rpc.d.ts +12 -0
- package/dist/agent-ours/file-rpc.js +18 -4
- package/dist/agent-ours/harness.js +9 -1
- package/dist/agent-ours/mcp-endpoint.d.ts +19 -0
- package/dist/agent-ours/mcp-endpoint.js +98 -25
- package/dist/agent-ours/runtime.d.ts +9 -1
- package/dist/agent-ours/runtime.js +50 -2
- package/dist/agent-ours/service.d.ts +24 -1
- package/dist/agent-ours/service.js +97 -13
- package/dist/application/codex-models.d.ts +15 -0
- package/dist/application/codex-models.js +56 -0
- package/dist/application/conversation-history.d.ts +27 -0
- package/dist/application/conversation-history.js +215 -0
- package/dist/application/conversation-role-observer.d.ts +62 -0
- package/dist/application/conversation-role-observer.js +206 -0
- package/dist/application/fleet-query-service.d.ts +1 -1
- package/dist/application/fleet-query-service.js +2 -2
- package/dist/application/log-service.js +8 -8
- package/dist/application/model-catalog.d.ts +1 -1
- package/dist/application/model-catalog.js +5 -2
- package/dist/application/preset-provenance.d.ts +19 -0
- package/dist/application/preset-provenance.js +59 -0
- package/dist/application/role-creation-service.js +3 -2
- package/dist/application/role-removal-service.js +17 -3
- package/dist/application/role-repository.js +19 -2
- package/dist/application/room-layout-definitions.d.ts +45 -0
- package/dist/application/room-layout-definitions.js +130 -0
- package/dist/application/session-control.d.ts +61 -17
- package/dist/application/session-control.js +207 -23
- package/dist/application/supervisor-ours-tools.js +5 -11
- package/dist/application/task-layouts.d.ts +91 -0
- package/dist/application/task-layouts.js +259 -0
- package/dist/application/task-room-service.d.ts +99 -3
- package/dist/application/task-room-service.js +285 -32
- package/dist/application/types.d.ts +2 -0
- package/dist/atomic-file.d.ts +34 -1
- package/dist/atomic-file.js +161 -18
- package/dist/briefing.d.ts +3 -1
- package/dist/briefing.js +97 -31
- package/dist/build-info.json +9 -4
- package/dist/capabilities.d.ts +9 -1
- package/dist/capabilities.js +13 -0
- package/dist/cli.js +400 -37
- package/dist/client-profile.d.ts +5 -17
- package/dist/client-profile.js +4 -127
- package/dist/config.d.ts +45 -0
- package/dist/config.js +57 -6
- package/dist/creation.d.ts +1 -1
- package/dist/creation.js +4 -4
- package/dist/daemon-recovery.d.ts +1 -8
- package/dist/daemon-recovery.js +8 -113
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +207 -19
- package/dist/doctor.d.ts +4 -1
- package/dist/doctor.js +75 -60
- package/dist/erased-resources.d.ts +9 -0
- package/dist/erased-resources.js +87 -0
- package/dist/file-delivery/reader.d.ts +15 -0
- package/dist/file-delivery/reader.js +63 -0
- package/dist/file-delivery/store.d.ts +15 -0
- package/dist/file-delivery/store.js +124 -0
- package/dist/file-delivery/types.d.ts +19 -0
- package/dist/file-delivery/types.js +1 -0
- package/dist/fleet-command-audit.d.ts +7 -0
- package/dist/fleet-command-audit.js +24 -8
- package/dist/harness/agent-session.d.ts +4 -0
- package/dist/harness/claude-code-session.js +1 -1
- package/dist/harness/claude-code.js +21 -11
- package/dist/harness/claude-runtime.d.ts +12 -0
- package/dist/harness/claude-runtime.js +43 -0
- package/dist/harness/codex-app-server-proxy.d.ts +4 -1
- package/dist/harness/codex-app-server-proxy.js +41 -5
- package/dist/harness/codex-reasoning.d.ts +5 -0
- package/dist/harness/codex-reasoning.js +12 -0
- package/dist/harness/codex-runtime.d.ts +11 -1
- package/dist/harness/codex-runtime.js +31 -4
- package/dist/harness/codex-session.js +2 -2
- package/dist/harness/codex.js +24 -12
- package/dist/init-wizard.d.ts +2 -0
- package/dist/init-wizard.js +38 -19
- package/dist/isolation/policy.js +6 -1
- package/dist/isolation/types.d.ts +5 -0
- package/dist/managed-cli.d.ts +253 -0
- package/dist/managed-cli.js +923 -0
- package/dist/managed-recovery.d.ts +13 -0
- package/dist/managed-recovery.js +31 -0
- package/dist/minimal-setup.d.ts +2 -0
- package/dist/minimal-setup.js +44 -0
- package/dist/monitor.d.ts +8 -34
- package/dist/monitor.js +89 -152
- package/dist/notifications/fleet-producer.d.ts +19 -0
- package/dist/notifications/fleet-producer.js +208 -0
- package/dist/notifications/outbox.d.ts +46 -0
- package/dist/notifications/outbox.js +158 -0
- package/dist/notifications/target-cleanup.d.ts +10 -0
- package/dist/notifications/target-cleanup.js +63 -0
- package/dist/notifications/task-producer.d.ts +18 -0
- package/dist/notifications/task-producer.js +67 -0
- package/dist/ops.d.ts +2 -0
- package/dist/ops.js +20 -3
- package/dist/owner-channel/channel.js +17 -6
- package/dist/owner-channel/commands.d.ts +4 -0
- package/dist/owner-channel/commands.js +8 -0
- package/dist/owner-channel/lifecycle-outbox.js +4 -3
- package/dist/owner-channel/ours-client.js +2 -17
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +2 -0
- package/dist/preset-migration.js +43 -0
- package/dist/process-incarnation.d.ts +23 -0
- package/dist/process-incarnation.js +42 -0
- package/dist/reminders/manager.d.ts +75 -0
- package/dist/reminders/manager.js +278 -0
- package/dist/reminders/runtime.d.ts +27 -0
- package/dist/reminders/runtime.js +32 -0
- package/dist/reminders/schedule.d.ts +37 -0
- package/dist/reminders/schedule.js +104 -0
- package/dist/reminders/store.d.ts +341 -0
- package/dist/reminders/store.js +762 -0
- package/dist/reminders/tools.d.ts +20 -0
- package/dist/reminders/tools.js +114 -0
- package/dist/resolved-plan.js +1 -0
- package/dist/rooms-tasks/add-member.d.ts +48 -0
- package/dist/rooms-tasks/add-member.js +83 -0
- package/dist/rooms-tasks/archived-absence.d.ts +8 -0
- package/dist/rooms-tasks/archived-absence.js +48 -0
- package/dist/rooms-tasks/cli.js +65 -5
- package/dist/rooms-tasks/close.d.ts +6 -2
- package/dist/rooms-tasks/close.js +246 -37
- package/dist/rooms-tasks/config.d.ts +1 -1
- package/dist/rooms-tasks/config.js +11 -4
- package/dist/rooms-tasks/cowork-adapter.d.ts +12 -5
- package/dist/rooms-tasks/cowork-adapter.js +15 -121
- package/dist/rooms-tasks/cowork-http.js +56 -6
- package/dist/rooms-tasks/deletion.d.ts +1 -1
- package/dist/rooms-tasks/deletion.js +84 -5
- package/dist/rooms-tasks/erasure.d.ts +6 -0
- package/dist/rooms-tasks/erasure.js +173 -0
- package/dist/rooms-tasks/external-worker.d.ts +1 -1
- package/dist/rooms-tasks/external-worker.js +3 -4
- package/dist/rooms-tasks/layout-binding-client.d.ts +11 -0
- package/dist/rooms-tasks/layout-binding-client.js +56 -0
- package/dist/rooms-tasks/layout-binding-grants.d.ts +21 -0
- package/dist/rooms-tasks/layout-binding-grants.js +128 -0
- package/dist/rooms-tasks/layout-cli.d.ts +4 -0
- package/dist/rooms-tasks/layout-cli.js +107 -0
- package/dist/rooms-tasks/layout-config.d.ts +11 -0
- package/dist/rooms-tasks/layout-config.js +89 -0
- package/dist/rooms-tasks/layout-control.d.ts +21 -0
- package/dist/rooms-tasks/layout-control.js +52 -0
- package/dist/rooms-tasks/layout-member-retirement.d.ts +10 -0
- package/dist/rooms-tasks/layout-member-retirement.js +90 -0
- package/dist/rooms-tasks/layout-service.d.ts +43 -0
- package/dist/rooms-tasks/layout-service.js +203 -0
- package/dist/rooms-tasks/layout.d.ts +121 -0
- package/dist/rooms-tasks/layout.js +285 -0
- package/dist/rooms-tasks/legacy-task-member.d.ts +19 -0
- package/dist/rooms-tasks/legacy-task-member.js +116 -0
- package/dist/rooms-tasks/live-readiness.d.ts +18 -0
- package/dist/rooms-tasks/live-readiness.js +85 -0
- package/dist/rooms-tasks/member-ownership.d.ts +5 -0
- package/dist/rooms-tasks/member-ownership.js +40 -0
- package/dist/rooms-tasks/member-startup.d.ts +1 -0
- package/dist/rooms-tasks/member-startup.js +2 -0
- package/dist/rooms-tasks/provision.d.ts +3 -0
- package/dist/rooms-tasks/provision.js +101 -49
- package/dist/rooms-tasks/recovery.d.ts +19 -0
- package/dist/rooms-tasks/recovery.js +110 -0
- package/dist/rooms-tasks/room-state.d.ts +4 -2
- package/dist/rooms-tasks/room-state.js +47 -8
- package/dist/rooms-tasks/task-service-retirement.d.ts +11 -0
- package/dist/rooms-tasks/task-service-retirement.js +21 -0
- package/dist/rooms-tasks/task-state.d.ts +51 -8
- package/dist/rooms-tasks/task-state.js +245 -25
- package/dist/rooms-tasks/types.d.ts +40 -0
- package/dist/rooms-tasks/workspace-artifacts.d.ts +6 -0
- package/dist/rooms-tasks/workspace-artifacts.js +93 -0
- package/dist/rooms-tasks/workspace.d.ts +35 -0
- package/dist/rooms-tasks/workspace.js +325 -0
- package/dist/runner.d.ts +33 -4
- package/dist/runner.js +389 -56
- package/dist/session/acp.d.ts +75 -2
- package/dist/session/acp.js +345 -82
- package/dist/session/arbiter.d.ts +98 -0
- package/dist/session/arbiter.js +272 -3
- package/dist/session/codex-app-server.d.ts +45 -1
- package/dist/session/codex-app-server.js +225 -32
- package/dist/session/control.d.ts +17 -3
- package/dist/session/control.js +213 -23
- package/dist/session/conversation-normalizer.d.ts +2 -1
- package/dist/session/conversation-normalizer.js +1 -1
- package/dist/session/conversation-observation.d.ts +25 -0
- package/dist/session/conversation-observation.js +100 -0
- package/dist/session/conversation-replay.d.ts +50 -0
- package/dist/session/conversation-replay.js +203 -0
- package/dist/session/conversation-store.d.ts +15 -1
- package/dist/session/conversation-store.js +206 -26
- package/dist/session/conversation-types.d.ts +57 -4
- package/dist/session/prompt-batch.d.ts +79 -0
- package/dist/session/prompt-batch.js +120 -0
- package/dist/session/task-notice.d.ts +14 -0
- package/dist/session/task-notice.js +13 -0
- package/dist/session/types.d.ts +42 -1
- package/dist/setup-tunnel-preflight.d.ts +34 -0
- package/dist/setup-tunnel-preflight.js +62 -0
- package/dist/socket-path.d.ts +2 -0
- package/dist/socket-path.js +22 -0
- package/dist/spawn.d.ts +5 -1
- package/dist/spawn.js +40 -4
- package/dist/startup-prompt.d.ts +15 -0
- package/dist/startup-prompt.js +71 -0
- package/dist/startup-readiness.d.ts +32 -0
- package/dist/startup-readiness.js +101 -0
- package/dist/startup-telemetry.d.ts +16 -0
- package/dist/startup-telemetry.js +46 -0
- package/dist/subscriptions/cli.d.ts +91 -0
- package/dist/subscriptions/cli.js +223 -0
- package/dist/subscriptions/launch.d.ts +37 -0
- package/dist/subscriptions/launch.js +93 -0
- package/dist/subscriptions/login.d.ts +76 -0
- package/dist/subscriptions/login.js +207 -0
- package/dist/subscriptions/observed.d.ts +7 -0
- package/dist/subscriptions/observed.js +44 -0
- package/dist/subscriptions/probe.d.ts +10 -0
- package/dist/subscriptions/probe.js +73 -0
- package/dist/subscriptions/service.d.ts +102 -0
- package/dist/subscriptions/service.js +364 -0
- package/dist/subscriptions/store.d.ts +71 -0
- package/dist/subscriptions/store.js +140 -0
- package/dist/supervisor/adoption.d.ts +8 -0
- package/dist/supervisor/adoption.js +78 -0
- package/dist/supervisor/catalog.d.ts +62 -0
- package/dist/supervisor/catalog.js +254 -0
- package/dist/supervisor/fleet.d.ts +8 -0
- package/dist/supervisor/fleet.js +89 -0
- package/dist/supervisor/index.js +3 -6
- package/dist/supervisor/launchd.d.ts +1 -1
- package/dist/supervisor/launchd.js +26 -13
- package/dist/supervisor/legacy.d.ts +35 -0
- package/dist/supervisor/legacy.js +524 -0
- package/dist/supervisor/manager.d.ts +15 -0
- package/dist/supervisor/manager.js +270 -0
- package/dist/supervisor/registration-refresh.d.ts +45 -0
- package/dist/supervisor/registration-refresh.js +266 -0
- package/dist/supervisor/scope.d.ts +4 -0
- package/dist/supervisor/scope.js +10 -0
- package/dist/supervisor/systemd.d.ts +2 -2
- package/dist/supervisor/systemd.js +19 -33
- package/dist/task-supervision.d.ts +9 -0
- package/dist/task-supervision.js +145 -0
- package/dist/temp-idle.d.ts +17 -0
- package/dist/temp-idle.js +42 -0
- package/dist/temp-lifecycle.d.ts +23 -8
- package/dist/temp-lifecycle.js +123 -66
- package/dist/temp-supervisor-recovery.d.ts +1 -1
- package/dist/temp-supervisor-recovery.js +2 -2
- package/dist/tunnel-setup-completion.d.ts +7 -0
- package/dist/tunnel-setup-completion.js +13 -0
- package/dist/tunnel-setup-input.d.ts +19 -0
- package/dist/tunnel-setup-input.js +124 -0
- package/dist/web/agent-attachments.d.ts +29 -0
- package/dist/web/agent-attachments.js +162 -0
- package/dist/web/auth.d.ts +65 -2
- package/dist/web/auth.js +201 -11
- package/dist/web/available-port.d.ts +2 -0
- package/dist/web/available-port.js +23 -0
- package/dist/web/control.d.ts +3 -3
- package/dist/web/control.js +10 -8
- package/dist/web/conversation-stream-codec.d.ts +23 -0
- package/dist/web/conversation-stream-codec.js +110 -0
- package/dist/web/conversation-stream.d.ts +25 -0
- package/dist/web/conversation-stream.js +231 -0
- package/dist/web/fleet-config-service.d.ts +4 -1
- package/dist/web/fleet-config-service.js +46 -15
- package/dist/web/prefix-gateway.d.ts +32 -0
- package/dist/web/prefix-gateway.js +238 -0
- package/dist/web/runtime.d.ts +3 -1
- package/dist/web/runtime.js +128 -33
- package/dist/web/server.d.ts +16 -0
- package/dist/web/server.js +639 -55
- package/dist/web/service.d.ts +11 -2
- package/dist/web/service.js +30 -4
- package/dist/web/workspace-devices.d.ts +107 -0
- package/dist/web/workspace-devices.js +277 -0
- package/dist/web/workspace-tunnel.d.ts +1 -0
- package/dist/web/workspace-tunnel.js +34 -0
- package/dist/workspace-enrollment.d.ts +83 -0
- package/dist/workspace-enrollment.js +580 -0
- package/dist/workspace-replacement.d.ts +66 -0
- package/dist/workspace-replacement.js +220 -0
- package/docs/acp-files.md +146 -0
- package/docs/conversation-stream.md +190 -0
- package/docs/fleet-migration.md +54 -0
- package/docs/live-voice.md +13 -0
- package/docs/room-layouts.md +227 -0
- package/docs/self-reminders.md +374 -0
- package/docs/task-workspaces.md +225 -0
- package/docs/validation/managed-cli-permissions.md +421 -0
- package/examples/room-layouts/fresh.yaml +27 -0
- package/examples/room-layouts/scoped.yaml +21 -0
- package/examples/room-layouts/shared.yaml +19 -0
- package/package.json +24 -20
- package/presets/README.md +78 -0
- package/presets/brain-catalog.json +8 -2
- package/presets/fleet/agent_templates/Critic.yaml +1 -1
- package/presets/fleet/agent_templates/Developer.yaml +1 -1
- package/presets/fleet/agent_templates/Engineer.yaml +5 -0
- package/presets/fleet/agent_templates/LocalCoordinator.yaml +4 -2
- package/presets/fleet/agents/FleetCoordinator.yaml +1 -1
- package/presets/fleet/brains/claude-fable-5-1-high.yaml +5 -0
- package/presets/fleet/brains/claude-fable-5-1-low.yaml +5 -0
- package/presets/fleet/brains/claude-fable-5-1-max.yaml +5 -0
- package/presets/fleet/brains/claude-fable-5-1-medium.yaml +5 -0
- package/presets/fleet/brains/claude-fable-5-1-xhigh.yaml +5 -0
- package/presets/fleet/brains/claude-fable-5-high.yaml +1 -1
- package/presets/fleet/brains/claude-fable-5-low.yaml +1 -1
- package/presets/fleet/brains/claude-fable-5-max.yaml +1 -1
- package/presets/fleet/brains/claude-fable-5-medium.yaml +1 -1
- package/presets/fleet/brains/claude-fable-5-xhigh.yaml +1 -1
- package/presets/fleet/brains/claude-haiku-4-5-20251001-default.yaml +4 -0
- package/presets/fleet/brains/claude-opus-5-5-high.yaml +5 -0
- package/presets/fleet/brains/claude-opus-5-5-low.yaml +5 -0
- package/presets/fleet/brains/claude-opus-5-5-max.yaml +5 -0
- package/presets/fleet/brains/claude-opus-5-5-medium.yaml +5 -0
- package/presets/fleet/brains/claude-opus-5-5-xhigh.yaml +5 -0
- package/presets/fleet/brains/claude-opus-5-high.yaml +1 -1
- package/presets/fleet/brains/claude-opus-5-low.yaml +1 -1
- package/presets/fleet/brains/claude-opus-5-max.yaml +1 -1
- package/presets/fleet/brains/claude-opus-5-medium.yaml +1 -1
- package/presets/fleet/brains/claude-opus-5-xhigh.yaml +1 -1
- package/presets/fleet/brains/claude-sonnet-5-high.yaml +1 -1
- package/presets/fleet/brains/claude-sonnet-5-low.yaml +1 -1
- package/presets/fleet/brains/claude-sonnet-5-max.yaml +1 -1
- package/presets/fleet/brains/claude-sonnet-5-medium.yaml +1 -1
- package/presets/fleet/brains/claude-sonnet-5-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-3-codex-spark-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-3-codex-spark-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-3-codex-spark-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-3-codex-spark-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-mini-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-mini-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-mini-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-mini-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-4-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-5-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-5-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-5-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-5-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-luna-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-luna-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-luna-max.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-luna-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-luna-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-max.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-ultra.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-sol-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-max.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-ultra.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-5-6-terra-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-1-sol-high.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-1-sol-low.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-1-sol-max.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-1-sol-medium.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-1-sol-ultra.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-1-sol-xhigh.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-astra-high.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-astra-low.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-astra-max.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-astra-medium.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-astra-ultra.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-astra-xhigh.yaml +1 -1
- package/presets/fleet/brains/codex-gpt-6-luna-high.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-luna-low.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-luna-max.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-luna-medium.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-luna-xhigh.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-high.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-low.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-max.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-medium.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-ultra.yaml +5 -0
- package/presets/fleet/brains/codex-gpt-6-sol-xhigh.yaml +5 -0
- package/presets/fleet/roles/Coordinator.yaml +12 -11
- package/presets/fleet/roles/Critic.yaml +13 -0
- package/presets/fleet/roles/Developer.yaml +13 -0
- package/presets/fleet/roles/Engineer.yaml +53 -0
- package/presets/fleet/room_layouts/engineering.yaml +25 -0
- package/presets/fleet/room_layouts/pair.yaml +24 -0
- package/presets/fleet/room_layouts/single.yaml +17 -0
- package/presets/fleet/room_layouts/team.yaml +30 -0
- package/presets/fleet/room_templates/engineering.yaml +19 -0
- package/presets/manifest.json +2 -2
- package/dist/web-app/assets/index-59GF-gsZ.css +0 -1
- package/dist/web-app/assets/index-C0h3ALvs.js +0 -10
- package/dist/web-app/icons/ours-fleet-maskable.svg +0 -4
- package/dist/web-app/icons/ours-fleet.svg +0 -4
- package/dist/web-app/index.html +0 -17
- package/dist/web-app/manifest.webmanifest +0 -15
- package/dist/web-app/offline.html +0 -18
- package/dist/web-app/sw.js +0 -51
package/dist/web/server.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { registerConversationStream } from './conversation-stream.js';
|
|
2
|
+
import { conversationHasAttachment } from '../application/conversation-history.js';
|
|
3
|
+
import { readDeliveredFile } from '../file-delivery/store.js';
|
|
4
|
+
import { WorkspaceDeviceAuthError } from './workspace-devices.js';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { packagedPresetRoot } from '../preset-bootstrap.js';
|
|
7
|
+
import { validateCatalog } from '../init-wizard.js';
|
|
8
|
+
import { getAdapter } from '../harness/registry.js';
|
|
9
|
+
import { storeAgentAttachment, attachmentPrompt, MAX_ATTACHMENT_BODY, readAgentAttachment, prepareAttachmentPresentation, presentAttachmentEvent } from './agent-attachments.js';
|
|
10
|
+
import { readChatIdle } from '../temp-idle.js';
|
|
11
|
+
import { agentDir } from '../paths.js';
|
|
1
12
|
import { SupervisorOursTools } from '../application/supervisor-ours-tools.js';
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { join } from 'node:path';
|
|
5
14
|
import Fastify from 'fastify';
|
|
6
|
-
import fastifyStatic from '@fastify/static';
|
|
7
15
|
import fastifyWebsocket from '@fastify/websocket';
|
|
8
16
|
import { createHmac, randomBytes } from 'node:crypto';
|
|
9
17
|
import { FleetError, normalizeError } from '../application/errors.js';
|
|
@@ -14,6 +22,8 @@ import { FleetEventBus } from './events.js';
|
|
|
14
22
|
import { ROLE_NAME_RE } from '../config.js';
|
|
15
23
|
import { TaskListError } from '../rooms-tasks/task-lists.js';
|
|
16
24
|
import { TaskStateError } from '../rooms-tasks/task-state.js';
|
|
25
|
+
import { isProvider } from '../subscriptions/store.js';
|
|
26
|
+
const ONBOARDING_WORK = ['coordination', 'development', 'review'];
|
|
17
27
|
const statusFor = (code) => ({
|
|
18
28
|
role_not_found: 404, resource_not_found: 404, unauthorized: 401, forbidden: 403, conflict: 409,
|
|
19
29
|
idempotency_conflict: 409, stale_state: 409, rate_limited: 429,
|
|
@@ -34,25 +44,37 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
34
44
|
app.addHook('onRequest', async (request, reply) => {
|
|
35
45
|
reply.header('X-Content-Type-Options', 'nosniff');
|
|
36
46
|
reply.header('Referrer-Policy', 'no-referrer');
|
|
37
|
-
reply.header('Permissions-Policy', 'camera=(), microphone=(), geolocation=(), payment=()');
|
|
38
|
-
|
|
39
|
-
reply.header('Content-Security-Policy',
|
|
40
|
-
`connect-src 'self' ${auth.secureCookies ? 'wss' : 'ws'}://${auth.host}; object-src 'none'; base-uri 'none'; ` +
|
|
41
|
-
`frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; worker-src 'self'`);
|
|
47
|
+
reply.header('Permissions-Policy', 'camera=(), microphone=(self), geolocation=(), payment=()');
|
|
48
|
+
// Fleet serves an API only: nothing it returns may run, load or be framed as a page.
|
|
49
|
+
reply.header('Content-Security-Policy', "default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'");
|
|
42
50
|
if (request.url.startsWith('/api/'))
|
|
43
51
|
reply.header('Cache-Control', 'no-store');
|
|
44
|
-
|
|
45
|
-
auth.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (request.headers.origin === auth.appOrigin && request.url.startsWith('/api/')) {
|
|
53
|
+
reply.header('Access-Control-Allow-Origin', auth.appOrigin).header('Vary', 'Origin');
|
|
54
|
+
reply.header('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
|
|
55
|
+
reply.header('Access-Control-Expose-Headers', 'X-Ours-Workspace-Auth, X-Ours-Request-Id');
|
|
56
|
+
reply.header('Access-Control-Allow-Headers', 'Authorization,Content-Type,X-CSRF-Token,Idempotency-Key');
|
|
57
|
+
if (request.method === 'OPTIONS') {
|
|
58
|
+
auth.validateBoundary(request, false);
|
|
59
|
+
return reply.code(204).send();
|
|
60
|
+
}
|
|
52
61
|
}
|
|
62
|
+
auth.validateBoundary(request, false);
|
|
63
|
+
});
|
|
64
|
+
app.post('/api/v1/layout-bindings/:id/control', async (request) => {
|
|
65
|
+
// Initial support is direct same-host Fleet-to-Fleet transport.
|
|
66
|
+
const forwarded = Object.keys(request.headers).some(name => name === 'forwarded' || name.startsWith('x-forwarded-') || name === 'x-real-ip' || name === 'via');
|
|
67
|
+
if (!['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(request.ip) || forwarded)
|
|
68
|
+
throw new FleetError('forbidden', 'layout bindings require direct loopback access');
|
|
69
|
+
// Machine credentials cannot authenticate browser or lifecycle routes.
|
|
70
|
+
if (request.headers.origin)
|
|
71
|
+
auth.validateBoundary(request, true);
|
|
72
|
+
if (!services.layoutBindings)
|
|
73
|
+
throw new FleetError('capability_unavailable', 'layout bindings unavailable');
|
|
74
|
+
return services.layoutBindings.control(request.params.id, request.headers.authorization, request.body);
|
|
53
75
|
});
|
|
54
76
|
app.setErrorHandler(async (error, request, reply) => {
|
|
55
|
-
const privateToolParseError =
|
|
77
|
+
const privateToolParseError = ['/api/v1/roles/:id/ours/call', '/api/v1/layout-bindings/:id/control'].includes(request.routeOptions.url ?? '')
|
|
56
78
|
&& error instanceof Error && 'code' in error
|
|
57
79
|
&& typeof error.code === 'string' && error.code.startsWith('FST_ERR_CTP_');
|
|
58
80
|
const fleetError = normalizeError(privateToolParseError
|
|
@@ -61,8 +83,13 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
61
83
|
requestId: request.id, action: `${request.method} ${request.routeOptions.url ?? request.url}`,
|
|
62
84
|
result: 'rejected', errorCode: fleetError.code,
|
|
63
85
|
});
|
|
86
|
+
if (error instanceof WorkspaceDeviceAuthError)
|
|
87
|
+
reply.header('X-Ours-Workspace-Auth', 'rejected');
|
|
88
|
+
if (fleetError.code === 'unauthorized')
|
|
89
|
+
reply.header('X-Ours-Request-Id', request.id);
|
|
64
90
|
reply.code(statusFor(fleetError.code)).send({ error: fleetError.toJSON() });
|
|
65
91
|
});
|
|
92
|
+
registerConversationStream(app, services, auth);
|
|
66
93
|
app.post('/api/v1/auth/exchange', async (request, reply) => {
|
|
67
94
|
const { session, device } = auth.exchange(request);
|
|
68
95
|
setAuthCookies(reply, session.id, device.token, auth.secureCookies);
|
|
@@ -101,6 +128,51 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
101
128
|
const session = auth.authenticate(request);
|
|
102
129
|
return { csrfToken: session.csrf, expiresAt: new Date(session.absoluteExpiresAt).toISOString() };
|
|
103
130
|
});
|
|
131
|
+
app.get('/api/v1/workspace/identity', async () => auth.workspaceIdentity());
|
|
132
|
+
app.post('/api/v1/devices/enroll', async (request, reply) => {
|
|
133
|
+
reply.header('Cache-Control', 'no-store');
|
|
134
|
+
const input = request.body;
|
|
135
|
+
if (!input)
|
|
136
|
+
throw new FleetError('invalid_request', 'device enrollment body required');
|
|
137
|
+
return auth.enrollWorkspace(request, input);
|
|
138
|
+
});
|
|
139
|
+
// Refresh credentials travel between the account server and this host; these routes refuse browsers.
|
|
140
|
+
const refreshInput = (request, name) => {
|
|
141
|
+
const value = request.body?.[name];
|
|
142
|
+
if (typeof value !== 'string')
|
|
143
|
+
throw new FleetError('invalid_request', `${name} is required`);
|
|
144
|
+
return value;
|
|
145
|
+
};
|
|
146
|
+
app.post('/api/v1/devices/refresh', async (request, reply) => {
|
|
147
|
+
reply.header('Cache-Control', 'no-store');
|
|
148
|
+
return auth.refreshWorkspace(request, refreshInput(request, 'refreshToken'));
|
|
149
|
+
});
|
|
150
|
+
app.post('/api/v1/devices/exchange', async (request, reply) => {
|
|
151
|
+
reply.header('Cache-Control', 'no-store');
|
|
152
|
+
return auth.exchangeWorkspace(request);
|
|
153
|
+
});
|
|
154
|
+
app.post('/api/v1/devices/revoke', async (request) => ({ revoked: auth.revokeWorkspaceRefresh(request, refreshInput(request, 'refreshHash')) }));
|
|
155
|
+
app.post('/api/v1/devices/link', async (request, reply) => {
|
|
156
|
+
const proof = request.body?.refreshToken;
|
|
157
|
+
if (proof !== undefined) {
|
|
158
|
+
reply.header('Cache-Control', 'no-store');
|
|
159
|
+
const { enrollment, enrollmentExpiresAt, ...credentials } = auth.linkWorkspaceDevice(request, refreshInput(request, 'refreshToken'));
|
|
160
|
+
return { ...credentials, code: { version: 1, origin: auth.origin, enrollment, workspaceId: credentials.workspaceId, expiresAt: enrollmentExpiresAt } };
|
|
161
|
+
}
|
|
162
|
+
const session = auth.authenticate(request, true);
|
|
163
|
+
// A short-lived access credential must not be able to create a lasting one.
|
|
164
|
+
if (session.rotating)
|
|
165
|
+
throw new FleetError('forbidden', 'linking another device requires this link\'s refresh credential');
|
|
166
|
+
return { version: 1, origin: auth.origin, ...auth.workspaceEnrollment(session.id) };
|
|
167
|
+
});
|
|
168
|
+
app.get('/api/v1/devices/current', async (request) => {
|
|
169
|
+
const session = auth.authenticate(request);
|
|
170
|
+
if (!session.id.startsWith('workspace:'))
|
|
171
|
+
throw new FleetError('resource_not_found', 'no workspace device');
|
|
172
|
+
return { deviceId: session.id.slice(10), authorizedUntil: session.absoluteExpiresAt };
|
|
173
|
+
});
|
|
174
|
+
app.get('/api/v1/devices', async (request) => { auth.authenticate(request); return { devices: auth.listWorkspaceDevices() }; });
|
|
175
|
+
app.delete('/api/v1/devices/:id', async (request) => { auth.authenticate(request, true); auth.revokeWorkspaceDevice(request.params.id); return { revoked: true }; });
|
|
104
176
|
app.get('/api/v1/meta', async (request) => {
|
|
105
177
|
auth.authenticate(request);
|
|
106
178
|
return {
|
|
@@ -111,6 +183,83 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
111
183
|
auditDegraded: audit.degraded,
|
|
112
184
|
};
|
|
113
185
|
});
|
|
186
|
+
app.get('/api/v1/onboarding', async (request) => {
|
|
187
|
+
auth.authenticate(request);
|
|
188
|
+
// Opening an existing workspace needs configuration state, not CLI/account discovery.
|
|
189
|
+
// Keep the full report for the setup screens and older App clients.
|
|
190
|
+
if (request.query.view === 'state')
|
|
191
|
+
return { configured: onboardingConfigured() };
|
|
192
|
+
const harnesses = await Promise.all(['codex', 'claude-code'].map(async (harness) => {
|
|
193
|
+
try {
|
|
194
|
+
return { harness, ...await getAdapter(harness).checkPrereqs() };
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return { harness, ok: false, checks: [{ name: 'availability', ok: false, detail: 'Harness checks unavailable' }] };
|
|
198
|
+
}
|
|
199
|
+
}));
|
|
200
|
+
const catalog = validateCatalog(JSON.parse(readFileSync(join(packagedPresetRoot(), 'brain-catalog.json'), 'utf8')));
|
|
201
|
+
// Codex models are offered only when the runtime itself listed them for the active account.
|
|
202
|
+
// When it could not be asked, none is offered and the reason is reported.
|
|
203
|
+
const codexModels = services.codexModels ? await services.codexModels() : undefined;
|
|
204
|
+
const offered = (model) => model.harness !== 'codex' || !codexModels || (codexModels.state === 'known' && codexModels.models.includes(model.model));
|
|
205
|
+
return { harnesses, catalog: catalog.models.filter(offered), ...(codexModels ? { codexModels: codexModels.state === 'known' ? { state: 'known' } : codexModels } : {}), providers: services.subscriptions ? await services.subscriptions.list() : [], coordinator: 'FleetCoordinator', configured: onboardingConfigured() };
|
|
206
|
+
});
|
|
207
|
+
// First-time setup is what creates the persistent coordinator. A configuration that loads and
|
|
208
|
+
// has it is set up, whatever its brains are called; its models are then changed by editing it.
|
|
209
|
+
const onboardingConfigured = () => {
|
|
210
|
+
if (!services.configuration)
|
|
211
|
+
return false;
|
|
212
|
+
try {
|
|
213
|
+
return Boolean(services.configuration.read(false).model.agents.FleetCoordinator);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
let onboardingSetupQueue = Promise.resolve();
|
|
220
|
+
app.post('/api/v1/onboarding/setup', async (request) => {
|
|
221
|
+
auth.authenticate(request, true);
|
|
222
|
+
if (!services.configuration || !services.onboardingSetup)
|
|
223
|
+
throw new FleetError('capability_unavailable', 'first-time Fleet setup is unavailable');
|
|
224
|
+
const requested = request.body?.models;
|
|
225
|
+
const codexModels = services.codexModels ? await services.codexModels() : undefined;
|
|
226
|
+
const supported = validateCatalog(JSON.parse(readFileSync(join(packagedPresetRoot(), 'brain-catalog.json'), 'utf8'))).models
|
|
227
|
+
.filter(model => model.harness !== 'codex' || !codexModels || (codexModels.state === 'known' && codexModels.models.includes(model.model)));
|
|
228
|
+
const models = {};
|
|
229
|
+
for (const work of ONBOARDING_WORK) {
|
|
230
|
+
const matches = supported.filter(model => model.harness === requested?.[work]?.harness && model.model === requested?.[work]?.model);
|
|
231
|
+
if (matches.length !== 1)
|
|
232
|
+
throw new FleetError('invalid_request', `choose a supported model for ${work}`);
|
|
233
|
+
models[work] = matches[0];
|
|
234
|
+
}
|
|
235
|
+
const chosen = Object.values(models);
|
|
236
|
+
const subscriptions = [...new Set(chosen.map(model => model.harness === 'codex' ? 'codex' : 'claude'))];
|
|
237
|
+
const oneModel = new Set(chosen.map(model => `${model.harness}\0${model.model}`)).size === 1;
|
|
238
|
+
const configuration = services.configuration, setup = services.onboardingSetup;
|
|
239
|
+
// One setup at a time: the first-time check and the publication it guards must not interleave.
|
|
240
|
+
const run = onboardingSetupQueue.then(async () => {
|
|
241
|
+
if (onboardingConfigured())
|
|
242
|
+
throw new FleetError('conflict', 'Fleet is already set up; change its models in the configuration');
|
|
243
|
+
try {
|
|
244
|
+
await setup({ subscriptions, assignmentStrategy: oneModel ? 'one-model' : 'per-job', models, reasoning: 'balanced' });
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
throw new FleetError('backend_failure', `Fleet setup did not complete: ${error.message}`);
|
|
248
|
+
}
|
|
249
|
+
// Setup preserves files it finds, so confirm the published models are the ones this request chose.
|
|
250
|
+
// The prepared agents reference packaged Brain presets, so resolve what each of them now points at:
|
|
251
|
+
// a preserved file of a packaged name may hold another model, session or reasoning than its name says.
|
|
252
|
+
const published = configuration.read(true).model, brains = published.brains ?? {};
|
|
253
|
+
const brainOf = (holder) => brains[String(holder?.brain?.ref ?? '')];
|
|
254
|
+
const assigned = { coordination: brainOf(published.agents.FleetCoordinator), development: brainOf(published.agent_templates?.Developer), review: brainOf(published.agent_templates?.Critic) };
|
|
255
|
+
for (const work of ONBOARDING_WORK)
|
|
256
|
+
if (assigned[work]?.harness !== models[work].harness || assigned[work]?.model !== models[work].model || assigned[work]?.session !== models[work].session || assigned[work]?.effort !== 'medium')
|
|
257
|
+
throw new FleetError('conflict', 'Fleet was set up with different models; review its configuration');
|
|
258
|
+
return { configured: true };
|
|
259
|
+
});
|
|
260
|
+
onboardingSetupQueue = run.catch(() => { });
|
|
261
|
+
return run;
|
|
262
|
+
});
|
|
114
263
|
app.get('/api/v1/creation-capabilities', async (request) => {
|
|
115
264
|
auth.authenticate(request);
|
|
116
265
|
return services.creation.capabilities();
|
|
@@ -133,7 +282,8 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
133
282
|
});
|
|
134
283
|
app.get('/api/v1/roles', async (request) => {
|
|
135
284
|
auth.authenticate(request);
|
|
136
|
-
|
|
285
|
+
const query = request.query;
|
|
286
|
+
return { roles: await services.query.list(query.includeTemporary === 'true') };
|
|
137
287
|
});
|
|
138
288
|
const taskApi = async (fn) => {
|
|
139
289
|
try {
|
|
@@ -146,6 +296,8 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
146
296
|
? 'conflict' : 'invalid_request';
|
|
147
297
|
throw new FleetError(code, error.message);
|
|
148
298
|
}
|
|
299
|
+
if (error instanceof TaskStateError && 'accepted' in error && error.accepted === false)
|
|
300
|
+
return Promise.reject(Object.assign(new FleetError('invalid_request', error.message), { memberNotAccepted: true }));
|
|
149
301
|
if (error instanceof TaskStateError) {
|
|
150
302
|
throw new FleetError(error.message.startsWith('task not found:') ? 'resource_not_found' : 'conflict', error.message);
|
|
151
303
|
}
|
|
@@ -193,9 +345,10 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
193
345
|
const state = query.state && query.state !== 'all' ? query.state : undefined;
|
|
194
346
|
const filter = { ...(state ? { state } : {}), ...(query.list ? { list: query.list } : {}),
|
|
195
347
|
...(query.includeDeleting === 'true' ? { includeDeleting: true } : {}) };
|
|
348
|
+
const api = requireTaskRooms();
|
|
196
349
|
return taskApi(() => query.groupByList === 'true'
|
|
197
|
-
? { groups:
|
|
198
|
-
: { tasks:
|
|
350
|
+
? { groups: api.groupedTasks(filter).map(group => ({ ...group, tasks: group.tasks.map(task => api.withLayoutRooms(task)) })) }
|
|
351
|
+
: { tasks: api.listTasks(filter).map(task => api.withLayoutRooms(task)) });
|
|
199
352
|
});
|
|
200
353
|
app.delete('/api/v1/tasks/:id', async (request, reply) => {
|
|
201
354
|
auth.authenticate(request, true);
|
|
@@ -226,12 +379,17 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
226
379
|
const body = request.body;
|
|
227
380
|
if (typeof body?.title !== 'string' || !body.title)
|
|
228
381
|
throw new FleetError('invalid_request', 'title is required');
|
|
382
|
+
// Every task runs a saved Room Layout; rooms are never defined inline or from room templates here.
|
|
383
|
+
if (typeof body.layout !== 'string' || !body.layout)
|
|
384
|
+
throw new FleetError('invalid_request', 'layout is required: choose a room layout from Settings › Room layouts');
|
|
385
|
+
if (body.template !== undefined || body.noRoom !== undefined)
|
|
386
|
+
throw new FleetError('invalid_request', 'tasks use room layouts; template and noRoom are not accepted');
|
|
229
387
|
const task = await taskApi(() => requireTaskRooms().createTask({
|
|
230
388
|
actor: { kind: 'local_control', surface: 'web' }, title: body.title,
|
|
231
389
|
brief: typeof body.brief === 'string' ? body.brief : undefined,
|
|
232
|
-
|
|
233
|
-
backlog: body.backlog === true, noRoom: body.noRoom === true,
|
|
390
|
+
backlog: body.backlog === true,
|
|
234
391
|
list: typeof body.list === 'string' ? body.list : undefined,
|
|
392
|
+
layout: body.layout,
|
|
235
393
|
idempotencyKey: typeof request.headers['idempotency-key'] === 'string'
|
|
236
394
|
? request.headers['idempotency-key'] : undefined,
|
|
237
395
|
origin: { type: 'web' },
|
|
@@ -245,11 +403,162 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
245
403
|
const list = String(request.body?.list ?? '');
|
|
246
404
|
return { task: await taskApi(() => requireTaskRooms().moveTask({ actor: { kind: 'local_control', surface: 'web' }, taskId, list })) };
|
|
247
405
|
});
|
|
406
|
+
app.patch('/api/v1/tasks/:id/description', async (request) => {
|
|
407
|
+
auth.authenticate(request, true);
|
|
408
|
+
const body = request.body;
|
|
409
|
+
if (typeof body?.brief !== 'string' || typeof body.expectedBrief !== 'string' || body.brief.length > 100_000)
|
|
410
|
+
throw new FleetError('invalid_request', 'brief and expectedBrief must be strings; brief maximum is 100000 characters');
|
|
411
|
+
return { task: await taskApi(() => requireTaskRooms().editTaskDescription({
|
|
412
|
+
actor: { kind: 'local_control', surface: 'web' }, taskId: request.params.id,
|
|
413
|
+
brief: body.brief, expectedBrief: body.expectedBrief,
|
|
414
|
+
})) };
|
|
415
|
+
});
|
|
416
|
+
app.get('/api/v1/tasks/:id', async (request) => {
|
|
417
|
+
auth.authenticate(request);
|
|
418
|
+
return taskApi(() => requireTaskRooms().getTask(request.params.id));
|
|
419
|
+
});
|
|
420
|
+
app.post('/api/v1/tasks/:id/members', async (request, reply) => {
|
|
421
|
+
auth.authenticate(request, true);
|
|
422
|
+
const body = request.body;
|
|
423
|
+
try {
|
|
424
|
+
const result = await taskApi(() => requireTaskRooms().addMember(request.params.id, body));
|
|
425
|
+
reply.code(result.state === 'running' ? 202 : 200);
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (error instanceof Error && 'memberNotAccepted' in error)
|
|
430
|
+
return reply.code(409).send({ error: { code: 'member_not_accepted', message: error.message }, accepted: false });
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
app.get('/api/v1/tasks/:id/member-additions/:requestId', async (request) => {
|
|
435
|
+
auth.authenticate(request);
|
|
436
|
+
const { id, requestId } = request.params;
|
|
437
|
+
return taskApi(() => requireTaskRooms().memberAddition(id, requestId));
|
|
438
|
+
});
|
|
439
|
+
app.patch('/api/v1/tasks/:id/layout', async (request) => {
|
|
440
|
+
const session = auth.authenticate(request, true);
|
|
441
|
+
const body = request.body;
|
|
442
|
+
const name = (v) => typeof v === 'string' && v.length > 0;
|
|
443
|
+
if (!name(body?.layout) || !(body.expectedLayout === null || name(body.expectedLayout)))
|
|
444
|
+
throw new FleetError('invalid_request', 'layout must be a layout name; expectedLayout a layout name or null');
|
|
445
|
+
const task = await taskApi(() => requireTaskRooms().setTaskLayout({ actor: { kind: 'local_control', surface: 'web' },
|
|
446
|
+
taskId: request.params.id, layout: body.layout, expectedLayout: body.expectedLayout }));
|
|
447
|
+
await audit.record({ requestId: request.id, browser: session.id, action: 'task.layout.set', result: 'succeeded' });
|
|
448
|
+
return { task: requireTaskRooms().withLayoutRooms(task) };
|
|
449
|
+
});
|
|
450
|
+
app.get('/api/v1/tasks/:id/layout', async (request) => {
|
|
451
|
+
auth.authenticate(request);
|
|
452
|
+
return { layout: await taskApi(async () => requireTaskRooms().taskLayout(request.params.id)) };
|
|
453
|
+
});
|
|
454
|
+
for (const operation of ['open', 'close']) {
|
|
455
|
+
app.post(`/api/v1/tasks/:id/layout/rooms/:room/${operation}`, async (request, reply) => {
|
|
456
|
+
const session = auth.authenticate(request, true);
|
|
457
|
+
const { id, room } = request.params;
|
|
458
|
+
const accepted = await taskApi(() => requireTaskRooms().launchTaskLayoutOperation({
|
|
459
|
+
actor: { kind: 'local_control', surface: 'web' }, taskId: id, room,
|
|
460
|
+
operation: operation === 'open' ? 'open' : 'close-room',
|
|
461
|
+
}));
|
|
462
|
+
await audit.record({ requestId: request.id, browser: session.id, action: `task.layout.${operation}`, result: 'succeeded' });
|
|
463
|
+
reply.code(202);
|
|
464
|
+
return { operation: accepted };
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
app.post('/api/v1/tasks/:id/layout/cleanup', async (request, reply) => {
|
|
468
|
+
auth.authenticate(request, true);
|
|
469
|
+
const accepted = await taskApi(() => requireTaskRooms().retryTaskLayoutCleanup({
|
|
470
|
+
actor: { kind: 'local_control', surface: 'web' }, taskId: request.params.id,
|
|
471
|
+
}));
|
|
472
|
+
reply.code(202);
|
|
473
|
+
return { operation: accepted };
|
|
474
|
+
});
|
|
475
|
+
app.get('/api/v1/task-templates', async (request) => {
|
|
476
|
+
auth.authenticate(request);
|
|
477
|
+
return { templates: requireTaskRooms().listTemplates() };
|
|
478
|
+
});
|
|
479
|
+
const layouts = () => {
|
|
480
|
+
if (!services.roomLayouts)
|
|
481
|
+
throw new FleetError('capability_unavailable', 'room layout editing is unavailable');
|
|
482
|
+
return services.roomLayouts;
|
|
483
|
+
};
|
|
484
|
+
app.get('/api/v1/room-layouts', async (request) => {
|
|
485
|
+
auth.authenticate(request);
|
|
486
|
+
const list = layouts().list(), defaultLayout = layouts().defaultLayout(list);
|
|
487
|
+
return { layouts: list, ...(defaultLayout ? { default_layout: defaultLayout } : {}) };
|
|
488
|
+
});
|
|
489
|
+
app.post('/api/v1/room-layouts/validate', async (request) => {
|
|
490
|
+
auth.authenticate(request, true);
|
|
491
|
+
return layouts().validate(request.body?.definition);
|
|
492
|
+
});
|
|
493
|
+
app.put('/api/v1/room-layouts/:name', async (request) => {
|
|
494
|
+
const session = auth.authenticate(request, true);
|
|
495
|
+
const body = request.body;
|
|
496
|
+
if (typeof body?.revision !== 'string')
|
|
497
|
+
throw new FleetError('invalid_request', 'revision is required');
|
|
498
|
+
const result = await layouts().save(request.params.name, body.revision, body.definition);
|
|
499
|
+
events.publish('room_layouts.changed', { name: result.name, revision: result.revision });
|
|
500
|
+
await audit.record({ requestId: request.id, browser: session.id, action: 'room_layout.save', result: 'succeeded' });
|
|
501
|
+
return result;
|
|
502
|
+
});
|
|
503
|
+
app.delete('/api/v1/room-layouts/:name', async (request) => {
|
|
504
|
+
const session = auth.authenticate(request, true);
|
|
505
|
+
const revision = request.query.revision;
|
|
506
|
+
if (typeof revision !== 'string' || !revision)
|
|
507
|
+
throw new FleetError('invalid_request', 'revision is required');
|
|
508
|
+
const result = await layouts().remove(request.params.name, revision);
|
|
509
|
+
events.publish('room_layouts.changed', { name: result.name });
|
|
510
|
+
await audit.record({ requestId: request.id, browser: session.id, action: 'room_layout.delete', result: 'succeeded' });
|
|
511
|
+
return result;
|
|
512
|
+
});
|
|
513
|
+
for (const action of ['start', 'block', 'unblock', 'review', 'finish', 'cancel']) {
|
|
514
|
+
app.post(`/api/v1/tasks/:id/${action}`, async (request, reply) => {
|
|
515
|
+
auth.authenticate(request, true);
|
|
516
|
+
const taskId = request.params.id;
|
|
517
|
+
const body = (request.body ?? {});
|
|
518
|
+
const input = { actor: { kind: 'local_control', surface: 'web' }, taskId };
|
|
519
|
+
const api = requireTaskRooms();
|
|
520
|
+
return taskApi(async () => {
|
|
521
|
+
switch (action) {
|
|
522
|
+
case 'start': {
|
|
523
|
+
// A task's layout can be chosen or changed but never removed, so this check cannot go stale.
|
|
524
|
+
if (!api.getTask(taskId).task.layout)
|
|
525
|
+
throw new FleetError('conflict', 'choose a room layout for this task before starting it');
|
|
526
|
+
const task = await api.startTask(input);
|
|
527
|
+
const provisioning = await api.launchTaskProvisioning(taskId);
|
|
528
|
+
if (provisioning.kind !== 'ready')
|
|
529
|
+
reply.code(202);
|
|
530
|
+
return { task, provisioning };
|
|
531
|
+
}
|
|
532
|
+
case 'block':
|
|
533
|
+
if (typeof body.reason !== 'string' || !body.reason.trim())
|
|
534
|
+
throw new FleetError('invalid_request', 'reason is required');
|
|
535
|
+
return { task: api.blockTask({ ...input, reason: body.reason }) };
|
|
536
|
+
case 'unblock': return { task: api.unblockTask(input) };
|
|
537
|
+
case 'review': return { task: api.reviewTask(input) };
|
|
538
|
+
case 'finish':
|
|
539
|
+
case 'cancel': {
|
|
540
|
+
const plan = action === 'finish' ? await api.finishTask(input) : await api.cancelTask(input);
|
|
541
|
+
const task = plan.settlementRequired ? await api.launchTaskSettlement(taskId) : plan.task;
|
|
542
|
+
const pending = task.terminal_intent?.status === 'pending';
|
|
543
|
+
if (pending)
|
|
544
|
+
reply.code(202);
|
|
545
|
+
return { task, pending };
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
app.get('/api/v1/configuration/provenance', async (request) => {
|
|
552
|
+
auth.authenticate(request);
|
|
553
|
+
if (!services.presetProvenance)
|
|
554
|
+
throw new FleetError('capability_unavailable', 'preset provenance is unavailable');
|
|
555
|
+
return { provenance: services.presetProvenance.read() };
|
|
556
|
+
});
|
|
248
557
|
app.get('/api/v1/configuration', async (request) => {
|
|
249
558
|
auth.authenticate(request);
|
|
250
559
|
if (!services.configuration)
|
|
251
560
|
throw new FleetError('capability_unavailable', 'fleet configuration editing is unavailable');
|
|
252
|
-
return services.configuration.read();
|
|
561
|
+
return services.configuration.read(request.query.includeDefinitions === 'true');
|
|
253
562
|
});
|
|
254
563
|
app.post('/api/v1/configuration/preview', async (request) => {
|
|
255
564
|
auth.authenticate(request, true);
|
|
@@ -270,6 +579,86 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
270
579
|
});
|
|
271
580
|
return result;
|
|
272
581
|
});
|
|
582
|
+
// Claude Code / Codex subscription profiles. Responses carry account metadata
|
|
583
|
+
// only; token values never leave the CLI-owned credential files.
|
|
584
|
+
const subscriptions = () => {
|
|
585
|
+
if (!services.subscriptions)
|
|
586
|
+
throw new FleetError('capability_unavailable', 'subscription management is unavailable');
|
|
587
|
+
return services.subscriptions;
|
|
588
|
+
};
|
|
589
|
+
const provider = (raw) => {
|
|
590
|
+
if (!isProvider(raw))
|
|
591
|
+
throw new FleetError('invalid_request', 'unknown subscription provider');
|
|
592
|
+
return raw;
|
|
593
|
+
};
|
|
594
|
+
const subscriptionsChanged = () => events.publish('subscription.changed', {});
|
|
595
|
+
app.get('/api/v1/subscriptions', async (request) => {
|
|
596
|
+
auth.authenticate(request);
|
|
597
|
+
return { providers: await subscriptions().list() };
|
|
598
|
+
});
|
|
599
|
+
app.post('/api/v1/subscriptions/:provider/logins', async (request, reply) => {
|
|
600
|
+
const session = auth.authenticate(request, true);
|
|
601
|
+
const login = await subscriptions().startLogin(provider(request.params.provider), session.id);
|
|
602
|
+
await audit.record({ requestId: request.id, browser: session.id, action: `subscription.login.${request.params.provider}`, result: login.state });
|
|
603
|
+
reply.code(201);
|
|
604
|
+
return login;
|
|
605
|
+
});
|
|
606
|
+
app.get('/api/v1/subscriptions/:provider/logins/:loginId', async (request) => {
|
|
607
|
+
const session = auth.authenticate(request);
|
|
608
|
+
return subscriptions().login(request.params.loginId, session.id).view();
|
|
609
|
+
});
|
|
610
|
+
app.post('/api/v1/subscriptions/:provider/logins/:loginId/code', async (request) => {
|
|
611
|
+
const session = auth.authenticate(request, true);
|
|
612
|
+
const code = request.body?.code;
|
|
613
|
+
if (typeof code !== 'string')
|
|
614
|
+
throw new FleetError('invalid_request', 'code is required');
|
|
615
|
+
const login = subscriptions().login(request.params.loginId, session.id);
|
|
616
|
+
login.submitCode(code.trim());
|
|
617
|
+
await audit.record({ requestId: request.id, browser: session.id, action: `subscription.login.code.${request.params.provider}`, result: 'submitted' });
|
|
618
|
+
return login.view();
|
|
619
|
+
});
|
|
620
|
+
app.delete('/api/v1/subscriptions/:provider/logins/:loginId', async (request) => {
|
|
621
|
+
const session = auth.authenticate(request, true);
|
|
622
|
+
const login = subscriptions().login(request.params.loginId, session.id);
|
|
623
|
+
login.cancel();
|
|
624
|
+
return login.view();
|
|
625
|
+
});
|
|
626
|
+
app.post('/api/v1/subscriptions/:provider/active', async (request) => {
|
|
627
|
+
const session = auth.authenticate(request, true);
|
|
628
|
+
const profileId = request.body?.profileId;
|
|
629
|
+
if (typeof profileId !== 'string')
|
|
630
|
+
throw new FleetError('invalid_request', 'profileId is required');
|
|
631
|
+
const view = await subscriptions().setActive(provider(request.params.provider), profileId);
|
|
632
|
+
subscriptionsChanged();
|
|
633
|
+
await audit.record({ requestId: request.id, browser: session.id, action: `subscription.activate.${request.params.provider}`, result: 'succeeded' });
|
|
634
|
+
return view;
|
|
635
|
+
});
|
|
636
|
+
app.post('/api/v1/subscriptions/:provider/profiles/:profileId/check', async (request) => {
|
|
637
|
+
auth.authenticate(request, true);
|
|
638
|
+
return subscriptions().check(provider(request.params.provider), request.params.profileId);
|
|
639
|
+
});
|
|
640
|
+
app.post('/api/v1/subscriptions/claude/profiles/:profileId/probe', async (request) => {
|
|
641
|
+
const session = auth.authenticate(request, true);
|
|
642
|
+
const usage = await subscriptions().probeClaudeUsage(request.params.profileId);
|
|
643
|
+
await audit.record({ requestId: request.id, browser: session.id, action: 'subscription.usage.probe.claude', result: usage.source });
|
|
644
|
+
return { usage };
|
|
645
|
+
});
|
|
646
|
+
app.patch('/api/v1/subscriptions/:provider/profiles/:profileId', async (request) => {
|
|
647
|
+
auth.authenticate(request, true);
|
|
648
|
+
const label = request.body?.label;
|
|
649
|
+
if (typeof label !== 'string')
|
|
650
|
+
throw new FleetError('invalid_request', 'label is required');
|
|
651
|
+
await subscriptions().rename(provider(request.params.provider), request.params.profileId, label);
|
|
652
|
+
subscriptionsChanged();
|
|
653
|
+
return { ok: true };
|
|
654
|
+
});
|
|
655
|
+
app.delete('/api/v1/subscriptions/:provider/profiles/:profileId', async (request) => {
|
|
656
|
+
const session = auth.authenticate(request, true);
|
|
657
|
+
await subscriptions().remove(provider(request.params.provider), request.params.profileId);
|
|
658
|
+
subscriptionsChanged();
|
|
659
|
+
await audit.record({ requestId: request.id, browser: session.id, action: `subscription.remove.${request.params.provider}`, result: 'succeeded' });
|
|
660
|
+
return { ok: true };
|
|
661
|
+
});
|
|
273
662
|
app.get('/api/v1/topology', async (request) => {
|
|
274
663
|
auth.authenticate(request);
|
|
275
664
|
if (!services.topology)
|
|
@@ -317,6 +706,20 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
317
706
|
return result;
|
|
318
707
|
});
|
|
319
708
|
const oursTools = services.oursTools ?? new SupervisorOursTools();
|
|
709
|
+
app.get('/api/v1/roles/:id/contacts', async (request) => {
|
|
710
|
+
auth.authenticate(request);
|
|
711
|
+
const control = await services.session(request.params.id);
|
|
712
|
+
if (!control.agentContacts)
|
|
713
|
+
throw new FleetError('capability_unavailable', 'Supervisor contacts API is unavailable');
|
|
714
|
+
return control.agentContacts();
|
|
715
|
+
});
|
|
716
|
+
app.get('/api/v1/roles/:id/messages', async (request) => {
|
|
717
|
+
auth.authenticate(request);
|
|
718
|
+
const control = await services.session(request.params.id);
|
|
719
|
+
if (!control.agentHistory)
|
|
720
|
+
throw new FleetError('capability_unavailable', 'Supervisor history API is unavailable');
|
|
721
|
+
return control.agentHistory({ peer_cid: request.query.peer_cid, ...(request.query.limit !== undefined ? { limit: Number(request.query.limit) } : {}), ...(request.query.before_seq !== undefined ? { before_seq: Number(request.query.before_seq) } : {}) });
|
|
722
|
+
});
|
|
320
723
|
app.get('/api/v1/roles/:id/ours/tools', async (request) => {
|
|
321
724
|
auth.authenticate(request);
|
|
322
725
|
return oursTools.list(request.params.id);
|
|
@@ -330,7 +733,13 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
330
733
|
});
|
|
331
734
|
app.get('/api/v1/roles/:id', async (request) => {
|
|
332
735
|
auth.authenticate(request);
|
|
333
|
-
|
|
736
|
+
const detail = await services.query.detail(request.params.id);
|
|
737
|
+
return { ...detail, chatIdle: detail.role.lifetime === 'temporary' ? readChatIdle(agentDir(request.params.id, true)) ?? null : null };
|
|
738
|
+
});
|
|
739
|
+
app.get('/api/v1/roles/:id/voice-capabilities', async (request) => {
|
|
740
|
+
auth.authenticate(request);
|
|
741
|
+
const descriptor = await (await services.session(request.params.id)).describe();
|
|
742
|
+
return { supported: ['generation_bound_prompts', 'idle_bound_prompts', 'targeted_voice_interrupt'].every(f => descriptor.features.includes(f)) };
|
|
334
743
|
});
|
|
335
744
|
app.get('/api/v1/roles/:id/removal-preview', async (request) => {
|
|
336
745
|
auth.authenticate(request);
|
|
@@ -365,15 +774,103 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
365
774
|
const control = await services.session(request.params.id);
|
|
366
775
|
if (!control.conversationPage)
|
|
367
776
|
throw new FleetError('capability_unavailable', 'this role has no conversation ledger');
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
777
|
+
const limit = request.query.limit ? Number(request.query.limit) : undefined;
|
|
778
|
+
// `latest` / `before` page backwards from the newest event; `after` pages forward for live updates.
|
|
779
|
+
const backward = request.query.latest === '1' || request.query.before !== undefined;
|
|
780
|
+
if (backward && request.query.after !== undefined)
|
|
781
|
+
throw new FleetError('invalid_request', 'after cannot be combined with latest or before');
|
|
782
|
+
if (backward && !control.conversationTail)
|
|
783
|
+
throw new FleetError('capability_unavailable', 'this role cannot page its conversation backwards');
|
|
784
|
+
const role = await services.repository.get(request.params.id);
|
|
785
|
+
const stateDir = role ? services.repository.stateDir(role) : undefined;
|
|
786
|
+
const present = (event) => presentAttachmentEvent(stateDir, request.params.id, event);
|
|
787
|
+
if (backward) {
|
|
788
|
+
const page = await control.conversationTail({ before: request.query.before, limit });
|
|
789
|
+
return { ...page, events: page.events.map(present), context: page.context.map(present) };
|
|
790
|
+
}
|
|
791
|
+
const page = await control.conversationPage({ after: request.query.after, limit });
|
|
792
|
+
return { ...page, events: page.events.map(present) };
|
|
793
|
+
});
|
|
794
|
+
app.get('/api/v1/roles/:id/artifacts/:artifactId', async (request, reply) => {
|
|
795
|
+
auth.authenticate(request);
|
|
796
|
+
const role = await services.repository.get(request.params.id);
|
|
797
|
+
if (!role)
|
|
798
|
+
throw new FleetError('role_not_found', 'Agent not found');
|
|
799
|
+
const stateDir = services.repository.stateDir(role);
|
|
800
|
+
if (!stateDir)
|
|
801
|
+
throw new FleetError('resource_not_found', 'Agent file not found');
|
|
802
|
+
try {
|
|
803
|
+
const { record, bytes } = await readDeliveredFile(stateDir, request.params.artifactId);
|
|
804
|
+
if (!await conversationHasAttachment(stateDir, record))
|
|
805
|
+
throw Error('ARTIFACT_NOT_PUBLISHED');
|
|
806
|
+
reply.header('Cache-Control', 'private, no-store');
|
|
807
|
+
reply.header('X-Content-Type-Options', 'nosniff');
|
|
808
|
+
reply.header('Content-Security-Policy', "default-src 'none'; sandbox");
|
|
809
|
+
reply.header('Content-Disposition', `attachment; filename*=UTF-8''${encodeURIComponent(record.name).replace(/'/g, '%27')}`);
|
|
810
|
+
return reply.type('application/octet-stream').send(bytes);
|
|
811
|
+
}
|
|
812
|
+
catch {
|
|
813
|
+
throw new FleetError('resource_not_found', 'Agent file unavailable');
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
app.get('/api/v1/roles/:id/attachments/:attachmentId', async (request, reply) => {
|
|
817
|
+
auth.authenticate(request);
|
|
818
|
+
const role = await services.repository.get(request.params.id);
|
|
819
|
+
if (!role)
|
|
820
|
+
throw new FleetError('role_not_found', 'Agent not found');
|
|
821
|
+
const stateDir = services.repository.stateDir(role);
|
|
822
|
+
if (!stateDir)
|
|
823
|
+
throw new FleetError('capability_unavailable', 'Agent file storage is unavailable');
|
|
824
|
+
const { record, bytes } = readAgentAttachment(stateDir, request.params.attachmentId);
|
|
825
|
+
const image = /^image\/(png|jpeg|gif|webp|avif)$/.test(record.mimeType);
|
|
826
|
+
reply.header('Cache-Control', 'private, no-store');
|
|
827
|
+
reply.header('X-Content-Type-Options', 'nosniff');
|
|
828
|
+
reply.header('Content-Security-Policy', "default-src 'none'; sandbox");
|
|
829
|
+
reply.header('Content-Disposition', `${image ? 'inline' : 'attachment'}; filename*=UTF-8''${encodeURIComponent(record.name).replace(/'/g, '%27')}`);
|
|
830
|
+
return reply.type(image ? record.mimeType : 'application/octet-stream').send(bytes);
|
|
831
|
+
});
|
|
832
|
+
app.post('/api/v1/roles/:id/attachments', { bodyLimit: MAX_ATTACHMENT_BODY }, async (request) => {
|
|
833
|
+
auth.authenticate(request, true);
|
|
834
|
+
const role = await services.repository.get(request.params.id);
|
|
835
|
+
if (!role)
|
|
836
|
+
throw new FleetError('role_not_found', 'Agent not found');
|
|
837
|
+
const stateDir = services.repository.stateDir(role);
|
|
838
|
+
if (!stateDir)
|
|
839
|
+
throw new FleetError('capability_unavailable', 'Agent file storage is unavailable');
|
|
840
|
+
const body = request.body;
|
|
841
|
+
if (typeof body?.expectedSessionGeneration !== 'string' || !body.expectedSessionGeneration.trim())
|
|
842
|
+
throw new FleetError('invalid_request', 'expectedSessionGeneration is required for attachments');
|
|
843
|
+
const control = await services.session(request.params.id);
|
|
844
|
+
if (!control.conversationPage || !control.submitPromptV2)
|
|
845
|
+
throw new FleetError('capability_unavailable', 'Session-bound attachments are unavailable');
|
|
846
|
+
const page = await control.conversationPage({ limit: 1 });
|
|
847
|
+
if (page.snapshot.sessionGeneration !== body.expectedSessionGeneration)
|
|
848
|
+
throw new FleetError('stale_state', 'Agent session changed. Select the files again.');
|
|
849
|
+
return storeAgentAttachment(stateDir, body.expectedSessionGeneration, request.body);
|
|
372
850
|
});
|
|
373
851
|
app.post('/api/v1/roles/:id/input', async (request, reply) => {
|
|
374
852
|
const session = auth.authenticate(request, true);
|
|
375
853
|
const body = request.body;
|
|
376
|
-
|
|
854
|
+
if (body?.expectedSessionGeneration !== undefined && (typeof body.expectedSessionGeneration !== 'string' || !body.expectedSessionGeneration.trim()))
|
|
855
|
+
throw new FleetError('invalid_request', 'expectedSessionGeneration must be a nonempty string');
|
|
856
|
+
if (body?.requireIdle !== undefined && typeof body.requireIdle !== 'boolean')
|
|
857
|
+
throw new FleetError('invalid_request', 'requireIdle must be boolean');
|
|
858
|
+
let text = String(body?.text ?? '');
|
|
859
|
+
if (body?.attachments !== undefined) {
|
|
860
|
+
if (typeof body.commandId !== 'string' || !body.commandId.trim())
|
|
861
|
+
throw new FleetError('invalid_request', 'commandId is required for attachments');
|
|
862
|
+
if (typeof body.expectedSessionGeneration !== 'string' || !body.expectedSessionGeneration.trim())
|
|
863
|
+
throw new FleetError('invalid_request', 'expectedSessionGeneration is required for attachments');
|
|
864
|
+
const role = await services.repository.get(request.params.id);
|
|
865
|
+
if (!role)
|
|
866
|
+
throw new FleetError('role_not_found', 'Agent not found');
|
|
867
|
+
const stateDir = services.repository.stateDir(role);
|
|
868
|
+
if (!stateDir)
|
|
869
|
+
throw new FleetError('capability_unavailable', 'Agent file storage is unavailable');
|
|
870
|
+
const originalText = text;
|
|
871
|
+
text = attachmentPrompt(stateDir, body.expectedSessionGeneration, body.attachments, text);
|
|
872
|
+
prepareAttachmentPresentation(stateDir, body.expectedSessionGeneration, body.commandId, body.attachments, originalText, text);
|
|
873
|
+
}
|
|
377
874
|
const commandId = typeof body?.commandId === 'string' && body.commandId.trim()
|
|
378
875
|
? body.commandId : undefined;
|
|
379
876
|
const control = await services.session(request.params.id);
|
|
@@ -384,6 +881,7 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
384
881
|
const admittedCommandId = commandId ?? randomBytes(16).toString('hex');
|
|
385
882
|
const receipt = await control.submitPromptV2({
|
|
386
883
|
commandId: admittedCommandId, text, source: 'owner_admin_console',
|
|
884
|
+
expectedSessionGeneration: body.expectedSessionGeneration, requireIdle: body.requireIdle === true,
|
|
387
885
|
actorBrowserSession: createHmac('sha256', digestKey).update(session.id).digest('hex').slice(0, 24),
|
|
388
886
|
});
|
|
389
887
|
await audit.record({
|
|
@@ -395,6 +893,8 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
395
893
|
reply.code(202);
|
|
396
894
|
return receipt;
|
|
397
895
|
}
|
|
896
|
+
if (body.expectedSessionGeneration !== undefined || body.requireIdle)
|
|
897
|
+
throw new FleetError('capability_unavailable', 'session-bound voice input is unavailable for this role');
|
|
398
898
|
const receipt = await control.sendText(text);
|
|
399
899
|
await audit.record({
|
|
400
900
|
requestId: request.id, browser: session.id, roleId: request.params.id,
|
|
@@ -410,6 +910,16 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
410
910
|
const commandId = typeof body?.commandId === 'string' && body.commandId.trim()
|
|
411
911
|
? body.commandId : undefined;
|
|
412
912
|
const control = await services.session(request.params.id);
|
|
913
|
+
if (body?.expectedSessionGeneration !== undefined || body?.promptId !== undefined) {
|
|
914
|
+
if (!commandId || typeof body.expectedSessionGeneration !== 'string' || !body.expectedSessionGeneration.trim() || typeof body.promptId !== 'string' || !body.promptId.trim())
|
|
915
|
+
throw new FleetError('invalid_request', 'Targeted interrupt requires commandId, expectedSessionGeneration and promptId');
|
|
916
|
+
if (!control.interruptPromptV2)
|
|
917
|
+
throw new FleetError('capability_unavailable', 'Targeted voice interrupt is unavailable');
|
|
918
|
+
const receipt = await control.interruptPromptV2({ commandId, expectedSessionGeneration: body.expectedSessionGeneration, promptId: body.promptId });
|
|
919
|
+
await audit.record({ requestId: request.id, browser: session.id, roleId: request.params.id, action: 'session.interrupt_voice', result: 'accepted' });
|
|
920
|
+
reply.code(202);
|
|
921
|
+
return receipt;
|
|
922
|
+
}
|
|
413
923
|
if (commandId && control.interruptV2) {
|
|
414
924
|
const receipt = await control.interruptV2(commandId);
|
|
415
925
|
await audit.record({
|
|
@@ -460,10 +970,22 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
460
970
|
const body = request.body;
|
|
461
971
|
if (!body.action || !['start', 'stop', 'restart_resume', 'restart_fresh'].includes(body.action))
|
|
462
972
|
throw new FleetError('invalid_request', 'invalid lifecycle action');
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
973
|
+
let receipt;
|
|
974
|
+
try {
|
|
975
|
+
receipt = await services.commands.execute({
|
|
976
|
+
roleId: request.params.id, action: body.action,
|
|
977
|
+
actionId: body.actionId, confirmation: body.confirmation,
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
catch (error) {
|
|
981
|
+
// An existing receipt always wins: a conflicting/repeated action is not a
|
|
982
|
+
// proof that the original operation was never admitted.
|
|
983
|
+
if (typeof body.actionId === 'string' && !services.commands.get(body.actionId)) {
|
|
984
|
+
const normalized = normalizeError(error);
|
|
985
|
+
return reply.code(409).send({ error: { code: 'action_not_accepted', message: normalized.message }, accepted: false });
|
|
986
|
+
}
|
|
987
|
+
throw error;
|
|
988
|
+
}
|
|
467
989
|
events.publish('action.changed', receipt, request.params.id);
|
|
468
990
|
reply.code(202);
|
|
469
991
|
return receipt;
|
|
@@ -482,6 +1004,75 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
482
1004
|
throw new FleetError('role_not_found', 'creation action not found');
|
|
483
1005
|
return action;
|
|
484
1006
|
});
|
|
1007
|
+
// A fetch stream works through the same authenticated workspace transport as
|
|
1008
|
+
// ordinary requests, and owns one ACP controller until its browser disconnects.
|
|
1009
|
+
app.post('/api/v1/roles/:id/live-presence', async (request, reply) => {
|
|
1010
|
+
const browser = auth.authenticate(request, true);
|
|
1011
|
+
const generation = request.body?.expectedSessionGeneration;
|
|
1012
|
+
if (typeof generation !== 'string' || !generation.trim())
|
|
1013
|
+
throw new FleetError('invalid_request', 'expectedSessionGeneration is required');
|
|
1014
|
+
const control = await services.session(request.params.id);
|
|
1015
|
+
if (!control.followConversation || !control.conversationPage)
|
|
1016
|
+
throw new FleetError('capability_unavailable', 'Live voice requires a conversation controller');
|
|
1017
|
+
const page = await control.conversationPage({ limit: 1 });
|
|
1018
|
+
if (page.snapshot.sessionGeneration !== generation)
|
|
1019
|
+
throw new FleetError('stale_state', 'Agent session changed. Start live voice again.');
|
|
1020
|
+
// Session/page discovery can await I/O; recheck revocation before attaching.
|
|
1021
|
+
auth.authenticate(request, true);
|
|
1022
|
+
if (reply.raw.destroyed)
|
|
1023
|
+
return;
|
|
1024
|
+
reply.hijack();
|
|
1025
|
+
for (const [name, value] of Object.entries(reply.getHeaders()))
|
|
1026
|
+
if (value !== undefined)
|
|
1027
|
+
reply.raw.setHeader(name, Array.isArray(value) ? value : String(value));
|
|
1028
|
+
reply.raw.writeHead(200, { 'Content-Type': 'application/x-ndjson', 'Cache-Control': 'no-store', 'X-Accel-Buffering': 'no' });
|
|
1029
|
+
let ended = false;
|
|
1030
|
+
let follow;
|
|
1031
|
+
let heartbeat;
|
|
1032
|
+
let unbind;
|
|
1033
|
+
const close = () => { if (ended)
|
|
1034
|
+
return; ended = true; unbind?.(); if (heartbeat)
|
|
1035
|
+
clearInterval(heartbeat); follow?.close(); reply.raw.end(); };
|
|
1036
|
+
const write = (value) => { if (!ended && !reply.raw.write(JSON.stringify(value) + '\n'))
|
|
1037
|
+
close(); };
|
|
1038
|
+
reply.raw.once('close', close);
|
|
1039
|
+
// A voice session outlives one access credential; its page renews this stream by name.
|
|
1040
|
+
const renewal = browser.rotating ? randomBytes(32).toString('base64url') : undefined;
|
|
1041
|
+
unbind = auth.bindTransport(browser, close, renewal);
|
|
1042
|
+
try {
|
|
1043
|
+
follow = await control.followConversation({
|
|
1044
|
+
after: page.nextCursor,
|
|
1045
|
+
onPage: current => { if (current.snapshot.sessionGeneration !== generation) {
|
|
1046
|
+
write({ error: 'Agent session changed. Start live voice again.' });
|
|
1047
|
+
close();
|
|
1048
|
+
}
|
|
1049
|
+
else
|
|
1050
|
+
write({ ready: true, ...(renewal ? { renewal } : {}) }); },
|
|
1051
|
+
onEvent: event => { if (event.sessionGeneration !== generation) {
|
|
1052
|
+
write({ error: 'Agent session changed. Start live voice again.' });
|
|
1053
|
+
close();
|
|
1054
|
+
} },
|
|
1055
|
+
onClose: () => close(),
|
|
1056
|
+
});
|
|
1057
|
+
if (ended)
|
|
1058
|
+
follow.close();
|
|
1059
|
+
// A renewable stream is ended by its own deadline and by revocation, not by the first credential's expiry.
|
|
1060
|
+
else
|
|
1061
|
+
heartbeat = setInterval(() => { try {
|
|
1062
|
+
if (!renewal)
|
|
1063
|
+
auth.authenticate(request);
|
|
1064
|
+
write({ heartbeat: true });
|
|
1065
|
+
}
|
|
1066
|
+
catch {
|
|
1067
|
+
close();
|
|
1068
|
+
} }, 10_000);
|
|
1069
|
+
}
|
|
1070
|
+
catch {
|
|
1071
|
+
write({ error: 'Agent controller connection failed.' });
|
|
1072
|
+
close();
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
app.post('/api/v1/transports/:id/renew', async (request) => auth.renewTransport(request, request.params.id));
|
|
485
1076
|
app.post('/api/v1/ws-tickets', async (request) => {
|
|
486
1077
|
const body = request.body;
|
|
487
1078
|
if (!body?.purpose || !['events', 'conversation'].includes(body.purpose))
|
|
@@ -516,7 +1107,7 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
516
1107
|
requireSubprotocol(request, 'ours-fleet-events.v1');
|
|
517
1108
|
authorizeSocket(socket, request, async (hello) => {
|
|
518
1109
|
const session = auth.consumeTicket(request, String(hello.ticket ?? ''), 'events');
|
|
519
|
-
auth.bindSocket(session
|
|
1110
|
+
auth.bindSocket(session, socket);
|
|
520
1111
|
const detach = events.attach(socket, typeof hello.lastEventId === 'string' ? hello.lastEventId : undefined);
|
|
521
1112
|
socket.on('close', detach);
|
|
522
1113
|
socket.send(JSON.stringify({ kind: 'ready', at: new Date().toISOString() }));
|
|
@@ -526,7 +1117,7 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
526
1117
|
requireSubprotocol(request, 'ours-fleet-conversation.v1');
|
|
527
1118
|
authorizeSocket(socket, request, async (hello) => {
|
|
528
1119
|
const session = auth.consumeTicket(request, String(hello.ticket ?? ''), 'conversation', request.params.id);
|
|
529
|
-
auth.bindSocket(session
|
|
1120
|
+
auth.bindSocket(session, socket);
|
|
530
1121
|
const control = await services.session(request.params.id);
|
|
531
1122
|
if (!control.followConversation)
|
|
532
1123
|
throw new FleetError('capability_unavailable', 'this role has no conversation ledger');
|
|
@@ -551,6 +1142,9 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
551
1142
|
}
|
|
552
1143
|
socket.send(JSON.stringify(payload));
|
|
553
1144
|
};
|
|
1145
|
+
const role = await services.repository.get(request.params.id);
|
|
1146
|
+
const stateDir = role ? services.repository.stateDir(role) : undefined;
|
|
1147
|
+
const present = (event) => presentAttachmentEvent(stateDir, request.params.id, event);
|
|
554
1148
|
const follow = await control.followConversation({
|
|
555
1149
|
after,
|
|
556
1150
|
onPage: page => {
|
|
@@ -561,11 +1155,11 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
561
1155
|
lastCursor: page.nextCursor ?? after,
|
|
562
1156
|
});
|
|
563
1157
|
if (page.events.length)
|
|
564
|
-
guardedSend({ type: 'events', events: page.events });
|
|
1158
|
+
guardedSend({ type: 'events', events: page.events.map(present) });
|
|
565
1159
|
if (page.hasMore)
|
|
566
1160
|
guardedSend({ type: 'resync.required' });
|
|
567
1161
|
},
|
|
568
|
-
onEvent: event => guardedSend({ type: 'events', events: [event] }),
|
|
1162
|
+
onEvent: event => guardedSend({ type: 'events', events: [present(event)] }),
|
|
569
1163
|
onClose: reason => {
|
|
570
1164
|
if (socket.readyState === socket.OPEN)
|
|
571
1165
|
socket.close(4409, (reason ?? 'conversation stream ended').slice(0, 120));
|
|
@@ -578,15 +1172,8 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
578
1172
|
socket.on('close', () => { clearInterval(heartbeat); follow.close(); });
|
|
579
1173
|
});
|
|
580
1174
|
});
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
await app.register(fastifyStatic, { root: staticRoot, prefix: '/' });
|
|
584
|
-
app.setNotFoundHandler((request, reply) => {
|
|
585
|
-
if (request.url.startsWith('/api/'))
|
|
586
|
-
return reply.code(404).send({ error: 'not found' });
|
|
587
|
-
return reply.sendFile('index.html');
|
|
588
|
-
});
|
|
589
|
-
}
|
|
1175
|
+
// Fleet has no pages of its own; every screen belongs to the App.
|
|
1176
|
+
app.setNotFoundHandler((_request, reply) => reply.code(404).send({ error: 'not found' }));
|
|
590
1177
|
return {
|
|
591
1178
|
app, auth, audit, events,
|
|
592
1179
|
async close() {
|
|
@@ -599,17 +1186,17 @@ export async function buildWebServer(services, boundary, options = {}) {
|
|
|
599
1186
|
function setAuthCookies(reply, session, device, secure = false) {
|
|
600
1187
|
const suffix = secure ? '; Secure' : '';
|
|
601
1188
|
reply.header('Set-Cookie', [
|
|
602
|
-
`ofs_session=${encodeURIComponent(session)}; HttpOnly; SameSite=Strict; Path
|
|
603
|
-
`ofs_device=${encodeURIComponent(device)}; HttpOnly; SameSite=Strict; Path
|
|
1189
|
+
`ofs_session=${encodeURIComponent(session)}; HttpOnly; SameSite=Strict; Path=/; Max-Age=28800${suffix}`,
|
|
1190
|
+
`ofs_device=${encodeURIComponent(device)}; HttpOnly; SameSite=Strict; Path=/; Max-Age=2592000${suffix}`,
|
|
604
1191
|
]);
|
|
605
1192
|
}
|
|
606
1193
|
function setSessionCookie(reply, session, secure = false) {
|
|
607
|
-
reply.header('Set-Cookie', `ofs_session=${encodeURIComponent(session)}; HttpOnly; SameSite=Strict; Path
|
|
1194
|
+
reply.header('Set-Cookie', `ofs_session=${encodeURIComponent(session)}; HttpOnly; SameSite=Strict; Path=/; Max-Age=28800${secure ? '; Secure' : ''}`);
|
|
608
1195
|
}
|
|
609
1196
|
function clearAuthCookies(reply) {
|
|
610
1197
|
reply.header('Set-Cookie', [
|
|
611
|
-
'ofs_session=; HttpOnly; SameSite=Strict; Path
|
|
612
|
-
'ofs_device=; HttpOnly; SameSite=Strict; Path
|
|
1198
|
+
'ofs_session=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0',
|
|
1199
|
+
'ofs_device=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0',
|
|
613
1200
|
]);
|
|
614
1201
|
}
|
|
615
1202
|
function promoteRequest(body) {
|
|
@@ -623,9 +1210,6 @@ function promoteRequest(body) {
|
|
|
623
1210
|
};
|
|
624
1211
|
}
|
|
625
1212
|
function cryptoRandomId() { return randomBytes(12).toString('hex'); }
|
|
626
|
-
function escapeHtml(value) {
|
|
627
|
-
return value.replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char]));
|
|
628
|
-
}
|
|
629
1213
|
function requireSubprotocol(request, expected) {
|
|
630
1214
|
const protocols = String(request.headers['sec-websocket-protocol'] ?? '')
|
|
631
1215
|
.split(',').map(value => value.trim());
|