@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
|
@@ -13,11 +13,23 @@ function positiveInt(value, fallback) {
|
|
|
13
13
|
* Build the tool context from the environment a stdio MCP entry was spawned with. Throws for an
|
|
14
14
|
* unparsable or unknown tool allowlist so a misconfigured server refuses to start.
|
|
15
15
|
*/
|
|
16
|
+
function selectionFromEnv(env) {
|
|
17
|
+
const backend = env.CORTEX_BACKEND;
|
|
18
|
+
const model = optional(env.CORTEX_MODEL);
|
|
19
|
+
if ((backend !== 'claude' && backend !== 'pi') || !model)
|
|
20
|
+
return null;
|
|
21
|
+
return {
|
|
22
|
+
backend, model,
|
|
23
|
+
provider: backend === 'pi' ? optional(env.CORTEX_PROVIDER) : null,
|
|
24
|
+
thinking: optional(env.CORTEX_THINKING),
|
|
25
|
+
mode: env.CORTEX_MODE ?? '',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
16
28
|
export function toolContextFromEnv(env = process.env) {
|
|
17
29
|
return {
|
|
18
30
|
channel: optional(env.SLACK_CHANNEL) ?? optional(env.FEISHU_CHANNEL),
|
|
19
31
|
sessionId: optional(env.CORTEX_SESSION_ID),
|
|
20
|
-
|
|
32
|
+
selection: selectionFromEnv(env),
|
|
21
33
|
project: optional(env.CORTEX_PROJECT),
|
|
22
34
|
backend: optional(env.CORTEX_BACKEND),
|
|
23
35
|
claudeModel: optional(env.CORTEX_CLAUDE_MODEL),
|
|
@@ -25,7 +37,6 @@ export function toolContextFromEnv(env = process.env) {
|
|
|
25
37
|
subagentClaudeModels: decodeSubagentModels(env.CORTEX_SUBAGENT_CLAUDE_MODELS),
|
|
26
38
|
scheduleTaskId: optional(env.CORTEX_SCHEDULE_TASK_ID),
|
|
27
39
|
callbackSource: optional(env.CORTEX_CALLBACK_SOURCE),
|
|
28
|
-
branchMachine: optional(env.CORTEX_BRANCH_MACHINE),
|
|
29
40
|
webhookBaseUrl: `http://127.0.0.1:${positiveInt(env.WEBHOOK_PORT, DEFAULT_WEBHOOK_PORT)}`,
|
|
30
41
|
webhookToken: env.CORTEX_WEBHOOK_TOKEN || '',
|
|
31
42
|
slackBotToken: optional(env.SLACK_BOT_TOKEN),
|
|
@@ -61,7 +72,9 @@ export async function resolveCortexContext(ctx, findBoard = lookupBoard) {
|
|
|
61
72
|
const scope = {
|
|
62
73
|
channel: ctx.channel,
|
|
63
74
|
sessionId: ctx.sessionId,
|
|
64
|
-
|
|
75
|
+
model: ctx.selection?.model ?? null,
|
|
76
|
+
thinking: ctx.selection?.thinking ?? null,
|
|
77
|
+
mode: ctx.selection?.mode ?? null,
|
|
65
78
|
project: ctx.project,
|
|
66
79
|
backend: ctx.backend,
|
|
67
80
|
scheduleTaskId: ctx.scheduleTaskId,
|
|
@@ -79,7 +92,7 @@ export async function resolveCortexContext(ctx, findBoard = lookupBoard) {
|
|
|
79
92
|
return scope;
|
|
80
93
|
}
|
|
81
94
|
export function registerContextTools(server, ctx) {
|
|
82
|
-
server.tool('cortex_context', 'Get current session identity,
|
|
95
|
+
server.tool('cortex_context', 'Get current session identity, backend, model, thinking, mode, project, bound board and trigger context.', {}, { readOnlyHint: true }, async () => {
|
|
83
96
|
try {
|
|
84
97
|
const ctxInternal = await resolveCortexContext(ctx);
|
|
85
98
|
// Strip channel from public response — consumers address by project/sessionId.
|
|
@@ -148,7 +148,7 @@ export function registerSubagentTools(server, ctx) {
|
|
|
148
148
|
background: !!background,
|
|
149
149
|
cwd: process.cwd(),
|
|
150
150
|
// The parent's own scope: it decides where children run and what routing they inherit.
|
|
151
|
-
|
|
151
|
+
selection: ctx.selection,
|
|
152
152
|
project: ctx.project,
|
|
153
153
|
channel: ctx.channel,
|
|
154
154
|
backend: ctx.backend,
|
|
@@ -50,7 +50,7 @@ async function sendFiles(ctx, input) {
|
|
|
50
50
|
return sentSummary(Array.isArray(body.data) ? body.data : [body.data], input.device);
|
|
51
51
|
}
|
|
52
52
|
export function registerUiFileTools(server, ctx) {
|
|
53
|
-
server.tool('send_file', 'Share produced files as downloadable chat cards (images preview inline). Send one file or an ordered group with a shared caption. Supports local or remote-device files.', {
|
|
53
|
+
server.tool('send_file', 'Share produced files as downloadable chat cards (images preview inline). Send one file or an ordered group with a shared caption. Supports local or remote-device files. Embed images or videos in reply text with , using a local absolute/~/relative path, workspace/... path, registered-device:/absolute/path (or device:C:/path on Windows), or https:// URL.', {
|
|
54
54
|
file_path: z.string().optional().describe(`${FILE_PATH_DESC} Use this OR \`files\`.`),
|
|
55
55
|
file_name: z.string().optional().describe('Display filename override for file_path.'),
|
|
56
56
|
files: z.array(z.object({
|
|
@@ -18,6 +18,8 @@ export interface EventLoopMonitorOptions {
|
|
|
18
18
|
intervalMs?: number;
|
|
19
19
|
/** Test seam: supplies the histogram instead of `monitorEventLoopDelay`. */
|
|
20
20
|
createHistogram?: () => EventLoopDelayHistogram;
|
|
21
|
+
/** Observer of each closed window (telemetry). */
|
|
22
|
+
onReading?: (reading: EventLoopLagReading) => void;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Close the current window: read the percentiles, log them, and reset the histogram.
|
|
@@ -43,7 +43,11 @@ export function startEventLoopMonitor(options = {}) {
|
|
|
43
43
|
_intervalMs = options.intervalMs ?? DEFAULT_SAMPLE_INTERVAL_MS;
|
|
44
44
|
_histogram = (options.createHistogram ?? (() => monitorEventLoopDelay({ resolution: RESOLUTION_MS })))();
|
|
45
45
|
_histogram.enable();
|
|
46
|
-
_timer = setInterval(() => {
|
|
46
|
+
_timer = setInterval(() => {
|
|
47
|
+
const reading = sampleEventLoopLagOnce();
|
|
48
|
+
if (reading)
|
|
49
|
+
options.onReading?.(reading);
|
|
50
|
+
}, _intervalMs);
|
|
47
51
|
// The daemon's lifetime is owned by its servers, never by this metric timer.
|
|
48
52
|
if (typeof _timer.unref === 'function')
|
|
49
53
|
_timer.unref();
|
|
@@ -21,7 +21,7 @@ export interface CustomProviderInput {
|
|
|
21
21
|
compat?: Record<string, unknown>;
|
|
22
22
|
}
|
|
23
23
|
export type CustomProviderIssue = 'name-required' | 'name-charset' | 'api-invalid' | 'upstream-required' | 'upstream-scheme' | 'models-required' | 'model-id-required' | 'model-id-duplicate';
|
|
24
|
-
/**
|
|
24
|
+
/** Safe provider names used by the model selection and gateway endpoints. */
|
|
25
25
|
export declare const CUSTOM_PROVIDER_NAME_RE: RegExp;
|
|
26
26
|
/**
|
|
27
27
|
* Written as the PI-side `apiKey` so PI counts the provider as authenticated and lists its models.
|
|
@@ -5,7 +5,7 @@ export const CUSTOM_PROVIDER_APIS = [
|
|
|
5
5
|
'openai-responses',
|
|
6
6
|
'google-generative-ai',
|
|
7
7
|
];
|
|
8
|
-
/**
|
|
8
|
+
/** Safe provider names used by the model selection and gateway endpoints. */
|
|
9
9
|
export const CUSTOM_PROVIDER_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
10
10
|
/**
|
|
11
11
|
* Written as the PI-side `apiKey` so PI counts the provider as authenticated and lists its models.
|
|
@@ -33,7 +33,14 @@ export declare function removePlugin(id: string): void;
|
|
|
33
33
|
/** Give a legacy plugin the root manifest that portable discovery needs, reusing the legacy
|
|
34
34
|
* manifest's own fields. The legacy file is left in place. */
|
|
35
35
|
export declare function convertToPortable(id: string): void;
|
|
36
|
+
export interface McpSource {
|
|
37
|
+
servers: Record<string, unknown>;
|
|
38
|
+
/** Hash of the mcp.json bytes in effect; an absent file hashes as empty. */
|
|
39
|
+
baseHash: string;
|
|
40
|
+
}
|
|
36
41
|
/** The raw envelope, secrets included. Only the ui-service redaction layer may see this — it must
|
|
37
42
|
* never be returned to a browser unfiltered (that is the whole point of PLUGIN_MCP_RUNTIME). */
|
|
43
|
+
export declare function readMcpSource(pluginId: string): McpSource;
|
|
38
44
|
export declare function readMcpEnvelope(pluginId: string): Record<string, unknown>;
|
|
39
|
-
|
|
45
|
+
/** Optimistic concurrency, same contract as writeSkillSource. */
|
|
46
|
+
export declare function writeMcpEnvelope(pluginId: string, servers: Record<string, unknown>, baseHash: string): void;
|
|
@@ -273,15 +273,23 @@ export function convertToPortable(id) {
|
|
|
273
273
|
body.description = legacy.description;
|
|
274
274
|
atomicWriteSync(containedTarget(root), `${JSON.stringify(body, null, 2)}\n`);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function parseJsonObject(text) {
|
|
277
277
|
try {
|
|
278
|
-
const parsed = JSON.parse(
|
|
278
|
+
const parsed = JSON.parse(text);
|
|
279
279
|
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
280
280
|
}
|
|
281
281
|
catch {
|
|
282
282
|
return null;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
+
function readJson(filePath) {
|
|
286
|
+
try {
|
|
287
|
+
return parseJsonObject(fs.readFileSync(filePath, 'utf8'));
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
285
293
|
/** The mcp.json in effect: the user's when their layer has one, otherwise the built-in plugin's. */
|
|
286
294
|
function effectiveMcpFile(pluginId) {
|
|
287
295
|
assertName('plugin id', pluginId);
|
|
@@ -294,19 +302,26 @@ function effectiveMcpFile(pluginId) {
|
|
|
294
302
|
}
|
|
295
303
|
/** The raw envelope, secrets included. Only the ui-service redaction layer may see this — it must
|
|
296
304
|
* never be returned to a browser unfiltered (that is the whole point of PLUGIN_MCP_RUNTIME). */
|
|
297
|
-
export function
|
|
305
|
+
export function readMcpSource(pluginId) {
|
|
298
306
|
const file = effectiveMcpFile(pluginId);
|
|
299
307
|
if (!file)
|
|
300
|
-
return {};
|
|
301
|
-
const
|
|
308
|
+
return { servers: {}, baseHash: sha256('') };
|
|
309
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
310
|
+
const parsed = parseJsonObject(text);
|
|
302
311
|
if (!parsed)
|
|
303
312
|
throw fail('invalid-args', `'${pluginId}/mcp.json' is not valid JSON`);
|
|
304
313
|
const servers = parsed.mcpServers;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
: {};
|
|
314
|
+
const valid = servers && typeof servers === 'object' && !Array.isArray(servers);
|
|
315
|
+
return { servers: valid ? servers : {}, baseHash: sha256(text) };
|
|
308
316
|
}
|
|
309
|
-
export function
|
|
317
|
+
export function readMcpEnvelope(pluginId) {
|
|
318
|
+
return readMcpSource(pluginId).servers;
|
|
319
|
+
}
|
|
320
|
+
/** Optimistic concurrency, same contract as writeSkillSource. */
|
|
321
|
+
export function writeMcpEnvelope(pluginId, servers, baseHash) {
|
|
322
|
+
if (readMcpSource(pluginId).baseHash !== baseHash) {
|
|
323
|
+
throw fail('conflict', `'${pluginId}/mcp.json' changed on disk`);
|
|
324
|
+
}
|
|
310
325
|
const envelope = { $schema: AGENT_PLUGIN_V1_MCP_SCHEMA_URL, mcpServers: servers };
|
|
311
326
|
const parsed = portableMcpSchema.safeParse(envelope);
|
|
312
327
|
if (!parsed.success) {
|
|
@@ -6,5 +6,12 @@ export declare function markInUse(directory: string): void;
|
|
|
6
6
|
* directory a later spawn still wants is rebuilt at the same path. Returns what was removed.
|
|
7
7
|
*/
|
|
8
8
|
export declare function sweepStaleRuntimeDirs(backendDir: string, inUse: ReadonlySet<string>, now?: number): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Remove Claude MCP and remote-proxy configs under `runtimeDir` that nothing has touched for
|
|
11
|
+
* {@link STALE_AFTER_MS}. Every Claude spawn and every pooled-session reuse check rewrites or touches
|
|
12
|
+
* the files it resolves, and an idle Claude process exits within the hour, so a file this old is
|
|
13
|
+
* used by no running process. A later spawn that wants it writes it again at the same path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sweepStaleClaudeMcpFiles(runtimeDir: string, now?: number): string[];
|
|
9
16
|
/** Test hook: forget the per-directory sweep throttle. */
|
|
10
17
|
export declare function _resetSweepThrottle(): void;
|
|
@@ -9,6 +9,10 @@ const SWEEP_INTERVAL_MS = 60 * 60 * 1000;
|
|
|
9
9
|
/** Only names this runtime creates (`safeNativeComposite` prefixes): projections and their temp
|
|
10
10
|
* dirs are `plugin_*`, snapshot descriptors are `skill_*`. Anything else is left alone. */
|
|
11
11
|
const OWNED_NAME = /^(plugin|skill)_/;
|
|
12
|
+
/** Claude MCP configs and remote-proxy configs are content-addressed `<sha256>.json` files; an
|
|
13
|
+
* interrupted write leaves its `.tmp.*` sibling behind. */
|
|
14
|
+
const OWNED_MCP_FILE = /^[0-9a-f]{64}\.json(?:\.tmp\..+)?$/;
|
|
15
|
+
const CLAUDE_MCP_DIRS = ['claude-mcp', 'claude-mcp-proxies'];
|
|
12
16
|
const lastSweep = new Map();
|
|
13
17
|
/** Mark a reused projection or snapshot as live, so a sweep in this or another process keeps it. */
|
|
14
18
|
export function markInUse(directory) {
|
|
@@ -20,48 +24,77 @@ export function markInUse(directory) {
|
|
|
20
24
|
// A failed touch only makes the directory eligible for a sweep, which rebuilds it on demand.
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
|
-
function ownedChildren(parent) {
|
|
27
|
+
function ownedChildren(parent, owned) {
|
|
24
28
|
try {
|
|
25
|
-
return fs.readdirSync(parent).filter((name) =>
|
|
29
|
+
return fs.readdirSync(parent).filter((name) => owned.test(name)).map((name) => path.join(parent, name));
|
|
26
30
|
}
|
|
27
31
|
catch {
|
|
28
32
|
return [];
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
function isStale(
|
|
35
|
+
function isStale(entry, now, isKind) {
|
|
32
36
|
try {
|
|
33
|
-
const stat = fs.lstatSync(
|
|
34
|
-
return stat
|
|
37
|
+
const stat = fs.lstatSync(entry);
|
|
38
|
+
return isKind(stat) && now - stat.mtimeMs >= STALE_AFTER_MS;
|
|
35
39
|
}
|
|
36
40
|
catch {
|
|
37
41
|
return false;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
lastSweep.set(backendDir, now);
|
|
44
|
+
/** True when `key` was swept within the last interval; otherwise records this sweep. */
|
|
45
|
+
function throttled(key, now) {
|
|
46
|
+
if (now - (lastSweep.get(key) ?? 0) < SWEEP_INTERVAL_MS)
|
|
47
|
+
return true;
|
|
48
|
+
lastSweep.set(key, now);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function removeStale(entries, inUse, now, isKind) {
|
|
49
52
|
const removed = [];
|
|
50
|
-
for (const
|
|
51
|
-
if (inUse.has(
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
if (inUse.has(entry) || !isStale(entry, now, isKind))
|
|
52
55
|
continue;
|
|
53
56
|
try {
|
|
54
|
-
fs.rmSync(
|
|
55
|
-
removed.push(
|
|
57
|
+
fs.rmSync(entry, { recursive: true, force: true });
|
|
58
|
+
removed.push(entry);
|
|
56
59
|
}
|
|
57
60
|
catch (error) {
|
|
58
|
-
log.warn(`Could not remove stale plugin runtime
|
|
61
|
+
log.warn(`Could not remove stale plugin runtime entry ${entry}: ${error.message}`);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
64
|
+
return removed;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Remove projections and skill snapshots under `backendDir` that the current spawn does not use and
|
|
68
|
+
* that nothing has touched for {@link STALE_AFTER_MS}. Every one is content-addressed, so a removed
|
|
69
|
+
* directory a later spawn still wants is rebuilt at the same path. Returns what was removed.
|
|
70
|
+
*/
|
|
71
|
+
export function sweepStaleRuntimeDirs(backendDir, inUse, now = Date.now()) {
|
|
72
|
+
if (throttled(backendDir, now))
|
|
73
|
+
return [];
|
|
74
|
+
const entries = [
|
|
75
|
+
...ownedChildren(backendDir, OWNED_NAME),
|
|
76
|
+
...ownedChildren(path.join(backendDir, 'skill-snapshots'), OWNED_NAME),
|
|
77
|
+
];
|
|
78
|
+
const removed = removeStale(entries, inUse, now, (stat) => stat.isDirectory());
|
|
61
79
|
if (removed.length > 0)
|
|
62
80
|
log.info(`Removed ${removed.length} stale plugin runtime dir(s) under ${backendDir}`);
|
|
63
81
|
return removed;
|
|
64
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove Claude MCP and remote-proxy configs under `runtimeDir` that nothing has touched for
|
|
85
|
+
* {@link STALE_AFTER_MS}. Every Claude spawn and every pooled-session reuse check rewrites or touches
|
|
86
|
+
* the files it resolves, and an idle Claude process exits within the hour, so a file this old is
|
|
87
|
+
* used by no running process. A later spawn that wants it writes it again at the same path.
|
|
88
|
+
*/
|
|
89
|
+
export function sweepStaleClaudeMcpFiles(runtimeDir, now = Date.now()) {
|
|
90
|
+
if (throttled(path.join(runtimeDir, CLAUDE_MCP_DIRS[0]), now))
|
|
91
|
+
return [];
|
|
92
|
+
const entries = CLAUDE_MCP_DIRS.flatMap((dir) => ownedChildren(path.join(runtimeDir, dir), OWNED_MCP_FILE));
|
|
93
|
+
const removed = removeStale(entries, new Set(), now, (stat) => stat.isFile());
|
|
94
|
+
if (removed.length > 0)
|
|
95
|
+
log.info(`Removed ${removed.length} stale Claude MCP config(s) under ${runtimeDir}`);
|
|
96
|
+
return removed;
|
|
97
|
+
}
|
|
65
98
|
/** Test hook: forget the per-directory sweep throttle. */
|
|
66
99
|
export function _resetSweepThrottle() {
|
|
67
100
|
lastSweep.clear();
|
|
@@ -9,7 +9,7 @@ import { loadPluginCatalog } from './catalog.js';
|
|
|
9
9
|
import { defaultBuiltinPluginsDir, listBuiltinPluginIds } from './builtin.js';
|
|
10
10
|
import { pluginMcpRuntime, portableNamespace, skillRoot, } from './catalog-types.js';
|
|
11
11
|
import { listImmediateChildNames, realPath } from './fs-helpers.js';
|
|
12
|
-
import { markInUse, sweepStaleRuntimeDirs } from './runtime-gc.js';
|
|
12
|
+
import { markInUse, sweepStaleClaudeMcpFiles, sweepStaleRuntimeDirs } from './runtime-gc.js';
|
|
13
13
|
import { safeClaudeManifestVersion, safeNativeComposite } from '../../core/native-name.js';
|
|
14
14
|
import { buildProjectedSkillTree, copyProjectedSkillTree, validateProjectedSkillTree, } from './skill-projection.js';
|
|
15
15
|
const log = createLogger('plugin-runtime');
|
|
@@ -546,6 +546,7 @@ export function resolvePluginRuntime(options) {
|
|
|
546
546
|
const portable = collectPortableDetails(classified.portableSelections, options.backend, runtimeDir, portableMcpEnabled(options.mcpComposition));
|
|
547
547
|
warnLegacySkillCollisions(portable.skillClaims, classified.selectedLegacySkills);
|
|
548
548
|
sweepStaleRuntimeDirs(path.join(runtimeDir, options.backend), directoriesInUse(portable.details));
|
|
549
|
+
sweepStaleClaudeMcpFiles(runtimeDir);
|
|
549
550
|
const resolved = resolvedRuntime(options.backend, classified.items, portable.details);
|
|
550
551
|
return withWarnings(resolved, [...classified.warnings, ...portable.warnings]);
|
|
551
552
|
}
|
|
@@ -22,7 +22,7 @@ if (!serverHost) {
|
|
|
22
22
|
}
|
|
23
23
|
const serverPort = getArg('--server-port') || '3002';
|
|
24
24
|
if (!sshHost) {
|
|
25
|
-
log.error(`Usage: node --import tsx src/client-bootstrap.ts --host user@host --device-name NAME [options]
|
|
25
|
+
log.error(`Usage (from agent-server/): node --import tsx src/domain/remote/client-bootstrap.ts --host user@host --device-name NAME [options]
|
|
26
26
|
|
|
27
27
|
Options:
|
|
28
28
|
--host <user@host> SSH target (required)
|
|
@@ -5,6 +5,7 @@ import { AUTH_HEADER, getClientToken, timingSafeEqualStr } from '../../core/auth
|
|
|
5
5
|
import { createLogger } from '../../core/log.js';
|
|
6
6
|
import { claimStream, parseStreamId, cancelStreamsFor } from './reverse-stream.js';
|
|
7
7
|
import { emitCortexEvent } from '../../core/hook-bus.js';
|
|
8
|
+
import { recordRemoteClientConnected, recordRemoteClientDisconnected } from '../telemetry/usage.js';
|
|
8
9
|
const log = createLogger('client-manager');
|
|
9
10
|
let updateHooks = null;
|
|
10
11
|
function setClientUpdateHooks(hooks) { updateHooks = hooks; }
|
|
@@ -16,10 +17,13 @@ const pendingCommands = new Map();
|
|
|
16
17
|
let wss = null;
|
|
17
18
|
let heartbeatCheckInterval = null;
|
|
18
19
|
let clientManagerPort = null;
|
|
20
|
+
const SHUTDOWN_REASON = 'Server shutting down';
|
|
19
21
|
const HEARTBEAT_TIMEOUT_MS = 15_000; // 3 missed 5s heartbeats
|
|
20
22
|
const DEFAULT_COMMAND_TIMEOUT_MS = 120_000; // 2 min for bash
|
|
21
23
|
const FILE_COMMAND_TIMEOUT_MS = 30_000; // 30s for file operations
|
|
22
24
|
function emitDisconnected(device, reason) {
|
|
25
|
+
if (reason !== SHUTDOWN_REASON)
|
|
26
|
+
recordRemoteClientDisconnected();
|
|
23
27
|
const payload = reason ? { device, reason } : { device };
|
|
24
28
|
void emitCortexEvent('cortex:client.disconnected', payload).catch(() => { });
|
|
25
29
|
}
|
|
@@ -94,6 +98,7 @@ function registerHelloDevice(ws, msg, remoteAddress) {
|
|
|
94
98
|
connectedAt: new Date(), lastHeartbeat: new Date(), bundleHash, ws,
|
|
95
99
|
});
|
|
96
100
|
log.info(`Device connected: ${device} (${platform})`);
|
|
101
|
+
recordRemoteClientConnected();
|
|
97
102
|
void emitCortexEvent('cortex:client.connected', { device }).catch(() => { });
|
|
98
103
|
applyReportedGpuCount(device, typeof msg.gpuCount === 'number' ? msg.gpuCount : null);
|
|
99
104
|
try {
|
|
@@ -247,7 +252,7 @@ async function stopClientManager() {
|
|
|
247
252
|
info.ws.close(1001, 'Server shutting down');
|
|
248
253
|
}
|
|
249
254
|
catch { }
|
|
250
|
-
emitDisconnected(info.device,
|
|
255
|
+
emitDisconnected(info.device, SHUTDOWN_REASON);
|
|
251
256
|
}
|
|
252
257
|
devices.clear();
|
|
253
258
|
const server = wss;
|
|
@@ -13,7 +13,7 @@ const log = createLogger('device-browser');
|
|
|
13
13
|
* channel maps it onto a loopback port here.
|
|
14
14
|
*/
|
|
15
15
|
/** Chrome's own startup, plus the device round trip. Generous: a cold Chrome on a busy laptop is
|
|
16
|
-
* slow, and the alternative to waiting is a
|
|
16
|
+
* slow, and the alternative to waiting is a failed `cortex-browser` call. */
|
|
17
17
|
const LAUNCH_TIMEOUT_MS = 90_000;
|
|
18
18
|
/** One HTTP GET through the tunnel. If this is slow, the tunnel is broken, not the browser. */
|
|
19
19
|
const VERIFY_TIMEOUT_MS = 5_000;
|
|
@@ -82,6 +82,8 @@ function unixChromeLaunchCommand(platform) {
|
|
|
82
82
|
'[ -n "$CHROME" ] || { echo "chrome-not-found" >&2; exit 3; }',
|
|
83
83
|
'nohup "$CHROME" --remote-debugging-port=0 --remote-debugging-address=127.0.0.1'
|
|
84
84
|
+ ' --user-data-dir="$PROFILE" --no-first-run --no-default-browser-check'
|
|
85
|
+
// Linux only (macOS ignores it): skip the keyring D-Bus probe that stalls the first page ~25s.
|
|
86
|
+
+ ' --password-store=basic'
|
|
85
87
|
+ ' about:blank >/dev/null 2>&1 &',
|
|
86
88
|
'for _ in $(seq 1 60); do [ -s "$PORTFILE" ] && break; sleep 0.5; done',
|
|
87
89
|
'[ -s "$PORTFILE" ] || { echo "chrome-did-not-listen" >&2; exit 4; }', 'head -1 "$PORTFILE"',
|
|
@@ -4,8 +4,8 @@ import { requestStream } from './reverse-stream.js';
|
|
|
4
4
|
import { sendControlMessage } from './client-manager.js';
|
|
5
5
|
const log = createLogger('device-port');
|
|
6
6
|
/**
|
|
7
|
-
* Why a real local socket at all (plan/embedded-browser.md §18.1): the consumer is
|
|
8
|
-
* which takes a `--cdp
|
|
7
|
+
* Why a real local socket at all (plan/embedded-browser.md §18.1): the consumer is agent-browser,
|
|
8
|
+
* which takes a `--cdp` URL, does `GET /json/version`, then opens a WebSocket. It needs
|
|
9
9
|
* something it can dial. So the server binds a loopback port and every byte written to it comes
|
|
10
10
|
* out of a TCP connection on the device — no CDP awareness anywhere in the path, which is what
|
|
11
11
|
* makes the same tunnel serve TensorBoard, Jupyter and dashboards for free.
|
|
@@ -3,13 +3,13 @@ import type { Backend, EngineRun, EngineSession, EngineSpec } from '../../agent-
|
|
|
3
3
|
import type { RunEvent } from '../../agent-adapter/run-events.js';
|
|
4
4
|
import type { EventObserver } from '../../agent-adapter/normalize/event-types.js';
|
|
5
5
|
import type { ModeEnv } from './mode-env.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
7
7
|
import type { RunRequest } from './request.js';
|
|
8
8
|
import { type ProductionAttemptIdentityRecord } from '../benchmark/production-attempt-identity.js';
|
|
9
9
|
export interface StartAttemptInput {
|
|
10
10
|
request: RunRequest;
|
|
11
|
-
/**
|
|
12
|
-
attempt:
|
|
11
|
+
/** The engine selection this run executes. */
|
|
12
|
+
attempt: EngineSelection;
|
|
13
13
|
/** The execution record the attempt is billed and attested under. */
|
|
14
14
|
executionId: string | null;
|
|
15
15
|
/** The resolved mode route (base URL + credentials) for this attempt. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// A run
|
|
3
|
-
// THIS is one link of that chain: acquire the pooled engine session for the spec, open a run on it,
|
|
2
|
+
// A run opens one attempt: acquire the pooled engine session for the selection, open a run on it,
|
|
4
3
|
// and hand back the stream plus the two results a caller can await. Everything downstream of
|
|
5
4
|
// `engine.run()` — the background phase, the watchdog, when the run is really over — belongs to the
|
|
6
5
|
// engine, so this module is wiring plus the two things that must happen per attempt and nowhere
|
|
@@ -158,7 +157,7 @@ export function startAttempt(input) {
|
|
|
158
157
|
const spec = buildEngineSpec(request, attempt, { route, executionId });
|
|
159
158
|
const identity = freezeProductionAttemptIdentity({
|
|
160
159
|
adapterBackend: attempt.backend, spec, request, executionId,
|
|
161
|
-
|
|
160
|
+
selection: request.selection,
|
|
162
161
|
});
|
|
163
162
|
const journal = identity
|
|
164
163
|
? createProductionAttemptJournalSink({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
2
2
|
import type { RunRequest } from './request.js';
|
|
3
3
|
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
4
|
-
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on,
|
|
5
|
-
* direct MCP surface
|
|
4
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, and
|
|
5
|
+
* the direct MCP surface.
|
|
6
6
|
*
|
|
7
7
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
8
8
|
* to, `captureTranscriptLogs` defaults to ON, and only a frozen subagent child opts out.
|
|
@@ -14,7 +14,7 @@ export interface ContinuationRunOptions {
|
|
|
14
14
|
/** Ids the caller already resolved: the Cortex track id, the backend resume target, the engine
|
|
15
15
|
* pool key and the display name. */
|
|
16
16
|
session: RunRequest['session'];
|
|
17
|
-
|
|
17
|
+
selection: EngineSelection;
|
|
18
18
|
/** Prompt text; continuation runs never carry attachments. */
|
|
19
19
|
prompt: string;
|
|
20
20
|
channel: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A continuation run forwards one prompt into a session whose live engine it does not share: the
|
|
2
2
|
// onNew hook's pre-close turn, which resumes the old session on its own isolated pool key. It runs
|
|
3
3
|
// on a bare spec (`bareSpec()` — no agent identity), the direct-run policy and a machine-driven
|
|
4
|
-
// context; only the session ids, the
|
|
4
|
+
// context; only the session ids, the selection and the trigger differ.
|
|
5
5
|
//
|
|
6
6
|
// A turn on a session's LIVE engine must not use it: the pool compares the spec identity and would
|
|
7
7
|
// respawn the process. Those turns build their request the way a user turn does
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
10
|
import { bareSpec } from './spec-loader.js';
|
|
11
11
|
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
12
|
-
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on,
|
|
13
|
-
* direct MCP surface
|
|
12
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, and
|
|
13
|
+
* the direct MCP surface.
|
|
14
14
|
*
|
|
15
15
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
16
16
|
* to, `captureTranscriptLogs` defaults to ON, and only a frozen subagent child opts out.
|
|
@@ -23,7 +23,6 @@ export const DIRECT_RUN_POLICY = {
|
|
|
23
23
|
hooks: true,
|
|
24
24
|
loadRules: true,
|
|
25
25
|
mcpComposition: 'direct',
|
|
26
|
-
browserCdpEndpoint: null,
|
|
27
26
|
captureTranscripts: true,
|
|
28
27
|
};
|
|
29
28
|
/** Build the `RunRequest` for a continuation run. Every field not named in `o` is the shared
|
|
@@ -32,7 +31,7 @@ export function continuationRunRequest(o) {
|
|
|
32
31
|
return {
|
|
33
32
|
runId: randomUUID(),
|
|
34
33
|
session: o.session,
|
|
35
|
-
|
|
34
|
+
selection: o.selection,
|
|
36
35
|
spec: bareSpec(),
|
|
37
36
|
prompt: { text: o.prompt, attachments: [] },
|
|
38
37
|
context: {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import type { Backend, EngineSession, EngineSpec } from '../../agent-adapter/types.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Backend, EngineSession, EngineSpec, AgentCompactResult } from '../../agent-adapter/types.js';
|
|
2
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
3
3
|
import type { ModeEnv } from './mode-env.js';
|
|
4
|
-
import { type ResolvedProfileConfig, type RunAttemptConfig } from '../agents/profile-manager.js';
|
|
5
4
|
import type { RunRequest } from './request.js';
|
|
6
|
-
/** What compaction runs against. */
|
|
7
5
|
export interface CompactAgentTarget {
|
|
8
|
-
/** The request the session's next turn would run under, prompt aside. The pool hands back the
|
|
9
|
-
* session's live engine only for a request that asks for it exactly. */
|
|
10
6
|
request: RunRequest;
|
|
11
|
-
/** The session's backend; a profile that would run another one is refused. */
|
|
12
7
|
backend: Backend;
|
|
13
8
|
}
|
|
14
9
|
interface CompactCostEntry {
|
|
@@ -24,20 +19,12 @@ interface CompactCostEntry {
|
|
|
24
19
|
model?: string;
|
|
25
20
|
}
|
|
26
21
|
export interface CompactAgentDeps {
|
|
27
|
-
/** The pooled session for the spec. Compaction runs on it and leaves it pooled — it is the same
|
|
28
|
-
* session the channel's next turn will resume into, not a throwaway process. */
|
|
29
22
|
acquireEngine: (spec: EngineSpec) => EngineSession;
|
|
30
|
-
|
|
31
|
-
isPooled: (spec: EngineSpec) => boolean;
|
|
32
|
-
/** The route the run would open this attempt of the request under. */
|
|
33
|
-
route: (request: RunRequest, attempt: RunAttemptConfig) => ModeEnv;
|
|
23
|
+
route: (request: RunRequest, selection: EngineSelection) => ModeEnv;
|
|
34
24
|
recordCost: (entry: CompactCostEntry) => Promise<void>;
|
|
35
25
|
}
|
|
36
|
-
/** The cheap gate a surface asks before offering compaction, on the profile the registry recorded.
|
|
37
|
-
* `compactAgentContext` checks the profile the session's turns actually resolve to. */
|
|
38
26
|
export declare function isSessionCompactionSupported(session: {
|
|
39
27
|
backend: string;
|
|
40
|
-
|
|
41
|
-
}, resolve?: (profileName: string | null) => ResolvedProfileConfig): boolean;
|
|
28
|
+
}): boolean;
|
|
42
29
|
export declare function compactAgentContext(target: CompactAgentTarget, deps?: CompactAgentDeps): Promise<AgentCompactResult>;
|
|
43
30
|
export {};
|