@cortex-agent/server 2026.10.15 → 2026.10.21
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 +76 -50
- 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/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/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/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/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 +3 -2
- package/dist/agent-adapter/claude/turn-machine.js +21 -68
- 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.js +3 -0
- 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 +11 -10
- package/dist/agent-adapter/run-events.js +2 -0
- package/dist/agent-adapter/types.d.ts +5 -4
- package/dist/client-bundle/manifest.json +2 -2
- package/dist/core/codex-quota.d.ts +1 -1
- package/dist/core/codex-quota.js +1 -1
- package/dist/core/gateway-generator.d.ts +9 -11
- package/dist/core/gateway-generator.js +31 -58
- package/dist/core/locales/en.d.ts +51 -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 +8 -19
- package/dist/core/locales/slices/init.js +17 -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/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 +25 -0
- package/dist/core/settings-spec.js +34 -0
- package/dist/core/status-format.d.ts +3 -2
- package/dist/core/status-format.js +2 -2
- package/dist/core/types/environment-types.d.ts +0 -2
- 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 +2 -1
- package/dist/domain/agents/environments/resolve.js +0 -1
- package/dist/domain/agents/environments/schema.d.ts +0 -1
- package/dist/domain/agents/environments/schema.js +0 -1
- 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/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 -6
- package/dist/domain/mcp/tools/context.js +17 -3
- package/dist/domain/mcp/tools/subagent.js +1 -1
- package/dist/domain/mcp/tools/ui-file.js +1 -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/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 +0 -17
- package/dist/domain/runs/run.d.ts +12 -42
- package/dist/domain/runs/run.js +40 -147
- package/dist/domain/runs/service.d.ts +1 -1
- package/dist/domain/runs/service.js +8 -3
- 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/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 +22 -21
- 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/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/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 +49 -71
- package/dist/domain/ui-service/app-router.js +9 -13
- 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 +52 -115
- package/dist/domain/ui-service/input-schemas.js +38 -84
- 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/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/query/config.js +22 -42
- package/dist/domain/ui-service/query/models.js +2 -2
- package/dist/domain/ui-service/query/schedules.js +1 -1
- package/dist/domain/ui-service/query/sessions.js +7 -13
- package/dist/domain/ui-service/types.d.ts +51 -177
- package/dist/domain/ui-service/ui-service.d.ts +23 -49
- package/dist/domain/ui-service/ui-service.js +8 -6
- package/dist/entry/app.js +42 -19
- 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 +37 -6
- package/dist/entry/cli.js +16 -14
- package/dist/entry/daemon.js +2 -0
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init.d.ts +7 -8
- package/dist/entry/init.js +89 -249
- 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 +8 -1
- package/dist/entry/start-ui-http.js +8 -0
- package/dist/entry/ui-service-wiring.js +8 -10
- package/dist/events/event-types.d.ts +3 -2
- 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/webhook.js +4 -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 +6 -0
- package/dist/orchestration/transcript-sink.js +21 -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/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-http-server.d.ts +12 -0
- package/dist/platform/ui-http/ui-http-server.js +23 -6
- 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/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 +48 -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 +2 -3
- package/dist/store/version-migrations.js +19 -3
- 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-CB4GJ6qO.js +2 -0
- package/web/dist/assets/index-CaSZPg_H.css +1 -0
- package/web/dist/assets/index-CzOR7Edh.js +522 -0
- package/web/dist/assets/{index-CndZZ1IQ.js → index-cIGFv27z.js} +1 -1
- package/web/dist/index.html +3 -2
- package/web/dist/theme.css +6 -0
- package/dist/agent-adapter/browser-mcp-server.d.ts +0 -13
- package/dist/agent-adapter/browser-mcp-server.js +0 -28
- package/dist/agent-adapter/claude/browser-mcp.d.ts +0 -9
- package/dist/agent-adapter/claude/browser-mcp.js +0 -10
- package/dist/core/profile-generator.d.ts +0 -79
- package/dist/core/profile-generator.js +0 -215
- package/dist/domain/agents/profile-manager.d.ts +0 -103
- package/dist/domain/agents/profile-manager.js +0 -286
- package/dist/domain/agents/profile-switch.d.ts +0 -49
- package/dist/domain/agents/profile-switch.js +0 -62
- package/dist/domain/ui-service/mutate/profiles.d.ts +0 -36
- package/dist/domain/ui-service/mutate/profiles.js +0 -151
- package/dist/store/profile-repo.d.ts +0 -20
- package/dist/store/profile-repo.js +0 -97
- package/web/dist/assets/index-B76ueW3q.js +0 -494
- package/web/dist/assets/index-C8O0yxg8.css +0 -1
|
@@ -13,11 +13,23 @@ function positiveInt(value, fallback) {
|
|
|
13
13
|
* Build the tool context from the environment a stdio MCP entry was spawned with. Throws for an
|
|
14
14
|
* unparsable or unknown tool allowlist so a misconfigured server refuses to start.
|
|
15
15
|
*/
|
|
16
|
+
function selectionFromEnv(env) {
|
|
17
|
+
const backend = env.CORTEX_BACKEND;
|
|
18
|
+
const model = optional(env.CORTEX_MODEL);
|
|
19
|
+
if ((backend !== 'claude' && backend !== 'pi') || !model)
|
|
20
|
+
return null;
|
|
21
|
+
return {
|
|
22
|
+
backend, model,
|
|
23
|
+
provider: backend === 'pi' ? optional(env.CORTEX_PROVIDER) : null,
|
|
24
|
+
thinking: optional(env.CORTEX_THINKING),
|
|
25
|
+
mode: env.CORTEX_MODE ?? '',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
16
28
|
export function toolContextFromEnv(env = process.env) {
|
|
17
29
|
return {
|
|
18
30
|
channel: optional(env.SLACK_CHANNEL) ?? optional(env.FEISHU_CHANNEL),
|
|
19
31
|
sessionId: optional(env.CORTEX_SESSION_ID),
|
|
20
|
-
|
|
32
|
+
selection: selectionFromEnv(env),
|
|
21
33
|
project: optional(env.CORTEX_PROJECT),
|
|
22
34
|
backend: optional(env.CORTEX_BACKEND),
|
|
23
35
|
claudeModel: optional(env.CORTEX_CLAUDE_MODEL),
|
|
@@ -61,7 +73,9 @@ export async function resolveCortexContext(ctx, findBoard = lookupBoard) {
|
|
|
61
73
|
const scope = {
|
|
62
74
|
channel: ctx.channel,
|
|
63
75
|
sessionId: ctx.sessionId,
|
|
64
|
-
|
|
76
|
+
model: ctx.selection?.model ?? null,
|
|
77
|
+
thinking: ctx.selection?.thinking ?? null,
|
|
78
|
+
mode: ctx.selection?.mode ?? null,
|
|
65
79
|
project: ctx.project,
|
|
66
80
|
backend: ctx.backend,
|
|
67
81
|
scheduleTaskId: ctx.scheduleTaskId,
|
|
@@ -79,7 +93,7 @@ export async function resolveCortexContext(ctx, findBoard = lookupBoard) {
|
|
|
79
93
|
return scope;
|
|
80
94
|
}
|
|
81
95
|
export function registerContextTools(server, ctx) {
|
|
82
|
-
server.tool('cortex_context', 'Get current session identity,
|
|
96
|
+
server.tool('cortex_context', 'Get current session identity, backend, model, thinking, mode, project, bound board and trigger context.', {}, { readOnlyHint: true }, async () => {
|
|
83
97
|
try {
|
|
84
98
|
const ctxInternal = await resolveCortexContext(ctx);
|
|
85
99
|
// Strip channel from public response — consumers address by project/sessionId.
|
|
@@ -148,7 +148,7 @@ export function registerSubagentTools(server, ctx) {
|
|
|
148
148
|
background: !!background,
|
|
149
149
|
cwd: process.cwd(),
|
|
150
150
|
// The parent's own scope: it decides where children run and what routing they inherit.
|
|
151
|
-
|
|
151
|
+
selection: ctx.selection,
|
|
152
152
|
project: ctx.project,
|
|
153
153
|
channel: ctx.channel,
|
|
154
154
|
backend: ctx.backend,
|
|
@@ -50,7 +50,7 @@ async function sendFiles(ctx, input) {
|
|
|
50
50
|
return sentSummary(Array.isArray(body.data) ? body.data : [body.data], input.device);
|
|
51
51
|
}
|
|
52
52
|
export function registerUiFileTools(server, ctx) {
|
|
53
|
-
server.tool('send_file', 'Share produced files as downloadable chat cards (images preview inline). Send one file or an ordered group with a shared caption. Supports local or remote-device files.', {
|
|
53
|
+
server.tool('send_file', 'Share produced files as downloadable chat cards (images preview inline). Send one file or an ordered group with a shared caption. Supports local or remote-device files. Embed images or videos in reply text with , using a local absolute/~/relative path, workspace/... path, registered-device:/absolute/path (or device:C:/path on Windows), or https:// URL.', {
|
|
54
54
|
file_path: z.string().optional().describe(`${FILE_PATH_DESC} Use this OR \`files\`.`),
|
|
55
55
|
file_name: z.string().optional().describe('Display filename override for file_path.'),
|
|
56
56
|
files: z.array(z.object({
|
|
@@ -21,7 +21,7 @@ export interface CustomProviderInput {
|
|
|
21
21
|
compat?: Record<string, unknown>;
|
|
22
22
|
}
|
|
23
23
|
export type CustomProviderIssue = 'name-required' | 'name-charset' | 'api-invalid' | 'upstream-required' | 'upstream-scheme' | 'models-required' | 'model-id-required' | 'model-id-duplicate';
|
|
24
|
-
/**
|
|
24
|
+
/** Safe provider names used by the model selection and gateway endpoints. */
|
|
25
25
|
export declare const CUSTOM_PROVIDER_NAME_RE: RegExp;
|
|
26
26
|
/**
|
|
27
27
|
* Written as the PI-side `apiKey` so PI counts the provider as authenticated and lists its models.
|
|
@@ -5,7 +5,7 @@ export const CUSTOM_PROVIDER_APIS = [
|
|
|
5
5
|
'openai-responses',
|
|
6
6
|
'google-generative-ai',
|
|
7
7
|
];
|
|
8
|
-
/**
|
|
8
|
+
/** Safe provider names used by the model selection and gateway endpoints. */
|
|
9
9
|
export const CUSTOM_PROVIDER_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
10
10
|
/**
|
|
11
11
|
* Written as the PI-side `apiKey` so PI counts the provider as authenticated and lists its models.
|
|
@@ -13,7 +13,7 @@ const log = createLogger('device-browser');
|
|
|
13
13
|
* channel maps it onto a loopback port here.
|
|
14
14
|
*/
|
|
15
15
|
/** Chrome's own startup, plus the device round trip. Generous: a cold Chrome on a busy laptop is
|
|
16
|
-
* slow, and the alternative to waiting is a
|
|
16
|
+
* slow, and the alternative to waiting is a failed `cortex-browser` call. */
|
|
17
17
|
const LAUNCH_TIMEOUT_MS = 90_000;
|
|
18
18
|
/** One HTTP GET through the tunnel. If this is slow, the tunnel is broken, not the browser. */
|
|
19
19
|
const VERIFY_TIMEOUT_MS = 5_000;
|
|
@@ -82,6 +82,8 @@ function unixChromeLaunchCommand(platform) {
|
|
|
82
82
|
'[ -n "$CHROME" ] || { echo "chrome-not-found" >&2; exit 3; }',
|
|
83
83
|
'nohup "$CHROME" --remote-debugging-port=0 --remote-debugging-address=127.0.0.1'
|
|
84
84
|
+ ' --user-data-dir="$PROFILE" --no-first-run --no-default-browser-check'
|
|
85
|
+
// Linux only (macOS ignores it): skip the keyring D-Bus probe that stalls the first page ~25s.
|
|
86
|
+
+ ' --password-store=basic'
|
|
85
87
|
+ ' about:blank >/dev/null 2>&1 &',
|
|
86
88
|
'for _ in $(seq 1 60); do [ -s "$PORTFILE" ] && break; sleep 0.5; done',
|
|
87
89
|
'[ -s "$PORTFILE" ] || { echo "chrome-did-not-listen" >&2; exit 4; }', 'head -1 "$PORTFILE"',
|
|
@@ -4,8 +4,8 @@ import { requestStream } from './reverse-stream.js';
|
|
|
4
4
|
import { sendControlMessage } from './client-manager.js';
|
|
5
5
|
const log = createLogger('device-port');
|
|
6
6
|
/**
|
|
7
|
-
* Why a real local socket at all (plan/embedded-browser.md §18.1): the consumer is
|
|
8
|
-
* which takes a `--cdp
|
|
7
|
+
* Why a real local socket at all (plan/embedded-browser.md §18.1): the consumer is agent-browser,
|
|
8
|
+
* which takes a `--cdp` URL, does `GET /json/version`, then opens a WebSocket. It needs
|
|
9
9
|
* something it can dial. So the server binds a loopback port and every byte written to it comes
|
|
10
10
|
* out of a TCP connection on the device — no CDP awareness anywhere in the path, which is what
|
|
11
11
|
* makes the same tunnel serve TensorBoard, Jupyter and dashboards for free.
|
|
@@ -3,13 +3,13 @@ import type { Backend, EngineRun, EngineSession, EngineSpec } from '../../agent-
|
|
|
3
3
|
import type { RunEvent } from '../../agent-adapter/run-events.js';
|
|
4
4
|
import type { EventObserver } from '../../agent-adapter/normalize/event-types.js';
|
|
5
5
|
import type { ModeEnv } from './mode-env.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
7
7
|
import type { RunRequest } from './request.js';
|
|
8
8
|
import { type ProductionAttemptIdentityRecord } from '../benchmark/production-attempt-identity.js';
|
|
9
9
|
export interface StartAttemptInput {
|
|
10
10
|
request: RunRequest;
|
|
11
|
-
/**
|
|
12
|
-
attempt:
|
|
11
|
+
/** The engine selection this run executes. */
|
|
12
|
+
attempt: EngineSelection;
|
|
13
13
|
/** The execution record the attempt is billed and attested under. */
|
|
14
14
|
executionId: string | null;
|
|
15
15
|
/** The resolved mode route (base URL + credentials) for this attempt. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// A run
|
|
3
|
-
// THIS is one link of that chain: acquire the pooled engine session for the spec, open a run on it,
|
|
2
|
+
// A run opens one attempt: acquire the pooled engine session for the selection, open a run on it,
|
|
4
3
|
// and hand back the stream plus the two results a caller can await. Everything downstream of
|
|
5
4
|
// `engine.run()` — the background phase, the watchdog, when the run is really over — belongs to the
|
|
6
5
|
// engine, so this module is wiring plus the two things that must happen per attempt and nowhere
|
|
@@ -158,7 +157,7 @@ export function startAttempt(input) {
|
|
|
158
157
|
const spec = buildEngineSpec(request, attempt, { route, executionId });
|
|
159
158
|
const identity = freezeProductionAttemptIdentity({
|
|
160
159
|
adapterBackend: attempt.backend, spec, request, executionId,
|
|
161
|
-
|
|
160
|
+
selection: request.selection,
|
|
162
161
|
});
|
|
163
162
|
const journal = identity
|
|
164
163
|
? createProductionAttemptJournalSink({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
2
2
|
import type { RunRequest } from './request.js';
|
|
3
3
|
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
4
|
-
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on,
|
|
5
|
-
* direct MCP surface
|
|
4
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, and
|
|
5
|
+
* the direct MCP surface.
|
|
6
6
|
*
|
|
7
7
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
8
8
|
* to, `captureTranscriptLogs` defaults to ON, and only a frozen subagent child opts out.
|
|
@@ -14,7 +14,7 @@ export interface ContinuationRunOptions {
|
|
|
14
14
|
/** Ids the caller already resolved: the Cortex track id, the backend resume target, the engine
|
|
15
15
|
* pool key and the display name. */
|
|
16
16
|
session: RunRequest['session'];
|
|
17
|
-
|
|
17
|
+
selection: EngineSelection;
|
|
18
18
|
/** Prompt text; continuation runs never carry attachments. */
|
|
19
19
|
prompt: string;
|
|
20
20
|
channel: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A continuation run forwards one prompt into a session whose live engine it does not share: the
|
|
2
2
|
// onNew hook's pre-close turn, which resumes the old session on its own isolated pool key. It runs
|
|
3
3
|
// on a bare spec (`bareSpec()` — no agent identity), the direct-run policy and a machine-driven
|
|
4
|
-
// context; only the session ids, the
|
|
4
|
+
// context; only the session ids, the selection and the trigger differ.
|
|
5
5
|
//
|
|
6
6
|
// A turn on a session's LIVE engine must not use it: the pool compares the spec identity and would
|
|
7
7
|
// respawn the process. Those turns build their request the way a user turn does
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
10
|
import { bareSpec } from './spec-loader.js';
|
|
11
11
|
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
12
|
-
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on,
|
|
13
|
-
* direct MCP surface
|
|
12
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, and
|
|
13
|
+
* the direct MCP surface.
|
|
14
14
|
*
|
|
15
15
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
16
16
|
* to, `captureTranscriptLogs` defaults to ON, and only a frozen subagent child opts out.
|
|
@@ -23,7 +23,6 @@ export const DIRECT_RUN_POLICY = {
|
|
|
23
23
|
hooks: true,
|
|
24
24
|
loadRules: true,
|
|
25
25
|
mcpComposition: 'direct',
|
|
26
|
-
browserCdpEndpoint: null,
|
|
27
26
|
captureTranscripts: true,
|
|
28
27
|
};
|
|
29
28
|
/** Build the `RunRequest` for a continuation run. Every field not named in `o` is the shared
|
|
@@ -32,7 +31,7 @@ export function continuationRunRequest(o) {
|
|
|
32
31
|
return {
|
|
33
32
|
runId: randomUUID(),
|
|
34
33
|
session: o.session,
|
|
35
|
-
|
|
34
|
+
selection: o.selection,
|
|
36
35
|
spec: bareSpec(),
|
|
37
36
|
prompt: { text: o.prompt, attachments: [] },
|
|
38
37
|
context: {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import type { Backend, EngineSession, EngineSpec } from '../../agent-adapter/types.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Backend, EngineSession, EngineSpec, AgentCompactResult } from '../../agent-adapter/types.js';
|
|
2
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
3
3
|
import type { ModeEnv } from './mode-env.js';
|
|
4
|
-
import { type ResolvedProfileConfig, type RunAttemptConfig } from '../agents/profile-manager.js';
|
|
5
4
|
import type { RunRequest } from './request.js';
|
|
6
|
-
/** What compaction runs against. */
|
|
7
5
|
export interface CompactAgentTarget {
|
|
8
|
-
/** The request the session's next turn would run under, prompt aside. The pool hands back the
|
|
9
|
-
* session's live engine only for a request that asks for it exactly. */
|
|
10
6
|
request: RunRequest;
|
|
11
|
-
/** The session's backend; a profile that would run another one is refused. */
|
|
12
7
|
backend: Backend;
|
|
13
8
|
}
|
|
14
9
|
interface CompactCostEntry {
|
|
@@ -24,20 +19,12 @@ interface CompactCostEntry {
|
|
|
24
19
|
model?: string;
|
|
25
20
|
}
|
|
26
21
|
export interface CompactAgentDeps {
|
|
27
|
-
/** The pooled session for the spec. Compaction runs on it and leaves it pooled — it is the same
|
|
28
|
-
* session the channel's next turn will resume into, not a throwaway process. */
|
|
29
22
|
acquireEngine: (spec: EngineSpec) => EngineSession;
|
|
30
|
-
|
|
31
|
-
isPooled: (spec: EngineSpec) => boolean;
|
|
32
|
-
/** The route the run would open this attempt of the request under. */
|
|
33
|
-
route: (request: RunRequest, attempt: RunAttemptConfig) => ModeEnv;
|
|
23
|
+
route: (request: RunRequest, selection: EngineSelection) => ModeEnv;
|
|
34
24
|
recordCost: (entry: CompactCostEntry) => Promise<void>;
|
|
35
25
|
}
|
|
36
|
-
/** The cheap gate a surface asks before offering compaction, on the profile the registry recorded.
|
|
37
|
-
* `compactAgentContext` checks the profile the session's turns actually resolve to. */
|
|
38
26
|
export declare function isSessionCompactionSupported(session: {
|
|
39
27
|
backend: string;
|
|
40
|
-
|
|
41
|
-
}, resolve?: (profileName: string | null) => ResolvedProfileConfig): boolean;
|
|
28
|
+
}): boolean;
|
|
42
29
|
export declare function compactAgentContext(target: CompactAgentTarget, deps?: CompactAgentDeps): Promise<AgentCompactResult>;
|
|
43
30
|
export {};
|
|
@@ -1,84 +1,42 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Compaction is not a run: nothing is asked, no turn is opened, no attempt chain is walked. It is a
|
|
3
|
-
// command sent to the engine session a channel is already resuming into — which is why it runs on
|
|
4
|
-
// the POOLED session and leaves it pooled, rather than spawning a throwaway that would discard the
|
|
5
|
-
// warmed process the next turn wants. That session is whichever attempt of the profile the last
|
|
6
|
-
// turn ran on: a turn the primary could not serve leaves a fallback's engine live.
|
|
7
1
|
import { recordCost } from '../costs/cost-tracker.js';
|
|
8
|
-
import { resolveProfileConfig, } from '../agents/profile-manager.js';
|
|
9
2
|
import { engines } from './engines.js';
|
|
10
3
|
import { buildEngineSpec } from './engine-spec.js';
|
|
11
4
|
import { requestRoute } from './config-resolver.js';
|
|
12
|
-
import { planAttempts } from './fallback.js';
|
|
13
5
|
const compactAgentDeps = {
|
|
14
6
|
acquireEngine: (spec) => engines.acquire(spec),
|
|
15
|
-
isPooled: (spec) => engines.reuses(spec),
|
|
16
7
|
route: requestRoute,
|
|
17
8
|
recordCost,
|
|
18
9
|
};
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
return profile.backend === backend && (backend === 'claude' || backend === 'pi');
|
|
10
|
+
export function isSessionCompactionSupported(session) {
|
|
11
|
+
return session.backend === 'claude' || session.backend === 'pi';
|
|
22
12
|
}
|
|
23
|
-
|
|
24
|
-
* `compactAgentContext` checks the profile the session's turns actually resolve to. */
|
|
25
|
-
export function isSessionCompactionSupported(session, resolve = resolveProfileConfig) {
|
|
26
|
-
try {
|
|
27
|
-
return supportsCompactProfile(session.backend, resolve(session.profileName));
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function compactCostEntry(target, attempt, result) {
|
|
13
|
+
function compactCostEntry(target, result) {
|
|
34
14
|
if (!result.usage)
|
|
35
15
|
return null;
|
|
36
|
-
const { context } = target.request;
|
|
16
|
+
const { context, selection } = target.request;
|
|
37
17
|
return {
|
|
38
18
|
project: context.project,
|
|
39
19
|
trigger: context.trigger,
|
|
40
20
|
cost_usd: result.usage.costUsd,
|
|
41
21
|
backend: target.backend,
|
|
42
|
-
mode:
|
|
22
|
+
mode: selection.mode,
|
|
43
23
|
source: 'estimate',
|
|
44
24
|
input_tokens: result.usage.inputTokens,
|
|
45
25
|
output_tokens: result.usage.outputTokens,
|
|
46
|
-
...(
|
|
47
|
-
|
|
26
|
+
...(selection.provider ? { provider: selection.provider } : {}),
|
|
27
|
+
model: selection.model,
|
|
48
28
|
};
|
|
49
29
|
}
|
|
50
|
-
/** The engine spec of the attempt whose engine is live — the primary's when none is. Only attempts
|
|
51
|
-
* on the session's backend count: an engine of another backend holds another conversation. Every
|
|
52
|
-
* attempt is asked for with the session's resume target: a fallback's turn started a fresh
|
|
53
|
-
* conversation and the session recorded its id, so that target names the live engine's transcript
|
|
54
|
-
* whichever attempt opened it. */
|
|
55
|
-
function liveAttemptSpec(target, deps) {
|
|
56
|
-
const { request, backend } = target;
|
|
57
|
-
const specOf = (attempt) => ({
|
|
58
|
-
attempt, spec: buildEngineSpec(request, attempt, { route: deps.route(request, attempt) }),
|
|
59
|
-
});
|
|
60
|
-
const [primary, ...fallbacks] = planAttempts(request.profile);
|
|
61
|
-
const first = specOf(primary);
|
|
62
|
-
if (deps.isPooled(first.spec))
|
|
63
|
-
return first;
|
|
64
|
-
for (const attempt of fallbacks) {
|
|
65
|
-
if (attempt.backend !== backend)
|
|
66
|
-
continue;
|
|
67
|
-
const candidate = specOf(attempt);
|
|
68
|
-
if (deps.isPooled(candidate.spec))
|
|
69
|
-
return candidate;
|
|
70
|
-
}
|
|
71
|
-
return first;
|
|
72
|
-
}
|
|
73
30
|
export async function compactAgentContext(target, deps = compactAgentDeps) {
|
|
74
31
|
const { request, backend } = target;
|
|
75
|
-
if (!
|
|
76
|
-
throw new Error(`${backend}
|
|
32
|
+
if (!isSessionCompactionSupported(target) || request.selection.backend !== backend) {
|
|
33
|
+
throw new Error(`${backend} selection does not support manual context compaction`);
|
|
77
34
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
35
|
+
const spec = buildEngineSpec(request, request.selection, {
|
|
36
|
+
route: deps.route(request, request.selection),
|
|
37
|
+
});
|
|
38
|
+
const result = await deps.acquireEngine(spec).compact();
|
|
39
|
+
const cost = compactCostEntry(target, result);
|
|
82
40
|
if (cost)
|
|
83
41
|
await deps.recordCost(cost);
|
|
84
42
|
return result;
|
|
@@ -1,94 +1,26 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Session } from '../../store/session-registry-repo.js';
|
|
2
|
+
import type { EngineSelection } from '../agents/engine-selection.js';
|
|
2
3
|
import { type ModeEnv } from './mode-env.js';
|
|
3
|
-
import { type ResolvedProfileConfig, type RunAttemptConfig } from '../agents/profile-manager.js';
|
|
4
4
|
import type { RunRequest } from './request.js';
|
|
5
|
-
export interface
|
|
6
|
-
/** Conduit the run belongs to. Absent for runs with no channel (a scheduled job's first turn). */
|
|
5
|
+
export interface RunSelectionQuery {
|
|
7
6
|
channel?: string | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* has since moved on. */
|
|
11
|
-
session?: {
|
|
12
|
-
profileName?: string | null;
|
|
13
|
-
} | null;
|
|
14
|
-
/** A profile the caller was handed explicitly — a thread agent's `profile`, a step's override.
|
|
15
|
-
* Highest priority, and deliberately NOT validated here: an unknown name must reach the run so
|
|
16
|
-
* the run rejects it, after the execution record exists. */
|
|
17
|
-
override?: string | null;
|
|
7
|
+
session?: Partial<Pick<Session, 'selection' | 'backend' | 'sessionId' | 'backendSessionId'>> | null;
|
|
8
|
+
selection?: EngineSelection | null;
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
override: ChannelOverride | null;
|
|
27
|
-
/** `!model` for this channel, to be layered on top of `profile.model`. null is the normal case.
|
|
28
|
-
* Kept as its own field because the model is the one override with a display of its own
|
|
29
|
-
* (`!model` prints "profile says X, this channel was told Y"). */
|
|
30
|
-
modelOverride: string | null;
|
|
31
|
-
/** False when `profileName` names no profile in profiles.json. The caller still gets a profile
|
|
32
|
-
* so it can open an execution record with a truthful backend, and still has the bad name to
|
|
33
|
-
* fail on. Callers that simply want to run should treat false as an error. */
|
|
34
|
-
resolved: boolean;
|
|
35
|
-
}
|
|
36
|
-
/** Startup and login exist before a first profile. Only a missing file is unconfigured. */
|
|
37
|
-
export declare function resolveConfiguredDefaultRun(): ResolvedRunConfig | null;
|
|
38
|
-
/**
|
|
39
|
-
* The profile name for a run, by D5's priority: explicit override → the session's recorded
|
|
40
|
-
* profile → the channel's profile → the global active profile → profiles.defaultProfile.
|
|
41
|
-
*
|
|
42
|
-
* `getActiveProfile(channel)` already folds the middle two together (and resolves init's
|
|
43
|
-
* `'__active__'` placeholder), so only the ends are added here.
|
|
44
|
-
*/
|
|
45
|
-
export declare function resolveProfileName(query?: RunConfigQuery): string;
|
|
46
|
-
/**
|
|
47
|
-
* Resolve everything a run needs to know about its configuration, in one place.
|
|
48
|
-
*
|
|
49
|
-
* Backend, model, provider, mode, thinking and the fallback chain come from the profile and only
|
|
50
|
-
* from the profile (D5). The single exception is the channel's `!model` override, returned
|
|
51
|
-
* separately rather than folded in so a caller can tell "the profile says X" from "this channel
|
|
52
|
-
* was told to use Y" — the run applies it, the display distinguishes them.
|
|
53
|
-
*/
|
|
54
|
-
export declare function resolveRunConfig(query?: RunConfigQuery): ResolvedRunConfig;
|
|
55
|
-
/**
|
|
56
|
-
* The Anthropic route (base URL + credentials) one attempt runs under. Per attempt, because a
|
|
57
|
-
* fallback may be a different mode entirely, and per run because the project/trigger it carries
|
|
58
|
-
* select the gateway's account: resolving this never writes a daemon global (K-053), the value
|
|
59
|
-
* reaches exactly the one child env it was resolved for.
|
|
60
|
-
*/
|
|
61
|
-
export declare function resolveRunRoute(attempt: {
|
|
62
|
-
mode?: RunAttemptConfig['mode'];
|
|
10
|
+
/** Explicit request > recorded session > channel > configured default. No overlays. */
|
|
11
|
+
export declare function resolveRunSelection(query?: RunSelectionQuery): EngineSelection;
|
|
12
|
+
/** Startup and login can precede configuration; malformed configuration still throws. */
|
|
13
|
+
export declare function resolveConfiguredDefaultRun(): EngineSelection | null;
|
|
14
|
+
/** Resolve the route per run, never by changing the daemon's environment. */
|
|
15
|
+
export declare function resolveRunRoute(selection: {
|
|
16
|
+
mode?: EngineSelection['mode'];
|
|
63
17
|
}, context?: {
|
|
64
18
|
project?: string | null;
|
|
65
19
|
trigger?: string | null;
|
|
66
20
|
}): ModeEnv;
|
|
67
|
-
/** The route one attempt of `request` runs under — the run's own choice, and what a command on the
|
|
68
|
-
* same engine has to ask for to be handed that engine. */
|
|
69
21
|
export declare function requestRoute(request: {
|
|
70
22
|
context: Pick<RunRequest['context'], 'project' | 'trigger' | 'routeTrigger'>;
|
|
71
|
-
},
|
|
72
|
-
mode?:
|
|
23
|
+
}, selection: {
|
|
24
|
+
mode?: EngineSelection['mode'];
|
|
73
25
|
}): ModeEnv;
|
|
74
|
-
|
|
75
|
-
export declare function resolveRunBackend(query?: RunConfigQuery): ResolvedProfileConfig['backend'];
|
|
76
|
-
/**
|
|
77
|
-
* The profile a run actually executes: the resolved profile with the channel's selection
|
|
78
|
-
* (model / provider / thinking) applied to its primary attempt.
|
|
79
|
-
*
|
|
80
|
-
* What each field does:
|
|
81
|
-
* - `model` — replaces the primary model (this is `!model`, unchanged).
|
|
82
|
-
* - `mode` — which gateway route of the SAME endpoint bills the turn (anthropic `plan` vs `api`).
|
|
83
|
-
* - `provider` — PI only. It selects both the request protocol and the gateway endpoint, so the
|
|
84
|
-
* route is re-derived with it (overriding any `mode` above), and the profile's `maxOutputTokens`
|
|
85
|
-
* is dropped: that cap was stated for the profile's own model and says nothing about the one now
|
|
86
|
-
* selected.
|
|
87
|
-
* - `thinking` — replaces the level AND removes the profile's own thinking flag from extraOption,
|
|
88
|
-
* which both adapters would otherwise let win over the selection.
|
|
89
|
-
*
|
|
90
|
-
* The fallback chain is deliberately untouched. It is the profile's stated recovery path for when
|
|
91
|
-
* the primary model is unavailable, not a second model choice the user made — overriding it too
|
|
92
|
-
* would mean a selection on a rate-limited channel silently disabled the profile's own escape.
|
|
93
|
-
*/
|
|
94
|
-
export declare function effectiveProfile(config: ResolvedRunConfig): ResolvedProfileConfig;
|
|
26
|
+
export declare function resolveRunBackend(query?: RunSelectionQuery): EngineSelection['backend'];
|