@code-yeongyu/senpi 2026.8.23 → 2026.8.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +6 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -14
- package/dist/config.js.map +1 -1
- package/dist/core/agent-abort-provenance.d.ts +5 -5
- package/dist/core/agent-abort-provenance.d.ts.map +1 -1
- package/dist/core/agent-abort-provenance.js +8 -1
- package/dist/core/agent-abort-provenance.js.map +1 -1
- package/dist/core/agent-session.d.ts +14 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +129 -29
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +35 -8
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/brand.d.ts +2 -0
- package/dist/core/brand.d.ts.map +1 -1
- package/dist/core/brand.js +1 -0
- package/dist/core/brand.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +1 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +24 -8
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/extensions/builtin/goal/agent-end-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/agent-end-continuation.js +10 -0
- package/dist/core/extensions/builtin/goal/agent-end-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +0 -8
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation-types.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/monitor-continuation-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation-types.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +2 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +31 -3
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/terminal-provider-error.js +1 -1
- package/dist/core/extensions/builtin/goal/terminal-provider-error.js.map +1 -1
- package/dist/core/extensions/builtin/goal/wait-ticker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/wait-ticker.js +14 -9
- package/dist/core/extensions/builtin/goal/wait-ticker.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/notice.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/notice.js +5 -1
- package/dist/core/extensions/builtin/loop-guard/notice.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts +2 -2
- package/dist/core/extensions/builtin/ttsr/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/index.js +6 -6
- package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/message-update.d.ts +10 -0
- package/dist/core/extensions/builtin/ttsr/message-update.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ttsr/message-update.js +38 -0
- package/dist/core/extensions/builtin/ttsr/message-update.js.map +1 -0
- package/dist/core/extensions/builtin/ttsr/remediation.d.ts +5 -10
- package/dist/core/extensions/builtin/ttsr/remediation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/remediation.js +19 -3
- package/dist/core/extensions/builtin/ttsr/remediation.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/stream-remediation.d.ts +1 -1
- package/dist/core/extensions/builtin/ttsr/stream-remediation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/stream-remediation.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/types.d.ts +1 -1
- package/dist/core/extensions/builtin/ttsr/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/types.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/watch.d.ts +1 -1
- package/dist/core/extensions/builtin/ttsr/watch.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/watch.js +2 -2
- package/dist/core/extensions/builtin/ttsr/watch.js.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.d.ts.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.js +5 -23
- package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.js.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/response-body.d.ts +11 -0
- package/dist/core/extensions/builtin/webfetch/webfetch/response-body.d.ts.map +1 -0
- package/dist/core/extensions/builtin/webfetch/webfetch/response-body.js +54 -0
- package/dist/core/extensions/builtin/webfetch/webfetch/response-body.js.map +1 -0
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +107 -45
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +17 -6
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -19
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +26 -5
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config-schema.d.ts +17 -5
- package/dist/core/model-config-schema.d.ts.map +1 -1
- package/dist/core/model-config-schema.js +1 -1
- package/dist/core/model-config-schema.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +7 -5
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +3 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +3 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +0 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +0 -18
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +14 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -0
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +3 -6
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +0 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/provider-timeout-retry.d.ts.map +1 -1
- package/dist/core/provider-timeout-retry.js +8 -12
- package/dist/core/provider-timeout-retry.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/retry-fallback/profile-override.d.ts +24 -0
- package/dist/core/retry-fallback/profile-override.d.ts.map +1 -0
- package/dist/core/retry-fallback/profile-override.js +138 -0
- package/dist/core/retry-fallback/profile-override.js.map +1 -0
- package/dist/core/retry-fallback/settings.d.ts +1 -0
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +20 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +4 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +32 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +18 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +88 -7
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +14 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +35 -19
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +3 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +13 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +5 -0
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +6 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +3 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +27 -6
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -2
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/app-server/daemon/probe.js +1 -1
- package/dist/modes/app-server/daemon/probe.js.map +1 -1
- package/dist/modes/app-server/daemon.js +13 -2
- package/dist/modes/app-server/daemon.js.map +1 -1
- package/dist/modes/app-server/transports/websocket-connection-handler.d.ts.map +1 -1
- package/dist/modes/app-server/transports/websocket-connection-handler.js +4 -0
- package/dist/modes/app-server/transports/websocket-connection-handler.js.map +1 -1
- package/dist/modes/interactive/aborted-error-label.d.ts +4 -1
- package/dist/modes/interactive/aborted-error-label.d.ts.map +1 -1
- package/dist/modes/interactive/aborted-error-label.js +27 -5
- package/dist/modes/interactive/aborted-error-label.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +68 -17
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +28 -13
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/streaming-reveal.d.ts +8 -0
- package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -1
- package/dist/modes/interactive/streaming-reveal.js +12 -0
- package/dist/modes/interactive/streaming-reveal.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +3 -0
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +7 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +186 -2
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +60 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/docs/AGENTS.md +3 -1
- package/docs/compaction.md +0 -2
- package/docs/custom-provider.md +6 -6
- package/docs/environment-variables.md +8 -8
- package/docs/extensions.md +6 -5
- package/docs/json.md +7 -2
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +2 -2
- package/docs/rpc.md +32 -3
- package/docs/sdk.md +7 -2
- package/docs/settings.md +9 -1
- package/docs/terminal-setup.md +11 -9
- package/docs/usage.md +4 -1
- package/docs/windows.md +24 -2
- package/examples/AGENTS.md +21 -6
- package/examples/extensions/AGENTS.md +50 -0
- package/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +90 -88
- package/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +40 -40
- package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +20 -21
- package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +24 -25
- package/node_modules/@anthropic-ai/claude-agent-sdk/package.json +2 -2
- package/node_modules/@anthropic-ai/claude-agent-sdk/sdk-tools.d.ts +102 -5
- package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.d.ts +31 -15
- package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +80 -78
- package/node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +13 -13
- package/node_modules/@aws-sdk/core/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +12 -12
- package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +6 -6
- package/node_modules/@aws-sdk/eventstream-handler-node/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-websocket/package.json +6 -6
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
- package/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +26 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +5 -5
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager-proxy.ts +39 -5
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/AGENTS.md +40 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/AGENTS.md +40 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-notification.ts +3 -8
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-notification-queue.ts +2 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +7 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +2 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +7 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts +4 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +8 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +6 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +1 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +25 -13
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +91 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +93 -54
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +2 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js +97 -46
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -14
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.d.ts +50 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.js +129 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +16 -3
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js +10 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/backoff.d.ts +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/backoff.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/backoff.js +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/backoff.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/classifiers.d.ts +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/classifiers.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/classifiers.js +109 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/classifiers.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/failure.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/failure.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/failure.js +109 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/failure.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/index.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/index.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/planner.d.ts +46 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/planner.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/planner.js +41 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/planner.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js +93 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/types.d.ts +121 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/types.js +11 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/types.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +25 -5
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +22 -18
- package/node_modules/@earendil-works/pi-pty/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session-bun.d.ts +30 -0
- package/node_modules/@earendil-works/pi-pty/dist/session-bun.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/session-bun.js +76 -0
- package/node_modules/@earendil-works/pi-pty/dist/session-bun.js.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/session-types.d.ts +3 -1
- package/node_modules/@earendil-works/pi-pty/dist/session-types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session-types.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session.d.ts +2 -0
- package/node_modules/@earendil-works/pi-pty/dist/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session.js +19 -9
- package/node_modules/@earendil-works/pi-pty/dist/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +3 -3
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +9 -4
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +8 -2
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +24 -4
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +2 -2
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +2 -2
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +2 -8
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-module-path.d.ts +7 -0
- package/node_modules/@earendil-works/pi-tui/dist/native-module-path.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/native-module-path.js +19 -0
- package/node_modules/@earendil-works/pi-tui/dist/native-module-path.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +11 -14
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +5 -5
- package/node_modules/@smithy/signature-v4/dist-cjs/index.js +19 -7
- package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +4 -1
- package/node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js +4 -1
- package/node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js +4 -1
- package/node_modules/@smithy/signature-v4/dist-es/headerUtil.js +10 -3
- package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +4 -1
- package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +4 -1
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/package.json +110 -108
- package/dist/core/radius.d.ts +0 -2
- package/dist/core/radius.d.ts.map +0 -1
- package/dist/core/radius.js +0 -2
- package/dist/core/radius.js.map +0 -1
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +0 -201
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +0 -62
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +0 -154
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +0 -16
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +0 -80
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +0 -11
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +0 -10
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +0 -4
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/constants.d.ts +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromEnvSigningName.d.ts +0 -18
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromSso.d.ts +0 -12
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromStatic.d.ts +0 -9
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/getNewSsoOidcToken.d.ts +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/getSsoOidcClient.d.ts +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/index.d.ts +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/nodeProvider.d.ts +0 -18
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/constants.d.ts +0 -3
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromEnvSigningName.d.ts +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromSso.d.ts +0 -10
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromStatic.d.ts +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/getNewSsoOidcToken.d.ts +0 -9
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/getSsoOidcClient.d.ts +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/index.d.ts +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/nodeProvider.d.ts +0 -3
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/validateTokenExpiry.d.ts +0 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/validateTokenKey.d.ts +0 -1
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/writeSSOTokenToFile.d.ts +0 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/validateTokenExpiry.d.ts +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/validateTokenKey.d.ts +0 -4
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/writeSSOTokenToFile.d.ts +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +0 -69
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RetryFailure } from "./types.ts";
|
|
2
|
+
export interface RetryFailureContext {
|
|
3
|
+
/** Raw response/error body text captured at the catch boundary, when held. */
|
|
4
|
+
readonly bodyText?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a raw anthropic-messages failure into whitelisted
|
|
8
|
+
* {@link RetryFailure} facts. Raw headers, bodies, and credentials are never
|
|
9
|
+
* retained: only the eight declared fields, each derived from parsed facts.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeAnthropicRetryFailure(error: unknown, context?: RetryFailureContext): RetryFailure;
|
|
12
|
+
//# sourceMappingURL=failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/failure.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAEjE,MAAM,WAAW,mBAAmB;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AA0ED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAyC1G"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { extract429RetryAfterMs } from "../retry-hint.js";
|
|
2
|
+
const MAX_MESSAGE_CHARS = 500;
|
|
3
|
+
const QUOTA_WORDING_PATTERN = /exceeded_current_quota_error|insufficient\s+balance|credits?_required|quota|billing/i;
|
|
4
|
+
const IMAGE_FORMAT_PATTERN = /unsupported image format|unsupported media type for base64 image|invalid data url for image/i;
|
|
5
|
+
/**
|
|
6
|
+
* Anthropic SDK connection-error classes are matched by constructor name
|
|
7
|
+
* rather than `instanceof`: a static import of the SDK error classes would
|
|
8
|
+
* break every test that `vi.mock`s `@anthropic-ai/sdk` without re-exporting
|
|
9
|
+
* them, and the SDK never sets `error.name`. `APIConnectionTimeoutError`
|
|
10
|
+
* extends `APIConnectionError`, so callers must check the timeout name first.
|
|
11
|
+
*/
|
|
12
|
+
function sdkErrorClassName(error) {
|
|
13
|
+
if (!(error instanceof Error))
|
|
14
|
+
return undefined;
|
|
15
|
+
const name = error.constructor?.name;
|
|
16
|
+
return typeof name === "string" && name.length > 0 ? name : undefined;
|
|
17
|
+
}
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function toShaped(error) {
|
|
22
|
+
return error instanceof Error ? error : undefined;
|
|
23
|
+
}
|
|
24
|
+
function numericStatus(shaped) {
|
|
25
|
+
const status = shaped?.status;
|
|
26
|
+
return typeof status === "number" && Number.isFinite(status) ? status : undefined;
|
|
27
|
+
}
|
|
28
|
+
function headerObject(shaped) {
|
|
29
|
+
return shaped?.headers instanceof Headers ? shaped.headers : undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Nested `error.type` / `error.code` strings from a parsed provider body, in order. */
|
|
32
|
+
function nestedProviderCodes(body) {
|
|
33
|
+
if (!isRecord(body))
|
|
34
|
+
return undefined;
|
|
35
|
+
const inner = body.error;
|
|
36
|
+
if (!isRecord(inner))
|
|
37
|
+
return undefined;
|
|
38
|
+
const codes = [];
|
|
39
|
+
for (const key of ["type", "code"]) {
|
|
40
|
+
const value = inner[key];
|
|
41
|
+
if (typeof value === "string" && value.length > 0)
|
|
42
|
+
codes.push(value);
|
|
43
|
+
}
|
|
44
|
+
return codes.length > 0 ? codes : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Parse the leading JSON object of an SSE error payload, ignoring trailing markers. */
|
|
47
|
+
function parseLeadingJson(text) {
|
|
48
|
+
const candidate = text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1);
|
|
49
|
+
if (!candidate.startsWith("{") || !candidate.endsWith("}"))
|
|
50
|
+
return undefined;
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(candidate);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function quotaWording(shaped, bodyText) {
|
|
59
|
+
const candidates = [shaped?.message, bodyText];
|
|
60
|
+
return candidates.some((text) => typeof text === "string" && QUOTA_WORDING_PATTERN.test(text));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Normalize a raw anthropic-messages failure into whitelisted
|
|
64
|
+
* {@link RetryFailure} facts. Raw headers, bodies, and credentials are never
|
|
65
|
+
* retained: only the eight declared fields, each derived from parsed facts.
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeAnthropicRetryFailure(error, context) {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
const shaped = toShaped(error);
|
|
70
|
+
const status = numericStatus(shaped);
|
|
71
|
+
const headers = headerObject(shaped);
|
|
72
|
+
const bodyText = context?.bodyText ?? message;
|
|
73
|
+
let kind;
|
|
74
|
+
let providerCodes;
|
|
75
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
76
|
+
kind = "abort";
|
|
77
|
+
}
|
|
78
|
+
else if (sdkErrorClassName(error) === "APIConnectionTimeoutError") {
|
|
79
|
+
kind = "timeout";
|
|
80
|
+
}
|
|
81
|
+
else if (sdkErrorClassName(error) === "APIConnectionError") {
|
|
82
|
+
kind = "connection";
|
|
83
|
+
}
|
|
84
|
+
else if (typeof message === "string" && IMAGE_FORMAT_PATTERN.test(message)) {
|
|
85
|
+
kind = "image-format";
|
|
86
|
+
}
|
|
87
|
+
else if (status !== undefined) {
|
|
88
|
+
kind = status === 429 && quotaWording(shaped, bodyText) ? "quota-exhausted" : "http-status";
|
|
89
|
+
providerCodes = nestedProviderCodes(shaped?.error);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const parsed = parseLeadingJson(bodyText);
|
|
93
|
+
providerCodes = nestedProviderCodes(parsed);
|
|
94
|
+
kind = providerCodes !== undefined ? "provider" : "unknown";
|
|
95
|
+
}
|
|
96
|
+
const retryAfterMs = extract429RetryAfterMs({ status, headers, bodyText });
|
|
97
|
+
const shouldRetryHeader = headers?.get("x-should-retry");
|
|
98
|
+
const shouldRetry = shouldRetryHeader === "true" ? true : shouldRetryHeader === "false" ? false : undefined;
|
|
99
|
+
return {
|
|
100
|
+
origin: "anthropic-messages",
|
|
101
|
+
kind,
|
|
102
|
+
message: message.slice(0, MAX_MESSAGE_CHARS),
|
|
103
|
+
...(status !== undefined ? { statusCode: status } : {}),
|
|
104
|
+
...(providerCodes !== undefined ? { providerCodes } : {}),
|
|
105
|
+
...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
|
|
106
|
+
...(shouldRetry !== undefined ? { shouldRetry } : {}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAQ1D,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,MAAM,qBAAqB,GAAG,sFAAsF,CAAC;AACrH,MAAM,oBAAoB,GACzB,8FAA8F,CAAC;AAEhG;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,KAAc;IACxC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AASD,SAAS,QAAQ,CAAC,K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AAO,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC;QAC5C,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACH,CAAC","sourcesContent":["import { extract429RetryAfterMs } from \"../retry-hint.ts\";\nimport type { RetryFailure, RetryFailureKind } from \"./types.ts\";\n\nexport interface RetryFailureContext {\n\t/** Raw response/error body text captured at the catch boundary, when held. */\n\treadonly bodyText?: string;\n}\n\nconst MAX_MESSAGE_CHARS = 500;\n\nconst QUOTA_WORDING_PATTERN = /exceeded_current_quota_error|insufficient\\s+balance|credits?_required|quota|billing/i;\nconst IMAGE_FORMAT_PATTERN =\n\t/unsupported image format|unsupported media type for base64 image|invalid data url for image/i;\n\n/**\n * Anthropic SDK connection-error classes are matched by constructor name\n * rather than `instanceof`: a static import of the SDK error classes would\n * break every test that `vi.mock`s `@anthropic-ai/sdk` without re-exporting\n * them, and the SDK never sets `error.name`. `APIConnectionTimeoutError`\n * extends `APIConnectionError`, so callers must check the timeout name first.\n */\nfunction sdkErrorClassName(error: unknown): string | undefined {\n\tif (!(error instanceof Error)) return undefined;\n\tconst name = error.constructor?.name;\n\treturn typeof name === \"string\" && name.length > 0 ? name : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\ninterface ShapedProviderError extends Error {\n\treadonly status?: unknown;\n\treadonly headers?: unknown;\n\t/** Anthropic SDK carries the parsed error body here. */\n\treadonly error?: unknown;\n}\n\nfunction toShaped(error: unknown): ShapedProviderError | undefined {\n\treturn error instanceof Error ? (error as ShapedProviderError) : undefined;\n}\n\nfunction numericStatus(shaped: ShapedProviderError | undefined): number | undefined {\n\tconst status = shaped?.status;\n\treturn typeof status === \"number\" && Number.isFinite(status) ? status : undefined;\n}\n\nfunction headerObject(shaped: ShapedProviderError | undefined): Headers | undefined {\n\treturn shaped?.headers instanceof Headers ? shaped.headers : undefined;\n}\n\n/** Nested `error.type` / `error.code` strings from a parsed provider body, in order. */\nfunction nestedProviderCodes(body: unknown): readonly string[] | undefined {\n\tif (!isRecord(body)) return undefined;\n\tconst inner = body.error;\n\tif (!isRecord(inner)) return undefined;\n\tconst codes: string[] = [];\n\tfor (const key of [\"type\", \"code\"] as const) {\n\t\tconst value = inner[key];\n\t\tif (typeof value === \"string\" && value.length > 0) codes.push(value);\n\t}\n\treturn codes.length > 0 ? codes : undefined;\n}\n\n/** Parse the leading JSON object of an SSE error payload, ignoring trailing markers. */\nfunction parseLeadingJson(text: string): unknown {\n\tconst candidate = text.slice(text.indexOf(\"{\"), text.lastIndexOf(\"}\") + 1);\n\tif (!candidate.startsWith(\"{\") || !candidate.endsWith(\"}\")) return undefined;\n\ttry {\n\t\treturn JSON.parse(candidate) as unknown;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction quotaWording(shaped: ShapedProviderError | undefined, bodyText: string): boolean {\n\tconst candidates = [shaped?.message, bodyText];\n\treturn candidates.some((text) => typeof text === \"string\" && QUOTA_WORDING_PATTERN.test(text));\n}\n\n/**\n * Normalize a raw anthropic-messages failure into whitelisted\n * {@link RetryFailure} facts. Raw headers, bodies, and credentials are never\n * retained: only the eight declared fields, each derived from parsed facts.\n */\nexport function normalizeAnthropicRetryFailure(error: unknown, context?: RetryFailureContext): RetryFailure {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tconst shaped = toShaped(error);\n\tconst status = numericStatus(shaped);\n\tconst headers = headerObject(shaped);\n\tconst bodyText = context?.bodyText ?? message;\n\n\tlet kind: RetryFailureKind;\n\tlet providerCodes: readonly string[] | undefined;\n\n\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\tkind = \"abort\";\n\t} else if (sdkErrorClassName(error) === \"APIConnectionTimeoutError\") {\n\t\tkind = \"timeout\";\n\t} else if (sdkErrorClassName(error) === \"APIConnectionError\") {\n\t\tkind = \"connection\";\n\t} else if (typeof message === \"string\" && IMAGE_FORMAT_PATTERN.test(message)) {\n\t\tkind = \"image-format\";\n\t} else if (status !== undefined) {\n\t\tkind = status === 429 && quotaWording(shaped, bodyText) ? \"quota-exhausted\" : \"http-status\";\n\t\tproviderCodes = nestedProviderCodes(shaped?.error);\n\t} else {\n\t\tconst parsed = parseLeadingJson(bodyText);\n\t\tproviderCodes = nestedProviderCodes(parsed);\n\t\tkind = providerCodes !== undefined ? \"provider\" : \"unknown\";\n\t}\n\n\tconst retryAfterMs = extract429RetryAfterMs({ status, headers, bodyText });\n\n\tconst shouldRetryHeader = headers?.get(\"x-should-retry\");\n\tconst shouldRetry = shouldRetryHeader === \"true\" ? true : shouldRetryHeader === \"false\" ? false : undefined;\n\n\treturn {\n\t\torigin: \"anthropic-messages\",\n\t\tkind,\n\t\tmessage: message.slice(0, MAX_MESSAGE_CHARS),\n\t\t...(status !== undefined ? { statusCode: status } : {}),\n\t\t...(providerCodes !== undefined ? { providerCodes } : {}),\n\t\t...(retryAfterMs !== undefined ? { retryAfterMs } : {}),\n\t\t...(shouldRetry !== undefined ? { shouldRetry } : {}),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { retryBackoffDelayMs } from "./backoff.ts";
|
|
2
|
+
export { classifyKimiFailure, classifySenpiAssistantFailure } from "./classifiers.ts";
|
|
3
|
+
export type { RetryFailureContext } from "./failure.ts";
|
|
4
|
+
export { normalizeAnthropicRetryFailure } from "./failure.ts";
|
|
5
|
+
export type { RetryPlanResult } from "./planner.ts";
|
|
6
|
+
export { planRetryDelay } from "./planner.ts";
|
|
7
|
+
export { KIMI_CODE_RETRY_PROFILE, SENPI_DEFAULT_RETRY_PROFILE } from "./profiles.ts";
|
|
8
|
+
export type { RetryBackoffPolicy, RetryClassification, RetryClassifier, RetryFailure, RetryFailureKind, RetryHintCeiling, RetryHintExtractor, RetryJitterPolicy, RetryPolicyProfile, RetryServerHintPolicy, RetryStagePolicy, RetryTieredHintDecision, RetryTieredHintStrategy, } from "./types.ts";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACtF,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACrF,YAAY,EACX,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { retryBackoffDelayMs } from "./backoff.js";
|
|
2
|
+
export { classifyKimiFailure, classifySenpiAssistantFailure } from "./classifiers.js";
|
|
3
|
+
export { normalizeAnthropicRetryFailure } from "./failure.js";
|
|
4
|
+
export { planRetryDelay } from "./planner.js";
|
|
5
|
+
export { KIMI_CODE_RETRY_PROFILE, SENPI_DEFAULT_RETRY_PROFILE } from "./profiles.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { retryBackoffDelayMs } from \"./backoff.ts\";\nexport { classifyKimiFailure, classifySenpiAssistantFailure } from \"./classifiers.ts\";\nexport type { RetryFailureContext } from \"./failure.ts\";\nexport { normalizeAnthropicRetryFailure } from \"./failure.ts\";\nexport type { RetryPlanResult } from \"./planner.ts\";\nexport { planRetryDelay } from \"./planner.ts\";\nexport { KIMI_CODE_RETRY_PROFILE, SENPI_DEFAULT_RETRY_PROFILE } from \"./profiles.ts\";\nexport type {\n\tRetryBackoffPolicy,\n\tRetryClassification,\n\tRetryClassifier,\n\tRetryFailure,\n\tRetryFailureKind,\n\tRetryHintCeiling,\n\tRetryHintExtractor,\n\tRetryJitterPolicy,\n\tRetryPolicyProfile,\n\tRetryServerHintPolicy,\n\tRetryStagePolicy,\n\tRetryTieredHintDecision,\n\tRetryTieredHintStrategy,\n} from \"./types.ts\";\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { RetryFailure, RetryStagePolicy } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One planned retry decision: how long to wait before the next attempt, or
|
|
4
|
+
* that a server hint asked for more than the profile's ceiling allows.
|
|
5
|
+
*
|
|
6
|
+
* - `wait` — sleep `delayMs` and retry.
|
|
7
|
+
* - `over-ceiling` — the server-requested wait strictly exceeded the stage's
|
|
8
|
+
* `ceiling.maxDelayMs`; the caller turns this into an error-with-marker
|
|
9
|
+
* (profiles only declare `error-with-marker`, so no branch is needed here).
|
|
10
|
+
* - `tiered` — see the tiered-stage contract below.
|
|
11
|
+
*/
|
|
12
|
+
export type RetryPlanResult = {
|
|
13
|
+
readonly kind: "wait";
|
|
14
|
+
readonly delayMs: number;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "over-ceiling";
|
|
17
|
+
readonly requestedMs: number;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "tiered";
|
|
20
|
+
readonly tier: string;
|
|
21
|
+
readonly delayMs: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Combine a stage's backoff schedule with its server-hint policy into one
|
|
25
|
+
* retry delay decision.
|
|
26
|
+
*
|
|
27
|
+
* The computed backoff `retryBackoffDelayMs(stage.backoff, retryNumber,
|
|
28
|
+
* random)` is the default. In `override` mode a positive `failure.retryAfterMs`
|
|
29
|
+
* replaces that delay entirely — even when the hint is shorter — while zero,
|
|
30
|
+
* negative, or absent hints fall back to the computed backoff unless the stage
|
|
31
|
+
* opts into `acceptZero`. A hint strictly above `ceiling.maxDelayMs` surfaces
|
|
32
|
+
* as `over-ceiling` instead of being clamped; a `null` ceiling makes that
|
|
33
|
+
* unreachable, so any positive hint is honoured verbatim.
|
|
34
|
+
*
|
|
35
|
+
* Tiered-stage contract: this planner does NOT decide tiers. For a `tiered`
|
|
36
|
+
* stage it merely reports whether a hint was present — `{ kind: "tiered",
|
|
37
|
+
* tier: "delegated", delayMs: computed }` when `failure.retryAfterMs` exists,
|
|
38
|
+
* plain `wait` with the computed backoff otherwise. The ACTUAL tier decision
|
|
39
|
+
* (tier label, degraded budget, per-tier delay) stays in coding-agent's
|
|
40
|
+
* existing hint-policy module
|
|
41
|
+
* (`packages/coding-agent/src/core/retry-fallback/hint-policy.ts`), injected
|
|
42
|
+
* into the profile as `RetryTieredHintStrategy`; packages must not import
|
|
43
|
+
* across, so the label here is the fixed sentinel `"delegated"`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function planRetryDelay(stage: RetryStagePolicy, failure: RetryFailure, retryNumber: number, random: number): RetryPlanResult;
|
|
46
|
+
//# sourceMappingURL=planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/planner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACZ,eAAe,CAmBjB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { retryBackoffDelayMs } from "./backoff.js";
|
|
2
|
+
/**
|
|
3
|
+
* Combine a stage's backoff schedule with its server-hint policy into one
|
|
4
|
+
* retry delay decision.
|
|
5
|
+
*
|
|
6
|
+
* The computed backoff `retryBackoffDelayMs(stage.backoff, retryNumber,
|
|
7
|
+
* random)` is the default. In `override` mode a positive `failure.retryAfterMs`
|
|
8
|
+
* replaces that delay entirely — even when the hint is shorter — while zero,
|
|
9
|
+
* negative, or absent hints fall back to the computed backoff unless the stage
|
|
10
|
+
* opts into `acceptZero`. A hint strictly above `ceiling.maxDelayMs` surfaces
|
|
11
|
+
* as `over-ceiling` instead of being clamped; a `null` ceiling makes that
|
|
12
|
+
* unreachable, so any positive hint is honoured verbatim.
|
|
13
|
+
*
|
|
14
|
+
* Tiered-stage contract: this planner does NOT decide tiers. For a `tiered`
|
|
15
|
+
* stage it merely reports whether a hint was present — `{ kind: "tiered",
|
|
16
|
+
* tier: "delegated", delayMs: computed }` when `failure.retryAfterMs` exists,
|
|
17
|
+
* plain `wait` with the computed backoff otherwise. The ACTUAL tier decision
|
|
18
|
+
* (tier label, degraded budget, per-tier delay) stays in coding-agent's
|
|
19
|
+
* existing hint-policy module
|
|
20
|
+
* (`packages/coding-agent/src/core/retry-fallback/hint-policy.ts`), injected
|
|
21
|
+
* into the profile as `RetryTieredHintStrategy`; packages must not import
|
|
22
|
+
* across, so the label here is the fixed sentinel `"delegated"`.
|
|
23
|
+
*/
|
|
24
|
+
export function planRetryDelay(stage, failure, retryNumber, random) {
|
|
25
|
+
const computed = retryBackoffDelayMs(stage.backoff, retryNumber, random);
|
|
26
|
+
const hint = failure.retryAfterMs;
|
|
27
|
+
if (stage.serverHint.mode === "tiered") {
|
|
28
|
+
return hint === undefined
|
|
29
|
+
? { kind: "wait", delayMs: computed }
|
|
30
|
+
: { kind: "tiered", tier: "delegated", delayMs: computed };
|
|
31
|
+
}
|
|
32
|
+
if (hint !== undefined && (hint > 0 || (hint === 0 && stage.serverHint.acceptZero))) {
|
|
33
|
+
const { maxDelayMs } = stage.serverHint.ceiling;
|
|
34
|
+
if (maxDelayMs !== null && hint > maxDelayMs) {
|
|
35
|
+
return { kind: "over-ceiling", requestedMs: hint };
|
|
36
|
+
}
|
|
37
|
+
return { kind: "wait", delayMs: hint };
|
|
38
|
+
}
|
|
39
|
+
return { kind: "wait", delayMs: computed };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAkBnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAuB,EACvB,OAAqB,EACrB,WAAmB,EACnB,MAAc;IAEd,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAElC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;YACrC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC7D,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACrF,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;QAChD,IAAI,UAAU,KAAK,IAAI,IAAI,IAAI,GAAG,UAAU,EAAE,CAAC;YAC9C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QACpD,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { retryBackoffDelayMs } from \"./backoff.ts\";\nimport type { RetryFailure, RetryStagePolicy } from \"./types.ts\";\n\n/**\n * One planned retry decision: how long to wait before the next attempt, or\n * that a server hint asked for more than the profile's ceiling allows.\n *\n * - `wait` — sleep `delayMs` and retry.\n * - `over-ceiling` — the server-requested wait strictly exceeded the stage's\n * `ceiling.maxDelayMs`; the caller turns this into an error-with-marker\n * (profiles only declare `error-with-marker`, so no branch is needed here).\n * - `tiered` — see the tiered-stage contract below.\n */\nexport type RetryPlanResult =\n\t| { readonly kind: \"wait\"; readonly delayMs: number }\n\t| { readonly kind: \"over-ceiling\"; readonly requestedMs: number }\n\t| { readonly kind: \"tiered\"; readonly tier: string; readonly delayMs: number };\n\n/**\n * Combine a stage's backoff schedule with its server-hint policy into one\n * retry delay decision.\n *\n * The computed backoff `retryBackoffDelayMs(stage.backoff, retryNumber,\n * random)` is the default. In `override` mode a positive `failure.retryAfterMs`\n * replaces that delay entirely — even when the hint is shorter — while zero,\n * negative, or absent hints fall back to the computed backoff unless the stage\n * opts into `acceptZero`. A hint strictly above `ceiling.maxDelayMs` surfaces\n * as `over-ceiling` instead of being clamped; a `null` ceiling makes that\n * unreachable, so any positive hint is honoured verbatim.\n *\n * Tiered-stage contract: this planner does NOT decide tiers. For a `tiered`\n * stage it merely reports whether a hint was present — `{ kind: \"tiered\",\n * tier: \"delegated\", delayMs: computed }` when `failure.retryAfterMs` exists,\n * plain `wait` with the computed backoff otherwise. The ACTUAL tier decision\n * (tier label, degraded budget, per-tier delay) stays in coding-agent's\n * existing hint-policy module\n * (`packages/coding-agent/src/core/retry-fallback/hint-policy.ts`), injected\n * into the profile as `RetryTieredHintStrategy`; packages must not import\n * across, so the label here is the fixed sentinel `\"delegated\"`.\n */\nexport function planRetryDelay(\n\tstage: RetryStagePolicy,\n\tfailure: RetryFailure,\n\tretryNumber: number,\n\trandom: number,\n): RetryPlanResult {\n\tconst computed = retryBackoffDelayMs(stage.backoff, retryNumber, random);\n\tconst hint = failure.retryAfterMs;\n\n\tif (stage.serverHint.mode === \"tiered\") {\n\t\treturn hint === undefined\n\t\t\t? { kind: \"wait\", delayMs: computed }\n\t\t\t: { kind: \"tiered\", tier: \"delegated\", delayMs: computed };\n\t}\n\n\tif (hint !== undefined && (hint > 0 || (hint === 0 && stage.serverHint.acceptZero))) {\n\t\tconst { maxDelayMs } = stage.serverHint.ceiling;\n\t\tif (maxDelayMs !== null && hint > maxDelayMs) {\n\t\t\treturn { kind: \"over-ceiling\", requestedMs: hint };\n\t\t}\n\t\treturn { kind: \"wait\", delayMs: hint };\n\t}\n\n\treturn { kind: \"wait\", delayMs: computed };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/profiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAQzE,eAAO,MAAM,2BAA2B,EAAE,kBAyCzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBA4CrC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { classifyKimiFailure, classifySenpiAssistantFailure } from "./classifiers.js";
|
|
2
|
+
const extractNormalizedHint = (failure) => failure.retryAfterMs;
|
|
3
|
+
const senpiDefaultTurnStrategy = () => {
|
|
4
|
+
throw new Error("senpi-default turn tier strategy must be injected by coding-agent");
|
|
5
|
+
};
|
|
6
|
+
export const SENPI_DEFAULT_RETRY_PROFILE = {
|
|
7
|
+
id: "senpi-default",
|
|
8
|
+
providerRequest: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
maxRetries: 0,
|
|
11
|
+
backoff: {
|
|
12
|
+
baseDelayMs: 500,
|
|
13
|
+
growthFactor: 2,
|
|
14
|
+
perAttemptCapMs: 8_000,
|
|
15
|
+
jitter: { mode: "subtractive", ratio: 0.25 },
|
|
16
|
+
},
|
|
17
|
+
extractServerHint: extractNormalizedHint,
|
|
18
|
+
serverHint: {
|
|
19
|
+
mode: "override",
|
|
20
|
+
acceptZero: true,
|
|
21
|
+
ceiling: { maxDelayMs: 60_000, onExceeded: "error-with-marker" },
|
|
22
|
+
},
|
|
23
|
+
classify: classifySenpiAssistantFailure,
|
|
24
|
+
},
|
|
25
|
+
turn: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
maxRetries: 3,
|
|
28
|
+
backoff: {
|
|
29
|
+
baseDelayMs: 2_000,
|
|
30
|
+
growthFactor: 2,
|
|
31
|
+
perAttemptCapMs: 8_000,
|
|
32
|
+
jitter: { mode: "additive", ratio: 0.25 },
|
|
33
|
+
},
|
|
34
|
+
extractServerHint: extractNormalizedHint,
|
|
35
|
+
serverHint: {
|
|
36
|
+
mode: "tiered",
|
|
37
|
+
strategy: senpiDefaultTurnStrategy,
|
|
38
|
+
},
|
|
39
|
+
classify: classifySenpiAssistantFailure,
|
|
40
|
+
},
|
|
41
|
+
fallback: {
|
|
42
|
+
terminal: "immediate-if-eligible",
|
|
43
|
+
transient: "after-turn-budget",
|
|
44
|
+
rateLimited: "tiered",
|
|
45
|
+
resetBudgetOnModelChange: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export const KIMI_CODE_RETRY_PROFILE = {
|
|
49
|
+
id: "kimi-code",
|
|
50
|
+
providerRequest: {
|
|
51
|
+
// A user setting retry.provider.maxRetries would otherwise hand Kimi a
|
|
52
|
+
// second hidden retry budget on top of the turn stage's 9.
|
|
53
|
+
enabled: false,
|
|
54
|
+
maxRetries: 0,
|
|
55
|
+
backoff: {
|
|
56
|
+
baseDelayMs: 500,
|
|
57
|
+
growthFactor: 2,
|
|
58
|
+
perAttemptCapMs: 32_000,
|
|
59
|
+
jitter: { mode: "additive", ratio: 0.25 },
|
|
60
|
+
},
|
|
61
|
+
extractServerHint: extractNormalizedHint,
|
|
62
|
+
serverHint: {
|
|
63
|
+
mode: "override",
|
|
64
|
+
acceptZero: false,
|
|
65
|
+
ceiling: { maxDelayMs: null, onExceeded: "error-with-marker" },
|
|
66
|
+
},
|
|
67
|
+
classify: classifyKimiFailure,
|
|
68
|
+
},
|
|
69
|
+
turn: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
maxRetries: 9,
|
|
72
|
+
backoff: {
|
|
73
|
+
baseDelayMs: 500,
|
|
74
|
+
growthFactor: 2,
|
|
75
|
+
perAttemptCapMs: 32_000,
|
|
76
|
+
jitter: { mode: "additive", ratio: 0.25 },
|
|
77
|
+
},
|
|
78
|
+
extractServerHint: extractNormalizedHint,
|
|
79
|
+
serverHint: {
|
|
80
|
+
mode: "override",
|
|
81
|
+
acceptZero: false,
|
|
82
|
+
ceiling: { maxDelayMs: null, onExceeded: "error-with-marker" },
|
|
83
|
+
},
|
|
84
|
+
classify: classifyKimiFailure,
|
|
85
|
+
},
|
|
86
|
+
fallback: {
|
|
87
|
+
terminal: "immediate-if-eligible",
|
|
88
|
+
transient: "after-turn-budget",
|
|
89
|
+
rateLimited: "after-turn-budget",
|
|
90
|
+
resetBudgetOnModelChange: true,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAGtF,MAAM,qBAAqB,GAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;AAEpF,MAAM,wBAAwB,GAAG,GAAG,EAAE;IACrC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAA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AAY,EAAE,CAAC;YACf,eAAe,EAAE,MAAM;YACvB,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;SACzC;QACD,iBAAiB,EAAE,qBAAqB;QACxC,UAAU,EAAE;YACX,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE;SAC9D;QACD,QAAQ,EAAE,mBAAmB;KAC7B;IACD,IAAI,EAAE;QACL,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,CAAC;QACb,OAAO,EAAE;YACR,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,CAAC;YACf,eAAe,EAAE,MAAM;YACvB,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;SACzC;QACD,iBAAiB,EAAE,qBAAqB;QACxC,UAAU,EAAE;YACX,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE;SAC9D;QACD,QAAQ,EAAE,mBAAmB;KAC7B;IACD,QAAQ,EAAE;QACT,QAAQ,EAAE,uBAAuB;QACjC,SAAS,EAAE,mBAAmB;QAC9B,WAAW,EAAE,mBAAmB;QAChC,wBAAwB,EAAE,IAAI;KAC9B;CACD,CAAC","sourcesContent":["import { classifyKimiFailure, classifySenpiAssistantFailure } from \"./classifiers.ts\";\nimport type { RetryHintExtractor, RetryPolicyProfile } from \"./types.ts\";\n\nconst extractNormalizedHint: RetryHintExtractor = (failure) => failure.retryAfterMs;\n\nconst senpiDefaultTurnStrategy = () => {\n\tthrow new Error(\"senpi-default turn tier strategy must be injected by coding-agent\");\n};\n\nexport const SENPI_DEFAULT_RETRY_PROFILE: RetryPolicyProfile = {\n\tid: \"senpi-default\",\n\tproviderRequest: {\n\t\tenabled: true,\n\t\tmaxRetries: 0,\n\t\tbackoff: {\n\t\t\tbaseDelayMs: 500,\n\t\t\tgrowthFactor: 2,\n\t\t\tperAttemptCapMs: 8_000,\n\t\t\tjitter: { mode: \"subtractive\", ratio: 0.25 },\n\t\t},\n\t\textractServerHint: extractNormalizedHint,\n\t\tserverHint: {\n\t\t\tmode: \"override\",\n\t\t\tacceptZero: true,\n\t\t\tceiling: { maxDelayMs: 60_000, onExceeded: \"error-with-marker\" },\n\t\t},\n\t\tclassify: classifySenpiAssistantFailure,\n\t},\n\tturn: {\n\t\tenabled: true,\n\t\tmaxRetries: 3,\n\t\tbackoff: {\n\t\t\tbaseDelayMs: 2_000,\n\t\t\tgrowthFactor: 2,\n\t\t\tperAttemptCapMs: 8_000,\n\t\t\tjitter: { mode: \"additive\", ratio: 0.25 },\n\t\t},\n\t\textractServerHint: extractNormalizedHint,\n\t\tserverHint: {\n\t\t\tmode: \"tiered\",\n\t\t\tstrategy: senpiDefaultTurnStrategy,\n\t\t},\n\t\tclassify: classifySenpiAssistantFailure,\n\t},\n\tfallback: {\n\t\tterminal: \"immediate-if-eligible\",\n\t\ttransient: \"after-turn-budget\",\n\t\trateLimited: \"tiered\",\n\t\tresetBudgetOnModelChange: true,\n\t},\n};\n\nexport const KIMI_CODE_RETRY_PROFILE: RetryPolicyProfile = {\n\tid: \"kimi-code\",\n\tproviderRequest: {\n\t\t// A user setting retry.provider.maxRetries would otherwise hand Kimi a\n\t\t// second hidden retry budget on top of the turn stage's 9.\n\t\tenabled: false,\n\t\tmaxRetries: 0,\n\t\tbackoff: {\n\t\t\tbaseDelayMs: 500,\n\t\t\tgrowthFactor: 2,\n\t\t\tperAttemptCapMs: 32_000,\n\t\t\tjitter: { mode: \"additive\", ratio: 0.25 },\n\t\t},\n\t\textractServerHint: extractNormalizedHint,\n\t\tserverHint: {\n\t\t\tmode: \"override\",\n\t\t\tacceptZero: false,\n\t\t\tceiling: { maxDelayMs: null, onExceeded: \"error-with-marker\" },\n\t\t},\n\t\tclassify: classifyKimiFailure,\n\t},\n\tturn: {\n\t\tenabled: true,\n\t\tmaxRetries: 9,\n\t\tbackoff: {\n\t\t\tbaseDelayMs: 500,\n\t\t\tgrowthFactor: 2,\n\t\t\tperAttemptCapMs: 32_000,\n\t\t\tjitter: { mode: \"additive\", ratio: 0.25 },\n\t\t},\n\t\textractServerHint: extractNormalizedHint,\n\t\tserverHint: {\n\t\t\tmode: \"override\",\n\t\t\tacceptZero: false,\n\t\t\tceiling: { maxDelayMs: null, onExceeded: \"error-with-marker\" },\n\t\t},\n\t\tclassify: classifyKimiFailure,\n\t},\n\tfallback: {\n\t\tterminal: \"immediate-if-eligible\",\n\t\ttransient: \"after-turn-budget\",\n\t\trateLimited: \"after-turn-budget\",\n\t\tresetBudgetOnModelChange: true,\n\t},\n};\n"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure value types for provider-declared retry policy profiles.
|
|
3
|
+
*
|
|
4
|
+
* A {@link RetryPolicyProfile} describes how one provider's requests are
|
|
5
|
+
* retried at two independent stages — the provider/transport request and the
|
|
6
|
+
* assistant turn — plus how the model-fallback chain interacts with the turn
|
|
7
|
+
* budget. These types carry no behaviour; scheduling functions live in sibling
|
|
8
|
+
* modules (`backoff.ts`, and later waves) so the contract stays pure data.
|
|
9
|
+
*/
|
|
10
|
+
/** Normalized failure category; the classifier union is exhaustive over this. */
|
|
11
|
+
export type RetryFailureKind = "abort" | "connection" | "timeout" | "empty-response" | "quota-exhausted" | "http-status" | "image-format" | "provider" | "refusal" | "sensitive" | "unknown";
|
|
12
|
+
/**
|
|
13
|
+
* Whitelisted facts about one provider failure, normalized at the API
|
|
14
|
+
* boundary. Only these fields are ever retained: raw `Headers` objects,
|
|
15
|
+
* authorization values, and response bodies are never carried here.
|
|
16
|
+
*/
|
|
17
|
+
export interface RetryFailure {
|
|
18
|
+
/** API surface that captured the failure (e.g. "anthropic-messages"). */
|
|
19
|
+
readonly origin: string;
|
|
20
|
+
readonly kind: RetryFailureKind;
|
|
21
|
+
/** Byte-identical to the error string today's regex classifier matches on. */
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly statusCode?: number;
|
|
24
|
+
/** Nested provider `error.type` / `error.code` strings when present. */
|
|
25
|
+
readonly providerCodes?: readonly string[];
|
|
26
|
+
readonly finishReason?: string;
|
|
27
|
+
/** Parsed server-requested wait in ms when a hint exists. */
|
|
28
|
+
readonly retryAfterMs?: number;
|
|
29
|
+
/** Provider `x-should-retry` verdict when the transport exposed one. */
|
|
30
|
+
readonly shouldRetry?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Verdict of a stage classifier: how the retry loop may treat a failure. */
|
|
33
|
+
export type RetryClassification = {
|
|
34
|
+
readonly verdict: "transient";
|
|
35
|
+
} | {
|
|
36
|
+
readonly verdict: "rate-limited";
|
|
37
|
+
} | {
|
|
38
|
+
readonly verdict: "terminal";
|
|
39
|
+
};
|
|
40
|
+
/** Classifies a normalized failure into a retry verdict. */
|
|
41
|
+
export type RetryClassifier = (failure: RetryFailure) => RetryClassification;
|
|
42
|
+
/**
|
|
43
|
+
* Narrow server-hint extractor: returns a positive server-requested wait in
|
|
44
|
+
* milliseconds, or undefined when the failure carries none. Profiles declare
|
|
45
|
+
* their own; senpi's richer five-source precedence lives in `../retry-hint.ts`
|
|
46
|
+
* and is not part of this contract.
|
|
47
|
+
*/
|
|
48
|
+
export type RetryHintExtractor = (failure: RetryFailure) => number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Jitter applied AFTER the per-attempt cap: `additive` grows the delay by up
|
|
51
|
+
* to `ratio` (random * ratio * capped), `subtractive` shrinks it by the same
|
|
52
|
+
* amount. `none` returns the capped delay unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export type RetryJitterPolicy = {
|
|
55
|
+
readonly mode: "none";
|
|
56
|
+
} | {
|
|
57
|
+
readonly mode: "additive" | "subtractive";
|
|
58
|
+
readonly ratio: number;
|
|
59
|
+
};
|
|
60
|
+
export interface RetryBackoffPolicy {
|
|
61
|
+
readonly baseDelayMs: number;
|
|
62
|
+
readonly growthFactor: number;
|
|
63
|
+
/**
|
|
64
|
+
* Per-attempt cap applied to `baseDelayMs * growthFactor ** (retryNumber - 1)`
|
|
65
|
+
* BEFORE jitter. `null` means no cap; `0` is a literal zero cap.
|
|
66
|
+
*/
|
|
67
|
+
readonly perAttemptCapMs: number | null;
|
|
68
|
+
readonly jitter: RetryJitterPolicy;
|
|
69
|
+
}
|
|
70
|
+
/** Ceiling on a server-requested wait for `override`-mode hint policies. */
|
|
71
|
+
export interface RetryHintCeiling {
|
|
72
|
+
/** `null` means no ceiling, so `over-ceiling` is unreachable. */
|
|
73
|
+
readonly maxDelayMs: number | null;
|
|
74
|
+
readonly onExceeded: "error-with-marker";
|
|
75
|
+
}
|
|
76
|
+
/** Tier verdict forwarded unchanged by the delay planner for tiered stages. */
|
|
77
|
+
export interface RetryTieredHintDecision {
|
|
78
|
+
/** Tier label owned by the injected strategy (senpi's tiers live in coding-agent). */
|
|
79
|
+
readonly tier: string;
|
|
80
|
+
readonly delayMs: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Tiered-hint strategy, injected from the coding-agent side. packages/ai must
|
|
84
|
+
* not import packages/coding-agent, so the senpi-default profile receives its
|
|
85
|
+
* tier engine (`classifyRateLimitedWait` / `nextInTurnDelayMs` /
|
|
86
|
+
* `degradeWithoutFallback`) as a function value.
|
|
87
|
+
*/
|
|
88
|
+
export type RetryTieredHintStrategy = (failure: RetryFailure, retryNumber: number, backoff: RetryBackoffPolicy, now: number) => RetryTieredHintDecision;
|
|
89
|
+
/**
|
|
90
|
+
* How a stage treats a server-requested wait. `override` replaces the computed
|
|
91
|
+
* backoff with the hint (positive by default; `acceptZero` opts into zero);
|
|
92
|
+
* `tiered` delegates the decision to the injected tier strategy.
|
|
93
|
+
*/
|
|
94
|
+
export type RetryServerHintPolicy = {
|
|
95
|
+
readonly mode: "override";
|
|
96
|
+
readonly acceptZero: boolean;
|
|
97
|
+
readonly ceiling: RetryHintCeiling;
|
|
98
|
+
} | {
|
|
99
|
+
readonly mode: "tiered";
|
|
100
|
+
readonly strategy: RetryTieredHintStrategy;
|
|
101
|
+
};
|
|
102
|
+
export interface RetryStagePolicy {
|
|
103
|
+
readonly enabled: boolean;
|
|
104
|
+
readonly maxRetries: number;
|
|
105
|
+
readonly backoff: RetryBackoffPolicy;
|
|
106
|
+
readonly extractServerHint: RetryHintExtractor;
|
|
107
|
+
readonly serverHint: RetryServerHintPolicy;
|
|
108
|
+
readonly classify: RetryClassifier;
|
|
109
|
+
}
|
|
110
|
+
export interface RetryPolicyProfile {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
readonly providerRequest: RetryStagePolicy;
|
|
113
|
+
readonly turn: RetryStagePolicy;
|
|
114
|
+
readonly fallback: {
|
|
115
|
+
readonly terminal: "immediate-if-eligible";
|
|
116
|
+
readonly transient: "after-turn-budget";
|
|
117
|
+
readonly rateLimited: "tiered" | "after-turn-budget";
|
|
118
|
+
readonly resetBudgetOnModelChange: true;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GACzB,OAAO,GACP,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,UAAU,GACV,SAAS,GACT,WAAW,GACX,SAAS,CAAC;AAEb;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM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,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;QAC3C,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACxC,QAAQ,CAAC,WAAW,EAAE,QAAQ,GAAG,mBAAmB,CAAC;QACrD,QAAQ,CAAC,wBAAwB,EAAE,IAAI,CAAC;KACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure value types for provider-declared retry policy profiles.
|
|
3
|
+
*
|
|
4
|
+
* A {@link RetryPolicyProfile} describes how one provider's requests are
|
|
5
|
+
* retried at two independent stages — the provider/transport request and the
|
|
6
|
+
* assistant turn — plus how the model-fallback chain interacts with the turn
|
|
7
|
+
* budget. These types carry no behaviour; scheduling functions live in sibling
|
|
8
|
+
* modules (`backoff.ts`, and later waves) so the contract stays pure data.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG","sourcesContent":["/**\n * Pure value types for provider-declared retry policy profiles.\n *\n * A {@link RetryPolicyProfile} describes how one provider's requests are\n * retried at two independent stages — the provider/transport request and the\n * assistant turn — plus how the model-fallback chain interacts with the turn\n * budget. These types carry no behaviour; scheduling functions live in sibling\n * modules (`backoff.ts`, and later waves) so the contract stays pure data.\n */\n\n/** Normalized failure category; the classifier union is exhaustive over this. */\nexport type RetryFailureKind =\n\t| \"abort\"\n\t| \"connection\"\n\t| \"timeout\"\n\t| \"empty-response\"\n\t| \"quota-exhausted\"\n\t| \"http-status\"\n\t| \"image-format\"\n\t| \"provider\"\n\t| \"refusal\"\n\t| \"sensitive\"\n\t| \"unknown\";\n\n/**\n * Whitelisted facts about one provider failure, normalized at the API\n * boundary. Only these fields are ever retained: raw `Headers` objects,\n * authorization values, and response bodies are never carried here.\n */\nexport interface RetryFailure {\n\t/** API surface that captured the failure (e.g. \"anthropic-messages\"). */\n\treadonly origin: string;\n\treadonly kind: RetryFailureKind;\n\t/** Byte-identical to the error string today's regex classifier matches on. */\n\treadonly message: string;\n\treadonly statusCode?: number;\n\t/** Nested provider `error.type` / `error.code` strings when present. */\n\treadonly providerCodes?: readonly string[];\n\treadonly finishReason?: string;\n\t/** Parsed server-requested wait in ms when a hint exists. */\n\treadonly retryAfterMs?: number;\n\t/** Provider `x-should-retry` verdict when the transport exposed one. */\n\treadonly shouldRetry?: boolean;\n}\n\n/** Verdict of a stage classifier: how the retry loop may treat a failure. */\nexport type RetryClassification =\n\t| { readonly verdict: \"transient\" }\n\t| { readonly verdict: \"rate-limited\" }\n\t| { readonly verdict: \"terminal\" };\n\n/** Classifies a normalized failure into a retry verdict. */\nexport type RetryClassifier = (failure: RetryFailure) => RetryClassification;\n\n/**\n * Narrow server-hint extractor: returns a positive server-requested wait in\n * milliseconds, or undefined when the failure carries none. Profiles declare\n * their own; senpi's richer five-source precedence lives in `../retry-hint.ts`\n * and is not part of this contract.\n */\nexport type RetryHintExtractor = (failure: RetryFailure) => number | undefined;\n\n/**\n * Jitter applied AFTER the per-attempt cap: `additive` grows the delay by up\n * to `ratio` (random * ratio * capped), `subtractive` shrinks it by the same\n * amount. `none` returns the capped delay unchanged.\n */\nexport type RetryJitterPolicy =\n\t| { readonly mode: \"none\" }\n\t| { readonly mode: \"additive\" | \"subtractive\"; readonly ratio: number };\n\nexport interface RetryBackoffPolicy {\n\treadonly baseDelayMs: number;\n\treadonly growthFactor: number;\n\t/**\n\t * Per-attempt cap applied to `baseDelayMs * growthFactor ** (retryNumber - 1)`\n\t * BEFORE jitter. `null` means no cap; `0` is a literal zero cap.\n\t */\n\treadonly perAttemptCapMs: number | null;\n\treadonly jitter: RetryJitterPolicy;\n}\n\n/** Ceiling on a server-requested wait for `override`-mode hint policies. */\nexport interface RetryHintCeiling {\n\t/** `null` means no ceiling, so `over-ceiling` is unreachable. */\n\treadonly maxDelayMs: number | null;\n\treadonly onExceeded: \"error-with-marker\";\n}\n\n/** Tier verdict forwarded unchanged by the delay planner for tiered stages. */\nexport interface RetryTieredHintDecision {\n\t/** Tier label owned by the injected strategy (senpi's tiers live in coding-agent). */\n\treadonly tier: string;\n\treadonly delayMs: number;\n}\n\n/**\n * Tiered-hint strategy, injected from the coding-agent side. packages/ai must\n * not import packages/coding-agent, so the senpi-default profile receives its\n * tier engine (`classifyRateLimitedWait` / `nextInTurnDelayMs` /\n * `degradeWithoutFallback`) as a function value.\n */\nexport type RetryTieredHintStrategy = (\n\tfailure: RetryFailure,\n\tretryNumber: number,\n\tbackoff: RetryBackoffPolicy,\n\tnow: number,\n) => RetryTieredHintDecision;\n\n/**\n * How a stage treats a server-requested wait. `override` replaces the computed\n * backoff with the hint (positive by default; `acceptZero` opts into zero);\n * `tiered` delegates the decision to the injected tier strategy.\n */\nexport type RetryServerHintPolicy =\n\t| {\n\t\t\treadonly mode: \"override\";\n\t\t\treadonly acceptZero: boolean;\n\t\t\treadonly ceiling: RetryHintCeiling;\n\t }\n\t| {\n\t\t\treadonly mode: \"tiered\";\n\t\t\treadonly strategy: RetryTieredHintStrategy;\n\t };\n\nexport interface RetryStagePolicy {\n\treadonly enabled: boolean;\n\treadonly maxRetries: number;\n\treadonly backoff: RetryBackoffPolicy;\n\treadonly extractServerHint: RetryHintExtractor;\n\treadonly serverHint: RetryServerHintPolicy;\n\treadonly classify: RetryClassifier;\n}\n\nexport interface RetryPolicyProfile {\n\treadonly id: string;\n\treadonly providerRequest: RetryStagePolicy;\n\treadonly turn: RetryStagePolicy;\n\treadonly fallback: {\n\t\treadonly terminal: \"immediate-if-eligible\";\n\t\treadonly transient: \"after-turn-budget\";\n\t\treadonly rateLimited: \"tiered\" | \"after-turn-budget\";\n\t\treadonly resetBudgetOnModelChange: true;\n\t};\n}\n"]}
|
|
@@ -11,7 +11,10 @@ export interface RetryPolicy {
|
|
|
11
11
|
maxRetries: number;
|
|
12
12
|
/** Base delay in ms. Per-attempt delay is `baseDelayMs * 2^(attempt-1)` before jitter. */
|
|
13
13
|
baseDelayMs: number;
|
|
14
|
+
/** Injectable source used for Codex-style +/-10% backoff jitter. */
|
|
15
|
+
random?: () => number;
|
|
14
16
|
}
|
|
17
|
+
export declare function retryDelayMs(baseDelayMs: number, attempt: number, random?: () => number): number;
|
|
15
18
|
/** Optional callbacks emitted by {@link retryAssistantCall} around each retry. */
|
|
16
19
|
export interface RetryCallbacks {
|
|
17
20
|
/** Emitted before the backoff sleep of each retry attempt (1-indexed). */
|
|
@@ -89,4 +92,13 @@ export declare function isProviderTimeoutError(message: AssistantMessage): boole
|
|
|
89
92
|
* failures that must decide between degrading and surfacing loudly).
|
|
90
93
|
*/
|
|
91
94
|
export declare function isRetryableErrorMessage(errorMessage: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Tri-state form of {@link isRetryableErrorMessage}. The regexes only carry
|
|
97
|
+
* three outcomes — a non-retryable match, a retryable match, or no match at
|
|
98
|
+
* all — and callers that hold structured failure facts (status codes, provider
|
|
99
|
+
* error codes) need to distinguish "the regexes say terminal" from "the
|
|
100
|
+
* regexes say nothing" so they can consult the structured facts only in the
|
|
101
|
+
* latter case. Non-retryable still outranks retryable, exactly as before.
|
|
102
|
+
*/
|
|
103
|
+
export declare function classifyErrorMessage(errorMessage: string): "non-retryable" | "retryable" | "unknown";
|
|
92
104
|
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAsIpD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;
|
|
1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