@bastani/atomic 0.9.40 → 0.9.41-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 +50 -0
- package/README.md +1 -1
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/README.md +1 -1
- package/dist/builtin/intercom/broker/broker.ts +24 -21
- package/dist/builtin/intercom/broker/client.ts +97 -6
- package/dist/builtin/intercom/broker/list-reply.ts +53 -0
- package/dist/builtin/intercom/index.bundle.mjs +278 -46
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/recoverable-disconnect.ts +27 -1
- package/dist/builtin/intercom/types.ts +8 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +14 -0
- package/dist/builtin/subagents/README.md +14 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +99 -19
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +25 -0
- package/dist/builtin/workflows/README.md +2 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +16 -0
- package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +9 -0
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +6 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +441 -90
- package/dist/builtin/workflows/src/index.js +226 -34
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +17 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +1 -1
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +33 -18
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +114 -21
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +6 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +19 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +41 -6
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts +3 -1
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.js +79 -12
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +16 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
- package/dist/core/compaction/planner-outcome.js +2 -1
- package/dist/core/compaction/planner-outcome.js.map +1 -1
- package/dist/core/execution-model-router.d.ts +18 -0
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +14 -8
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/extension-oauth-refresh-rejection.d.ts +12 -0
- package/dist/core/extension-oauth-refresh-rejection.d.ts.map +1 -0
- package/dist/core/extension-oauth-refresh-rejection.js +70 -0
- package/dist/core/extension-oauth-refresh-rejection.js.map +1 -0
- package/dist/core/extension-startup-failure.d.ts +30 -0
- package/dist/core/extension-startup-failure.d.ts.map +1 -0
- package/dist/core/extension-startup-failure.js +62 -0
- package/dist/core/extension-startup-failure.js.map +1 -0
- package/dist/core/extensions/context-types.d.ts +2 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +8 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +1 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.d.ts +1 -0
- package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.js +3 -0
- package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +8 -0
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +12 -0
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +9 -3
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +5 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +6 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +6 -5
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +13 -2
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +12 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +35 -0
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +158 -42
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/structured-output/deadline.d.ts +40 -0
- package/dist/core/structured-output/deadline.d.ts.map +1 -0
- package/dist/core/structured-output/deadline.js +110 -0
- package/dist/core/structured-output/deadline.js.map +1 -0
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +103 -47
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/rejection-detail.d.ts +9 -0
- package/dist/core/structured-output/rejection-detail.d.ts.map +1 -0
- package/dist/core/structured-output/rejection-detail.js +129 -0
- package/dist/core/structured-output/rejection-detail.js.map +1 -0
- package/dist/core/structured-output/types.d.ts +8 -1
- package/dist/core/structured-output/types.d.ts.map +1 -1
- package/dist/core/structured-output/types.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +7 -1
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +28 -6
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/contracts.d.ts +6 -1
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/pause.d.ts +2 -1
- package/dist/core/tasks/pause.d.ts.map +1 -1
- package/dist/core/tasks/pause.js +3 -2
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +10 -5
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -32
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/kill.d.ts.map +1 -1
- package/dist/core/tools/kill.js +17 -3
- package/dist/core/tools/kill.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +55 -0
- package/dist/core/tools/shell-task-render.d.ts.map +1 -0
- package/dist/core/tools/shell-task-render.js +123 -0
- package/dist/core/tools/shell-task-render.js.map +1 -0
- package/dist/core/tools/shell-task-status.d.ts +52 -0
- package/dist/core/tools/shell-task-status.d.ts.map +1 -0
- package/dist/core/tools/shell-task-status.js +184 -0
- package/dist/core/tools/shell-task-status.js.map +1 -0
- package/dist/core/tools/structured-output.d.ts +5 -0
- package/dist/core/tools/structured-output.d.ts.map +1 -1
- package/dist/core/tools/structured-output.js +3 -0
- package/dist/core/tools/structured-output.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +134 -57
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -0
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +3 -0
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +19 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +11 -1
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +12 -10
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +20 -30
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +23 -96
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +7 -8
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +27 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +20 -10
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +40 -5
- package/dist/modes/interactive/interactive-mode-base.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-mode-surface.d.ts +2 -4
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.d.ts +3 -0
- package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.js +9 -1
- package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +30 -2
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +43 -8
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +12 -3
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts +6 -1
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
- package/dist/modes/interactive/theme/color-utils.js +39 -17
- package/dist/modes/interactive/theme/color-utils.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -2
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-tokens.d.ts +6 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-tokens.js +7 -3
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +3 -0
- package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.js +13 -1
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +11 -2
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +8 -0
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js +54 -0
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +4 -13
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-model-catalog.d.ts +9 -0
- package/dist/modes/rpc/rpc-model-catalog.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-model-catalog.js +19 -0
- package/dist/modes/rpc/rpc-model-catalog.js.map +1 -0
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +2 -6
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +6 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/changelog.d.ts +6 -0
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +11 -0
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +4 -0
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/background-tasks.md +5 -3
- package/docs/codemode.md +2 -2
- package/docs/custom-provider/oauth.md +42 -1
- package/docs/custom-provider/registration.md +2 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions/api-reference.md +3 -4
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/events.md +1 -1
- package/docs/providers.md +3 -3
- package/docs/rpc/protocol.md +4 -2
- package/docs/sdk/reference.md +2 -0
- package/docs/sdk/structured-decisions.md +7 -5
- package/docs/sdk.md +5 -2
- package/docs/settings.md +4 -2
- package/docs/subagents/reference.md +1 -1
- package/docs/subagents.md +15 -1
- package/docs/themes/reference.md +3 -1
- package/docs/usage.md +3 -1
- package/docs/workflows/api-reference.md +28 -0
- package/docs/workflows/operations.md +2 -2
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -87
- package/dist/core/provider-attribution.js.map +0 -1
|
@@ -124,6 +124,14 @@ export interface WorkflowRunControl {
|
|
|
124
124
|
pause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;
|
|
125
125
|
quit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;
|
|
126
126
|
resume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;
|
|
127
|
+
/**
|
|
128
|
+
* Resolves once this session has finished executing the run, which includes recording its ending in the
|
|
129
|
+
* workflow journal and releasing its lease. A run reports `completed`, `failed` or `killed` before this
|
|
130
|
+
* point, so wait here before treating the journal as final. Resolves at once when this session is not
|
|
131
|
+
* executing the run. Rejects with `WorkflowRunStorageError` when the journal could not record the ending.
|
|
132
|
+
* It never times out; race it against your own deadline.
|
|
133
|
+
*/
|
|
134
|
+
waitForSettled(runId: string): Promise<void>;
|
|
127
135
|
}
|
|
128
136
|
/** `session.workflows`: run management plus observation of the workflow runs owned by one session. */
|
|
129
137
|
export interface SessionWorkflows extends WorkflowRunControl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,oBAAoB,GAC7B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,oBAAoB,EAAE,GAC/B,qBAAqB,CAAC;AAEzB,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAC;CACzD;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACrC,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,O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qF;AACrF,qBAAa,mCAAoC,SAAQ,uBAAuB;IAC/E,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,0DAA0D;AAC1D,qBAAa,uBAAwB,SAAQ,uBAAuB;IACnE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,2FAA2F;AAC3F,qBAAa,kCAAmC,SAAQ,uBAAuB;IAC9E,YACC,OAAO,SAA0D,EACjE,OAAO,CAAC,EAAE,8BAA8B,EAIxC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AAwLA,2FAA2F;AAC3F,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,CAA8B;IAClC,KAAK,CAAU;IACxB,mFAAmF;IAC1E,UAAU,CAA0C;IAE7D,YAAY,IAAiC,EAAE,OAAe,EAAE,OAAO,GAAmC,EAAE;QAC3G,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAC5E,CAAC;CACD;AAED,gEAAgE;AAChE,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAED,y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,yBAAyB,CAAC;IACvC,CAAC;CACD;AAED,2FAA2F;AAC3F,MAAM,OAAO,kCAAmC,SAAQ,uBAAuB;IAC9E,YACC,OAAO,GAAG,uDAAuD,EACjE,OAAwC;QAExC,KAAK,CAAC,kCAAkC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;IAClD,CAAC;CACD","sourcesContent":["import type {\n\tWorkflowActivityObserver,\n\tWorkflowActivitySubscription,\n\tWorkflowRunStatus,\n\tWorkflowStageStatus,\n} from \"./workflow-events.js\";\n\nexport type WorkflowRunJsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunJsonValue[]\n\t| WorkflowRunJsonObject;\n\nexport interface WorkflowRunJsonObject {\n\treadonly [key: string]: WorkflowRunJsonValue | undefined;\n}\n\nexport type WorkflowRunFilterStatus = WorkflowRunStatus | WorkflowStageStatus | \"awaiting_input\";\n\nexport interface WorkflowRunListFilter {\n\t/** Run statuses match directly; `awaiting_input` selects runs with an unanswered prompt. */\n\treadonly status?: WorkflowRunFilterStatus;\n\t/** Include project durable/completed history in addition to this session's runs. */\n\treadonly includeDurable?: boolean;\n}\n\nexport interface WorkflowStageListFilter {\n\treadonly status?: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunActiveStage {\n\treadonly stageId: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunAwaitingInput {\n\treadonly stageId?: string;\n\treadonly stageName?: string;\n\treadonly promptId?: string;\n\treadonly promptKind?: string;\n\treadonly message?: string;\n}\n\n/** Stored generated description and the run identity used by resume clients. */\nexport interface WorkflowRunSummaryMetadata {\n\treadonly label?: string;\n\treadonly identity?: string;\n\treadonly summary?: string;\n\t/** Unix milliseconds through which the summary describes the run. */\n\treadonly summarizedThrough?: number;\n}\n\n/** The concise per-run data that the `workflow` tool's `status` action lists. */\nexport interface WorkflowRunSummary extends WorkflowRunSummaryMetadata {\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly elapsedMs: number;\n\treadonly activeStages: readonly WorkflowRunActiveStage[];\n\treadonly awaitingInputCount: number;\n\treadonly awaitingInput: readonly WorkflowRunAwaitingInput[];\n\treadonly exitReason?: string;\n\treadonly error?: string;\n}\n\nexport interface WorkflowRunStageSummary {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n\treadonly sessionId?: string;\n\treadonly error?: string;\n\treadonly skippedReason?: string;\n\treadonly awaitingInputSince?: number;\n}\n\n/** The per-run detail that the `workflow` tool's `status` action returns for one run id. */\nexport interface WorkflowRunDetail extends WorkflowRunSummaryMetadata {\n\treadonly runId: string;\n\treadonly rootRunId?: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus | \"crashed\";\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly durationMs?: number;\n\treadonly inputs: WorkflowRunJsonObject;\n\treadonly stages: readonly WorkflowRunStageSummary[];\n\treadonly result?: WorkflowRunJsonObject;\n\treadonly error?: string;\n\treadonly exitReason?: string;\n\treadonly resumable?: boolean;\n\treadonly resumeGuidance?: string;\n\treadonly ownerActiveElsewhere?: boolean;\n}\n\nexport interface WorkflowRunAllTarget {\n\treadonly all: true;\n}\n\nexport interface WorkflowRunPauseOptions {\n\t/** Pause one stage instead of the whole run. */\n\treadonly stageId?: string;\n}\n\nexport interface WorkflowRunResumeOptions {\n\t/** Resume one paused stage instead of the whole run. */\n\treadonly stageId?: string;\n\t/** Message delivered to each resumed stage. */\n\treadonly message?: string;\n\treadonly legacyRecovery?: { readonly olderWorkersStopped: true };\n}\n\nexport type WorkflowRunControlStatus = \"ok\" | \"running\" | \"paused\" | \"partial\" | \"noop\" | \"cancelled\";\n\n/** A run that a batch pause or quit could not stop; it may still be active. */\nexport interface WorkflowRunControlFailedRun {\n\treadonly runId: string;\n\t/** Machine-readable refusal, such as `not_found`, `no_active_stages` or `pause_failed`. */\n\treadonly reason: string;\n\treadonly message?: string;\n}\n\n/**\n * The acknowledged result of a pause, quit or resume request, as the `workflow`\n * tool reports it. `runId` is `--all` for a batch request. `noop` means the request was\n * understood and found nothing to change; `partial` means only part of the\n * request took effect. For a batch pause or quit, `failedRuns` names every run that\n * could not be stopped, so a `partial` outcome is never a complete stop.\n */\nexport interface WorkflowRunControlOutcome {\n\treadonly action: \"pause\" | \"quit\" | \"resume\";\n\treadonly runId: string;\n\treadonly status: WorkflowRunControlStatus;\n\treadonly message: string;\n\treadonly stageId?: string;\n\treadonly workflowStatus?: WorkflowRunStatus;\n\treadonly abandoned?: boolean;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Typed run management for the workflow runs owned by one session, as registered by the workflows extension. */\nexport interface WorkflowRunControl {\n\tlistRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;\n\tgetRun(runId: string): Promise<WorkflowRunDetail>;\n\tgetStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tquit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tresume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;\n}\n\n/** `session.workflows`: run management plus observation of the workflow runs owned by one session. */\nexport interface SessionWorkflows extends WorkflowRunControl {\n\t/**\n\t * Follow root activity and graph changes. Delivers a snapshot frame first, then FIFO\n\t * `changed` and `removed` frames; the subscription follows extension reloads.\n\t */\n\tobserve(observer: WorkflowActivityObserver): WorkflowActivitySubscription;\n}\n\nexport interface WorkflowRunControlRegistration {\n\tdispose(): void;\n}\n\nexport type WorkflowRunControlErrorCode =\n\t| \"WORKFLOW_RUN_NOT_FOUND\"\n\t| \"WORKFLOW_RUN_OWNED_ELSEWHERE\"\n\t| \"WORKFLOW_RUN_NOT_RESUMABLE\"\n\t| \"WORKFLOW_STAGE_NOT_FOUND\"\n\t| \"WORKFLOW_STAGE_AMBIGUOUS\"\n\t| \"WORKFLOW_STAGE_RESUME_UNSUPPORTED\"\n\t| \"WORKFLOW_RUN_STORAGE\"\n\t| \"WORKFLOW_RUN_CONTROL_FAILED\"\n\t| \"WORKFLOW_RUN_CONTROL_UNAVAILABLE\";\n\nexport interface WorkflowRunControlErrorOptions extends ErrorOptions {\n\treadonly runId?: string;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Base class for every failure reported by {@link SessionWorkflows}; branch on `code`. */\nexport class WorkflowRunControlError extends Error {\n\treadonly code: WorkflowRunControlErrorCode;\n\treadonly runId?: string;\n\t/** Runs a batch pause or quit could not stop, when the whole batch was refused. */\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n\n\tconstructor(code: WorkflowRunControlErrorCode, message: string, options: WorkflowRunControlErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.name = \"WorkflowRunControlError\";\n\t\tthis.code = code;\n\t\tif (options.runId !== undefined) this.runId = options.runId;\n\t\tif (options.failedRuns !== undefined) this.failedRuns = options.failedRuns;\n\t}\n}\n\n/** The run id is unknown, malformed, or an ambiguous prefix. */\nexport class WorkflowRunNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowRunNotFoundError\";\n\t}\n}\n\n/** The run belongs to another session or is executing in another live Atomic process. */\nexport class WorkflowRunOwnershipError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_OWNED_ELSEWHERE\", message, options);\n\t\tthis.name = \"WorkflowRunOwnershipError\";\n\t}\n}\n\n/** The run has no continuation to resume: it completed, was killed, or has no durable progress. */\nexport class WorkflowRunNotResumableError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_RESUMABLE\", message, options);\n\t\tthis.name = \"WorkflowRunNotResumableError\";\n\t}\n}\n\n/** The stage identifier matches no stage or tool node of the run. */\nexport class WorkflowStageNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowStageNotFoundError\";\n\t}\n}\n\n/** The stage identifier matches more than one stage or tool node; pass a more specific identifier. */\nexport class WorkflowStageAmbiguousError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_AMBIGUOUS\", message, options);\n\t\tthis.name = \"WorkflowStageAmbiguousError\";\n\t}\n}\n\n/** A durable run can only be resumed whole; resume it without a stage identifier. */\nexport class WorkflowStageResumeUnsupportedError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_RESUME_UNSUPPORTED\", message, options);\n\t\tthis.name = \"WorkflowStageResumeUnsupportedError\";\n\t}\n}\n\n/** Workflow storage is unavailable, closed, or failed. */\nexport class WorkflowRunStorageError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_STORAGE\", message, options);\n\t\tthis.name = \"WorkflowRunStorageError\";\n\t}\n}\n\n/** The workflows extension is not loaded for this session, or the session was disposed. */\nexport class WorkflowRunControlUnavailableError extends WorkflowRunControlError {\n\tconstructor(\n\t\tmessage = \"Workflow run control is unavailable for this session.\",\n\t\toptions?: WorkflowRunControlErrorOptions,\n\t) {\n\t\tsuper(\"WORKFLOW_RUN_CONTROL_UNAVAILABLE\", message, options);\n\t\tthis.name = \"WorkflowRunControlUnavailableError\";\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow-run-control.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AAgMA,2FAA2F;AAC3F,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,CAA8B;IAClC,KAAK,CAAU;IACxB,mFAAmF;IAC1E,UAAU,CAA0C;IAE7D,YAAY,IAAiC,EAAE,OAAe,EAAE,OAAO,GAAmC,EAAE;QAC3G,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAC5E,CAAC;CACD;AAED,gEAAgE;AAChE,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAED,yFAAyF;AACzF,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IACrE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IACzC,CAAC;CACD;AAED,mGAAmG;AACnG,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IACxE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,4BAA4B,EAAE,OAAO,E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\n\tWorkflowStageStatus,\n} from \"./workflow-events.js\";\n\nexport type WorkflowRunJsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunJsonValue[]\n\t| WorkflowRunJsonObject;\n\nexport interface WorkflowRunJsonObject {\n\treadonly [key: string]: WorkflowRunJsonValue | undefined;\n}\n\nexport type WorkflowRunFilterStatus = WorkflowRunStatus | WorkflowStageStatus | \"awaiting_input\";\n\nexport interface WorkflowRunListFilter {\n\t/** Run statuses match directly; `awaiting_input` selects runs with an unanswered prompt. */\n\treadonly status?: WorkflowRunFilterStatus;\n\t/** Include project durable/completed history in addition to this session's runs. */\n\treadonly includeDurable?: boolean;\n}\n\nexport interface WorkflowStageListFilter {\n\treadonly status?: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunActiveStage {\n\treadonly stageId: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunAwaitingInput {\n\treadonly stageId?: string;\n\treadonly stageName?: string;\n\treadonly promptId?: string;\n\treadonly promptKind?: string;\n\treadonly message?: string;\n}\n\n/** Stored generated description and the run identity used by resume clients. */\nexport interface WorkflowRunSummaryMetadata {\n\treadonly label?: string;\n\treadonly identity?: string;\n\treadonly summary?: string;\n\t/** Unix milliseconds through which the summary describes the run. */\n\treadonly summarizedThrough?: number;\n}\n\n/** The concise per-run data that the `workflow` tool's `status` action lists. */\nexport interface WorkflowRunSummary extends WorkflowRunSummaryMetadata {\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly elapsedMs: number;\n\treadonly activeStages: readonly WorkflowRunActiveStage[];\n\treadonly awaitingInputCount: number;\n\treadonly awaitingInput: readonly WorkflowRunAwaitingInput[];\n\treadonly exitReason?: string;\n\treadonly error?: string;\n}\n\nexport interface WorkflowRunStageSummary {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n\treadonly sessionId?: string;\n\treadonly error?: string;\n\treadonly skippedReason?: string;\n\treadonly awaitingInputSince?: number;\n}\n\n/** The per-run detail that the `workflow` tool's `status` action returns for one run id. */\nexport interface WorkflowRunDetail extends WorkflowRunSummaryMetadata {\n\treadonly runId: string;\n\treadonly rootRunId?: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus | \"crashed\";\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly durationMs?: number;\n\treadonly inputs: WorkflowRunJsonObject;\n\treadonly stages: readonly WorkflowRunStageSummary[];\n\treadonly result?: WorkflowRunJsonObject;\n\treadonly error?: string;\n\treadonly exitReason?: string;\n\treadonly resumable?: boolean;\n\treadonly resumeGuidance?: string;\n\treadonly ownerActiveElsewhere?: boolean;\n}\n\nexport interface WorkflowRunAllTarget {\n\treadonly all: true;\n}\n\nexport interface WorkflowRunPauseOptions {\n\t/** Pause one stage instead of the whole run. */\n\treadonly stageId?: string;\n}\n\nexport interface WorkflowRunResumeOptions {\n\t/** Resume one paused stage instead of the whole run. */\n\treadonly stageId?: string;\n\t/** Message delivered to each resumed stage. */\n\treadonly message?: string;\n\treadonly legacyRecovery?: { readonly olderWorkersStopped: true };\n}\n\nexport type WorkflowRunControlStatus = \"ok\" | \"running\" | \"paused\" | \"partial\" | \"noop\" | \"cancelled\";\n\n/** A run that a batch pause or quit could not stop; it may still be active. */\nexport interface WorkflowRunControlFailedRun {\n\treadonly runId: string;\n\t/** Machine-readable refusal, such as `not_found`, `no_active_stages` or `pause_failed`. */\n\treadonly reason: string;\n\treadonly message?: string;\n}\n\n/**\n * The acknowledged result of a pause, quit or resume request, as the `workflow`\n * tool reports it. `runId` is `--all` for a batch request. `noop` means the request was\n * understood and found nothing to change; `partial` means only part of the\n * request took effect. For a batch pause or quit, `failedRuns` names every run that\n * could not be stopped, so a `partial` outcome is never a complete stop.\n */\nexport interface WorkflowRunControlOutcome {\n\treadonly action: \"pause\" | \"quit\" | \"resume\";\n\treadonly runId: string;\n\treadonly status: WorkflowRunControlStatus;\n\treadonly message: string;\n\treadonly stageId?: string;\n\treadonly workflowStatus?: WorkflowRunStatus;\n\treadonly abandoned?: boolean;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Typed run management for the workflow runs owned by one session, as registered by the workflows extension. */\nexport interface WorkflowRunControl {\n\tlistRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;\n\tgetRun(runId: string): Promise<WorkflowRunDetail>;\n\tgetStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tquit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tresume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;\n\t/**\n\t * Resolves once this session has finished executing the run, which includes recording its ending in the\n\t * workflow journal and releasing its lease. A run reports `completed`, `failed` or `killed` before this\n\t * point, so wait here before treating the journal as final. Resolves at once when this session is not\n\t * executing the run. Rejects with `WorkflowRunStorageError` when the journal could not record the ending.\n\t * It never times out; race it against your own deadline.\n\t */\n\twaitForSettled(runId: string): Promise<void>;\n}\n\n/** `session.workflows`: run management plus observation of the workflow runs owned by one session. */\nexport interface SessionWorkflows extends WorkflowRunControl {\n\t/**\n\t * Follow root activity and graph changes. Delivers a snapshot frame first, then FIFO\n\t * `changed` and `removed` frames; the subscription follows extension reloads.\n\t */\n\tobserve(observer: WorkflowActivityObserver): WorkflowActivitySubscription;\n}\n\nexport interface WorkflowRunControlRegistration {\n\tdispose(): void;\n}\n\nexport type WorkflowRunControlErrorCode =\n\t| \"WORKFLOW_RUN_NOT_FOUND\"\n\t| \"WORKFLOW_RUN_OWNED_ELSEWHERE\"\n\t| \"WORKFLOW_RUN_NOT_RESUMABLE\"\n\t| \"WORKFLOW_STAGE_NOT_FOUND\"\n\t| \"WORKFLOW_STAGE_AMBIGUOUS\"\n\t| \"WORKFLOW_STAGE_RESUME_UNSUPPORTED\"\n\t| \"WORKFLOW_RUN_STORAGE\"\n\t| \"WORKFLOW_RUN_CONTROL_FAILED\"\n\t| \"WORKFLOW_RUN_CONTROL_UNAVAILABLE\";\n\nexport interface WorkflowRunControlErrorOptions extends ErrorOptions {\n\treadonly runId?: string;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Base class for every failure reported by {@link SessionWorkflows}; branch on `code`. */\nexport class WorkflowRunControlError extends Error {\n\treadonly code: WorkflowRunControlErrorCode;\n\treadonly runId?: string;\n\t/** Runs a batch pause or quit could not stop, when the whole batch was refused. */\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n\n\tconstructor(code: WorkflowRunControlErrorCode, message: string, options: WorkflowRunControlErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.name = \"WorkflowRunControlError\";\n\t\tthis.code = code;\n\t\tif (options.runId !== undefined) this.runId = options.runId;\n\t\tif (options.failedRuns !== undefined) this.failedRuns = options.failedRuns;\n\t}\n}\n\n/** The run id is unknown, malformed, or an ambiguous prefix. */\nexport class WorkflowRunNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowRunNotFoundError\";\n\t}\n}\n\n/** The run belongs to another session or is executing in another live Atomic process. */\nexport class WorkflowRunOwnershipError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_OWNED_ELSEWHERE\", message, options);\n\t\tthis.name = \"WorkflowRunOwnershipError\";\n\t}\n}\n\n/** The run has no continuation to resume: it completed, was killed, or has no durable progress. */\nexport class WorkflowRunNotResumableError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_RESUMABLE\", message, options);\n\t\tthis.name = \"WorkflowRunNotResumableError\";\n\t}\n}\n\n/** The stage identifier matches no stage or tool node of the run. */\nexport class WorkflowStageNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowStageNotFoundError\";\n\t}\n}\n\n/** The stage identifier matches more than one stage or tool node; pass a more specific identifier. */\nexport class WorkflowStageAmbiguousError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_AMBIGUOUS\", message, options);\n\t\tthis.name = \"WorkflowStageAmbiguousError\";\n\t}\n}\n\n/** A durable run can only be resumed whole; resume it without a stage identifier. */\nexport class WorkflowStageResumeUnsupportedError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_RESUME_UNSUPPORTED\", message, options);\n\t\tthis.name = \"WorkflowStageResumeUnsupportedError\";\n\t}\n}\n\n/** Workflow storage is unavailable, closed, or failed. */\nexport class WorkflowRunStorageError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_STORAGE\", message, options);\n\t\tthis.name = \"WorkflowRunStorageError\";\n\t}\n}\n\n/** The workflows extension is not loaded for this session, or the session was disposed. */\nexport class WorkflowRunControlUnavailableError extends WorkflowRunControlError {\n\tconstructor(\n\t\tmessage = \"Workflow run control is unavailable for this session.\",\n\t\toptions?: WorkflowRunControlErrorOptions,\n\t) {\n\t\tsuper(\"WORKFLOW_RUN_CONTROL_UNAVAILABLE\", message, options);\n\t\tthis.name = \"WorkflowRunControlUnavailableError\";\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;AAiFH,MAAM,MAAM,wBAAwB,GACjC,4BAA4B,GAC5B,YAAY,GACZ,sBAAsB,GACtB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,WAAW,GACX,cAAc,GACd,SAAS,CAAC;AAEb,MAAM,MAAM,0BAA0B,GACnC,mBAAmB,GACnB,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,iBAAiB,CAAC;AAErB,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AA0gBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnD;AAED,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,qBAAe,CAAC;AAEhD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAuBtF;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK9D;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG/D;AASD,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcnE"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* module free of AgentSession and workflow imports so the published SDK can
|
|
7
7
|
* expose it to the raw-TypeScript companion packages without a cycle.
|
|
8
8
|
*/
|
|
9
|
+
import { isExtensionStartupFailure } from "./extension-startup-failure.js";
|
|
9
10
|
const RETRYABLE_MODEL_FAILURE_PATTERNS = [
|
|
10
11
|
/rate\s*limit/i,
|
|
11
12
|
/too\s*many\s*requests/i,
|
|
@@ -581,6 +582,17 @@ export function errorMessage(error) {
|
|
|
581
582
|
/** Alias used by the subagent package's older public helper name. */
|
|
582
583
|
export const modelFailureMessage = errorMessage;
|
|
583
584
|
export function normalizeModelFailureSignal(error) {
|
|
585
|
+
// Extension startup is not a model request. Its message names extension paths
|
|
586
|
+
// and their own errors, which must not read as a provider failure.
|
|
587
|
+
if (isExtensionStartupFailure(error)) {
|
|
588
|
+
const name = errorName(error);
|
|
589
|
+
return {
|
|
590
|
+
kind: "unknown",
|
|
591
|
+
message: errorMessage(error),
|
|
592
|
+
source: "string_fallback",
|
|
593
|
+
...(name !== undefined ? { name } : {}),
|
|
594
|
+
};
|
|
595
|
+
}
|
|
584
596
|
const structured = structuredSignal(error, new Set());
|
|
585
597
|
if (structured !== undefined)
|
|
586
598
|
return structured;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fallback-failures.js","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,gCAAgC,GAAsB;IAC3D,eAAe;IACf,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,wB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,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEjF,OAAO,KAAK,CAAC;IACd,OAAO,IAAI,CAAC;AACb,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\nconst RETRYABLE_MODEL_FAILURE_PATTERNS: readonly RegExp[] = [\n\t/rate\\s*limit/i,\n\t/too\\s*many\\s*requests/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/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| \"provider_unavailable\"\n\t| \"network_timeout\"\n\t| \"transport_error\"\n\t| \"model_unavailable\"\n\t| \"request_incompatible\"\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\nconst FALLBACKABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"auth_on_candidate_provider\",\n\t\"rate_limit\",\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\treturn typeof rawCode === \"string\" || typeof rawCode === \"number\" ? rawCode : 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 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\tif (normalizedCode.includes(\"content_filter\") || normalizedCode.includes(\"contentfilter\")) return \"task_failure\";\n\tif (normalizedCode.includes(\"safety\") || normalizedCode.includes(\"policy\")) return \"task_failure\";\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\tcase \"tool_refusal\":\n\t\tcase \"tool_call_refusal\":\n\t\tcase \"tool_use_refusal\":\n\t\t\treturn \"task_failure\";\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 \"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\t\treturn \"rate_limit\";\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\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\nconst PROVIDER_REFUSAL_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/\\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/\\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\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 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];\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\tif (PROVIDER_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\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\tconst hasRetryablePattern =\n\t\tRETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(message)) ||\n\t\tmessageLooksLikeModelUnavailable(message);\n\tif (!hasRetryablePattern) return undefined;\n\tif (/rate\\s*limit|too\\s*many\\s*requests|\\b429\\b|quota|usage[\\s_-]*limit|billing|credit/i.test(message))\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\";\n}\n\nfunction nestedSignalPriority(signal: ModelFallbackFailureSignal): number {\n\tswitch (signal.kind) {\n\t\tcase \"cancelled\":\n\t\tcase \"task_failure\":\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 \"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\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\nexport function normalizeModelFailureSignal(error: unknown): ModelFallbackFailureSignal {\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 task-failure signal is a provider safety/refusal response. */\nexport function isSafetyRefusalFailure(error: unknown): boolean {\n\tconst signal = normalizeModelFailureSignal(error);\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/** True when this failure may spend a configured model fallback candidate. */\nexport function isRetryableModelFailure(error: unknown): boolean {\n\tif (error === undefined) return false;\n\treturn FALLBACKABLE_FAILURE_KINDS.has(normalizeModelFailureSignal(error).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/** 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\tif (!SAME_MODEL_RETRYABLE_FAILURE_KINDS.has(signal.kind)) return false;\n\tif (\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\t\treturn false;\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-fallback-failures.js","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,gCAAgC,GAAsB;IAC3D,eAAe;IACf,wBAAwB;IACxB,SAAS;IACT,QAAQ;IACR,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,gCAAgC;IAChC,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;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BAAuB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,CAAC,kCAAkC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACvE,IACC,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;QAEjF,OAAO,KAAK,CAAC;IACd,OAAO,IAAI,CAAC;AACb,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 { 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/\\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/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| \"provider_unavailable\"\n\t| \"network_timeout\"\n\t| \"transport_error\"\n\t| \"model_unavailable\"\n\t| \"request_incompatible\"\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\nconst FALLBACKABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Set([\n\t\"auth_on_candidate_provider\",\n\t\"rate_limit\",\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\treturn typeof rawCode === \"string\" || typeof rawCode === \"number\" ? rawCode : 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 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\tif (normalizedCode.includes(\"content_filter\") || normalizedCode.includes(\"contentfilter\")) return \"task_failure\";\n\tif (normalizedCode.includes(\"safety\") || normalizedCode.includes(\"policy\")) return \"task_failure\";\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\tcase \"tool_refusal\":\n\t\tcase \"tool_call_refusal\":\n\t\tcase \"tool_use_refusal\":\n\t\t\treturn \"task_failure\";\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 \"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\t\treturn \"rate_limit\";\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\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\nconst PROVIDER_REFUSAL_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/\\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/\\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\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 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];\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\tif (PROVIDER_REFUSAL_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return \"task_failure\";\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\tconst hasRetryablePattern =\n\t\tRETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(message)) ||\n\t\tmessageLooksLikeModelUnavailable(message);\n\tif (!hasRetryablePattern) return undefined;\n\tif (/rate\\s*limit|too\\s*many\\s*requests|\\b429\\b|quota|usage[\\s_-]*limit|billing|credit/i.test(message))\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\";\n}\n\nfunction nestedSignalPriority(signal: ModelFallbackFailureSignal): number {\n\tswitch (signal.kind) {\n\t\tcase \"cancelled\":\n\t\tcase \"task_failure\":\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 \"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\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\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 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 task-failure signal is a provider safety/refusal response. */\nexport function isSafetyRefusalFailure(error: unknown): boolean {\n\tconst signal = normalizeModelFailureSignal(error);\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/** True when this failure may spend a configured model fallback candidate. */\nexport function isRetryableModelFailure(error: unknown): boolean {\n\tif (error === undefined) return false;\n\treturn FALLBACKABLE_FAILURE_KINDS.has(normalizeModelFailureSignal(error).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/** 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\tif (!SAME_MODEL_RETRYABLE_FAILURE_KINDS.has(signal.kind)) return false;\n\tif (\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\t\treturn false;\n\treturn true;\n}\n"]}
|
|
@@ -12,7 +12,7 @@ export const defaultModelPerProvider = {
|
|
|
12
12
|
deepseek: "deepseek-v4-pro",
|
|
13
13
|
google: "gemini-3.1-pro-preview",
|
|
14
14
|
"google-vertex": "gemini-3.1-pro-preview",
|
|
15
|
-
"github-copilot": "gpt-
|
|
15
|
+
"github-copilot": "gpt-6.1-sol",
|
|
16
16
|
openrouter: "moonshotai/kimi-k2.6",
|
|
17
17
|
"vercel-ai-gateway": "zai/glm-5.1",
|
|
18
18
|
xai: "grok-4.7",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver-defaults.js","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC9D,gBAAgB,EAAE,iCAAiC;IACnD,SAAS,EAAE,iBAAiB;IAC5B,eAAe,EAAE,iBAAiB;IAClC,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,SAAS;IACvB,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,aAAa;IAC7B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,wCAAwC;IAChD,QAAQ,EAAE,iBAAiB;IAC3B,MAAM,EAAE,wBAAwB;IAChC,eAAe,EAAE,wBAAwB;IACzC,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"model-resolver-defaults.js","sourceRoot":"","sources":["../../src/core/model-resolver-defaults.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC9D,gBAAgB,EAAE,iCAAiC;IACnD,SAAS,EAAE,iBAAiB;IAC5B,eAAe,EAAE,iBAAiB;IAClC,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,SAAS;IACvB,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,aAAa;IAC7B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,wCAAwC;IAChD,QAAQ,EAAE,iBAAiB;IAC3B,MAAM,EAAE,wBAAwB;IAChC,eAAe,EAAE,wBAAwB;IACzC,gBAAgB,EAAE,aAAa;IAC/B,UAAU,EAAE,sBAAsB;IAClC,mBAAmB,EAAE,aAAa;IAClC,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,qBAAqB;IAC3B,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,aAAa;IACzB,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,SAAS;IAC1B,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,cAAc;IACvB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,WAAW;IACvB,eAAe,EAAE,WAAW;IAC5B,WAAW,EAAE,sBAAsB;IACnC,SAAS,EAAE,mCAAmC;IAC9C,QAAQ,EAAE,oBAAoB;IAC9B,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,WAAW;IACrB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,iBAAiB;IAChC,IAAI,EAAE,gBAAgB;IACtB,uBAAuB,EAAE,0BAA0B;IACnD,uBAAuB,EAAE,qCAAqC;IAC9D,iBAAiB,EAAE,aAAa;IAChC,oBAAoB,EAAE,aAAa;IACnC,4BAA4B,EAAE,aAAa;IAC3C,MAAM,EAAE,eAAe;IACvB,sBAAsB,EAAE,eAAe;IACvC,uBAAuB,EAAE,eAAe;IACxC,uBAAuB,EAAE,eAAe;CACxC,CAAC;AAEF,MAAM,UAAU,2BAA2B,CAAC,eAA6B;IACxE,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC7E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;QACzF,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { Api, Model } from \"@bastani/pi-ai/compat\";\n\n/** Default model IDs for each known provider */\nexport const defaultModelPerProvider: Record<string, string> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-4-6-v1\",\n\tanthropic: \"claude-opus-4-8\",\n\t\"anthropic-api\": \"claude-opus-4-8\",\n\topenai: \"gpt-5.5\",\n\t\"openai-api\": \"gpt-5.5\",\n\tazure: \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6.1-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3.5-super-vl-120b-a12b\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-3.1-pro-preview\",\n\t\"google-vertex\": \"gemini-3.1-pro-preview\",\n\t\"github-copilot\": \"gpt-6.1-sol\",\n\topenrouter: \"moonshotai/kimi-k2.6\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.1\",\n\txai: \"grok-4.7\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"gpt-oss-120b\",\n\t\"ant-ling\": \"Ring-2.6-1T\",\n\tzai: \"glm-5.3\",\n\t\"zai-coding-cn\": \"glm-5.3\",\n\tmistral: \"devstral-medium-latest\",\n\tminimax: \"MiniMax-M2.7\",\n\t\"minimax-cn\": \"MiniMax-M2.7\",\n\tmoonshotai: \"kimi-k2.6\",\n\t\"moonshotai-cn\": \"kimi-k2.6\",\n\thuggingface: \"moonshotai/Kimi-K2.6\",\n\tfireworks: \"accounts/fireworks/models/kimi-k3\",\n\ttogether: \"moonshotai/Kimi-K3\",\n\tbaseten: \"zai-org/GLM-5.3\",\n\topencode: \"kimi-k2.6\",\n\t\"opencode-go\": \"kimi-k3\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\tmeta: \"muse-spark-1.3\",\n\t\"cloudflare-workers-ai\": \"@cf/moonshotai/kimi-k2.6\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/moonshotai/kimi-k2.6\",\n\t\"qwen-token-plan\": \"qwen3.7-max\",\n\t\"qwen-token-plan-cn\": \"qwen3.7-max\",\n\t\"qwen-token-plan-individual\": \"qwen3.8-max\",\n\txiaomi: \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.6-pro\",\n};\n\nexport function findPreferredAvailableModel(availableModels: Model<Api>[]): Model<Api> | undefined {\n\tfor (const [provider, defaultId] of Object.entries(defaultModelPerProvider)) {\n\t\tconst match = availableModels.find((m) => m.provider === provider && m.id === defaultId);\n\t\tif (match) {\n\t\t\treturn match;\n\t\t}\n\t}\n\n\treturn availableModels[0];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-streaming.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EAER,KAAK,gBAAgB,EAErB,KAAK,2BAA2B,EAChC,KAAK,UAAU,EAEf,KAAK,OAAO,EAGZ,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"model-runtime-streaming.d.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EAChB,OAAO,CAAC,EAAE,+BAA+B,GACvC,2BAA2B,CAY7B;IAED,cAAc,CACb,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,+BAA+B,GACvC,OAAO,CAAC,gBAAgB,CAAC,CAE3B;IAED,OAAO,CAAC,yBAAyB;IAkG3B,aAAa,CAClB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,0BAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAQ3B;IAEK,cAAc,CACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,2BAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAMf;CACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertChatModel, lazyStream, ModelsError, normalizeContext, } from "@bastani/pi-ai";
|
|
1
|
+
import { assertChatModel, getOpenCodeSessionHeaders, lazyStream, ModelsError, normalizeContext, } from "@bastani/pi-ai";
|
|
2
2
|
import { normalizeModelProvider } from "./azure-provider-compat.js";
|
|
3
3
|
import { usesChatGptCodexTransport, withChatGptCodexTransportRouting } from "./fast-model-routing.js";
|
|
4
4
|
import { installCodexFastRouteWebSocketIdentity } from "./fast-model-routing-transport.js";
|
|
@@ -67,7 +67,13 @@ export class ModelRuntimeStreaming {
|
|
|
67
67
|
options?.signal?.throwIfAborted();
|
|
68
68
|
if (!resolution)
|
|
69
69
|
throw new ModelsError("auth", `Provider is not configured: ${model.provider}`);
|
|
70
|
-
|
|
70
|
+
const requestModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;
|
|
71
|
+
// An SDK-prepared request already carries the session header, which `before_provider_headers`
|
|
72
|
+
// handlers may have removed, so only other requests add it here.
|
|
73
|
+
const sessionHeaders = preparedRequestAuth
|
|
74
|
+
? undefined
|
|
75
|
+
: getOpenCodeSessionHeaders(requestModel, providerOptions.sessionId);
|
|
76
|
+
let headers = mergeHeaders(mergeHeaders(sessionHeaders, resolution.auth.headers), providerOptions.headers);
|
|
71
77
|
if (transformHeaders)
|
|
72
78
|
headers = await transformHeaders(headers ?? {});
|
|
73
79
|
options?.signal?.throwIfAborted();
|
|
@@ -88,7 +94,7 @@ export class ModelRuntimeStreaming {
|
|
|
88
94
|
env: Object.entries(env ?? {}).sort(([left], [right]) => left.localeCompare(right)),
|
|
89
95
|
baseUrl: resolution.auth.baseUrl ?? model.baseUrl,
|
|
90
96
|
}),
|
|
91
|
-
model:
|
|
97
|
+
model: requestModel,
|
|
92
98
|
options: {
|
|
93
99
|
...providerOptions,
|
|
94
100
|
apiKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime-streaming.js","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,eAAe,EAKf,UAAU,EAKV,WAAW,EAIX,gBAAgB,GAKhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,sCAAsC,EAAE,MAAM,mCAAmC,CAAC;AAG3F,MAAM,UAAU,YAAY,CAC3B,IAAiC,EACjC,QAAqC;IAErC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,YAAY,IAAI,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C;QACD,MAAM,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAgC,CAAC,CAAC;IAC3G,CAAC;CACD;AAED,MAAM,gBAAgB,GAAG,6DAA6D,CAAC;AACvF,MAAM,4BAA4B,GACjC,mNAAmN,CAAC;AAErN,SAAS,qBAAqB,CAAC,KAAkC;IAChE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,CAAC;YACrG,OAAO,IAAI,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAChH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEvent,\n\ttype AssistantMessageEventStream,\n\ttype AuthResult,\n\tassertChatModel,\n\ttype Context,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\tlazyStream,\n\ttype Model,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@bastani/pi-ai\";\nimport { normalizeModelProvider } from \"./azure-provider-compat.js\";\nimport { usesChatGptCodexTransport, withChatGptCodexTransportRouting } from \"./fast-model-routing.ts\";\nimport { installCodexFastRouteWebSocketIdentity } from \"./fast-model-routing-transport.ts\";\nimport type { ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport function mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** SDK-owned request-auth result so transport preparation does not start a second deadline. */\nexport interface PreparedRequestAuth {\n\treadonly resolution: AuthResult | undefined;\n\treadonly reprepare?: () => Promise<{ model: Model<Api>; options: ModelRuntimeSimpleStreamOptions }>;\n\treadonly streamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n}\n\nexport type ModelRuntimePreparedStreamOptions = StreamOptions &\n\tModelsRequestTransforms & {\n\t\tpreparedRequestAuth?: PreparedRequestAuth;\n\t};\n\nexport type ModelRuntimeSimpleStreamOptions = ModelsSimpleStreamOptions & {\n\tpreparedRequestAuth?: PreparedRequestAuth;\n};\n\ntype ResolveAuth = (model: Model<Api>, overrides?: ModelRuntimeAuthOverrides) => Promise<AuthResult | undefined>;\n/** Whether an extension owns this model's transport, in which case it owns its serialization too. */\ntype OwnsExtensionTransport = (model: Model<Api>) => boolean;\n\n/** Streaming request preparation split from ModelRuntime solely for Atomic's 500-line source gate. */\nexport class ModelRuntimeStreaming {\n\tprivate readonly models: MutableModels;\n\tprivate readonly resolveAuth: ResolveAuth;\n\tprivate readonly ownsExtensionTransport: OwnsExtensionTransport;\n\tprivate readonly transportModel: (model: Model<Api>) => Model<Api>;\n\tprivate readonly reloadCredentials: () => Promise<void>;\n\tconstructor(\n\t\tmodels: MutableModels,\n\t\tresolveAuth: ResolveAuth,\n\t\townsExtensionTransport: OwnsExtensionTransport,\n\t\ttransportModel: (model: Model<Api>) => Model<Api> = (model) => model,\n\t\treloadCredentials: () => Promise<void> = async () => {},\n\t) {\n\t\tthis.models = models;\n\t\tthis.resolveAuth = resolveAuth;\n\t\tthis.ownsExtensionTransport = ownsExtensionTransport;\n\t\tthis.transportModel = transportModel;\n\t\tthis.reloadCredentials = reloadCredentials;\n\t}\n\n\t/**\n\t * Attach the first-party ChatGPT Codex routing identity to a prepared request.\n\t *\n\t * This must happen *after* `prepareRequest`, not before it. The wrapper works by mutating the\n\t * header object it captures at construction, and `prepareRequest` rebuilds headers through\n\t * `mergeHeaders`, which copies — so a wrapper applied upstream is silently inert. The wrapper\n\t * decides from the final payload whether the request is priority, so a normal model still ends up\n\t * with `originator: pi` and no routing hint.\n\t */\n\tprivate withCodexRouting<TOptions extends StreamOptions>(model: Model<Api>, options: TOptions): TOptions {\n\t\tmodel = this.transportModel(model);\n\t\tif (!usesChatGptCodexTransport(model) || this.ownsExtensionTransport(model)) return options;\n\t\t// The WebSocket handshake builds its headers inside pi-ai and the constructor can be cached, so\n\t\t// the identity is repaired through the global constructor rather than per-request options. CLI\n\t\t// entrypoints install this through the HTTP dispatcher; a pure SDK embedder never does.\n\t\tif (options.transport !== \"sse\") installCodexFastRouteWebSocketIdentity();\n\t\treturn withChatGptCodexTransportRouting(model, options);\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: ModelRuntimePreparedStreamOptions | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions; authIdentity: string }> {\n\t\tassertChatModel(model);\n\t\tmodel = normalizeModelProvider(model);\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst { transformHeaders, preparedRequestAuth, ...providerOptions } = options ?? {};\n\t\tconst resolution = preparedRequestAuth\n\t\t\t? preparedRequestAuth.resolution\n\t\t\t: await this.resolveAuth(model, {\n\t\t\t\t\tapiKey: options?.apiKey,\n\t\t\t\t\tenv: options?.env,\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst apiKey = providerOptions.apiKey ?? resolution.auth.apiKey;\n\t\tconst credentialHeaderNames = new Set(\n\t\t\tObject.keys(resolution.auth.headers ?? {}).map((name) => name.toLowerCase()),\n\t\t);\n\t\treturn {\n\t\t\tprovider,\n\t\t\tauthIdentity: JSON.stringify({\n\t\t\t\tapiKey,\n\t\t\t\theaders: Object.entries(headers ?? {})\n\t\t\t\t\t.map(([name, value]) => [name.toLowerCase(), value] as const)\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t([name]) =>\n\t\t\t\t\t\t\tcredentialHeaderNames.has(name) ||\n\t\t\t\t\t\t\t/^(?:authorization|proxy-authorization|x-api-key|api-key|cookie)$/.test(name),\n\t\t\t\t\t)\n\t\t\t\t\t.sort(([left], [right]) => left.localeCompare(right)),\n\t\t\t\tenv: Object.entries(env ?? {}).sort(([left], [right]) => left.localeCompare(right)),\n\t\t\t\tbaseUrl: resolution.auth.baseUrl ?? model.baseUrl,\n\t\t\t}),\n\t\t\tmodel: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\treturn this.streamWithCredentialRetry(model, options, (prepared) =>\n\t\t\tprepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\ttranscript,\n\t\t\t\tthis.withCodexRouting(prepared.model, prepared.options) as ApiStreamOptions<TApi>,\n\t\t\t),\n\t\t);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tconst dispatch = options?.preparedRequestAuth?.streamSimple;\n\t\treturn this.streamWithCredentialRetry(model, options, (prepared) =>\n\t\t\tdispatch\n\t\t\t\t? dispatch(prepared.model, context, prepared.options as SimpleStreamOptions)\n\t\t\t\t: prepared.provider.streamSimple(\n\t\t\t\t\t\tprepared.model,\n\t\t\t\t\t\ttranscript,\n\t\t\t\t\t\tthis.withCodexRouting(prepared.model, prepared.options) as SimpleStreamOptions,\n\t\t\t\t\t),\n\t\t);\n\t}\n\n\tcompleteSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tprivate streamWithCredentialRetry(\n\t\tmodel: Model<Api>,\n\t\toptions: ModelRuntimePreparedStreamOptions | undefined,\n\t\tinvoke: (prepared: Awaited<ReturnType<ModelRuntimeStreaming[\"prepareRequest\"]>>) => AssistantMessageEventStream,\n\t): AssistantMessageEventStream {\n\t\tconst prepare = () => this.prepareRequest(model, options);\n\t\tconst reprepareCredentials = async (previous: Awaited<ReturnType<typeof prepare>>) => {\n\t\t\tif (options?.signal?.aborted) return undefined;\n\t\t\tawait this.reloadCredentials();\n\t\t\tconst { preparedRequestAuth: previousAuth, ...callerOptions } = options ?? {};\n\t\t\tconst reprepared = previousAuth?.reprepare ? await previousAuth.reprepare() : undefined;\n\t\t\tconst next = reprepared\n\t\t\t\t? await this.prepareRequest(reprepared.model, {\n\t\t\t\t\t\t...callerOptions,\n\t\t\t\t\t\tapiKey: reprepared.options.apiKey,\n\t\t\t\t\t\theaders: reprepared.options.headers,\n\t\t\t\t\t\tenv: reprepared.options.env,\n\t\t\t\t\t\tpreparedRequestAuth: reprepared.options.preparedRequestAuth,\n\t\t\t\t\t})\n\t\t\t\t: await this.prepareRequest(model, callerOptions);\n\t\t\treturn next.authIdentity !== previous.authIdentity ? next : undefined;\n\t\t};\n\t\tconst retry = (previous: Awaited<ReturnType<typeof prepare>>) =>\n\t\t\treprepareCredentials(previous).catch(() => undefined);\n\t\tconst iterate = async function* (): AsyncGenerator<AssistantMessageEvent> {\n\t\t\tlet prepared = await prepare();\n\t\t\tfor (let attempt = 0; attempt < 2; attempt++) {\n\t\t\t\tconst pending: AssistantMessageEvent[] = [];\n\t\t\t\tlet deliveredContent = false;\n\t\t\t\tlet rejection: AssistantMessageEvent | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst source = invoke(prepared);\n\t\t\t\t\tlet terminal = false;\n\t\t\t\t\tfor await (const event of source) {\n\t\t\t\t\t\tif (event.type === \"start\") {\n\t\t\t\t\t\t\tpending.push(event);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.type === \"error\" &&\n\t\t\t\t\t\t\t!deliveredContent &&\n\t\t\t\t\t\t\tattempt === 0 &&\n\t\t\t\t\t\t\tisCredentialRejection(event.error.errorMessage)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\trejection = event;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield* pending.splice(0);\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t\tterminal = event.type === \"done\" || event.type === \"error\";\n\t\t\t\t\t\tdeliveredContent = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!rejection && !terminal) {\n\t\t\t\t\t\tconst result = await source.result();\n\t\t\t\t\t\tconst event: AssistantMessageEvent =\n\t\t\t\t\t\t\tresult.stopReason === \"error\" || result.stopReason === \"aborted\"\n\t\t\t\t\t\t\t\t? { type: \"error\", reason: result.stopReason, error: result }\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\ttype: \"done\",\n\t\t\t\t\t\t\t\t\t\treason: result.stopReason === \"pending\" ? \"stop\" : result.stopReason,\n\t\t\t\t\t\t\t\t\t\tmessage: result,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!deliveredContent &&\n\t\t\t\t\t\t\tattempt === 0 &&\n\t\t\t\t\t\t\tresult.stopReason === \"error\" &&\n\t\t\t\t\t\t\tisCredentialRejection(result.errorMessage)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\trejection = event;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tyield* pending;\n\t\t\t\t\t\t\tyield event;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tdeliveredContent ||\n\t\t\t\t\t\tattempt !== 0 ||\n\t\t\t\t\t\t!isCredentialRejection(error instanceof Error ? error : String(error))\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\tconst next = await retry(prepared);\n\t\t\t\t\tif (!next) throw error;\n\t\t\t\t\tprepared = next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!rejection) return;\n\t\t\t\tconst next = await retry(prepared);\n\t\t\t\tif (!next) {\n\t\t\t\t\tyield* pending;\n\t\t\t\t\tyield rejection;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tprepared = next;\n\t\t\t}\n\t\t};\n\t\treturn lazyStream(model, async () => iterate());\n\t}\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t}).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n}\n\nconst HTTP_401_PATTERN = /^\\W*401\\b|\\b(?:http|status|code|error)\\W{0,3}401\\b|\\(401\\)/i;\nconst CREDENTIAL_REJECTION_PATTERN =\n\t/unauthori[sz]ed|invalid(?:ated)?[_\\s-]*(?:api[_\\s-]*key|(?:access[_\\s-]*|auth[_\\s-]*|oauth[_\\s-]*)?token)|(?:token|api[_\\s-]*key)[_\\s-]*(?:(?:is|has[_\\s-]*been)[_\\s-]*)?(?:invalid|revoked|expired|invalidated)/i;\n\nfunction isCredentialRejection(error: object | string | undefined): boolean {\n\tif (error instanceof Error) {\n\t\tif ((\"status\" in error && error.status === 401) || (\"statusCode\" in error && error.statusCode === 401))\n\t\t\treturn true;\n\t\terror = error.message;\n\t}\n\treturn typeof error === \"string\" && (HTTP_401_PATTERN.test(error) || CREDENTIAL_REJECTION_PATTERN.test(error));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-runtime-streaming.js","sourceRoot":"","sources":["../../src/core/model-runtime-streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,eAAe,EAKf,yBAAyB,EACzB,UAAU,EAKV,WAAW,EAIX,gBAAgB,GAKhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,sCAAsC,EAAE,MAAM,mCAAmC,CAAC;AAG3F,MAAM,UAAU,YAAY,CAC3B,IAAiC,EACjC,QAAqC;IAErC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC;QAC3E,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AA0BD,sGAAsG;AACtG,MAAM,OAAO,qBAAqB;IAChB,MAAM,CAAgB;IACtB,WAAW,CAAc;IACzB,sBAAsB,CAAyB;IA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AC3G,CAAC;CACD;AAED,MAAM,gBAAgB,GAAG,6DAA6D,CAAC;AACvF,MAAM,4BAA4B,GACjC,mNAAmN,CAAC;AAErN,SAAS,qBAAqB,CAAC,KAAkC;IAChE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,CAAC;YACrG,OAAO,IAAI,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAChH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEvent,\n\ttype AssistantMessageEventStream,\n\ttype AuthResult,\n\tassertChatModel,\n\ttype Context,\n\ttype DeferredCancelOptions,\n\ttype DeferredFetchOptions,\n\ttype DeferredHandle,\n\tgetOpenCodeSessionHeaders,\n\tlazyStream,\n\ttype Model,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\tModelsError,\n\ttype ModelsRequestTransforms,\n\ttype ModelsSimpleStreamOptions,\n\ttype MutableModels,\n\tnormalizeContext,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@bastani/pi-ai\";\nimport { normalizeModelProvider } from \"./azure-provider-compat.js\";\nimport { usesChatGptCodexTransport, withChatGptCodexTransportRouting } from \"./fast-model-routing.ts\";\nimport { installCodexFastRouteWebSocketIdentity } from \"./fast-model-routing-transport.ts\";\nimport type { ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport function mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** SDK-owned request-auth result so transport preparation does not start a second deadline. */\nexport interface PreparedRequestAuth {\n\treadonly resolution: AuthResult | undefined;\n\treadonly reprepare?: () => Promise<{ model: Model<Api>; options: ModelRuntimeSimpleStreamOptions }>;\n\treadonly streamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n}\n\nexport type ModelRuntimePreparedStreamOptions = StreamOptions &\n\tModelsRequestTransforms & {\n\t\tpreparedRequestAuth?: PreparedRequestAuth;\n\t};\n\nexport type ModelRuntimeSimpleStreamOptions = ModelsSimpleStreamOptions & {\n\tpreparedRequestAuth?: PreparedRequestAuth;\n};\n\ntype ResolveAuth = (model: Model<Api>, overrides?: ModelRuntimeAuthOverrides) => Promise<AuthResult | undefined>;\n/** Whether an extension owns this model's transport, in which case it owns its serialization too. */\ntype OwnsExtensionTransport = (model: Model<Api>) => boolean;\n\n/** Streaming request preparation split from ModelRuntime solely for Atomic's 500-line source gate. */\nexport class ModelRuntimeStreaming {\n\tprivate readonly models: MutableModels;\n\tprivate readonly resolveAuth: ResolveAuth;\n\tprivate readonly ownsExtensionTransport: OwnsExtensionTransport;\n\tprivate readonly transportModel: (model: Model<Api>) => Model<Api>;\n\tprivate readonly reloadCredentials: () => Promise<void>;\n\tconstructor(\n\t\tmodels: MutableModels,\n\t\tresolveAuth: ResolveAuth,\n\t\townsExtensionTransport: OwnsExtensionTransport,\n\t\ttransportModel: (model: Model<Api>) => Model<Api> = (model) => model,\n\t\treloadCredentials: () => Promise<void> = async () => {},\n\t) {\n\t\tthis.models = models;\n\t\tthis.resolveAuth = resolveAuth;\n\t\tthis.ownsExtensionTransport = ownsExtensionTransport;\n\t\tthis.transportModel = transportModel;\n\t\tthis.reloadCredentials = reloadCredentials;\n\t}\n\n\t/**\n\t * Attach the first-party ChatGPT Codex routing identity to a prepared request.\n\t *\n\t * This must happen *after* `prepareRequest`, not before it. The wrapper works by mutating the\n\t * header object it captures at construction, and `prepareRequest` rebuilds headers through\n\t * `mergeHeaders`, which copies — so a wrapper applied upstream is silently inert. The wrapper\n\t * decides from the final payload whether the request is priority, so a normal model still ends up\n\t * with `originator: pi` and no routing hint.\n\t */\n\tprivate withCodexRouting<TOptions extends StreamOptions>(model: Model<Api>, options: TOptions): TOptions {\n\t\tmodel = this.transportModel(model);\n\t\tif (!usesChatGptCodexTransport(model) || this.ownsExtensionTransport(model)) return options;\n\t\t// The WebSocket handshake builds its headers inside pi-ai and the constructor can be cached, so\n\t\t// the identity is repaired through the global constructor rather than per-request options. CLI\n\t\t// entrypoints install this through the HTTP dispatcher; a pure SDK embedder never does.\n\t\tif (options.transport !== \"sse\") installCodexFastRouteWebSocketIdentity();\n\t\treturn withChatGptCodexTransportRouting(model, options);\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: ModelRuntimePreparedStreamOptions | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions; authIdentity: string }> {\n\t\tassertChatModel(model);\n\t\tmodel = normalizeModelProvider(model);\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst { transformHeaders, preparedRequestAuth, ...providerOptions } = options ?? {};\n\t\tconst resolution = preparedRequestAuth\n\t\t\t? preparedRequestAuth.resolution\n\t\t\t: await this.resolveAuth(model, {\n\t\t\t\t\tapiKey: options?.apiKey,\n\t\t\t\t\tenv: options?.env,\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t});\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst requestModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;\n\t\t// An SDK-prepared request already carries the session header, which `before_provider_headers`\n\t\t// handlers may have removed, so only other requests add it here.\n\t\tconst sessionHeaders = preparedRequestAuth\n\t\t\t? undefined\n\t\t\t: getOpenCodeSessionHeaders(requestModel, providerOptions.sessionId);\n\t\tlet headers = mergeHeaders(mergeHeaders(sessionHeaders, resolution.auth.headers), providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\tconst apiKey = providerOptions.apiKey ?? resolution.auth.apiKey;\n\t\tconst credentialHeaderNames = new Set(\n\t\t\tObject.keys(resolution.auth.headers ?? {}).map((name) => name.toLowerCase()),\n\t\t);\n\t\treturn {\n\t\t\tprovider,\n\t\t\tauthIdentity: JSON.stringify({\n\t\t\t\tapiKey,\n\t\t\t\theaders: Object.entries(headers ?? {})\n\t\t\t\t\t.map(([name, value]) => [name.toLowerCase(), value] as const)\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t([name]) =>\n\t\t\t\t\t\t\tcredentialHeaderNames.has(name) ||\n\t\t\t\t\t\t\t/^(?:authorization|proxy-authorization|x-api-key|api-key|cookie)$/.test(name),\n\t\t\t\t\t)\n\t\t\t\t\t.sort(([left], [right]) => left.localeCompare(right)),\n\t\t\t\tenv: Object.entries(env ?? {}).sort(([left], [right]) => left.localeCompare(right)),\n\t\t\t\tbaseUrl: resolution.auth.baseUrl ?? model.baseUrl,\n\t\t\t}),\n\t\t\tmodel: requestModel,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\treturn this.streamWithCredentialRetry(model, options, (prepared) =>\n\t\t\tprepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\ttranscript,\n\t\t\t\tthis.withCodexRouting(prepared.model, prepared.options) as ApiStreamOptions<TApi>,\n\t\t\t),\n\t\t);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): AssistantMessageEventStream {\n\t\tconst transcript = normalizeContext(context);\n\t\tconst dispatch = options?.preparedRequestAuth?.streamSimple;\n\t\treturn this.streamWithCredentialRetry(model, options, (prepared) =>\n\t\t\tdispatch\n\t\t\t\t? dispatch(prepared.model, context, prepared.options as SimpleStreamOptions)\n\t\t\t\t: prepared.provider.streamSimple(\n\t\t\t\t\t\tprepared.model,\n\t\t\t\t\t\ttranscript,\n\t\t\t\t\t\tthis.withCodexRouting(prepared.model, prepared.options) as SimpleStreamOptions,\n\t\t\t\t\t),\n\t\t);\n\t}\n\n\tcompleteSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelRuntimeSimpleStreamOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tprivate streamWithCredentialRetry(\n\t\tmodel: Model<Api>,\n\t\toptions: ModelRuntimePreparedStreamOptions | undefined,\n\t\tinvoke: (prepared: Awaited<ReturnType<ModelRuntimeStreaming[\"prepareRequest\"]>>) => AssistantMessageEventStream,\n\t): AssistantMessageEventStream {\n\t\tconst prepare = () => this.prepareRequest(model, options);\n\t\tconst reprepareCredentials = async (previous: Awaited<ReturnType<typeof prepare>>) => {\n\t\t\tif (options?.signal?.aborted) return undefined;\n\t\t\tawait this.reloadCredentials();\n\t\t\tconst { preparedRequestAuth: previousAuth, ...callerOptions } = options ?? {};\n\t\t\tconst reprepared = previousAuth?.reprepare ? await previousAuth.reprepare() : undefined;\n\t\t\tconst next = reprepared\n\t\t\t\t? await this.prepareRequest(reprepared.model, {\n\t\t\t\t\t\t...callerOptions,\n\t\t\t\t\t\tapiKey: reprepared.options.apiKey,\n\t\t\t\t\t\theaders: reprepared.options.headers,\n\t\t\t\t\t\tenv: reprepared.options.env,\n\t\t\t\t\t\tpreparedRequestAuth: reprepared.options.preparedRequestAuth,\n\t\t\t\t\t})\n\t\t\t\t: await this.prepareRequest(model, callerOptions);\n\t\t\treturn next.authIdentity !== previous.authIdentity ? next : undefined;\n\t\t};\n\t\tconst retry = (previous: Awaited<ReturnType<typeof prepare>>) =>\n\t\t\treprepareCredentials(previous).catch(() => undefined);\n\t\tconst iterate = async function* (): AsyncGenerator<AssistantMessageEvent> {\n\t\t\tlet prepared = await prepare();\n\t\t\tfor (let attempt = 0; attempt < 2; attempt++) {\n\t\t\t\tconst pending: AssistantMessageEvent[] = [];\n\t\t\t\tlet deliveredContent = false;\n\t\t\t\tlet rejection: AssistantMessageEvent | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst source = invoke(prepared);\n\t\t\t\t\tlet terminal = false;\n\t\t\t\t\tfor await (const event of source) {\n\t\t\t\t\t\tif (event.type === \"start\") {\n\t\t\t\t\t\t\tpending.push(event);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.type === \"error\" &&\n\t\t\t\t\t\t\t!deliveredContent &&\n\t\t\t\t\t\t\tattempt === 0 &&\n\t\t\t\t\t\t\tisCredentialRejection(event.error.errorMessage)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\trejection = event;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield* pending.splice(0);\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t\tterminal = event.type === \"done\" || event.type === \"error\";\n\t\t\t\t\t\tdeliveredContent = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!rejection && !terminal) {\n\t\t\t\t\t\tconst result = await source.result();\n\t\t\t\t\t\tconst event: AssistantMessageEvent =\n\t\t\t\t\t\t\tresult.stopReason === \"error\" || result.stopReason === \"aborted\"\n\t\t\t\t\t\t\t\t? { type: \"error\", reason: result.stopReason, error: result }\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\ttype: \"done\",\n\t\t\t\t\t\t\t\t\t\treason: result.stopReason === \"pending\" ? \"stop\" : result.stopReason,\n\t\t\t\t\t\t\t\t\t\tmessage: result,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!deliveredContent &&\n\t\t\t\t\t\t\tattempt === 0 &&\n\t\t\t\t\t\t\tresult.stopReason === \"error\" &&\n\t\t\t\t\t\t\tisCredentialRejection(result.errorMessage)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\trejection = event;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tyield* pending;\n\t\t\t\t\t\t\tyield event;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tdeliveredContent ||\n\t\t\t\t\t\tattempt !== 0 ||\n\t\t\t\t\t\t!isCredentialRejection(error instanceof Error ? error : String(error))\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\tconst next = await retry(prepared);\n\t\t\t\t\tif (!next) throw error;\n\t\t\t\t\tprepared = next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!rejection) return;\n\t\t\t\tconst next = await retry(prepared);\n\t\t\t\tif (!next) {\n\t\t\t\t\tyield* pending;\n\t\t\t\t\tyield rejection;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tprepared = next;\n\t\t\t}\n\t\t};\n\t\treturn lazyStream(model, async () => iterate());\n\t}\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\tif (!prepared.provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\treturn prepared.provider.fetchDeferred(prepared.model, handle, prepared.options as DeferredFetchOptions);\n\t\t}).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tconst prepared = await this.prepareRequest(model, options);\n\t\tif (!prepared.provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tawait prepared.provider.cancelDeferred(prepared.model, handle, prepared.options as DeferredCancelOptions);\n\t}\n}\n\nconst HTTP_401_PATTERN = /^\\W*401\\b|\\b(?:http|status|code|error)\\W{0,3}401\\b|\\(401\\)/i;\nconst CREDENTIAL_REJECTION_PATTERN =\n\t/unauthori[sz]ed|invalid(?:ated)?[_\\s-]*(?:api[_\\s-]*key|(?:access[_\\s-]*|auth[_\\s-]*|oauth[_\\s-]*)?token)|(?:token|api[_\\s-]*key)[_\\s-]*(?:(?:is|has[_\\s-]*been)[_\\s-]*)?(?:invalid|revoked|expired|invalidated)/i;\n\nfunction isCredentialRejection(error: object | string | undefined): boolean {\n\tif (error instanceof Error) {\n\t\tif ((\"status\" in error && error.status === 401) || (\"statusCode\" in error && error.statusCode === 401))\n\t\t\treturn true;\n\t\terror = error.message;\n\t}\n\treturn typeof error === \"string\" && (HTTP_401_PATTERN.test(error) || CREDENTIAL_REJECTION_PATTERN.test(error));\n}\n"]}
|
|
@@ -119,6 +119,11 @@ export declare class ModelRuntime implements Models {
|
|
|
119
119
|
getRegisteredProviderIds(): readonly string[];
|
|
120
120
|
getRegisteredNativeProvider(providerId: string): Provider | undefined;
|
|
121
121
|
getOAuthProviderMetadata(): import("./oauth-login.ts").OAuthProviderMetadata[];
|
|
122
|
+
/** Providers that offer API-key login in `/login`. */
|
|
123
|
+
getApiKeyLoginProviderMetadata(): Array<{
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
}>;
|
|
122
127
|
/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */
|
|
123
128
|
getCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig;
|
|
124
129
|
isUsingOAuth(providerId: string): boolean;
|