@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
|
@@ -4294,20 +4294,25 @@ function getClientHelp() {
|
|
|
4294
4294
|
"",
|
|
4295
4295
|
"Usage: cortex-client",
|
|
4296
4296
|
"",
|
|
4297
|
-
"cortex-client is a daemon-style worker
|
|
4297
|
+
"cortex-client is a daemon-style worker that the agent-server starts.",
|
|
4298
|
+
"Configuration is read from",
|
|
4298
4299
|
` ${path5.join(CONFIG_DIR, "cortex-client.json")}`,
|
|
4299
|
-
"which the
|
|
4300
|
-
"
|
|
4300
|
+
"which is written by the server's bootstrap script (from agent-server/ in a",
|
|
4301
|
+
"source checkout: node --import tsx src/domain/remote/client-bootstrap.ts),",
|
|
4302
|
+
"by `cortex init` for a local desktop install, or by hand. There are no",
|
|
4303
|
+
"command-line flags beyond --help.",
|
|
4301
4304
|
"",
|
|
4302
4305
|
"Config schema (JSON):",
|
|
4303
4306
|
" {",
|
|
4304
4307
|
' "serverHost": "<agent-server host or LAN IP>",',
|
|
4305
4308
|
' "serverPort": 3002,',
|
|
4306
|
-
' "
|
|
4309
|
+
' "serverUrl": "<optional wss:// or ws:// URL; replaces serverHost/serverPort>",',
|
|
4310
|
+
' "deviceName": "<short device name>",',
|
|
4311
|
+
' "clientToken": "<server CORTEX_CLIENT_TOKEN; env CORTEX_CLIENT_TOKEN overrides>"',
|
|
4307
4312
|
" }",
|
|
4308
4313
|
"",
|
|
4309
4314
|
"Behavior:",
|
|
4310
|
-
" \u2022 Opens a WebSocket to ws://<serverHost>:<serverPort
|
|
4315
|
+
" \u2022 Opens a WebSocket to CORTEX_SERVER_URL, else serverUrl, else ws://<serverHost>:<serverPort>.",
|
|
4311
4316
|
" \u2022 Receives bash/read/write/edit/glob/grep commands.",
|
|
4312
4317
|
" \u2022 Exits if the server rejects the handshake (e.g. device already connected).",
|
|
4313
4318
|
" \u2022 Reconnects automatically on transient disconnects.",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026.
|
|
3
|
-
"hash": "
|
|
4
|
-
"source": "
|
|
2
|
+
"version": "2026.10.15",
|
|
3
|
+
"hash": "905214a46c7dbf67fc247e63168c0f687e4af7aed67df5c017317635139c3a8a",
|
|
4
|
+
"source": "d7f13e9b4fdb417bc24fd7cc06dac6c16118b33a"
|
|
5
5
|
}
|
|
@@ -83,3 +83,9 @@ export declare function claudeKeychainService(deps?: ClaudeCredentialDeps): stri
|
|
|
83
83
|
* shadow a live credential there.
|
|
84
84
|
*/
|
|
85
85
|
export declare function claudeOwnsOAuthCredential(deps?: ClaudeCredentialDeps): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Can a Claude spawn on this host authenticate at all? Any store counts, unlike
|
|
88
|
+
* resolveClaudeCredential: an expired login still refreshes inside Claude Code, a macOS keychain
|
|
89
|
+
* login is never readable here, and ANTHROPIC_AUTH_TOKEN reaches a child only through the env.
|
|
90
|
+
*/
|
|
91
|
+
export declare function hasClaudeCredential(deps?: ClaudeCredentialDeps): boolean;
|
|
@@ -229,3 +229,14 @@ export function claudeOwnsOAuthCredential(deps = {}) {
|
|
|
229
229
|
const probe = deps.probeKeychain ?? probeKeychainItem;
|
|
230
230
|
return probe(claudeKeychainService(deps));
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Can a Claude spawn on this host authenticate at all? Any store counts, unlike
|
|
234
|
+
* resolveClaudeCredential: an expired login still refreshes inside Claude Code, a macOS keychain
|
|
235
|
+
* login is never readable here, and ANTHROPIC_AUTH_TOKEN reaches a child only through the env.
|
|
236
|
+
*/
|
|
237
|
+
export function hasClaudeCredential(deps = {}) {
|
|
238
|
+
const env = deps.env ?? process.env;
|
|
239
|
+
if (credentialValue(env.ANTHROPIC_AUTH_TOKEN))
|
|
240
|
+
return true;
|
|
241
|
+
return resolveClaudeCredential(deps) !== null || claudeOwnsOAuthCredential(deps);
|
|
242
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Provider slug this reading is attributed to; matches the gateway route and
|
|
1
|
+
/** Provider slug this reading is attributed to; matches the gateway route and model provider. */
|
|
2
2
|
export declare const CODEX_PROVIDER = "openai-codex";
|
|
3
3
|
export interface QuotaWindow {
|
|
4
4
|
/** Codex limit family, preserving the provider's primary/secondary distinction. */
|
package/dist/core/codex-quota.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Provider slug this reading is attributed to; matches the gateway route and
|
|
1
|
+
/** Provider slug this reading is attributed to; matches the gateway route and model provider. */
|
|
2
2
|
export const CODEX_PROVIDER = 'openai-codex';
|
|
3
3
|
/** The two limit buckets Codex advertises per response. `secondary` is empty on plans without a
|
|
4
4
|
* short window (pro, 2026-08), so a bucket is only real when its window length is positive. */
|
|
@@ -23,13 +23,13 @@ export interface MergeGatewayResult {
|
|
|
23
23
|
}>;
|
|
24
24
|
}
|
|
25
25
|
export interface GatewayValidationIssue {
|
|
26
|
-
|
|
26
|
+
model: string;
|
|
27
27
|
mode: string;
|
|
28
28
|
provider?: string;
|
|
29
29
|
reason: string;
|
|
30
30
|
}
|
|
31
31
|
export interface DiscoveredEndpoint {
|
|
32
|
-
/** Mode key in gateway.yaml
|
|
32
|
+
/** Mode key in gateway.yaml (e.g. "plan", "deepseek", "openai-codex") */
|
|
33
33
|
mode: string;
|
|
34
34
|
/** Endpoint group name (e.g. "anthropic", "deepseek", "openai-codex") */
|
|
35
35
|
endpoint: string;
|
|
@@ -40,12 +40,29 @@ export interface DiscoveredEndpoint {
|
|
|
40
40
|
/** Model IDs known to be available for this endpoint */
|
|
41
41
|
models: string[];
|
|
42
42
|
/** Whether gateway.yaml should render an endpoint section for this entry. PI providers without a
|
|
43
|
-
* known upstream URL are surfaced as
|
|
43
|
+
* known upstream URL are surfaced as models but skipped in gateway.yaml. */
|
|
44
44
|
gatewayManaged: boolean;
|
|
45
45
|
/** The model this endpoint recommends when nothing is chosen — PI's per-provider default, or the
|
|
46
46
|
* newest Claude flagship. Always one of `models`; absent when the endpoint has no preference. */
|
|
47
47
|
defaultModel?: string;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Map a PI built-in provider name to its real upstream URL. Used by `generateGatewayYaml` so PI
|
|
51
|
+
* traffic can be routed through the gateway. Entries are sourced from PI source / docs.
|
|
52
|
+
*
|
|
53
|
+
* Providers absent from this table are still surfaced as models, but no gateway endpoint
|
|
54
|
+
* is generated for them (gatewayManaged=false). PI will then either fail (if the cortex spawn path
|
|
55
|
+
* forces gateway routing) or direct-call the upstream (if the spawn path leaves models.json
|
|
56
|
+
* untouched for that provider). Full provider plumbing remains future work.
|
|
57
|
+
*/
|
|
58
|
+
export declare const PI_PROVIDER_UPSTREAM: Record<string, {
|
|
59
|
+
url: string;
|
|
60
|
+
auth_style: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** Point every stored route still on a retired PI upstream at the current one; returns how many moved. */
|
|
63
|
+
export declare function refreshRetiredPiUpstreams(endpoints: EndpointMap): number;
|
|
64
|
+
/** Rewrite gateway.yaml (backing it up first) when a stored route is on a retired PI upstream. */
|
|
65
|
+
export declare function migrateRetiredPiUpstreams(configPath?: string): number;
|
|
49
66
|
export interface PiDiscoveredModel {
|
|
50
67
|
provider: string;
|
|
51
68
|
model: string;
|
|
@@ -77,12 +94,12 @@ export interface DiscoverEndpointsOptions {
|
|
|
77
94
|
* @param backends - Optional filter: when provided, only discover endpoints for the listed backends
|
|
78
95
|
* (e.g. `['claude']`, `['pi']`, `['claude', 'pi']`). When omitted, all backends are discovered.
|
|
79
96
|
*
|
|
80
|
-
* Claude endpoints come first, then PI providers in PI's order;
|
|
97
|
+
* Claude endpoints come first, then PI providers in PI's order; model recommendations follow that order.
|
|
81
98
|
* - Claude Code plan mode: only when Claude Code holds a subscription login.
|
|
82
99
|
* - Claude Code api mode: only when a real ANTHROPIC_API_KEY is available.
|
|
83
100
|
* - PI providers: those PI reports usable auth for. Each provider becomes one endpoint with
|
|
84
101
|
* `mode = endpoint = provider name`. `gatewayManaged` is true only if the provider has a known
|
|
85
|
-
* upstream URL in PI_PROVIDER_UPSTREAM (otherwise
|
|
102
|
+
* upstream URL in PI_PROVIDER_UPSTREAM (otherwise the model is discovered but gateway.yaml entry is
|
|
86
103
|
* skipped).
|
|
87
104
|
*/
|
|
88
105
|
export declare function discoverEndpoints(backends?: string[], options?: DiscoverEndpointsOptions): Promise<DiscoveredEndpoint[]>;
|
|
@@ -90,7 +107,7 @@ export declare function discoverEndpoints(backends?: string[], options?: Discove
|
|
|
90
107
|
* Generate gateway.yaml content from discovered endpoints.
|
|
91
108
|
* Outputs a formatted YAML string with comments explaining each mode.
|
|
92
109
|
*
|
|
93
|
-
* Endpoints with gatewayManaged=false are skipped (their
|
|
110
|
+
* Endpoints with gatewayManaged=false are skipped (their models still exist in models.json,
|
|
94
111
|
* but gateway.yaml has no entry for them — PI traffic to those providers is currently direct).
|
|
95
112
|
*/
|
|
96
113
|
export declare function generateGatewayYaml(endpoints: DiscoveredEndpoint[], defaultMode?: string): string;
|
|
@@ -104,7 +121,7 @@ export declare function discoveredToEndpointMap(endpoints: DiscoveredEndpoint[])
|
|
|
104
121
|
/**
|
|
105
122
|
* Merge freshly discovered endpoints over an existing gateway config.
|
|
106
123
|
*
|
|
107
|
-
* Add-only at the (endpoint, mode) PAIR level (
|
|
124
|
+
* Add-only at the (endpoint, mode) PAIR level (preserving existing operator choices): a pair
|
|
108
125
|
* absent from the existing file is added from discovery; any pair that already exists is preserved
|
|
109
126
|
* verbatim — its base_url, auth_style and (critically) managed keys are never clobbered. This both
|
|
110
127
|
* fixes the original bug (a missing mode gets added) and protects hand-customized routes, e.g. a
|
|
@@ -125,11 +142,9 @@ export declare function writeMergedGatewayYaml(discovered: DiscoveredEndpoint[],
|
|
|
125
142
|
result: MergeGatewayResult;
|
|
126
143
|
};
|
|
127
144
|
/**
|
|
128
|
-
*
|
|
129
|
-
* that actually exists in the merged endpoint map. Pure + non-fatal — returns the list of problems
|
|
130
|
-
* so the caller can warn loudly. This is what catches the `400 Unknown mode: <x>` class of bug.
|
|
145
|
+
* Check the default's selected route and whether each favorite has an available endpoint route.
|
|
131
146
|
*/
|
|
132
|
-
export declare function
|
|
147
|
+
export declare function validateModelsAgainstGateway(mergedEndpoints: EndpointMap, configDir?: string): GatewayValidationIssue[];
|
|
133
148
|
/**
|
|
134
149
|
* Run discovery and return the YAML string (without writing to disk).
|
|
135
150
|
* Useful for dry-run / preview.
|
|
@@ -23,29 +23,29 @@ const FLAT_MODE = 'default';
|
|
|
23
23
|
* Map a PI built-in provider name to its real upstream URL. Used by `generateGatewayYaml` so PI
|
|
24
24
|
* traffic can be routed through the gateway. Entries are sourced from PI source / docs.
|
|
25
25
|
*
|
|
26
|
-
* Providers absent from this table are still surfaced as
|
|
26
|
+
* Providers absent from this table are still surfaced as models, but no gateway endpoint
|
|
27
27
|
* is generated for them (gatewayManaged=false). PI will then either fail (if the cortex spawn path
|
|
28
28
|
* forces gateway routing) or direct-call the upstream (if the spawn path leaves models.json
|
|
29
29
|
* untouched for that provider). Full provider plumbing remains future work.
|
|
30
30
|
*/
|
|
31
|
-
const PI_PROVIDER_UPSTREAM = {
|
|
31
|
+
export const PI_PROVIDER_UPSTREAM = {
|
|
32
32
|
// Anthropic-protocol providers (PI's `api: anthropic-messages`)
|
|
33
33
|
anthropic: { url: 'https://api.anthropic.com', auth_style: 'bearer' },
|
|
34
34
|
fireworks: { url: 'https://api.fireworks.ai/inference', auth_style: 'bearer' },
|
|
35
35
|
'github-copilot': { url: 'https://api.individual.githubcopilot.com', auth_style: 'bearer' },
|
|
36
|
-
'kimi-coding': { url: 'https://api.kimi.com/coding', auth_style: 'bearer' },
|
|
37
36
|
minimax: { url: 'https://api.minimax.io/anthropic', auth_style: 'bearer' },
|
|
38
37
|
'minimax-cn': { url: 'https://api.minimaxi.com/anthropic', auth_style: 'bearer' },
|
|
39
|
-
opencode: { url: 'https://opencode.ai/
|
|
38
|
+
opencode: { url: 'https://opencode.ai/inference', auth_style: 'bearer' },
|
|
40
39
|
'vercel-ai-gateway': { url: 'https://ai-gateway.vercel.sh', auth_style: 'bearer' },
|
|
41
40
|
// OpenAI-completions / OpenAI-responses providers
|
|
42
41
|
cerebras: { url: 'https://api.cerebras.ai/v1', auth_style: 'bearer' },
|
|
43
42
|
deepseek: { url: 'https://api.deepseek.com', auth_style: 'bearer' },
|
|
44
43
|
groq: { url: 'https://api.groq.com/openai/v1', auth_style: 'bearer' },
|
|
45
44
|
huggingface: { url: 'https://router.huggingface.co/v1', auth_style: 'bearer' },
|
|
45
|
+
'kimi-coding': { url: 'https://api.kimi.com/coding/v1', auth_style: 'bearer' },
|
|
46
46
|
mistral: { url: 'https://api.mistral.ai', auth_style: 'bearer' },
|
|
47
47
|
openai: { url: 'https://api.openai.com/v1', auth_style: 'bearer' },
|
|
48
|
-
'opencode-go': { url: 'https://opencode.ai/
|
|
48
|
+
'opencode-go': { url: 'https://opencode.ai/inference/go/v1', auth_style: 'bearer' },
|
|
49
49
|
openrouter: { url: 'https://openrouter.ai/api/v1', auth_style: 'bearer' },
|
|
50
50
|
xai: { url: 'https://api.x.ai/v1', auth_style: 'bearer' },
|
|
51
51
|
zai: { url: 'https://api.z.ai/api/coding/paas/v4', auth_style: 'bearer' },
|
|
@@ -55,10 +55,48 @@ const PI_PROVIDER_UPSTREAM = {
|
|
|
55
55
|
'google-antigravity': { url: 'https://daily-cloudcode-pa.sandbox.googleapis.com', auth_style: 'bearer' },
|
|
56
56
|
// Other built-ins
|
|
57
57
|
google: { url: 'https://generativelanguage.googleapis.com/v1beta', auth_style: 'bearer' },
|
|
58
|
-
// amazon-bedrock / google-vertex / azure
|
|
58
|
+
// amazon-bedrock / google-vertex / azure / cloudflare-workers-ai use
|
|
59
59
|
// env-driven URLs (region / account ID / resource name) — not safely templated here.
|
|
60
60
|
// Users wanting these through the gateway must edit gateway.yaml manually.
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Upstream URLs the table above held for a PI provider before PI moved it (PI 1.3.0). A stored
|
|
64
|
+
* route still on one of these is the route Cortex wrote, not a hand-pointed relay, so it follows
|
|
65
|
+
* the provider to its current upstream; mergeGatewayConfig never rewrites an existing route.
|
|
66
|
+
*/
|
|
67
|
+
const RETIRED_PI_UPSTREAMS = {
|
|
68
|
+
'kimi-coding': ['https://api.kimi.com/coding'],
|
|
69
|
+
opencode: ['https://opencode.ai/zen'],
|
|
70
|
+
'opencode-go': ['https://opencode.ai/zen/go/v1'],
|
|
71
|
+
};
|
|
72
|
+
/** Point every stored route still on a retired PI upstream at the current one; returns how many moved. */
|
|
73
|
+
export function refreshRetiredPiUpstreams(endpoints) {
|
|
74
|
+
let moved = 0;
|
|
75
|
+
for (const [provider, retired] of Object.entries(RETIRED_PI_UPSTREAMS)) {
|
|
76
|
+
for (const route of Object.values(endpoints[provider] ?? {})) {
|
|
77
|
+
if (!retired.includes(route.base_url))
|
|
78
|
+
continue;
|
|
79
|
+
route.base_url = PI_PROVIDER_UPSTREAM[provider].url;
|
|
80
|
+
moved += 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return moved;
|
|
84
|
+
}
|
|
85
|
+
/** Rewrite gateway.yaml (backing it up first) when a stored route is on a retired PI upstream. */
|
|
86
|
+
export function migrateRetiredPiUpstreams(configPath = path.join(AISTATUS_DIR, 'gateway.yaml')) {
|
|
87
|
+
const parsed = readGatewayYaml(configPath);
|
|
88
|
+
if (!parsed)
|
|
89
|
+
return 0;
|
|
90
|
+
const moved = refreshRetiredPiUpstreams(parsed.endpoints);
|
|
91
|
+
if (moved === 0)
|
|
92
|
+
return 0;
|
|
93
|
+
copyFileSync(configPath, `${configPath}.bak`);
|
|
94
|
+
atomicWriteSync(configPath, serializeGatewayYaml({
|
|
95
|
+
endpoints: parsed.endpoints, top: parsed.top, preservedCustom: [], droppedFromDiscovery: [],
|
|
96
|
+
}));
|
|
97
|
+
log.info(`Moved ${moved} gateway route(s) off retired PI upstream URLs in ${configPath}`);
|
|
98
|
+
return moved;
|
|
99
|
+
}
|
|
62
100
|
/** The ascending thinking-level ladder PI's own selector walks. */
|
|
63
101
|
const PI_THINKING_LADDER = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
64
102
|
/**
|
|
@@ -126,12 +164,12 @@ async function scanPiForEndpoints() {
|
|
|
126
164
|
* @param backends - Optional filter: when provided, only discover endpoints for the listed backends
|
|
127
165
|
* (e.g. `['claude']`, `['pi']`, `['claude', 'pi']`). When omitted, all backends are discovered.
|
|
128
166
|
*
|
|
129
|
-
* Claude endpoints come first, then PI providers in PI's order;
|
|
167
|
+
* Claude endpoints come first, then PI providers in PI's order; model recommendations follow that order.
|
|
130
168
|
* - Claude Code plan mode: only when Claude Code holds a subscription login.
|
|
131
169
|
* - Claude Code api mode: only when a real ANTHROPIC_API_KEY is available.
|
|
132
170
|
* - PI providers: those PI reports usable auth for. Each provider becomes one endpoint with
|
|
133
171
|
* `mode = endpoint = provider name`. `gatewayManaged` is true only if the provider has a known
|
|
134
|
-
* upstream URL in PI_PROVIDER_UPSTREAM (otherwise
|
|
172
|
+
* upstream URL in PI_PROVIDER_UPSTREAM (otherwise the model is discovered but gateway.yaml entry is
|
|
135
173
|
* skipped).
|
|
136
174
|
*/
|
|
137
175
|
export async function discoverEndpoints(backends, options = {}) {
|
|
@@ -156,7 +194,7 @@ function anthropicEndpoint(mode, models, defaultModel) {
|
|
|
156
194
|
}
|
|
157
195
|
/**
|
|
158
196
|
* Claude Code's endpoints, each present only when its credential is: an endpoint nobody logged
|
|
159
|
-
* into would otherwise become the default
|
|
197
|
+
* into would otherwise become the default selection and lock the user out of the one they did log
|
|
160
198
|
* into (merges never overwrite an existing plan/execute).
|
|
161
199
|
*/
|
|
162
200
|
async function discoverClaudeEndpoints(options) {
|
|
@@ -218,7 +256,7 @@ function capitalize(s) {
|
|
|
218
256
|
* Generate gateway.yaml content from discovered endpoints.
|
|
219
257
|
* Outputs a formatted YAML string with comments explaining each mode.
|
|
220
258
|
*
|
|
221
|
-
* Endpoints with gatewayManaged=false are skipped (their
|
|
259
|
+
* Endpoints with gatewayManaged=false are skipped (their models still exist in models.json,
|
|
222
260
|
* but gateway.yaml has no entry for them — PI traffic to those providers is currently direct).
|
|
223
261
|
*/
|
|
224
262
|
export function generateGatewayYaml(endpoints, defaultMode) {
|
|
@@ -280,7 +318,7 @@ export function generateGatewayYaml(endpoints, defaultMode) {
|
|
|
280
318
|
for (const s of skipped) {
|
|
281
319
|
lines.push(`# ${s.mode} (${s.models.length} model${s.models.length === 1 ? '' : 's'})`);
|
|
282
320
|
}
|
|
283
|
-
lines.push('# These providers appear in
|
|
321
|
+
lines.push('# These providers appear in models.json but are not routed through this gateway.');
|
|
284
322
|
}
|
|
285
323
|
lines.push('');
|
|
286
324
|
return lines.join('\n');
|
|
@@ -355,7 +393,7 @@ export function discoveredToEndpointMap(endpoints) {
|
|
|
355
393
|
/**
|
|
356
394
|
* Merge freshly discovered endpoints over an existing gateway config.
|
|
357
395
|
*
|
|
358
|
-
* Add-only at the (endpoint, mode) PAIR level (
|
|
396
|
+
* Add-only at the (endpoint, mode) PAIR level (preserving existing operator choices): a pair
|
|
359
397
|
* absent from the existing file is added from discovery; any pair that already exists is preserved
|
|
360
398
|
* verbatim — its base_url, auth_style and (critically) managed keys are never clobbered. This both
|
|
361
399
|
* fixes the original bug (a missing mode gets added) and protects hand-customized routes, e.g. a
|
|
@@ -476,64 +514,37 @@ export function writeMergedGatewayYaml(discovered, outputDir, defaultMode) {
|
|
|
476
514
|
return { path: configPath, result };
|
|
477
515
|
}
|
|
478
516
|
/**
|
|
479
|
-
*
|
|
480
|
-
* that actually exists in the merged endpoint map. Pure + non-fatal — returns the list of problems
|
|
481
|
-
* so the caller can warn loudly. This is what catches the `400 Unknown mode: <x>` class of bug.
|
|
517
|
+
* Check the default's selected route and whether each favorite has an available endpoint route.
|
|
482
518
|
*/
|
|
483
|
-
export function
|
|
484
|
-
const
|
|
519
|
+
export function validateModelsAgainstGateway(mergedEndpoints, configDir = CONFIG_DIR) {
|
|
520
|
+
const file = path.join(configDir, 'models.json');
|
|
485
521
|
let parsed;
|
|
486
522
|
try {
|
|
487
|
-
if (!existsSync(
|
|
523
|
+
if (!existsSync(file))
|
|
488
524
|
return [];
|
|
489
|
-
parsed = JSON.parse(readFileSync(
|
|
525
|
+
parsed = JSON.parse(readFileSync(file, 'utf8'));
|
|
490
526
|
}
|
|
491
|
-
catch (
|
|
492
|
-
log.warn(`Failed to read
|
|
527
|
+
catch (error) {
|
|
528
|
+
log.warn(`Failed to read models.json for validation: ${error.message}`);
|
|
493
529
|
return [];
|
|
494
530
|
}
|
|
495
|
-
if (!isPlainObject(parsed)
|
|
531
|
+
if (!isPlainObject(parsed))
|
|
496
532
|
return [];
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
return; // Unknown backends do not route through gateway modes here.
|
|
513
|
-
if (backend === 'pi' && !provider) {
|
|
514
|
-
issues.push({ profile: label, mode, reason: `pi profile is missing a provider (cannot resolve gateway endpoint)` });
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
if (!endpoint || !mergedEndpoints[endpoint]?.[mode]) {
|
|
518
|
-
const reason = !modeExistsAnywhere(mode)
|
|
519
|
-
? `mode "${mode}" is not configured in gateway.yaml`
|
|
520
|
-
: `endpoint "${endpoint}" is not configured under mode "${mode}"`;
|
|
521
|
-
issues.push({ profile: label, mode, provider, reason });
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
for (const [name, profileVal] of Object.entries(parsed.profiles)) {
|
|
525
|
-
if (!isPlainObject(profileVal))
|
|
526
|
-
continue;
|
|
527
|
-
checkEntry(profileVal, name);
|
|
528
|
-
const fallback = profileVal.fallback;
|
|
529
|
-
if (Array.isArray(fallback)) {
|
|
530
|
-
fallback.forEach((fb, i) => {
|
|
531
|
-
if (isPlainObject(fb))
|
|
532
|
-
checkEntry(fb, `${name} (fallback #${i + 1})`);
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return issues;
|
|
533
|
+
const entries = [parsed.default, ...(Array.isArray(parsed.favorites) ? parsed.favorites : [])];
|
|
534
|
+
return entries.filter(isPlainObject).flatMap(entry => validateModelRoute(entry, mergedEndpoints));
|
|
535
|
+
}
|
|
536
|
+
function validateModelRoute(entry, endpoints) {
|
|
537
|
+
const provider = typeof entry.provider === 'string' ? entry.provider : undefined;
|
|
538
|
+
const endpoint = entry.backend === 'claude' ? 'anthropic' : provider;
|
|
539
|
+
const mode = typeof entry.mode === 'string' ? entry.mode : '';
|
|
540
|
+
const model = String(entry.model ?? '(unknown)');
|
|
541
|
+
if (!endpoint)
|
|
542
|
+
return [{ model, mode, reason: 'PI model is missing a provider (cannot resolve gateway endpoint)' }];
|
|
543
|
+
const routes = endpoints[endpoint] ?? {};
|
|
544
|
+
const available = mode ? !!routes[mode] : Object.keys(routes).length > 0;
|
|
545
|
+
if (available)
|
|
546
|
+
return [];
|
|
547
|
+
return [{ model, mode, provider, reason: `endpoint "${endpoint}" has no configured ${mode ? `mode "${mode}"` : 'route'} in gateway.yaml` }];
|
|
537
548
|
}
|
|
538
549
|
/**
|
|
539
550
|
* Run discovery and return the YAML string (without writing to disk).
|
package/dist/core/hook-bus.d.ts
CHANGED
package/dist/core/hook-bus.js
CHANGED
|
@@ -43,14 +43,7 @@ function failure(id, error) {
|
|
|
43
43
|
return { id, error: message };
|
|
44
44
|
}
|
|
45
45
|
function parsedResult(hook, stdout) {
|
|
46
|
-
|
|
47
|
-
case 'hook-result':
|
|
48
|
-
return { id: hook.id, result: JSON.parse(stdout) };
|
|
49
|
-
case 'stdout-as-prompt':
|
|
50
|
-
return { id: hook.id, result: stdout.trim() };
|
|
51
|
-
default:
|
|
52
|
-
return { id: hook.id };
|
|
53
|
-
}
|
|
46
|
+
return hook.result === 'stdout-as-prompt' ? { id: hook.id, result: stdout.trim() } : { id: hook.id };
|
|
54
47
|
}
|
|
55
48
|
function interpretResult(hook, stdout, stderr) {
|
|
56
49
|
const result = parsedResult(hook, stdout);
|