@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
|
@@ -14,6 +14,38 @@ const AUTH_KIND_KEYS = {
|
|
|
14
14
|
function pairKey(event) {
|
|
15
15
|
return `${event.backend}:${event.provider}`;
|
|
16
16
|
}
|
|
17
|
+
/** One reminder per pair and channel every 24h; a null channel (internal run) is its own bucket. */
|
|
18
|
+
class ReminderLedger {
|
|
19
|
+
now;
|
|
20
|
+
byPair = new Map();
|
|
21
|
+
constructor(now) {
|
|
22
|
+
this.now = now;
|
|
23
|
+
}
|
|
24
|
+
fresh(reminder) {
|
|
25
|
+
return reminder !== undefined && this.now() - reminder.notifiedAt < REMINDER_INTERVAL_MS;
|
|
26
|
+
}
|
|
27
|
+
anyRecent(pair) {
|
|
28
|
+
return [...(this.byPair.get(pair)?.values() ?? [])].some(reminder => this.fresh(reminder));
|
|
29
|
+
}
|
|
30
|
+
/** Reserve before async delivery so concurrent events cannot create a retry storm. */
|
|
31
|
+
reserve(pair, channel) {
|
|
32
|
+
const channels = this.byPair.get(pair) ?? new Map();
|
|
33
|
+
if (this.fresh(channels.get(channel)))
|
|
34
|
+
return null;
|
|
35
|
+
const attempt = Symbol(pair);
|
|
36
|
+
channels.set(channel, { notifiedAt: this.now(), attempt });
|
|
37
|
+
this.byPair.set(pair, channels);
|
|
38
|
+
return attempt;
|
|
39
|
+
}
|
|
40
|
+
release(pair, channel, attempt) {
|
|
41
|
+
const channels = this.byPair.get(pair);
|
|
42
|
+
if (channels?.get(channel)?.attempt === attempt)
|
|
43
|
+
channels.delete(channel);
|
|
44
|
+
}
|
|
45
|
+
clear(pair) {
|
|
46
|
+
this.byPair.delete(pair);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
17
49
|
let recentNotificationQuery = () => false;
|
|
18
50
|
export function wasAuthRecentlyNotified(backend, provider) {
|
|
19
51
|
return recentNotificationQuery(backend, provider);
|
|
@@ -91,14 +123,21 @@ async function postPlatformNotice(adapter, event, text, action, buildAction) {
|
|
|
91
123
|
...(event.sessionId !== null ? { sessionId: event.sessionId } : {}),
|
|
92
124
|
}, platformContent(text, button));
|
|
93
125
|
}
|
|
126
|
+
/** Internal runs have no conversation: the notice and its login button go to the admin channel. */
|
|
127
|
+
async function emitAdminNotice(adapter, notice, action, buildAction) {
|
|
128
|
+
const button = action && buildAction ? buildAction(action, '', notice.text) : null;
|
|
129
|
+
const { richBlocks } = platformContent(notice.text, button);
|
|
130
|
+
await emitSystemNotice(adapter, { ...notice, level: 'error', richBlocks });
|
|
131
|
+
}
|
|
94
132
|
async function deliverNotice(bus, adapter, event, dependencies) {
|
|
95
133
|
const web = event.channel?.startsWith('web:') ?? false;
|
|
96
134
|
const snapshot = await readSnapshot(dependencies.readStatus ?? getAuthStatus);
|
|
97
|
-
const action =
|
|
98
|
-
|
|
135
|
+
const action = resolveAction(event, snapshot);
|
|
136
|
+
// The admin notice's Web toast cannot carry the button, so its text keeps the manual guidance.
|
|
137
|
+
const actionable = !!action && event.channel !== null && (web || !!dependencies.buildPlatformAction);
|
|
99
138
|
const notice = buildNotice(event, findAccount(snapshot, event), actionable);
|
|
100
139
|
if (event.channel === null) {
|
|
101
|
-
await
|
|
140
|
+
await emitAdminNotice(adapter, notice, action, dependencies.buildPlatformAction);
|
|
102
141
|
}
|
|
103
142
|
else if (web) {
|
|
104
143
|
publishWebNotice(bus, event, notice.text, action);
|
|
@@ -109,28 +148,19 @@ async function deliverNotice(bus, adapter, event, dependencies) {
|
|
|
109
148
|
}
|
|
110
149
|
export function registerAuthWatch(bus, adapter, dependencies = {}) {
|
|
111
150
|
// A restart may repeat one reminder; keeping this local avoids shared mutable publisher state.
|
|
112
|
-
const reminders = new
|
|
113
|
-
|
|
114
|
-
const wasRecentlyNotified = (backend, provider) => {
|
|
115
|
-
const previous = reminders.get(pairKey({ backend, provider }))?.notifiedAt;
|
|
116
|
-
return previous !== undefined && now() - previous < REMINDER_INTERVAL_MS;
|
|
117
|
-
};
|
|
118
|
-
recentNotificationQuery = wasRecentlyNotified;
|
|
151
|
+
const reminders = new ReminderLedger(dependencies.now ?? Date.now);
|
|
152
|
+
recentNotificationQuery = (backend, provider) => reminders.anyRecent(pairKey({ backend, provider }));
|
|
119
153
|
bus.subscribe('auth.required', (event) => {
|
|
120
154
|
const key = pairKey(event);
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
155
|
+
const attempt = reminders.reserve(key, event.channel);
|
|
156
|
+
if (!attempt)
|
|
123
157
|
return;
|
|
124
|
-
// Reserve before async delivery so concurrent events cannot create a retry storm.
|
|
125
|
-
const attempt = Symbol(key);
|
|
126
|
-
reminders.set(key, { notifiedAt: current, attempt });
|
|
127
158
|
void deliverNotice(bus, adapter, event, dependencies).catch(() => {
|
|
128
|
-
|
|
129
|
-
reminders.delete(key);
|
|
159
|
+
reminders.release(key, event.channel, attempt);
|
|
130
160
|
log.error(`Failed to deliver authentication notice for ${key}`);
|
|
131
161
|
});
|
|
132
162
|
});
|
|
133
163
|
bus.subscribe('auth.recovered', (event) => {
|
|
134
|
-
reminders.
|
|
164
|
+
reminders.clear(pairKey(event));
|
|
135
165
|
});
|
|
136
166
|
}
|
|
@@ -1,39 +1,19 @@
|
|
|
1
1
|
import { type DiscoveredEndpoint } from '../../core/gateway-generator.js';
|
|
2
|
+
import type { ModelRef } from '../agents/engine-selection.js';
|
|
2
3
|
export interface GatewaySyncResult {
|
|
3
|
-
/** True when gateway.yaml and profiles.json were regenerated. */
|
|
4
4
|
configured: boolean;
|
|
5
|
-
/** How many endpoints discovery reported. */
|
|
6
5
|
endpoints: number;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/**
|
|
6
|
+
/** Whether this sync supplied a previously missing default. */
|
|
7
|
+
defaultSet: boolean;
|
|
8
|
+
/** Favorites actually present after the sync. */
|
|
9
|
+
favorites: ModelRef[];
|
|
10
10
|
reason?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface GatewaySyncOptions {
|
|
13
|
-
/** Limit discovery to these backends. Omitted → discover everything available. */
|
|
14
13
|
backends?: string[];
|
|
15
|
-
/** Where profiles.json lives. Defaults to the running install's config dir. */
|
|
16
14
|
configDir?: string;
|
|
17
|
-
/** Where gateway.yaml lives. Defaults to ~/.aistatus. */
|
|
18
15
|
gatewayConfigDir?: string;
|
|
19
|
-
/** Injectable discovery seam (tests supply fixed endpoints instead of scanning the machine). */
|
|
20
16
|
discover?: (backends?: string[]) => DiscoveredEndpoint[] | Promise<DiscoveredEndpoint[]>;
|
|
21
17
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Regenerate gateway.yaml and profiles.json from the backends that are reachable right now.
|
|
24
|
-
*
|
|
25
|
-
* Logging in is only half of becoming usable: the models a provider exposes are discovered by
|
|
26
|
-
* scanning local backend state (PI's auth and model catalog, Claude config), and that scan previously ran
|
|
27
|
-
* only inside `cortex init` and `cortex setup-gateway`. A user who logged in from the workbench
|
|
28
|
-
* therefore had working credentials but no profile pointing at the newly reachable models, with no
|
|
29
|
-
* in-product way to fix it. Running this after a successful login closes that loop.
|
|
30
|
-
*
|
|
31
|
-
* Both writes are merge-aware on purpose: `writeMergedGatewayYaml` keeps hand-maintained modes, and
|
|
32
|
-
* profiles are written with `overwrite: false` so an operator's edited `plan` / `execute` survives —
|
|
33
|
-
* a login must never silently re-point which model the agents run on. Only missing profiles are
|
|
34
|
-
* filled in.
|
|
35
|
-
*
|
|
36
|
-
* Never throws. It runs on the tail of a login flow and inside a UI mutation; a discovery hiccup
|
|
37
|
-
* must not fail the login that just succeeded, so problems come back as `configured: false`.
|
|
38
|
-
*/
|
|
18
|
+
/** Add newly connected backend/provider groups without changing an existing default. Never fails login. */
|
|
39
19
|
export declare function syncGatewayFromBackends(options?: GatewaySyncOptions): Promise<GatewaySyncResult>;
|
|
@@ -1,90 +1,46 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
1
|
import * as path from 'node:path';
|
|
3
2
|
import { createLogger } from '../../core/log.js';
|
|
3
|
+
import { atomicWriteSync } from '../../core/atomic-write.js';
|
|
4
4
|
import { discoverEndpoints, writeMergedGatewayYaml } from '../../core/gateway-generator.js';
|
|
5
|
-
import {
|
|
5
|
+
import { generateModels, mergeModelsJson, readExistingModels, recommendedChoice } from '../../core/models-generator.js';
|
|
6
6
|
import { CONFIG_DIR } from '../../core/paths.js';
|
|
7
|
+
import { modelsRepo, modelsWriteLock } from '../../store/models-repo.js';
|
|
7
8
|
const log = createLogger('gateway-sync');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
function syncModels(endpoints, configDir) {
|
|
10
|
+
const saved = readExistingModels(configDir);
|
|
11
|
+
const groups = new Set((saved?.favorites ?? []).map(ref => JSON.stringify([ref.backend, ref.provider])));
|
|
12
|
+
const generated = generateModels(endpoints);
|
|
13
|
+
generated.favorites = [];
|
|
14
|
+
for (const endpoint of endpoints) {
|
|
15
|
+
if (!recommendedChoice([endpoint]))
|
|
16
|
+
continue;
|
|
17
|
+
const ref = generateModels([endpoint]).favorites[0];
|
|
18
|
+
const group = JSON.stringify([ref.backend, ref.provider]);
|
|
19
|
+
if (groups.has(group))
|
|
20
|
+
continue;
|
|
21
|
+
generated.favorites.push(ref);
|
|
22
|
+
groups.add(group);
|
|
23
|
+
}
|
|
24
|
+
const merged = mergeModelsJson(generated, configDir);
|
|
25
|
+
atomicWriteSync(path.join(configDir, 'models.json'), JSON.stringify(merged, null, 2) + '\n');
|
|
26
|
+
modelsRepo.invalidate();
|
|
27
|
+
return { defaultSet: !saved?.default, favorites: merged.favorites };
|
|
28
|
+
}
|
|
29
|
+
/** Add newly connected backend/provider groups without changing an existing default. Never fails login. */
|
|
25
30
|
export async function syncGatewayFromBackends(options = {}) {
|
|
26
|
-
const discover = options.discover ?? discoverEndpoints;
|
|
27
|
-
const configDir = options.configDir ?? CONFIG_DIR;
|
|
28
31
|
try {
|
|
29
|
-
const endpoints = await discover(options.backends);
|
|
30
|
-
if (endpoints.length
|
|
31
|
-
|
|
32
|
-
return { configured: false, endpoints: 0, profiles: [], reason: 'no-endpoints' };
|
|
32
|
+
const endpoints = await (options.discover ?? discoverEndpoints)(options.backends);
|
|
33
|
+
if (!endpoints.some(endpoint => endpoint.models.length > 0)) {
|
|
34
|
+
return { configured: false, endpoints: 0, defaultSet: false, favorites: [], reason: 'no-endpoints' };
|
|
33
35
|
}
|
|
34
36
|
writeMergedGatewayYaml(endpoints, options.gatewayConfigDir);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const profiles = readProfileNames(configDir);
|
|
39
|
-
log.info(`Synced ${endpoints.length} endpoint(s) → profiles: ${profiles.join(', ')}`);
|
|
40
|
-
return { configured: true, endpoints: endpoints.length, profiles };
|
|
37
|
+
const result = await modelsWriteLock.run(() => syncModels(endpoints, options.configDir ?? CONFIG_DIR));
|
|
38
|
+
log.info(`Synced ${endpoints.length} endpoint(s) → ${result.favorites.length} favorite model(s)`);
|
|
39
|
+
return { configured: true, endpoints: endpoints.length, ...result };
|
|
41
40
|
}
|
|
42
41
|
catch (error) {
|
|
43
42
|
const reason = error instanceof Error ? error.message : String(error);
|
|
44
43
|
log.warn(`Gateway sync skipped: ${reason}`);
|
|
45
|
-
return { configured: false, endpoints: 0,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/** Read back the profile names actually on disk, so the caller reports facts rather than intent. */
|
|
49
|
-
function readProfileNames(configDir) {
|
|
50
|
-
const file = path.join(configDir, 'profiles.json');
|
|
51
|
-
if (!existsSync(file))
|
|
52
|
-
return [];
|
|
53
|
-
try {
|
|
54
|
-
const parsed = JSON.parse(readFileSync(file, 'utf-8'));
|
|
55
|
-
return Object.keys(parsed.profiles ?? {});
|
|
44
|
+
return { configured: false, endpoints: 0, defaultSet: false, favorites: [], reason };
|
|
56
45
|
}
|
|
57
|
-
catch {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function missingBackendChoices(endpoints, configDir) {
|
|
62
|
-
const file = path.join(configDir, 'profiles.json');
|
|
63
|
-
if (!existsSync(file))
|
|
64
|
-
return [];
|
|
65
|
-
const saved = JSON.parse(readFileSync(file, 'utf8'));
|
|
66
|
-
const backends = new Set(Object.values(saved.profiles ?? {}).map(p => p.backend));
|
|
67
|
-
const extras = [];
|
|
68
|
-
const names = new Set(Object.keys(saved.profiles ?? {}));
|
|
69
|
-
for (const endpoint of endpoints) {
|
|
70
|
-
const choice = recommendedChoice([endpoint]);
|
|
71
|
-
if (!choice)
|
|
72
|
-
continue;
|
|
73
|
-
const backend = generateProfiles([endpoint]).profiles.plan.backend;
|
|
74
|
-
if (backends.has(backend))
|
|
75
|
-
continue;
|
|
76
|
-
const name = availableProfileName(choice.model, backend, names);
|
|
77
|
-
extras.push({ ...choice, name });
|
|
78
|
-
names.add(name);
|
|
79
|
-
backends.add(backend);
|
|
80
|
-
}
|
|
81
|
-
return extras;
|
|
82
|
-
}
|
|
83
|
-
function availableProfileName(model, backend, names) {
|
|
84
|
-
const base = model.replace(/[^a-zA-Z0-9_-]/g, '-') || backend;
|
|
85
|
-
let name = base;
|
|
86
|
-
let suffix = 1;
|
|
87
|
-
while (name === 'plan' || name === 'execute' || names.has(name))
|
|
88
|
-
name = `${backend}-${base}-${suffix++}`;
|
|
89
|
-
return name;
|
|
90
46
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { McpComposition } from '../../agent-adapter/types.js';
|
|
2
|
-
import type { ResolvedProfileConfig } from '../agents/profile-manager.js';
|
|
1
|
+
import type { Backend, McpComposition } from '../../agent-adapter/types.js';
|
|
3
2
|
export type IdentityJsonValue = null | boolean | number | string | IdentityJsonValue[] | {
|
|
4
3
|
[key: string]: IdentityJsonValue;
|
|
5
4
|
};
|
|
6
5
|
export interface ModelExecutionIdentityInput {
|
|
7
|
-
backend:
|
|
6
|
+
backend: Backend;
|
|
8
7
|
requestedModel: string;
|
|
9
8
|
modelAliasPolicy: IdentityJsonValue;
|
|
10
9
|
providerProtocol: string | null;
|
|
@@ -12,11 +11,10 @@ export interface ModelExecutionIdentityInput {
|
|
|
12
11
|
claudeCliVersion: string | null;
|
|
13
12
|
/** Backend-neutral CLI identity; `claudeCliVersion` keeps its Claude-only meaning so every
|
|
14
13
|
* hash frozen before the neutral pair existed stays reproducible from its own inputs. */
|
|
15
|
-
cliName:
|
|
14
|
+
cliName: Backend | null;
|
|
16
15
|
cliVersion: string | null;
|
|
17
16
|
reasoningEffort: string | null;
|
|
18
17
|
maxOutputTokens?: number | null;
|
|
19
|
-
fallbackEmpty: true;
|
|
20
18
|
}
|
|
21
19
|
export interface PluginDirIdentityInput {
|
|
22
20
|
path: string;
|
|
@@ -46,7 +46,6 @@ export function computeModelExecutionIdentityHash(input) {
|
|
|
46
46
|
cli_version: input.cliVersion,
|
|
47
47
|
reasoning_effort: input.reasoningEffort,
|
|
48
48
|
max_output_tokens: input.maxOutputTokens ?? null,
|
|
49
|
-
fallback_empty: input.fallbackEmpty,
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
function compareText(left, right) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Backend, EngineSpec } from '../../agent-adapter/types.js';
|
|
2
2
|
import type { RunRequest } from '../runs/request.js';
|
|
3
|
-
import type {
|
|
4
|
-
declare const RECORD_SCHEMA = "cortex-production-attempt-identity/
|
|
3
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
4
|
+
declare const RECORD_SCHEMA = "cortex-production-attempt-identity/5";
|
|
5
5
|
export type ProductionAttemptIdentityRecord = Readonly<{
|
|
6
6
|
schema_version: typeof RECORD_SCHEMA;
|
|
7
7
|
trial_id: string;
|
|
@@ -11,7 +11,8 @@ export type ProductionAttemptIdentityRecord = Readonly<{
|
|
|
11
11
|
spawn_parent_attempt_id: string | null;
|
|
12
12
|
execution_id: string;
|
|
13
13
|
session_id: string;
|
|
14
|
-
|
|
14
|
+
thinking: string | null;
|
|
15
|
+
mode: string;
|
|
15
16
|
backend: Backend;
|
|
16
17
|
provider: string | null;
|
|
17
18
|
requested_model: string;
|
|
@@ -21,7 +22,7 @@ export type ProductionAttemptIdentityRecord = Readonly<{
|
|
|
21
22
|
frozen_at: string;
|
|
22
23
|
}>;
|
|
23
24
|
interface ConfigurationRevision {
|
|
24
|
-
|
|
25
|
+
models: number;
|
|
25
26
|
environments: number;
|
|
26
27
|
}
|
|
27
28
|
export interface ProductionAttemptIdentityInit {
|
|
@@ -34,7 +35,7 @@ interface FreezeAttemptInput {
|
|
|
34
35
|
request: RunRequest;
|
|
35
36
|
/** The execution record this attempt belongs to — the attested attempt id is derived from it. */
|
|
36
37
|
executionId: string | null;
|
|
37
|
-
|
|
38
|
+
selection: EngineSelection | undefined;
|
|
38
39
|
}
|
|
39
40
|
type AttemptScope = Pick<ProductionAttemptIdentityRecord, 'trial_id' | 'root_run_id' | 'session_id'>;
|
|
40
41
|
export interface ProductionAttemptIdentityScope {
|
|
@@ -5,12 +5,12 @@ import { parseProductionBenchmarkEvidenceContext } from './production-benchmark-
|
|
|
5
5
|
import { computeModelExecutionIdentityHash, computeRoleToolSurfaceHash, } from './identity.js';
|
|
6
6
|
import { roleSurfaceFromSpec } from './role-surface.js';
|
|
7
7
|
import { initializeProductionAttemptJournals, resetProductionAttemptJournals, } from './production-attempt-journal.js';
|
|
8
|
-
const RECORD_SCHEMA = 'cortex-production-attempt-identity/
|
|
8
|
+
const RECORD_SCHEMA = 'cortex-production-attempt-identity/5';
|
|
9
9
|
const SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
10
10
|
const DEFAULT_STORE_PATH = path.join(STORE_DIR, 'benchmark-attempt-identities.jsonl');
|
|
11
11
|
const RECORD_KEYS = [
|
|
12
12
|
'schema_version', 'trial_id', 'root_run_id', 'attempt_id', 'root_attempt_id',
|
|
13
|
-
'spawn_parent_attempt_id', 'execution_id', 'session_id', '
|
|
13
|
+
'spawn_parent_attempt_id', 'execution_id', 'session_id', 'thinking', 'mode',
|
|
14
14
|
'backend', 'provider', 'requested_model', 'model_execution_identity_hash',
|
|
15
15
|
'role_tool_surface_hash', 'bundle_manifest_hash', 'frozen_at',
|
|
16
16
|
];
|
|
@@ -37,10 +37,10 @@ function isNullableString(value) {
|
|
|
37
37
|
function storedRecordValid(value) {
|
|
38
38
|
const strings = [
|
|
39
39
|
'trial_id', 'root_run_id', 'attempt_id', 'root_attempt_id', 'execution_id',
|
|
40
|
-
'session_id', '
|
|
40
|
+
'session_id', 'mode', 'requested_model', 'model_execution_identity_hash',
|
|
41
41
|
'role_tool_surface_hash', 'bundle_manifest_hash', 'frozen_at',
|
|
42
42
|
];
|
|
43
|
-
const nullable = ['spawn_parent_attempt_id', 'provider'];
|
|
43
|
+
const nullable = ['spawn_parent_attempt_id', 'provider', 'thinking'];
|
|
44
44
|
const hashes = [
|
|
45
45
|
value.model_execution_identity_hash, value.role_tool_surface_hash, value.bundle_manifest_hash,
|
|
46
46
|
];
|
|
@@ -240,34 +240,31 @@ function configuredRouteHost(spec, backend) {
|
|
|
240
240
|
throw new Error(`Production benchmark resolved route is invalid: ${route}`);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
if (spec.model.id !==
|
|
243
|
+
function assertSpawnMatchesSelection(spec, selection) {
|
|
244
|
+
if (spec.model.id !== selection.model) {
|
|
245
245
|
throw new Error('Production benchmark resolved model drifted before adapter spawn');
|
|
246
246
|
}
|
|
247
|
-
if ((spec.model.thinking ?? null) !==
|
|
247
|
+
if ((spec.model.thinking ?? null) !== selection.thinking) {
|
|
248
248
|
throw new Error('Production benchmark resolved thinking drifted before adapter spawn');
|
|
249
249
|
}
|
|
250
|
-
if (
|
|
250
|
+
if (selection.backend === 'pi' && (spec.model.provider ?? null) !== selection.provider) {
|
|
251
251
|
throw new Error('Production benchmark resolved provider drifted before adapter spawn');
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
257
|
-
throw new Error('Production benchmark attempt is missing
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
if (profile.backend !== context.model_execution.cli_name
|
|
262
|
-
|| profile.backend !== input.adapterBackend) {
|
|
254
|
+
function assertSelection(input, context) {
|
|
255
|
+
const selection = input.selection;
|
|
256
|
+
if (!selection)
|
|
257
|
+
throw new Error('Production benchmark attempt is missing selection');
|
|
258
|
+
if (selection.backend !== context.model_execution.cli_name
|
|
259
|
+
|| selection.backend !== input.adapterBackend) {
|
|
263
260
|
throw new Error('Production benchmark backend differs from injected CLI identity');
|
|
264
261
|
}
|
|
265
|
-
|
|
266
|
-
return
|
|
262
|
+
assertSpawnMatchesSelection(input.spec, selection);
|
|
263
|
+
return selection;
|
|
267
264
|
}
|
|
268
265
|
function maxOutputTokens(spec, context) {
|
|
269
266
|
const injected = context.model_execution.max_output_tokens;
|
|
270
|
-
const resolved = spec.model.
|
|
267
|
+
const resolved = spec.model.benchmarkMaxOutputTokens ?? null;
|
|
271
268
|
if (resolved !== injected) {
|
|
272
269
|
throw new Error('Production benchmark max output token identity drifted');
|
|
273
270
|
}
|
|
@@ -289,33 +286,33 @@ function attemptLinkage(state, request, executionIdInput, context, existing) {
|
|
|
289
286
|
execution_id: executionId, session_id: scope.session_id,
|
|
290
287
|
};
|
|
291
288
|
}
|
|
292
|
-
function modelExecutionHash(context, spec,
|
|
289
|
+
function modelExecutionHash(context, spec, selection) {
|
|
293
290
|
const cli = context.model_execution;
|
|
294
291
|
return computeModelExecutionIdentityHash({
|
|
295
|
-
backend:
|
|
296
|
-
requestedModel:
|
|
292
|
+
backend: selection.backend,
|
|
293
|
+
requestedModel: selection.model,
|
|
297
294
|
modelAliasPolicy: cli.model_alias_policy,
|
|
298
|
-
providerProtocol:
|
|
299
|
-
configuredRouteBaseHost: configuredRouteHost(spec,
|
|
300
|
-
claudeCliVersion:
|
|
295
|
+
providerProtocol: selection.provider,
|
|
296
|
+
configuredRouteBaseHost: configuredRouteHost(spec, selection.backend),
|
|
297
|
+
claudeCliVersion: selection.backend === 'claude' ? cli.cli_version : null,
|
|
301
298
|
cliName: cli.cli_name,
|
|
302
299
|
cliVersion: cli.cli_version,
|
|
303
|
-
reasoningEffort:
|
|
300
|
+
reasoningEffort: selection.thinking,
|
|
304
301
|
maxOutputTokens: maxOutputTokens(spec, context),
|
|
305
|
-
fallbackEmpty: true,
|
|
306
302
|
});
|
|
307
303
|
}
|
|
308
304
|
function attemptModel(context, input) {
|
|
309
|
-
const
|
|
305
|
+
const selection = assertSelection(input, context);
|
|
310
306
|
const directive = typeof input.request.benchmark?.identityDirective === 'string'
|
|
311
307
|
? input.request.benchmark.identityDirective : '';
|
|
312
308
|
const roleSurface = roleSurfaceFromSpec(input.spec, directive);
|
|
313
309
|
return {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
310
|
+
thinking: selection.thinking,
|
|
311
|
+
mode: selection.mode,
|
|
312
|
+
backend: selection.backend,
|
|
313
|
+
provider: selection.provider,
|
|
314
|
+
requested_model: selection.model,
|
|
315
|
+
model_execution_identity_hash: modelExecutionHash(context, input.spec, selection),
|
|
319
316
|
role_tool_surface_hash: computeRoleToolSurfaceHash(roleSurface),
|
|
320
317
|
};
|
|
321
318
|
}
|
|
@@ -335,7 +332,7 @@ function assertRootBaseline(repo, record) {
|
|
|
335
332
|
if (!root)
|
|
336
333
|
return;
|
|
337
334
|
const rootFields = [
|
|
338
|
-
'trial_id', 'root_run_id', 'bundle_manifest_hash', '
|
|
335
|
+
'trial_id', 'root_run_id', 'bundle_manifest_hash', 'thinking', 'mode', 'backend', 'provider',
|
|
339
336
|
'requested_model', 'model_execution_identity_hash',
|
|
340
337
|
];
|
|
341
338
|
if (rootFields.some(field => root[field] !== record[field])) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProductionBenchmarkEvidenceContext } from './benchmark-types.js';
|
|
2
2
|
/** Bind `context` to `sessionId`. A trial run (trial id + root run id) owns exactly one session. */
|
|
3
|
-
export declare function bindSessionEvidenceContext(sessionId: string, context: ProductionBenchmarkEvidenceContext): void;
|
|
3
|
+
export declare function bindSessionEvidenceContext(sessionId: string, context: ProductionBenchmarkEvidenceContext, benchmarkMaxOutputTokens?: number): void;
|
|
4
4
|
export declare function sessionEvidenceContext(sessionId: string): ProductionBenchmarkEvidenceContext | null;
|
|
5
|
+
export declare function sessionBenchmarkMaxOutputTokens(sessionId: string): number | undefined;
|
|
5
6
|
export declare function sessionForRun(trialId: string, rootRunId: string): string | null;
|
|
6
7
|
export declare function _resetSessionEvidence(): void;
|
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
// of that session then opens its runs with the context, so each attempt is frozen and journaled.
|
|
5
5
|
// In memory only: a trial's server lives exactly as long as its one session.
|
|
6
6
|
const bound = new Map();
|
|
7
|
+
const outputCaps = new Map();
|
|
7
8
|
/** Bind `context` to `sessionId`. A trial run (trial id + root run id) owns exactly one session. */
|
|
8
|
-
export function bindSessionEvidenceContext(sessionId, context) {
|
|
9
|
+
export function bindSessionEvidenceContext(sessionId, context, benchmarkMaxOutputTokens) {
|
|
9
10
|
const owner = sessionForRun(context.trial_id, context.root_run_id);
|
|
10
11
|
if (owner && owner !== sessionId) {
|
|
11
12
|
throw new Error(`trial run ${context.trial_id}/${context.root_run_id} already has a session`);
|
|
12
13
|
}
|
|
13
14
|
bound.set(sessionId, context);
|
|
15
|
+
if (benchmarkMaxOutputTokens !== undefined)
|
|
16
|
+
outputCaps.set(sessionId, benchmarkMaxOutputTokens);
|
|
14
17
|
}
|
|
15
18
|
export function sessionEvidenceContext(sessionId) {
|
|
16
19
|
return bound.get(sessionId) ?? null;
|
|
17
20
|
}
|
|
21
|
+
export function sessionBenchmarkMaxOutputTokens(sessionId) {
|
|
22
|
+
return outputCaps.get(sessionId);
|
|
23
|
+
}
|
|
18
24
|
export function sessionForRun(trialId, rootRunId) {
|
|
19
25
|
for (const [sessionId, context] of bound) {
|
|
20
26
|
if (context.trial_id === trialId && context.root_run_id === rootRunId)
|
|
@@ -24,4 +30,5 @@ export function sessionForRun(trialId, rootRunId) {
|
|
|
24
30
|
}
|
|
25
31
|
export function _resetSessionEvidence() {
|
|
26
32
|
bound.clear();
|
|
33
|
+
outputCaps.clear();
|
|
27
34
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type AgentBrowserRun } from '../../platform/browser/agent-browser.js';
|
|
2
|
+
/**
|
|
3
|
+
* Browser leases for `cortex-browser`, held per Cortex session rather than per turn.
|
|
4
|
+
*
|
|
5
|
+
* A lease ties one session to one device's shared Chrome (server-local, or a device's through the
|
|
6
|
+
* reverse channel) and to one agent-browser session pinned to its own tab there. It holds one
|
|
7
|
+
* reference on that Chrome, is renewed by every call, and is released, closing its tab, after
|
|
8
|
+
* {@link LEASE_IDLE_MS} without one. Page state survives between turns because nothing here is torn
|
|
9
|
+
* down per turn.
|
|
10
|
+
*/
|
|
11
|
+
export declare const LEASE_IDLE_MS: number;
|
|
12
|
+
export type BrowserSessionState = 'starting' | 'ready' | 'error';
|
|
13
|
+
export interface BrowserSessionInfo {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
device: string;
|
|
16
|
+
abSession: string;
|
|
17
|
+
state: BrowserSessionState;
|
|
18
|
+
error?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
takenOver: boolean;
|
|
22
|
+
lastUsedAt: number;
|
|
23
|
+
}
|
|
24
|
+
export interface BrowserLease {
|
|
25
|
+
device: string;
|
|
26
|
+
cdpEndpoint: string;
|
|
27
|
+
abSession: string;
|
|
28
|
+
}
|
|
29
|
+
export type BrowserLeaseErrorCode = 'bad-request' | 'unknown-device' | 'device-offline' | 'taken-over' | 'chrome-failed' | 'engine-missing' | 'no-lease';
|
|
30
|
+
/** A lease failure meant for a human: what went wrong, and what to do about it. */
|
|
31
|
+
export declare class BrowserLeaseError extends Error {
|
|
32
|
+
readonly code: BrowserLeaseErrorCode;
|
|
33
|
+
readonly hint?: string;
|
|
34
|
+
constructor(code: BrowserLeaseErrorCode, message: string, hint?: string);
|
|
35
|
+
}
|
|
36
|
+
/** Device states the broker distinguishes when asked for one. */
|
|
37
|
+
export type DeviceAvailability = 'online' | 'offline' | 'unknown';
|
|
38
|
+
export interface BrokerDeps {
|
|
39
|
+
/** Take one reference on the device's Chrome, starting it if needed. */
|
|
40
|
+
acquire(device: string): Promise<string>;
|
|
41
|
+
/** Drop one reference taken by {@link acquire}. */
|
|
42
|
+
release(device: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* The device's live endpoint for a lease that already holds a reference, relaunching Chrome if
|
|
45
|
+
* it died. Must leave the reference count as it found it.
|
|
46
|
+
*/
|
|
47
|
+
refresh(device: string, cdpEndpoint: string): Promise<string>;
|
|
48
|
+
availability(device: string): {
|
|
49
|
+
state: DeviceAvailability;
|
|
50
|
+
online: string[];
|
|
51
|
+
};
|
|
52
|
+
resolveBin(): string;
|
|
53
|
+
baseEnv(): Record<string, string>;
|
|
54
|
+
run(bin: string, args: string[], env: Record<string, string>): Promise<AgentBrowserRun>;
|
|
55
|
+
now(): number;
|
|
56
|
+
idleMs: number;
|
|
57
|
+
}
|
|
58
|
+
export interface BrowserBroker {
|
|
59
|
+
leaseBrowser(input: {
|
|
60
|
+
sessionId: string;
|
|
61
|
+
device?: string | null;
|
|
62
|
+
}): Promise<BrowserLease>;
|
|
63
|
+
listBrowserSessions(): BrowserSessionInfo[];
|
|
64
|
+
runAgentBrowser(sessionId: string, args: string[]): Promise<AgentBrowserRun>;
|
|
65
|
+
streamPort(sessionId: string): Promise<number | null>;
|
|
66
|
+
setTakeover(sessionId: string, on: boolean): void;
|
|
67
|
+
isTakenOver(sessionId: string): boolean;
|
|
68
|
+
insertText(sessionId: string, text: string): Promise<void>;
|
|
69
|
+
/** A CLI call finished: refresh the URL and title shown for the session. */
|
|
70
|
+
noteBrowserCommand(sessionId: string): void;
|
|
71
|
+
/** The binary and environment a CLI call must use to reach this broker's daemons. */
|
|
72
|
+
agentBrowserRuntime(): {
|
|
73
|
+
bin: string;
|
|
74
|
+
env: Record<string, string>;
|
|
75
|
+
};
|
|
76
|
+
onBrowserSessionsChanged(listener: () => void): () => void;
|
|
77
|
+
/** Forget every lease (daemon shutdown). Chrome itself is stopped by its own owner. */
|
|
78
|
+
shutdown(): void;
|
|
79
|
+
}
|
|
80
|
+
/** Turn a device launch failure (often a bare marker from the launch script) into a sentence. */
|
|
81
|
+
export declare function describeDeviceFailure(device: string, raw: string): {
|
|
82
|
+
message: string;
|
|
83
|
+
hint?: string;
|
|
84
|
+
};
|
|
85
|
+
export declare function createBrowserBroker(deps: BrokerDeps): BrowserBroker;
|
|
86
|
+
export declare function defaultBrokerDeps(): BrokerDeps;
|
|
87
|
+
/** Test seam: swap the process-wide broker (pass null to rebuild it from the real deps). */
|
|
88
|
+
export declare function _setBrowserBroker(next: BrowserBroker | null): void;
|
|
89
|
+
export declare const leaseBrowser: BrowserBroker['leaseBrowser'];
|
|
90
|
+
export declare const listBrowserSessions: BrowserBroker['listBrowserSessions'];
|
|
91
|
+
export declare const runAgentBrowser: BrowserBroker['runAgentBrowser'];
|
|
92
|
+
export declare const streamPort: BrowserBroker['streamPort'];
|
|
93
|
+
export declare const setTakeover: BrowserBroker['setTakeover'];
|
|
94
|
+
export declare const isTakenOver: BrowserBroker['isTakenOver'];
|
|
95
|
+
export declare const insertText: BrowserBroker['insertText'];
|
|
96
|
+
export declare const noteBrowserCommand: BrowserBroker['noteBrowserCommand'];
|
|
97
|
+
export declare const agentBrowserRuntime: BrowserBroker['agentBrowserRuntime'];
|
|
98
|
+
export declare const onBrowserSessionsChanged: BrowserBroker['onBrowserSessionsChanged'];
|
|
99
|
+
export declare function shutdownBrowserBroker(): void;
|