@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
|
@@ -104,7 +104,7 @@ export class ContinuationPhase {
|
|
|
104
104
|
const emit = sinkToRunEvents((event) => this.ingest(event));
|
|
105
105
|
return {
|
|
106
106
|
...emit,
|
|
107
|
-
onTurnOpen: () => this.onTurnOpen(),
|
|
107
|
+
onTurnOpen: (wake) => this.onTurnOpen(wake),
|
|
108
108
|
onResult: (result) => this.onResult(result),
|
|
109
109
|
};
|
|
110
110
|
}
|
|
@@ -165,14 +165,19 @@ export class ContinuationPhase {
|
|
|
165
165
|
* result decides what happens next. Releasing it on the ack instead would close the stream
|
|
166
166
|
* before the reply it is owed could land; never releasing it (as was the case) left a run whose
|
|
167
167
|
* foreground turn ended with one injected message pending open forever — the max-wait watchdog
|
|
168
|
-
* bounds a WAIT, it does not finish a run.
|
|
169
|
-
|
|
168
|
+
* bounds a WAIT, it does not finish a run.
|
|
169
|
+
*
|
|
170
|
+
* A turn that finished background work opened carries its `wake`, reported ahead of anything
|
|
171
|
+
* the turn says. */
|
|
172
|
+
onTurnOpen(wake) {
|
|
170
173
|
if (this.settled || !this.started)
|
|
171
174
|
return;
|
|
172
175
|
this.backgroundTurnOpen = true;
|
|
173
176
|
this.outstandingInjections = 0;
|
|
174
177
|
this.pause();
|
|
175
178
|
this.enterBackground();
|
|
179
|
+
if (wake)
|
|
180
|
+
this.port.push({ type: 'background_wake', summaries: wake.summaries, phase: 'background' });
|
|
176
181
|
}
|
|
177
182
|
enterBackground() {
|
|
178
183
|
if (!this.acc)
|
|
@@ -316,6 +321,9 @@ export function sinkToRunEvents(emit) {
|
|
|
316
321
|
...(subagent !== undefined ? { subagent } : {}),
|
|
317
322
|
});
|
|
318
323
|
},
|
|
324
|
+
onAssistantThinking: (text, blockId) => emit({
|
|
325
|
+
type: 'assistant_thinking', text, phase: 'background', ...(blockId ? { blockId } : {}),
|
|
326
|
+
}),
|
|
319
327
|
onToolUse: (name, input, toolUseId, subagent) => {
|
|
320
328
|
emit({
|
|
321
329
|
type: 'tool_use', toolUseId: toolUseId ?? '', name, input, phase: 'background',
|
|
@@ -41,6 +41,14 @@ export type NormalizedEvent = {
|
|
|
41
41
|
type: 'assistant_delta';
|
|
42
42
|
text: string;
|
|
43
43
|
blockId: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'assistant_thinking';
|
|
46
|
+
text: string;
|
|
47
|
+
blockId?: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'assistant_thinking_delta';
|
|
50
|
+
text: string;
|
|
51
|
+
blockId: string;
|
|
44
52
|
} | {
|
|
45
53
|
type: 'tool_use';
|
|
46
54
|
toolUseId: string;
|
|
@@ -86,7 +86,6 @@ export declare class PIAdapter implements EngineAdapter {
|
|
|
86
86
|
gatewayPath?: string | null;
|
|
87
87
|
gatewayBaseUrl: string;
|
|
88
88
|
model?: string;
|
|
89
|
-
maxTokens?: number;
|
|
90
89
|
}): void;
|
|
91
90
|
/** The one construction of a `PiSessionRequest`; `specIdentity` and `prepareRequest` both come
|
|
92
91
|
* through here so the identity the pool compares can never drift from the request `open` builds. */
|
|
@@ -11,7 +11,7 @@ import { CODEX_PROVIDER } from '../../core/codex-quota.js';
|
|
|
11
11
|
import { PISession } from './pi-session.js';
|
|
12
12
|
import { PIEngineSession } from './engine.js';
|
|
13
13
|
import { createPiRuntime } from './runtime.js';
|
|
14
|
-
import { buildSessionRequest, sessionIdentity,
|
|
14
|
+
import { buildSessionRequest, sessionIdentity, } from './session-options.js';
|
|
15
15
|
import { PI_AGENT_DIR, PI_SESSIONS_DIR, piModelsPath } from './defaults.js';
|
|
16
16
|
const log = createLogger('pi-adapter');
|
|
17
17
|
/** Discovery that reports nothing when the daemon does not inject its cached scanner. */
|
|
@@ -99,14 +99,10 @@ export class PIAdapter {
|
|
|
99
99
|
const cached = await this.usageStore?.get(CODEX_PROVIDER) ?? null;
|
|
100
100
|
return [cached ? staleCodexUsage(cached) : neverCodexUsage(scope.mode)];
|
|
101
101
|
}
|
|
102
|
-
gatewayOverrides(discovered, currentProvider, gatewayPath
|
|
102
|
+
gatewayOverrides(discovered, currentProvider, gatewayPath) {
|
|
103
103
|
if (currentProvider) {
|
|
104
104
|
const [current] = buildProviderOverrides([], currentProvider, gatewayPath);
|
|
105
|
-
|
|
106
|
-
? { [model]: { maxTokens } } : undefined;
|
|
107
|
-
this.configuredProviderOverrides.set(currentProvider, {
|
|
108
|
-
...current, ...(modelOverrides ? { modelOverrides } : {}),
|
|
109
|
-
});
|
|
105
|
+
this.configuredProviderOverrides.set(currentProvider, current);
|
|
110
106
|
}
|
|
111
107
|
const byName = new Map(buildProviderOverrides(discovered, null, null).map((override) => [override.name, override]));
|
|
112
108
|
for (const override of this.configuredProviderOverrides.values())
|
|
@@ -139,9 +135,9 @@ export class PIAdapter {
|
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
137
|
writeGatewayProvidersUnchecked(spec, agentDir, gatewayBaseUrl) {
|
|
142
|
-
const overrides = withCustomEntries(this.gatewayOverrides(this.providerDiscovery.getProviders(), spec.model.provider ?? null, spec.route.gatewayPath ?? null
|
|
138
|
+
const overrides = withCustomEntries(this.gatewayOverrides(this.providerDiscovery.getProviders(), spec.model.provider ?? null, spec.route.gatewayPath ?? null), this.userModelsPath ? readCustomProviderEntries(this.userModelsPath) : {});
|
|
143
139
|
if (overrides.length === 0) {
|
|
144
|
-
log.warn('No PI providers to route (empty discovery and no
|
|
140
|
+
log.warn('No PI providers to route (empty discovery and no selected provider); the PI session may fail to authenticate');
|
|
145
141
|
return;
|
|
146
142
|
}
|
|
147
143
|
writeProvidersConfig(overrides, gatewayBaseUrl, { modelsPath: piModelsPath(agentDir) });
|
|
@@ -170,7 +166,6 @@ export class PIAdapter {
|
|
|
170
166
|
const spec = minimalEngineSpec();
|
|
171
167
|
spec.model.provider = opts.provider;
|
|
172
168
|
spec.model.id = opts.model;
|
|
173
|
-
spec.model.maxOutputTokens = opts.maxTokens;
|
|
174
169
|
spec.route.gatewayPath = opts.gatewayPath ?? undefined;
|
|
175
170
|
spec.route.gatewayBaseUrl = opts.gatewayBaseUrl;
|
|
176
171
|
this.syncGatewayConfig(spec, this.agentDir);
|
|
@@ -197,9 +192,6 @@ export class PIAdapter {
|
|
|
197
192
|
mkdirSync(this.sessionDir, { recursive: true });
|
|
198
193
|
const sessionPath = this.resolveSpawnSessionPath(spec, this.sessionDir);
|
|
199
194
|
this.syncGatewayConfig(spec, agentDir);
|
|
200
|
-
for (const key of unsupportedExtraOptions(spec)) {
|
|
201
|
-
log.warn(`PI extraOption ${key} was a CLI flag; the in-process backend ignores it`);
|
|
202
|
-
}
|
|
203
195
|
return this.buildRequest(spec, sessionPath);
|
|
204
196
|
}
|
|
205
197
|
/** Undefined unless this instance was given somewhere to put a reading: no gateway route means
|
|
@@ -20,7 +20,7 @@ export declare function createPIEventParserState(): PIEventParserState;
|
|
|
20
20
|
* NormalizedEvents.
|
|
21
21
|
*
|
|
22
22
|
* Dropped events (return []): turn_start, turn_end, message_start, agent_start,
|
|
23
|
-
* queue_update, compaction_end, auto_retry_start/end, message_update
|
|
23
|
+
* queue_update, compaction_end, auto_retry_start/end, unsupported message_update events,
|
|
24
24
|
* fire-and-forget extension_ui_request.
|
|
25
25
|
* message_end emits a turn_progress heartbeat (non-terminal, state.turnProgressCount++).
|
|
26
26
|
* compaction_start emits a context_compacted event (user notification); compaction_end is dropped
|
|
@@ -15,7 +15,7 @@ export function createPIEventParserState() {
|
|
|
15
15
|
* NormalizedEvents.
|
|
16
16
|
*
|
|
17
17
|
* Dropped events (return []): turn_start, turn_end, message_start, agent_start,
|
|
18
|
-
* queue_update, compaction_end, auto_retry_start/end, message_update
|
|
18
|
+
* queue_update, compaction_end, auto_retry_start/end, unsupported message_update events,
|
|
19
19
|
* fire-and-forget extension_ui_request.
|
|
20
20
|
* message_end emits a turn_progress heartbeat (non-terminal, state.turnProgressCount++).
|
|
21
21
|
* compaction_start emits a context_compacted event (user notification); compaction_end is dropped
|
|
@@ -27,32 +27,8 @@ export function piEventToNormalized(event, state) {
|
|
|
27
27
|
if (typeof ev['type'] !== 'string')
|
|
28
28
|
return [];
|
|
29
29
|
const type = ev['type'];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const ame = ev['assistantMessageEvent'];
|
|
33
|
-
if (ame && typeof ame === 'object') {
|
|
34
|
-
const delta = ame['delta'];
|
|
35
|
-
if (ame['type'] === 'text_delta' &&
|
|
36
|
-
typeof delta === 'string' &&
|
|
37
|
-
delta.length > 0) {
|
|
38
|
-
// blockId groups every delta of one assistant message and ties them to the finalizing
|
|
39
|
-
// whole-message assistant_text. PI's AssistantMessage carries no `id`: the stable
|
|
40
|
-
// per-message identifier is `responseId`, which the provider assigns once when the
|
|
41
|
-
// stream opens (anthropic msg_… / openai-compatible chatcmpl-…), before any text_delta.
|
|
42
|
-
// `id` is kept first so any producer that does supply one keeps working.
|
|
43
|
-
const msgObj = ev['message'];
|
|
44
|
-
const blockId = msgObj && typeof msgObj === 'object'
|
|
45
|
-
? (msgObj['id'] ??
|
|
46
|
-
msgObj['responseId'])
|
|
47
|
-
: undefined;
|
|
48
|
-
const result = { type: 'assistant_text', text: delta };
|
|
49
|
-
if (typeof blockId === 'string')
|
|
50
|
-
result.blockId = blockId;
|
|
51
|
-
return [result];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
30
|
+
if (type === 'message_update')
|
|
31
|
+
return handleMessageUpdate(ev);
|
|
56
32
|
// --- tool_execution_start → tool_use ---
|
|
57
33
|
if (type === 'tool_execution_start') {
|
|
58
34
|
return handleToolExecutionStart(ev);
|
|
@@ -107,6 +83,46 @@ export function piEventToNormalized(event, state) {
|
|
|
107
83
|
// ---------------------------------------------------------------------------
|
|
108
84
|
// Private helpers
|
|
109
85
|
// ---------------------------------------------------------------------------
|
|
86
|
+
function record(value) {
|
|
87
|
+
return value !== null && typeof value === 'object' ? value : undefined;
|
|
88
|
+
}
|
|
89
|
+
/** Real PI messages use responseId; keep id first for producers that already supply it. */
|
|
90
|
+
function messageId(message) {
|
|
91
|
+
const msg = record(message);
|
|
92
|
+
const id = msg?.id ?? msg?.responseId;
|
|
93
|
+
return typeof id === 'string' ? id : undefined;
|
|
94
|
+
}
|
|
95
|
+
function redactedBlock(message, index) {
|
|
96
|
+
const content = record(message)?.content;
|
|
97
|
+
if (!Array.isArray(content) || typeof index !== 'number')
|
|
98
|
+
return false;
|
|
99
|
+
return record(content[index])?.redacted === true;
|
|
100
|
+
}
|
|
101
|
+
function handleThinkingUpdate(ev, ame) {
|
|
102
|
+
const redacted = ame.redacted === true
|
|
103
|
+
|| redactedBlock(ev.message, ame.contentIndex)
|
|
104
|
+
|| redactedBlock(ame.partial, ame.contentIndex);
|
|
105
|
+
const text = ame.type === 'thinking_end' ? ame.content : ame.delta;
|
|
106
|
+
if (redacted || typeof text !== 'string' || text.length === 0)
|
|
107
|
+
return [];
|
|
108
|
+
const id = messageId(ev.message);
|
|
109
|
+
const blockId = id !== undefined && typeof ame.contentIndex === 'number' ? `${id}:t${ame.contentIndex}` : undefined;
|
|
110
|
+
if (ame.type === 'thinking_end') {
|
|
111
|
+
return [{ type: 'assistant_thinking', text, ...(blockId !== undefined ? { blockId } : {}) }];
|
|
112
|
+
}
|
|
113
|
+
return blockId !== undefined ? [{ type: 'assistant_thinking_delta', text, blockId }] : [];
|
|
114
|
+
}
|
|
115
|
+
function handleMessageUpdate(ev) {
|
|
116
|
+
const ame = record(ev.assistantMessageEvent);
|
|
117
|
+
if (!ame)
|
|
118
|
+
return [];
|
|
119
|
+
if (ame.type === 'thinking_delta' || ame.type === 'thinking_end')
|
|
120
|
+
return handleThinkingUpdate(ev, ame);
|
|
121
|
+
if (ame.type !== 'text_delta' || typeof ame.delta !== 'string' || ame.delta.length === 0)
|
|
122
|
+
return [];
|
|
123
|
+
const blockId = messageId(ev.message);
|
|
124
|
+
return [{ type: 'assistant_text', text: ame.delta, ...(blockId !== undefined ? { blockId } : {}) }];
|
|
125
|
+
}
|
|
110
126
|
function handleToolExecutionStart(ev) {
|
|
111
127
|
const toolCallId = ev['toolCallId'];
|
|
112
128
|
const toolName = ev['toolName'];
|
|
@@ -41,7 +41,7 @@ export type OpenBundledMcpServer = (bundles: McpBundleName[], env: Record<string
|
|
|
41
41
|
export interface McpBridgeDeps {
|
|
42
42
|
/** The session's environment: composition markers, channel, Cortex context, tool gate. */
|
|
43
43
|
env: NodeJS.ProcessEnv;
|
|
44
|
-
/** Plugin
|
|
44
|
+
/** Plugin servers for this session, already filtered by composition. */
|
|
45
45
|
pluginServers?: readonly McpServerConfig[];
|
|
46
46
|
spawnClient(state: ServerState): Promise<McpClientHandle>;
|
|
47
47
|
reportFailure(error: unknown): void;
|
|
@@ -130,6 +130,8 @@ export declare class PISession {
|
|
|
130
130
|
private buildAgentResult;
|
|
131
131
|
/** Buffer deltas into whole assistant messages while preserving Web preview events. */
|
|
132
132
|
private emitNormalizedEvent;
|
|
133
|
+
private emitThinkingEvent;
|
|
134
|
+
private bufferTextEvent;
|
|
133
135
|
/**
|
|
134
136
|
* Hand the opening prompt to PI. The call resolves only when the whole agent run has finished,
|
|
135
137
|
* so it is not awaited here; the turn is settled off the event stream instead. A rejection
|
|
@@ -424,6 +424,10 @@ export class PISession {
|
|
|
424
424
|
this.turnStream?.push(evt);
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
|
+
if (evt.type === 'assistant_thinking' || evt.type === 'assistant_thinking_delta') {
|
|
428
|
+
this.emitThinkingEvent(evt);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
427
431
|
// Forwarded subagent prose is already a complete message, not a token delta. Putting it in the
|
|
428
432
|
// main-agent text buffer would erase attribution when flushTextBuffer reconstructs the event.
|
|
429
433
|
if (evt.type === 'assistant_text' && evt.subagent) {
|
|
@@ -440,6 +444,17 @@ export class PISession {
|
|
|
440
444
|
this.closeTurnStream();
|
|
441
445
|
return;
|
|
442
446
|
}
|
|
447
|
+
this.bufferTextEvent(evt);
|
|
448
|
+
}
|
|
449
|
+
emitThinkingEvent(evt) {
|
|
450
|
+
if (!getSettings().showThinking)
|
|
451
|
+
return;
|
|
452
|
+
this.flushTextBuffer();
|
|
453
|
+
if (evt.type === 'assistant_thinking_delta' && !this.request.streamDeltas)
|
|
454
|
+
return;
|
|
455
|
+
this.turnStream?.push(evt);
|
|
456
|
+
}
|
|
457
|
+
bufferTextEvent(evt) {
|
|
443
458
|
const blockId = evt.blockId ?? null;
|
|
444
459
|
if (this.textBuffer.length > 0 && blockId !== this.textBlockId)
|
|
445
460
|
this.flushTextBuffer();
|
|
@@ -13,7 +13,7 @@ export interface ProviderOverride {
|
|
|
13
13
|
* (e.g. deepseek's anthropic-compat endpoint: `/deepseek/anthropic`).
|
|
14
14
|
*/
|
|
15
15
|
basePath?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** Catalog-wide model metadata defaults. Never put per-session benchmark caps here. */
|
|
17
17
|
modelOverrides?: Record<string, {
|
|
18
18
|
maxTokens: number;
|
|
19
19
|
}>;
|
|
@@ -42,7 +42,7 @@ export declare function writeProvidersConfig(providers: ProviderOverride[], gate
|
|
|
42
42
|
* Compute the set of PI providers whose baseUrl should be overridden to the gateway for a spawn.
|
|
43
43
|
*
|
|
44
44
|
* Design: "route through gateway" and "PI has credentials" are independent concerns. Discovery
|
|
45
|
-
* (`pi --list-models`) only reports providers the user is authenticated to, but
|
|
45
|
+
* (`pi --list-models`) only reports providers the user is authenticated to, but an engine selection may
|
|
46
46
|
* legitimately route a provider through the gateway even without direct PI credentials (the
|
|
47
47
|
* gateway injects managed keys). So the override set is the union of:
|
|
48
48
|
* - `discovered` — providers PI reports creds for (credential passthrough via auth.json)
|
|
@@ -60,7 +60,7 @@ export function writeProvidersConfig(providers, gatewayUrl, opts) {
|
|
|
60
60
|
* Compute the set of PI providers whose baseUrl should be overridden to the gateway for a spawn.
|
|
61
61
|
*
|
|
62
62
|
* Design: "route through gateway" and "PI has credentials" are independent concerns. Discovery
|
|
63
|
-
* (`pi --list-models`) only reports providers the user is authenticated to, but
|
|
63
|
+
* (`pi --list-models`) only reports providers the user is authenticated to, but an engine selection may
|
|
64
64
|
* legitimately route a provider through the gateway even without direct PI credentials (the
|
|
65
65
|
* gateway injects managed keys). So the override set is the union of:
|
|
66
66
|
* - `discovered` — providers PI reports creds for (credential passthrough via auth.json)
|
|
@@ -20,9 +20,9 @@ export interface CodexQuotaSinkDeps {
|
|
|
20
20
|
* Resolve the two keys the dispatch gate looks a throttle up by. `configIsRateLimited` asks
|
|
21
21
|
* `isProviderModeRateLimited(resolveRateLimitProvider(config), config.mode || 'api')`, so a reading
|
|
22
22
|
* filed under any other pair would be recorded and then never consulted. The provider mirrors
|
|
23
|
-
* `resolveRateLimitProvider` (
|
|
24
|
-
* the gateway sub-path `/m/<mode>/<provider>` that the engine spec derives from the
|
|
25
|
-
* and its absence means
|
|
23
|
+
* `resolveRateLimitProvider` (selection provider, else the backend name); the mode is recovered from
|
|
24
|
+
* the gateway sub-path `/m/<mode>/<provider>` that the engine spec derives from the selection's mode,
|
|
25
|
+
* and its absence means no gateway mode was attached — which the gate reads as 'api'.
|
|
26
26
|
*/
|
|
27
27
|
export declare function resolveQuotaSource(route: {
|
|
28
28
|
provider?: string | null;
|
|
@@ -5,9 +5,9 @@ const DISPLAY_NAMES = {
|
|
|
5
5
|
* Resolve the two keys the dispatch gate looks a throttle up by. `configIsRateLimited` asks
|
|
6
6
|
* `isProviderModeRateLimited(resolveRateLimitProvider(config), config.mode || 'api')`, so a reading
|
|
7
7
|
* filed under any other pair would be recorded and then never consulted. The provider mirrors
|
|
8
|
-
* `resolveRateLimitProvider` (
|
|
9
|
-
* the gateway sub-path `/m/<mode>/<provider>` that the engine spec derives from the
|
|
10
|
-
* and its absence means
|
|
8
|
+
* `resolveRateLimitProvider` (selection provider, else the backend name); the mode is recovered from
|
|
9
|
+
* the gateway sub-path `/m/<mode>/<provider>` that the engine spec derives from the selection's mode,
|
|
10
|
+
* and its absence means no gateway mode was attached — which the gate reads as 'api'.
|
|
11
11
|
*/
|
|
12
12
|
export function resolveQuotaSource(route) {
|
|
13
13
|
const provider = route.provider || 'pi';
|
|
@@ -49,7 +49,12 @@ function resolveModel(sdk, request, modelRuntime) {
|
|
|
49
49
|
throw new Error(resolved.error);
|
|
50
50
|
if (resolved.warning)
|
|
51
51
|
log.warn(`PI model resolution for ${request.sessionKey}: ${resolved.warning}`);
|
|
52
|
-
|
|
52
|
+
// The catalog belongs to the adapter, but a benchmark's frozen output cap belongs only to
|
|
53
|
+
// this session. Copy the resolved model: never mutate either the file or the SDK catalog.
|
|
54
|
+
const model = resolved.model && request.benchmarkMaxOutputTokens !== undefined
|
|
55
|
+
? { ...resolved.model, maxTokens: request.benchmarkMaxOutputTokens }
|
|
56
|
+
: resolved.model;
|
|
57
|
+
return { model, thinking: thinking ?? resolved.thinkingLevel };
|
|
53
58
|
}
|
|
54
59
|
async function createRuntimeServices(sdk, request, extensions, cwd, agentDir) {
|
|
55
60
|
// Before the manager reads the file: Pi has no setter for the compaction reserve.
|
|
@@ -8,8 +8,8 @@ export interface PIEnvOptions {
|
|
|
8
8
|
channel?: string | null;
|
|
9
9
|
callbackSource?: string | null;
|
|
10
10
|
scheduleTaskId?: string | null;
|
|
11
|
-
|
|
12
|
-
/** Keys deleted after the
|
|
11
|
+
routeEnv?: Record<string, string> | null;
|
|
12
|
+
/** Keys deleted after the route environment merge (EngineSpec.env.unsets). PI routes purely through
|
|
13
13
|
* env, so this is how a mode expresses "this spawn must not carry ANTHROPIC_API_KEY". */
|
|
14
14
|
unsetEnv?: string[] | null;
|
|
15
15
|
context?: CortexContextEnv;
|
|
@@ -46,6 +46,8 @@ export interface PiSessionRequest {
|
|
|
46
46
|
provider: string | null;
|
|
47
47
|
/** Model id with any context-window suffix (`[1m]`) stripped. */
|
|
48
48
|
model: string | null;
|
|
49
|
+
/** Benchmark-only output cap, applied to this session's selected model, never models.json. */
|
|
50
|
+
benchmarkMaxOutputTokens?: number;
|
|
49
51
|
thinking: string | null;
|
|
50
52
|
systemPrompt: string | null;
|
|
51
53
|
appendSystemPrompt: string[];
|
|
@@ -54,12 +56,12 @@ export interface PiSessionRequest {
|
|
|
54
56
|
disableHooks: boolean;
|
|
55
57
|
/** Gateway-routed runs report provider quota read off response headers. */
|
|
56
58
|
reportsProviderQuota: boolean;
|
|
57
|
-
/** Plugin
|
|
59
|
+
/** Plugin MCP servers, already filtered by composition. Empty when none apply. */
|
|
58
60
|
pluginMcpServers: McpServerConfig[];
|
|
59
61
|
/**
|
|
60
|
-
* The session's CORTEX_* environment.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
62
|
+
* The session's CORTEX_* environment. Both in-process MCP context and child processes (hook
|
|
63
|
+
* scripts, plugin MCP servers, subagents) read scope from this snapshot, also used as the pool
|
|
64
|
+
* identity.
|
|
63
65
|
*/
|
|
64
66
|
env: NodeJS.ProcessEnv;
|
|
65
67
|
streamDeltas: boolean;
|
|
@@ -73,14 +75,8 @@ export interface SessionRequestInputs {
|
|
|
73
75
|
}
|
|
74
76
|
/** Strip a context-window suffix like "[1m]" (e.g. "deepseek-v4-flash[1m]" → "deepseek-v4-flash"). */
|
|
75
77
|
export declare function stripModelSuffix(model: string): string;
|
|
76
|
-
/**
|
|
77
|
-
* Plugin MCP servers for this session. Browser control rides along like any other plugin server,
|
|
78
|
-
* gated on `direct` for the same reason Claude gates it: an unattended worker sharing one browser
|
|
79
|
-
* is a cross-run side channel, not a feature.
|
|
80
|
-
*/
|
|
78
|
+
/** Plugin MCP servers for this session; only the direct composition carries them. */
|
|
81
79
|
export declare function pluginMcpServers(spec: EngineSpec, composition: McpComposition): McpServerConfig[];
|
|
82
|
-
/** `extraOption` keys other than `--thinking` were PI CLI flags; there is no CLI to hand them to. */
|
|
83
|
-
export declare function unsupportedExtraOptions(spec: EngineSpec): string[];
|
|
84
80
|
export declare function buildSessionRequest(spec: EngineSpec, inputs: SessionRequestInputs): PiSessionRequest;
|
|
85
81
|
/**
|
|
86
82
|
* The exact configuration a live PI session was created with, as a comparable string. Everything
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { resolveMcpComposition } from '../types.js';
|
|
2
2
|
import { fromCanonical } from '../../core/tool-names.js';
|
|
3
|
-
import { browserMcpServer } from '../browser-mcp-server.js';
|
|
4
3
|
import { MCP_TOOL_ALLOWLIST_ENV } from '../../core/mcp-tool-gate.js';
|
|
5
4
|
export const PI_MCP_COMPOSITION_ENV = 'CORTEX_PI_MCP_COMPOSITION';
|
|
6
5
|
export const PI_INTERACTION_BRIDGE_ENV = 'CORTEX_PI_INTERACTION_BRIDGE';
|
|
@@ -8,7 +7,8 @@ export const PI_TEAM_LEAD_ENV = 'CORTEX_PI_TEAM_LEAD';
|
|
|
8
7
|
export const PI_TEAM_WORKER_ENV = 'CORTEX_PI_TEAM_WORKER';
|
|
9
8
|
const RESET_CONTEXT_KEYS = [
|
|
10
9
|
'SLACK_CHANNEL', 'FEISHU_CHANNEL',
|
|
11
|
-
'CORTEX_SESSION_ID', 'CORTEX_PROFILE',
|
|
10
|
+
'CORTEX_SESSION_ID', 'CORTEX_PROFILE', // Strip the retired context key from inherited env.
|
|
11
|
+
'CORTEX_BACKEND', 'CORTEX_MODEL', 'CORTEX_PROVIDER', 'CORTEX_THINKING', 'CORTEX_MODE',
|
|
12
12
|
'CORTEX_PROJECT', 'CORTEX_SESSION_NAME', 'CORTEX_EXECUTION_ID',
|
|
13
13
|
'CORTEX_CALLBACK_SOURCE', 'CORTEX_SCHEDULE_TASK_ID',
|
|
14
14
|
'CORTEX_CONFIG_IMMUTABLE', 'CORTEX_PRODUCTION_AUTH_FILE',
|
|
@@ -23,10 +23,13 @@ function setOptional(env, key, value) {
|
|
|
23
23
|
}
|
|
24
24
|
function applyContext(env, options) {
|
|
25
25
|
const context = options.context;
|
|
26
|
+
setOptional(env, 'CORTEX_MODEL', context?.selection?.model);
|
|
27
|
+
setOptional(env, 'CORTEX_PROVIDER', context?.selection?.provider);
|
|
28
|
+
setOptional(env, 'CORTEX_THINKING', context?.selection?.thinking);
|
|
29
|
+
setOptional(env, 'CORTEX_MODE', context?.selection?.mode);
|
|
26
30
|
setOptional(env, 'CORTEX_SESSION_ID', context?.trackSessionId ?? options.sessionId);
|
|
27
31
|
setOptional(env, 'CORTEX_CALLBACK_SOURCE', options.callbackSource);
|
|
28
32
|
setOptional(env, 'CORTEX_SCHEDULE_TASK_ID', options.scheduleTaskId);
|
|
29
|
-
setOptional(env, 'CORTEX_PROFILE', context?.profile);
|
|
30
33
|
setOptional(env, 'CORTEX_PROJECT', context?.project);
|
|
31
34
|
setOptional(env, 'CORTEX_EXECUTION_ID', context?.executionId);
|
|
32
35
|
}
|
|
@@ -36,7 +39,7 @@ function applyContext(env, options) {
|
|
|
36
39
|
* read their scope from it, and it doubles as part of the pooled-session identity.
|
|
37
40
|
*/
|
|
38
41
|
export function buildPiEnv(options, inheritedEnv = process.env) {
|
|
39
|
-
const env = { ...inheritedEnv, ...(options.
|
|
42
|
+
const env = { ...inheritedEnv, ...(options.routeEnv ?? {}) };
|
|
40
43
|
for (const key of RESET_CONTEXT_KEYS)
|
|
41
44
|
delete env[key];
|
|
42
45
|
// After the merge: deletion is the only way to express "absent", since '' is a legal value here.
|
|
@@ -83,28 +86,11 @@ function allowedToolLabels(spec) {
|
|
|
83
86
|
function subagentMarker(spec) {
|
|
84
87
|
return spec.env.sets?.CORTEX_PI_SUBAGENT === '1' ? '1' : undefined;
|
|
85
88
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Plugin MCP servers for this session. Browser control rides along like any other plugin server,
|
|
88
|
-
* gated on `direct` for the same reason Claude gates it: an unattended worker sharing one browser
|
|
89
|
-
* is a cross-run side channel, not a feature.
|
|
90
|
-
*/
|
|
89
|
+
/** Plugin MCP servers for this session; only the direct composition carries them. */
|
|
91
90
|
export function pluginMcpServers(spec, composition) {
|
|
92
91
|
if (composition !== 'direct')
|
|
93
92
|
return [];
|
|
94
|
-
|
|
95
|
-
if (spec.mcp.browserCdpEndpoint && composition === 'direct') {
|
|
96
|
-
servers.push(browserMcpServer(spec.mcp.browserCdpEndpoint));
|
|
97
|
-
}
|
|
98
|
-
return servers;
|
|
99
|
-
}
|
|
100
|
-
/** Thinking level: the profile field wins unless `extraOption` carries an explicit `--thinking`. */
|
|
101
|
-
function thinkingLevel(spec) {
|
|
102
|
-
const explicit = spec.extraOption?.['--thinking'];
|
|
103
|
-
return explicit || spec.model.thinking || null;
|
|
104
|
-
}
|
|
105
|
-
/** `extraOption` keys other than `--thinking` were PI CLI flags; there is no CLI to hand them to. */
|
|
106
|
-
export function unsupportedExtraOptions(spec) {
|
|
107
|
-
return Object.keys(spec.extraOption ?? {}).filter((key) => key !== '--thinking');
|
|
93
|
+
return [...(spec.mcp.servers ?? [])];
|
|
108
94
|
}
|
|
109
95
|
export function buildSessionRequest(spec, inputs) {
|
|
110
96
|
const composition = resolveMcpComposition(spec.mcp.composition);
|
|
@@ -114,7 +100,7 @@ export function buildSessionRequest(spec, inputs) {
|
|
|
114
100
|
channel: spec.context.channel,
|
|
115
101
|
callbackSource: spec.context.callbackSource,
|
|
116
102
|
scheduleTaskId: spec.context.scheduleTaskId,
|
|
117
|
-
|
|
103
|
+
routeEnv: spec.env.sets,
|
|
118
104
|
unsetEnv: spec.env.unsets,
|
|
119
105
|
context: spec.env.context,
|
|
120
106
|
piAgentDir: inputs.agentDir,
|
|
@@ -140,7 +126,8 @@ export function buildSessionRequest(spec, inputs) {
|
|
|
140
126
|
sessionPath: inputs.sessionPath,
|
|
141
127
|
provider: spec.model.provider ?? null,
|
|
142
128
|
model: spec.model.id ? stripModelSuffix(spec.model.id) : null,
|
|
143
|
-
|
|
129
|
+
benchmarkMaxOutputTokens: spec.model.benchmarkMaxOutputTokens,
|
|
130
|
+
thinking: spec.model.thinking ?? null,
|
|
144
131
|
systemPrompt: spec.prompt.system || null,
|
|
145
132
|
appendSystemPrompt: promptValues(spec.prompt.append),
|
|
146
133
|
// PI has no skill layer of its own to switch off: its skills are exactly the roots handed to
|
|
@@ -6,13 +6,9 @@ import type { NormalizedEvent, ToolUseSubagent } from './normalize/event-types.j
|
|
|
6
6
|
* (Claude background tasks, PI deferred completion, post-result injected messages).
|
|
7
7
|
* - `done` — terminal bookkeeping after every background task has settled. */
|
|
8
8
|
export type RunPhase = 'foreground' | 'background' | 'done';
|
|
9
|
-
/** Opaque label identifying one attempt of the fallback chain, e.g. `model/mode`.
|
|
10
|
-
* The plan sketches `run_fallback` with this type but does not define it; declared here so the
|
|
11
|
-
* event union is self-contained until `domain/runs/run.ts` owns the real shape. */
|
|
12
|
-
export type AttemptLabel = string;
|
|
13
9
|
/** The one event union every run produces. Passthrough kinds keep the exact field names of the
|
|
14
10
|
* `NormalizedEvent` member they translate from and add a `phase` tag; the remaining kinds are the
|
|
15
|
-
* run's own vocabulary (dialogs, injections, accounting,
|
|
11
|
+
* run's own vocabulary (dialogs, injections, accounting, terminal results). */
|
|
16
12
|
export type RunEvent = {
|
|
17
13
|
type: 'engine_started';
|
|
18
14
|
backendSessionId: string;
|
|
@@ -36,6 +32,16 @@ export type RunEvent = {
|
|
|
36
32
|
text: string;
|
|
37
33
|
blockId: string;
|
|
38
34
|
phase: RunPhase;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'assistant_thinking';
|
|
37
|
+
text: string;
|
|
38
|
+
blockId?: string;
|
|
39
|
+
phase: RunPhase;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'assistant_thinking_delta';
|
|
42
|
+
text: string;
|
|
43
|
+
blockId: string;
|
|
44
|
+
phase: RunPhase;
|
|
39
45
|
} | {
|
|
40
46
|
type: 'tool_use';
|
|
41
47
|
toolUseId: string;
|
|
@@ -57,6 +63,10 @@ export type RunEvent = {
|
|
|
57
63
|
toolUseId: string;
|
|
58
64
|
snapshot: TodoSnapshot;
|
|
59
65
|
phase: RunPhase;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'background_wake';
|
|
68
|
+
summaries: string[];
|
|
69
|
+
phase: RunPhase;
|
|
60
70
|
} | ({
|
|
61
71
|
type: 'context_usage';
|
|
62
72
|
phase: RunPhase;
|
|
@@ -124,11 +134,6 @@ export type RunEvent = {
|
|
|
124
134
|
} | {
|
|
125
135
|
type: 'turn_progress';
|
|
126
136
|
numTurns: number;
|
|
127
|
-
} | {
|
|
128
|
-
type: 'run_fallback';
|
|
129
|
-
from: AttemptLabel;
|
|
130
|
-
to: AttemptLabel;
|
|
131
|
-
reason: 'rate-limited' | 'transport-error';
|
|
132
137
|
} | {
|
|
133
138
|
type: 'foreground_result';
|
|
134
139
|
result: AgentResult;
|
|
@@ -3,6 +3,7 @@ import type { NormalizedEvent, ToolUseSubagent } from './normalize/event-types.j
|
|
|
3
3
|
import type { AwaitBackground } from './continuation-phase.js';
|
|
4
4
|
import type { RunEvent } from './run-events.js';
|
|
5
5
|
import type { AgentResult, ContextUsage, ToolResultImage } from '../core/types/agent-types.js';
|
|
6
|
+
import type { EngineSelection } from '../domain/agents/engine-selection.js';
|
|
6
7
|
import type { Backend } from '../core/types/agent-types.js';
|
|
7
8
|
export type { Backend };
|
|
8
9
|
export type McpComposition = 'direct' | 'none';
|
|
@@ -29,7 +30,8 @@ export interface RateLimitOrigin {
|
|
|
29
30
|
export type RateLimitReporter = (info: RateLimitObservation, origin: RateLimitOrigin) => Promise<void>;
|
|
30
31
|
/** Cortex execution context surfaced to child processes as CORTEX_* env vars. */
|
|
31
32
|
export interface CortexContextEnv {
|
|
32
|
-
|
|
33
|
+
/** The actual selected attempt, not the request's original selection. */
|
|
34
|
+
selection?: EngineSelection;
|
|
33
35
|
project?: string | null;
|
|
34
36
|
/** Stable Cortex tracking id (decoupled from the backend `sessionId`). Surfaced as
|
|
35
37
|
* CORTEX_SESSION_ID so session-activity logs + MCP context tools key on the stable UI-facing
|
|
@@ -55,7 +57,7 @@ export interface EngineSpec {
|
|
|
55
57
|
id?: string;
|
|
56
58
|
provider?: string;
|
|
57
59
|
thinking?: string;
|
|
58
|
-
|
|
60
|
+
benchmarkMaxOutputTokens?: number;
|
|
59
61
|
};
|
|
60
62
|
prompt: {
|
|
61
63
|
system?: string;
|
|
@@ -77,7 +79,6 @@ export interface EngineSpec {
|
|
|
77
79
|
servers?: McpServerConfig[];
|
|
78
80
|
allowlist?: string[];
|
|
79
81
|
configPaths?: string[];
|
|
80
|
-
browserCdpEndpoint?: string;
|
|
81
82
|
};
|
|
82
83
|
env: {
|
|
83
84
|
sets?: Record<string, string>;
|
|
@@ -110,7 +111,6 @@ export interface EngineSpec {
|
|
|
110
111
|
callbackSource?: string;
|
|
111
112
|
scheduleTaskId?: string;
|
|
112
113
|
};
|
|
113
|
-
extraOption?: Record<string, string>;
|
|
114
114
|
backend: {
|
|
115
115
|
kind: 'claude';
|
|
116
116
|
claudeAgent?: string;
|
|
@@ -175,6 +175,11 @@ export interface SpawnedAgentProcess {
|
|
|
175
175
|
supervision?: AgentProcessSupervision;
|
|
176
176
|
}
|
|
177
177
|
export type AgentProcessSpawner = (command: string, args: string[], options: SpawnOptionsWithoutStdio) => SpawnedAgentProcess;
|
|
178
|
+
/** What re-invoked the model when a background turn was opened by finished background work:
|
|
179
|
+
* the summaries of the task notifications the CLI delivered. */
|
|
180
|
+
export interface BackgroundWake {
|
|
181
|
+
summaries: string[];
|
|
182
|
+
}
|
|
178
183
|
/**
|
|
179
184
|
* Where a BACKGROUND TURN reports itself: a turn the backend opened on its own, with no caller
|
|
180
185
|
* awaiting it — a finished `run_in_background` task making the CLI re-invoke the model, or an
|
|
@@ -188,11 +193,14 @@ export type AgentProcessSpawner = (command: string, args: string[], options: Spa
|
|
|
188
193
|
*/
|
|
189
194
|
export interface BackgroundTurnSink {
|
|
190
195
|
/** Optional: the continuation turn has opened (first assistant line arrived). The wait is over;
|
|
191
|
-
* holders pause their grace/max-wait watchdogs until `onResult` reports what remains.
|
|
192
|
-
|
|
196
|
+
* holders pause their grace/max-wait watchdogs until `onResult` reports what remains. `wake` is
|
|
197
|
+
* set when finished background tasks opened the turn, and absent when an injected message did
|
|
198
|
+
* (that message already has its own transcript row). */
|
|
199
|
+
onTurnOpen?: (wake?: BackgroundWake) => void;
|
|
193
200
|
/** Assistant text from the continuation turn (append to the original reply). `subagent` is set
|
|
194
201
|
* only when a native subagent produced it (see ToolUseSubagent). */
|
|
195
202
|
onAssistantText: (text: string, model?: string | null, subagent?: ToolUseSubagent) => void;
|
|
203
|
+
onAssistantThinking?: (text: string, blockId?: string) => void;
|
|
196
204
|
/** Optional tool_use trace from the continuation turn, preserving its correlation id and,
|
|
197
205
|
* when a native subagent made the call, its attribution. */
|
|
198
206
|
onToolUse?: (name: string, input: any, toolUseId?: string, subagent?: ToolUseSubagent) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"telemetryEndpoint":"https://telemetry.fangxm.me/v1/batch"}
|