@bastani/atomic 0.9.80 → 0.9.81-alpha.1
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 +38 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/client.ts +12 -1
- package/dist/builtin/intercom/index.bundle.mjs +16 -4
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +10 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +40 -2
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +123 -25
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +10 -0
- package/dist/builtin/workflows/builtin/{chunk-m56qhe4b.js → chunk-zpkcqyhr.js} +2 -0
- package/dist/builtin/workflows/builtin/index.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +16 -4
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +12 -2
- package/dist/builtin/workflows/src/index.js +12 -2
- package/dist/builtin/workflows/src/local-worker-entry.mjs +12 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +8 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/cache-stats.d.ts +21 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +42 -2
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/exec.d.ts +1 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +2 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/execution-model-router.d.ts +17 -0
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +52 -23
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +1 -0
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +0 -1
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +0 -8
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-routing-candidates.d.ts +30 -5
- package/dist/core/model-routing-candidates.d.ts.map +1 -1
- package/dist/core/model-routing-candidates.js +381 -105
- package/dist/core/model-routing-candidates.js.map +1 -1
- package/dist/core/model-routing-estimates.d.ts +70 -0
- package/dist/core/model-routing-estimates.d.ts.map +1 -0
- package/dist/core/model-routing-estimates.js +244 -0
- package/dist/core/model-routing-estimates.js.map +1 -0
- package/dist/core/model-routing-needs.d.ts +1 -0
- package/dist/core/model-routing-needs.d.ts.map +1 -1
- package/dist/core/model-routing-needs.js +1 -1
- package/dist/core/model-routing-needs.js.map +1 -1
- package/dist/core/provider-display-names.js +2 -2
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +6 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +1 -1
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +20 -11
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +2 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +30 -10
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +86 -9
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +6 -3
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +5 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +11 -4
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +4 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +24 -1
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +29 -36
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +6 -6
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +11 -3
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +11 -1
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +34 -7
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +24 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +61 -0
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +2 -3
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +10 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +3 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +4 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/docs/background-tasks.md +2 -2
- package/docs/extensions/api-reference.md +1 -1
- package/docs/models/model-selection.md +7 -7
- package/docs/providers.md +12 -17
- package/docs/skills.md +1 -1
- package/docs/subagents.md +3 -1
- package/docs/tools.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows/authoring.md +2 -0
- package/docs/workflows/operations.md +1 -1
- package/npm-shrinkwrap.json +57 -33
- package/package.json +3 -3
|
@@ -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,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAEN,cAAc,EACd,WAAW,EAEX,cAAc,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,YAAY,EAGZ,qBAAqB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EAEd,gBAAgB,GAEhB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAuBtG;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACnD;;;;OAIG;IACM,iBAAiB,CAAc;IAExC,YAAY,OAAe,EAAE,iBAA8B,EAA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C,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YACvE,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO;QACN,eAAe;QACf,aAAa,EAAE,eAAe,CAAC,KAAK,GAAG,CAAC,eAAe,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 { getDocsPath } from \"../config.js\";\nimport { decide, decideWithModel } from \"./decision/decide.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 { resolveDecisionModel } 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\tgetDecisionModel(): 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, options?: ErrorOptions) {\n\t\tsuper(message, options);\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\tgetDecisionModel: () => ctx.getDecisionModel(),\n\t\t\t...(ctx.getHttpIdleTimeoutMs ? { getHttpIdleTimeoutMs: () => ctx.getHttpIdleTimeoutMs!() } : {}),\n\t\t};\n\t\tconst router = resolveDecisionModel({ 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>(ask: (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(() => ask(inferenceSignal), inferenceSignal) : ask(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\tdeadline?.aborted ? undefined : { cause: error },\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 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\t// A classifier never receives the task: the reader is a chat model.\n\t\t\t\tdecideWithModel(\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\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\tquestions: Object.fromEntries(\n\t\t\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\t\t\t{ type: \"choice\" as const, instructions: question.instructions, criteria: question.criteria },\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t\t...(inferenceSignal ? { signal: inferenceSignal } : {}),\n\t\t\t\t\t},\n\t\t\t\t\t{ kind: \"chat\", fullId: reader!, model: readerModel! },\n\t\t\t\t),\n\t\t\t);\n\t\t\tanswers = Object.fromEntries(Object.entries(result.answers).map(([id, answer]) => [id, answer.choice]));\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 result = await infer((inferenceSignal) =>\n\t\t\t\tdecide({\n\t\t\t\t\tsettings,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\tstate: { ...choiceState },\n\t\t\t\t\tinstructions: CHOICE_INSTRUCTIONS,\n\t\t\t\t\tquestions: {\n\t\t\t\t\t\tmodel: {\n\t\t\t\t\t\t\ttype: \"choice\",\n\t\t\t\t\t\t\tinstructions: \"Which model should do this task?\",\n\t\t\t\t\t\t\tcriteria: describeAll(shortlist),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t...(inferenceSignal ? { signal: inferenceSignal } : {}),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tchosen = shortlist[keys.indexOf(result.answers.model.choice)]!;\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,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,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO;QACN,eAAe;QACf,aAAa,EAAE,eAAe,CAAC,KAAK,GAAG,CAAC,eAAe,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 { getDocsPath } from \"../config.js\";\nimport { decide, decideWithModel } from \"./decision/decide.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 { type EvalsCatalog, modelEvidenceTokens, 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 { resolveDecisionModel } 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\tgetDecisionModel(): 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, options?: ErrorOptions) {\n\t\tsuper(message, options);\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. The work standing compares a cautious estimate of the model's quality for this work with every benchmarked model; results marked estimated are inferred from the model's other results, not measured, and carry their uncertainty. 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\n/**\n * What ranking needs to know about a catalog model, priced at its fast route's rates when it is one.\n * `efforts` are the levels it may run at; they default to every level the model supports.\n */\nexport function routingCandidate(\n\tmodel: Model<Api>,\n\tefforts: readonly (string | null)[] = model.reasoning ? getSupportedThinkingLevels(model) : [null],\n): CandidateModel {\n\tconst routeCost = model.fastRoute?.serviceTier ? getServiceTierCost(model, model.fastRoute.serviceTier) : undefined;\n\treturn {\n\t\tmodel: `${model.provider}/${model.id}`,\n\t\tname: model.name,\n\t\tcost: routeCost ?? model.cost,\n\t\tinput: model.input,\n\t\tefforts,\n\t\t...(model.fastRoute\n\t\t\t? {\n\t\t\t\t\tfastRouteOf: `${model.provider}/${model.fastRoute.baseModelId}`,\n\t\t\t\t\tfastRouteServiceTier: model.fastRoute.serviceTier,\n\t\t\t\t\tfastRoutePriced: routeCost !== undefined,\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n}\n\n/**\n * One of `count` routes made together, for example parallel reviewers, which\n * gain little from running the same model twice.\n */\nexport interface ParallelSlot {\n\t/** This route's position among the routes made together, from 0. */\n\treadonly index: number;\n\treadonly count: number;\n}\n\n/** A model's family: the vendor line its name starts with, such as `claude`, `gpt` or `gemini`. */\nconst modelFamily = (candidate: RankedCandidate) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model)[0];\n\n/**\n * Candidates for one slot of routes made together. Model families, in ranking\n * order, are dealt to slots in turn, so every slot of the same task routes to\n * a different family while each still gets a strong one. A slot left without\n * a family, because fewer families are eligible than slots, keeps every candidate.\n */\nfunction slotCandidates(ranked: readonly RankedCandidate[], slot: ParallelSlot | undefined): RankedCandidate[] {\n\tif (slot === undefined || slot.count < 2) return [...ranked];\n\tconst families = [...new Set(ranked.map(modelFamily))];\n\tconst own = new Set(families.filter((_, position) => position % slot.count === slot.index % slot.count));\n\tconst kept = ranked.filter((candidate) => own.has(modelFamily(candidate)));\n\treturn kept.length > 0 ? kept : [...ranked];\n}\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\nlet lastEvals: { readonly text: string; readonly catalog: EvalsCatalog } | undefined;\n\n/**\n * The parsed catalog for this evals.md text, reused while the text is unchanged\n * so the benchmark completion fitted on it is computed once per process.\n */\nfunction parsedEvals(text: string): EvalsCatalog {\n\tif (lastEvals?.text !== text) lastEvals = { text, catalog: parseEvalsCatalog(text) };\n\treturn lastEvals.catalog;\n}\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\t/** This route is one of several made together; each slot prefers a different model family. */\n\tparallelSlot?: ParallelSlot;\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\tgetDecisionModel: () => ctx.getDecisionModel(),\n\t\t\t...(ctx.getHttpIdleTimeoutMs ? { getHttpIdleTimeoutMs: () => ctx.getHttpIdleTimeoutMs!() } : {}),\n\t\t};\n\t\tconst router = resolveDecisionModel({ 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>(ask: (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(() => ask(inferenceSignal), inferenceSignal) : ask(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\tdeadline?.aborted ? undefined : { cause: error },\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(parsedEvals)\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 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\t// A classifier never receives the task: the reader is a chat model.\n\t\t\t\tdecideWithModel(\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\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\tquestions: Object.fromEntries(\n\t\t\t\t\t\t\tquestions.map((question) => [\n\t\t\t\t\t\t\t\tquestion.id,\n\t\t\t\t\t\t\t\t{ type: \"choice\" as const, instructions: question.instructions, criteria: question.criteria },\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t\t...(inferenceSignal ? { signal: inferenceSignal } : {}),\n\t\t\t\t\t},\n\t\t\t\t\t{ kind: \"chat\", fullId: reader!, model: readerModel! },\n\t\t\t\t),\n\t\t\t);\n\t\t\tanswers = Object.fromEntries(Object.entries(result.answers).map(([id, answer]) => [id, answer.choice]));\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\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(\n\t\t\tcatalogEvals,\n\t\t\treference.map((model) =>\n\t\t\t\troutingCandidate(\n\t\t\t\t\tmodel,\n\t\t\t\t\tpairsFor.get(`${model.provider}/${model.id}`)?.map((pair) => pair.effort),\n\t\t\t\t),\n\t\t\t),\n\t\t\tneeds,\n\t\t);\n\t\tconst ranked = slotCandidates(\n\t\t\tstandings.filter((candidate) => pairsFor.has(candidate.model)),\n\t\t\tinput.parallelSlot,\n\t\t);\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 result = await infer((inferenceSignal) =>\n\t\t\t\tdecide({\n\t\t\t\t\tsettings,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\tstate: { ...choiceState },\n\t\t\t\t\tinstructions: CHOICE_INSTRUCTIONS,\n\t\t\t\t\tquestions: {\n\t\t\t\t\t\tmodel: {\n\t\t\t\t\t\t\ttype: \"choice\",\n\t\t\t\t\t\t\tinstructions: \"Which model should do this task?\",\n\t\t\t\t\t\t\tcriteria: describeAll(shortlist),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t...(inferenceSignal ? { signal: inferenceSignal } : {}),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tchosen = shortlist[keys.indexOf(result.answers.model.choice)]!;\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fallback-failures.d.ts","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"model-fallback-failures.d.ts","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0FH,MAAM,MAAM,wBAAwB,GACjC,4BAA4B,GAC5B,YAAY,GACZ,iBAAiB,GACj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,EAAE,2BAA2B,GAAG,OAAO,CAKtG;AAwBD,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAInE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fallback-failures.js","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,sBAAsB,EAGtB,kCAAkC,GAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,gCAAgC,GAAsB;IAC3D,eAAe;IACf,wBAAwB;IACxB,wBAAwB;IACxB,SAAS;IACT,QAAQ;IACR,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,gCAAgC;IAChC,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,sBAAsB;IACtB,sCAAsC;IACtC,+CAA+C;IAC/C,YAAY;IACZ,gBAAgB;IAChB,aAAa;IACb,4BAA4B;IAC5B,wBAAwB;IACxB,UAAU;IACV,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,uBAAuB;IACvB,WAAW;IACX,UAAU;IACV,cAAc;IACd,aAAa;IACb,aAAa;IACb,SAAS;IACT,4BAA4B;IAC5B,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,mBAAmB;IACnB,oBAAoB;IACpB,aAAa;IACb,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,gBAAgB;IAChB,mCAAmC;IACnC,gDAAgD;IAChD,uCAAuC;IACvC,mCAAmC;IACnC,cAAc;IACd,2BAA2B;IAC3B,aAAa;IACb,6BAA6B;IAC7B,yBAAyB;IACzB,4BAA4B;IAC5B,2EAA2E;I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AAC,KAAc;IACzD,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,kCAAkC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACxD,OAAO,uBAAuB,CAAC,KAAK,CAAC,IAAI,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["/**\n * Shared model/provider failure classification.\n *\n * Workflows, subagents, and the main chat all need the same decision about\n * whether a provider failure may spend another model candidate. Keep this\n * module free of AgentSession and workflow imports so the published SDK can\n * expose it to the raw-TypeScript companion packages without a cycle.\n */\n\nimport {\n\tfindGitHubCopilotError,\n\ttype GitHubCopilotError,\n\ttype GitHubCopilotErrorCode,\n\tGitHubCopilotStreamEndedEarlyError,\n} from \"@bastani/pi-ai\";\nimport { isExtensionStartupFailure } from \"./extension-startup-failure.ts\";\n\nconst RETRYABLE_MODEL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/rate\\s*limit/i,\n\t/too\\s*many\\s*requests/i,\n\t/\\bthrottl(?:ing|ed)\\b/i,\n\t/\\b429\\b/,\n\t/quota/i,\n\t/usage[\\s_-]*limit/i,\n\t/billing/i,\n\t/credit/i,\n\t/auth(?:entication|orization)?/i,\n\t/unauthori[sz]ed/i,\n\t/\\b40[13]\\b/,\n\t/api[_\\s-]*key/i,\n\t/token[_\\s-]*expired/i,\n\t/token[_\\s-]*(?:revoked|invalidated)/i,\n\t/invalidated[_\\s-]+(?:oauth|auth)[_\\s-]+token/i,\n\t/forbidden/i,\n\t/invalid\\s*key/i,\n\t/overloaded/i,\n\t/temporarily\\s*unavailable/i,\n\t/service\\s*unavailable/i,\n\t/network/i,\n\t/fetch/i,\n\t/getaddrinfo/i,\n\t/ENOTFOUND/i,\n\t/EAI_AGAIN/i,\n\t/socket/i,\n\t/connection\\s*refused/i,\n\t/upstream/i,\n\t/timeout/i,\n\t/timed\\s*out/i,\n\t/\\b50[0-4]\\b/,\n\t/\\b52[0-4]\\b/,\n\t/\\b529\\b/,\n\t/provider.?returned.?error/i,\n\t/server.?error/i,\n\t/internal.?error/i,\n\t/connection.?error/i,\n\t/connection.?lost/i,\n\t/connection.?reset/i,\n\t/ECONNRESET/i,\n\t/other side closed/i,\n\t/websocket.?closed/i,\n\t/websocket.?error/i,\n\t/reset before headers/i,\n\t/socket hang up/i,\n\t/ended without/i,\n\t/stream ended before message_stop/i,\n\t/stream ended before a terminal response event/i,\n\t/http2 request did not get a response/i,\n\t/pending stream has been canceled/i,\n\t/retry delay/i,\n\t/finish.?reason:?\\s*error/i,\n\t/terminated/i,\n\t/you can retry your request/i,\n\t/try your request again/i,\n\t/please retry your request/i,\n\t// gRPC based providers (e.g. NVIDIA NIM); upstream pi-ai retries this too.\n\t/ResourceExhausted/i,\n];\n\nconst NON_RETRYABLE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/command failed/i,\n\t/tests? failed/i,\n\t/shell/i,\n\t/missing file/i,\n\t/no such file/i,\n\t/cancel/i,\n\t/abort/i,\n\t/interrupted/i,\n];\n\nconst CANCELLED_FAILURE_PATTERNS: readonly RegExp[] = [/cancel/i, /abort/i, /interrupted/i];\n\nconst TRANSPORT_CANCELLATION_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/getaddrinfo|ENOTFOUND|EAI_AGAIN/i,\n\t/pending stream has been canceled/i,\n];\n\nexport type ModelFallbackFailureKind =\n\t| \"auth_on_candidate_provider\"\n\t| \"rate_limit\"\n\t| \"quota_exhausted\"\n\t| \"provider_unavailable\"\n\t| \"network_timeout\"\n\t| \"transport_error\"\n\t| \"model_unavailable\"\n\t| \"request_incompatible\"\n\t| \"content_filter\"\n\t| \"cancelled\"\n\t| \"task_failure\"\n\t| \"unknown\";\n\nexport type ModelFallbackFailureSource =\n\t| \"assistant_message\"\n\t| \"diagnostic\"\n\t| \"throw\"\n\t| \"structured\"\n\t| \"string_fallback\";\n\nexport interface ModelFallbackFailureSignal {\n\treadonly kind: ModelFallbackFailureKind;\n\treadonly message: string;\n\treadonly source: ModelFallbackFailureSource;\n\treadonly stopReason?: string;\n\treadonly status?: number;\n\treadonly code?: string | number;\n\treadonly name?: string;\n}\n\n/** How a caller treats a provider content-filter refusal; `retry.fallbackOnContentFilter` in settings. */\nexport interface ModelFallbackFailureOptions {\n\t/** Whether a content-filter refusal may spend the next fallback candidate. Defaults to true. */\n\treadonly fallbackOnContentFilter?: boolean;\n}\n\nconst FALLBACKABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"auth_on_candidate_provider\",\n\t\"rate_limit\",\n\t\"quota_exhausted\",\n\t\"provider_unavailable\",\n\t\"network_timeout\",\n\t\"transport_error\",\n\t\"model_unavailable\",\n\t\"request_incompatible\",\n]);\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value !== null && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction field(value: unknown, key: string): unknown {\n\treturn asRecord(value)?.[key];\n}\n\nfunction stringField(value: unknown, key: string): string | undefined {\n\tconst raw = field(value, key);\n\treturn typeof raw === \"string\" && raw.trim().length > 0 ? raw : undefined;\n}\n\nfunction errorName(value: unknown): string | undefined {\n\treturn value instanceof Error ? value.name : stringField(value, \"name\");\n}\n\nfunction directMessageFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"errorMessage\") ?? stringField(value, \"message\") ?? stringField(value, \"statusText\");\n}\n\nfunction integerFrom(value: unknown): number | undefined {\n\tif (typeof value === \"number\" && Number.isInteger(value)) return value;\n\tif (typeof value !== \"string\" || value.trim().length === 0) return undefined;\n\tconst parsed = Number(value.trim());\n\treturn Number.isInteger(parsed) ? parsed : undefined;\n}\n\nfunction statusFrom(value: unknown): number | undefined {\n\treturn (\n\t\tintegerFrom(field(value, \"status\")) ??\n\t\tintegerFrom(field(value, \"statusCode\")) ??\n\t\tintegerFrom(field(value, \"httpStatus\"))\n\t);\n}\n\nfunction codeFrom(value: unknown): string | number | undefined {\n\tconst rawCode = field(value, \"code\");\n\tif (typeof rawCode === \"string\" || typeof rawCode === \"number\") return rawCode;\n\t// Provider failure diagnostics (`bedrock_response_failure`) keep the modeled error code in `details.errorCode`,\n\t// because the provider's display message replaces the exception name with a readable prefix.\n\tconst detailsCode = field(field(value, \"details\"), \"errorCode\");\n\treturn typeof detailsCode === \"string\" ? detailsCode : undefined;\n}\n\nfunction stopReasonFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"stopReason\");\n}\n\nfunction finishReasonFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"finish_reason\") ?? stringField(value, \"finishReason\");\n}\n\nfunction causeOf(value: unknown): unknown {\n\treturn value instanceof Error ? value.cause : field(value, \"cause\");\n}\n\nfunction diagnosticErrors(value: unknown): readonly unknown[] {\n\tconst diagnostics = field(value, \"diagnostics\");\n\tif (!Array.isArray(diagnostics)) return [];\n\tconst errors: unknown[] = [];\n\tfor (const diagnostic of diagnostics) {\n\t\tconst diagnosticType = stringField(diagnostic, \"type\");\n\t\tconst diagnosticError = field(diagnostic, \"error\");\n\t\terrors.push(\n\t\t\tnormalizeCode(diagnosticType) === \"provider_transport_failure\" ? diagnostic : (diagnosticError ?? diagnostic),\n\t\t);\n\t}\n\treturn errors;\n}\n\nfunction normalizeCode(value: string | number | undefined): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst raw = String(value).trim().toLowerCase();\n\tif (!raw) return undefined;\n\tlet normalized = \"\";\n\tlet needsSeparator = false;\n\tfor (const char of raw) {\n\t\tconst code = char.charCodeAt(0);\n\t\tconst isLowerAlpha = code >= 97 && code <= 122;\n\t\tconst isDigit = code >= 48 && code <= 57;\n\t\tif (isLowerAlpha || isDigit) {\n\t\t\tnormalized += char;\n\t\t\tneedsSeparator = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (needsSeparator && normalized[normalized.length - 1] !== \"_\") normalized += \"_\";\n\t}\n\tif (normalized.endsWith(\"_\")) normalized = normalized.slice(0, -1);\n\treturn normalized.length > 0 ? normalized : undefined;\n}\n\nfunction messageLooksLikeModelUnavailable(message: string): boolean {\n\tconst lower = message.toLowerCase();\n\treturn (\n\t\tlower.includes(\"model\") &&\n\t\t(lower.includes(\"unavailable\") ||\n\t\t\tlower.includes(\"disabled\") ||\n\t\t\tlower.includes(\"not found\") ||\n\t\t\tlower.includes(\"unknown\"))\n\t);\n}\n\nfunction kindFromStatus(status: number | undefined): ModelFallbackFailureKind | undefined {\n\tswitch (status) {\n\t\tcase 400:\n\t\tcase 413:\n\t\tcase 422:\n\t\t\treturn \"request_incompatible\";\n\t\tcase 401:\n\t\tcase 403:\n\t\t\treturn \"auth_on_candidate_provider\";\n\t\tcase 408:\n\t\t\treturn \"network_timeout\";\n\t\tcase 404:\n\t\t\treturn \"model_unavailable\";\n\t\tcase 402:\n\t\t\treturn \"quota_exhausted\";\n\t\tcase 429:\n\t\t\treturn \"rate_limit\";\n\t\tdefault:\n\t\t\tif (status !== undefined && status >= 500 && status <= 599) return \"provider_unavailable\";\n\t\t\treturn undefined;\n\t}\n}\n\nfunction refusalKindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalizedCode = normalizeCode(code);\n\tif (normalizedCode === undefined) return undefined;\n\t// A refused tool call, such as `tool_call_refusal` or `tool_use_refused_by_policy`, before the policy words.\n\tif (/(?:^|_)tool(?:_|$)/.test(normalizedCode) && normalizedCode.includes(\"refus\")) return \"task_failure\";\n\tif (normalizedCode.includes(\"content_filter\") || normalizedCode.includes(\"contentfilter\")) return \"content_filter\";\n\t// Includes OpenAI's `cyber_policy`.\n\tif (normalizedCode.includes(\"safety\") || normalizedCode.includes(\"policy\")) return \"content_filter\";\n\tswitch (normalizedCode) {\n\t\tcase \"blocked\":\n\t\tcase \"blocked_by_provider\":\n\t\tcase \"blocked_by_safety\":\n\t\tcase \"blocked_by_policy\":\n\t\tcase \"provider_refusal\":\n\t\tcase \"refusal\":\n\t\t\treturn \"content_filter\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nconst REQUEST_INCOMPATIBLE_CODES: ReadonlySet<string> = new Set([\n\t\"invalid_request\",\n\t\"invalid_request_error\",\n\t\"bad_request\",\n\t\"context_length_exceeded\",\n\t\"request_too_large\",\n\t\"too_large\",\n\t\"request_entity_too_large\",\n\t\"max_tokens\",\n\t\"max_context_length\",\n\t\"context_window_exceeded\",\n]);\n\nfunction requestIncompatibleKindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalized = normalizeCode(code);\n\treturn normalized !== undefined && REQUEST_INCOMPATIBLE_CODES.has(normalized) ? \"request_incompatible\" : undefined;\n}\n\nfunction kindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalizedCode = normalizeCode(code);\n\tif (normalizedCode === undefined) return undefined;\n\tconst refusalKind = refusalKindFromCode(code);\n\tif (refusalKind !== undefined) return refusalKind;\n\tconst httpStatusKind = kindFromStatus(integerFrom(code));\n\tif (httpStatusKind !== undefined) return httpStatusKind;\n\tconst requestIncompatibleKind = requestIncompatibleKindFromCode(code);\n\tif (requestIncompatibleKind !== undefined) return requestIncompatibleKind;\n\n\tswitch (normalizedCode) {\n\t\tcase \"auth\":\n\t\tcase \"auth_required\":\n\t\tcase \"authentication_required\":\n\t\tcase \"unauthorized\":\n\t\tcase \"forbidden\":\n\t\tcase \"invalid_api_key\":\n\t\tcase \"missing_api_key\":\n\t\tcase \"invalid_key\":\n\t\tcase \"token_expired\":\n\t\tcase \"token_revoked\":\n\t\tcase \"token_invalidated\":\n\t\tcase \"oauth_token_invalidated\":\n\t\t\treturn \"auth_on_candidate_provider\";\n\t\tcase \"etimedout\":\n\t\tcase \"econnreset\":\n\t\tcase \"econnrefused\":\n\t\tcase \"enotfound\":\n\t\tcase \"eai_again\":\n\t\tcase \"fetch_failed\":\n\t\tcase \"network_error\":\n\t\tcase \"timeout\":\n\t\tcase \"timeout_error\":\n\t\tcase \"und_err_connect_timeout\":\n\t\t\treturn \"network_timeout\";\n\t\tcase \"rate_limit\":\n\t\tcase \"rate_limit_exceeded\":\n\t\tcase \"too_many_requests\":\n\t\tcase \"throttlingexception\":\n\t\t\treturn \"rate_limit\";\n\t\tcase \"quota_exceeded\":\n\t\tcase \"insufficient_quota\":\n\t\tcase \"usage_limit\":\n\t\tcase \"usage_limit_reached\":\n\t\tcase \"usage_limit_exceeded\":\n\t\tcase \"payment_required\":\n\t\tcase \"servicequotaexceededexception\":\n\t\t\treturn \"quota_exhausted\";\n\t\tcase \"aborterror\":\n\t\tcase \"aborted\":\n\t\tcase \"cancelled\":\n\t\tcase \"canceled\":\n\t\t\treturn \"cancelled\";\n\t\tcase \"model_not_found\":\n\t\tcase \"model_unavailable\":\n\t\tcase \"model_disabled\":\n\t\tcase \"unknown_model\":\n\t\tcase \"model_not_available_for_integrator\":\n\t\t\treturn \"model_unavailable\";\n\t\tcase \"provider_error\":\n\t\tcase \"api_error\":\n\t\tcase \"service_unavailable\":\n\t\tcase \"temporarily_unavailable\":\n\t\tcase \"overloaded\":\n\t\t\treturn \"provider_unavailable\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nconst REQUEST_INCOMPATIBLE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\bcontext[_\\s-]?length(?:[_\\s-]?exceeded)?\\b/i,\n\t/\\bcontext[_\\s-]?window(?:[_\\s-]?exceeded)?\\b/i,\n\t/\\bmax[_\\s-]?context\\b/i,\n\t/\\bmax[_\\s-]?tokens?\\b/i,\n\t/\\brequest(?:[_\\s-]?entity)?[_\\s-]?too[_\\s-]?large\\b/i,\n\t/\\btoo[_\\s-]?large\\b/i,\n\t/\\b(?:unsupported|unknown|invalid)\\s+(?:tool|parameter|function)\\b/i,\n\t/\\b(?:tool|parameter|function)\\s+(?:not\\s+(?:supported|found|allowed)|unknown|invalid)\\b/i,\n\t/\\binvalid[_\\s-]?request(?:[_\\s-]?error)?\\b/i,\n\t/\\bbad[_\\s-]?request\\b/i,\n];\n\n/** A provider declined the request's content under its usage policy: the model will refuse it again. */\nconst CONTENT_FILTER_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\bthe\\s+model\\s+refused\\s+to\\s+complete\\s+the\\s+request\\b/i,\n\t/\\bfinish[_\\s-]?reason\\b[^\\n]*\\bcontent[_\\s-]?filter\\b/i,\n\t/\\bcontent[_\\s-]?filter(?:ed|ing)?\\b/i,\n\t/\\bcyber[_\\s-]?policy\\b/i,\n\t// OpenAI's cyber safeguard: \"This content was flagged for possible cybersecurity risk.\"\n\t/\\bflagged\\s+for\\s+(?:possible|potential(?:ly)?)\\b[^\\n]*\\b(?:risk|harm(?:ful)?|safety|policy|cyber\\w*)\\b/i,\n\t/\\b(?:safety|policy)\\b[^\\n]*\\b(?:refus(?:e|al|ed|es|ing)?|block(?:ed|ing)?|filter(?:ed|ing)?|violat(?:e|ion|ed|ing)?|disallow(?:ed|ing)?|reject(?:ed|ion|ing)?)\\b/i,\n\t/\\b(?:refus(?:e|al|ed|es|ing)?|block(?:ed|ing)?|filter(?:ed|ing)?|violat(?:e|ion|ed|ing)?|disallow(?:ed|ing)?|reject(?:ed|ion|ing)?)\\b[^\\n]*\\b(?:safety|policy)\\b/i,\n\t/\\bprovider[_\\s-]?refus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\bprovider\\b[^\\n]*\\brefus(?:e|al|ed|es|ing)?\\b[^\\n]*\\b(?:prompt|request|content|policy|safety)\\b/i,\n];\n\nconst TOOL_REFUSAL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\btool[_\\s-]?(?:call|use)?[_\\s-]?refus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\btool(?:\\s+call|\\s+use)?\\b[^\\n]*\\brefus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\brefus(?:e|al|ed|es|ing)?\\b[^\\n]*\\btool(?:\\s+call|\\s+use)?\\b/i,\n];\n\nconst PROVIDER_REFUSAL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t...CONTENT_FILTER_FAILURE_PATTERNS,\n\t...TOOL_REFUSAL_FAILURE_PATTERNS,\n];\n\nconst TRANSPORT_OUTAGE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/^connection\\s+error\\.?$/i,\n\t/^fetch\\s+failed\\.?$/i,\n\t// Response-body decompression failures reported by Node/Bun zlib, optionally\n\t// behind the fetch/WebSocket layer's \"Library error:\" wrapper. GitHub Copilot\n\t// on the default `transport: \"auto\"` surfaces this as\n\t// \"Library error: zlib error: incorrect header check\" (#2553). These are\n\t// unanchored because the wrapper text varies by runtime and transport. `zlib`\n\t// has no trailing word boundary on purpose: Bun 1.4.0, the shipped runtime\n\t// when verified, throws `ZlibError fetching \"...\"` as one word.\n\t/\\bzlib/i,\n\t/\\bincorrect\\s+header\\s+check\\b/i,\n\t/\\bdecompress(?:ion|ing|ed)?\\b/i,\n\t/^library\\s+error\\b/i,\n\t// Idle-stream deadline enforced below the HTTP layer by pi-ai's\n\t// `withStreamDeadline`, so a stalled stream fails over instead of hanging.\n\t/\\bstream\\s+deadline\\s+exceeded\\b/i,\n\t// A streamed response cut off before its finish reason, as GitHub Copilot's Gemini models do now and then: the\n\t// same request normally completes when sent again (#4223).\n\t/\\bstream\\s+ended\\s+without\\s+finish[_\\s-]?reason\\b/i,\n];\n\n// HTTP 402 and explicit quota exhaustion: the account cannot be served again until its quota resets.\n// Codes that also appear as free-text wording for short limits (\"quota exceeded\", \"usage limit reached\")\n// count only as a JSON `code`/`type` value, as in a raw error body some providers put in the message.\n// A service-quota exception and a per-day quota violation in a JSON error body (`\"quotaId\": \"...PerDay...\"`)\n// also last until the quota resets.\nconst QUOTA_EXHAUSTED_FAILURE_PATTERN =\n\t/(?<![a-z0-9.])402(?![a-z0-9.])|payment[_\\s-]*required|insufficient[_\\s-]*quota|\\bServiceQuotaExceededException\\b|\"quotaId\"\\s*:\\s*\"[^\"]*PerDay|\"(?:code|type|error_code)\"\\s*:\\s*\"(?:quota_exceeded|usage_limit|usage_limit_reached|usage_limit_exceeded)\"/i;\n\nfunction transportOutageKindFromMessage(message: string): ModelFallbackFailureKind | undefined {\n\treturn TRANSPORT_OUTAGE_FAILURE_PATTERNS.some((pattern) => pattern.test(message.trim()))\n\t\t? \"transport_error\"\n\t\t: undefined;\n}\n\nfunction refusalKindFromMessage(message: string): ModelFallbackFailureKind | undefined {\n\tif (TRANSPORT_CANCELLATION_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"network_timeout\";\n\tif (CANCELLED_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"cancelled\";\n\tif (NON_RETRYABLE_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\n\t// A refused tool call is about that call, whatever policy the provider names: another model is asked the same\n\t// tool call. So it is checked before the content-filter grammar, which \"refused ... safety policy\" also matches.\n\tif (TOOL_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\n\tif (CONTENT_FILTER_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"content_filter\";\n\treturn undefined;\n}\n\nfunction fallbackKindFromMessage(message: string, name: string | undefined): ModelFallbackFailureKind | undefined {\n\tconst refusalKind = refusalKindFromMessage(message);\n\tif (refusalKind !== undefined) return refusalKind;\n\tconst transportOutageKind = transportOutageKindFromMessage(message);\n\tif (transportOutageKind !== undefined) return transportOutageKind;\n\tif (REQUEST_INCOMPATIBLE_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"request_incompatible\";\n\tconst nameKind = kindFromCode(name);\n\tif (nameKind !== undefined) return nameKind;\n\tif (QUOTA_EXHAUSTED_FAILURE_PATTERN.test(message)) return \"quota_exhausted\";\n\tconst hasRetryablePattern =\n\t\tRETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(message)) ||\n\t\tmessageLooksLikeModelUnavailable(message);\n\tif (!hasRetryablePattern) return undefined;\n\tif (\n\t\t/rate\\s*limit|too\\s*many\\s*requests|\\bthrottl(?:ing|ed)\\b|\\b429\\b|quota|usage[\\s_-]*limit|billing|credit/i.test(\n\t\t\tmessage,\n\t\t)\n\t)\n\t\treturn \"rate_limit\";\n\tif (\n\t\t/auth|unauthori[sz]ed|\\b40[13]\\b|api[_\\s-]*key|token[_\\s-]*(?:expired|revoked|invalidated|rejected)|forbidden|invalid[_\\s-]*key/i.test(\n\t\t\tmessage,\n\t\t)\n\t)\n\t\treturn \"auth_on_candidate_provider\";\n\tif (messageLooksLikeModelUnavailable(message)) return \"model_unavailable\";\n\tif (/network|fetch|socket|connection\\s*refused|getaddrinfo|ENOTFOUND|EAI_AGAIN|timeout|timed\\s*out/i.test(message))\n\t\treturn \"network_timeout\";\n\treturn \"provider_unavailable\";\n}\n\nfunction signalSource(value: unknown, fallback: ModelFallbackFailureSource | undefined): ModelFallbackFailureSource {\n\tif (fallback !== undefined) return fallback;\n\tif (stopReasonFrom(value) !== undefined || diagnosticErrors(value).length > 0) return \"assistant_message\";\n\tif (value instanceof Error) return \"throw\";\n\treturn \"structured\";\n}\n\nfunction makeSignal(\n\tkind: ModelFallbackFailureKind,\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal {\n\tconst status = statusFrom(value);\n\tconst code = codeFrom(value);\n\tconst name = errorName(value);\n\tconst stopReason = stopReasonFrom(value);\n\treturn {\n\t\tkind,\n\t\tmessage: errorMessage(value),\n\t\tsource: signalSource(value, source),\n\t\t...(stopReason !== undefined ? { stopReason } : {}),\n\t\t...(status !== undefined ? { status } : {}),\n\t\t...(code !== undefined ? { code } : {}),\n\t\t...(name !== undefined ? { name } : {}),\n\t};\n}\n\nfunction fallbackSignalFromDirectMessage(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst message = directMessageFrom(value);\n\tif (message === undefined) return undefined;\n\tconst kind = fallbackKindFromMessage(message, errorName(value));\n\treturn kind === undefined ? undefined : makeSignal(kind, value, source);\n}\n\nfunction fallbackSignalFromMessage(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst message = errorMessage(value);\n\tif (!message.trim()) return undefined;\n\tconst kind = fallbackKindFromMessage(message, errorName(value));\n\treturn kind === undefined ? undefined : makeSignal(kind, value, source);\n}\n\nfunction classifyAssistantRefusalSignal(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst codeRefusalKind =\n\t\trefusalKindFromCode(codeFrom(value)) ??\n\t\trefusalKindFromCode(errorName(value)) ??\n\t\trefusalKindFromCode(finishReasonFrom(value));\n\tif (codeRefusalKind !== undefined) return makeSignal(codeRefusalKind, value, source);\n\n\tconst messageRefusalKind = refusalKindFromMessage(directMessageFrom(value) ?? \"\");\n\treturn messageRefusalKind === undefined ? undefined : makeSignal(messageRefusalKind, value, source);\n}\n\nfunction isRefusalSignal(signal: ModelFallbackFailureSignal): boolean {\n\treturn signal.kind === \"cancelled\" || signal.kind === \"task_failure\" || signal.kind === \"content_filter\";\n}\n\nfunction nestedSignalPriority(signal: ModelFallbackFailureSignal): number {\n\tswitch (signal.kind) {\n\t\tcase \"cancelled\":\n\t\tcase \"task_failure\":\n\t\tcase \"content_filter\":\n\t\t\treturn 100;\n\t\tcase \"auth_on_candidate_provider\":\n\t\t\treturn 90;\n\t\tcase \"request_incompatible\":\n\t\t\treturn 85;\n\t\tcase \"model_unavailable\":\n\t\t\treturn 80;\n\t\tcase \"quota_exhausted\":\n\t\t\treturn 75;\n\t\tcase \"rate_limit\":\n\t\t\treturn 70;\n\t\tcase \"provider_unavailable\":\n\t\t\treturn 60;\n\t\tcase \"network_timeout\":\n\t\t\treturn 50;\n\t\tcase \"transport_error\":\n\t\t\treturn 82;\n\t\tcase \"unknown\":\n\t\t\treturn 0;\n\t}\n}\nfunction structuredSignal(\n\tvalue: unknown,\n\tseen: Set<unknown>,\n\tsource?: ModelFallbackFailureSource,\n): ModelFallbackFailureSignal | undefined {\n\tif (value === undefined || value === null || seen.has(value)) return undefined;\n\tif (typeof value === \"object\") seen.add(value);\n\n\tconst stopReason = stopReasonFrom(value)?.toLowerCase();\n\tconst diagnosticType = stringField(value, \"type\");\n\tconst providerTransportSignal =\n\t\tdiagnosticType !== undefined && normalizeCode(diagnosticType) === \"provider_transport_failure\"\n\t\t\t? makeSignal(\"transport_error\", value, source)\n\t\t\t: undefined;\n\tif (stopReason === \"aborted\") return makeSignal(\"cancelled\", value, source);\n\n\t// Defer direct refusal/cancellation signals until nested diagnostics and\n\t// causes have been inspected. A transport wrapper can carry a cancellation\n\t// or provider refusal that must win over the wrapper's transport label.\n\tconst directRefusalSignal = classifyAssistantRefusalSignal(value, source);\n\tconst codeKind = kindFromCode(codeFrom(value));\n\tconst nameKind = kindFromCode(errorName(value));\n\tconst directCancellationSignal =\n\t\tcodeKind === \"cancelled\" || nameKind === \"cancelled\" ? makeSignal(\"cancelled\", value, source) : undefined;\n\n\tlet bestNestedFallbackSignal: ModelFallbackFailureSignal | undefined;\n\tconst nestedSeen = new Set(seen);\n\tconst nestedValues: readonly { value: unknown; source?: ModelFallbackFailureSource }[] = [\n\t\t...diagnosticErrors(value).map((diagnosticError) => ({ value: diagnosticError, source: \"diagnostic\" as const })),\n\t\t...(field(value, \"error\") === undefined ? [] : [{ value: field(value, \"error\"), source }]),\n\t];\n\tfor (const nested of nestedValues) {\n\t\tconst nestedSignal =\n\t\t\tstructuredSignal(nested.value, nestedSeen, nested.source) ??\n\t\t\tfallbackSignalFromMessage(nested.value, nested.source);\n\t\tif (nestedSignal === undefined) continue;\n\t\tif (isRefusalSignal(nestedSignal)) return nestedSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(nestedSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = nestedSignal;\n\t\t}\n\t}\n\tconst cause = causeOf(value);\n\tconst causeSignal = structuredSignal(cause, nestedSeen, source) ?? fallbackSignalFromMessage(cause, source);\n\tif (causeSignal !== undefined) {\n\t\tif (isRefusalSignal(causeSignal)) return causeSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(causeSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = causeSignal;\n\t\t}\n\t}\n\n\t// This code names the exact cause, so the generic 400 status and its request-error text must not outrank it.\n\tif (\n\t\tdirectRefusalSignal === undefined &&\n\t\tdirectCancellationSignal === undefined &&\n\t\tnormalizeCode(codeFrom(value)) === \"model_not_available_for_integrator\"\n\t)\n\t\treturn makeSignal(\"model_unavailable\", value, source);\n\n\tconst directSignals = [\n\t\tdirectRefusalSignal,\n\t\tdirectCancellationSignal,\n\t\tproviderTransportSignal,\n\t\tfallbackSignalFromDirectMessage(value, source),\n\t\tkindFromStatus(statusFrom(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromStatus(statusFrom(value))!, value, source),\n\t\tkindFromCode(codeFrom(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromCode(codeFrom(value))!, value, source),\n\t\tkindFromCode(errorName(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromCode(errorName(value))!, value, source),\n\t].filter((signal): signal is ModelFallbackFailureSignal => signal !== undefined);\n\tfor (const directSignal of directSignals) {\n\t\tif (isRefusalSignal(directSignal)) return directSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(directSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = directSignal;\n\t\t}\n\t}\n\n\tif (bestNestedFallbackSignal !== undefined) return bestNestedFallbackSignal;\n\tif (stopReason === \"error\") return makeSignal(\"provider_unavailable\", value, source);\n\treturn undefined;\n}\n\nfunction messageFromUnknown(value: unknown, seen: Set<unknown>): string | undefined {\n\tif (value === undefined || value === null || seen.has(value)) return undefined;\n\tif (typeof value === \"string\") return value.trim().length > 0 ? value : undefined;\n\tif (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return String(value);\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return undefined;\n\tseen.add(value);\n\n\tif (value instanceof Error && value.message.trim().length > 0) return value.message;\n\tconst directMessage = directMessageFrom(value);\n\tif (directMessage !== undefined) return directMessage;\n\tfor (const diagnosticError of diagnosticErrors(value)) {\n\t\tconst diagnosticMessage = messageFromUnknown(diagnosticError, seen);\n\t\tif (diagnosticMessage !== undefined) return diagnosticMessage;\n\t}\n\tconst causeMessage = messageFromUnknown(causeOf(value), seen);\n\tif (causeMessage !== undefined) return causeMessage;\n\tconst finishReason = finishReasonFrom(value);\n\tif (finishReason !== undefined) return `Model request finished with finish_reason:${finishReason}`;\n\tconst stopReason = stopReasonFrom(value);\n\tif (stopReason !== undefined) return `Assistant message ended with stopReason:${stopReason}`;\n\tconst status = statusFrom(value);\n\tif (status !== undefined) return `Model request failed with status ${status}`;\n\tconst code = codeFrom(value);\n\tif (code !== undefined) return `Model request failed with code ${String(code)}`;\n\treturn undefined;\n}\n\nexport function errorMessage(error: unknown): string {\n\tconst structuredMessage = messageFromUnknown(error, new Set());\n\tif (structuredMessage !== undefined) return structuredMessage;\n\tconst rendered = String(error);\n\treturn rendered === \"[object Object]\" ? \"Model request failed\" : rendered;\n}\n\n/** Alias used by the subagent package's older public helper name. */\nexport const modelFailureMessage = errorMessage;\n\n/** The fallback decision each typed GitHub Copilot failure stands for. */\nconst GITHUB_COPILOT_FAILURE_KINDS: Readonly<Record<GitHubCopilotErrorCode, ModelFallbackFailureKind>> = {\n\t\"model-unavailable\": \"model_unavailable\",\n\t\"rate-limited\": \"rate_limit\",\n\t\"quota-exhausted\": \"quota_exhausted\",\n\t\"content-filtered\": \"content_filter\",\n\t\"prompt-too-large\": \"request_incompatible\",\n\t\"invalid-request\": \"request_incompatible\",\n\t\"authentication-failed\": \"auth_on_candidate_provider\",\n\t\"service-unavailable\": \"provider_unavailable\",\n\t\"stream-ended-early\": \"transport_error\",\n\t\"empty-response\": \"transport_error\",\n\t\"unrecognized-response\": \"provider_unavailable\",\n};\n\n/**\n * A GitHub Copilot failure is typed at the provider: its code decides, never its text. The typed error is found on\n * the failure, anywhere in its cause chain, or in the diagnostics of a failed assistant message in that chain, as\n * when a workflow wraps the message.\n */\nfunction githubCopilotSignal(error: unknown): ModelFallbackFailureSignal | undefined {\n\tconst copilotError: GitHubCopilotError | undefined = findGitHubCopilotError(error);\n\tif (copilotError === undefined) return undefined;\n\treturn makeSignal(GITHUB_COPILOT_FAILURE_KINDS[copilotError.code], copilotError, signalSource(error, undefined));\n}\n\n/**\n * How long the attempt ran, in milliseconds, before its response stream ended early. It is read from the typed GitHub\n * Copilot failure, never from message text: on the error, anywhere in its cause chain, or in the diagnostics of a\n * failed assistant message. Undefined for any other failure, and for a stream-cut error that carries no duration.\n */\nexport function streamCutDurationMs(error: unknown): number | undefined {\n\tconst copilotError = findGitHubCopilotError(error);\n\treturn copilotError instanceof GitHubCopilotStreamEndedEarlyError ? copilotError.durationMs : undefined;\n}\n\nexport function normalizeModelFailureSignal(error: unknown): ModelFallbackFailureSignal {\n\t// Extension startup is not a model request. Its message names extension paths\n\t// and their own errors, which must not read as a provider failure.\n\tif (isExtensionStartupFailure(error)) {\n\t\tconst name = errorName(error);\n\t\treturn {\n\t\t\tkind: \"unknown\",\n\t\t\tmessage: errorMessage(error),\n\t\t\tsource: \"string_fallback\",\n\t\t\t...(name !== undefined ? { name } : {}),\n\t\t};\n\t}\n\tconst copilot = githubCopilotSignal(error);\n\tif (copilot !== undefined) return copilot;\n\tconst structured = structuredSignal(error, new Set());\n\tif (structured !== undefined) return structured;\n\tconst message = errorMessage(error);\n\tconst name = errorName(error);\n\tconst fallbackKind = message.trim().length > 0 ? fallbackKindFromMessage(message, name) : undefined;\n\treturn {\n\t\tkind: fallbackKind ?? \"unknown\",\n\t\tmessage,\n\t\tsource: \"string_fallback\",\n\t\t...(name !== undefined ? { name } : {}),\n\t};\n}\n\n/** Whether a failure is a provider safety/refusal response: a content-filter refusal, or a refused tool call. */\nexport function isSafetyRefusalFailure(error: unknown): boolean {\n\tconst signal = normalizeModelFailureSignal(error);\n\tif (signal.kind === \"content_filter\") return true;\n\tif (signal.kind !== \"task_failure\") return false;\n\tconst text = `${signal.message}\\n${signal.code ?? \"\"}\\n${signal.name ?? \"\"}`;\n\treturn PROVIDER_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(text));\n}\n\n/** Whether a provider's content filter refused the request, as OpenAI's HTTP 422 `cyber_policy` does. */\nexport function isContentFilterRefusal(error: unknown): boolean {\n\treturn normalizeModelFailureSignal(error).kind === \"content_filter\";\n}\n\n/**\n * True when this failure may spend a configured model fallback candidate. A content-filter refusal does unless\n * `options.fallbackOnContentFilter` is false.\n */\nexport function isRetryableModelFailure(error: unknown, options?: ModelFallbackFailureOptions): boolean {\n\tif (error === undefined) return false;\n\tconst kind = normalizeModelFailureSignal(error).kind;\n\tif (kind === \"content_filter\") return options?.fallbackOnContentFilter !== false;\n\treturn FALLBACKABLE_FAILURE_KINDS.has(kind);\n}\n\nconst SAME_MODEL_RETRYABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"rate_limit\",\n\t\"provider_unavailable\",\n\t\"network_timeout\",\n\t\"transport_error\",\n]);\n\n/**\n * An assistant error that only its `stopReason` marks as a model failure: no status, code or name, and text that no\n * pattern recognizes. It may spend a fallback candidate, but it is not retried on the same model on its own.\n */\nfunction isUnrecognizedSignal(signal: ModelFallbackFailureSignal): boolean {\n\treturn (\n\t\tsignal.kind === \"provider_unavailable\" &&\n\t\tsignal.source === \"assistant_message\" &&\n\t\tsignal.status === undefined &&\n\t\tsignal.code === undefined &&\n\t\tsignal.name === undefined &&\n\t\t!RETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(signal.message))\n\t);\n}\n\n/** True when the same model may be requested again before fallback advances. */\nexport function isRetryableSameModelFailure(error: unknown): boolean {\n\tif (!isRetryableModelFailure(error)) return false;\n\tconst signal = normalizeModelFailureSignal(error);\n\treturn SAME_MODEL_RETRYABLE_FAILURE_KINDS.has(signal.kind) && !isUnrecognizedSignal(signal);\n}\n\n/**\n * True for a failure that may spend a fallback candidate although nothing recognizes it: an assistant error with no\n * status, code or name whose text matches no known pattern. A session with a fallback chain retries it on the same\n * model first, so such an error never switches models on its first occurrence (#4223).\n */\nexport function isUnrecognizedModelFailure(error: unknown): boolean {\n\treturn isRetryableModelFailure(error) && isUnrecognizedSignal(normalizeModelFailureSignal(error));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-fallback-failures.js","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,sBAAsB,EAGtB,kCAAkC,GAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,gCAAgC,GAAsB;IAC3D,eAAe;IACf,wBAAwB;IACxB,wBAAwB;IACxB,SAAS;IACT,QAAQ;IACR,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,gCAAgC;IAChC,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,sBAAsB;IACtB,sCAAsC;IACtC,+CAA+C;IAC/C,YAAY;IACZ,gBAAgB;IAChB,aAAa;IACb,4BAA4B;IAC5B,wBAAwB;IACxB,UAAU;IACV,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,uBAAuB;IACvB,WAAW;IACX,UAAU;IACV,cAAc;IACd,aAA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,OAAO,CACN,MAAM,CAAC,IAAI,KAAK,sBAAsB;QACtC,MAAM,CAAC,MAAM,KAAK,mBAAmB;QACrC,MAAM,CAAC,MAAM,KAAK,SAAS;QAC3B,MAAM,CAAC,IAAI,KAAK,SAAS;QACzB,MAAM,CAAC,IAAI,KAAK,SAAS;QACzB,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CACjF,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACzD,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,kCAAkC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACxD,OAAO,uBAAuB,CAAC,KAAK,CAAC,IAAI,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["/**\n * Shared model/provider failure classification.\n *\n * Workflows, subagents, and the main chat all need the same decision about\n * whether a provider failure may spend another model candidate. Keep this\n * module free of AgentSession and workflow imports so the published SDK can\n * expose it to the raw-TypeScript companion packages without a cycle.\n */\n\nimport {\n\tfindGitHubCopilotError,\n\ttype GitHubCopilotError,\n\ttype GitHubCopilotErrorCode,\n\tGitHubCopilotStreamEndedEarlyError,\n} from \"@bastani/pi-ai\";\nimport { isExtensionStartupFailure } from \"./extension-startup-failure.ts\";\n\nconst RETRYABLE_MODEL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/rate\\s*limit/i,\n\t/too\\s*many\\s*requests/i,\n\t/\\bthrottl(?:ing|ed)\\b/i,\n\t/\\b429\\b/,\n\t/quota/i,\n\t/usage[\\s_-]*limit/i,\n\t/billing/i,\n\t/credit/i,\n\t/auth(?:entication|orization)?/i,\n\t/unauthori[sz]ed/i,\n\t/\\b40[13]\\b/,\n\t/api[_\\s-]*key/i,\n\t/token[_\\s-]*expired/i,\n\t/token[_\\s-]*(?:revoked|invalidated)/i,\n\t/invalidated[_\\s-]+(?:oauth|auth)[_\\s-]+token/i,\n\t/forbidden/i,\n\t/invalid\\s*key/i,\n\t/overloaded/i,\n\t/temporarily\\s*unavailable/i,\n\t/service\\s*unavailable/i,\n\t/network/i,\n\t/fetch/i,\n\t/getaddrinfo/i,\n\t/ENOTFOUND/i,\n\t/EAI_AGAIN/i,\n\t/socket/i,\n\t/connection\\s*refused/i,\n\t/upstream/i,\n\t/timeout/i,\n\t/timed\\s*out/i,\n\t/\\b50[0-4]\\b/,\n\t/\\b52[0-4]\\b/,\n\t/\\b529\\b/,\n\t/provider.?returned.?error/i,\n\t/server.?error/i,\n\t/internal.?error/i,\n\t/connection.?error/i,\n\t/connection.?lost/i,\n\t/connection.?closed/i,\n\t/connection.?reset/i,\n\t/ECONNRESET/i,\n\t/other side closed/i,\n\t/websocket.?closed/i,\n\t/websocket.?error/i,\n\t/reset before headers/i,\n\t/socket hang up/i,\n\t/ended without/i,\n\t/stream ended before message_stop/i,\n\t/stream ended before a terminal response event/i,\n\t/http2 request did not get a response/i,\n\t/pending stream has been canceled/i,\n\t/retry delay/i,\n\t/finish.?reason:?\\s*error/i,\n\t/terminated/i,\n\t/you can retry your request/i,\n\t/try your request again/i,\n\t/please retry your request/i,\n\t// gRPC based providers (e.g. NVIDIA NIM); upstream pi-ai retries this too.\n\t/ResourceExhausted/i,\n];\n\nconst NON_RETRYABLE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/command failed/i,\n\t/tests? failed/i,\n\t/shell/i,\n\t/missing file/i,\n\t/no such file/i,\n\t/cancel/i,\n\t/abort/i,\n\t/interrupted/i,\n];\n\nconst CANCELLED_FAILURE_PATTERNS: readonly RegExp[] = [/cancel/i, /abort/i, /interrupted/i];\n\nconst TRANSPORT_CANCELLATION_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/getaddrinfo|ENOTFOUND|EAI_AGAIN/i,\n\t/pending stream has been canceled/i,\n];\n\nexport type ModelFallbackFailureKind =\n\t| \"auth_on_candidate_provider\"\n\t| \"rate_limit\"\n\t| \"quota_exhausted\"\n\t| \"provider_unavailable\"\n\t| \"network_timeout\"\n\t| \"transport_error\"\n\t| \"model_unavailable\"\n\t| \"request_incompatible\"\n\t| \"content_filter\"\n\t| \"cancelled\"\n\t| \"task_failure\"\n\t| \"unknown\";\n\nexport type ModelFallbackFailureSource =\n\t| \"assistant_message\"\n\t| \"diagnostic\"\n\t| \"throw\"\n\t| \"structured\"\n\t| \"string_fallback\";\n\nexport interface ModelFallbackFailureSignal {\n\treadonly kind: ModelFallbackFailureKind;\n\treadonly message: string;\n\treadonly source: ModelFallbackFailureSource;\n\treadonly stopReason?: string;\n\treadonly status?: number;\n\treadonly code?: string | number;\n\treadonly name?: string;\n}\n\n/** How a caller treats a provider content-filter refusal; `retry.fallbackOnContentFilter` in settings. */\nexport interface ModelFallbackFailureOptions {\n\t/** Whether a content-filter refusal may spend the next fallback candidate. Defaults to true. */\n\treadonly fallbackOnContentFilter?: boolean;\n}\n\nconst FALLBACKABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"auth_on_candidate_provider\",\n\t\"rate_limit\",\n\t\"quota_exhausted\",\n\t\"provider_unavailable\",\n\t\"network_timeout\",\n\t\"transport_error\",\n\t\"model_unavailable\",\n\t\"request_incompatible\",\n]);\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value !== null && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction field(value: unknown, key: string): unknown {\n\treturn asRecord(value)?.[key];\n}\n\nfunction stringField(value: unknown, key: string): string | undefined {\n\tconst raw = field(value, key);\n\treturn typeof raw === \"string\" && raw.trim().length > 0 ? raw : undefined;\n}\n\nfunction errorName(value: unknown): string | undefined {\n\treturn value instanceof Error ? value.name : stringField(value, \"name\");\n}\n\nfunction directMessageFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"errorMessage\") ?? stringField(value, \"message\") ?? stringField(value, \"statusText\");\n}\n\nfunction integerFrom(value: unknown): number | undefined {\n\tif (typeof value === \"number\" && Number.isInteger(value)) return value;\n\tif (typeof value !== \"string\" || value.trim().length === 0) return undefined;\n\tconst parsed = Number(value.trim());\n\treturn Number.isInteger(parsed) ? parsed : undefined;\n}\n\nfunction statusFrom(value: unknown): number | undefined {\n\treturn (\n\t\tintegerFrom(field(value, \"status\")) ??\n\t\tintegerFrom(field(value, \"statusCode\")) ??\n\t\tintegerFrom(field(value, \"httpStatus\"))\n\t);\n}\n\nfunction codeFrom(value: unknown): string | number | undefined {\n\tconst rawCode = field(value, \"code\");\n\tif (typeof rawCode === \"string\" || typeof rawCode === \"number\") return rawCode;\n\t// Provider failure diagnostics (`bedrock_response_failure`) keep the modeled error code in `details.errorCode`,\n\t// because the provider's display message replaces the exception name with a readable prefix.\n\tconst detailsCode = field(field(value, \"details\"), \"errorCode\");\n\treturn typeof detailsCode === \"string\" ? detailsCode : undefined;\n}\n\nfunction stopReasonFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"stopReason\");\n}\n\nfunction finishReasonFrom(value: unknown): string | undefined {\n\treturn stringField(value, \"finish_reason\") ?? stringField(value, \"finishReason\");\n}\n\nfunction causeOf(value: unknown): unknown {\n\treturn value instanceof Error ? value.cause : field(value, \"cause\");\n}\n\nfunction diagnosticErrors(value: unknown): readonly unknown[] {\n\tconst diagnostics = field(value, \"diagnostics\");\n\tif (!Array.isArray(diagnostics)) return [];\n\tconst errors: unknown[] = [];\n\tfor (const diagnostic of diagnostics) {\n\t\tconst diagnosticType = stringField(diagnostic, \"type\");\n\t\tconst diagnosticError = field(diagnostic, \"error\");\n\t\terrors.push(\n\t\t\tnormalizeCode(diagnosticType) === \"provider_transport_failure\" ? diagnostic : (diagnosticError ?? diagnostic),\n\t\t);\n\t}\n\treturn errors;\n}\n\nfunction normalizeCode(value: string | number | undefined): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst raw = String(value).trim().toLowerCase();\n\tif (!raw) return undefined;\n\tlet normalized = \"\";\n\tlet needsSeparator = false;\n\tfor (const char of raw) {\n\t\tconst code = char.charCodeAt(0);\n\t\tconst isLowerAlpha = code >= 97 && code <= 122;\n\t\tconst isDigit = code >= 48 && code <= 57;\n\t\tif (isLowerAlpha || isDigit) {\n\t\t\tnormalized += char;\n\t\t\tneedsSeparator = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (needsSeparator && normalized[normalized.length - 1] !== \"_\") normalized += \"_\";\n\t}\n\tif (normalized.endsWith(\"_\")) normalized = normalized.slice(0, -1);\n\treturn normalized.length > 0 ? normalized : undefined;\n}\n\nfunction messageLooksLikeModelUnavailable(message: string): boolean {\n\tconst lower = message.toLowerCase();\n\treturn (\n\t\tlower.includes(\"model\") &&\n\t\t(lower.includes(\"unavailable\") ||\n\t\t\tlower.includes(\"disabled\") ||\n\t\t\tlower.includes(\"not found\") ||\n\t\t\tlower.includes(\"unknown\"))\n\t);\n}\n\nfunction kindFromStatus(status: number | undefined): ModelFallbackFailureKind | undefined {\n\tswitch (status) {\n\t\tcase 400:\n\t\tcase 413:\n\t\tcase 422:\n\t\t\treturn \"request_incompatible\";\n\t\tcase 401:\n\t\tcase 403:\n\t\t\treturn \"auth_on_candidate_provider\";\n\t\tcase 408:\n\t\t\treturn \"network_timeout\";\n\t\tcase 404:\n\t\t\treturn \"model_unavailable\";\n\t\tcase 402:\n\t\t\treturn \"quota_exhausted\";\n\t\tcase 429:\n\t\t\treturn \"rate_limit\";\n\t\tdefault:\n\t\t\tif (status !== undefined && status >= 500 && status <= 599) return \"provider_unavailable\";\n\t\t\treturn undefined;\n\t}\n}\n\nfunction refusalKindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalizedCode = normalizeCode(code);\n\tif (normalizedCode === undefined) return undefined;\n\t// A refused tool call, such as `tool_call_refusal` or `tool_use_refused_by_policy`, before the policy words.\n\tif (/(?:^|_)tool(?:_|$)/.test(normalizedCode) && normalizedCode.includes(\"refus\")) return \"task_failure\";\n\tif (normalizedCode.includes(\"content_filter\") || normalizedCode.includes(\"contentfilter\")) return \"content_filter\";\n\t// Includes OpenAI's `cyber_policy`.\n\tif (normalizedCode.includes(\"safety\") || normalizedCode.includes(\"policy\")) return \"content_filter\";\n\tswitch (normalizedCode) {\n\t\tcase \"blocked\":\n\t\tcase \"blocked_by_provider\":\n\t\tcase \"blocked_by_safety\":\n\t\tcase \"blocked_by_policy\":\n\t\tcase \"provider_refusal\":\n\t\tcase \"refusal\":\n\t\t\treturn \"content_filter\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nconst REQUEST_INCOMPATIBLE_CODES: ReadonlySet<string> = new Set([\n\t\"invalid_request\",\n\t\"invalid_request_error\",\n\t\"bad_request\",\n\t\"context_length_exceeded\",\n\t\"request_too_large\",\n\t\"too_large\",\n\t\"request_entity_too_large\",\n\t\"max_tokens\",\n\t\"max_context_length\",\n\t\"context_window_exceeded\",\n]);\n\nfunction requestIncompatibleKindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalized = normalizeCode(code);\n\treturn normalized !== undefined && REQUEST_INCOMPATIBLE_CODES.has(normalized) ? \"request_incompatible\" : undefined;\n}\n\nfunction kindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {\n\tconst normalizedCode = normalizeCode(code);\n\tif (normalizedCode === undefined) return undefined;\n\tconst refusalKind = refusalKindFromCode(code);\n\tif (refusalKind !== undefined) return refusalKind;\n\tconst httpStatusKind = kindFromStatus(integerFrom(code));\n\tif (httpStatusKind !== undefined) return httpStatusKind;\n\tconst requestIncompatibleKind = requestIncompatibleKindFromCode(code);\n\tif (requestIncompatibleKind !== undefined) return requestIncompatibleKind;\n\n\tswitch (normalizedCode) {\n\t\tcase \"auth\":\n\t\tcase \"auth_required\":\n\t\tcase \"authentication_required\":\n\t\tcase \"unauthorized\":\n\t\tcase \"forbidden\":\n\t\tcase \"invalid_api_key\":\n\t\tcase \"missing_api_key\":\n\t\tcase \"invalid_key\":\n\t\tcase \"token_expired\":\n\t\tcase \"token_revoked\":\n\t\tcase \"token_invalidated\":\n\t\tcase \"oauth_token_invalidated\":\n\t\t\treturn \"auth_on_candidate_provider\";\n\t\tcase \"etimedout\":\n\t\tcase \"econnreset\":\n\t\tcase \"econnrefused\":\n\t\tcase \"enotfound\":\n\t\tcase \"eai_again\":\n\t\tcase \"fetch_failed\":\n\t\tcase \"network_error\":\n\t\tcase \"timeout\":\n\t\tcase \"timeout_error\":\n\t\tcase \"und_err_connect_timeout\":\n\t\t\treturn \"network_timeout\";\n\t\tcase \"rate_limit\":\n\t\tcase \"rate_limit_exceeded\":\n\t\tcase \"too_many_requests\":\n\t\tcase \"throttlingexception\":\n\t\t\treturn \"rate_limit\";\n\t\tcase \"quota_exceeded\":\n\t\tcase \"insufficient_quota\":\n\t\tcase \"usage_limit\":\n\t\tcase \"usage_limit_reached\":\n\t\tcase \"usage_limit_exceeded\":\n\t\tcase \"payment_required\":\n\t\tcase \"servicequotaexceededexception\":\n\t\t\treturn \"quota_exhausted\";\n\t\tcase \"aborterror\":\n\t\tcase \"aborted\":\n\t\tcase \"cancelled\":\n\t\tcase \"canceled\":\n\t\t\treturn \"cancelled\";\n\t\tcase \"model_not_found\":\n\t\tcase \"model_unavailable\":\n\t\tcase \"model_disabled\":\n\t\tcase \"unknown_model\":\n\t\tcase \"model_not_available_for_integrator\":\n\t\t\treturn \"model_unavailable\";\n\t\tcase \"provider_error\":\n\t\tcase \"api_error\":\n\t\tcase \"service_unavailable\":\n\t\tcase \"temporarily_unavailable\":\n\t\tcase \"overloaded\":\n\t\t\treturn \"provider_unavailable\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nconst REQUEST_INCOMPATIBLE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\bcontext[_\\s-]?length(?:[_\\s-]?exceeded)?\\b/i,\n\t/\\bcontext[_\\s-]?window(?:[_\\s-]?exceeded)?\\b/i,\n\t/\\bmax[_\\s-]?context\\b/i,\n\t/\\bmax[_\\s-]?tokens?\\b/i,\n\t/\\brequest(?:[_\\s-]?entity)?[_\\s-]?too[_\\s-]?large\\b/i,\n\t/\\btoo[_\\s-]?large\\b/i,\n\t/\\b(?:unsupported|unknown|invalid)\\s+(?:tool|parameter|function)\\b/i,\n\t/\\b(?:tool|parameter|function)\\s+(?:not\\s+(?:supported|found|allowed)|unknown|invalid)\\b/i,\n\t/\\binvalid[_\\s-]?request(?:[_\\s-]?error)?\\b/i,\n\t/\\bbad[_\\s-]?request\\b/i,\n];\n\n/** A provider declined the request's content under its usage policy: the model will refuse it again. */\nconst CONTENT_FILTER_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\bthe\\s+model\\s+refused\\s+to\\s+complete\\s+the\\s+request\\b/i,\n\t/\\bfinish[_\\s-]?reason\\b[^\\n]*\\bcontent[_\\s-]?filter\\b/i,\n\t/\\bcontent[_\\s-]?filter(?:ed|ing)?\\b/i,\n\t/\\bcyber[_\\s-]?policy\\b/i,\n\t// OpenAI's cyber safeguard: \"This content was flagged for possible cybersecurity risk.\"\n\t/\\bflagged\\s+for\\s+(?:possible|potential(?:ly)?)\\b[^\\n]*\\b(?:risk|harm(?:ful)?|safety|policy|cyber\\w*)\\b/i,\n\t/\\b(?:safety|policy)\\b[^\\n]*\\b(?:refus(?:e|al|ed|es|ing)?|block(?:ed|ing)?|filter(?:ed|ing)?|violat(?:e|ion|ed|ing)?|disallow(?:ed|ing)?|reject(?:ed|ion|ing)?)\\b/i,\n\t/\\b(?:refus(?:e|al|ed|es|ing)?|block(?:ed|ing)?|filter(?:ed|ing)?|violat(?:e|ion|ed|ing)?|disallow(?:ed|ing)?|reject(?:ed|ion|ing)?)\\b[^\\n]*\\b(?:safety|policy)\\b/i,\n\t/\\bprovider[_\\s-]?refus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\bprovider\\b[^\\n]*\\brefus(?:e|al|ed|es|ing)?\\b[^\\n]*\\b(?:prompt|request|content|policy|safety)\\b/i,\n];\n\nconst TOOL_REFUSAL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/\\btool[_\\s-]?(?:call|use)?[_\\s-]?refus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\btool(?:\\s+call|\\s+use)?\\b[^\\n]*\\brefus(?:e|al|ed|es|ing)?\\b/i,\n\t/\\brefus(?:e|al|ed|es|ing)?\\b[^\\n]*\\btool(?:\\s+call|\\s+use)?\\b/i,\n];\n\nconst PROVIDER_REFUSAL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t...CONTENT_FILTER_FAILURE_PATTERNS,\n\t...TOOL_REFUSAL_FAILURE_PATTERNS,\n];\n\nconst TRANSPORT_OUTAGE_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/^connection\\s+error\\.?$/i,\n\t/^fetch\\s+failed\\.?$/i,\n\t// Response-body decompression failures reported by Node/Bun zlib, optionally\n\t// behind the fetch/WebSocket layer's \"Library error:\" wrapper. GitHub Copilot\n\t// on the default `transport: \"auto\"` surfaces this as\n\t// \"Library error: zlib error: incorrect header check\" (#2553). These are\n\t// unanchored because the wrapper text varies by runtime and transport. `zlib`\n\t// has no trailing word boundary on purpose: Bun 1.4.0, the shipped runtime\n\t// when verified, throws `ZlibError fetching \"...\"` as one word.\n\t/\\bzlib/i,\n\t/\\bincorrect\\s+header\\s+check\\b/i,\n\t/\\bdecompress(?:ion|ing|ed)?\\b/i,\n\t/^library\\s+error\\b/i,\n\t// Idle-stream deadline enforced below the HTTP layer by pi-ai's\n\t// `withStreamDeadline`, so a stalled stream fails over instead of hanging.\n\t/\\bstream\\s+deadline\\s+exceeded\\b/i,\n\t// A streamed response cut off before its finish reason, as GitHub Copilot's Gemini models do now and then: the\n\t// same request normally completes when sent again (#4223).\n\t/\\bstream\\s+ended\\s+without\\s+finish[_\\s-]?reason\\b/i,\n];\n\n// HTTP 402 and explicit quota exhaustion: the account cannot be served again until its quota resets.\n// Codes that also appear as free-text wording for short limits (\"quota exceeded\", \"usage limit reached\")\n// count only as a JSON `code`/`type` value, as in a raw error body some providers put in the message.\n// A service-quota exception and a per-day quota violation in a JSON error body (`\"quotaId\": \"...PerDay...\"`)\n// also last until the quota resets.\nconst QUOTA_EXHAUSTED_FAILURE_PATTERN =\n\t/(?<![a-z0-9.])402(?![a-z0-9.])|payment[_\\s-]*required|insufficient[_\\s-]*quota|\\bServiceQuotaExceededException\\b|\"quotaId\"\\s*:\\s*\"[^\"]*PerDay|\"(?:code|type|error_code)\"\\s*:\\s*\"(?:quota_exceeded|usage_limit|usage_limit_reached|usage_limit_exceeded)\"/i;\n\nfunction transportOutageKindFromMessage(message: string): ModelFallbackFailureKind | undefined {\n\treturn TRANSPORT_OUTAGE_FAILURE_PATTERNS.some((pattern) => pattern.test(message.trim()))\n\t\t? \"transport_error\"\n\t\t: undefined;\n}\n\nfunction refusalKindFromMessage(message: string): ModelFallbackFailureKind | undefined {\n\tif (TRANSPORT_CANCELLATION_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"network_timeout\";\n\tif (CANCELLED_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"cancelled\";\n\tif (NON_RETRYABLE_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\n\t// A refused tool call is about that call, whatever policy the provider names: another model is asked the same\n\t// tool call. So it is checked before the content-filter grammar, which \"refused ... safety policy\" also matches.\n\tif (TOOL_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\n\tif (CONTENT_FILTER_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"content_filter\";\n\treturn undefined;\n}\n\nfunction fallbackKindFromMessage(message: string, name: string | undefined): ModelFallbackFailureKind | undefined {\n\tconst refusalKind = refusalKindFromMessage(message);\n\tif (refusalKind !== undefined) return refusalKind;\n\tconst transportOutageKind = transportOutageKindFromMessage(message);\n\tif (transportOutageKind !== undefined) return transportOutageKind;\n\tif (REQUEST_INCOMPATIBLE_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"request_incompatible\";\n\tconst nameKind = kindFromCode(name);\n\tif (nameKind !== undefined) return nameKind;\n\tif (QUOTA_EXHAUSTED_FAILURE_PATTERN.test(message)) return \"quota_exhausted\";\n\tconst hasRetryablePattern =\n\t\tRETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(message)) ||\n\t\tmessageLooksLikeModelUnavailable(message);\n\tif (!hasRetryablePattern) return undefined;\n\tif (\n\t\t/rate\\s*limit|too\\s*many\\s*requests|\\bthrottl(?:ing|ed)\\b|\\b429\\b|quota|usage[\\s_-]*limit|billing|credit/i.test(\n\t\t\tmessage,\n\t\t)\n\t)\n\t\treturn \"rate_limit\";\n\tif (\n\t\t/auth|unauthori[sz]ed|\\b40[13]\\b|api[_\\s-]*key|token[_\\s-]*(?:expired|revoked|invalidated|rejected)|forbidden|invalid[_\\s-]*key/i.test(\n\t\t\tmessage,\n\t\t)\n\t)\n\t\treturn \"auth_on_candidate_provider\";\n\tif (messageLooksLikeModelUnavailable(message)) return \"model_unavailable\";\n\tif (/network|fetch|socket|connection\\s*refused|getaddrinfo|ENOTFOUND|EAI_AGAIN|timeout|timed\\s*out/i.test(message))\n\t\treturn \"network_timeout\";\n\treturn \"provider_unavailable\";\n}\n\nfunction signalSource(value: unknown, fallback: ModelFallbackFailureSource | undefined): ModelFallbackFailureSource {\n\tif (fallback !== undefined) return fallback;\n\tif (stopReasonFrom(value) !== undefined || diagnosticErrors(value).length > 0) return \"assistant_message\";\n\tif (value instanceof Error) return \"throw\";\n\treturn \"structured\";\n}\n\nfunction makeSignal(\n\tkind: ModelFallbackFailureKind,\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal {\n\tconst status = statusFrom(value);\n\tconst code = codeFrom(value);\n\tconst name = errorName(value);\n\tconst stopReason = stopReasonFrom(value);\n\treturn {\n\t\tkind,\n\t\tmessage: errorMessage(value),\n\t\tsource: signalSource(value, source),\n\t\t...(stopReason !== undefined ? { stopReason } : {}),\n\t\t...(status !== undefined ? { status } : {}),\n\t\t...(code !== undefined ? { code } : {}),\n\t\t...(name !== undefined ? { name } : {}),\n\t};\n}\n\nfunction fallbackSignalFromDirectMessage(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst message = directMessageFrom(value);\n\tif (message === undefined) return undefined;\n\tconst kind = fallbackKindFromMessage(message, errorName(value));\n\treturn kind === undefined ? undefined : makeSignal(kind, value, source);\n}\n\nfunction fallbackSignalFromMessage(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst message = errorMessage(value);\n\tif (!message.trim()) return undefined;\n\tconst kind = fallbackKindFromMessage(message, errorName(value));\n\treturn kind === undefined ? undefined : makeSignal(kind, value, source);\n}\n\nfunction classifyAssistantRefusalSignal(\n\tvalue: unknown,\n\tsource: ModelFallbackFailureSource | undefined,\n): ModelFallbackFailureSignal | undefined {\n\tconst codeRefusalKind =\n\t\trefusalKindFromCode(codeFrom(value)) ??\n\t\trefusalKindFromCode(errorName(value)) ??\n\t\trefusalKindFromCode(finishReasonFrom(value));\n\tif (codeRefusalKind !== undefined) return makeSignal(codeRefusalKind, value, source);\n\n\tconst messageRefusalKind = refusalKindFromMessage(directMessageFrom(value) ?? \"\");\n\treturn messageRefusalKind === undefined ? undefined : makeSignal(messageRefusalKind, value, source);\n}\n\nfunction isRefusalSignal(signal: ModelFallbackFailureSignal): boolean {\n\treturn signal.kind === \"cancelled\" || signal.kind === \"task_failure\" || signal.kind === \"content_filter\";\n}\n\nfunction nestedSignalPriority(signal: ModelFallbackFailureSignal): number {\n\tswitch (signal.kind) {\n\t\tcase \"cancelled\":\n\t\tcase \"task_failure\":\n\t\tcase \"content_filter\":\n\t\t\treturn 100;\n\t\tcase \"auth_on_candidate_provider\":\n\t\t\treturn 90;\n\t\tcase \"request_incompatible\":\n\t\t\treturn 85;\n\t\tcase \"model_unavailable\":\n\t\t\treturn 80;\n\t\tcase \"quota_exhausted\":\n\t\t\treturn 75;\n\t\tcase \"rate_limit\":\n\t\t\treturn 70;\n\t\tcase \"provider_unavailable\":\n\t\t\treturn 60;\n\t\tcase \"network_timeout\":\n\t\t\treturn 50;\n\t\tcase \"transport_error\":\n\t\t\treturn 82;\n\t\tcase \"unknown\":\n\t\t\treturn 0;\n\t}\n}\nfunction structuredSignal(\n\tvalue: unknown,\n\tseen: Set<unknown>,\n\tsource?: ModelFallbackFailureSource,\n): ModelFallbackFailureSignal | undefined {\n\tif (value === undefined || value === null || seen.has(value)) return undefined;\n\tif (typeof value === \"object\") seen.add(value);\n\n\tconst stopReason = stopReasonFrom(value)?.toLowerCase();\n\tconst diagnosticType = stringField(value, \"type\");\n\tconst providerTransportSignal =\n\t\tdiagnosticType !== undefined && normalizeCode(diagnosticType) === \"provider_transport_failure\"\n\t\t\t? makeSignal(\"transport_error\", value, source)\n\t\t\t: undefined;\n\tif (stopReason === \"aborted\") return makeSignal(\"cancelled\", value, source);\n\n\t// Defer direct refusal/cancellation signals until nested diagnostics and\n\t// causes have been inspected. A transport wrapper can carry a cancellation\n\t// or provider refusal that must win over the wrapper's transport label.\n\tconst directRefusalSignal = classifyAssistantRefusalSignal(value, source);\n\tconst codeKind = kindFromCode(codeFrom(value));\n\tconst nameKind = kindFromCode(errorName(value));\n\tconst directCancellationSignal =\n\t\tcodeKind === \"cancelled\" || nameKind === \"cancelled\" ? makeSignal(\"cancelled\", value, source) : undefined;\n\n\tlet bestNestedFallbackSignal: ModelFallbackFailureSignal | undefined;\n\tconst nestedSeen = new Set(seen);\n\tconst nestedValues: readonly { value: unknown; source?: ModelFallbackFailureSource }[] = [\n\t\t...diagnosticErrors(value).map((diagnosticError) => ({ value: diagnosticError, source: \"diagnostic\" as const })),\n\t\t...(field(value, \"error\") === undefined ? [] : [{ value: field(value, \"error\"), source }]),\n\t];\n\tfor (const nested of nestedValues) {\n\t\tconst nestedSignal =\n\t\t\tstructuredSignal(nested.value, nestedSeen, nested.source) ??\n\t\t\tfallbackSignalFromMessage(nested.value, nested.source);\n\t\tif (nestedSignal === undefined) continue;\n\t\tif (isRefusalSignal(nestedSignal)) return nestedSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(nestedSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = nestedSignal;\n\t\t}\n\t}\n\tconst cause = causeOf(value);\n\tconst causeSignal = structuredSignal(cause, nestedSeen, source) ?? fallbackSignalFromMessage(cause, source);\n\tif (causeSignal !== undefined) {\n\t\tif (isRefusalSignal(causeSignal)) return causeSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(causeSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = causeSignal;\n\t\t}\n\t}\n\n\t// This code names the exact cause, so the generic 400 status and its request-error text must not outrank it.\n\tif (\n\t\tdirectRefusalSignal === undefined &&\n\t\tdirectCancellationSignal === undefined &&\n\t\tnormalizeCode(codeFrom(value)) === \"model_not_available_for_integrator\"\n\t)\n\t\treturn makeSignal(\"model_unavailable\", value, source);\n\n\tconst directSignals = [\n\t\tdirectRefusalSignal,\n\t\tdirectCancellationSignal,\n\t\tproviderTransportSignal,\n\t\tfallbackSignalFromDirectMessage(value, source),\n\t\tkindFromStatus(statusFrom(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromStatus(statusFrom(value))!, value, source),\n\t\tkindFromCode(codeFrom(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromCode(codeFrom(value))!, value, source),\n\t\tkindFromCode(errorName(value)) === undefined\n\t\t\t? undefined\n\t\t\t: makeSignal(kindFromCode(errorName(value))!, value, source),\n\t].filter((signal): signal is ModelFallbackFailureSignal => signal !== undefined);\n\tfor (const directSignal of directSignals) {\n\t\tif (isRefusalSignal(directSignal)) return directSignal;\n\t\tif (\n\t\t\tbestNestedFallbackSignal === undefined ||\n\t\t\tnestedSignalPriority(directSignal) > nestedSignalPriority(bestNestedFallbackSignal)\n\t\t) {\n\t\t\tbestNestedFallbackSignal = directSignal;\n\t\t}\n\t}\n\n\tif (bestNestedFallbackSignal !== undefined) return bestNestedFallbackSignal;\n\tif (stopReason === \"error\") return makeSignal(\"provider_unavailable\", value, source);\n\treturn undefined;\n}\n\nfunction messageFromUnknown(value: unknown, seen: Set<unknown>): string | undefined {\n\tif (value === undefined || value === null || seen.has(value)) return undefined;\n\tif (typeof value === \"string\") return value.trim().length > 0 ? value : undefined;\n\tif (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return String(value);\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return undefined;\n\tseen.add(value);\n\n\tif (value instanceof Error && value.message.trim().length > 0) return value.message;\n\tconst directMessage = directMessageFrom(value);\n\tif (directMessage !== undefined) return directMessage;\n\tfor (const diagnosticError of diagnosticErrors(value)) {\n\t\tconst diagnosticMessage = messageFromUnknown(diagnosticError, seen);\n\t\tif (diagnosticMessage !== undefined) return diagnosticMessage;\n\t}\n\tconst causeMessage = messageFromUnknown(causeOf(value), seen);\n\tif (causeMessage !== undefined) return causeMessage;\n\tconst finishReason = finishReasonFrom(value);\n\tif (finishReason !== undefined) return `Model request finished with finish_reason:${finishReason}`;\n\tconst stopReason = stopReasonFrom(value);\n\tif (stopReason !== undefined) return `Assistant message ended with stopReason:${stopReason}`;\n\tconst status = statusFrom(value);\n\tif (status !== undefined) return `Model request failed with status ${status}`;\n\tconst code = codeFrom(value);\n\tif (code !== undefined) return `Model request failed with code ${String(code)}`;\n\treturn undefined;\n}\n\nexport function errorMessage(error: unknown): string {\n\tconst structuredMessage = messageFromUnknown(error, new Set());\n\tif (structuredMessage !== undefined) return structuredMessage;\n\tconst rendered = String(error);\n\treturn rendered === \"[object Object]\" ? \"Model request failed\" : rendered;\n}\n\n/** Alias used by the subagent package's older public helper name. */\nexport const modelFailureMessage = errorMessage;\n\n/** The fallback decision each typed GitHub Copilot failure stands for. */\nconst GITHUB_COPILOT_FAILURE_KINDS: Readonly<Record<GitHubCopilotErrorCode, ModelFallbackFailureKind>> = {\n\t\"model-unavailable\": \"model_unavailable\",\n\t\"rate-limited\": \"rate_limit\",\n\t\"quota-exhausted\": \"quota_exhausted\",\n\t\"content-filtered\": \"content_filter\",\n\t\"prompt-too-large\": \"request_incompatible\",\n\t\"invalid-request\": \"request_incompatible\",\n\t\"authentication-failed\": \"auth_on_candidate_provider\",\n\t\"service-unavailable\": \"provider_unavailable\",\n\t\"stream-ended-early\": \"transport_error\",\n\t\"empty-response\": \"transport_error\",\n\t\"unrecognized-response\": \"provider_unavailable\",\n};\n\n/**\n * A GitHub Copilot failure is typed at the provider: its code decides, never its text. The typed error is found on\n * the failure, anywhere in its cause chain, or in the diagnostics of a failed assistant message in that chain, as\n * when a workflow wraps the message.\n */\nfunction githubCopilotSignal(error: unknown): ModelFallbackFailureSignal | undefined {\n\tconst copilotError: GitHubCopilotError | undefined = findGitHubCopilotError(error);\n\tif (copilotError === undefined) return undefined;\n\treturn makeSignal(GITHUB_COPILOT_FAILURE_KINDS[copilotError.code], copilotError, signalSource(error, undefined));\n}\n\n/**\n * How long the attempt ran, in milliseconds, before its response stream ended early. It is read from the typed GitHub\n * Copilot failure, never from message text: on the error, anywhere in its cause chain, or in the diagnostics of a\n * failed assistant message. Undefined for any other failure, and for a stream-cut error that carries no duration.\n */\nexport function streamCutDurationMs(error: unknown): number | undefined {\n\tconst copilotError = findGitHubCopilotError(error);\n\treturn copilotError instanceof GitHubCopilotStreamEndedEarlyError ? copilotError.durationMs : undefined;\n}\n\nexport function normalizeModelFailureSignal(error: unknown): ModelFallbackFailureSignal {\n\t// Extension startup is not a model request. Its message names extension paths\n\t// and their own errors, which must not read as a provider failure.\n\tif (isExtensionStartupFailure(error)) {\n\t\tconst name = errorName(error);\n\t\treturn {\n\t\t\tkind: \"unknown\",\n\t\t\tmessage: errorMessage(error),\n\t\t\tsource: \"string_fallback\",\n\t\t\t...(name !== undefined ? { name } : {}),\n\t\t};\n\t}\n\tconst copilot = githubCopilotSignal(error);\n\tif (copilot !== undefined) return copilot;\n\tconst structured = structuredSignal(error, new Set());\n\tif (structured !== undefined) return structured;\n\tconst message = errorMessage(error);\n\tconst name = errorName(error);\n\tconst fallbackKind = message.trim().length > 0 ? fallbackKindFromMessage(message, name) : undefined;\n\treturn {\n\t\tkind: fallbackKind ?? \"unknown\",\n\t\tmessage,\n\t\tsource: \"string_fallback\",\n\t\t...(name !== undefined ? { name } : {}),\n\t};\n}\n\n/** Whether a failure is a provider safety/refusal response: a content-filter refusal, or a refused tool call. */\nexport function isSafetyRefusalFailure(error: unknown): boolean {\n\tconst signal = normalizeModelFailureSignal(error);\n\tif (signal.kind === \"content_filter\") return true;\n\tif (signal.kind !== \"task_failure\") return false;\n\tconst text = `${signal.message}\\n${signal.code ?? \"\"}\\n${signal.name ?? \"\"}`;\n\treturn PROVIDER_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(text));\n}\n\n/** Whether a provider's content filter refused the request, as OpenAI's HTTP 422 `cyber_policy` does. */\nexport function isContentFilterRefusal(error: unknown): boolean {\n\treturn normalizeModelFailureSignal(error).kind === \"content_filter\";\n}\n\n/**\n * True when this failure may spend a configured model fallback candidate. A content-filter refusal does unless\n * `options.fallbackOnContentFilter` is false.\n */\nexport function isRetryableModelFailure(error: unknown, options?: ModelFallbackFailureOptions): boolean {\n\tif (error === undefined) return false;\n\tconst kind = normalizeModelFailureSignal(error).kind;\n\tif (kind === \"content_filter\") return options?.fallbackOnContentFilter !== false;\n\treturn FALLBACKABLE_FAILURE_KINDS.has(kind);\n}\n\nconst SAME_MODEL_RETRYABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"rate_limit\",\n\t\"provider_unavailable\",\n\t\"network_timeout\",\n\t\"transport_error\",\n]);\n\n/**\n * An assistant error that only its `stopReason` marks as a model failure: no status, code or name, and text that no\n * pattern recognizes. It may spend a fallback candidate, but it is not retried on the same model on its own.\n */\nfunction isUnrecognizedSignal(signal: ModelFallbackFailureSignal): boolean {\n\treturn (\n\t\tsignal.kind === \"provider_unavailable\" &&\n\t\tsignal.source === \"assistant_message\" &&\n\t\tsignal.status === undefined &&\n\t\tsignal.code === undefined &&\n\t\tsignal.name === undefined &&\n\t\t!RETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(signal.message))\n\t);\n}\n\n/** True when the same model may be requested again before fallback advances. */\nexport function isRetryableSameModelFailure(error: unknown): boolean {\n\tif (!isRetryableModelFailure(error)) return false;\n\tconst signal = normalizeModelFailureSignal(error);\n\treturn SAME_MODEL_RETRYABLE_FAILURE_KINDS.has(signal.kind) && !isUnrecognizedSignal(signal);\n}\n\n/**\n * True for a failure that may spend a fallback candidate although nothing recognizes it: an assistant error with no\n * status, code or name whose text matches no known pattern. A session with a fallback chain retries it on the same\n * model first, so such an error never switches models on its first occurrence (#4223).\n */\nexport function isUnrecognizedModelFailure(error: unknown): boolean {\n\treturn isRetryableModelFailure(error) && isUnrecognizedSignal(normalizeModelFailureSignal(error));\n}\n"]}
|
|
@@ -21,5 +21,4 @@ export interface ResolveModelScopeResult {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function resolveModelScopeFromModels(patterns: string[], models: readonly Model<Api>[]): ResolveModelScopeResult;
|
|
23
23
|
export declare function resolveModelScopeWithDiagnostics(patterns: string[], modelRuntime: ModelRuntime): Promise<ResolveModelScopeResult>;
|
|
24
|
-
export declare function resolveModelScope(patterns: string[], modelRuntime: ModelRuntime): Promise<ScopedModel[]>;
|
|
25
24
|
//# sourceMappingURL=model-resolver-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-scope.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,KAAK,EAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-resolver-scope.d.ts","sourceRoot":"","sources":["../../src/core/model-resolver-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,KAAK,EAAkB,MAAM,uBAAuB,CAAC;AAM7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,UAAU,GAAG,wBAAwB,GAAG,WAAW,CAAC;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACvC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACpC;AAwBD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,GAC3B,uBAAuB,CAoEzB;AAED,wBAAsB,gCAAgC,CACrD,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { modelsAreEqual } from "@bastani/pi-ai/compat";
|
|
2
|
-
import chalk from "chalk";
|
|
3
2
|
import { minimatch } from "minimatch";
|
|
4
3
|
import { isValidThinkingLevel } from "../cli/args.js";
|
|
5
4
|
import { normalizeModelReference } from "./azure-provider-compat.js";
|
|
@@ -91,11 +90,4 @@ export function resolveModelScopeFromModels(patterns, models) {
|
|
|
91
90
|
export async function resolveModelScopeWithDiagnostics(patterns, modelRuntime) {
|
|
92
91
|
return resolveModelScopeFromModels(patterns, modelRuntime.getAvailableSnapshot());
|
|
93
92
|
}
|
|
94
|
-
export async function resolveModelScope(patterns, modelRuntime) {
|
|
95
|
-
const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(patterns, modelRuntime);
|
|
96
|
-
for (const diagnostic of diagnostics) {
|
|
97
|
-
console.warn(chalk.yellow(`Warning: ${diagnostic.message}`));
|
|
98
|
-
}
|
|
99
|
-
return scopedModels;
|
|
100
|
-
}
|
|
101
93
|
//# sourceMappingURL=model-resolver-scope.js.map
|