@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
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { formatError, formatHelp } from '../core/cli-utils.js';
|
|
5
|
+
import { AUTH_HEADER } from '../core/auth.js';
|
|
6
|
+
import { isMainModule } from '../core/utils.js';
|
|
7
|
+
import { agentBrowserArgs, agentBrowserBaseEnv, agentBrowserCallEnv, isTabGone, resolveAgentBrowserBin, AgentBrowserMissingError, } from '../platform/browser/agent-browser.js';
|
|
8
|
+
/**
|
|
9
|
+
* `cortex-browser`: agent-browser, attached to the Chrome Cortex manages for this session.
|
|
10
|
+
*
|
|
11
|
+
* Each call leases the session's browser from the daemon (starting Chrome if needed), then runs
|
|
12
|
+
* agent-browser here so its output streams straight back. Every failure is an error with a reason;
|
|
13
|
+
* nothing quietly falls back to a different browser.
|
|
14
|
+
*/
|
|
15
|
+
const HELP = {
|
|
16
|
+
name: 'cortex-browser',
|
|
17
|
+
description: [
|
|
18
|
+
"Drive a real browser from any Cortex session: agent-browser, attached to the session's own tab",
|
|
19
|
+
"in the Chrome Cortex manages on the server or on one of your devices.",
|
|
20
|
+
'',
|
|
21
|
+
'Every argument except --device is passed to agent-browser. Full command guide:',
|
|
22
|
+
' cortex-browser skills get core',
|
|
23
|
+
].join('\n'),
|
|
24
|
+
usage: 'cortex-browser [--device <name>] <agent-browser command> [args...]',
|
|
25
|
+
options: [
|
|
26
|
+
{ flag: '--device <name>', description: "Whose Chrome: 'server' or a connected device. Sticks for the session", default: "the session's last device, else server" },
|
|
27
|
+
{ flag: '--help, -h', description: 'Show this help (agent-browser <command> --help for one command)' },
|
|
28
|
+
],
|
|
29
|
+
examples: [
|
|
30
|
+
{ description: 'Open a page and list what can be clicked', command: 'cortex-browser open http://127.0.0.1:5173 && cortex-browser snapshot -i' },
|
|
31
|
+
{ description: 'Click a ref from the snapshot, then capture the result', command: 'cortex-browser click @e2 && cortex-browser screenshot ./after-click.png' },
|
|
32
|
+
{ description: "Use the Chrome on the user's machine (its localhost, its logins)", command: 'cortex-browser --device my-pc open https://example.com' },
|
|
33
|
+
{ description: 'Read the version-matched command reference', command: 'cortex-browser skills get core --full' },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
/** Flags that would point agent-browser at a different browser, daemon or tab than the lease. */
|
|
37
|
+
const RESERVED_FLAGS = new Set([
|
|
38
|
+
'--cdp', '--session', '--no-pin-tab', '--auto-connect', '--provider', '-p', '--namespace', '--engine',
|
|
39
|
+
'--executable-path',
|
|
40
|
+
]);
|
|
41
|
+
/** Commands that need no browser and so no lease. */
|
|
42
|
+
const LOCAL_COMMANDS = new Set(['skills', 'help']);
|
|
43
|
+
/** Commands that would change the shared setup underneath every session. */
|
|
44
|
+
const BLOCKED_COMMANDS = {
|
|
45
|
+
connect: 'cortex-browser already connects each call to the session browser',
|
|
46
|
+
install: 'Chrome is managed by Cortex; agent-browser does not install its own',
|
|
47
|
+
upgrade: 'agent-browser is pinned to the version Cortex ships with',
|
|
48
|
+
dashboard: "watch the browser in the Cortex app's Agent browser tab instead",
|
|
49
|
+
mcp: 'call cortex-browser commands directly',
|
|
50
|
+
};
|
|
51
|
+
/** Global agent-browser flags that take a value, so the value is not mistaken for the command. */
|
|
52
|
+
const VALUE_FLAGS = new Set([
|
|
53
|
+
'--session', '--namespace', '--executable-path', '--extension', '--init-script', '--enable', '--args',
|
|
54
|
+
'--user-agent', '--proxy', '--proxy-bypass', '--ca-cert', '--hide-scrollbars', '--provider', '-p',
|
|
55
|
+
'--screenshot-dir', '--screenshot-quality', '--screenshot-format', '--input-mode', '--cdp',
|
|
56
|
+
'--color-scheme', '--download-path', '--max-output', '--allowed-domains', '--action-policy',
|
|
57
|
+
'--confirm-actions', '--idle-timeout', '--engine', '--model', '--config', '--profile',
|
|
58
|
+
'--restore-save', '--restore-check-url', '--restore-check-text', '--restore-check-fn', '--session-name',
|
|
59
|
+
'--state', '--headers', '--threshold', '--baseline', '-d', '--depth', '-s', '--selector',
|
|
60
|
+
]);
|
|
61
|
+
/** Flags whose value is a directory or file wherever they appear. */
|
|
62
|
+
const PATH_FLAGS = new Set(['--screenshot-dir', '--download-path', '--baseline']);
|
|
63
|
+
/**
|
|
64
|
+
* Commands that write or read local files, and how many leading positionals are not files
|
|
65
|
+
* (`download <selector> <path>`). The daemon resolves a relative path against ITS working
|
|
66
|
+
* directory, not the caller's, so these are made absolute before they leave this process.
|
|
67
|
+
*/
|
|
68
|
+
const FILE_COMMANDS = {
|
|
69
|
+
screenshot: 0, pdf: 0, download: 1, upload: 1, record: 0, trace: 0, profiler: 0, network: 0, har: 0,
|
|
70
|
+
state: 0, diff: 0,
|
|
71
|
+
};
|
|
72
|
+
const FILE_EXTENSIONS = /\.(png|jpe?g|webp|gif|pdf|webm|mp4|json|har|zip|txt|html?|csv|xml|md|log|cpuprofile)$/i;
|
|
73
|
+
export class BrowserUsageError extends Error {
|
|
74
|
+
}
|
|
75
|
+
/** The first token that is neither a flag nor a flag's value, with its index. */
|
|
76
|
+
function findCommand(args) {
|
|
77
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
78
|
+
const token = args[i];
|
|
79
|
+
if (token.startsWith('-')) {
|
|
80
|
+
if (VALUE_FLAGS.has(token))
|
|
81
|
+
i += 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
return { command: token, index: i };
|
|
85
|
+
}
|
|
86
|
+
return { command: null, index: -1 };
|
|
87
|
+
}
|
|
88
|
+
export function parseBrowserArgs(argv) {
|
|
89
|
+
let device = null;
|
|
90
|
+
const args = [];
|
|
91
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
92
|
+
const token = argv[i];
|
|
93
|
+
if (token === '--device' || token.startsWith('--device=')) {
|
|
94
|
+
const value = token === '--device' ? argv[i + 1] : token.slice('--device='.length);
|
|
95
|
+
if (!value || value.startsWith('-')) {
|
|
96
|
+
throw new BrowserUsageError(formatError('--device requires a device name', {
|
|
97
|
+
hint: "use 'server' for this machine, or a connected device name (cortex-browser --device my-pc open …)",
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
device = value;
|
|
101
|
+
if (token === '--device')
|
|
102
|
+
i += 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const flag = token.split('=')[0];
|
|
106
|
+
if (RESERVED_FLAGS.has(flag)) {
|
|
107
|
+
throw new BrowserUsageError(formatError(`${flag} is set by cortex-browser and cannot be passed`, {
|
|
108
|
+
hint: 'cortex-browser attaches every call to this session\'s own tab; use --device to pick whose Chrome',
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
if (token === '--pin-tab')
|
|
112
|
+
continue; // always on
|
|
113
|
+
args.push(token);
|
|
114
|
+
}
|
|
115
|
+
const { command } = findCommand(args);
|
|
116
|
+
// No command at all (`cortex-browser`, `cortex-browser --device x`) shows this help rather than
|
|
117
|
+
// leasing a browser just to print agent-browser's.
|
|
118
|
+
const help = command === null && !args.some((a) => a === '--version' || a === '-V');
|
|
119
|
+
if (command && Object.hasOwn(BLOCKED_COMMANDS, command)) {
|
|
120
|
+
throw new BrowserUsageError(formatError(`'${command}' is not available through cortex-browser`, {
|
|
121
|
+
hint: BLOCKED_COMMANDS[command],
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
if (command === 'close' && args.includes('--all')) {
|
|
125
|
+
throw new BrowserUsageError(formatError("'close --all' would disconnect every other session's browser", {
|
|
126
|
+
hint: "use 'cortex-browser close' to close only this session's connection",
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
return { help, device, args, command };
|
|
130
|
+
}
|
|
131
|
+
/** Does this command run without a browser (help, version, bundled skills)? */
|
|
132
|
+
export function isLocalCommand(parsed) {
|
|
133
|
+
if (parsed.command && LOCAL_COMMANDS.has(parsed.command))
|
|
134
|
+
return true;
|
|
135
|
+
if (parsed.args.some((a) => a === '--help' || a === '-h'))
|
|
136
|
+
return true;
|
|
137
|
+
return parsed.command === null && parsed.args.some((a) => a === '--version' || a === '-V');
|
|
138
|
+
}
|
|
139
|
+
function looksLikePath(token) {
|
|
140
|
+
if (!token || token.startsWith('-') || token.startsWith('@') || token.includes('://'))
|
|
141
|
+
return false;
|
|
142
|
+
if (/[*?{}[\]]/.test(token))
|
|
143
|
+
return false; // a URL pattern (`network route "*.png"`), not a file
|
|
144
|
+
if (path.isAbsolute(token))
|
|
145
|
+
return false;
|
|
146
|
+
return token.startsWith('./') || token.startsWith('../') || FILE_EXTENSIONS.test(token);
|
|
147
|
+
}
|
|
148
|
+
/** Make the file arguments of file-writing commands absolute against the caller's directory. */
|
|
149
|
+
export function absolutizePaths(args, cwd) {
|
|
150
|
+
const out = [...args];
|
|
151
|
+
for (let i = 0; i < out.length - 1; i += 1) {
|
|
152
|
+
if (PATH_FLAGS.has(out[i]) && !path.isAbsolute(out[i + 1]) && !out[i + 1].startsWith('-')) {
|
|
153
|
+
out[i + 1] = path.resolve(cwd, out[i + 1]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const { command, index } = findCommand(out);
|
|
157
|
+
if (!command || !Object.hasOwn(FILE_COMMANDS, command))
|
|
158
|
+
return out;
|
|
159
|
+
let skip = FILE_COMMANDS[command];
|
|
160
|
+
for (let i = index + 1; i < out.length; i += 1) {
|
|
161
|
+
const token = out[i];
|
|
162
|
+
if (token.startsWith('-')) {
|
|
163
|
+
if (VALUE_FLAGS.has(token))
|
|
164
|
+
i += 1;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (skip > 0) {
|
|
168
|
+
skip -= 1;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (looksLikePath(token))
|
|
172
|
+
out[i] = path.resolve(cwd, token);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
async function httpPost(url, body, headers) {
|
|
177
|
+
const response = await fetch(url, {
|
|
178
|
+
method: 'POST',
|
|
179
|
+
headers: { 'content-type': 'application/json', ...headers },
|
|
180
|
+
body: JSON.stringify(body),
|
|
181
|
+
// A device's first Chrome launch can take the device's own 90s budget plus the round trip.
|
|
182
|
+
signal: AbortSignal.timeout(180_000),
|
|
183
|
+
});
|
|
184
|
+
const text = await response.text();
|
|
185
|
+
let parsed = text;
|
|
186
|
+
try {
|
|
187
|
+
parsed = JSON.parse(text);
|
|
188
|
+
}
|
|
189
|
+
catch { /* non-JSON bodies surface as text */ }
|
|
190
|
+
return { status: response.status, body: parsed };
|
|
191
|
+
}
|
|
192
|
+
/** stdout passes straight through; stderr is held so a recoverable tab_gone can be retried
|
|
193
|
+
* without showing the agent an error that was already handled. */
|
|
194
|
+
function spawnExec(bin, args, env, cwd, quiet = false) {
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
let stderr = '';
|
|
197
|
+
const child = spawn(bin, args, { env, cwd, stdio: [quiet ? 'ignore' : 'inherit', quiet ? 'ignore' : 'inherit', 'pipe'] });
|
|
198
|
+
child.stderr?.on('data', (chunk) => { stderr += String(chunk); });
|
|
199
|
+
child.on('error', (e) => resolve({ code: 127, stderr: `${stderr}cortex-browser: cannot run ${bin}: ${e.message}\n` }));
|
|
200
|
+
child.on('close', (code, signal) => resolve({ code: code ?? (signal ? 128 : 1), stderr }));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
class BrowserCliError extends Error {
|
|
204
|
+
exitCode;
|
|
205
|
+
constructor(message, exitCode = 1) {
|
|
206
|
+
super(message);
|
|
207
|
+
this.exitCode = exitCode;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function lease(options, env, sessionId, device) {
|
|
211
|
+
const port = env.WEBHOOK_PORT || '3001';
|
|
212
|
+
const url = `http://127.0.0.1:${port}/webhook/browser`;
|
|
213
|
+
const notice = setTimeout(() => {
|
|
214
|
+
options.writeErr(`cortex-browser: starting the browser${device ? ` on ${device}` : ''}…\n`);
|
|
215
|
+
}, options.slowNoticeMs);
|
|
216
|
+
let response;
|
|
217
|
+
try {
|
|
218
|
+
response = await options.post(url, { action: 'lease', sessionId, device }, { [AUTH_HEADER]: env.CORTEX_WEBHOOK_TOKEN || '' });
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
throw new BrowserCliError(formatError(`cannot reach the Cortex daemon at 127.0.0.1:${port}: ${error.message}`, {
|
|
222
|
+
hint: 'cortex-browser works inside Cortex sessions while the Cortex server is running',
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
clearTimeout(notice);
|
|
227
|
+
}
|
|
228
|
+
if (response.status === 401) {
|
|
229
|
+
throw new BrowserCliError(formatError('the Cortex daemon rejected this call (bad or missing CORTEX_WEBHOOK_TOKEN)', {
|
|
230
|
+
hint: 'run cortex-browser from a Cortex session, which sets the token',
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
if (response.status === 404) {
|
|
234
|
+
throw new BrowserCliError(formatError('this Cortex server has no browser endpoint yet', {
|
|
235
|
+
hint: 'the server needs a restart onto the version that ships cortex-browser',
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
const body = response.body;
|
|
239
|
+
if (response.status !== 200 || !body?.success) {
|
|
240
|
+
const detail = typeof body === 'object' && body ? body.error : String(body ?? '');
|
|
241
|
+
throw new BrowserCliError(formatError(`browser unavailable: ${detail || `HTTP ${response.status}`}`, { hint: body?.hint }));
|
|
242
|
+
}
|
|
243
|
+
return body.data;
|
|
244
|
+
}
|
|
245
|
+
export async function runBrowserCli(argv, options = {}) {
|
|
246
|
+
const env = options.env ?? process.env;
|
|
247
|
+
const cwd = options.cwd ?? process.cwd();
|
|
248
|
+
const writeErr = options.writeErr ?? ((text) => { process.stderr.write(text); });
|
|
249
|
+
const exec = options.exec ?? spawnExec;
|
|
250
|
+
const post = options.post ?? httpPost;
|
|
251
|
+
let parsed;
|
|
252
|
+
try {
|
|
253
|
+
parsed = parseBrowserArgs(argv);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (error instanceof BrowserUsageError) {
|
|
257
|
+
writeErr(`${error.message}\n`);
|
|
258
|
+
return 2;
|
|
259
|
+
}
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
if (parsed.help) {
|
|
263
|
+
process.stdout.write(`${formatHelp(HELP)}\n`);
|
|
264
|
+
return 0;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
if (isLocalCommand(parsed)) {
|
|
268
|
+
const bin = resolveAgentBrowserBin(env);
|
|
269
|
+
const run = await exec(bin, parsed.args, agentBrowserBaseEnv(env), cwd);
|
|
270
|
+
if (run.stderr)
|
|
271
|
+
writeErr(run.stderr);
|
|
272
|
+
return run.code;
|
|
273
|
+
}
|
|
274
|
+
const sessionId = env.CORTEX_SESSION_ID || env.CORTEX_EXECUTION_ID || '';
|
|
275
|
+
if (!sessionId) {
|
|
276
|
+
writeErr(`${formatError('no Cortex session (CORTEX_SESSION_ID is unset)', {
|
|
277
|
+
hint: 'cortex-browser leases a browser per Cortex session; run it from a session\'s shell',
|
|
278
|
+
})}\n`);
|
|
279
|
+
return 2;
|
|
280
|
+
}
|
|
281
|
+
const data = await lease({ post, writeErr, slowNoticeMs: options.slowNoticeMs ?? 2_000 }, env, sessionId, parsed.device);
|
|
282
|
+
const callEnv = agentBrowserCallEnv(data.env, env);
|
|
283
|
+
const args = absolutizePaths(parsed.args, cwd);
|
|
284
|
+
let run = await exec(data.bin, agentBrowserArgs(data.cdpEndpoint, data.abSession, args), callEnv, cwd);
|
|
285
|
+
if (run.code !== 0 && isTabGone(run.stderr)) {
|
|
286
|
+
// The tab this session was bound to is gone (Chrome was restarted, or someone closed it).
|
|
287
|
+
// The command never ran, so binding a fresh tab and running it once more is safe.
|
|
288
|
+
const rebound = await exec(data.bin, agentBrowserArgs(data.cdpEndpoint, data.abSession, ['tab', 'new']), callEnv, cwd, true);
|
|
289
|
+
if (rebound.code === 0) {
|
|
290
|
+
writeErr('cortex-browser: this session\'s previous tab is gone (closed after 10 idle minutes, or the browser restarted); continuing in a new blank tab\n');
|
|
291
|
+
run = await exec(data.bin, agentBrowserArgs(data.cdpEndpoint, data.abSession, args), callEnv, cwd);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (run.stderr)
|
|
295
|
+
writeErr(run.stderr);
|
|
296
|
+
await post(`http://127.0.0.1:${env.WEBHOOK_PORT || '3001'}/webhook/browser`, { action: 'report', sessionId }, { [AUTH_HEADER]: env.CORTEX_WEBHOOK_TOKEN || '' }).catch(() => undefined);
|
|
297
|
+
return run.code;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
if (error instanceof BrowserCliError) {
|
|
301
|
+
writeErr(`${error.message}\n`);
|
|
302
|
+
return error.exitCode;
|
|
303
|
+
}
|
|
304
|
+
if (error instanceof AgentBrowserMissingError) {
|
|
305
|
+
writeErr(`${formatError(error.message, { hint: error.hint })}\n`);
|
|
306
|
+
return 1;
|
|
307
|
+
}
|
|
308
|
+
writeErr(`cortex-browser: ${error.message}\n`);
|
|
309
|
+
return 1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
313
|
+
process.exitCode = await runBrowserCli(argv);
|
|
314
|
+
}
|
|
315
|
+
if (isMainModule(import.meta.url)) {
|
|
316
|
+
void main();
|
|
317
|
+
}
|
package/dist/entry/cli-help.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare function getInitHelp(): string;
|
|
|
2
2
|
export declare function getSetupGatewayHelp(): string;
|
|
3
3
|
export declare function getTuiHelp(): string;
|
|
4
4
|
export declare function getUiHelp(): string;
|
|
5
|
+
export declare function getPathHelp(): string;
|
|
5
6
|
export declare function getClientHelp(): string;
|
|
6
7
|
export declare function getMemoryHelp(): string;
|
|
7
8
|
export declare function getScheduleHelp(): string;
|
package/dist/entry/cli-help.js
CHANGED
|
@@ -4,33 +4,44 @@ export function getInitHelp() {
|
|
|
4
4
|
return [
|
|
5
5
|
'Initialize Cortex data directory',
|
|
6
6
|
'',
|
|
7
|
-
'Usage: cortex init [--home <path>] [--gateway-config-dir <path>]',
|
|
7
|
+
'Usage: cortex init [--home <path>] [--gateway-config-dir <path>] [--force] [--answers <file>] [--json]',
|
|
8
8
|
'',
|
|
9
|
-
'Creates the CORTEX_HOME directory structure
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
9
|
+
'Creates the CORTEX_HOME directory structure and asks for the language, interaction',
|
|
10
|
+
'platform (Slack / Feishu), machine name, usage reporting and system service.',
|
|
11
|
+
'Writes .env, copies default configs and generates mcp-config*.json, machines.json',
|
|
12
|
+
'and agent-state.json. It then detects provider logins, offers to log in, and sets',
|
|
13
|
+
'up gateway routes, the default model and favorites.',
|
|
13
14
|
'',
|
|
14
15
|
'Options:',
|
|
15
|
-
' --home <path>
|
|
16
|
+
' --home <path> Set CORTEX_HOME (default: $CORTEX_HOME or ~/.cortex/)',
|
|
16
17
|
' --gateway-config-dir <path> Gateway config output directory (default: ~/.aistatus/)',
|
|
17
|
-
' --force
|
|
18
|
-
' --
|
|
18
|
+
' --force Overwrite existing configs (.env, budget.json, agent-state.json, etc.)',
|
|
19
|
+
' --answers <file> Read answers from a JSON file instead of prompting; omitted fields use defaults',
|
|
20
|
+
' --json Print NDJSON progress events on stdout and send human output to stderr',
|
|
21
|
+
' --help, -h Show this help',
|
|
22
|
+
'',
|
|
23
|
+
'With --answers or --json, init does not prompt or start provider login; it reports',
|
|
24
|
+
'credential status and can finish before any provider is set up.',
|
|
25
|
+
'',
|
|
26
|
+
'Examples:',
|
|
27
|
+
' cortex init',
|
|
28
|
+
' cortex init --home /data/cortex',
|
|
29
|
+
' cortex init --answers answers.json --json',
|
|
19
30
|
].join('\n');
|
|
20
31
|
}
|
|
21
32
|
export function getSetupGatewayHelp() {
|
|
22
33
|
return [
|
|
23
|
-
'Auto-detect Claude Code / PI configurations and generate gateway.yaml +
|
|
34
|
+
'Auto-detect Claude Code / PI configurations and generate gateway.yaml + models.json',
|
|
24
35
|
'',
|
|
25
36
|
'Usage: cortex setup-gateway [--dry-run] [--output-dir <path>]',
|
|
26
37
|
'',
|
|
27
38
|
'Discovers backend endpoints from local Claude Code and PI configs, then',
|
|
28
|
-
'writes ~/.aistatus/gateway.yaml (with backup) and $CORTEX_HOME/config/
|
|
39
|
+
'writes ~/.aistatus/gateway.yaml (with backup) and $CORTEX_HOME/config/models.json.',
|
|
29
40
|
'Without flags, this command writes files in place.',
|
|
30
41
|
'',
|
|
31
42
|
'Options:',
|
|
32
43
|
' --dry-run Print the generated gateway.yaml to stdout without writing anything',
|
|
33
|
-
' --output-dir <path> Write gateway.yaml and
|
|
44
|
+
' --output-dir <path> Write gateway.yaml and models.json under <path> instead of the defaults',
|
|
34
45
|
' --help, -h Show this help',
|
|
35
46
|
].join('\n');
|
|
36
47
|
}
|
|
@@ -53,21 +64,51 @@ export function getTuiHelp() {
|
|
|
53
64
|
export function getUiHelp() {
|
|
54
65
|
return formatHelp({
|
|
55
66
|
name: 'cortex ui',
|
|
56
|
-
description: 'Manage the
|
|
57
|
-
usage: 'cortex ui enable [--port <port>] [--home <path>] [--json]',
|
|
67
|
+
description: 'Manage the Web UI endpoint used by the Cortex apps and browsers',
|
|
68
|
+
usage: 'cortex ui <enable|pair> [--port <port>] [--home <path>] [--json]',
|
|
58
69
|
commands: [
|
|
59
70
|
{ name: 'enable', description: 'Turn on the loopback Web UI endpoint and print how to reach it' },
|
|
71
|
+
{ name: 'pair', description: 'Print a one-time pairing code (10 minutes) for a new app or browser' },
|
|
60
72
|
],
|
|
61
73
|
options: [
|
|
62
|
-
{ flag: '--port <port>', description: 'TCP port to serve the Web UI on', default: '3004' },
|
|
63
|
-
{ flag: '--home <path>', description: 'CORTEX_HOME to
|
|
64
|
-
{ flag: '--json', description: 'Print the endpoint, token
|
|
74
|
+
{ flag: '--port <port>', description: 'enable: TCP port to serve the Web UI on', default: 'the configured CORTEX_UI_PORT, else 3004' },
|
|
75
|
+
{ flag: '--home <path>', description: 'CORTEX_HOME to use', default: '$CORTEX_HOME or ~/.cortex' },
|
|
76
|
+
{ flag: '--json', description: 'Print the result as JSON (enable: endpoint, token, change state; pair: code, expiry)' },
|
|
65
77
|
{ flag: '--help, -h', description: 'Show this help' },
|
|
66
78
|
],
|
|
67
79
|
examples: [
|
|
68
|
-
{ description: 'Enable the endpoint
|
|
80
|
+
{ description: 'Enable the endpoint, keeping the configured port', command: 'cortex ui enable' },
|
|
69
81
|
{ description: 'Serve on another port', command: 'cortex ui enable --port 4000' },
|
|
70
82
|
{ description: 'Machine-readable output for the desktop setup flow', command: 'cortex ui enable --json' },
|
|
83
|
+
{ description: 'Get a code to connect a phone or another computer', command: 'cortex ui pair' },
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export function getPathHelp() {
|
|
88
|
+
return formatHelp({
|
|
89
|
+
name: 'cortex path',
|
|
90
|
+
description: 'Make this install\'s commands (cortex, cortex-signal, …) available in new terminals',
|
|
91
|
+
usage: 'cortex path <install|remove|status> [--home <path>] [--dry-run] [--json]',
|
|
92
|
+
commands: [
|
|
93
|
+
{
|
|
94
|
+
name: 'install',
|
|
95
|
+
description: 'Write launchers that use this install\'s Node into <home>/runtime/bin and put that '
|
|
96
|
+
+ 'directory on PATH (shell profiles on Linux/macOS, the user Path on Windows)',
|
|
97
|
+
},
|
|
98
|
+
{ name: 'remove', description: 'Delete the launchers and undo the PATH change' },
|
|
99
|
+
{ name: 'status', description: 'Show whether the launchers exist, are current, and are on PATH' },
|
|
100
|
+
],
|
|
101
|
+
options: [
|
|
102
|
+
{ flag: '--home <path>', description: 'CORTEX_HOME the launchers belong to', default: '$CORTEX_HOME or ~/.cortex' },
|
|
103
|
+
{ flag: '--dry-run', description: 'Report what install or remove would change and change nothing' },
|
|
104
|
+
{ flag: '--json', description: 'Print the result as JSON' },
|
|
105
|
+
{ flag: '--help, -h', description: 'Show this help' },
|
|
106
|
+
],
|
|
107
|
+
examples: [
|
|
108
|
+
{ description: 'Add cortex to new terminals', command: 'cortex path install' },
|
|
109
|
+
{ description: 'Preview the change', command: 'cortex path install --dry-run --json' },
|
|
110
|
+
{ description: 'Check the current state', command: 'cortex path status' },
|
|
111
|
+
{ description: 'Undo it', command: 'cortex path remove' },
|
|
71
112
|
],
|
|
72
113
|
});
|
|
73
114
|
}
|
|
@@ -130,7 +171,7 @@ export function getScheduleHelp() {
|
|
|
130
171
|
{ name: 'list', description: 'List schedules (--project to filter)' },
|
|
131
172
|
{ name: 'get <id>', description: 'Show one schedule' },
|
|
132
173
|
{ name: 'add --type <type>', description: 'Create a schedule' },
|
|
133
|
-
{ name: 'edit <id>', description: 'Change message, project,
|
|
174
|
+
{ name: 'edit <id>', description: 'Change message, project, model, thinking, pre-check or timing (the type is fixed)' },
|
|
134
175
|
{ name: 'pause <id>', description: 'Pause a recurring schedule' },
|
|
135
176
|
{ name: 'resume <id>', description: 'Resume a paused schedule' },
|
|
136
177
|
{ name: 'remove <id>', description: 'Delete a schedule (--dry-run to preview)' },
|
|
@@ -143,7 +184,8 @@ export function getScheduleHelp() {
|
|
|
143
184
|
{ flag: '--delay <duration>', description: 'once: fire this long from now, e.g. 90m, 2h' },
|
|
144
185
|
{ flag: '--message <text|->', description: 'Prompt for the fired session; "-" reads stdin' },
|
|
145
186
|
{ flag: '--project <id>', description: 'Project the fired session belongs to', default: 'general' },
|
|
146
|
-
{ flag: '--
|
|
187
|
+
{ flag: '--model [provider/]model', description: 'Model to run', default: 'the default model' },
|
|
188
|
+
{ flag: '--thinking <level>', description: 'Thinking level for the selected model' },
|
|
147
189
|
{ flag: '--pre-check <cmd>', description: 'Shell gate run before each fire; non-zero exit skips it' },
|
|
148
190
|
{ flag: '--idempotency-key <key>', description: 'add: return the schedule already created with this key' },
|
|
149
191
|
{ flag: '--dry-run', description: 'remove: show what would be removed' },
|
|
@@ -177,9 +219,10 @@ function getCliCommands() {
|
|
|
177
219
|
{ name: 'doctor', description: 'Health-check the install (runtime, login, platform, gateway); --fix to repair' },
|
|
178
220
|
{ name: 'auth status', description: t('cmd.auth.cli.statusDescription') },
|
|
179
221
|
{ name: 'feishu', description: 'Manage Feishu user-identity login (login / status / logout)' },
|
|
180
|
-
{ name: 'setup-gateway', description: 'Auto-detect Claude/PI configs and generate gateway.yaml +
|
|
222
|
+
{ name: 'setup-gateway', description: 'Auto-detect Claude/PI configs and generate gateway.yaml + models.json' },
|
|
181
223
|
{ name: 'ui enable', description: 'Enable the local Web UI endpoint the desktop app connects to' },
|
|
182
224
|
{ name: 'client remove', description: 'Unregister a remote machine and uninstall its cortex-client' },
|
|
225
|
+
{ name: 'path install', description: 'Make cortex available in new terminals (remove / status to undo or check)' },
|
|
183
226
|
{ name: 'schedule', description: 'List, add, edit, pause, resume and remove scheduled tasks' },
|
|
184
227
|
{ name: 'memory', description: 'Rebuild project memory indexes; report knowledge lifecycle findings' },
|
|
185
228
|
{ name: 'tui', description: 'Start the Terminal UI (TUI) client for local interaction' },
|
|
@@ -197,6 +240,7 @@ function getCliExamples() {
|
|
|
197
240
|
{ description: 'Re-generate gateway config', command: 'cortex setup-gateway' },
|
|
198
241
|
{ description: 'Enable the local Web UI endpoint', command: 'cortex ui enable' },
|
|
199
242
|
{ description: 'Remove a remote machine and its client', command: 'cortex client remove --device trainer' },
|
|
243
|
+
{ description: 'Add cortex to new terminals', command: 'cortex path install' },
|
|
200
244
|
{ description: 'List scheduled tasks', command: 'cortex schedule list' },
|
|
201
245
|
{ description: 'Rebuild every project memory index', command: 'cortex memory regen' },
|
|
202
246
|
{ description: 'Start the server', command: 'cortex start' },
|
package/dist/entry/cli.js
CHANGED
|
@@ -11,8 +11,8 @@ import { createLogger } from '../core/log.js';
|
|
|
11
11
|
import { getResolvedPaths, formatConfigOutput, runInit, parseInitAnswersJson, } from './init.js';
|
|
12
12
|
import { cmdFeishu } from './feishu-login.js';
|
|
13
13
|
import { cmdDoctor } from './doctor-cli.js';
|
|
14
|
-
import { discoverEndpoints, writeMergedGatewayYaml,
|
|
15
|
-
import {
|
|
14
|
+
import { discoverEndpoints, writeMergedGatewayYaml, validateModelsAgainstGateway, dryRunGatewayYaml } from '../core/gateway-generator.js';
|
|
15
|
+
import { readExistingModels, writeModelsJson } from '../core/models-generator.js';
|
|
16
16
|
import { CORTEX_VERSION } from '../core/version.js';
|
|
17
17
|
import { getAuthStatus } from '../domain/auth/auth-status.js';
|
|
18
18
|
import { defaultCustomProviderStores } from '../domain/pi-providers/index.js';
|
|
@@ -20,6 +20,7 @@ import { runAuthCli } from './auth-cli.js';
|
|
|
20
20
|
import { getCliHelp, getInitHelp, getSetupGatewayHelp, getTuiHelp, } from './cli-help.js';
|
|
21
21
|
import { runUiCli } from './ui-cli.js';
|
|
22
22
|
import { runClientCli } from './client-cli.js';
|
|
23
|
+
import { runPathCli } from './path-cli.js';
|
|
23
24
|
import { LoginCliError } from './auth-login-cli.js';
|
|
24
25
|
import { t } from '../core/i18n.js';
|
|
25
26
|
// ─── Paths ──────────────────────────────────────────────────────
|
|
@@ -355,37 +356,37 @@ function appendDroppedWarnings(lines, result) {
|
|
|
355
356
|
lines.push(`WARNING: preserved ${result.droppedFromDiscovery.length} existing gateway mode(s) not reported by discovery: ${list}`);
|
|
356
357
|
lines.push(' (if these should auto-detect, check `cortex auth status` and log the provider in)');
|
|
357
358
|
}
|
|
358
|
-
function
|
|
359
|
+
function appendModelIssues(lines, issues) {
|
|
359
360
|
if (issues.length === 0)
|
|
360
361
|
return;
|
|
361
|
-
lines.push(`WARNING: ${issues.length}
|
|
362
|
+
lines.push(`WARNING: ${issues.length} model selection(s) reference an unconfigured gateway route:`);
|
|
362
363
|
for (const issue of issues)
|
|
363
|
-
lines.push(` - ${issue.
|
|
364
|
+
lines.push(` - ${issue.model}: ${issue.reason}`);
|
|
364
365
|
}
|
|
365
|
-
function gatewayOutput(endpoints, outputDir, gatewayPath,
|
|
366
|
-
const
|
|
367
|
-
const
|
|
366
|
+
function gatewayOutput(endpoints, outputDir, gatewayPath, modelsPath, mergeResult) {
|
|
367
|
+
const models = readExistingModels(path.dirname(modelsPath));
|
|
368
|
+
const favorites = models.favorites.map(ref => ref.model).join(', ');
|
|
368
369
|
const lines = [
|
|
369
370
|
outputDir ? `[TEST MODE] Output directory: ${outputDir}` : '',
|
|
370
371
|
`Gateway config: ${gatewayPath}`,
|
|
371
|
-
`
|
|
372
|
+
`Models: ${modelsPath}`,
|
|
372
373
|
`Discovered ${endpoints.length} endpoint modes`,
|
|
373
|
-
`
|
|
374
|
+
`Favorites: ${favorites} (default: ${models.default.model})`,
|
|
374
375
|
];
|
|
375
376
|
appendDroppedWarnings(lines, mergeResult);
|
|
376
|
-
|
|
377
|
+
appendModelIssues(lines, validateModelsAgainstGateway(mergeResult.endpoints, outputDir));
|
|
377
378
|
return lines.filter(Boolean).join('\n');
|
|
378
379
|
}
|
|
379
380
|
async function writeGatewayConfiguration(outputDir) {
|
|
380
381
|
const endpoints = await discoverEndpoints();
|
|
381
|
-
if (endpoints.length
|
|
382
|
+
if (!endpoints.some(endpoint => endpoint.models.length > 0)) {
|
|
382
383
|
return { exitCode: 0, stdout: 'No backends discovered. Log into Claude Code and/or PI first.\n', stderr: '' };
|
|
383
384
|
}
|
|
384
385
|
const { path: gatewayPath, result } = writeMergedGatewayYaml(endpoints, outputDir);
|
|
385
|
-
const
|
|
386
|
+
const modelsPath = writeModelsJson(endpoints, { outputDir });
|
|
386
387
|
return {
|
|
387
388
|
exitCode: 0,
|
|
388
|
-
stdout: gatewayOutput(endpoints, outputDir, gatewayPath,
|
|
389
|
+
stdout: gatewayOutput(endpoints, outputDir, gatewayPath, modelsPath, result),
|
|
389
390
|
stderr: '',
|
|
390
391
|
};
|
|
391
392
|
}
|
|
@@ -448,6 +449,7 @@ const CLI_HANDLERS = {
|
|
|
448
449
|
'setup-gateway': (args) => runSetupGatewayCli(args),
|
|
449
450
|
ui: (args) => runUiCli(args),
|
|
450
451
|
client: (args) => runClientCli(args),
|
|
452
|
+
path: (args) => runPathCli(args),
|
|
451
453
|
install: (args) => runInstallCli(args),
|
|
452
454
|
schedule: async (args) => (await import('./schedule-cli.js')).runScheduleCli(args),
|
|
453
455
|
memory: async (args) => (await import('./memory-cli.js')).runMemoryCli(args),
|
package/dist/entry/daemon.d.ts
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
* rebuild pipeline; in production mode it just respawns app.js.
|
|
69
69
|
*/
|
|
70
70
|
import { type RebuildProgress, type RebuildStepName } from '../core/rebuild-progress.js';
|
|
71
|
-
export declare function buildChildProcessConfig(restartReason?: string | null): {
|
|
71
|
+
export declare function buildChildProcessConfig(restartReason?: string | null, childExit?: string | null): {
|
|
72
72
|
cwd: string;
|
|
73
73
|
windowsHide: boolean;
|
|
74
74
|
stdio: ("ignore" | "ipc" | "pipe")[];
|