@cortex-agent/server 2026.10.15 → 2026.10.25
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 +81 -51
- package/defaults/board/board.css +140 -62
- package/defaults/board/scaffold.html +36 -13
- package/defaults/config/environments/creative.json +0 -1
- package/defaults/config/environments/main.json +1 -2
- package/defaults/context/projects/AGENTS.md +1 -1
- package/defaults/gitignore +3 -3
- package/defaults/hooks/new-session-hook.mjs +1 -1
- package/defaults/hooks/status-md-guard.mjs +6 -6
- package/defaults/plugins/cortex-board/skills/board/SKILL.md +30 -22
- package/defaults/plugins/cortex-system/plugin.json +2 -2
- package/defaults/plugins/cortex-system/skills/browser/SKILL.md +56 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +16 -9
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +2 -2
- package/defaults/rules/agents-md.md +1 -1
- package/defaults/rules/issues-md.md +1 -1
- package/defaults/rules/meta-conventions.md +3 -3
- package/defaults/rules/mission-md.md +1 -1
- package/defaults/rules/status-md.md +1 -1
- package/dist/agent-adapter/claude/adapter.d.ts +2 -5
- package/dist/agent-adapter/claude/adapter.js +6 -5
- package/dist/agent-adapter/claude/assistant-blocks.d.ts +5 -0
- package/dist/agent-adapter/claude/assistant-blocks.js +61 -0
- package/dist/agent-adapter/claude/bg-task-tracker.d.ts +3 -1
- package/dist/agent-adapter/claude/bg-task-tracker.js +6 -2
- package/dist/agent-adapter/claude/cache-refresh.d.ts +58 -0
- package/dist/agent-adapter/claude/cache-refresh.js +145 -0
- package/dist/agent-adapter/claude/cache-touch.d.ts +12 -0
- package/dist/agent-adapter/claude/cache-touch.js +75 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +8 -3
- package/dist/agent-adapter/claude/event-parser.js +33 -17
- package/dist/agent-adapter/claude/event-translator.d.ts +2 -0
- package/dist/agent-adapter/claude/event-translator.js +2 -0
- package/dist/agent-adapter/claude/mcp-config.js +11 -0
- package/dist/agent-adapter/claude/session-options.d.ts +6 -13
- package/dist/agent-adapter/claude/session-options.js +2 -13
- package/dist/agent-adapter/claude/spawn-args.d.ts +4 -21
- package/dist/agent-adapter/claude/spawn-args.js +17 -24
- package/dist/agent-adapter/claude/transcript-clear.d.ts +42 -0
- package/dist/agent-adapter/claude/transcript-clear.js +217 -0
- package/dist/agent-adapter/claude/turn-machine.d.ts +5 -3
- package/dist/agent-adapter/claude/turn-machine.js +29 -73
- package/dist/agent-adapter/claude/window-warmup.d.ts +13 -0
- package/dist/agent-adapter/claude/window-warmup.js +38 -0
- package/dist/agent-adapter/continuation-phase.d.ts +6 -3
- package/dist/agent-adapter/continuation-phase.js +11 -3
- package/dist/agent-adapter/normalize/event-types.d.ts +8 -0
- package/dist/agent-adapter/pi/adapter.d.ts +0 -1
- package/dist/agent-adapter/pi/adapter.js +5 -13
- package/dist/agent-adapter/pi/event-parser.d.ts +1 -1
- package/dist/agent-adapter/pi/event-parser.js +43 -27
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +1 -1
- package/dist/agent-adapter/pi/pi-session.d.ts +2 -0
- package/dist/agent-adapter/pi/pi-session.js +15 -0
- package/dist/agent-adapter/pi/providers-config.d.ts +2 -2
- package/dist/agent-adapter/pi/providers-config.js +1 -1
- package/dist/agent-adapter/pi/quota-sink.d.ts +3 -3
- package/dist/agent-adapter/pi/quota-sink.js +3 -3
- package/dist/agent-adapter/pi/runtime.js +6 -1
- package/dist/agent-adapter/pi/session-options.d.ts +9 -13
- package/dist/agent-adapter/pi/session-options.js +12 -25
- package/dist/agent-adapter/run-events.d.ts +15 -10
- package/dist/agent-adapter/run-events.js +2 -0
- package/dist/agent-adapter/types.d.ts +14 -6
- package/dist/build-info.json +1 -0
- package/dist/client-bundle/client.mjs +10 -5
- package/dist/client-bundle/manifest.json +3 -3
- package/dist/core/claude-credentials.d.ts +6 -0
- package/dist/core/claude-credentials.js +11 -0
- package/dist/core/codex-quota.d.ts +1 -1
- package/dist/core/codex-quota.js +1 -1
- package/dist/core/gateway-generator.d.ts +26 -11
- package/dist/core/gateway-generator.js +73 -62
- package/dist/core/hook-bus.d.ts +1 -1
- package/dist/core/hook-bus.js +1 -8
- package/dist/core/locales/en.d.ts +52 -77
- package/dist/core/locales/slices/commands.d.ts +26 -31
- package/dist/core/locales/slices/commands.js +54 -64
- package/dist/core/locales/slices/init.d.ts +9 -19
- package/dist/core/locales/slices/init.js +19 -53
- package/dist/core/locales/slices/interactions.d.ts +3 -3
- package/dist/core/locales/slices/interactions.js +6 -6
- package/dist/core/locales/slices/notices.d.ts +1 -3
- package/dist/core/locales/slices/notices.js +2 -6
- package/dist/core/locales/slices/scheduling.d.ts +9 -9
- package/dist/core/locales/slices/scheduling.js +18 -18
- package/dist/core/locales/slices/status.d.ts +0 -4
- package/dist/core/locales/slices/status.js +0 -8
- package/dist/core/locales/slices/tui.d.ts +0 -1
- package/dist/core/locales/slices/tui.js +0 -2
- package/dist/core/locales/slices/uimsg.d.ts +4 -7
- package/dist/core/locales/slices/uimsg.js +9 -15
- package/dist/core/log.d.ts +3 -0
- package/dist/core/log.js +18 -1
- package/dist/core/models-generator.d.ts +29 -0
- package/dist/core/models-generator.js +82 -0
- package/dist/core/paths.d.ts +1 -1
- package/dist/core/paths.js +1 -1
- package/dist/core/settings-spec.d.ts +30 -0
- package/dist/core/settings-spec.js +38 -0
- package/dist/core/status-format.d.ts +3 -2
- package/dist/core/status-format.js +2 -2
- package/dist/core/types/agent-types.d.ts +3 -1
- package/dist/core/types/environment-types.d.ts +1 -8
- package/dist/domain/agents/agent-state.d.ts +11 -56
- package/dist/domain/agents/agent-state.js +48 -115
- package/dist/domain/agents/agent-switch.d.ts +2 -24
- package/dist/domain/agents/agent-switch.js +9 -72
- package/dist/domain/agents/config.d.ts +11 -61
- package/dist/domain/agents/config.js +47 -154
- package/dist/domain/agents/engine-selection.d.ts +21 -0
- package/dist/domain/agents/engine-selection.js +37 -0
- package/dist/domain/agents/environments/registry.js +4 -2
- package/dist/domain/agents/environments/resolve.js +0 -1
- package/dist/domain/agents/environments/schema.d.ts +3 -3
- package/dist/domain/agents/environments/schema.js +4 -4
- package/dist/domain/agents/index.d.ts +2 -1
- package/dist/domain/agents/index.js +3 -7
- package/dist/domain/agents/model-selection.d.ts +18 -70
- package/dist/domain/agents/model-selection.js +100 -150
- package/dist/domain/agents/models.d.ts +12 -0
- package/dist/domain/agents/models.js +94 -0
- package/dist/domain/agents/subagent/registry.d.ts +2 -0
- package/dist/domain/agents/subagent/registry.js +8 -0
- package/dist/domain/agents/subagent/runner.d.ts +5 -5
- package/dist/domain/agents/subagent/runner.js +12 -35
- package/dist/domain/auth/auth-status.d.ts +4 -4
- package/dist/domain/auth/auth-status.js +17 -28
- package/dist/domain/auth/auth-watch.js +48 -18
- package/dist/domain/auth/gateway-sync.d.ts +6 -26
- package/dist/domain/auth/gateway-sync.js +31 -75
- package/dist/domain/benchmark/identity.d.ts +3 -5
- package/dist/domain/benchmark/identity.js +0 -1
- package/dist/domain/benchmark/production-attempt-identity.d.ts +6 -5
- package/dist/domain/benchmark/production-attempt-identity.js +32 -35
- package/dist/domain/benchmark/session-evidence.d.ts +2 -1
- package/dist/domain/benchmark/session-evidence.js +8 -1
- package/dist/domain/browser/broker.d.ts +99 -0
- package/dist/domain/browser/broker.js +487 -0
- package/dist/domain/costs/claude-account.js +21 -0
- package/dist/domain/costs/rate-limit-throttle.js +3 -1
- package/dist/domain/costs/reset-account.d.ts +2 -0
- package/dist/domain/costs/usage-service.d.ts +1 -1
- package/dist/domain/costs/usage-service.js +20 -7
- package/dist/domain/mcp/tools/context.d.ts +5 -7
- package/dist/domain/mcp/tools/context.js +17 -4
- package/dist/domain/mcp/tools/subagent.js +1 -1
- package/dist/domain/mcp/tools/ui-file.js +1 -1
- package/dist/domain/monitor/event-loop-monitor.d.ts +2 -0
- package/dist/domain/monitor/event-loop-monitor.js +5 -1
- package/dist/domain/pi-providers/custom-provider-model.d.ts +1 -1
- package/dist/domain/pi-providers/custom-provider-model.js +1 -1
- package/dist/domain/plugins/authoring.d.ts +8 -1
- package/dist/domain/plugins/authoring.js +24 -9
- package/dist/domain/plugins/runtime-gc.d.ts +7 -0
- package/dist/domain/plugins/runtime-gc.js +52 -19
- package/dist/domain/plugins/runtime.js +2 -1
- package/dist/domain/remote/client-bootstrap.js +1 -1
- package/dist/domain/remote/client-manager.js +6 -1
- package/dist/domain/remote/device-browser.js +1 -1
- package/dist/domain/remote/device-chrome-commands.js +2 -0
- package/dist/domain/remote/device-port.js +2 -2
- package/dist/domain/runs/attempt.d.ts +3 -3
- package/dist/domain/runs/attempt.js +2 -3
- package/dist/domain/runs/builders.d.ts +4 -4
- package/dist/domain/runs/builders.js +4 -5
- package/dist/domain/runs/compact.d.ts +4 -17
- package/dist/domain/runs/compact.js +14 -56
- package/dist/domain/runs/config-resolver.d.ts +15 -83
- package/dist/domain/runs/config-resolver.js +24 -150
- package/dist/domain/runs/engine-spec.d.ts +8 -8
- package/dist/domain/runs/engine-spec.js +15 -31
- package/dist/domain/runs/events.d.ts +1 -1
- package/dist/domain/runs/fallback.d.ts +6 -38
- package/dist/domain/runs/fallback.js +10 -72
- package/dist/domain/runs/notices.d.ts +1 -11
- package/dist/domain/runs/notices.js +3 -30
- package/dist/domain/runs/request.d.ts +4 -3
- package/dist/domain/runs/retryable-errors.d.ts +0 -13
- package/dist/domain/runs/retryable-errors.js +3 -18
- package/dist/domain/runs/run.d.ts +12 -42
- package/dist/domain/runs/run.js +40 -147
- package/dist/domain/runs/service.d.ts +0 -9
- package/dist/domain/runs/service.js +33 -14
- package/dist/domain/runs/spec-loader.d.ts +1 -1
- package/dist/domain/runs/spend.d.ts +1 -1
- package/dist/domain/runs/spend.js +1 -1
- package/dist/domain/scheduling/builtin-job-controller.d.ts +3 -1
- package/dist/domain/scheduling/builtin-job-controller.js +5 -2
- package/dist/domain/scheduling/builtin-jobs.js +7 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +25 -19
- package/dist/domain/scheduling/schedule-ops.d.ts +0 -1
- package/dist/domain/scheduling/schedule-ops.js +2 -5
- package/dist/domain/scheduling/schedule-selection.d.ts +3 -0
- package/dist/domain/scheduling/schedule-selection.js +16 -0
- package/dist/domain/scheduling/schedule-spec.d.ts +6 -5
- package/dist/domain/scheduling/schedule-spec.js +6 -6
- package/dist/domain/scheduling/scheduler.d.ts +3 -1
- package/dist/domain/scheduling/scheduler.js +36 -26
- package/dist/domain/sessions/session-hooks.d.ts +5 -4
- package/dist/domain/sessions/session-hooks.js +15 -33
- package/dist/domain/sessions/session-lifecycle.d.ts +19 -51
- package/dist/domain/sessions/session-lifecycle.js +34 -96
- package/dist/domain/system/doctor.d.ts +3 -3
- package/dist/domain/system/doctor.js +22 -26
- package/dist/domain/system/own-bin-path.d.ts +13 -0
- package/dist/domain/system/own-bin-path.js +36 -0
- package/dist/domain/system/server-update-check.js +2 -1
- package/dist/domain/system/terminal-cli/index.d.ts +58 -0
- package/dist/domain/system/terminal-cli/index.js +100 -0
- package/dist/domain/system/terminal-cli/posix-profiles.d.ts +23 -0
- package/dist/domain/system/terminal-cli/posix-profiles.js +74 -0
- package/dist/domain/system/terminal-cli/registrar.d.ts +12 -0
- package/dist/domain/system/terminal-cli/registrar.js +1 -0
- package/dist/domain/system/terminal-cli/shims.d.ts +27 -0
- package/dist/domain/system/terminal-cli/shims.js +108 -0
- package/dist/domain/system/terminal-cli/state.d.ts +7 -0
- package/dist/domain/system/terminal-cli/state.js +36 -0
- package/dist/domain/system/terminal-cli/windows-user-path.d.ts +13 -0
- package/dist/domain/system/terminal-cli/windows-user-path.js +67 -0
- package/dist/domain/telemetry/bus-collector.d.ts +3 -0
- package/dist/domain/telemetry/bus-collector.js +22 -0
- package/dist/domain/telemetry/child-exit.d.ts +11 -0
- package/dist/domain/telemetry/child-exit.js +36 -0
- package/dist/domain/telemetry/client-kind.d.ts +4 -0
- package/dist/domain/telemetry/client-kind.js +7 -0
- package/dist/domain/telemetry/crash-limits.d.ts +15 -0
- package/dist/domain/telemetry/crash-limits.js +50 -0
- package/dist/domain/telemetry/crash.d.ts +25 -0
- package/dist/domain/telemetry/crash.js +70 -0
- package/dist/domain/telemetry/daily-upload.d.ts +5 -0
- package/dist/domain/telemetry/daily-upload.js +20 -0
- package/dist/domain/telemetry/daily.d.ts +5 -0
- package/dist/domain/telemetry/daily.js +104 -0
- package/dist/domain/telemetry/endpoint.d.ts +7 -0
- package/dist/domain/telemetry/endpoint.js +40 -0
- package/dist/domain/telemetry/envelope.d.ts +6 -0
- package/dist/domain/telemetry/envelope.js +35 -0
- package/dist/domain/telemetry/error-digest.d.ts +7 -0
- package/dist/domain/telemetry/error-digest.js +43 -0
- package/dist/domain/telemetry/funnel.d.ts +6 -0
- package/dist/domain/telemetry/funnel.js +22 -0
- package/dist/domain/telemetry/gate.d.ts +19 -0
- package/dist/domain/telemetry/gate.js +67 -0
- package/dist/domain/telemetry/heartbeat.d.ts +17 -0
- package/dist/domain/telemetry/heartbeat.js +49 -0
- package/dist/domain/telemetry/info.d.ts +9 -0
- package/dist/domain/telemetry/info.js +12 -0
- package/dist/domain/telemetry/init-answer.d.ts +12 -0
- package/dist/domain/telemetry/init-answer.js +42 -0
- package/dist/domain/telemetry/install-id.d.ts +5 -0
- package/dist/domain/telemetry/install-id.js +42 -0
- package/dist/domain/telemetry/normalize.d.ts +33 -0
- package/dist/domain/telemetry/normalize.js +88 -0
- package/dist/domain/telemetry/outbox.d.ts +18 -0
- package/dist/domain/telemetry/outbox.js +93 -0
- package/dist/domain/telemetry/panic-group.d.ts +4 -0
- package/dist/domain/telemetry/panic-group.js +51 -0
- package/dist/domain/telemetry/paths.d.ts +7 -0
- package/dist/domain/telemetry/paths.js +11 -0
- package/dist/domain/telemetry/redact.d.ts +18 -0
- package/dist/domain/telemetry/redact.js +109 -0
- package/dist/domain/telemetry/rollup-types.d.ts +81 -0
- package/dist/domain/telemetry/rollup-types.js +31 -0
- package/dist/domain/telemetry/rollup.d.ts +16 -0
- package/dist/domain/telemetry/rollup.js +102 -0
- package/dist/domain/telemetry/schema.d.ts +931 -0
- package/dist/domain/telemetry/schema.js +275 -0
- package/dist/domain/telemetry/service.d.ts +34 -0
- package/dist/domain/telemetry/service.js +146 -0
- package/dist/domain/telemetry/state.d.ts +17 -0
- package/dist/domain/telemetry/state.js +29 -0
- package/dist/domain/telemetry/turns.d.ts +17 -0
- package/dist/domain/telemetry/turns.js +176 -0
- package/dist/domain/telemetry/upgrade.d.ts +14 -0
- package/dist/domain/telemetry/upgrade.js +87 -0
- package/dist/domain/telemetry/uploader.d.ts +21 -0
- package/dist/domain/telemetry/uploader.js +82 -0
- package/dist/domain/telemetry/usage.d.ts +25 -0
- package/dist/domain/telemetry/usage.js +153 -0
- package/dist/domain/telemetry/web-report.d.ts +8 -0
- package/dist/domain/telemetry/web-report.js +15 -0
- package/dist/domain/tui-session/tui-session-service.js +1 -1
- package/dist/domain/tui-session/types.d.ts +2 -2
- package/dist/domain/ui-service/app-router.d.ts +117 -95
- package/dist/domain/ui-service/app-router.js +17 -14
- package/dist/domain/ui-service/assistant-snapshots.js +2 -0
- package/dist/domain/ui-service/contract.parity.d.ts +19 -0
- package/dist/domain/ui-service/contract.parity.js +1 -0
- package/dist/domain/ui-service/inline-media-types.d.ts +18 -0
- package/dist/domain/ui-service/inline-media-types.js +1 -0
- package/dist/domain/ui-service/input-schemas.d.ts +120 -119
- package/dist/domain/ui-service/input-schemas.js +47 -85
- package/dist/domain/ui-service/mutate/approvals.d.ts +3 -2
- package/dist/domain/ui-service/mutate/approvals.js +3 -2
- package/dist/domain/ui-service/mutate/auth.d.ts +1 -1
- package/dist/domain/ui-service/mutate/auth.js +3 -2
- package/dist/domain/ui-service/mutate/config.d.ts +0 -8
- package/dist/domain/ui-service/mutate/config.js +0 -22
- package/dist/domain/ui-service/mutate/models.d.ts +13 -0
- package/dist/domain/ui-service/mutate/models.js +137 -0
- package/dist/domain/ui-service/mutate/plugin-packages.js +1 -1
- package/dist/domain/ui-service/mutate/resolve-media.d.ts +4 -0
- package/dist/domain/ui-service/mutate/resolve-media.js +17 -0
- package/dist/domain/ui-service/mutate/sessions.d.ts +2 -2
- package/dist/domain/ui-service/mutate/sessions.js +29 -126
- package/dist/domain/ui-service/mutate/telemetry.d.ts +5 -0
- package/dist/domain/ui-service/mutate/telemetry.js +6 -0
- package/dist/domain/ui-service/query/approvals.js +4 -3
- package/dist/domain/ui-service/query/config.js +22 -42
- package/dist/domain/ui-service/query/machine-probe.d.ts +1 -1
- package/dist/domain/ui-service/query/machine-probe.js +3 -2
- package/dist/domain/ui-service/query/models.d.ts +3 -0
- package/dist/domain/ui-service/query/models.js +49 -32
- package/dist/domain/ui-service/query/plugin-source.js +4 -3
- package/dist/domain/ui-service/query/schedules.js +1 -1
- package/dist/domain/ui-service/query/sessions.js +8 -13
- package/dist/domain/ui-service/query/telemetry.d.ts +3 -0
- package/dist/domain/ui-service/query/telemetry.js +4 -0
- package/dist/domain/ui-service/trpc.d.ts +8 -3
- package/dist/domain/ui-service/trpc.js +1 -1
- package/dist/domain/ui-service/types.d.ts +71 -179
- package/dist/domain/ui-service/ui-service.d.ts +56 -53
- package/dist/domain/ui-service/ui-service.js +27 -24
- package/dist/entry/app.js +62 -21
- package/dist/entry/browser-cli.d.ts +39 -0
- package/dist/entry/browser-cli.js +317 -0
- package/dist/entry/cli-help.d.ts +1 -0
- package/dist/entry/cli-help.js +64 -20
- package/dist/entry/cli.js +16 -14
- package/dist/entry/daemon.d.ts +1 -1
- package/dist/entry/daemon.js +88 -72
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init.d.ts +10 -8
- package/dist/entry/init.js +138 -276
- package/dist/entry/path-cli.d.ts +4 -0
- package/dist/entry/path-cli.js +65 -0
- package/dist/entry/schedule-cli.js +13 -6
- package/dist/entry/shutdown.d.ts +1 -1
- package/dist/entry/shutdown.js +11 -1
- package/dist/entry/signal-cli.js +8 -11
- package/dist/entry/start-ui-http.js +48 -18
- package/dist/entry/telemetry-wiring.d.ts +12 -0
- package/dist/entry/telemetry-wiring.js +56 -0
- package/dist/entry/ui-cli.d.ts +0 -11
- package/dist/entry/ui-cli.js +42 -33
- package/dist/entry/ui-service-wiring.js +8 -10
- package/dist/events/event-types.d.ts +4 -6
- package/dist/orchestration/agent-runner.d.ts +2 -2
- package/dist/orchestration/agent-runner.js +10 -9
- package/dist/orchestration/benchmark-session-webhook.js +13 -1
- package/dist/orchestration/browser-webhook.d.ts +11 -0
- package/dist/orchestration/browser-webhook.js +28 -0
- package/dist/orchestration/cache-keep-warm.d.ts +77 -0
- package/dist/orchestration/cache-keep-warm.js +213 -0
- package/dist/orchestration/claude-window-warmup.d.ts +40 -0
- package/dist/orchestration/claude-window-warmup.js +126 -0
- package/dist/orchestration/conversation-request.d.ts +6 -10
- package/dist/orchestration/conversation-request.js +5 -23
- package/dist/orchestration/delta-coalescer.d.ts +4 -2
- package/dist/orchestration/delta-coalescer.js +5 -5
- package/dist/orchestration/edit-retry.js +9 -11
- package/dist/orchestration/inline-media-eager.d.ts +13 -0
- package/dist/orchestration/inline-media-eager.js +58 -0
- package/dist/orchestration/inline-media.d.ts +22 -0
- package/dist/orchestration/inline-media.js +151 -0
- package/dist/orchestration/interactions/ask-user-resume.js +3 -7
- package/dist/orchestration/interactions/interaction-handlers.js +6 -6
- package/dist/orchestration/mid-turn-inject.d.ts +2 -1
- package/dist/orchestration/mid-turn-inject.js +1 -1
- package/dist/orchestration/pending-injection-recovery.d.ts +2 -1
- package/dist/orchestration/pending-injection-recovery.js +1 -1
- package/dist/orchestration/routing/commands/index.js +4 -4
- package/dist/orchestration/routing/commands/mode.d.ts +5 -44
- package/dist/orchestration/routing/commands/mode.js +98 -272
- package/dist/orchestration/routing/commands/schedule.js +29 -18
- package/dist/orchestration/routing/commands/session.js +9 -9
- package/dist/orchestration/routing/commands/status.js +1 -1
- package/dist/orchestration/routing/commands/usage-format.js +3 -0
- package/dist/orchestration/routing/message-router.js +2 -0
- package/dist/orchestration/routing/webhook.js +6 -0
- package/dist/orchestration/session-compact.d.ts +0 -1
- package/dist/orchestration/session-compact.js +5 -7
- package/dist/orchestration/session-events.d.ts +2 -1
- package/dist/orchestration/session-events.js +1 -0
- package/dist/orchestration/status-helpers.d.ts +0 -4
- package/dist/orchestration/status-helpers.js +0 -18
- package/dist/orchestration/subagent-webhook.js +9 -34
- package/dist/orchestration/team-webhook.d.ts +8 -9
- package/dist/orchestration/team-webhook.js +16 -42
- package/dist/orchestration/transcript-sink.d.ts +12 -0
- package/dist/orchestration/transcript-sink.js +38 -2
- package/dist/orchestration/turn/terminal.js +7 -7
- package/dist/orchestration/turn/turn-prep.d.ts +0 -8
- package/dist/orchestration/turn/turn-prep.js +0 -51
- package/dist/orchestration/turn/turn-tracking.d.ts +2 -2
- package/dist/orchestration/turn/turn-tracking.js +8 -5
- package/dist/orchestration/turn/turn.d.ts +0 -2
- package/dist/orchestration/turn/turn.js +13 -15
- package/dist/orchestration/waitpoint-ingress.js +3 -0
- package/dist/platform/adapters/tui/ports.d.ts +1 -1
- package/dist/platform/adapters/tui/tui-transcript.js +2 -0
- package/dist/platform/browser/agent-browser.d.ts +50 -0
- package/dist/platform/browser/agent-browser.js +165 -0
- package/dist/platform/browser/managed-browser.d.ts +1 -11
- package/dist/platform/browser/managed-browser.js +4 -12
- package/dist/platform/ui-http/browser-stream.d.ts +110 -0
- package/dist/platform/ui-http/browser-stream.js +447 -0
- package/dist/platform/ui-http/ui-auth-routes.d.ts +2 -0
- package/dist/platform/ui-http/ui-auth-routes.js +9 -2
- package/dist/platform/ui-http/ui-device-routes.d.ts +13 -0
- package/dist/platform/ui-http/ui-device-routes.js +81 -0
- package/dist/platform/ui-http/ui-devices.d.ts +24 -0
- package/dist/platform/ui-http/ui-devices.js +107 -0
- package/dist/platform/ui-http/ui-http-server.d.ts +22 -3
- package/dist/platform/ui-http/ui-http-server.js +33 -12
- package/dist/platform/ui-http/ui-pairing.d.ts +25 -0
- package/dist/platform/ui-http/ui-pairing.js +98 -0
- package/dist/store/conversation-history-reader.js +8 -0
- package/dist/store/conversation-history-repo.d.ts +8 -1
- package/dist/store/conversation-history-repo.js +5 -0
- package/dist/store/conversation-ledger-repo.d.ts +6 -6
- package/dist/store/conversation-ledger-repo.js +4 -4
- package/dist/store/gitignore-migration.d.ts +2 -0
- package/dist/store/gitignore-migration.js +16 -0
- package/dist/store/hook-registry.d.ts +1 -1
- package/dist/store/hook-registry.js +11 -6
- package/dist/store/models-repo.d.ts +18 -0
- package/dist/store/models-repo.js +74 -0
- package/dist/store/pending-injection-repo.d.ts +2 -1
- package/dist/store/pending-injection-repo.js +3 -1
- package/dist/store/retire-profiles-migration.d.ts +28 -0
- package/dist/store/retire-profiles-migration.js +335 -0
- package/dist/store/schedule-repo.d.ts +2 -1
- package/dist/store/session-registry-import.js +3 -2
- package/dist/store/session-registry-journal.d.ts +10 -13
- package/dist/store/session-registry-journal.js +51 -25
- package/dist/store/session-registry-repo.d.ts +4 -4
- package/dist/store/session-registry-repo.js +4 -5
- package/dist/store/version-migrations.d.ts +7 -3
- package/dist/store/version-migrations.js +133 -80
- package/dist/tui/components/Dashboard.js +4 -3
- package/dist/tui/hooks/useDashboardData.js +1 -1
- package/dist/tui/slash-commands.js +2 -2
- package/dist/tui/turn-status.js +1 -1
- package/package.json +6 -4
- package/web/dist/assets/board-math-css-spk7yR6n.js +2 -0
- package/web/dist/assets/index-BQ69u-92.css +1 -0
- package/web/dist/assets/{index-CndZZ1IQ.js → index-CKNLatCd.js} +1 -1
- package/web/dist/assets/index-CkzWfC98.js +525 -0
- package/web/dist/index.html +3 -2
- package/web/dist/theme.css +6 -0
- package/dist/agent-adapter/browser-mcp-server.d.ts +0 -13
- package/dist/agent-adapter/browser-mcp-server.js +0 -28
- package/dist/agent-adapter/claude/browser-mcp.d.ts +0 -9
- package/dist/agent-adapter/claude/browser-mcp.js +0 -10
- package/dist/core/profile-generator.d.ts +0 -79
- package/dist/core/profile-generator.js +0 -215
- package/dist/domain/agents/profile-manager.d.ts +0 -103
- package/dist/domain/agents/profile-manager.js +0 -286
- package/dist/domain/agents/profile-switch.d.ts +0 -49
- package/dist/domain/agents/profile-switch.js +0 -62
- package/dist/domain/ui-service/mutate/profiles.d.ts +0 -36
- package/dist/domain/ui-service/mutate/profiles.js +0 -151
- package/dist/store/profile-repo.d.ts +0 -20
- package/dist/store/profile-repo.js +0 -97
- package/web/dist/assets/index-B76ueW3q.js +0 -494
- package/web/dist/assets/index-C8O0yxg8.css +0 -1
|
@@ -3,15 +3,16 @@ import { scheduleRepo } from '../store/schedule-repo.js';
|
|
|
3
3
|
import { normalizeScheduleSpec, parseDayOfWeek, parseDurationMs, ScheduleSpecError, SCHEDULE_TYPES, } from '../domain/scheduling/schedule-spec.js';
|
|
4
4
|
import { addSchedule, pauseSchedule, resumeSchedule, updateSchedule } from '../domain/scheduling/schedule-ops.js';
|
|
5
5
|
import { getScheduleHelp } from './cli-help.js';
|
|
6
|
+
import { resolveScheduleSelection } from '../domain/scheduling/schedule-selection.js';
|
|
6
7
|
// `cortex schedule` shares schedule-ops with the daemon, which watches the file and re-arms changes.
|
|
7
8
|
// Both writers hold the schedules.json lock across read-modify-write to preserve concurrent changes.
|
|
8
9
|
const COMMANDS = ['list', 'get', 'add', 'edit', 'pause', 'resume', 'remove'];
|
|
9
10
|
const VALUE_FLAGS = {
|
|
10
11
|
'--type': 'type', '--interval': 'interval', '--time': 'time', '--day': 'day', '--delay': 'delay',
|
|
11
|
-
'--message': 'message', '--project': 'project', '--
|
|
12
|
+
'--message': 'message', '--project': 'project', '--model': 'model', '--thinking': 'thinking', '--pre-check': 'preCheck',
|
|
12
13
|
'--idempotency-key': 'idempotencyKey',
|
|
13
14
|
};
|
|
14
|
-
const SPEC_FLAGS = ['interval', 'time', 'day', 'delay', 'message', 'project', '
|
|
15
|
+
const SPEC_FLAGS = ['interval', 'time', 'day', 'delay', 'message', 'project', 'model', 'thinking', 'preCheck'];
|
|
15
16
|
const COMMAND_FLAGS = {
|
|
16
17
|
list: ['project'],
|
|
17
18
|
get: [],
|
|
@@ -43,7 +44,7 @@ function readFlag(command, args, i, flags) {
|
|
|
43
44
|
const valid = [...flagNames(COMMAND_FLAGS[command]), ...(command === 'remove' ? ['--dry-run'] : [])];
|
|
44
45
|
throw new UsageError(`Unknown option for '${command}': '${args[i]}'.`, valid.length ? valid : ['(none)']);
|
|
45
46
|
}
|
|
46
|
-
if (args[i + 1] === undefined)
|
|
47
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith('--'))
|
|
47
48
|
throw new UsageError(`Missing value for ${args[i]}.`);
|
|
48
49
|
flags[name] = args[i + 1];
|
|
49
50
|
}
|
|
@@ -86,7 +87,8 @@ async function runAdd({ flags }, repo) {
|
|
|
86
87
|
if (!flags.type)
|
|
87
88
|
throw new UsageError('Missing --type.', [...SCHEDULE_TYPES]);
|
|
88
89
|
const spec = normalizeScheduleSpec({
|
|
89
|
-
type: flags.type, message: flags.message, projectId: flags.project,
|
|
90
|
+
type: flags.type, message: flags.message, projectId: flags.project,
|
|
91
|
+
selection: resolveScheduleSelection(flags.model, flags.thinking),
|
|
90
92
|
preCheck: flags.preCheck, interval: flags.interval, time: flags.time, dayOfWeek: flags.day, delay: flags.delay,
|
|
91
93
|
});
|
|
92
94
|
const allowed = TIMING_FLAGS[spec.type];
|
|
@@ -100,7 +102,6 @@ async function runAdd({ flags }, repo) {
|
|
|
100
102
|
const EDIT_FIELDS = {
|
|
101
103
|
message: (message) => ({ message }),
|
|
102
104
|
project: (projectId) => ({ projectId }),
|
|
103
|
-
profile: (profile) => ({ profile }),
|
|
104
105
|
preCheck: (preCheck) => ({ preCheck }),
|
|
105
106
|
interval: (value) => ({ intervalMs: parseDurationMs(value, 'interval') }),
|
|
106
107
|
time: (time) => ({ time }),
|
|
@@ -108,7 +109,13 @@ const EDIT_FIELDS = {
|
|
|
108
109
|
delay: (value) => ({ runAt: Date.now() + parseDurationMs(value, 'delay') }),
|
|
109
110
|
};
|
|
110
111
|
async function runEdit({ id, flags }, repo) {
|
|
111
|
-
const
|
|
112
|
+
const task = await repo.findTask(id);
|
|
113
|
+
found(task, id);
|
|
114
|
+
const { model, thinking, ...fields } = flags;
|
|
115
|
+
const patch = Object.assign({}, ...Object.entries(fields).map(([name, value]) => EDIT_FIELDS[name](value)));
|
|
116
|
+
const selection = resolveScheduleSelection(model, thinking, task?.selection);
|
|
117
|
+
if (selection)
|
|
118
|
+
patch.selection = selection;
|
|
112
119
|
return { ok: true, schedule: found(await updateSchedule(repo, id, patch), id) };
|
|
113
120
|
}
|
|
114
121
|
async function runRemove({ id, dryRun }, repo) {
|
package/dist/entry/shutdown.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface ShutdownHandles {
|
|
|
23
23
|
uiHttpServer?: {
|
|
24
24
|
close(): Promise<void>;
|
|
25
25
|
} | null;
|
|
26
|
-
|
|
26
|
+
stopModelsWatcher?: (() => void) | null;
|
|
27
27
|
stopBoardWatcher?: (() => void) | null;
|
|
28
28
|
}
|
|
29
29
|
export declare function shutdownSteps(h: ShutdownHandles): ShutdownStep[];
|
package/dist/entry/shutdown.js
CHANGED
|
@@ -5,15 +5,19 @@ import { CORTEX_VERSION } from '../core/version.js';
|
|
|
5
5
|
import { flushAllRepositories } from '../core/json-repository.js';
|
|
6
6
|
import { engines } from '../domain/runs/engines.js';
|
|
7
7
|
import { stopBuiltinJobs } from '../domain/scheduling/builtin-jobs.js';
|
|
8
|
+
import { stopTelemetry } from '../domain/telemetry/service.js';
|
|
8
9
|
import { stopClientManager } from '../domain/remote/client-manager.js';
|
|
9
10
|
import { stopMachineRegistryWatcher } from '../domain/remote/machine-registry.js';
|
|
10
11
|
import { stopAllDevicePorts } from '../domain/remote/device-port.js';
|
|
11
12
|
import { forgetDeviceBrowsers } from '../domain/remote/device-browser.js';
|
|
13
|
+
import { shutdownBrowserBroker } from '../domain/browser/broker.js';
|
|
12
14
|
import { stopDiskMonitor } from '../domain/monitor/disk-monitor.js';
|
|
13
15
|
import { stopEventLoopMonitor } from '../domain/monitor/event-loop-monitor.js';
|
|
14
16
|
import { stopGateway } from '../domain/costs/gateway-manager.js';
|
|
15
17
|
import { stopBrowser } from '../platform/browser/managed-browser.js';
|
|
16
18
|
import { stopWaitpointSweep } from '../orchestration/waitpoint-sweep.js';
|
|
19
|
+
import { stopCacheKeepWarm } from '../orchestration/cache-keep-warm.js';
|
|
20
|
+
import { stopClaudeWindowWarmup } from '../orchestration/claude-window-warmup.js';
|
|
17
21
|
const log = createLogger('shutdown');
|
|
18
22
|
function serviceSteps(h) {
|
|
19
23
|
return [
|
|
@@ -24,8 +28,10 @@ function serviceSteps(h) {
|
|
|
24
28
|
{ name: 'agent engines', run: () => engines.closeAll() },
|
|
25
29
|
{ name: 'client manager', run: stopClientManager },
|
|
26
30
|
{ name: 'machine watcher', run: stopMachineRegistryWatcher },
|
|
27
|
-
{ name: '
|
|
31
|
+
{ name: 'models watcher', run: () => h.stopModelsWatcher?.() },
|
|
28
32
|
{ name: 'board watcher', run: () => h.stopBoardWatcher?.() },
|
|
33
|
+
// Leases first: their timers would otherwise fire against a browser that is already gone.
|
|
34
|
+
{ name: 'browser leases', run: shutdownBrowserBroker },
|
|
29
35
|
// A Chrome that outlives the daemon keeps the profile locked, so the next launch would attach to
|
|
30
36
|
// an instance nothing is supervising.
|
|
31
37
|
{ name: 'browser', run: stopBrowser },
|
|
@@ -45,8 +51,12 @@ function drainSteps(h) {
|
|
|
45
51
|
// its store's flush resolved, losing that write.
|
|
46
52
|
{ name: 'scheduler', run: () => h.scheduler.stop() },
|
|
47
53
|
{ name: 'waitpoint sweep', run: stopWaitpointSweep },
|
|
54
|
+
{ name: 'cache keep-warm', run: stopCacheKeepWarm },
|
|
55
|
+
{ name: 'claude window warm-up', run: stopClaudeWindowWarmup },
|
|
48
56
|
// Pending WAL entries survive on disk for the next startup.
|
|
49
57
|
{ name: 'outbound drain loop', run: () => h.outboundQueue.stop() },
|
|
58
|
+
// After the engines closed, so turns cancelled by the shutdown are in the persisted rollup.
|
|
59
|
+
{ name: 'telemetry', run: stopTelemetry },
|
|
50
60
|
// SIGTERM landing between `writeFile(tmp)` and `rename(tmp, target)` in atomic-write.ts leaves
|
|
51
61
|
// orphan .tmp.* siblings; the daemon gives 5s before SIGKILL, well over what this needs.
|
|
52
62
|
{ name: 'flush stores', run: () => Promise.allSettled([h.bus.close(), h.outboundQueue.flush(), flushAllRepositories()]) },
|
package/dist/entry/signal-cli.js
CHANGED
|
@@ -69,19 +69,16 @@ export function parseSignalArgs(argv) {
|
|
|
69
69
|
}
|
|
70
70
|
/** `--exit-code` is the ergonomic form: one flag turns `$?` into both a status and a message. */
|
|
71
71
|
function resolveStatus(parsed) {
|
|
72
|
-
if (parsed.
|
|
73
|
-
|
|
74
|
-
if (!Number.isFinite(code)) {
|
|
75
|
-
throw cliError(formatError(`--exit-code must be a number, got '${parsed.exitCode}'`));
|
|
76
|
-
}
|
|
77
|
-
const status = parsed.status ?? (code === 0 ? 'ok' : 'fail');
|
|
78
|
-
return { status, message: parsed.message ?? `exit=${code}` };
|
|
72
|
+
if (parsed.status !== null && !STATUSES.includes(parsed.status)) {
|
|
73
|
+
throw cliError(formatError(`Invalid --status '${parsed.status}'`, { validValues: STATUSES }));
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
if (parsed.exitCode === null)
|
|
76
|
+
return { status: parsed.status ?? 'ok', message: parsed.message };
|
|
77
|
+
const code = Number.parseInt(parsed.exitCode, 10);
|
|
78
|
+
if (!Number.isFinite(code)) {
|
|
79
|
+
throw cliError(formatError(`--exit-code must be a number, got '${parsed.exitCode}'`));
|
|
83
80
|
}
|
|
84
|
-
return { status, message: parsed.message };
|
|
81
|
+
return { status: parsed.status ?? (code === 0 ? 'ok' : 'fail'), message: parsed.message ?? `exit=${code}` };
|
|
85
82
|
}
|
|
86
83
|
function readData(spec) {
|
|
87
84
|
if (spec === null)
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { parseClientKind } from '../domain/telemetry/client-kind.js';
|
|
5
|
+
import { CLIENT_KIND_HEADER } from '../domain/telemetry/schema.js';
|
|
4
6
|
import { createAppRouter } from '../domain/ui-service/app-router.js';
|
|
5
7
|
import { createUiHttpServer, createAuthorizer } from '../platform/ui-http/ui-http-server.js';
|
|
6
8
|
import { createUiSessionStore, DEFAULT_SESSION_TTL_MS } from '../platform/ui-http/ui-session.js';
|
|
7
9
|
import { createUiAuthRoutes, createUiSessionProbeRoute, UI_LOGIN_PATH, UI_SESSION_PATH, } from '../platform/ui-http/ui-auth-routes.js';
|
|
10
|
+
import { createUiDeviceRoutes, UI_PAIR_PATH } from '../platform/ui-http/ui-device-routes.js';
|
|
11
|
+
import { createUiDeviceStore } from '../platform/ui-http/ui-devices.js';
|
|
12
|
+
import { createPairingStore, PAIRING_FILE_NAME } from '../platform/ui-http/ui-pairing.js';
|
|
8
13
|
import { createOtaRoutes } from '../platform/ui-http/ui-ota.js';
|
|
9
14
|
import { createAppUpdateRoutes } from '../platform/ui-http/app-update.js';
|
|
10
15
|
import { isUpdateDevMode } from '../domain/system/server-update-check.js';
|
|
11
16
|
import { createForwardRoutes } from '../platform/ui-http/port-forward.js';
|
|
12
17
|
import { createDevicePortRoutes } from '../platform/ui-http/device-ports.js';
|
|
13
18
|
import { createFileRoutes } from '../platform/ui-http/file-routes.js';
|
|
19
|
+
import { BROWSER_STREAM_PATH, createBrowserStream } from '../platform/ui-http/browser-stream.js';
|
|
20
|
+
import { insertText, isTakenOver, listBrowserSessions, setTakeover, streamPort, } from '../domain/browser/broker.js';
|
|
14
21
|
import { getOnlineDevices, sendCommand } from '../domain/remote/client-manager.js';
|
|
15
22
|
import { openDevicePort, closeDevicePort, listDevicePorts } from '../domain/remote/device-port.js';
|
|
16
23
|
import { accessVerifierFromEnv } from '../platform/ui-http/access-jwt.js';
|
|
@@ -26,9 +33,11 @@ const log = createLogger('ui-http');
|
|
|
26
33
|
const DEFAULT_UI_PORT = 3004;
|
|
27
34
|
/** Where browser sessions survive a daemon restart. Written 0600 by the store. */
|
|
28
35
|
const SESSIONS_FILE = path.join(STORE_DIR, 'ui-sessions.json');
|
|
36
|
+
/** Paired apps (token hashes). Written 0600 by the store. */
|
|
37
|
+
const DEVICES_FILE = path.join(STORE_DIR, 'ui-devices.json');
|
|
29
38
|
/**
|
|
30
39
|
* Token login is ON unless explicitly switched off — a browser reaching this server can log in by
|
|
31
|
-
* pasting the clientToken
|
|
40
|
+
* pasting the clientToken or a one-time pairing code, and an app can pair with a code. Opting out (`CORTEX_UI_TOKEN_LOGIN=0`) removes the login routes and
|
|
32
41
|
* the cookie leg entirely, leaving the token header and (if configured) Cloudflare Access.
|
|
33
42
|
*
|
|
34
43
|
* Being on by default means every CORTEX_UI_HTTP deployment exposes a public POST /api/ui/login.
|
|
@@ -68,6 +77,32 @@ function defaultSpaDir() {
|
|
|
68
77
|
return undefined;
|
|
69
78
|
}
|
|
70
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Token login, pairing and paired apps behind one authorizer. The authorizer is handed to BOTH the
|
|
82
|
+
* gate and the public /api/ui/session probe, so "am I authenticated?" is answered by the same
|
|
83
|
+
* predicate that decides the next request — two copies would eventually disagree. With token login
|
|
84
|
+
* off, only the probe and the paired-app list remain — so the SPA can say "token login is off here"
|
|
85
|
+
* instead of showing a form that could never work.
|
|
86
|
+
*/
|
|
87
|
+
function createUiAuth(env, getToken, verifyAccessJwt) {
|
|
88
|
+
const tokenLogin = isTokenLoginEnabled(env);
|
|
89
|
+
const devices = createUiDeviceStore({ file: DEVICES_FILE });
|
|
90
|
+
const matchDeviceToken = (token) => devices.match(token) !== undefined;
|
|
91
|
+
const sessionStore = tokenLogin ? createUiSessionStore({ file: SESSIONS_FILE, ttlMs: sessionTtlMs(env) }) : undefined;
|
|
92
|
+
const pairing = tokenLogin ? createPairingStore({ file: path.join(STORE_DIR, PAIRING_FILE_NAME) }) : undefined;
|
|
93
|
+
const verifySession = sessionStore ? (sid) => sessionStore.verify(sid) : undefined;
|
|
94
|
+
const authorize = createAuthorizer({ getToken, matchDeviceToken, verifySession, verifyAccessJwt });
|
|
95
|
+
const loginRoutes = sessionStore && pairing
|
|
96
|
+
? createUiAuthRoutes({
|
|
97
|
+
store: sessionStore, getToken, authorize, ttlMs: sessionTtlMs(env), redeemCode: (code) => pairing.redeem(code),
|
|
98
|
+
})
|
|
99
|
+
: createUiSessionProbeRoute(authorize);
|
|
100
|
+
return {
|
|
101
|
+
authorize, matchDeviceToken, tokenLogin,
|
|
102
|
+
publicRoutes: tokenLogin ? [UI_LOGIN_PATH, UI_SESSION_PATH, UI_PAIR_PATH] : [UI_SESSION_PATH],
|
|
103
|
+
routes: { ...loginRoutes, ...createUiDeviceRoutes({ devices, pairing }) },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
71
106
|
/**
|
|
72
107
|
* Build the AppRouter from the injected UiService and start the Web UI HTTP+SSE transport-host
|
|
73
108
|
* on CORTEX_UI_PORT (default 3004), bound 127.0.0.1, behind the x-cortex-token gate, serving the
|
|
@@ -90,15 +125,12 @@ export function startUiHttpServer(opts) {
|
|
|
90
125
|
// to token-only.
|
|
91
126
|
const verifyAccessJwt = accessVerifierFromEnv(env);
|
|
92
127
|
const getToken = opts.getToken ?? getClientToken;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
//
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
: undefined;
|
|
100
|
-
const verifySession = sessionStore ? (sid) => sessionStore.verify(sid) : undefined;
|
|
101
|
-
const authorize = createAuthorizer({ getToken, verifySession, verifyAccessJwt });
|
|
128
|
+
const auth = createUiAuth(env, getToken, verifyAccessJwt);
|
|
129
|
+
const { authorize, tokenLogin } = auth;
|
|
130
|
+
// The agent's browser, live in the app: session list, takeover, typed text, and the stream itself.
|
|
131
|
+
const browserStream = createBrowserStream({
|
|
132
|
+
listSessions: listBrowserSessions, streamPort, setTakeover, isTakenOver, insertText,
|
|
133
|
+
});
|
|
102
134
|
log.info(`Web UI enabled — starting tRPC HTTP+SSE on 127.0.0.1:${port}` +
|
|
103
135
|
(spaDir ? ` (SPA: ${spaDir})` : ' (SPA: not built — non-tRPC paths 404)') +
|
|
104
136
|
(initialCorsOrigins.length > 0 ? ` (CORS allow-list: ${initialCorsOrigins.join(', ')})` : '') +
|
|
@@ -107,20 +139,16 @@ export function startUiHttpServer(opts) {
|
|
|
107
139
|
return createUiHttpServer({
|
|
108
140
|
router,
|
|
109
141
|
getToken,
|
|
142
|
+
matchDeviceToken: auth.matchDeviceToken,
|
|
110
143
|
port,
|
|
111
144
|
host: '127.0.0.1',
|
|
112
145
|
spaDir,
|
|
113
146
|
corsOrigins,
|
|
114
147
|
authorize,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
publicRoutes: tokenLogin ? [UI_LOGIN_PATH, UI_SESSION_PATH] : [UI_SESSION_PATH],
|
|
148
|
+
createContext: (req) => ({ client: parseClientKind(req.headers[CLIENT_KIND_HEADER]) }),
|
|
149
|
+
publicRoutes: auth.publicRoutes,
|
|
118
150
|
customRoutes: {
|
|
119
|
-
|
|
120
|
-
// login is off here" instead of showing a form that could never work.
|
|
121
|
-
...(sessionStore
|
|
122
|
-
? createUiAuthRoutes({ store: sessionStore, getToken, authorize, ttlMs: sessionTtlMs(env) })
|
|
123
|
-
: createUiSessionProbeRoute(authorize)),
|
|
151
|
+
...auth.routes,
|
|
124
152
|
// Composer uploads, workspace downloads and board assets.
|
|
125
153
|
...createFileRoutes({
|
|
126
154
|
attachmentsDir: path.join(WORKSPACE_DIR, 'attachments'),
|
|
@@ -152,7 +180,9 @@ export function startUiHttpServer(opts) {
|
|
|
152
180
|
closeDevicePort,
|
|
153
181
|
listDevicePorts,
|
|
154
182
|
}),
|
|
183
|
+
...browserStream.routes,
|
|
155
184
|
},
|
|
185
|
+
upgradeRoutes: { [BROWSER_STREAM_PATH]: browserStream },
|
|
156
186
|
portForward: env.CORTEX_PORT_FORWARD !== '0',
|
|
157
187
|
});
|
|
158
188
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { stopTelemetry } from '../domain/telemetry/service.js';
|
|
2
|
+
import type { EventBus } from '../events/event-bus.js';
|
|
3
|
+
/** Early in boot: everything that must see the boot itself. All of it is local until upload. */
|
|
4
|
+
export declare function installEarlyTelemetry(): void;
|
|
5
|
+
/** Feature and web signals; called once the event bus exists. */
|
|
6
|
+
export declare function installTelemetryCollectors(bus: EventBus): void;
|
|
7
|
+
/** The event-loop monitor's window observer. */
|
|
8
|
+
export declare const telemetryEventLoopObserver: (reading: {
|
|
9
|
+
p99Ms: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
export declare function startTelemetryService(): void;
|
|
12
|
+
export { stopTelemetry as stopTelemetryService };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Composition of the telemetry service: the heartbeat's data sources live all over the domain
|
|
2
|
+
// layer, so they are gathered here rather than imported by domain/telemetry itself.
|
|
3
|
+
import { setErrorLogSink } from '../core/log.js';
|
|
4
|
+
import { getSettings } from '../core/settings.js';
|
|
5
|
+
import { getAuthStatus } from '../domain/auth/auth-status.js';
|
|
6
|
+
import { projectStore } from '../domain/projects/index.js';
|
|
7
|
+
import { getOnlineDevices } from '../domain/remote/client-manager.js';
|
|
8
|
+
import { buildHeartbeat } from '../domain/telemetry/heartbeat.js';
|
|
9
|
+
import { loadNameCatalog } from '../domain/telemetry/normalize.js';
|
|
10
|
+
import { startTelemetry, stopTelemetry } from '../domain/telemetry/service.js';
|
|
11
|
+
import { captureChildExitFromEnv } from '../domain/telemetry/child-exit.js';
|
|
12
|
+
import { installDailyUpload } from '../domain/telemetry/daily-upload.js';
|
|
13
|
+
import { recordErrorLog } from '../domain/telemetry/error-digest.js';
|
|
14
|
+
import { subscribeTelemetryToBus } from '../domain/telemetry/bus-collector.js';
|
|
15
|
+
import { recordFunnelStep } from '../domain/telemetry/funnel.js';
|
|
16
|
+
import { installWebReportSink, recordEventLoopLag } from '../domain/telemetry/usage.js';
|
|
17
|
+
import { onLoginSuccess } from '../domain/auth/login-flow.js';
|
|
18
|
+
import { confirmUpgradeAtBoot } from '../domain/telemetry/upgrade.js';
|
|
19
|
+
import { sessionStore } from '../store/session-registry-repo.js';
|
|
20
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
21
|
+
async function activeSessions24h() {
|
|
22
|
+
const since = Date.now() - DAY_MS;
|
|
23
|
+
const recent = await sessionStore.listRecentSessions(10_000);
|
|
24
|
+
return recent.filter((session) => Date.parse(session.lastUsedAt ?? '') >= since).length;
|
|
25
|
+
}
|
|
26
|
+
function heartbeatSources() {
|
|
27
|
+
return {
|
|
28
|
+
authStatus: () => getAuthStatus(),
|
|
29
|
+
projects: () => projectStore.list().length,
|
|
30
|
+
onlineDevices: () => getOnlineDevices(),
|
|
31
|
+
activeSessions24h,
|
|
32
|
+
uptimeS: () => process.uptime(),
|
|
33
|
+
settings: () => getSettings(),
|
|
34
|
+
catalog: () => loadNameCatalog(new Date().toISOString().slice(0, 10)),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Early in boot: everything that must see the boot itself. All of it is local until upload. */
|
|
38
|
+
export function installEarlyTelemetry() {
|
|
39
|
+
installDailyUpload();
|
|
40
|
+
setErrorLogSink(recordErrorLog);
|
|
41
|
+
captureChildExitFromEnv();
|
|
42
|
+
confirmUpgradeAtBoot();
|
|
43
|
+
}
|
|
44
|
+
/** Feature and web signals; called once the event bus exists. */
|
|
45
|
+
export function installTelemetryCollectors(bus) {
|
|
46
|
+
subscribeTelemetryToBus(bus);
|
|
47
|
+
installWebReportSink();
|
|
48
|
+
onLoginSuccess((event) => recordFunnelStep('provider_authed', event.backend));
|
|
49
|
+
}
|
|
50
|
+
/** The event-loop monitor's window observer. */
|
|
51
|
+
export const telemetryEventLoopObserver = (reading) => recordEventLoopLag(reading.p99Ms);
|
|
52
|
+
export function startTelemetryService() {
|
|
53
|
+
const sources = heartbeatSources();
|
|
54
|
+
startTelemetry({ collectHeartbeat: () => buildHeartbeat(sources) });
|
|
55
|
+
}
|
|
56
|
+
export { stopTelemetry as stopTelemetryService };
|
package/dist/entry/ui-cli.d.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
1
|
import { type CliResult } from '../core/cli-utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* `cortex ui enable` — make this install reachable by the Cortex desktop app.
|
|
4
|
-
*
|
|
5
|
-
* The native shell needs three things that a plain `cortex init` leaves off (the endpoint is
|
|
6
|
-
* opt-in): the Web UI HTTP transport switched on, a port, and the shell's own origins allowed for
|
|
7
|
-
* CORS. This wraps all three plus token generation into one idempotent command, so both the desktop
|
|
8
|
-
* setup wizard and an operator repairing an older install use the same path.
|
|
9
|
-
*
|
|
10
|
-
* `changed` in the JSON output tells the caller whether a running daemon must be restarted: .env is
|
|
11
|
-
* read at process start, so flipping it mid-flight has no effect until the server respawns.
|
|
12
|
-
*/
|
|
13
2
|
export declare function runUiCli(args: string[]): Promise<CliResult>;
|
package/dist/entry/ui-cli.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
1
2
|
import { formatError } from '../core/cli-utils.js';
|
|
3
|
+
import { createPairingStore, PAIRING_CODE_TTL_MS, PAIRING_FILE_NAME } from '../platform/ui-http/ui-pairing.js';
|
|
2
4
|
import { getResolvedPaths } from './init.js';
|
|
3
5
|
import { enableLocalUi } from './local-ui.js';
|
|
4
6
|
import { getUiHelp } from './cli-help.js';
|
|
7
|
+
const SUBCOMMANDS = ['enable', 'pair'];
|
|
5
8
|
/** Read the value following a flag, or undefined when the flag is absent. */
|
|
6
9
|
function optionValue(args, flag) {
|
|
7
10
|
const index = args.indexOf(flag);
|
|
8
11
|
return index !== -1 && args[index + 1] ? args[index + 1] : undefined;
|
|
9
12
|
}
|
|
13
|
+
function usageError(message, opts) {
|
|
14
|
+
return { exitCode: 1, stdout: '', stderr: formatError(message, opts) };
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* `cortex ui enable` — make this install reachable by the Cortex desktop app.
|
|
12
18
|
*
|
|
@@ -18,42 +24,14 @@ function optionValue(args, flag) {
|
|
|
18
24
|
* `changed` in the JSON output tells the caller whether a running daemon must be restarted: .env is
|
|
19
25
|
* read at process start, so flipping it mid-flight has no effect until the server respawns.
|
|
20
26
|
*/
|
|
21
|
-
|
|
22
|
-
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
23
|
-
const noSubcommand = args.length === 0;
|
|
24
|
-
return noSubcommand
|
|
25
|
-
? {
|
|
26
|
-
exitCode: 1,
|
|
27
|
-
stdout: '',
|
|
28
|
-
stderr: formatError("Missing subcommand for 'ui'.", {
|
|
29
|
-
validValues: ['enable'],
|
|
30
|
-
hint: 'cortex ui --help',
|
|
31
|
-
}),
|
|
32
|
-
}
|
|
33
|
-
: { exitCode: 0, stdout: getUiHelp(), stderr: '' };
|
|
34
|
-
}
|
|
35
|
-
if (args[0] !== 'enable') {
|
|
36
|
-
return {
|
|
37
|
-
exitCode: 1,
|
|
38
|
-
stdout: '',
|
|
39
|
-
stderr: formatError(`Unknown subcommand: '${args[0]}'.`, {
|
|
40
|
-
validValues: ['enable'],
|
|
41
|
-
hint: 'cortex ui --help',
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
27
|
+
async function runEnable(args) {
|
|
45
28
|
const asJson = args.includes('--json');
|
|
46
29
|
const portRaw = optionValue(args, '--port');
|
|
47
30
|
const port = portRaw === undefined ? undefined : Number(portRaw);
|
|
48
31
|
if (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
stderr: formatError(`Invalid --port: '${portRaw}'.`, {
|
|
53
|
-
validValues: ['an integer in 1-65535'],
|
|
54
|
-
hint: 'cortex ui enable --port 3004',
|
|
55
|
-
}),
|
|
56
|
-
};
|
|
32
|
+
return usageError(`Invalid --port: '${portRaw}'.`, {
|
|
33
|
+
validValues: ['an integer in 1-65535'], hint: 'cortex ui enable --port 3004',
|
|
34
|
+
});
|
|
57
35
|
}
|
|
58
36
|
const paths = getResolvedPaths(optionValue(args, '--home'));
|
|
59
37
|
try {
|
|
@@ -68,7 +46,7 @@ export async function runUiCli(args) {
|
|
|
68
46
|
result.changed
|
|
69
47
|
? 'Configuration changed — restart the daemon to apply (cortex daemon restart).'
|
|
70
48
|
: 'Already configured — no restart needed.',
|
|
71
|
-
'Connect
|
|
49
|
+
'Connect another app or browser with a one-time code from `cortex ui pair`.',
|
|
72
50
|
];
|
|
73
51
|
return { exitCode: 0, stdout: `${lines.join('\n')}\n`, stderr: '' };
|
|
74
52
|
}
|
|
@@ -76,3 +54,34 @@ export async function runUiCli(args) {
|
|
|
76
54
|
return { exitCode: 1, stdout: '', stderr: error.message || String(error) };
|
|
77
55
|
}
|
|
78
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* `cortex ui pair` — mint a one-time pairing code for a new app or browser. It goes into the same
|
|
59
|
+
* file the running server redeems from, so the server needs no restart.
|
|
60
|
+
*/
|
|
61
|
+
async function runPair(args) {
|
|
62
|
+
const paths = getResolvedPaths(optionValue(args, '--home'));
|
|
63
|
+
const store = createPairingStore({ file: path.join(paths.STORE_DIR, PAIRING_FILE_NAME) });
|
|
64
|
+
const { code, expiresAt } = store.create();
|
|
65
|
+
if (args.includes('--json')) {
|
|
66
|
+
return { exitCode: 0, stdout: `${JSON.stringify({ ok: true, code, expiresAt }, null, 2)}\n`, stderr: '' };
|
|
67
|
+
}
|
|
68
|
+
const lines = [
|
|
69
|
+
`Pairing code: ${code}`,
|
|
70
|
+
`Valid for ${PAIRING_CODE_TTL_MS / 60_000} minutes, once.`,
|
|
71
|
+
'Enter it with this server\'s address in the Cortex app, or on the browser sign-in page.',
|
|
72
|
+
];
|
|
73
|
+
return { exitCode: 0, stdout: `${lines.join('\n')}\n`, stderr: '' };
|
|
74
|
+
}
|
|
75
|
+
const RUNNERS = { enable: runEnable, pair: runPair };
|
|
76
|
+
export async function runUiCli(args) {
|
|
77
|
+
if (args.length === 0) {
|
|
78
|
+
return usageError("Missing subcommand for 'ui'.", { validValues: SUBCOMMANDS, hint: 'cortex ui --help' });
|
|
79
|
+
}
|
|
80
|
+
if (args.includes('--help') || args.includes('-h'))
|
|
81
|
+
return { exitCode: 0, stdout: getUiHelp(), stderr: '' };
|
|
82
|
+
const runner = Object.hasOwn(RUNNERS, args[0]) ? RUNNERS[args[0]] : undefined;
|
|
83
|
+
if (!runner) {
|
|
84
|
+
return usageError(`Unknown subcommand: '${args[0]}'.`, { validValues: SUBCOMMANDS, hint: 'cortex ui --help' });
|
|
85
|
+
}
|
|
86
|
+
return runner(args);
|
|
87
|
+
}
|
|
@@ -9,7 +9,7 @@ import { conversationHistory } from '../store/conversation-history-repo.js';
|
|
|
9
9
|
import { pendingInjectionRepo } from '../store/pending-injection-repo.js';
|
|
10
10
|
import { sessionStore } from '../store/session-registry-repo.js';
|
|
11
11
|
import { waitpointRepo } from '../store/waitpoint-repo.js';
|
|
12
|
-
import { applyChannelSelection, clearChannelAgentSelection,
|
|
12
|
+
import { applyChannelSelection, clearChannelAgentSelection, getModelMemory, getSelectionDefault, resolveBackendForChannel, switchChannelAgent, } from '../domain/agents/index.js';
|
|
13
13
|
import { getSubagentChildStatuses } from '../domain/agents/subagent/registry.js';
|
|
14
14
|
import { getCostSummary } from '../domain/costs/cost-tracker.js';
|
|
15
15
|
import * as executionRegistry from '../domain/executions/registry.js';
|
|
@@ -29,10 +29,12 @@ import { cancelChannelRuns, cancelLiveExecution } from '../orchestration/routing
|
|
|
29
29
|
import { deliverToSessionDetached } from '../orchestration/session-gateway.js';
|
|
30
30
|
import { compactSessionContext } from '../orchestration/session-compact.js';
|
|
31
31
|
import { rewindWebSession } from '../orchestration/session-rewind.js';
|
|
32
|
+
import { snapshotInlineMedia } from '../orchestration/inline-media.js';
|
|
32
33
|
import { moveDraftAttachments } from './draft-attachments.js';
|
|
33
34
|
export function buildUiService(w) {
|
|
34
35
|
return createUiService({
|
|
35
36
|
checkServerUpdate: () => w.serverUpdateCoordinator.check(),
|
|
37
|
+
resolveMedia: snapshotInlineMedia,
|
|
36
38
|
projectStore,
|
|
37
39
|
sessionStore,
|
|
38
40
|
scheduler: w.scheduler,
|
|
@@ -95,26 +97,22 @@ function sessionRunDeps(adapter) {
|
|
|
95
97
|
moveDraftAttachments,
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
|
-
/** The
|
|
100
|
+
/** The environment and engine a session runs: the shared domain rules. */
|
|
99
101
|
function sessionSelectionDeps() {
|
|
100
102
|
return {
|
|
101
|
-
switchSessionProfile: (opts) => switchChannelProfile(opts),
|
|
102
103
|
// A null name is the "follow the global default" row, which clears the channel's selection.
|
|
103
104
|
switchSessionAgent: async ({ channel, name }) => {
|
|
104
105
|
if (name === null) {
|
|
105
106
|
await clearChannelAgentSelection(channel);
|
|
106
|
-
return { ok: true, agentName: null
|
|
107
|
+
return { ok: true, agentName: null };
|
|
107
108
|
}
|
|
108
109
|
const res = await switchChannelAgent({ channel, name });
|
|
109
110
|
return res.ok === true
|
|
110
|
-
? { ok: true, agentName: res.agentName
|
|
111
|
-
: {
|
|
112
|
-
ok: false, agentName: null, effectiveProfile: '', backendChanged: false,
|
|
113
|
-
reason: res.reason, currentBackend: res.currentBackend, targetBackend: res.targetBackend,
|
|
114
|
-
};
|
|
111
|
+
? { ok: true, agentName: res.agentName }
|
|
112
|
+
: { ok: false, agentName: null, reason: res.reason };
|
|
115
113
|
},
|
|
116
114
|
applySessionSelection: (opts) => applyChannelSelection(opts),
|
|
117
|
-
|
|
115
|
+
getModelMemory: () => getModelMemory(),
|
|
118
116
|
// What a draft composer starts on before any session exists.
|
|
119
117
|
getSelectionDefault: () => getSelectionDefault(),
|
|
120
118
|
};
|
|
@@ -9,7 +9,7 @@ export type CortexEvent = {
|
|
|
9
9
|
ts: string;
|
|
10
10
|
sessionId: string;
|
|
11
11
|
channel: string;
|
|
12
|
-
role: 'user' | 'assistant' | 'tool' | 'worker-progress';
|
|
12
|
+
role: 'user' | 'assistant' | 'thinking' | 'tool' | 'worker-progress';
|
|
13
13
|
text: string;
|
|
14
14
|
toolName?: string;
|
|
15
15
|
toolInput?: string;
|
|
@@ -57,6 +57,7 @@ export type CortexEvent = {
|
|
|
57
57
|
blockId: string;
|
|
58
58
|
text: string;
|
|
59
59
|
seq: number;
|
|
60
|
+
kind?: 'thinking';
|
|
60
61
|
} | {
|
|
61
62
|
type: 'session.status';
|
|
62
63
|
ts: string;
|
|
@@ -219,15 +220,11 @@ export type CortexEvent = {
|
|
|
219
220
|
} | {
|
|
220
221
|
type: 'config.changed';
|
|
221
222
|
ts: string;
|
|
222
|
-
section: '
|
|
223
|
+
section: 'models' | 'preferences';
|
|
223
224
|
} | {
|
|
224
225
|
type: 'llm.active-count-delta';
|
|
225
226
|
ts: string;
|
|
226
227
|
delta: number;
|
|
227
|
-
} | {
|
|
228
|
-
type: 'scheduler.tick';
|
|
229
|
-
ts: string;
|
|
230
|
-
jobKey: string;
|
|
231
228
|
} | {
|
|
232
229
|
type: 'rate-limit.changed';
|
|
233
230
|
ts: string;
|
|
@@ -240,6 +237,7 @@ export type CortexEvent = {
|
|
|
240
237
|
ok: boolean;
|
|
241
238
|
code?: string;
|
|
242
239
|
} | null;
|
|
240
|
+
client?: 'desktop' | 'android' | 'browser' | null;
|
|
243
241
|
} | {
|
|
244
242
|
type: 'event-bus.handler-failed';
|
|
245
243
|
ts: string;
|
|
@@ -43,8 +43,8 @@ export declare class AgentRunner {
|
|
|
43
43
|
*/
|
|
44
44
|
private _tryInjectReal;
|
|
45
45
|
/**
|
|
46
|
-
* Resolve what a turn needs but is not part of it — the files
|
|
47
|
-
* created) with its use lease
|
|
46
|
+
* Resolve what a turn needs but is not part of it — the files and the session record (found or
|
|
47
|
+
* created) with its use lease — and open the turn.
|
|
48
48
|
*/
|
|
49
49
|
private _executeReal;
|
|
50
50
|
}
|
|
@@ -5,7 +5,8 @@ import * as crypto from 'node:crypto';
|
|
|
5
5
|
import { getSessionAsync, setSessionAsync } from '../domain/sessions/session.js';
|
|
6
6
|
import { sessionStore, effectiveBackendSessionId } from '../store/session-registry-repo.js';
|
|
7
7
|
import { conversationHistory } from '../store/conversation-history-repo.js';
|
|
8
|
-
import {
|
|
8
|
+
import { resolveBackendForChannel } from '../domain/agents/index.js';
|
|
9
|
+
import { resolveRunSelection } from '../domain/runs/config-resolver.js';
|
|
9
10
|
import { registerSessionRecord } from '../domain/sessions/session-lifecycle.js';
|
|
10
11
|
import { createLogger } from '../core/log.js';
|
|
11
12
|
import { isDebugMode } from '../core/debug-mode.js';
|
|
@@ -15,7 +16,7 @@ import { runRegistry } from '../core/run-registry.js';
|
|
|
15
16
|
import { prepareConversationRequest } from './conversation-request.js';
|
|
16
17
|
import { openTurn, buildInjectDeps } from './turn/turn.js';
|
|
17
18
|
import { recordHistory } from './transcript-sink.js';
|
|
18
|
-
import { acquireSessionUseLease, collectTurnFiles,
|
|
19
|
+
import { acquireSessionUseLease, collectTurnFiles, } from './turn/turn-prep.js';
|
|
19
20
|
import { downloadMessageFiles } from './routing/file-handler.js';
|
|
20
21
|
import { acquireTurnMutationLock } from './turn-mutation-lock.js';
|
|
21
22
|
import { isRebuildHeld, refuseTurnForRebuild } from '../domain/system/rebuild-hold.js';
|
|
@@ -115,7 +116,7 @@ export class AgentRunner {
|
|
|
115
116
|
return tryInjectIntoLiveTurn(buildInjectDeps(sessionId, ctx.adapter), {
|
|
116
117
|
channel: ctx.channel,
|
|
117
118
|
sessionId,
|
|
118
|
-
|
|
119
|
+
selection: resolveRunSelection({ channel: ctx.channel, session: await sessionStore.getById(sessionId) }),
|
|
119
120
|
text: ctx.userMessage || '',
|
|
120
121
|
senderId: ctx.message.senderId,
|
|
121
122
|
...(ctx.message.systemOrigin ? { systemOrigin: ctx.message.systemOrigin } : {}),
|
|
@@ -135,8 +136,8 @@ export class AgentRunner {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
138
|
-
* Resolve what a turn needs but is not part of it — the files
|
|
139
|
-
* created) with its use lease
|
|
139
|
+
* Resolve what a turn needs but is not part of it — the files and the session record (found or
|
|
140
|
+
* created) with its use lease — and open the turn.
|
|
140
141
|
*/
|
|
141
142
|
async _executeReal(ctx, mutationRelease, loadPlatformFiles) {
|
|
142
143
|
const { message, channel, adapter, threadAnchorId, userMessage, agentMessage } = ctx;
|
|
@@ -145,7 +146,7 @@ export class AgentRunner {
|
|
|
145
146
|
const backend = resolveBackendForChannel(channel);
|
|
146
147
|
const { lease, backendSessionId } = await bindTurnSession(ctx, backend);
|
|
147
148
|
const session = lease.session;
|
|
148
|
-
await
|
|
149
|
+
await openTurn({
|
|
149
150
|
channel, adapter, threadAnchorId,
|
|
150
151
|
session: {
|
|
151
152
|
sessionId: session.sessionId, backendSessionId,
|
|
@@ -164,9 +165,9 @@ export class AgentRunner {
|
|
|
164
165
|
prepareRequest: (turnIds) => prepareConversationRequest({
|
|
165
166
|
ids: turnIds, channel, session, userMessage: agentMessage,
|
|
166
167
|
files: turnFiles.files, failedFiles: turnFiles.failures,
|
|
167
|
-
|
|
168
|
+
onPromptBuilt: debugPromptRecorder(session.sessionId, channel),
|
|
168
169
|
}),
|
|
169
|
-
})
|
|
170
|
+
});
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
/** In debug mode, the backend-ready prompt of each turn is kept in the session's history. */
|
|
@@ -194,7 +195,7 @@ async function bindTurnSession(ctx, backend) {
|
|
|
194
195
|
await registerSessionRecord(sessionStore, {
|
|
195
196
|
sessionId, channel: ctx.channel, backend,
|
|
196
197
|
label: ctx.userMessage?.substring(0, 60) ?? null,
|
|
197
|
-
|
|
198
|
+
selection: resolveRunSelection({ channel: ctx.channel }),
|
|
198
199
|
projectId: (await ctx.adapter.resolveInboundProject(ctx.channel)) ?? 'general',
|
|
199
200
|
});
|
|
200
201
|
await setSessionAsync(ctx.channel, sessionId);
|