@bastani/atomic 0.9.45 → 0.9.46
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/CHANGELOG.md +79 -0
- package/dist/builtin/intercom/CHANGELOG.md +22 -0
- package/dist/builtin/intercom/broker/broker.ts +124 -10
- package/dist/builtin/intercom/broker/client.ts +177 -25
- package/dist/builtin/intercom/broker/multinode-router.ts +228 -27
- package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
- package/dist/builtin/intercom/broker/recipient-receipts.ts +38 -4
- package/dist/builtin/intercom/broker/send-handler.ts +9 -2
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +29 -4
- package/dist/builtin/intercom/group.ts +25 -0
- package/dist/builtin/intercom/index.bundle.mjs +177 -35
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +7 -0
- package/dist/builtin/intercom/types.ts +21 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +152 -56
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +79 -0
- package/dist/builtin/workflows/builtin/{chunk-6901nsd6.js → chunk-6jpwc09k.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-vwx023ge.js → chunk-qhm35ntx.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-jvna28mq.js → chunk-zhyqnf5g.js} +331 -68
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +1 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +77 -0
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +7104 -3387
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +11105 -7264
- package/dist/builtin/workflows/src/index.js +6796 -3606
- package/dist/builtin/workflows/src/local-worker-entry.mjs +11105 -7264
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +19 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +1 -0
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +15 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +4 -2
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +13 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-recovery.d.ts.map +1 -1
- package/dist/core/agent-session-recovery.js +92 -1
- package/dist/core/agent-session-recovery.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +8 -1
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +5 -0
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/copilot-errors.d.ts +6 -0
- package/dist/core/copilot-errors.d.ts.map +1 -0
- package/dist/core/copilot-errors.js +17 -0
- package/dist/core/copilot-errors.js.map +1 -0
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +12 -2
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +7 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +6 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +9 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +4 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +26 -5
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +5 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/messages.d.ts +5 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +37 -3
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -2
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-runtime-streaming.js +2 -2
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +7 -3
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +19 -11
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-rate-limits.d.ts +55 -6
- package/dist/core/provider-rate-limits.d.ts.map +1 -1
- package/dist/core/provider-rate-limits.js +182 -29
- package/dist/core/provider-rate-limits.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +42 -18
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +176 -19
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/provider.d.ts +4 -2
- package/dist/core/storage/provider.d.ts.map +1 -1
- package/dist/core/storage/provider.js +94 -5
- package/dist/core/storage/provider.js.map +1 -1
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +15 -8
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/provider-failure.d.ts +17 -0
- package/dist/core/structured-output/provider-failure.d.ts.map +1 -0
- package/dist/core/structured-output/provider-failure.js +28 -0
- package/dist/core/structured-output/provider-failure.js.map +1 -0
- package/dist/core/tasks/completion.d.ts +6 -1
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +33 -18
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/pause.d.ts +2 -1
- package/dist/core/tasks/pause.d.ts.map +1 -1
- package/dist/core/tasks/pause.js +3 -2
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +13 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +6 -4
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +1 -0
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +7 -2
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +2 -1
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +5 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +38 -5
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +20 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +3 -2
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +42 -14
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +2 -1
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +10 -4
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +5 -6
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +6 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +9 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +3 -2
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +8 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +5 -0
- package/dist/utils/ansi.js.map +1 -1
- package/docs/codemode.md +1 -1
- package/docs/intercom/reference.md +3 -3
- package/docs/llama-cpp.md +25 -14
- package/docs/models/evals.md +31 -12
- package/docs/models/reference.md +23 -51
- package/docs/models.md +3 -4
- package/docs/providers.md +5 -15
- package/docs/settings.md +1 -1
- package/docs/storage.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/tui.md +2 -0
- package/docs/workflows/api-reference.md +20 -1
- package/docs/workflows/operations.md +17 -4
- package/npm-shrinkwrap.json +64 -44
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-model-router.js","sourceRoot":"","sources":["../../src/core/execution-model-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAEN,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,GAEX,MAAM,gBAAgB,CAAC;AACxB,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cAAc,EAAE,MAAM,CAAC,MAAM,CAC5B,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAC7G;QACD,aAAa;QACb,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n\ttype Api,\n\tcontainsKnownEnvCredential,\n\tgetServiceTierCost,\n\tgetSupportedThinkingLevels,\n\tisModelType,\n\ttype Model,\n} from \"@bastani/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getDocsPath } from \"../config.js\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { resolveModelScopeFromModels } from \"./model-resolver-scope.ts\";\nimport { ROUTING_REQUEST_BYTES } from \"./model-routing-bytes.js\";\nimport {\n\ttype CandidateModel,\n\tdescribeOption,\n\tdistinctTop,\n\ttype RankedCandidate,\n\trankCandidates,\n} from \"./model-routing-candidates.js\";\nimport {\n\teligiblePair,\n\ttype ModelConstraints,\n\ttype ModelRouterOutput,\n\tparseModelConstraints,\n} from \"./model-routing-constraints.js\";\nimport { reportModelRoutingDebug } from \"./model-routing-debug.js\";\nimport { parseEvalsCatalog } from \"./model-routing-evals.js\";\nimport {\n\teffortForDifficulty,\n\tmissingNeedsQuestions,\n\tparseTaskNeeds,\n\ttype ResolvedTaskNeeds,\n\tresolveTaskNeeds,\n\ttype TaskNeeds,\n} from \"./model-routing-needs.js\";\nimport type { ModelRoutingSettings } from \"./settings-types.ts\";\nimport { resolveRouterModel, routeModel } from \"./structured-output/index.js\";\n\nexport interface ModelRoutingContext {\n\treadonly modelRegistry: Pick<\n\t\tModelRegistry,\n\t\t\"getAll\" | \"getAvailable\" | \"streamSimple\" | \"containsConfiguredCredential\"\n\t> &\n\t\tPartial<Pick<ModelRegistry, \"getProviderAuthStatus\" | \"getProviderAuth\" | \"getClassifierModel\" | \"classify\">>;\n\treadonly model?: Model<Api>;\n\tgetRouterModel(): string;\n\t/** Provider and model filters from settings.json `modelRouting`; absent means every model is a candidate. */\n\tgetModelRouting?(): ModelRoutingSettings;\n\t/** The `httpIdleTimeoutMs` setting; bounds each routing inference. Absent means the setting's default. */\n\tgetHttpIdleTimeoutMs?(): number;\n}\nexport interface ModelRoute {\n\treadonly routerSelection: ModelRouterOutput;\n\treadonly modelOverride: string;\n\treadonly fallbackModels?: readonly string[];\n\tassertCurrent(): void;\n\tallowsModel(model: Model<Api>, effort?: string): boolean;\n}\n\n/**\n * Total auto-routing inference failure: Jev and the chat structured-output\n * fallback both failed before any model was selected (#3206). Validation,\n * eligibility, and credential-screening errors are never marked.\n */\nexport class AutoRoutingInferenceError extends Error {\n\t/**\n\t * Route pinned to the current chat model, present only when that model is\n\t * available and satisfies every routing constraint. Consumers may degrade\n\t * to it; when it is absent the failure stays fatal.\n\t */\n\treadonly currentModelRoute?: ModelRoute;\n\n\tconstructor(message: string, currentModelRoute?: ModelRoute) {\n\t\tsuper(message);\n\t\tthis.name = \"AutoRoutingInferenceError\";\n\t\tif (currentModelRoute !== undefined) this.currentModelRoute = currentModelRoute;\n\t}\n}\n\n/**\n * Caller-owned bounds on routing inference, on top of the structured-decision\n * deadline that already limits each inference call. A caller that needs a\n * shorter wait, or a concurrency limit, supplies them.\n */\nexport interface RoutingInferenceBounds {\n\t/**\n\t * When it aborts, inference stops and routing ends like any total inference\n\t * failure, so a consumer may degrade to `AutoRoutingInferenceError.currentModelRoute`.\n\t * Cancellation still goes through `signal`.\n\t */\n\treadonly deadline?: AbortSignal;\n\t/** Runs each inference under the caller's concurrency limit; the queue wait must end when `signal` aborts. */\n\treadonly limit?: <T>(run: () => Promise<T>, signal: AbortSignal | undefined) => Promise<T>;\n}\n\nconst INFERENCE_DEADLINE_MESSAGE =\n\t\"Auto routing timed out waiting for the routing model; the provider may be unavailable or overloaded.\";\n\n/** Degraded routes keep a balanced effort when the constraints leave a choice. */\nconst CURRENT_MODEL_EFFORT_PREFERENCE: readonly (string | null)[] = [\n\tnull,\n\t\"medium\",\n\t\"high\",\n\t\"low\",\n\t\"xhigh\",\n\t\"minimal\",\n\t\"max\",\n\t\"off\",\n];\n/** Most options the router compares when it builds the shortlist itself. */\nconst SHORTLIST_SIZE = 6;\n/** Conservative bytes per token when checking that a task fits a reader's context window. */\nconst BYTES_PER_TOKEN = 3;\n/** Room in the reader's window for the questions, instructions and its answer. */\nconst READER_OVERHEAD_TOKENS = 4_000;\n/** Jev accepts at most this many options in one Choice question. */\nconst MAX_CHOICE_OPTIONS = 255;\n\n/** A task that must hold this much in context prefers models whose window is at least this large. */\nconst LONG_CONTEXT_TOKENS = 400_000;\n\nconst NEEDS_INSTRUCTIONS =\n\t\"Read `task`, which `agent` will perform, and answer each field: what kind of work it is, how hard it is, how costly a mistake would be, whether it needs screenshots or images, whether it must hold a very large amount of material in context, and whether speed matters more than extra reasoning. Each field's description lists its options. Judge the task as written; `caller_says` lists answers the caller already gave.\";\nconst CHOICE_INSTRUCTIONS =\n\t\"Pick the model that should do the task `agent` will perform. The task's needs are in `needs`; the task itself is not shown. Each option lists the model's release date, price tier and prices, whether it reads images, and its results for this kind of work and overall; standings compare it with every eligible model. For demanding or high-stakes tasks prefer the best-proven model; for easy, low-stakes tasks prefer an adequate cheaper one. Prefer newer models over older ones with similar results. Missing results are unknown, not weak.\";\n\nconst EVALS_BUDGET_ERROR =\n\t\"Auto routing requires a nonempty evals.md document. Repair the Atomic installation or select a concrete execution model.\";\n\nasync function readModelSelectionEvals(signal?: AbortSignal): Promise<string> {\n\ttry {\n\t\tconst evals = await readFile(join(getDocsPath(), \"models\", \"evals.md\"), { encoding: \"utf8\", signal });\n\t\tif (!evals.trim()) throw new Error(EVALS_BUDGET_ERROR);\n\t\treturn evals;\n\t} catch (error) {\n\t\tsignal?.throwIfAborted();\n\t\tif (error instanceof Error && error.message === EVALS_BUDGET_ERROR) throw error;\n\t\tthrow new Error(EVALS_BUDGET_ERROR);\n\t}\n}\n\nexport async function routeExecutionModel(input: {\n\tctx: ModelRoutingContext;\n\ttask: string;\n\tagent: { name: string; description: string };\n\tconstraints?: readonly ModelConstraints[];\n\tsignal?: AbortSignal;\n\t/** Restore a recorded decision without another inference call. */\n\tselection?: ModelRouterOutput;\n\t/** What the caller already knows about the task; routing asks the router only for the rest. */\n\ttaskNeeds?: TaskNeeds;\n\t/**\n\t * True when this call's own constraints set a provider list because the user\n\t * asked. Only then are the settings.json provider lists replaced; provider\n\t * lists from agent definitions or inherited workflow constraints restrict\n\t * candidates on top of the settings and never lift a user's exclusion.\n\t */\n\toverrideProviderSettings?: boolean;\n\tinference?: RoutingInferenceBounds;\n}): Promise<ModelRoute> {\n\tconst { ctx, signal } = input;\n\tsignal?.throwIfAborted();\n\tconst constraints = structuredClone((input.constraints ?? []).map((c) => parseModelConstraints(c)!));\n\tconst statedNeeds = parseTaskNeeds(input.taskNeeds);\n\t// settings.json provider lists are defaults that only the call itself may\n\t// replace; every constraint's own provider lists are enforced by eligiblePair.\n\tconst routing = ctx.getModelRouting?.() ?? {};\n\tconst { allowedProviders = [], excludedProviders = [] } = input.overrideProviderSettings ? {} : routing;\n\t// The model lists are the operator's gate and apply to every call (#3528).\n\tconst { allowedModels = [], excludedModels = [] } = routing;\n\tconst providerPermitted = (provider: string) =>\n\t\t(allowedProviders.length === 0 || allowedProviders.includes(provider)) && !excludedProviders.includes(provider);\n\tconst matching = (patterns: readonly string[], models: readonly Model<Api>[]) =>\n\t\tnew Set(\n\t\t\tresolveModelScopeFromModels([...patterns], models).scopedModels.map(\n\t\t\t\t({ model }) => `${model.provider}/${model.id}`,\n\t\t\t),\n\t\t);\n\tconst permittedModels = () => {\n\t\tconst models = ctx.modelRegistry.getAvailable();\n\t\tconst allowed = allowedModels.length ? matching(allowedModels, models) : undefined;\n\t\tconst excluded = matching(excludedModels, models);\n\t\treturn models.filter((model) => {\n\t\t\tconst id = `${model.provider}/${model.id}`;\n\t\t\treturn (\n\t\t\t\tisModelType(model, \"chat\") &&\n\t\t\t\tproviderPermitted(model.provider) &&\n\t\t\t\t(allowed === undefined || allowed.has(id)) &&\n\t\t\t\t!excluded.has(id)\n\t\t\t);\n\t\t});\n\t};\n\tconst catalog = () =>\n\t\tpermittedModels()\n\t\t\t// Ultrafast is billed above Standard and gated by account access. It is selectable\n\t\t\t// manually, but auto must receive an exact caller allowance or restore an explicit decision.\n\t\t\t.filter(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.fastRoute?.serviceTier !== \"ultrafast\" ||\n\t\t\t\t\tconstraints.some((constraint) => constraint.allowedModels?.includes(`${model.provider}/${model.id}`)) ||\n\t\t\t\t\tinput.selection?.model === `${model.provider}/${model.id}`,\n\t\t\t)\n\t\t\t.map((model) => ({\n\t\t\t\tmodel,\n\t\t\t\tpairs: (model.reasoning ? getSupportedThinkingLevels(model) : [null])\n\t\t\t\t\t.map((effort) => ({ model: `${model.provider}/${model.id}`, effort }))\n\t\t\t\t\t.filter((pair) => eligiblePair(model, pair, constraints)),\n\t\t\t}))\n\t\t\t.filter((entry) => entry.pairs.length > 0);\n\tconst available = catalog();\n\tconst pairs = available.flatMap((entry) => entry.pairs);\n\tif (!pairs.length) {\n\t\tconst providerSettings = allowedProviders.length > 0 || excludedProviders.length > 0;\n\t\tconst gateSettings = [\n\t\t\t...(providerSettings ? [\"modelRouting allowedProviders/excludedProviders\"] : []),\n\t\t\t...(allowedModels.length ? [\"modelRouting.allowedModels\"] : []),\n\t\t\t...(excludedModels.length ? [\"modelRouting.excludedModels\"] : []),\n\t\t];\n\t\tconst noun = gateSettings.length === 1 && !providerSettings ? \"setting\" : \"settings\";\n\t\tthrow new Error(\n\t\t\tgateSettings.length\n\t\t\t\t? `Auto routing has no eligible model/effort pairs. Check configured providers, modelConstraints, and the ${new Intl.ListFormat(\"en\", { type: \"conjunction\" }).format(gateSettings)} ${noun}.`\n\t\t\t\t: \"Auto routing has no eligible model/effort pairs. Check configured providers and modelConstraints.\",\n\t\t);\n\t}\n\t// The effective post-filter pool, echoed in routerSelection for audit (#3528).\n\tconst candidates = [...new Set(available.map((entry) => `${entry.model.provider}/${entry.model.id}`))];\n\tlet selection = input.selection;\n\tif (selection === undefined) {\n\t\tconst settings = {\n\t\t\tgetRouterModel: () => ctx.getRouterModel(),\n\t\t\t...(ctx.getHttpIdleTimeoutMs ? { getHttpIdleTimeoutMs: () => ctx.getHttpIdleTimeoutMs!() } : {}),\n\t\t};\n\t\tconst router = resolveRouterModel({ settings, currentModel: ctx.model, modelRegistry: ctx.modelRegistry });\n\t\tif (!input.task.trim()) throw new Error(\"Auto routing requires task instructions.\");\n\t\tconst stated = statedNeeds;\n\t\tconst agent = { name: input.agent.name, description: input.agent.description };\n\t\t// Screen the task before any model reads it.\n\t\tconst serialized = JSON.stringify({ task: input.task, agent, stated, constraints });\n\t\tlet configuredCredential: boolean;\n\t\ttry {\n\t\t\tconfiguredCredential = await ctx.modelRegistry.containsConfiguredCredential(serialized);\n\t\t} catch {\n\t\t\tthrow new Error(\"Auto routing could not screen configured credentials. No inference was performed.\");\n\t\t}\n\t\tif (\n\t\t\tcontainsKnownEnvCredential(serialized) ||\n\t\t\tconfiguredCredential ||\n\t\t\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\\b(?:sk|ghp|github_pat)[-_][A-Za-z0-9_-]{16,}/i.test(\n\t\t\t\tserialized,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"Auto routing context contains credential material. Remove secrets before retrying.\");\n\t\tconst task = input.task;\n\t\t// Degrade only to a current chat model that is available and eligible under\n\t\t// the same constraints, restored through the normal selection path (#3206).\n\t\tconst currentModelRoute = async (): Promise<ModelRoute | undefined> => {\n\t\t\tconst current = ctx.model;\n\t\t\tconst entry = available.find(\n\t\t\t\t(candidate) => candidate.model.provider === current?.provider && candidate.model.id === current?.id,\n\t\t\t);\n\t\t\tconst pair = CURRENT_MODEL_EFFORT_PREFERENCE.map((effort) =>\n\t\t\t\tentry?.pairs.find((candidate) => candidate.effort === effort),\n\t\t\t).find((candidate) => candidate !== undefined);\n\t\t\tif (pair === undefined) return undefined;\n\t\t\treturn routeExecutionModel({ ...input, selection: { model: pair.model, effort: pair.effort, candidates } });\n\t\t};\n\t\t// Any failure before a model is chosen is a total inference failure: the\n\t\t// router and its chat structured-output fallback both failed (#3206).\n\t\tconst { deadline, limit } = input.inference ?? {};\n\t\tconst infer = async <T>(decide: (inferenceSignal: AbortSignal | undefined) => Promise<T>): Promise<T> => {\n\t\t\tconst inferenceSignal =\n\t\t\t\tdeadline === undefined ? signal : signal === undefined ? deadline : AbortSignal.any([signal, deadline]);\n\t\t\ttry {\n\t\t\t\treturn await (limit ? limit(() => decide(inferenceSignal), inferenceSignal) : decide(inferenceSignal));\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tthrow new AutoRoutingInferenceError(\n\t\t\t\t\tdeadline?.aborted ? INFERENCE_DEADLINE_MESSAGE : error instanceof Error ? error.message : String(error),\n\t\t\t\t\tawait currentModelRoute().catch(() => undefined),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\t// Where code cannot pick a model either, the current chat model takes over\n\t\t// the same way.\n\t\tconst fallBackToCurrentModel = async (message: string): Promise<never> => {\n\t\t\tthrow new AutoRoutingInferenceError(message, await currentModelRoute().catch(() => undefined));\n\t\t};\n\t\tconst catalogEvals = await readModelSelectionEvals(signal)\n\t\t\t.then(parseEvalsCatalog)\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\treturn fallBackToCurrentModel(error instanceof Error ? error.message : String(error));\n\t\t\t});\n\n\t\t// Step 1: a chat model reads the task and answers only what the caller did\n\t\t// not state. A classifier router such as Jev never receives the task.\n\t\tconst questions = missingNeedsQuestions(stated);\n\t\tlet answers: Record<string, string> = {};\n\t\tif (questions.length) {\n\t\t\tconst current = ctx.model;\n\t\t\tconst preferred =\n\t\t\t\trouter.kind === \"chat\"\n\t\t\t\t\t? router.model\n\t\t\t\t\t: current && current.id !== \"auto\" && isModelType(current, \"chat\")\n\t\t\t\t\t\t? current\n\t\t\t\t\t\t: undefined;\n\t\t\t// The reader gets the complete task. When the task is larger than the\n\t\t\t// preferred reader's window, the cheapest eligible model that holds it\n\t\t\t// reads instead; eligible models are the ones allowed to receive the task.\n\t\t\tconst taskTokens = Math.ceil(Buffer.byteLength(task, \"utf8\") / BYTES_PER_TOKEN) + READER_OVERHEAD_TOKENS;\n\t\t\tconst holdsTask = (model: Model<Api>) => model.contextWindow >= taskTokens;\n\t\t\tconst readerModel =\n\t\t\t\tpreferred && holdsTask(preferred)\n\t\t\t\t\t? preferred\n\t\t\t\t\t: (available\n\t\t\t\t\t\t\t.map((entry) => entry.model)\n\t\t\t\t\t\t\t.filter(holdsTask)\n\t\t\t\t\t\t\t.sort(\n\t\t\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t\t\ta.cost.input - b.cost.input ||\n\t\t\t\t\t\t\t\t\t`${a.provider}/${a.id}`.localeCompare(`${b.provider}/${b.id}`),\n\t\t\t\t\t\t\t)[0] ?? preferred);\n\t\t\tconst reader = readerModel ? `${readerModel.provider}/${readerModel.id}` : undefined;\n\t\t\tif (reader === undefined)\n\t\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t\t\"Auto routing needs a chat model to read the task. Select a chat model or state every taskNeeds field.\",\n\t\t\t\t);\n\t\t\tconst schema = Type.Object(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\tType.String({\n\t\t\t\t\t\t\tenum: Object.keys(question.criteria),\n\t\t\t\t\t\t\tdescription: `${question.instructions} ${Object.entries(question.criteria)\n\t\t\t\t\t\t\t\t.map(([key, meaning]) => `${key}: ${meaning}`)\n\t\t\t\t\t\t\t\t.join(\"; \")}.`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\t{ additionalProperties: false },\n\t\t\t);\n\t\t\tconst callerSays = stated\n\t\t\t\t? {\n\t\t\t\t\t\t...(stated.work ? { work: stated.work } : {}),\n\t\t\t\t\t\t...(stated.difficulty ? { difficulty: stated.difficulty } : {}),\n\t\t\t\t\t\t...(stated.mistakeCost ? { mistake_cost: stated.mistakeCost } : {}),\n\t\t\t\t\t\t...(stated.needsImages !== undefined ? { needs_images: stated.needsImages ? \"yes\" : \"no\" } : {}),\n\t\t\t\t\t\t...(stated.longContext !== undefined ? { long_context: stated.longContext ? \"yes\" : \"no\" } : {}),\n\t\t\t\t\t\t...(stated.latencySensitive !== undefined\n\t\t\t\t\t\t\t? { latency_sensitive: stated.latencySensitive ? \"yes\" : \"no\" }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t\tconst result = await infer((inferenceSignal) =>\n\t\t\t\trouteModel(\n\t\t\t\t\t{\n\t\t\t\t\t\tsettings: { ...settings, getRouterModel: () => reader! },\n\t\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\ttask,\n\t\t\t\t\t\t\tagent,\n\t\t\t\t\t\t\t...(callerSays && Object.keys(callerSays).length ? { caller_says: callerSays } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinstructions: NEEDS_INSTRUCTIONS,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\t// Unused: the reader always resolves to a chat model.\n\t\t\t\t\t\tclassifier: {\n\t\t\t\t\t\t\tquestions: Object.fromEntries(\n\t\t\t\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\t\t\t\t{ instructions: question.instructions, criteria: question.criteria },\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tdecode: (choices) =>\n\t\t\t\t\t\t\t\tObject.fromEntries(questions.map((question) => [question.id, choices[question.id]!])),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: inferenceSignal,\n\t\t\t\t\t},\n\t\t\t\t\t(value) => questions.every((question) => Object.hasOwn(question.criteria, String(value[question.id]))),\n\t\t\t\t),\n\t\t\t);\n\t\t\tanswers = result.value;\n\t\t}\n\t\tconst needs: ResolvedTaskNeeds = resolveTaskNeeds(stated, answers);\n\n\t\t// Step 2: narrow in code. A task that needs images only goes to models that read them.\n\t\tconst seeing = needs.needsImages ? available.filter((entry) => entry.model.input.includes(\"image\")) : available;\n\t\tif (seeing.length === 0)\n\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t\"Auto routing: this task needs a model that can read images, and no eligible model can. Allow an image-capable model or select a concrete execution model.\",\n\t\t\t);\n\t\t// A large context window is preferred, not required: context size is a matter of degree.\n\t\tconst roomy = needs.longContext\n\t\t\t? seeing.filter((entry) => entry.model.contextWindow >= LONG_CONTEXT_TOKENS)\n\t\t\t: seeing;\n\t\tconst usable = roomy.length ? roomy : seeing;\n\t\tconst pairsFor = new Map(usable.map((entry) => [`${entry.model.provider}/${entry.model.id}`, entry.pairs]));\n\t\tconst routedCandidates = [...pairsFor.keys()];\n\t\tconst toCandidate = (model: Model<Api>): CandidateModel => {\n\t\t\tconst routeCost = model.fastRoute?.serviceTier\n\t\t\t\t? getServiceTierCost(model, model.fastRoute.serviceTier)\n\t\t\t\t: undefined;\n\t\t\treturn {\n\t\t\t\tmodel: `${model.provider}/${model.id}`,\n\t\t\t\tname: model.name,\n\t\t\t\tcost: routeCost ?? model.cost,\n\t\t\t\tinput: model.input,\n\t\t\t\t...(model.fastRoute\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfastRouteOf: `${model.provider}/${model.fastRoute.baseModelId}`,\n\t\t\t\t\t\t\tfastRouteServiceTier: model.fastRoute.serviceTier,\n\t\t\t\t\t\t\tfastRoutePriced: routeCost !== undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t};\n\t\t// A caller that lists models (`allowedModels`) chooses the contenders itself,\n\t\t// but price and recency still compare them with every model the user could route to.\n\t\tconst callerListed = constraints.some((constraint) => (constraint.allowedModels?.length ?? 0) > 0);\n\t\tconst reference = callerListed\n\t\t\t? permittedModels().filter((model) => !needs.needsImages || model.input.includes(\"image\"))\n\t\t\t: usable.map((entry) => entry.model);\n\t\tconst standings = rankCandidates(catalogEvals, reference.map(toCandidate), needs);\n\t\tconst ranked = standings.filter((candidate) => pairsFor.has(candidate.model));\n\t\tconst choiceState = {\n\t\t\tagent,\n\t\t\tneeds: {\n\t\t\t\twork: needs.work,\n\t\t\t\tdifficulty: needs.difficulty,\n\t\t\t\tmistake_cost: needs.mistakeCost,\n\t\t\t\tneeds_images: needs.needsImages,\n\t\t\t\tlong_context: needs.longContext,\n\t\t\t\tlatency_sensitive: needs.latencySensitive,\n\t\t\t},\n\t\t};\n\t\tconst describeAll = (options: readonly RankedCandidate[]) =>\n\t\t\tObject.fromEntries(options.map((option, index) => [`m${index}`, describeOption(option, needs, standings)]));\n\t\tconst fitsOneChoice = (options: readonly RankedCandidate[]) =>\n\t\t\toptions.length <= MAX_CHOICE_OPTIONS &&\n\t\t\tBuffer.byteLength(\n\t\t\t\tJSON.stringify({ state: choiceState, instructions: CHOICE_INSTRUCTIONS, criteria: describeAll(options) }),\n\t\t\t\t\"utf8\",\n\t\t\t) <= ROUTING_REQUEST_BYTES;\n\t\t// A caller's list is offered whole when it fits one choice request; otherwise\n\t\t// duplicate routes of one model share a slot, and a list that still does not\n\t\t// fit falls back rather than silently dropping a contender.\n\t\tconst callerChoices = !callerListed || fitsOneChoice(ranked) ? ranked : distinctTop(ranked, ranked.length);\n\t\tif (callerListed && !fitsOneChoice(callerChoices))\n\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t`Auto routing cannot compare ${callerChoices.length} different models from modelConstraints.allowedModels in one routing request. List fewer models.`,\n\t\t\t);\n\t\tconst shortlist = callerListed ? callerChoices : distinctTop(ranked, SHORTLIST_SIZE);\n\n\t\t// Step 3: the router picks one option; each carries its own evidence.\n\t\tlet chosen = shortlist[0]!;\n\t\tif (shortlist.length > 1) {\n\t\t\tconst keys = shortlist.map((_, index) => `m${index}`);\n\t\t\tconst schema = Type.Object(\n\t\t\t\t{ modelId: Type.String({ enum: shortlist.map((option) => option.model) }) },\n\t\t\t\t{ additionalProperties: false },\n\t\t\t);\n\t\t\tconst result = await infer((inferenceSignal) =>\n\t\t\t\trouteModel(\n\t\t\t\t\t{\n\t\t\t\t\t\tsettings,\n\t\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...choiceState,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinstructions: CHOICE_INSTRUCTIONS,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tclassifier: {\n\t\t\t\t\t\t\tquestions: {\n\t\t\t\t\t\t\t\tmodel: {\n\t\t\t\t\t\t\t\t\tinstructions: \"Which model should do this task?\",\n\t\t\t\t\t\t\t\t\tcriteria: describeAll(shortlist),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdecode: (choices) => {\n\t\t\t\t\t\t\t\tconst option = shortlist[keys.indexOf(choices.model ?? \"\")];\n\t\t\t\t\t\t\t\tif (!option) throw new Error(\"Invalid execution model Choice.\");\n\t\t\t\t\t\t\t\treturn { modelId: option.model };\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: inferenceSignal,\n\t\t\t\t\t},\n\t\t\t\t\t(value) => shortlist.some((option) => option.model === value.modelId),\n\t\t\t\t),\n\t\t\t);\n\t\t\tchosen = shortlist.find((option) => option.model === result.value.modelId)!;\n\t\t}\n\n\t\t// Step 4: effort from difficulty; fallbacks are the next distinct models in code's ranking.\n\t\tconst effortOf = (model: string) =>\n\t\t\teffortForDifficulty(\n\t\t\t\t(pairsFor.get(model) ?? []).map((pair) => pair.effort),\n\t\t\t\tneeds.difficulty,\n\t\t\t\tneeds.latencySensitive,\n\t\t\t);\n\t\tconst fallbackModels = distinctTop(\n\t\t\tranked.filter((candidate) => candidate.baseKey !== chosen.baseKey),\n\t\t\t2,\n\t\t);\n\t\treportModelRoutingDebug(\n\t\t\t`Auto routing: ${needs.work}, ${needs.difficulty}, mistake cost ${needs.mistakeCost}, images ${needs.needsImages ? \"yes\" : \"no\"}, long context ${needs.longContext ? \"yes\" : \"no\"}, latency ${needs.latencySensitive ? \"sensitive\" : \"tolerant\"}; chose ${chosen.model} from ${shortlist.map((option) => option.model).join(\", \")}.`,\n\t\t);\n\t\tselection = {\n\t\t\tmodel: chosen.model,\n\t\t\teffort: effortOf(chosen.model),\n\t\t\t...(fallbackModels.length\n\t\t\t\t? {\n\t\t\t\t\t\tfallbacks: fallbackModels.map((candidate) => ({\n\t\t\t\t\t\t\tmodel: candidate.model,\n\t\t\t\t\t\t\teffort: effortOf(candidate.model),\n\t\t\t\t\t\t})),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tcandidates: routedCandidates,\n\t\t};\n\t}\n\tconst fallbacks = selection.fallbacks?.map((pair) => Object.freeze({ model: pair.model, effort: pair.effort }));\n\tif (\n\t\tfallbacks &&\n\t\t(fallbacks.length > 2 ||\n\t\t\tnew Set([selection.model, ...fallbacks.map((pair) => pair.model)]).size !== fallbacks.length + 1)\n\t)\n\t\tthrow new Error(\"Invalid ranked auto selection: expected up to three distinct models.\");\n\tconst routerSelection = Object.freeze({\n\t\tmodel: selection.model,\n\t\teffort: selection.effort,\n\t\t...(fallbacks?.length ? { fallbacks: Object.freeze(fallbacks) } : {}),\n\t\t...(selection.candidates ? { candidates: Object.freeze([...selection.candidates]) } : {}),\n\t});\n\tconst hasPair = (pair: ModelRouterOutput) =>\n\t\tcatalog().some((entry) => entry.pairs.some((p) => p.model === pair.model && p.effort === pair.effort));\n\tconst allowsModel = (model: Model<Api>, effort?: string): boolean => {\n\t\tconst levels = model.reasoning ? getSupportedThinkingLevels(model) : [null];\n\t\treturn levels.some((level) => {\n\t\t\tif (model.reasoning && effort !== undefined && level !== effort) return false;\n\t\t\tconst pair = { model: `${model.provider}/${model.id}`, effort: level };\n\t\t\treturn eligiblePair(model, pair, constraints) && hasPair(pair);\n\t\t});\n\t};\n\tconst assertCurrent = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (![routerSelection, ...(routerSelection.fallbacks ?? [])].every(hasPair))\n\t\t\tthrow new Error(\"Auto selection is no longer eligible. Retry explicitly with the current catalog.\");\n\t};\n\tassertCurrent();\n\treturn {\n\t\trouterSelection,\n\t\tmodelOverride: routerSelection.model + (routerSelection.effort === null ? \"\" : `:${routerSelection.effort}`),\n\t\tfallbackModels: Object.freeze(\n\t\t\t(routerSelection.fallbacks ?? []).map((pair) => pair.model + (pair.effort === null ? \"\" : `:${pair.effort}`)),\n\t\t),\n\t\tassertCurrent,\n\t\tallowsModel,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"execution-model-router.js","sourceRoot":"","sources":["../../src/core/execution-model-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAEN,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,GAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE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AAe,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC5G,cAAc,EAAE,MAAM,CAAC,MAAM,CAC5B,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAC7G;QACD,aAAa;QACb,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n\ttype Api,\n\tcontainsKnownEnvCredential,\n\tgetServiceTierCost,\n\tgetSupportedThinkingLevels,\n\tisModelType,\n\ttype Model,\n} from \"@bastani/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getDocsPath } from \"../config.js\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { resolveModelScopeFromModels } from \"./model-resolver-scope.ts\";\nimport { ROUTING_REQUEST_BYTES } from \"./model-routing-bytes.js\";\nimport {\n\ttype CandidateModel,\n\tdescribeOption,\n\tdistinctTop,\n\ttype RankedCandidate,\n\trankCandidates,\n} from \"./model-routing-candidates.js\";\nimport {\n\teligiblePair,\n\ttype ModelConstraints,\n\ttype ModelRouterOutput,\n\tparseModelConstraints,\n} from \"./model-routing-constraints.js\";\nimport { reportModelRoutingDebug } from \"./model-routing-debug.js\";\nimport { parseEvalsCatalog } from \"./model-routing-evals.js\";\nimport {\n\teffortForDifficulty,\n\tmissingNeedsQuestions,\n\tparseTaskNeeds,\n\ttype ResolvedTaskNeeds,\n\tresolveTaskNeeds,\n\ttype TaskNeeds,\n} from \"./model-routing-needs.js\";\nimport type { ModelRoutingSettings } from \"./settings-types.ts\";\nimport { resolveRouterModel, routeModel } from \"./structured-output/index.js\";\nimport { carriedProviderFailure, withProviderFailure } from \"./structured-output/provider-failure.js\";\n\nexport interface ModelRoutingContext {\n\treadonly modelRegistry: Pick<\n\t\tModelRegistry,\n\t\t\"getAll\" | \"getAvailable\" | \"streamSimple\" | \"containsConfiguredCredential\"\n\t> &\n\t\tPartial<Pick<ModelRegistry, \"getProviderAuthStatus\" | \"getProviderAuth\" | \"getClassifierModel\" | \"classify\">>;\n\treadonly model?: Model<Api>;\n\tgetRouterModel(): string;\n\t/** Provider and model filters from settings.json `modelRouting`; absent means every model is a candidate. */\n\tgetModelRouting?(): ModelRoutingSettings;\n\t/** The `httpIdleTimeoutMs` setting; bounds each routing inference. Absent means the setting's default. */\n\tgetHttpIdleTimeoutMs?(): number;\n}\nexport interface ModelRoute {\n\treadonly routerSelection: ModelRouterOutput;\n\treadonly modelOverride: string;\n\treadonly fallbackModels?: readonly string[];\n\tassertCurrent(): void;\n\tallowsModel(model: Model<Api>, effort?: string): boolean;\n}\n\n/**\n * Total auto-routing inference failure: Jev and the chat structured-output\n * fallback both failed before any model was selected (#3206). Validation,\n * eligibility, and credential-screening errors are never marked.\n */\nexport class AutoRoutingInferenceError extends Error {\n\t/**\n\t * Route pinned to the current chat model, present only when that model is\n\t * available and satisfies every routing constraint. Consumers may degrade\n\t * to it; when it is absent the failure stays fatal.\n\t */\n\treadonly currentModelRoute?: ModelRoute;\n\n\tconstructor(message: string, currentModelRoute?: ModelRoute) {\n\t\tsuper(message);\n\t\tthis.name = \"AutoRoutingInferenceError\";\n\t\tif (currentModelRoute !== undefined) this.currentModelRoute = currentModelRoute;\n\t}\n}\n\n/**\n * Caller-owned bounds on routing inference, on top of the structured-decision\n * deadline that already limits each inference call. A caller that needs a\n * shorter wait, or a concurrency limit, supplies them.\n */\nexport interface RoutingInferenceBounds {\n\t/**\n\t * When it aborts, inference stops and routing ends like any total inference\n\t * failure, so a consumer may degrade to `AutoRoutingInferenceError.currentModelRoute`.\n\t * Cancellation still goes through `signal`.\n\t */\n\treadonly deadline?: AbortSignal;\n\t/** Runs each inference under the caller's concurrency limit; the queue wait must end when `signal` aborts. */\n\treadonly limit?: <T>(run: () => Promise<T>, signal: AbortSignal | undefined) => Promise<T>;\n}\n\nconst INFERENCE_DEADLINE_MESSAGE =\n\t\"Auto routing timed out waiting for the routing model; the provider may be unavailable or overloaded.\";\n\n/** Degraded routes keep a balanced effort when the constraints leave a choice. */\nconst CURRENT_MODEL_EFFORT_PREFERENCE: readonly (string | null)[] = [\n\tnull,\n\t\"medium\",\n\t\"high\",\n\t\"low\",\n\t\"xhigh\",\n\t\"minimal\",\n\t\"max\",\n\t\"off\",\n];\n/** Most options the router compares when it builds the shortlist itself. */\nconst SHORTLIST_SIZE = 6;\n/** Conservative bytes per token when checking that a task fits a reader's context window. */\nconst BYTES_PER_TOKEN = 3;\n/** Room in the reader's window for the questions, instructions and its answer. */\nconst READER_OVERHEAD_TOKENS = 4_000;\n/** Jev accepts at most this many options in one Choice question. */\nconst MAX_CHOICE_OPTIONS = 255;\n\n/** A task that must hold this much in context prefers models whose window is at least this large. */\nconst LONG_CONTEXT_TOKENS = 400_000;\n\nconst NEEDS_INSTRUCTIONS =\n\t\"Read `task`, which `agent` will perform, and answer each field: what kind of work it is, how hard it is, how costly a mistake would be, whether it needs screenshots or images, whether it must hold a very large amount of material in context, and whether speed matters more than extra reasoning. Each field's description lists its options. Judge the task as written; `caller_says` lists answers the caller already gave.\";\nconst CHOICE_INSTRUCTIONS =\n\t\"Pick the model that should do the task `agent` will perform. The task's needs are in `needs`; the task itself is not shown. Each option lists the model's release date, price tier and prices, whether it reads images, and its results for this kind of work and overall; standings compare it with every eligible model. For demanding or high-stakes tasks prefer the best-proven model; for easy, low-stakes tasks prefer an adequate cheaper one. Prefer newer models over older ones with similar results. Missing results are unknown, not weak.\";\n\nconst EVALS_BUDGET_ERROR =\n\t\"Auto routing requires a nonempty evals.md document. Repair the Atomic installation or select a concrete execution model.\";\n\nasync function readModelSelectionEvals(signal?: AbortSignal): Promise<string> {\n\ttry {\n\t\tconst evals = await readFile(join(getDocsPath(), \"models\", \"evals.md\"), { encoding: \"utf8\", signal });\n\t\tif (!evals.trim()) throw new Error(EVALS_BUDGET_ERROR);\n\t\treturn evals;\n\t} catch (error) {\n\t\tsignal?.throwIfAborted();\n\t\tif (error instanceof Error && error.message === EVALS_BUDGET_ERROR) throw error;\n\t\tthrow new Error(EVALS_BUDGET_ERROR);\n\t}\n}\n\nexport async function routeExecutionModel(input: {\n\tctx: ModelRoutingContext;\n\ttask: string;\n\tagent: { name: string; description: string };\n\tconstraints?: readonly ModelConstraints[];\n\tsignal?: AbortSignal;\n\t/** Restore a recorded decision without another inference call. */\n\tselection?: ModelRouterOutput;\n\t/** What the caller already knows about the task; routing asks the router only for the rest. */\n\ttaskNeeds?: TaskNeeds;\n\t/**\n\t * True when this call's own constraints set a provider list because the user\n\t * asked. Only then are the settings.json provider lists replaced; provider\n\t * lists from agent definitions or inherited workflow constraints restrict\n\t * candidates on top of the settings and never lift a user's exclusion.\n\t */\n\toverrideProviderSettings?: boolean;\n\tinference?: RoutingInferenceBounds;\n}): Promise<ModelRoute> {\n\tconst { ctx, signal } = input;\n\tsignal?.throwIfAborted();\n\tconst constraints = structuredClone((input.constraints ?? []).map((c) => parseModelConstraints(c)!));\n\tconst statedNeeds = parseTaskNeeds(input.taskNeeds);\n\t// settings.json provider lists are defaults that only the call itself may\n\t// replace; every constraint's own provider lists are enforced by eligiblePair.\n\tconst routing = ctx.getModelRouting?.() ?? {};\n\tconst { allowedProviders = [], excludedProviders = [] } = input.overrideProviderSettings ? {} : routing;\n\t// The model lists are the operator's gate and apply to every call (#3528).\n\tconst { allowedModels = [], excludedModels = [] } = routing;\n\tconst providerPermitted = (provider: string) =>\n\t\t(allowedProviders.length === 0 || allowedProviders.includes(provider)) && !excludedProviders.includes(provider);\n\tconst matching = (patterns: readonly string[], models: readonly Model<Api>[]) =>\n\t\tnew Set(\n\t\t\tresolveModelScopeFromModels([...patterns], models).scopedModels.map(\n\t\t\t\t({ model }) => `${model.provider}/${model.id}`,\n\t\t\t),\n\t\t);\n\t// #3981: the returned route's `allowsModel` and `assertCurrent` outlive the caller's context: a subagent child\n\t// uses `allowsModel` as its fallback gate after model fallback retired the session that launched it, and a\n\t// retired extension context throws on every read. The registry is the session-independent model runtime's.\n\tconst { modelRegistry } = ctx;\n\tconst permittedModels = () => {\n\t\tconst models = modelRegistry.getAvailable();\n\t\tconst allowed = allowedModels.length ? matching(allowedModels, models) : undefined;\n\t\tconst excluded = matching(excludedModels, models);\n\t\treturn models.filter((model) => {\n\t\t\tconst id = `${model.provider}/${model.id}`;\n\t\t\treturn (\n\t\t\t\tisModelType(model, \"chat\") &&\n\t\t\t\tproviderPermitted(model.provider) &&\n\t\t\t\t(allowed === undefined || allowed.has(id)) &&\n\t\t\t\t!excluded.has(id)\n\t\t\t);\n\t\t});\n\t};\n\tconst catalog = () =>\n\t\tpermittedModels()\n\t\t\t// Ultrafast is billed above Standard and gated by account access. It is selectable\n\t\t\t// manually, but auto must receive an exact caller allowance or restore an explicit decision.\n\t\t\t.filter(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.fastRoute?.serviceTier !== \"ultrafast\" ||\n\t\t\t\t\tconstraints.some((constraint) => constraint.allowedModels?.includes(`${model.provider}/${model.id}`)) ||\n\t\t\t\t\tinput.selection?.model === `${model.provider}/${model.id}`,\n\t\t\t)\n\t\t\t.map((model) => ({\n\t\t\t\tmodel,\n\t\t\t\tpairs: (model.reasoning ? getSupportedThinkingLevels(model) : [null])\n\t\t\t\t\t.map((effort) => ({ model: `${model.provider}/${model.id}`, effort }))\n\t\t\t\t\t.filter((pair) => eligiblePair(model, pair, constraints)),\n\t\t\t}))\n\t\t\t.filter((entry) => entry.pairs.length > 0);\n\tconst available = catalog();\n\tconst pairs = available.flatMap((entry) => entry.pairs);\n\tif (!pairs.length) {\n\t\tconst providerSettings = allowedProviders.length > 0 || excludedProviders.length > 0;\n\t\tconst gateSettings = [\n\t\t\t...(providerSettings ? [\"modelRouting allowedProviders/excludedProviders\"] : []),\n\t\t\t...(allowedModels.length ? [\"modelRouting.allowedModels\"] : []),\n\t\t\t...(excludedModels.length ? [\"modelRouting.excludedModels\"] : []),\n\t\t];\n\t\tconst noun = gateSettings.length === 1 && !providerSettings ? \"setting\" : \"settings\";\n\t\tthrow new Error(\n\t\t\tgateSettings.length\n\t\t\t\t? `Auto routing has no eligible model/effort pairs. Check configured providers, modelConstraints, and the ${new Intl.ListFormat(\"en\", { type: \"conjunction\" }).format(gateSettings)} ${noun}.`\n\t\t\t\t: \"Auto routing has no eligible model/effort pairs. Check configured providers and modelConstraints.\",\n\t\t);\n\t}\n\t// The effective post-filter pool, echoed in routerSelection for audit (#3528).\n\tconst candidates = [...new Set(available.map((entry) => `${entry.model.provider}/${entry.model.id}`))];\n\tlet selection = input.selection;\n\tif (selection === undefined) {\n\t\tconst settings = {\n\t\t\tgetRouterModel: () => ctx.getRouterModel(),\n\t\t\t...(ctx.getHttpIdleTimeoutMs ? { getHttpIdleTimeoutMs: () => ctx.getHttpIdleTimeoutMs!() } : {}),\n\t\t};\n\t\tconst router = resolveRouterModel({ settings, currentModel: ctx.model, modelRegistry: ctx.modelRegistry });\n\t\tif (!input.task.trim()) throw new Error(\"Auto routing requires task instructions.\");\n\t\tconst stated = statedNeeds;\n\t\tconst agent = { name: input.agent.name, description: input.agent.description };\n\t\t// Screen the task before any model reads it.\n\t\tconst serialized = JSON.stringify({ task: input.task, agent, stated, constraints });\n\t\tlet configuredCredential: boolean;\n\t\ttry {\n\t\t\tconfiguredCredential = await ctx.modelRegistry.containsConfiguredCredential(serialized);\n\t\t} catch {\n\t\t\tthrow new Error(\"Auto routing could not screen configured credentials. No inference was performed.\");\n\t\t}\n\t\tif (\n\t\t\tcontainsKnownEnvCredential(serialized) ||\n\t\t\tconfiguredCredential ||\n\t\t\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\\b(?:sk|ghp|github_pat)[-_][A-Za-z0-9_-]{16,}/i.test(\n\t\t\t\tserialized,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"Auto routing context contains credential material. Remove secrets before retrying.\");\n\t\tconst task = input.task;\n\t\t// Degrade only to a current chat model that is available and eligible under\n\t\t// the same constraints, restored through the normal selection path (#3206).\n\t\tconst currentModelRoute = async (): Promise<ModelRoute | undefined> => {\n\t\t\tconst current = ctx.model;\n\t\t\tconst entry = available.find(\n\t\t\t\t(candidate) => candidate.model.provider === current?.provider && candidate.model.id === current?.id,\n\t\t\t);\n\t\t\tconst pair = CURRENT_MODEL_EFFORT_PREFERENCE.map((effort) =>\n\t\t\t\tentry?.pairs.find((candidate) => candidate.effort === effort),\n\t\t\t).find((candidate) => candidate !== undefined);\n\t\t\tif (pair === undefined) return undefined;\n\t\t\treturn routeExecutionModel({ ...input, selection: { model: pair.model, effort: pair.effort, candidates } });\n\t\t};\n\t\t// Any failure before a model is chosen is a total inference failure: the\n\t\t// router and its chat structured-output fallback both failed (#3206).\n\t\tconst { deadline, limit } = input.inference ?? {};\n\t\tconst infer = async <T>(decide: (inferenceSignal: AbortSignal | undefined) => Promise<T>): Promise<T> => {\n\t\t\tconst inferenceSignal =\n\t\t\t\tdeadline === undefined ? signal : signal === undefined ? deadline : AbortSignal.any([signal, deadline]);\n\t\t\ttry {\n\t\t\t\treturn await (limit ? limit(() => decide(inferenceSignal), inferenceSignal) : decide(inferenceSignal));\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t// A router's rate limit or exhausted quota keeps its status, code and retry hint (#4031).\n\t\t\t\tthrow withProviderFailure(\n\t\t\t\t\tnew AutoRoutingInferenceError(\n\t\t\t\t\t\tdeadline?.aborted\n\t\t\t\t\t\t\t? INFERENCE_DEADLINE_MESSAGE\n\t\t\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t: String(error),\n\t\t\t\t\t\tawait currentModelRoute().catch(() => undefined),\n\t\t\t\t\t),\n\t\t\t\t\tdeadline?.aborted ? undefined : carriedProviderFailure(error),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\t// Where code cannot pick a model either, the current chat model takes over\n\t\t// the same way.\n\t\tconst fallBackToCurrentModel = async (message: string): Promise<never> => {\n\t\t\tthrow new AutoRoutingInferenceError(message, await currentModelRoute().catch(() => undefined));\n\t\t};\n\t\tconst catalogEvals = await readModelSelectionEvals(signal)\n\t\t\t.then(parseEvalsCatalog)\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\treturn fallBackToCurrentModel(error instanceof Error ? error.message : String(error));\n\t\t\t});\n\n\t\t// Step 1: a chat model reads the task and answers only what the caller did\n\t\t// not state. A classifier router such as Jev never receives the task.\n\t\tconst questions = missingNeedsQuestions(stated);\n\t\tlet answers: Record<string, string> = {};\n\t\tif (questions.length) {\n\t\t\tconst current = ctx.model;\n\t\t\tconst preferred =\n\t\t\t\trouter.kind === \"chat\"\n\t\t\t\t\t? router.model\n\t\t\t\t\t: current && current.id !== \"auto\" && isModelType(current, \"chat\")\n\t\t\t\t\t\t? current\n\t\t\t\t\t\t: undefined;\n\t\t\t// The reader gets the complete task. When the task is larger than the\n\t\t\t// preferred reader's window, the cheapest eligible model that holds it\n\t\t\t// reads instead; eligible models are the ones allowed to receive the task.\n\t\t\tconst taskTokens = Math.ceil(Buffer.byteLength(task, \"utf8\") / BYTES_PER_TOKEN) + READER_OVERHEAD_TOKENS;\n\t\t\tconst holdsTask = (model: Model<Api>) => model.contextWindow >= taskTokens;\n\t\t\tconst readerModel =\n\t\t\t\tpreferred && holdsTask(preferred)\n\t\t\t\t\t? preferred\n\t\t\t\t\t: (available\n\t\t\t\t\t\t\t.map((entry) => entry.model)\n\t\t\t\t\t\t\t.filter(holdsTask)\n\t\t\t\t\t\t\t.sort(\n\t\t\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t\t\ta.cost.input - b.cost.input ||\n\t\t\t\t\t\t\t\t\t`${a.provider}/${a.id}`.localeCompare(`${b.provider}/${b.id}`),\n\t\t\t\t\t\t\t)[0] ?? preferred);\n\t\t\tconst reader = readerModel ? `${readerModel.provider}/${readerModel.id}` : undefined;\n\t\t\tif (reader === undefined)\n\t\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t\t\"Auto routing needs a chat model to read the task. Select a chat model or state every taskNeeds field.\",\n\t\t\t\t);\n\t\t\tconst schema = Type.Object(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\tType.String({\n\t\t\t\t\t\t\tenum: Object.keys(question.criteria),\n\t\t\t\t\t\t\tdescription: `${question.instructions} ${Object.entries(question.criteria)\n\t\t\t\t\t\t\t\t.map(([key, meaning]) => `${key}: ${meaning}`)\n\t\t\t\t\t\t\t\t.join(\"; \")}.`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\t{ additionalProperties: false },\n\t\t\t);\n\t\t\tconst callerSays = stated\n\t\t\t\t? {\n\t\t\t\t\t\t...(stated.work ? { work: stated.work } : {}),\n\t\t\t\t\t\t...(stated.difficulty ? { difficulty: stated.difficulty } : {}),\n\t\t\t\t\t\t...(stated.mistakeCost ? { mistake_cost: stated.mistakeCost } : {}),\n\t\t\t\t\t\t...(stated.needsImages !== undefined ? { needs_images: stated.needsImages ? \"yes\" : \"no\" } : {}),\n\t\t\t\t\t\t...(stated.longContext !== undefined ? { long_context: stated.longContext ? \"yes\" : \"no\" } : {}),\n\t\t\t\t\t\t...(stated.latencySensitive !== undefined\n\t\t\t\t\t\t\t? { latency_sensitive: stated.latencySensitive ? \"yes\" : \"no\" }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t\tconst result = await infer((inferenceSignal) =>\n\t\t\t\trouteModel(\n\t\t\t\t\t{\n\t\t\t\t\t\tsettings: { ...settings, getRouterModel: () => reader! },\n\t\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\ttask,\n\t\t\t\t\t\t\tagent,\n\t\t\t\t\t\t\t...(callerSays && Object.keys(callerSays).length ? { caller_says: callerSays } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinstructions: NEEDS_INSTRUCTIONS,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\t// Unused: the reader always resolves to a chat model.\n\t\t\t\t\t\tclassifier: {\n\t\t\t\t\t\t\tquestions: Object.fromEntries(\n\t\t\t\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\t\t\t\t{ instructions: question.instructions, criteria: question.criteria },\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tdecode: (choices) =>\n\t\t\t\t\t\t\t\tObject.fromEntries(questions.map((question) => [question.id, choices[question.id]!])),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: inferenceSignal,\n\t\t\t\t\t},\n\t\t\t\t\t(value) => questions.every((question) => Object.hasOwn(question.criteria, String(value[question.id]))),\n\t\t\t\t),\n\t\t\t);\n\t\t\tanswers = result.value;\n\t\t}\n\t\tconst needs: ResolvedTaskNeeds = resolveTaskNeeds(stated, answers);\n\n\t\t// Step 2: narrow in code. A task that needs images only goes to models that read them.\n\t\tconst seeing = needs.needsImages ? available.filter((entry) => entry.model.input.includes(\"image\")) : available;\n\t\tif (seeing.length === 0)\n\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t\"Auto routing: this task needs a model that can read images, and no eligible model can. Allow an image-capable model or select a concrete execution model.\",\n\t\t\t);\n\t\t// A large context window is preferred, not required: context size is a matter of degree.\n\t\tconst roomy = needs.longContext\n\t\t\t? seeing.filter((entry) => entry.model.contextWindow >= LONG_CONTEXT_TOKENS)\n\t\t\t: seeing;\n\t\tconst usable = roomy.length ? roomy : seeing;\n\t\tconst pairsFor = new Map(usable.map((entry) => [`${entry.model.provider}/${entry.model.id}`, entry.pairs]));\n\t\tconst routedCandidates = [...pairsFor.keys()];\n\t\tconst toCandidate = (model: Model<Api>): CandidateModel => {\n\t\t\tconst routeCost = model.fastRoute?.serviceTier\n\t\t\t\t? getServiceTierCost(model, model.fastRoute.serviceTier)\n\t\t\t\t: undefined;\n\t\t\treturn {\n\t\t\t\tmodel: `${model.provider}/${model.id}`,\n\t\t\t\tname: model.name,\n\t\t\t\tcost: routeCost ?? model.cost,\n\t\t\t\tinput: model.input,\n\t\t\t\t...(model.fastRoute\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfastRouteOf: `${model.provider}/${model.fastRoute.baseModelId}`,\n\t\t\t\t\t\t\tfastRouteServiceTier: model.fastRoute.serviceTier,\n\t\t\t\t\t\t\tfastRoutePriced: routeCost !== undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t};\n\t\t// A caller that lists models (`allowedModels`) chooses the contenders itself,\n\t\t// but price and recency still compare them with every model the user could route to.\n\t\tconst callerListed = constraints.some((constraint) => (constraint.allowedModels?.length ?? 0) > 0);\n\t\tconst reference = callerListed\n\t\t\t? permittedModels().filter((model) => !needs.needsImages || model.input.includes(\"image\"))\n\t\t\t: usable.map((entry) => entry.model);\n\t\tconst standings = rankCandidates(catalogEvals, reference.map(toCandidate), needs);\n\t\tconst ranked = standings.filter((candidate) => pairsFor.has(candidate.model));\n\t\tconst choiceState = {\n\t\t\tagent,\n\t\t\tneeds: {\n\t\t\t\twork: needs.work,\n\t\t\t\tdifficulty: needs.difficulty,\n\t\t\t\tmistake_cost: needs.mistakeCost,\n\t\t\t\tneeds_images: needs.needsImages,\n\t\t\t\tlong_context: needs.longContext,\n\t\t\t\tlatency_sensitive: needs.latencySensitive,\n\t\t\t},\n\t\t};\n\t\tconst describeAll = (options: readonly RankedCandidate[]) =>\n\t\t\tObject.fromEntries(options.map((option, index) => [`m${index}`, describeOption(option, needs, standings)]));\n\t\tconst fitsOneChoice = (options: readonly RankedCandidate[]) =>\n\t\t\toptions.length <= MAX_CHOICE_OPTIONS &&\n\t\t\tBuffer.byteLength(\n\t\t\t\tJSON.stringify({ state: choiceState, instructions: CHOICE_INSTRUCTIONS, criteria: describeAll(options) }),\n\t\t\t\t\"utf8\",\n\t\t\t) <= ROUTING_REQUEST_BYTES;\n\t\t// A caller's list is offered whole when it fits one choice request; otherwise\n\t\t// duplicate routes of one model share a slot, and a list that still does not\n\t\t// fit falls back rather than silently dropping a contender.\n\t\tconst callerChoices = !callerListed || fitsOneChoice(ranked) ? ranked : distinctTop(ranked, ranked.length);\n\t\tif (callerListed && !fitsOneChoice(callerChoices))\n\t\t\tawait fallBackToCurrentModel(\n\t\t\t\t`Auto routing cannot compare ${callerChoices.length} different models from modelConstraints.allowedModels in one routing request. List fewer models.`,\n\t\t\t);\n\t\tconst shortlist = callerListed ? callerChoices : distinctTop(ranked, SHORTLIST_SIZE);\n\n\t\t// Step 3: the router picks one option; each carries its own evidence.\n\t\tlet chosen = shortlist[0]!;\n\t\tif (shortlist.length > 1) {\n\t\t\tconst keys = shortlist.map((_, index) => `m${index}`);\n\t\t\tconst schema = Type.Object(\n\t\t\t\t{ modelId: Type.String({ enum: shortlist.map((option) => option.model) }) },\n\t\t\t\t{ additionalProperties: false },\n\t\t\t);\n\t\t\tconst result = await infer((inferenceSignal) =>\n\t\t\t\trouteModel(\n\t\t\t\t\t{\n\t\t\t\t\t\tsettings,\n\t\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...choiceState,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinstructions: CHOICE_INSTRUCTIONS,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tclassifier: {\n\t\t\t\t\t\t\tquestions: {\n\t\t\t\t\t\t\t\tmodel: {\n\t\t\t\t\t\t\t\t\tinstructions: \"Which model should do this task?\",\n\t\t\t\t\t\t\t\t\tcriteria: describeAll(shortlist),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdecode: (choices) => {\n\t\t\t\t\t\t\t\tconst option = shortlist[keys.indexOf(choices.model ?? \"\")];\n\t\t\t\t\t\t\t\tif (!option) throw new Error(\"Invalid execution model Choice.\");\n\t\t\t\t\t\t\t\treturn { modelId: option.model };\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: inferenceSignal,\n\t\t\t\t\t},\n\t\t\t\t\t(value) => shortlist.some((option) => option.model === value.modelId),\n\t\t\t\t),\n\t\t\t);\n\t\t\tchosen = shortlist.find((option) => option.model === result.value.modelId)!;\n\t\t}\n\n\t\t// Step 4: effort from difficulty; fallbacks are the next distinct models in code's ranking.\n\t\tconst effortOf = (model: string) =>\n\t\t\teffortForDifficulty(\n\t\t\t\t(pairsFor.get(model) ?? []).map((pair) => pair.effort),\n\t\t\t\tneeds.difficulty,\n\t\t\t\tneeds.latencySensitive,\n\t\t\t);\n\t\tconst fallbackModels = distinctTop(\n\t\t\tranked.filter((candidate) => candidate.baseKey !== chosen.baseKey),\n\t\t\t2,\n\t\t);\n\t\treportModelRoutingDebug(\n\t\t\t`Auto routing: ${needs.work}, ${needs.difficulty}, mistake cost ${needs.mistakeCost}, images ${needs.needsImages ? \"yes\" : \"no\"}, long context ${needs.longContext ? \"yes\" : \"no\"}, latency ${needs.latencySensitive ? \"sensitive\" : \"tolerant\"}; chose ${chosen.model} from ${shortlist.map((option) => option.model).join(\", \")}.`,\n\t\t);\n\t\tselection = {\n\t\t\tmodel: chosen.model,\n\t\t\teffort: effortOf(chosen.model),\n\t\t\t...(fallbackModels.length\n\t\t\t\t? {\n\t\t\t\t\t\tfallbacks: fallbackModels.map((candidate) => ({\n\t\t\t\t\t\t\tmodel: candidate.model,\n\t\t\t\t\t\t\teffort: effortOf(candidate.model),\n\t\t\t\t\t\t})),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tcandidates: routedCandidates,\n\t\t};\n\t}\n\tconst fallbacks = selection.fallbacks?.map((pair) => Object.freeze({ model: pair.model, effort: pair.effort }));\n\tif (\n\t\tfallbacks &&\n\t\t(fallbacks.length > 2 ||\n\t\t\tnew Set([selection.model, ...fallbacks.map((pair) => pair.model)]).size !== fallbacks.length + 1)\n\t)\n\t\tthrow new Error(\"Invalid ranked auto selection: expected up to three distinct models.\");\n\tconst routerSelection = Object.freeze({\n\t\tmodel: selection.model,\n\t\teffort: selection.effort,\n\t\t...(fallbacks?.length ? { fallbacks: Object.freeze(fallbacks) } : {}),\n\t\t...(selection.candidates ? { candidates: Object.freeze([...selection.candidates]) } : {}),\n\t});\n\tconst hasPair = (pair: ModelRouterOutput) =>\n\t\tcatalog().some((entry) => entry.pairs.some((p) => p.model === pair.model && p.effort === pair.effort));\n\tconst allowsModel = (model: Model<Api>, effort?: string): boolean => {\n\t\tconst levels = model.reasoning ? getSupportedThinkingLevels(model) : [null];\n\t\treturn levels.some((level) => {\n\t\t\tif (model.reasoning && effort !== undefined && level !== effort) return false;\n\t\t\tconst pair = { model: `${model.provider}/${model.id}`, effort: level };\n\t\t\treturn eligiblePair(model, pair, constraints) && hasPair(pair);\n\t\t});\n\t};\n\tconst assertCurrent = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (![routerSelection, ...(routerSelection.fallbacks ?? [])].every(hasPair))\n\t\t\tthrow new Error(\"Auto selection is no longer eligible. Retry explicitly with the current catalog.\");\n\t};\n\tassertCurrent();\n\treturn {\n\t\trouterSelection,\n\t\tmodelOverride: routerSelection.model + (routerSelection.effort === null ? \"\" : `:${routerSelection.effort}`),\n\t\tfallbackModels: Object.freeze(\n\t\t\t(routerSelection.fallbacks ?? []).map((pair) => pair.model + (pair.effort === null ? \"\" : `:${pair.effort}`)),\n\t\t),\n\t\tassertCurrent,\n\t\tallowsModel,\n\t};\n}\n"]}
|
|
@@ -176,6 +176,13 @@ export interface ExtensionContext {
|
|
|
176
176
|
getAgentTaskHost?(): import("../tasks/agent-adapter.js").AgentTaskHost;
|
|
177
177
|
/** Internal owner-bound defaults and capability ceiling for builtin child adapters. */
|
|
178
178
|
getChildSessionOptions?: import("../child-session-options.ts").ChildSessionOptionsResolver;
|
|
179
|
+
/**
|
|
180
|
+
* Internal: a child-options resolver that stays valid after this context's session is replaced or closed (#3981).
|
|
181
|
+
* A queued or restored child calls it when it starts, possibly after this context is stale. It answers from the
|
|
182
|
+
* owning session's live successor (a workflow stage replaced by model fallback), or from the owning session's last
|
|
183
|
+
* state when it has none. Obtain it while the context is live; the call itself asserts that.
|
|
184
|
+
*/
|
|
185
|
+
getChildSessionOptionsResolver?(): import("../child-session-options.ts").ChildSessionOptionsResolver;
|
|
179
186
|
/** Session-scoped orchestration policy for child runtimes such as workflow stages. */
|
|
180
187
|
readonly orchestrationContext?: OrchestrationContext;
|
|
181
188
|
/** Typed capability policy for an in-process subagent child, when this session is one. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/context-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAA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Aa,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,EACjF,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,eAAe,CACd,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7E,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-types.js","sourceRoot":"","sources":["../../../src/core/extensions/context-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, ImageContent, Model, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionResult } from \"../compaction/index.ts\";\nimport type { CustomMessage } from \"../messages.ts\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { ReadonlySessionManager, SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport type { WorkflowStageAdmissionBoundary } from \"../workflow-stage-admission.ts\";\nimport type { SendMessageOptions, SendMessagesOptions } from \"./message-types.ts\";\nimport type { ExtensionUIContext } from \"./ui-types.js\";\nimport type { WorkflowActivityObserver, WorkflowActivitySubscription } from \"./workflow-events.js\";\nexport interface ExecuteToolOptions {\n\tsignal?: AbortSignal;\n\tonUpdate?: import(\"@earendil-works/pi-agent-core\").AgentToolUpdateCallback;\n}\n\n/** Tool-only context. Nested calls retain session validation and permission hooks. */\nexport interface ExtensionToolContext extends ExtensionContext {\n\treadonly tools: readonly import(\"@earendil-works/pi-agent-core\").AgentTool[];\n\texecuteTool(\n\t\tname: string,\n\t\targs: unknown,\n\t\toptions?: ExecuteToolOptions,\n\t): Promise<import(\"@earendil-works/pi-agent-core\").AgentToolCallOutcome>;\n}\n\nexport interface ContextUsage {\n\t/** Estimated context tokens, or null if unknown (e.g. right after compaction, before next LLM response). */\n\ttokens: number | null;\n\tcontextWindow: number;\n\t/** Context usage as percentage of context window, or null if tokens is unknown. */\n\tpercent: number | null;\n}\n\nexport interface CompactOptions {\n\t/** Fraction of compactable context to keep. 0.3 is aggressive, 0.7 is light. */\n\tcompression_ratio?: number;\n\t/** Number of recent context-eligible messages to keep uncompressed. */\n\tpreserve_recent?: number;\n\t/** Focus query for relevance-based pruning. Defaults to auto-detected session context. */\n\tquery?: string;\n\t/** Exact `provider/model` ID for this run only; overrides the `compactionModel` setting without saving it. */\n\tcompactionModel?: string;\n\tonComplete?: (result: VerbatimCompactionResult) => void;\n\tonError?: (error: Error) => void;\n}\n\n/**\n * Late routes settle as delivery acknowledgements: resolution means the route\n * accepted delivery, while rejection means delivery was not fully accepted. A\n * sequential batch may have delivered a prefix before it rejects; stale-context\n * rejection identifies the dropped route, and other failures reject unchanged.\n */\nexport interface WorkflowStageLateMessageRouter {\n\trouteMessage<T>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): void | Promise<void>;\n\trouteMessages<T>(\n\t\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\t\toptions?: SendMessagesOptions,\n\t): void | Promise<void>;\n}\n\nexport interface WorkflowStageMessageAdmission {\n\t/** Internal generation-owned boundary shared by every model-fallback session. */\n\treadonly boundary: WorkflowStageAdmissionBoundary;\n\t/** Internal extension state that must survive model-fallback session replacement. */\n\treadonly extensionState: Map<string, object>;\n\tisOpen(): boolean;\n}\n\nexport interface WorkflowPendingStageSender {\n\treadonly id: string;\n\treadonly name?: string;\n\treadonly cwd: string;\n\treadonly model: string;\n\treadonly pid: number;\n\treadonly startedAt: number;\n\treadonly lastActivity: number;\n\treadonly status?: string;\n\treadonly group?: string;\n}\n\nexport interface WorkflowPendingStageMessage {\n\treadonly id: string;\n\treadonly timestamp: number;\n\treadonly replyTo?: string;\n\treadonly expectsReply?: boolean;\n\treadonly replyError?: string;\n\treadonly content: {\n\t\treadonly text: string;\n\t\treadonly attachments?: readonly {\n\t\t\treadonly type: \"file\" | \"snippet\" | \"context\";\n\t\t\treadonly name: string;\n\t\t\treadonly content: string;\n\t\t\treadonly language?: string;\n\t\t}[];\n\t};\n}\n\nexport interface WorkflowPendingStageDelivery {\n\t/** Process-private authority proving this stage belongs to the workflow run route. */\n\treadonly routeCapability: string;\n\tdeliverPending(\n\t\tdeliver: (from: WorkflowPendingStageSender, message: WorkflowPendingStageMessage) => void | Promise<void>,\n\t\trecipient?: { readonly sessionId: string; readonly receivedMessageIds: readonly string[] },\n\t): Promise<void>;\n\tready(sessionId?: string): Promise<void> | undefined;\n\t/**\n\t * Terminal signal from a delivery owner that has run out of recovery: the\n\t * queued messages can no longer be drained, so the stage must fail at its own\n\t * lifecycle boundary rather than run without the instructions it was given.\n\t * Idempotent — the first reason wins, and `ready()` then settles with a\n\t * stage-scoped error instead of waiting for a delivery that will not come.\n\t *\n\t * Required, not optional: `ready()` has no timeout, so a delivery that cannot\n\t * be settled leaves its stage parked forever. Every implementer must be able\n\t * to answer that no delivery is coming.\n\t */\n\tfail(reason: Error): void;\n}\n\nexport interface WorkflowStageOrchestrationContext {\n\treadonly kind: \"workflow-stage\";\n\treadonly workflowRunId: string;\n\treadonly workflowStageId: string;\n\treadonly workflowStageName: string;\n\treadonly constraints: {\n\t\treadonly disableWorkflowTool: true;\n\t};\n\t/** Internal lifecycle seam for surfacing detached results after this stage closes. */\n\treadonly lateMessageRouter?: WorkflowStageLateMessageRouter;\n\t/** Internal synchronous boundary used before producer reply/turn side effects. */\n\treadonly messageAdmission?: WorkflowStageMessageAdmission;\n\t/**\n\t * Resolved per-session intercom home group for this stage. Concrete, already\n\t * normalized upstream. Read by the intercom extension (buildRegistration) and\n\t * inherited by subagents this stage spawns. Absent => no group override.\n\t */\n\treadonly intercomGroup?: string;\n\t/** Durable pre-start intercom delivery, drained by the intercom extension before the first turn. */\n\treadonly pendingStageDelivery?: WorkflowPendingStageDelivery;\n}\n/** Typed child intercom identity and supervisor capability issued at admission. */\nexport interface SubagentIntercomIdentity {\n\treadonly orchestratorTarget: string;\n\treadonly runId: string;\n\treadonly agent: string;\n\treadonly index: number;\n\treadonly sessionName?: string;\n\treadonly supervisor?: {\n\t\treadonly capability: string;\n\t\treadonly supervisorSessionId: string;\n\t};\n}\n\n/** Typed child capability policy supplied by an in-process subagent admission. */\nexport interface SubagentChildPolicy {\n\treadonly managementActions: \"full\" | \"restricted\";\n\treadonly fanoutAuthorized: boolean;\n\treadonly inheritProjectContext: boolean;\n\treadonly inheritSkills: boolean;\n\t/** Host-owned signal fired when this noninteractive execution ends, before disposal. */\n\treadonly executionEnded?: AbortSignal;\n\t/** SDK-owned inbound lifetime; closing drains admitted messages without reopening the task. */\n\treadonly messageAdmission?: {\n\t\tisOpen(): boolean;\n\t\t/** Reserve the full producer operation, including retries, before child settlement. */\n\t\trun(deliver: () => void | Promise<void>): Promise<void>;\n\t};\n\t/** Current admitted in-process nesting depth; absent for top-level sessions. */\n\treadonly depth?: number;\n\t/** SDK-resolved exact child tool allowlist; undefined leaves ordinary tools unrestricted. */\n\treadonly tools?: readonly string[];\n\t/** Server or server/tool selections. Undefined preserves MCP defaults; [] disables selector-based access. */\n\treadonly mcpDirectTools?: readonly string[];\n\t/** Admission-issued identity/capability; never inherited through process environment. */\n\treadonly intercom?: SubagentIntercomIdentity;\n\t/** Resolved intercom group for this admitted child, when one was assigned. */\n\treadonly intercomGroup?: string;\n}\n// Union alias kept for forward-compatible orchestration context variants.\nexport type OrchestrationContext = WorkflowStageOrchestrationContext;\n\n/**\n * Context passed to extension event handlers.\n */\nexport type ExtensionMode = \"tui\" | \"rpc\" | \"json\" | \"print\";\n\nexport interface ExtensionContext {\n\t/** Observe the owning session's workflow activity, starting with an ordered snapshot. */\n\tobserveWorkflowActivity(observer: WorkflowActivityObserver): WorkflowActivitySubscription;\n\t/** Paths of actually loaded extensions, when supplied by the host. */\n\tgetExtensionPaths?(): string[];\n\t/** Internal actual-session binding; never populated from model arguments. */\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n\t/** Internal owner-bound defaults and capability ceiling for builtin child adapters. */\n\tgetChildSessionOptions?: import(\"../child-session-options.ts\").ChildSessionOptionsResolver;\n\t/** Session-scoped orchestration policy for child runtimes such as workflow stages. */\n\treadonly orchestrationContext?: OrchestrationContext;\n\t/** Typed capability policy for an in-process subagent child, when this session is one. */\n\treadonly subagentPolicy?: SubagentChildPolicy;\n\t/** UI methods for user interaction */\n\tui: ExtensionUIContext;\n\t/** Current run mode. Use \"tui\" to guard terminal-only UI such as custom components. */\n\tmode: ExtensionMode;\n\t/** Whether dialog-capable UI is available (true in TUI and RPC modes) */\n\thasUI: boolean;\n\t/** Whether a semantic human-input adapter is available, independently of rendering. */\n\thasHumanInput: boolean;\n\treadonly isPresentationOnly?: boolean;\n\t/** Current working directory */\n\tcwd: string;\n\t/** Session manager (read-only) */\n\tsessionManager: ReadonlySessionManager;\n\t/** Model registry for API key resolution */\n\tmodelRegistry: ModelRegistry;\n\t/** Current model (may be undefined) */\n\tmodel: Model<Api> | undefined;\n\t/** Models scoped to this session (resolved from `--models` / `enabledModels`\n\t * settings against the available catalogue). Same set the `/scoped-models`\n\t * command shows. Empty when no scoping is configured (all available models\n\t * are usable). Read-only snapshot, resolved at access time. */\n\tscopedModels: readonly ScopedModel[];\n\t/** Current thinking level, resolved from the active session at access time. */\n\tthinkingLevel?: ThinkingLevel;\n\t/** Session-scoped internal resource router (e.g. artifact:// resolver). */\n\treadonly internalResourceRouter?: import(\"../tools/resource-selectors.ts\").InternalResourceRouter;\n\t/** Whether the agent is idle (not streaming) */\n\tisIdle(): boolean;\n\t/** Whether project-local trust is active for this context. */\n\tisProjectTrusted(): boolean;\n\t/** The current abort signal, or undefined when the agent is not streaming. */\n\tsignal: AbortSignal | undefined;\n\t/** Ends on reload or shutdown, before admitted work is drained. Independent of agent streaming. */\n\treadonly sessionSignal: AbortSignal;\n\t/**\n\t * @internal The owning session's lifetime signal as it is now. `sessionSignal` is fixed when this context is\n\t * created, so it stays aborted for good once a reload that the host rolls back has begun.\n\t */\n\tgetCurrentSessionSignal?(): AbortSignal;\n\t/** Abort the current agent operation */\n\tabort(): void;\n\t/** Whether there are queued messages waiting */\n\thasPendingMessages(): boolean;\n\t/** Whether background session and workflow summaries are enabled. */\n\tisSessionSummaryEnabled?(): boolean;\n\t/** Generate a read-only workflow summary with this session's model and credentials. */\n\tgenerateWorkflowSummary?(\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t\toptions?: { terminal?: boolean },\n\t): Promise<string | undefined>;\n\t/** Gracefully shutdown pi and exit. Available in all contexts. */\n\tshutdown(): void;\n\t/** Get current context usage for the active model. */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Trigger compaction without awaiting completion. */\n\tcompact(options?: CompactOptions): void;\n\t/** Get the current effective system prompt. */\n\tgetSystemPrompt(): string;\n\t/** Current loader-owned skill candidates and exact selector resolver. */\n\tgetSkillCatalog?(): SkillCatalog;\n\t/** Current routing-only inference setting from the owning session. Does not change the chat model. */\n\tgetRouterModel(): string;\n\t/** Provider filters for `model: \"auto\"` candidates from the owning session's settings. */\n\tgetModelRouting?(): import(\"../settings-types.ts\").ModelRoutingSettings;\n\t/** The owning session's `httpIdleTimeoutMs` setting in milliseconds; 0 means the idle timeout is disabled. */\n\tgetHttpIdleTimeoutMs?(): number;\n}\n\n/**\n * Extended context for command handlers.\n * Includes session control methods only safe in user-initiated commands.\n */\nexport interface ExtensionCommandContext extends ExtensionContext {\n\t/** Get the current base system-prompt construction options. */\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\n\t/** Wait for the agent to finish streaming */\n\twaitForIdle(): Promise<void>;\n\n\t/** Start a new session, optionally with initialization. */\n\tnewSession(options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}): Promise<{ cancelled: boolean }>;\n\n\t/** Fork from a specific entry, creating a new session file. */\n\tfork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Navigate to a different point in the session tree. */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Switch to a different session by ID. */\n\tswitchSession(\n\t\tsessionId: string,\n\t\toptions?: { withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Reload extensions, skills, prompts, and themes. */\n\treload(): Promise<void>;\n}\n\n/**\n * Fresh command-capable context bound to the replacement session after a session switch.\n *\n * This is passed to `withSession()` callbacks on `newSession()`, `fork()`, and `switchSession()`.\n */\nexport interface ReplacedSessionContext extends ExtensionCommandContext {\n\tsendMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context-types.js","sourceRoot":"","sources":["../../../src/core/extensions/context-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, ImageContent, Model, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionResult } from \"../compaction/index.ts\";\nimport type { CustomMessage } from \"../messages.ts\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { ReadonlySessionManager, SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport type { WorkflowStageAdmissionBoundary } from \"../workflow-stage-admission.ts\";\nimport type { SendMessageOptions, SendMessagesOptions } from \"./message-types.ts\";\nimport type { ExtensionUIContext } from \"./ui-types.js\";\nimport type { WorkflowActivityObserver, WorkflowActivitySubscription } from \"./workflow-events.js\";\nexport interface ExecuteToolOptions {\n\tsignal?: AbortSignal;\n\tonUpdate?: import(\"@earendil-works/pi-agent-core\").AgentToolUpdateCallback;\n}\n\n/** Tool-only context. Nested calls retain session validation and permission hooks. */\nexport interface ExtensionToolContext extends ExtensionContext {\n\treadonly tools: readonly import(\"@earendil-works/pi-agent-core\").AgentTool[];\n\texecuteTool(\n\t\tname: string,\n\t\targs: unknown,\n\t\toptions?: ExecuteToolOptions,\n\t): Promise<import(\"@earendil-works/pi-agent-core\").AgentToolCallOutcome>;\n}\n\nexport interface ContextUsage {\n\t/** Estimated context tokens, or null if unknown (e.g. right after compaction, before next LLM response). */\n\ttokens: number | null;\n\tcontextWindow: number;\n\t/** Context usage as percentage of context window, or null if tokens is unknown. */\n\tpercent: number | null;\n}\n\nexport interface CompactOptions {\n\t/** Fraction of compactable context to keep. 0.3 is aggressive, 0.7 is light. */\n\tcompression_ratio?: number;\n\t/** Number of recent context-eligible messages to keep uncompressed. */\n\tpreserve_recent?: number;\n\t/** Focus query for relevance-based pruning. Defaults to auto-detected session context. */\n\tquery?: string;\n\t/** Exact `provider/model` ID for this run only; overrides the `compactionModel` setting without saving it. */\n\tcompactionModel?: string;\n\tonComplete?: (result: VerbatimCompactionResult) => void;\n\tonError?: (error: Error) => void;\n}\n\n/**\n * Late routes settle as delivery acknowledgements: resolution means the route\n * accepted delivery, while rejection means delivery was not fully accepted. A\n * sequential batch may have delivered a prefix before it rejects; stale-context\n * rejection identifies the dropped route, and other failures reject unchanged.\n */\nexport interface WorkflowStageLateMessageRouter {\n\trouteMessage<T>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): void | Promise<void>;\n\trouteMessages<T>(\n\t\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\t\toptions?: SendMessagesOptions,\n\t): void | Promise<void>;\n}\n\nexport interface WorkflowStageMessageAdmission {\n\t/** Internal generation-owned boundary shared by every model-fallback session. */\n\treadonly boundary: WorkflowStageAdmissionBoundary;\n\t/** Internal extension state that must survive model-fallback session replacement. */\n\treadonly extensionState: Map<string, object>;\n\tisOpen(): boolean;\n}\n\nexport interface WorkflowPendingStageSender {\n\treadonly id: string;\n\treadonly name?: string;\n\treadonly cwd: string;\n\treadonly model: string;\n\treadonly pid: number;\n\treadonly startedAt: number;\n\treadonly lastActivity: number;\n\treadonly status?: string;\n\treadonly group?: string;\n}\n\nexport interface WorkflowPendingStageMessage {\n\treadonly id: string;\n\treadonly timestamp: number;\n\treadonly replyTo?: string;\n\treadonly expectsReply?: boolean;\n\treadonly replyError?: string;\n\treadonly content: {\n\t\treadonly text: string;\n\t\treadonly attachments?: readonly {\n\t\t\treadonly type: \"file\" | \"snippet\" | \"context\";\n\t\t\treadonly name: string;\n\t\t\treadonly content: string;\n\t\t\treadonly language?: string;\n\t\t}[];\n\t};\n}\n\nexport interface WorkflowPendingStageDelivery {\n\t/** Process-private authority proving this stage belongs to the workflow run route. */\n\treadonly routeCapability: string;\n\tdeliverPending(\n\t\tdeliver: (from: WorkflowPendingStageSender, message: WorkflowPendingStageMessage) => void | Promise<void>,\n\t\trecipient?: { readonly sessionId: string; readonly receivedMessageIds: readonly string[] },\n\t): Promise<void>;\n\tready(sessionId?: string): Promise<void> | undefined;\n\t/**\n\t * Terminal signal from a delivery owner that has run out of recovery: the\n\t * queued messages can no longer be drained, so the stage must fail at its own\n\t * lifecycle boundary rather than run without the instructions it was given.\n\t * Idempotent — the first reason wins, and `ready()` then settles with a\n\t * stage-scoped error instead of waiting for a delivery that will not come.\n\t *\n\t * Required, not optional: `ready()` has no timeout, so a delivery that cannot\n\t * be settled leaves its stage parked forever. Every implementer must be able\n\t * to answer that no delivery is coming.\n\t */\n\tfail(reason: Error): void;\n}\n\nexport interface WorkflowStageOrchestrationContext {\n\treadonly kind: \"workflow-stage\";\n\treadonly workflowRunId: string;\n\treadonly workflowStageId: string;\n\treadonly workflowStageName: string;\n\treadonly constraints: {\n\t\treadonly disableWorkflowTool: true;\n\t};\n\t/** Internal lifecycle seam for surfacing detached results after this stage closes. */\n\treadonly lateMessageRouter?: WorkflowStageLateMessageRouter;\n\t/** Internal synchronous boundary used before producer reply/turn side effects. */\n\treadonly messageAdmission?: WorkflowStageMessageAdmission;\n\t/**\n\t * Resolved per-session intercom home group for this stage. Concrete, already\n\t * normalized upstream. Read by the intercom extension (buildRegistration) and\n\t * inherited by subagents this stage spawns. Absent => no group override.\n\t */\n\treadonly intercomGroup?: string;\n\t/** Durable pre-start intercom delivery, drained by the intercom extension before the first turn. */\n\treadonly pendingStageDelivery?: WorkflowPendingStageDelivery;\n}\n/** Typed child intercom identity and supervisor capability issued at admission. */\nexport interface SubagentIntercomIdentity {\n\treadonly orchestratorTarget: string;\n\treadonly runId: string;\n\treadonly agent: string;\n\treadonly index: number;\n\treadonly sessionName?: string;\n\treadonly supervisor?: {\n\t\treadonly capability: string;\n\t\treadonly supervisorSessionId: string;\n\t};\n}\n\n/** Typed child capability policy supplied by an in-process subagent admission. */\nexport interface SubagentChildPolicy {\n\treadonly managementActions: \"full\" | \"restricted\";\n\treadonly fanoutAuthorized: boolean;\n\treadonly inheritProjectContext: boolean;\n\treadonly inheritSkills: boolean;\n\t/** Host-owned signal fired when this noninteractive execution ends, before disposal. */\n\treadonly executionEnded?: AbortSignal;\n\t/** SDK-owned inbound lifetime; closing drains admitted messages without reopening the task. */\n\treadonly messageAdmission?: {\n\t\tisOpen(): boolean;\n\t\t/** Reserve the full producer operation, including retries, before child settlement. */\n\t\trun(deliver: () => void | Promise<void>): Promise<void>;\n\t};\n\t/** Current admitted in-process nesting depth; absent for top-level sessions. */\n\treadonly depth?: number;\n\t/** SDK-resolved exact child tool allowlist; undefined leaves ordinary tools unrestricted. */\n\treadonly tools?: readonly string[];\n\t/** Server or server/tool selections. Undefined preserves MCP defaults; [] disables selector-based access. */\n\treadonly mcpDirectTools?: readonly string[];\n\t/** Admission-issued identity/capability; never inherited through process environment. */\n\treadonly intercom?: SubagentIntercomIdentity;\n\t/** Resolved intercom group for this admitted child, when one was assigned. */\n\treadonly intercomGroup?: string;\n}\n// Union alias kept for forward-compatible orchestration context variants.\nexport type OrchestrationContext = WorkflowStageOrchestrationContext;\n\n/**\n * Context passed to extension event handlers.\n */\nexport type ExtensionMode = \"tui\" | \"rpc\" | \"json\" | \"print\";\n\nexport interface ExtensionContext {\n\t/** Observe the owning session's workflow activity, starting with an ordered snapshot. */\n\tobserveWorkflowActivity(observer: WorkflowActivityObserver): WorkflowActivitySubscription;\n\t/** Paths of actually loaded extensions, when supplied by the host. */\n\tgetExtensionPaths?(): string[];\n\t/** Internal actual-session binding; never populated from model arguments. */\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n\t/** Internal owner-bound defaults and capability ceiling for builtin child adapters. */\n\tgetChildSessionOptions?: import(\"../child-session-options.ts\").ChildSessionOptionsResolver;\n\t/**\n\t * Internal: a child-options resolver that stays valid after this context's session is replaced or closed (#3981).\n\t * A queued or restored child calls it when it starts, possibly after this context is stale. It answers from the\n\t * owning session's live successor (a workflow stage replaced by model fallback), or from the owning session's last\n\t * state when it has none. Obtain it while the context is live; the call itself asserts that.\n\t */\n\tgetChildSessionOptionsResolver?(): import(\"../child-session-options.ts\").ChildSessionOptionsResolver;\n\t/** Session-scoped orchestration policy for child runtimes such as workflow stages. */\n\treadonly orchestrationContext?: OrchestrationContext;\n\t/** Typed capability policy for an in-process subagent child, when this session is one. */\n\treadonly subagentPolicy?: SubagentChildPolicy;\n\t/** UI methods for user interaction */\n\tui: ExtensionUIContext;\n\t/** Current run mode. Use \"tui\" to guard terminal-only UI such as custom components. */\n\tmode: ExtensionMode;\n\t/** Whether dialog-capable UI is available (true in TUI and RPC modes) */\n\thasUI: boolean;\n\t/** Whether a semantic human-input adapter is available, independently of rendering. */\n\thasHumanInput: boolean;\n\treadonly isPresentationOnly?: boolean;\n\t/** Current working directory */\n\tcwd: string;\n\t/** Session manager (read-only) */\n\tsessionManager: ReadonlySessionManager;\n\t/** Model registry for API key resolution */\n\tmodelRegistry: ModelRegistry;\n\t/** Current model (may be undefined) */\n\tmodel: Model<Api> | undefined;\n\t/** Models scoped to this session (resolved from `--models` / `enabledModels`\n\t * settings against the available catalogue). Same set the `/scoped-models`\n\t * command shows. Empty when no scoping is configured (all available models\n\t * are usable). Read-only snapshot, resolved at access time. */\n\tscopedModels: readonly ScopedModel[];\n\t/** Current thinking level, resolved from the active session at access time. */\n\tthinkingLevel?: ThinkingLevel;\n\t/** Session-scoped internal resource router (e.g. artifact:// resolver). */\n\treadonly internalResourceRouter?: import(\"../tools/resource-selectors.ts\").InternalResourceRouter;\n\t/** Whether the agent is idle (not streaming) */\n\tisIdle(): boolean;\n\t/** Whether project-local trust is active for this context. */\n\tisProjectTrusted(): boolean;\n\t/** The current abort signal, or undefined when the agent is not streaming. */\n\tsignal: AbortSignal | undefined;\n\t/** Ends on reload or shutdown, before admitted work is drained. Independent of agent streaming. */\n\treadonly sessionSignal: AbortSignal;\n\t/**\n\t * @internal The owning session's lifetime signal as it is now. `sessionSignal` is fixed when this context is\n\t * created, so it stays aborted for good once a reload that the host rolls back has begun.\n\t */\n\tgetCurrentSessionSignal?(): AbortSignal;\n\t/** Abort the current agent operation */\n\tabort(): void;\n\t/** Whether there are queued messages waiting */\n\thasPendingMessages(): boolean;\n\t/** Whether background session and workflow summaries are enabled. */\n\tisSessionSummaryEnabled?(): boolean;\n\t/** Generate a read-only workflow summary with this session's model and credentials. */\n\tgenerateWorkflowSummary?(\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t\toptions?: { terminal?: boolean },\n\t): Promise<string | undefined>;\n\t/** Gracefully shutdown pi and exit. Available in all contexts. */\n\tshutdown(): void;\n\t/** Get current context usage for the active model. */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Trigger compaction without awaiting completion. */\n\tcompact(options?: CompactOptions): void;\n\t/** Get the current effective system prompt. */\n\tgetSystemPrompt(): string;\n\t/** Current loader-owned skill candidates and exact selector resolver. */\n\tgetSkillCatalog?(): SkillCatalog;\n\t/** Current routing-only inference setting from the owning session. Does not change the chat model. */\n\tgetRouterModel(): string;\n\t/** Provider filters for `model: \"auto\"` candidates from the owning session's settings. */\n\tgetModelRouting?(): import(\"../settings-types.ts\").ModelRoutingSettings;\n\t/** The owning session's `httpIdleTimeoutMs` setting in milliseconds; 0 means the idle timeout is disabled. */\n\tgetHttpIdleTimeoutMs?(): number;\n}\n\n/**\n * Extended context for command handlers.\n * Includes session control methods only safe in user-initiated commands.\n */\nexport interface ExtensionCommandContext extends ExtensionContext {\n\t/** Get the current base system-prompt construction options. */\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\n\t/** Wait for the agent to finish streaming */\n\twaitForIdle(): Promise<void>;\n\n\t/** Start a new session, optionally with initialization. */\n\tnewSession(options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}): Promise<{ cancelled: boolean }>;\n\n\t/** Fork from a specific entry, creating a new session file. */\n\tfork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Navigate to a different point in the session tree. */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Switch to a different session by ID. */\n\tswitchSession(\n\t\tsessionId: string,\n\t\toptions?: { withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean }>;\n\n\t/** Reload extensions, skills, prompts, and themes. */\n\treload(): Promise<void>;\n}\n\n/**\n * Fresh command-capable context bound to the replacement session after a session switch.\n *\n * This is passed to `withSession()` callbacks on `newSession()`, `fork()`, and `switchSession()`.\n */\nexport interface ReplacedSessionContext extends ExtensionCommandContext {\n\tsendMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-context.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/runner-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,wBAAwB,E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AAM,CAEhE;AAED,KAAK,aAAa,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAChD,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC7D,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;AAI9F,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAI5G;AAED,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAgB7E;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACnH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAYtH,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CASxG;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAYjE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,EAAE,KAAK,GAAE,MAAe,GAAG,gBAAgB,CA6K/G;AAED,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,6BAA6B,EACrC,KAAK,GAAE,MAAe,GACpB,uBAAuB,CA2CzB"}
|
|
@@ -129,6 +129,12 @@ export function createExtensionContext(source, owner = source) {
|
|
|
129
129
|
source.assertAction?.();
|
|
130
130
|
return source.getChildSessionOptions?.(options) ?? options;
|
|
131
131
|
},
|
|
132
|
+
getChildSessionOptionsResolver: () => {
|
|
133
|
+
source.assertActive();
|
|
134
|
+
source.assertAction?.();
|
|
135
|
+
const resolve = source.getChildSessionOptions;
|
|
136
|
+
return (options) => resolve?.(options) ?? options;
|
|
137
|
+
},
|
|
132
138
|
getExtensionPaths: () => {
|
|
133
139
|
source.assertActive();
|
|
134
140
|
return source.getExtensionPaths?.() ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-context.js","sourceRoot":"","sources":["../../../src/core/extensions/runner-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAsE1F;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAI,KAAQ;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAM,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACvE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAM,CAAC;AACnC,CAAC;AAED;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C,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;QACrB,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.js\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport { sessionScratchDir } from \"../storage/session/scratch-directory.js\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { createArtifactRouter, registerArtifactDir } from \"../tools/artifact-protocol.ts\";\nimport type {\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionMode,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSubagentChildPolicy,\n} from \"./types.ts\";\nexport interface ExtensionContextSource {\n\tobserveWorkflowActivity: ExtensionContext[\"observeWorkflowActivity\"];\n\tgetChildSessionOptions?: ExtensionContext[\"getChildSessionOptions\"];\n\tgetExtensionPaths?(): string[];\n\tassertActive(): void;\n\tassertAction?(): void;\n\tgetUIContext(): ExtensionUIContext;\n\tgetMode(): ExtensionMode;\n\thasUI(): boolean;\n\thasHumanInput?(): boolean;\n\tisPresentationOnly?(): boolean;\n\tgetCwd(): string;\n\tgetSessionManager(): SessionManager;\n\tgetModelRegistry(): ModelRegistry;\n\tgetModel(): Model<Api> | undefined;\n\tgetScopedModels(): readonly ScopedModel[];\n\tgetThinkingLevel(): ThinkingLevel | undefined;\n\tgetOrchestrationContext(): OrchestrationContext | undefined;\n\tgetSubagentPolicy(): SubagentChildPolicy | undefined;\n\tisIdle(): boolean;\n\tisProjectTrusted(): boolean;\n\tgetSignal(): AbortSignal | undefined;\n\tgetSessionSignal(): AbortSignal;\n\tabort(): void;\n\thasPendingMessages(): boolean;\n\tisSessionSummaryEnabled?(): boolean;\n\tgenerateWorkflowSummary?(\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t\toptions?: { terminal?: boolean },\n\t): Promise<string | undefined>;\n\tshutdown(): void;\n\tgetContextUsage(): ContextUsage | undefined;\n\tcompact(options?: CompactOptions): void;\n\tgetSystemPrompt(): string;\n\tgetRouterModel?(): string;\n\tgetModelRouting?(): import(\"../settings-types.ts\").ModelRoutingSettings;\n\tgetHttpIdleTimeoutMs?(): number;\n\tgetSkillCatalog?(): SkillCatalog;\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n}\n\nexport interface ExtensionCommandContextSource extends ExtensionContextSource {\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\twaitForIdle(): Promise<void>;\n\tnewSession: NewSessionHandler;\n\tfork: ForkHandler;\n\tnavigateTree: NavigateTreeHandler;\n\tswitchSession: SwitchSessionHandler;\n\treload: ReloadHandler;\n}\n\n/**\n * A copy of `value` that shares no mutable structure with it, frozen through.\n *\n * Arrays and plain objects are rebuilt; everything else — primitives, and any\n * value carrying a prototype this does not own, such as a function or a class\n * instance — is passed through untouched rather than mangled into a plain\n * object. A `Model` is plain data (`input`, `cost.tiers`, `headers`,\n * `thinkingLevelMap`, `compat`), so the whole of one is rebuilt.\n */\nfunction deepFrozenCopy<T>(value: T): T {\n\tif (Array.isArray(value)) return Object.freeze(value.map(deepFrozenCopy)) as T;\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst prototype: unknown = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\tconst copied: Record<string, unknown> = {};\n\tfor (const [key, nested] of Object.entries(value)) copied[key] = deepFrozenCopy(nested);\n\treturn Object.freeze(copied) as T;\n}\n\n/**\n * A defensive copy of the model scope, entries included.\n *\n * `readonly ScopedModel[]` is a compile-time claim only, so the array is\n * copied: a JavaScript extension, or one asserting the `readonly` away, could\n * otherwise push onto the session's own array and have `cycleModel()` treat the\n * entry as in scope.\n *\n * Copying the array alone is not enough. The entries are the session's objects,\n * so mutating `entry.model` or `entry.thinkingLevel` in place reaches the very\n * array `cycleModel()` reads, and swaps the model it selects without ever\n * touching the array.\n *\n * Nor is copying the entry and its model one level deep. `Object.freeze` and a\n * spread both stop at the first level, so `model.headers`, `model.input`,\n * `model.cost.tiers`, `model.thinkingLevelMap` and `model.compat` stayed the\n * session's own objects: writing through any of them changed the model used for\n * selection and request composition, and the freeze reported nothing. The copy\n * goes all the way down, and freezes all the way down with it, so an attempt\n * fails loudly under strict mode instead of silently succeeding.\n *\n * The accessor reports the scope; it must not be a way to change it.\n */\nexport function copyScopedModels(scoped: readonly ScopedModel[]): readonly ScopedModel[] {\n\treturn Object.freeze(scoped.map((entry) => deepFrozenCopy(entry)));\n}\n\n// Private host/builtin bridge, also read by intercom/context-owner.ts. Separate\n// bundles share identity without exposing guarded capabilities or retaining UI.\nconst CONTEXT_OWNERS_KEY = Symbol.for(\"atomic-coding-agent/extension-context-owners@1\");\nconst contextOwnerBag = globalThis as typeof globalThis & { [CONTEXT_OWNERS_KEY]?: WeakMap<object, object> };\ncontextOwnerBag[CONTEXT_OWNERS_KEY] ??= new WeakMap<object, object>();\nconst contextOwners = contextOwnerBag[CONTEXT_OWNERS_KEY];\n\n/** Internal lifecycle identity; contexts themselves are recreated for every dispatch. */\nexport function getExtensionContextOwner(context: object): object {\n\treturn contextOwners.get(context) ?? context;\n}\n\ntype ContextEffect = () => void | Promise<void>;\nexport type ExtensionContextEffectPhase = \"start\" | \"commit\";\ntype ContextPublication = (effect: ContextEffect, phase: ExtensionContextEffectPhase) => void;\nconst contextPublications = new WeakMap<object, ContextPublication>();\nconst contextRetirements = new WeakMap<object, Set<() => void>>();\n\nexport function bindExtensionContextPublication(context: object, stage: ContextPublication | undefined): void {\n\tconst owner = getExtensionContextOwner(context);\n\tif (stage) contextPublications.set(owner, stage);\n\telse contextPublications.delete(owner);\n}\n\nexport function runSynchronousExtensionContextEffect(effect: () => void): void {\n\tif (effect.constructor.name === \"AsyncFunction\") {\n\t\tthrow new TypeError(\"Extension commit and retirement effects must be synchronous\");\n\t}\n\tconst result: unknown = effect();\n\tif (\n\t\tresult &&\n\t\t(typeof result === \"object\" || typeof result === \"function\") &&\n\t\t\"then\" in result &&\n\t\ttypeof result.then === \"function\"\n\t) {\n\t\tvoid Promise.resolve(result).catch((error: unknown) =>\n\t\t\tconsole.error(\"Invalid asynchronous extension effect failed\", error),\n\t\t);\n\t\tthrow new TypeError(\"Extension commit and retirement effects must be synchronous\");\n\t}\n}\n\nexport function publishExtensionContextEffect(context: object, effect: () => void, phase: \"commit\"): Promise<void>;\nexport function publishExtensionContextEffect(context: object, effect: ContextEffect, phase?: \"start\"): Promise<void>;\nexport async function publishExtensionContextEffect(\n\tcontext: object,\n\teffect: ContextEffect,\n\tphase: ExtensionContextEffectPhase = \"start\",\n): Promise<void> {\n\tconst stage = contextPublications.get(getExtensionContextOwner(context));\n\tif (stage) stage(effect, phase);\n\telse if (phase === \"commit\") runSynchronousExtensionContextEffect(effect);\n\telse await effect();\n}\n\nexport function registerExtensionContextRetirementEffect(context: object, effect: () => void): () => void {\n\tconst owner = getExtensionContextOwner(context);\n\tlet effects = contextRetirements.get(owner);\n\tif (!effects) {\n\t\teffects = new Set();\n\t\tcontextRetirements.set(owner, effects);\n\t}\n\teffects.add(effect);\n\treturn () => effects.delete(effect);\n}\n\nexport function retireExtensionContextEffects(owner: object): void {\n\tconst effects = contextRetirements.get(owner);\n\tcontextRetirements.delete(owner);\n\tconst failures: unknown[] = [];\n\tfor (const effect of effects ?? []) {\n\t\ttry {\n\t\t\trunSynchronousExtensionContextEffect(effect);\n\t\t} catch (error) {\n\t\t\tfailures.push(error);\n\t\t}\n\t}\n\tif (failures.length) throw new AggregateError(failures, \"Extension observation retirement failed\");\n}\n\n/**\n * Create an ExtensionContext for use in event handlers and tool execution.\n * Context values are resolved at call time, so host changes are reflected.\n */\nexport function createExtensionContext(source: ExtensionContextSource, owner: object = source): ExtensionContext {\n\tconst context: ExtensionContext = {\n\t\tsessionSignal: source.getSessionSignal(),\n\t\tgetCurrentSessionSignal: () => source.getSessionSignal(),\n\t\tgetChildSessionOptions: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\treturn source.getChildSessionOptions?.(options) ?? options;\n\t\t},\n\t\tgetExtensionPaths: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getExtensionPaths?.() ?? [];\n\t\t},\n\t\t...(source.getAgentTaskHost\n\t\t\t? {\n\t\t\t\t\tgetAgentTaskHost: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\tsource.assertAction?.();\n\t\t\t\t\t\treturn source.getAgentTaskHost!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tget ui() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getUIContext();\n\t\t},\n\t\tget mode() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getMode();\n\t\t},\n\t\tobserveWorkflowActivity: (observer) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\treturn source.observeWorkflowActivity(observer);\n\t\t},\n\t\tget hasHumanInput() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasHumanInput?.() ?? source.hasUI();\n\t\t},\n\t\tget hasUI() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasUI();\n\t\t},\n\t\tget isPresentationOnly() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isPresentationOnly?.() ?? false;\n\t\t},\n\t\tget cwd() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getCwd();\n\t\t},\n\t\tget sessionManager() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSessionManager();\n\t\t},\n\t\tget modelRegistry() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRegistry();\n\t\t},\n\t\tget model() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModel();\n\t\t},\n\t\tget scopedModels() {\n\t\t\tsource.assertActive();\n\t\t\treturn copyScopedModels(source.getScopedModels());\n\t\t},\n\t\tget thinkingLevel() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getThinkingLevel();\n\t\t},\n\t\tget internalResourceRouter() {\n\t\t\tsource.assertActive();\n\t\t\tconst manager = source.getSessionManager();\n\t\t\tconst sessionDir =\n\t\t\t\tmanager.getSessionDir() ||\n\t\t\t\t(manager.isPersisted()\n\t\t\t\t\t? sessionScratchDir(getAgentDir(), manager.getCwd(), manager.getSessionId())\n\t\t\t\t\t: undefined);\n\t\t\tif (!sessionDir) return undefined;\n\t\t\tconst artifactsDir = join(sessionDir, \"artifacts\");\n\t\t\tregisterArtifactDir(artifactsDir);\n\t\t\treturn createArtifactRouter(() => [artifactsDir]);\n\t\t},\n\t\tget orchestrationContext() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getOrchestrationContext();\n\t\t},\n\t\tget subagentPolicy() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSubagentPolicy();\n\t\t},\n\t\tisIdle: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isIdle();\n\t\t},\n\t\tisProjectTrusted: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isProjectTrusted();\n\t\t},\n\t\tget signal() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSignal();\n\t\t},\n\t\tabort: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.abort();\n\t\t},\n\t\thasPendingMessages: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasPendingMessages();\n\t\t},\n\t\tisSessionSummaryEnabled: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isSessionSummaryEnabled?.() ?? false;\n\t\t},\n\t\tgenerateWorkflowSummary: (text, signal, options) => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.generateWorkflowSummary?.(text, signal, options) ?? Promise.resolve(undefined);\n\t\t},\n\t\tshutdown: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.shutdown();\n\t\t},\n\t\tgetContextUsage: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getContextUsage();\n\t\t},\n\t\tcompact: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.compact(options);\n\t\t},\n\t\tgetRouterModel: () => {\n\t\t\tsource.assertActive();\n\t\t\tif (!source.getRouterModel) throw new Error(\"Router settings are unavailable in this extension host.\");\n\t\t\treturn source.getRouterModel();\n\t\t},\n\t\tgetModelRouting: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRouting?.() ?? {};\n\t\t},\n\t\t...(source.getHttpIdleTimeoutMs\n\t\t\t? {\n\t\t\t\t\tgetHttpIdleTimeoutMs: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getHttpIdleTimeoutMs!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tgetSystemPrompt: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSystemPrompt();\n\t\t},\n\t\t...(source.getSkillCatalog\n\t\t\t? {\n\t\t\t\t\tgetSkillCatalog: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getSkillCatalog!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n\nexport function createExtensionCommandContext(\n\tsource: ExtensionCommandContextSource,\n\towner: object = source,\n): ExtensionCommandContext {\n\t// Use property descriptors instead of object spread so the guarded getters from\n\t// createExtensionContext() stay lazy. A spread would eagerly read them once and\n\t// freeze old values into the returned object, bypassing stale-instance checks.\n\tconst context = Object.defineProperties(\n\t\t{},\n\t\tObject.getOwnPropertyDescriptors(createExtensionContext(source, owner)),\n\t) as ExtensionCommandContext;\n\tcontext.getSystemPromptOptions = () => {\n\t\tsource.assertActive();\n\t\treturn source.getSystemPromptOptions();\n\t};\n\tcontext.waitForIdle = () => {\n\t\tsource.assertActive();\n\t\treturn source.waitForIdle();\n\t};\n\tcontext.newSession = (options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.newSession(options);\n\t};\n\tcontext.fork = (entryId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.fork(entryId, options);\n\t};\n\tcontext.navigateTree = (targetId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.navigateTree(targetId, options);\n\t};\n\tcontext.switchSession = (sessionId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.switchSession(sessionId, options);\n\t};\n\tcontext.reload = () => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.reload();\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runner-context.js","sourceRoot":"","sources":["../../../src/core/extensions/runner-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;A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O,EAAE,KAAK,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.js\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport { sessionScratchDir } from \"../storage/session/scratch-directory.js\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { createArtifactRouter, registerArtifactDir } from \"../tools/artifact-protocol.ts\";\nimport type {\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionMode,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSubagentChildPolicy,\n} from \"./types.ts\";\nexport interface ExtensionContextSource {\n\tobserveWorkflowActivity: ExtensionContext[\"observeWorkflowActivity\"];\n\tgetChildSessionOptions?: ExtensionContext[\"getChildSessionOptions\"];\n\tgetExtensionPaths?(): string[];\n\tassertActive(): void;\n\tassertAction?(): void;\n\tgetUIContext(): ExtensionUIContext;\n\tgetMode(): ExtensionMode;\n\thasUI(): boolean;\n\thasHumanInput?(): boolean;\n\tisPresentationOnly?(): boolean;\n\tgetCwd(): string;\n\tgetSessionManager(): SessionManager;\n\tgetModelRegistry(): ModelRegistry;\n\tgetModel(): Model<Api> | undefined;\n\tgetScopedModels(): readonly ScopedModel[];\n\tgetThinkingLevel(): ThinkingLevel | undefined;\n\tgetOrchestrationContext(): OrchestrationContext | undefined;\n\tgetSubagentPolicy(): SubagentChildPolicy | undefined;\n\tisIdle(): boolean;\n\tisProjectTrusted(): boolean;\n\tgetSignal(): AbortSignal | undefined;\n\tgetSessionSignal(): AbortSignal;\n\tabort(): void;\n\thasPendingMessages(): boolean;\n\tisSessionSummaryEnabled?(): boolean;\n\tgenerateWorkflowSummary?(\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t\toptions?: { terminal?: boolean },\n\t): Promise<string | undefined>;\n\tshutdown(): void;\n\tgetContextUsage(): ContextUsage | undefined;\n\tcompact(options?: CompactOptions): void;\n\tgetSystemPrompt(): string;\n\tgetRouterModel?(): string;\n\tgetModelRouting?(): import(\"../settings-types.ts\").ModelRoutingSettings;\n\tgetHttpIdleTimeoutMs?(): number;\n\tgetSkillCatalog?(): SkillCatalog;\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n}\n\nexport interface ExtensionCommandContextSource extends ExtensionContextSource {\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\twaitForIdle(): Promise<void>;\n\tnewSession: NewSessionHandler;\n\tfork: ForkHandler;\n\tnavigateTree: NavigateTreeHandler;\n\tswitchSession: SwitchSessionHandler;\n\treload: ReloadHandler;\n}\n\n/**\n * A copy of `value` that shares no mutable structure with it, frozen through.\n *\n * Arrays and plain objects are rebuilt; everything else — primitives, and any\n * value carrying a prototype this does not own, such as a function or a class\n * instance — is passed through untouched rather than mangled into a plain\n * object. A `Model` is plain data (`input`, `cost.tiers`, `headers`,\n * `thinkingLevelMap`, `compat`), so the whole of one is rebuilt.\n */\nfunction deepFrozenCopy<T>(value: T): T {\n\tif (Array.isArray(value)) return Object.freeze(value.map(deepFrozenCopy)) as T;\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst prototype: unknown = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\tconst copied: Record<string, unknown> = {};\n\tfor (const [key, nested] of Object.entries(value)) copied[key] = deepFrozenCopy(nested);\n\treturn Object.freeze(copied) as T;\n}\n\n/**\n * A defensive copy of the model scope, entries included.\n *\n * `readonly ScopedModel[]` is a compile-time claim only, so the array is\n * copied: a JavaScript extension, or one asserting the `readonly` away, could\n * otherwise push onto the session's own array and have `cycleModel()` treat the\n * entry as in scope.\n *\n * Copying the array alone is not enough. The entries are the session's objects,\n * so mutating `entry.model` or `entry.thinkingLevel` in place reaches the very\n * array `cycleModel()` reads, and swaps the model it selects without ever\n * touching the array.\n *\n * Nor is copying the entry and its model one level deep. `Object.freeze` and a\n * spread both stop at the first level, so `model.headers`, `model.input`,\n * `model.cost.tiers`, `model.thinkingLevelMap` and `model.compat` stayed the\n * session's own objects: writing through any of them changed the model used for\n * selection and request composition, and the freeze reported nothing. The copy\n * goes all the way down, and freezes all the way down with it, so an attempt\n * fails loudly under strict mode instead of silently succeeding.\n *\n * The accessor reports the scope; it must not be a way to change it.\n */\nexport function copyScopedModels(scoped: readonly ScopedModel[]): readonly ScopedModel[] {\n\treturn Object.freeze(scoped.map((entry) => deepFrozenCopy(entry)));\n}\n\n// Private host/builtin bridge, also read by intercom/context-owner.ts. Separate\n// bundles share identity without exposing guarded capabilities or retaining UI.\nconst CONTEXT_OWNERS_KEY = Symbol.for(\"atomic-coding-agent/extension-context-owners@1\");\nconst contextOwnerBag = globalThis as typeof globalThis & { [CONTEXT_OWNERS_KEY]?: WeakMap<object, object> };\ncontextOwnerBag[CONTEXT_OWNERS_KEY] ??= new WeakMap<object, object>();\nconst contextOwners = contextOwnerBag[CONTEXT_OWNERS_KEY];\n\n/** Internal lifecycle identity; contexts themselves are recreated for every dispatch. */\nexport function getExtensionContextOwner(context: object): object {\n\treturn contextOwners.get(context) ?? context;\n}\n\ntype ContextEffect = () => void | Promise<void>;\nexport type ExtensionContextEffectPhase = \"start\" | \"commit\";\ntype ContextPublication = (effect: ContextEffect, phase: ExtensionContextEffectPhase) => void;\nconst contextPublications = new WeakMap<object, ContextPublication>();\nconst contextRetirements = new WeakMap<object, Set<() => void>>();\n\nexport function bindExtensionContextPublication(context: object, stage: ContextPublication | undefined): void {\n\tconst owner = getExtensionContextOwner(context);\n\tif (stage) contextPublications.set(owner, stage);\n\telse contextPublications.delete(owner);\n}\n\nexport function runSynchronousExtensionContextEffect(effect: () => void): void {\n\tif (effect.constructor.name === \"AsyncFunction\") {\n\t\tthrow new TypeError(\"Extension commit and retirement effects must be synchronous\");\n\t}\n\tconst result: unknown = effect();\n\tif (\n\t\tresult &&\n\t\t(typeof result === \"object\" || typeof result === \"function\") &&\n\t\t\"then\" in result &&\n\t\ttypeof result.then === \"function\"\n\t) {\n\t\tvoid Promise.resolve(result).catch((error: unknown) =>\n\t\t\tconsole.error(\"Invalid asynchronous extension effect failed\", error),\n\t\t);\n\t\tthrow new TypeError(\"Extension commit and retirement effects must be synchronous\");\n\t}\n}\n\nexport function publishExtensionContextEffect(context: object, effect: () => void, phase: \"commit\"): Promise<void>;\nexport function publishExtensionContextEffect(context: object, effect: ContextEffect, phase?: \"start\"): Promise<void>;\nexport async function publishExtensionContextEffect(\n\tcontext: object,\n\teffect: ContextEffect,\n\tphase: ExtensionContextEffectPhase = \"start\",\n): Promise<void> {\n\tconst stage = contextPublications.get(getExtensionContextOwner(context));\n\tif (stage) stage(effect, phase);\n\telse if (phase === \"commit\") runSynchronousExtensionContextEffect(effect);\n\telse await effect();\n}\n\nexport function registerExtensionContextRetirementEffect(context: object, effect: () => void): () => void {\n\tconst owner = getExtensionContextOwner(context);\n\tlet effects = contextRetirements.get(owner);\n\tif (!effects) {\n\t\teffects = new Set();\n\t\tcontextRetirements.set(owner, effects);\n\t}\n\teffects.add(effect);\n\treturn () => effects.delete(effect);\n}\n\nexport function retireExtensionContextEffects(owner: object): void {\n\tconst effects = contextRetirements.get(owner);\n\tcontextRetirements.delete(owner);\n\tconst failures: unknown[] = [];\n\tfor (const effect of effects ?? []) {\n\t\ttry {\n\t\t\trunSynchronousExtensionContextEffect(effect);\n\t\t} catch (error) {\n\t\t\tfailures.push(error);\n\t\t}\n\t}\n\tif (failures.length) throw new AggregateError(failures, \"Extension observation retirement failed\");\n}\n\n/**\n * Create an ExtensionContext for use in event handlers and tool execution.\n * Context values are resolved at call time, so host changes are reflected.\n */\nexport function createExtensionContext(source: ExtensionContextSource, owner: object = source): ExtensionContext {\n\tconst context: ExtensionContext = {\n\t\tsessionSignal: source.getSessionSignal(),\n\t\tgetCurrentSessionSignal: () => source.getSessionSignal(),\n\t\tgetChildSessionOptions: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\treturn source.getChildSessionOptions?.(options) ?? options;\n\t\t},\n\t\tgetChildSessionOptionsResolver: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tconst resolve = source.getChildSessionOptions;\n\t\t\treturn (options) => resolve?.(options) ?? options;\n\t\t},\n\t\tgetExtensionPaths: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getExtensionPaths?.() ?? [];\n\t\t},\n\t\t...(source.getAgentTaskHost\n\t\t\t? {\n\t\t\t\t\tgetAgentTaskHost: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\tsource.assertAction?.();\n\t\t\t\t\t\treturn source.getAgentTaskHost!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tget ui() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getUIContext();\n\t\t},\n\t\tget mode() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getMode();\n\t\t},\n\t\tobserveWorkflowActivity: (observer) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\treturn source.observeWorkflowActivity(observer);\n\t\t},\n\t\tget hasHumanInput() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasHumanInput?.() ?? source.hasUI();\n\t\t},\n\t\tget hasUI() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasUI();\n\t\t},\n\t\tget isPresentationOnly() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isPresentationOnly?.() ?? false;\n\t\t},\n\t\tget cwd() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getCwd();\n\t\t},\n\t\tget sessionManager() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSessionManager();\n\t\t},\n\t\tget modelRegistry() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRegistry();\n\t\t},\n\t\tget model() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModel();\n\t\t},\n\t\tget scopedModels() {\n\t\t\tsource.assertActive();\n\t\t\treturn copyScopedModels(source.getScopedModels());\n\t\t},\n\t\tget thinkingLevel() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getThinkingLevel();\n\t\t},\n\t\tget internalResourceRouter() {\n\t\t\tsource.assertActive();\n\t\t\tconst manager = source.getSessionManager();\n\t\t\tconst sessionDir =\n\t\t\t\tmanager.getSessionDir() ||\n\t\t\t\t(manager.isPersisted()\n\t\t\t\t\t? sessionScratchDir(getAgentDir(), manager.getCwd(), manager.getSessionId())\n\t\t\t\t\t: undefined);\n\t\t\tif (!sessionDir) return undefined;\n\t\t\tconst artifactsDir = join(sessionDir, \"artifacts\");\n\t\t\tregisterArtifactDir(artifactsDir);\n\t\t\treturn createArtifactRouter(() => [artifactsDir]);\n\t\t},\n\t\tget orchestrationContext() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getOrchestrationContext();\n\t\t},\n\t\tget subagentPolicy() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSubagentPolicy();\n\t\t},\n\t\tisIdle: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isIdle();\n\t\t},\n\t\tisProjectTrusted: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isProjectTrusted();\n\t\t},\n\t\tget signal() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSignal();\n\t\t},\n\t\tabort: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.abort();\n\t\t},\n\t\thasPendingMessages: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasPendingMessages();\n\t\t},\n\t\tisSessionSummaryEnabled: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isSessionSummaryEnabled?.() ?? false;\n\t\t},\n\t\tgenerateWorkflowSummary: (text, signal, options) => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.generateWorkflowSummary?.(text, signal, options) ?? Promise.resolve(undefined);\n\t\t},\n\t\tshutdown: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.shutdown();\n\t\t},\n\t\tgetContextUsage: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getContextUsage();\n\t\t},\n\t\tcompact: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.assertAction?.();\n\t\t\tsource.compact(options);\n\t\t},\n\t\tgetRouterModel: () => {\n\t\t\tsource.assertActive();\n\t\t\tif (!source.getRouterModel) throw new Error(\"Router settings are unavailable in this extension host.\");\n\t\t\treturn source.getRouterModel();\n\t\t},\n\t\tgetModelRouting: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRouting?.() ?? {};\n\t\t},\n\t\t...(source.getHttpIdleTimeoutMs\n\t\t\t? {\n\t\t\t\t\tgetHttpIdleTimeoutMs: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getHttpIdleTimeoutMs!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tgetSystemPrompt: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSystemPrompt();\n\t\t},\n\t\t...(source.getSkillCatalog\n\t\t\t? {\n\t\t\t\t\tgetSkillCatalog: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getSkillCatalog!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n\nexport function createExtensionCommandContext(\n\tsource: ExtensionCommandContextSource,\n\towner: object = source,\n): ExtensionCommandContext {\n\t// Use property descriptors instead of object spread so the guarded getters from\n\t// createExtensionContext() stay lazy. A spread would eagerly read them once and\n\t// freeze old values into the returned object, bypassing stale-instance checks.\n\tconst context = Object.defineProperties(\n\t\t{},\n\t\tObject.getOwnPropertyDescriptors(createExtensionContext(source, owner)),\n\t) as ExtensionCommandContext;\n\tcontext.getSystemPromptOptions = () => {\n\t\tsource.assertActive();\n\t\treturn source.getSystemPromptOptions();\n\t};\n\tcontext.waitForIdle = () => {\n\t\tsource.assertActive();\n\t\treturn source.waitForIdle();\n\t};\n\tcontext.newSession = (options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.newSession(options);\n\t};\n\tcontext.fork = (entryId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.fork(entryId, options);\n\t};\n\tcontext.navigateTree = (targetId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.navigateTree(targetId, options);\n\t};\n\tcontext.switchSession = (sessionId, options) => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.switchSession(sessionId, options);\n\t};\n\tcontext.reload = () => {\n\t\tsource.assertActive();\n\t\tsource.assertAction?.();\n\t\treturn source.reload();\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AutocompleteProvider, Component, EditorComponent, EditorTheme, OverlayHandle, OverlayOptions, TUI } from "@earendil-works/pi-tui";
|
|
1
|
+
import type { AutocompleteProvider, Component, EditorComponent, EditorTheme, OverlayHandle, OverlayOptions, ProgramStatus, TUI } from "@earendil-works/pi-tui";
|
|
2
2
|
import type { Theme } from "../../modes/interactive/theme/theme.js";
|
|
3
3
|
import type { ReadonlyFooterDataProvider } from "../footer-data-provider.ts";
|
|
4
4
|
import type { KeybindingsManager } from "../keybindings.ts";
|
|
@@ -286,6 +286,14 @@ export interface ExtensionUIContext {
|
|
|
286
286
|
overlayOptions?: OverlayOptions | (() => OverlayOptions);
|
|
287
287
|
/** Called with the overlay handle after the overlay is shown. Use to control visibility. */
|
|
288
288
|
onHandle?: (handle: OverlayHandle) => void;
|
|
289
|
+
/**
|
|
290
|
+
* Report Atomic as blocked on user input (OSC 7501 program status) while this component is visible.
|
|
291
|
+
* Only applies to inline components, not overlays.
|
|
292
|
+
*/
|
|
293
|
+
blocked?: {
|
|
294
|
+
kind: NonNullable<ProgramStatus["kind"]>;
|
|
295
|
+
message: string;
|
|
296
|
+
};
|
|
289
297
|
}): Promise<T>;
|
|
290
298
|
/**
|
|
291
299
|
* Open a session-list picker that runs natively in the host terminal
|