@code-yeongyu/senpi-ai 2026.9.29 → 2026.9.30
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/dist/api/bedrock-converse-stream.js +4 -2
- package/dist/api/lazy.js +2 -1
- package/dist/api/openai-completions.js +13 -8
- package/dist/api/openai-responses-shared.js +4 -1
- package/dist/api/openai-responses.js +10 -7
- package/dist/models.js +6 -2
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cerebras.json +1 -1
- package/dist/providers/data/chatgpt-subscription.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/opengateway.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/venice.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/utils/prompt-cache-ttl.js +33 -2
- package/dist/utils/provider-failure-description.d.ts +7 -0
- package/dist/utils/provider-failure-description.js +21 -0
- package/dist/utils/retry.js +9 -0
- package/dist/utils/tool-schema-compat.d.ts +2 -0
- package/dist/utils/tool-schema-compat.js +28 -9
- package/package.json +3 -2
- package/dist/api/anthropic-messages.d.ts.map +0 -1
- package/dist/api/anthropic-messages.js.map +0 -1
- package/dist/api/anthropic-messages.lazy.d.ts.map +0 -1
- package/dist/api/anthropic-messages.lazy.js.map +0 -1
- package/dist/api/anthropic-tool-pairs.d.ts.map +0 -1
- package/dist/api/anthropic-tool-pairs.js.map +0 -1
- package/dist/api/anthropic-tool-references.d.ts.map +0 -1
- package/dist/api/anthropic-tool-references.js.map +0 -1
- package/dist/api/azure-openai-responses.d.ts.map +0 -1
- package/dist/api/azure-openai-responses.js.map +0 -1
- package/dist/api/azure-openai-responses.lazy.d.ts.map +0 -1
- package/dist/api/azure-openai-responses.lazy.js.map +0 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +0 -1
- package/dist/api/bedrock-converse-stream.js.map +0 -1
- package/dist/api/bedrock-converse-stream.lazy.d.ts.map +0 -1
- package/dist/api/bedrock-converse-stream.lazy.js.map +0 -1
- package/dist/api/cloudflare-ai-binding.d.ts.map +0 -1
- package/dist/api/cloudflare-ai-binding.js.map +0 -1
- package/dist/api/cloudflare.d.ts.map +0 -1
- package/dist/api/cloudflare.js.map +0 -1
- package/dist/api/constrained-sampling.d.ts.map +0 -1
- package/dist/api/constrained-sampling.js.map +0 -1
- package/dist/api/context-room.d.ts.map +0 -1
- package/dist/api/context-room.js.map +0 -1
- package/dist/api/cursor-agent/deterministic-id.d.ts.map +0 -1
- package/dist/api/cursor-agent/deterministic-id.js.map +0 -1
- package/dist/api/cursor-agent/exec-lifecycle.d.ts.map +0 -1
- package/dist/api/cursor-agent/exec-lifecycle.js.map +0 -1
- package/dist/api/cursor-agent/exec-modern.d.ts.map +0 -1
- package/dist/api/cursor-agent/exec-modern.js.map +0 -1
- package/dist/api/cursor-agent/gen/agent_pb.d.ts.map +0 -1
- package/dist/api/cursor-agent/gen/agent_pb.js.map +0 -1
- package/dist/api/cursor-agent/measure.d.ts.map +0 -1
- package/dist/api/cursor-agent/measure.js.map +0 -1
- package/dist/api/cursor-agent/pi-args.d.ts.map +0 -1
- package/dist/api/cursor-agent/pi-args.js.map +0 -1
- package/dist/api/cursor-agent/reasoning-params.d.ts.map +0 -1
- package/dist/api/cursor-agent/reasoning-params.js.map +0 -1
- package/dist/api/cursor-agent/stream-retry.d.ts.map +0 -1
- package/dist/api/cursor-agent/stream-retry.js.map +0 -1
- package/dist/api/cursor-agent/types.d.ts.map +0 -1
- package/dist/api/cursor-agent/types.js.map +0 -1
- package/dist/api/cursor-agent.d.ts.map +0 -1
- package/dist/api/cursor-agent.js.map +0 -1
- package/dist/api/cursor-agent.lazy.d.ts.map +0 -1
- package/dist/api/cursor-agent.lazy.js.map +0 -1
- package/dist/api/cursor-conversation-rotation.d.ts.map +0 -1
- package/dist/api/cursor-conversation-rotation.js.map +0 -1
- package/dist/api/cursor-task-args.d.ts.map +0 -1
- package/dist/api/cursor-task-args.js.map +0 -1
- package/dist/api/devin-agent/discovery.d.ts.map +0 -1
- package/dist/api/devin-agent/discovery.js.map +0 -1
- package/dist/api/devin-agent/frames.d.ts.map +0 -1
- package/dist/api/devin-agent/frames.js.map +0 -1
- package/dist/api/devin-agent/gen/cascade_pb.d.ts.map +0 -1
- package/dist/api/devin-agent/gen/cascade_pb.js.map +0 -1
- package/dist/api/devin-agent/metadata.d.ts.map +0 -1
- package/dist/api/devin-agent/metadata.js.map +0 -1
- package/dist/api/devin-agent/paths.d.ts.map +0 -1
- package/dist/api/devin-agent/paths.js.map +0 -1
- package/dist/api/devin-agent/request.d.ts.map +0 -1
- package/dist/api/devin-agent/request.js.map +0 -1
- package/dist/api/devin-agent/stream-state.d.ts.map +0 -1
- package/dist/api/devin-agent/stream-state.js.map +0 -1
- package/dist/api/devin-agent/trailer.d.ts.map +0 -1
- package/dist/api/devin-agent/trailer.js.map +0 -1
- package/dist/api/devin-agent/types.d.ts.map +0 -1
- package/dist/api/devin-agent/types.js.map +0 -1
- package/dist/api/devin-agent/unary.d.ts.map +0 -1
- package/dist/api/devin-agent/unary.js.map +0 -1
- package/dist/api/devin-agent/wire.d.ts.map +0 -1
- package/dist/api/devin-agent/wire.js.map +0 -1
- package/dist/api/devin-agent.d.ts.map +0 -1
- package/dist/api/devin-agent.js.map +0 -1
- package/dist/api/devin-agent.lazy.d.ts.map +0 -1
- package/dist/api/devin-agent.lazy.js.map +0 -1
- package/dist/api/github-copilot-endpoint.d.ts.map +0 -1
- package/dist/api/github-copilot-endpoint.js.map +0 -1
- package/dist/api/github-copilot-errors.d.ts.map +0 -1
- package/dist/api/github-copilot-errors.js.map +0 -1
- package/dist/api/github-copilot-headers.d.ts.map +0 -1
- package/dist/api/github-copilot-headers.js.map +0 -1
- package/dist/api/google-generative-ai.d.ts.map +0 -1
- package/dist/api/google-generative-ai.js.map +0 -1
- package/dist/api/google-generative-ai.lazy.d.ts.map +0 -1
- package/dist/api/google-generative-ai.lazy.js.map +0 -1
- package/dist/api/google-shared.d.ts.map +0 -1
- package/dist/api/google-shared.js.map +0 -1
- package/dist/api/google-vertex.d.ts.map +0 -1
- package/dist/api/google-vertex.js.map +0 -1
- package/dist/api/google-vertex.lazy.d.ts.map +0 -1
- package/dist/api/google-vertex.lazy.js.map +0 -1
- package/dist/api/lazy.d.ts.map +0 -1
- package/dist/api/lazy.js.map +0 -1
- package/dist/api/mistral-conversations.d.ts.map +0 -1
- package/dist/api/mistral-conversations.js.map +0 -1
- package/dist/api/mistral-conversations.lazy.d.ts.map +0 -1
- package/dist/api/mistral-conversations.lazy.js.map +0 -1
- package/dist/api/openai-client-auth.d.ts.map +0 -1
- package/dist/api/openai-client-auth.js.map +0 -1
- package/dist/api/openai-codex-responses/fallback-state.d.ts.map +0 -1
- package/dist/api/openai-codex-responses/fallback-state.js.map +0 -1
- package/dist/api/openai-codex-responses/reasoning.d.ts.map +0 -1
- package/dist/api/openai-codex-responses/reasoning.js.map +0 -1
- package/dist/api/openai-codex-responses.d.ts.map +0 -1
- package/dist/api/openai-codex-responses.js.map +0 -1
- package/dist/api/openai-codex-responses.lazy.d.ts.map +0 -1
- package/dist/api/openai-codex-responses.lazy.js.map +0 -1
- package/dist/api/openai-completions.d.ts.map +0 -1
- package/dist/api/openai-completions.js.map +0 -1
- package/dist/api/openai-completions.lazy.d.ts.map +0 -1
- package/dist/api/openai-completions.lazy.js.map +0 -1
- package/dist/api/openai-images-edit.d.ts.map +0 -1
- package/dist/api/openai-images-edit.js.map +0 -1
- package/dist/api/openai-images-params.d.ts.map +0 -1
- package/dist/api/openai-images-params.js.map +0 -1
- package/dist/api/openai-images-result.d.ts.map +0 -1
- package/dist/api/openai-images-result.js.map +0 -1
- package/dist/api/openai-images.d.ts.map +0 -1
- package/dist/api/openai-images.js.map +0 -1
- package/dist/api/openai-images.lazy.d.ts.map +0 -1
- package/dist/api/openai-images.lazy.js.map +0 -1
- package/dist/api/openai-prompt-cache.d.ts.map +0 -1
- package/dist/api/openai-prompt-cache.js.map +0 -1
- package/dist/api/openai-responses-prompt-cache.d.ts.map +0 -1
- package/dist/api/openai-responses-prompt-cache.js.map +0 -1
- package/dist/api/openai-responses-shared.d.ts.map +0 -1
- package/dist/api/openai-responses-shared.js.map +0 -1
- package/dist/api/openai-responses.d.ts.map +0 -1
- package/dist/api/openai-responses.js.map +0 -1
- package/dist/api/openai-responses.lazy.d.ts.map +0 -1
- package/dist/api/openai-responses.lazy.js.map +0 -1
- package/dist/api/openrouter-images.d.ts.map +0 -1
- package/dist/api/openrouter-images.js.map +0 -1
- package/dist/api/openrouter-images.lazy.d.ts.map +0 -1
- package/dist/api/openrouter-images.lazy.js.map +0 -1
- package/dist/api/pi-messages.d.ts.map +0 -1
- package/dist/api/pi-messages.js.map +0 -1
- package/dist/api/pi-messages.lazy.d.ts.map +0 -1
- package/dist/api/pi-messages.lazy.js.map +0 -1
- package/dist/api/prompt-cache-warmers.d.ts.map +0 -1
- package/dist/api/prompt-cache-warmers.js.map +0 -1
- package/dist/api/responses-completion-grace.d.ts.map +0 -1
- package/dist/api/responses-completion-grace.js.map +0 -1
- package/dist/api/simple-options.d.ts.map +0 -1
- package/dist/api/simple-options.js.map +0 -1
- package/dist/api/transform-messages.d.ts.map +0 -1
- package/dist/api/transform-messages.js.map +0 -1
- package/dist/api/warm-prompt-cache.d.ts.map +0 -1
- package/dist/api/warm-prompt-cache.js.map +0 -1
- package/dist/api/websocket-liveness.d.ts.map +0 -1
- package/dist/api/websocket-liveness.js.map +0 -1
- package/dist/api/websocket-transport-failure.d.ts.map +0 -1
- package/dist/api/websocket-transport-failure.js.map +0 -1
- package/dist/api-registry.d.ts.map +0 -1
- package/dist/api-registry.js.map +0 -1
- package/dist/auth/context.d.ts.map +0 -1
- package/dist/auth/context.js.map +0 -1
- package/dist/auth/credential-store.d.ts.map +0 -1
- package/dist/auth/credential-store.js.map +0 -1
- package/dist/auth/headers.d.ts.map +0 -1
- package/dist/auth/headers.js.map +0 -1
- package/dist/auth/helpers.d.ts.map +0 -1
- package/dist/auth/helpers.js.map +0 -1
- package/dist/auth/oauth/anthropic-callback-listener.d.ts.map +0 -1
- package/dist/auth/oauth/anthropic-callback-listener.js.map +0 -1
- package/dist/auth/oauth/anthropic.d.ts.map +0 -1
- package/dist/auth/oauth/anthropic.js.map +0 -1
- package/dist/auth/oauth/authorization-input.d.ts.map +0 -1
- package/dist/auth/oauth/authorization-input.js.map +0 -1
- package/dist/auth/oauth/chatgpt-subscription.d.ts.map +0 -1
- package/dist/auth/oauth/chatgpt-subscription.js.map +0 -1
- package/dist/auth/oauth/cursor.d.ts.map +0 -1
- package/dist/auth/oauth/cursor.js.map +0 -1
- package/dist/auth/oauth/device-code.d.ts.map +0 -1
- package/dist/auth/oauth/device-code.js.map +0 -1
- package/dist/auth/oauth/devin-callback.d.ts.map +0 -1
- package/dist/auth/oauth/devin-callback.js.map +0 -1
- package/dist/auth/oauth/devin-token.d.ts.map +0 -1
- package/dist/auth/oauth/devin-token.js.map +0 -1
- package/dist/auth/oauth/devin.d.ts.map +0 -1
- package/dist/auth/oauth/devin.js.map +0 -1
- package/dist/auth/oauth/error-details.d.ts.map +0 -1
- package/dist/auth/oauth/error-details.js.map +0 -1
- package/dist/auth/oauth/github-copilot-model-catalog.d.ts.map +0 -1
- package/dist/auth/oauth/github-copilot-model-catalog.js.map +0 -1
- package/dist/auth/oauth/github-copilot.d.ts.map +0 -1
- package/dist/auth/oauth/github-copilot.js.map +0 -1
- package/dist/auth/oauth/kimi-coding.d.ts.map +0 -1
- package/dist/auth/oauth/kimi-coding.js.map +0 -1
- package/dist/auth/oauth/kimi-identity.d.ts.map +0 -1
- package/dist/auth/oauth/kimi-identity.js.map +0 -1
- package/dist/auth/oauth/kimi-region.d.ts.map +0 -1
- package/dist/auth/oauth/kimi-region.js.map +0 -1
- package/dist/auth/oauth/load.d.ts.map +0 -1
- package/dist/auth/oauth/load.js.map +0 -1
- package/dist/auth/oauth/oauth-page.d.ts.map +0 -1
- package/dist/auth/oauth/oauth-page.js.map +0 -1
- package/dist/auth/oauth/openrouter.d.ts.map +0 -1
- package/dist/auth/oauth/openrouter.js.map +0 -1
- package/dist/auth/oauth/pkce.d.ts.map +0 -1
- package/dist/auth/oauth/pkce.js.map +0 -1
- package/dist/auth/oauth/radius.d.ts.map +0 -1
- package/dist/auth/oauth/radius.js.map +0 -1
- package/dist/auth/oauth/xai.d.ts.map +0 -1
- package/dist/auth/oauth/xai.js.map +0 -1
- package/dist/auth/oauth-refresh.d.ts.map +0 -1
- package/dist/auth/oauth-refresh.js.map +0 -1
- package/dist/auth/pool/classify.d.ts.map +0 -1
- package/dist/auth/pool/classify.js.map +0 -1
- package/dist/auth/pool/failover.d.ts.map +0 -1
- package/dist/auth/pool/failover.js.map +0 -1
- package/dist/auth/pool/select.d.ts.map +0 -1
- package/dist/auth/pool/select.js.map +0 -1
- package/dist/auth/pool/slots.d.ts.map +0 -1
- package/dist/auth/pool/slots.js.map +0 -1
- package/dist/auth/refresh-credential.d.ts.map +0 -1
- package/dist/auth/refresh-credential.js.map +0 -1
- package/dist/auth/resolve.d.ts.map +0 -1
- package/dist/auth/resolve.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/bedrock-provider.d.ts.map +0 -1
- package/dist/bedrock-provider.js.map +0 -1
- package/dist/bun-oauth.d.ts.map +0 -1
- package/dist/bun-oauth.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/compat/extension-oauth-types.d.ts.map +0 -1
- package/dist/compat/extension-oauth-types.js.map +0 -1
- package/dist/compat.d.ts.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/context-provenance.d.ts.map +0 -1
- package/dist/context-provenance.js.map +0 -1
- package/dist/cursor/catalog-grouping.d.ts.map +0 -1
- package/dist/cursor/catalog-grouping.js.map +0 -1
- package/dist/cursor/composer-prompt.d.ts.map +0 -1
- package/dist/cursor/composer-prompt.js.map +0 -1
- package/dist/cursor/context-limit-store.d.ts.map +0 -1
- package/dist/cursor/context-limit-store.js.map +0 -1
- package/dist/cursor/model-capabilities.d.ts.map +0 -1
- package/dist/cursor/model-capabilities.js.map +0 -1
- package/dist/cursor/selection-descriptor.d.ts.map +0 -1
- package/dist/cursor/selection-descriptor.js.map +0 -1
- package/dist/cursor/store-migration.d.ts.map +0 -1
- package/dist/cursor/store-migration.js.map +0 -1
- package/dist/cursor-agent-provider.d.ts.map +0 -1
- package/dist/cursor-agent-provider.js.map +0 -1
- package/dist/devin-provider.d.ts.map +0 -1
- package/dist/devin-provider.js.map +0 -1
- package/dist/endpoint-reasoning-efforts.d.ts.map +0 -1
- package/dist/endpoint-reasoning-efforts.js.map +0 -1
- package/dist/env-api-keys.d.ts.map +0 -1
- package/dist/env-api-keys.js.map +0 -1
- package/dist/image-models.d.ts.map +0 -1
- package/dist/image-models.generated.d.ts.map +0 -1
- package/dist/image-models.generated.js.map +0 -1
- package/dist/image-models.js.map +0 -1
- package/dist/images-api-registry.d.ts.map +0 -1
- package/dist/images-api-registry.js.map +0 -1
- package/dist/images-models.d.ts.map +0 -1
- package/dist/images-models.js.map +0 -1
- package/dist/images.d.ts.map +0 -1
- package/dist/images.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/legacy-api-aliases.d.ts.map +0 -1
- package/dist/legacy-api-aliases.js.map +0 -1
- package/dist/legacy-provider-ids.d.ts.map +0 -1
- package/dist/legacy-provider-ids.js.map +0 -1
- package/dist/model-catalog.d.ts.map +0 -1
- package/dist/model-catalog.js.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/models-store.d.ts.map +0 -1
- package/dist/models-store.js.map +0 -1
- package/dist/models.d.ts.map +0 -1
- package/dist/models.generated.d.ts.map +0 -1
- package/dist/models.generated.js.map +0 -1
- package/dist/models.js.map +0 -1
- package/dist/node/provider-scope.d.ts.map +0 -1
- package/dist/node/provider-scope.js.map +0 -1
- package/dist/oauth.d.ts.map +0 -1
- package/dist/oauth.js.map +0 -1
- package/dist/openai-responses-compat.d.ts.map +0 -1
- package/dist/openai-responses-compat.js.map +0 -1
- package/dist/provider-diagnostic.d.ts.map +0 -1
- package/dist/provider-diagnostic.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.models.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.models.js.map +0 -1
- package/dist/providers/all.d.ts.map +0 -1
- package/dist/providers/all.js.map +0 -1
- package/dist/providers/amazon-bedrock.d.ts.map +0 -1
- package/dist/providers/amazon-bedrock.js.map +0 -1
- package/dist/providers/amazon-bedrock.models.d.ts.map +0 -1
- package/dist/providers/amazon-bedrock.models.js.map +0 -1
- package/dist/providers/ant-ling.d.ts.map +0 -1
- package/dist/providers/ant-ling.js.map +0 -1
- package/dist/providers/ant-ling.models.d.ts.map +0 -1
- package/dist/providers/ant-ling.models.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/anthropic.models.d.ts.map +0 -1
- package/dist/providers/anthropic.models.js.map +0 -1
- package/dist/providers/azure-openai-responses.d.ts.map +0 -1
- package/dist/providers/azure-openai-responses.js.map +0 -1
- package/dist/providers/azure-openai-responses.models.d.ts.map +0 -1
- package/dist/providers/azure-openai-responses.models.js.map +0 -1
- package/dist/providers/bai-stream.d.ts.map +0 -1
- package/dist/providers/bai-stream.js.map +0 -1
- package/dist/providers/bai.d.ts.map +0 -1
- package/dist/providers/bai.js.map +0 -1
- package/dist/providers/bai.models.d.ts.map +0 -1
- package/dist/providers/bai.models.js.map +0 -1
- package/dist/providers/baseten.d.ts.map +0 -1
- package/dist/providers/baseten.js.map +0 -1
- package/dist/providers/baseten.models.d.ts.map +0 -1
- package/dist/providers/baseten.models.js.map +0 -1
- package/dist/providers/cerebras.d.ts.map +0 -1
- package/dist/providers/cerebras.js.map +0 -1
- package/dist/providers/cerebras.models.d.ts.map +0 -1
- package/dist/providers/cerebras.models.js.map +0 -1
- package/dist/providers/chatgpt-subscription.d.ts.map +0 -1
- package/dist/providers/chatgpt-subscription.js.map +0 -1
- package/dist/providers/chatgpt-subscription.models.d.ts.map +0 -1
- package/dist/providers/chatgpt-subscription.models.js.map +0 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts.map +0 -1
- package/dist/providers/cloudflare-ai-gateway.js.map +0 -1
- package/dist/providers/cloudflare-ai-gateway.models.d.ts.map +0 -1
- package/dist/providers/cloudflare-ai-gateway.models.js.map +0 -1
- package/dist/providers/cloudflare-auth.d.ts.map +0 -1
- package/dist/providers/cloudflare-auth.js.map +0 -1
- package/dist/providers/cloudflare-stream.d.ts.map +0 -1
- package/dist/providers/cloudflare-stream.js.map +0 -1
- package/dist/providers/cloudflare-workers-ai.d.ts.map +0 -1
- package/dist/providers/cloudflare-workers-ai.js.map +0 -1
- package/dist/providers/cloudflare-workers-ai.models.d.ts.map +0 -1
- package/dist/providers/cloudflare-workers-ai.models.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/deepseek.models.d.ts.map +0 -1
- package/dist/providers/deepseek.models.js.map +0 -1
- package/dist/providers/devin.d.ts.map +0 -1
- package/dist/providers/devin.js.map +0 -1
- package/dist/providers/devin.models.d.ts.map +0 -1
- package/dist/providers/devin.models.js.map +0 -1
- package/dist/providers/faux.d.ts.map +0 -1
- package/dist/providers/faux.js.map +0 -1
- package/dist/providers/fireworks.d.ts.map +0 -1
- package/dist/providers/fireworks.js.map +0 -1
- package/dist/providers/fireworks.models.d.ts.map +0 -1
- package/dist/providers/fireworks.models.js.map +0 -1
- package/dist/providers/github-copilot-limits.d.ts.map +0 -1
- package/dist/providers/github-copilot-limits.js.map +0 -1
- package/dist/providers/github-copilot.d.ts.map +0 -1
- package/dist/providers/github-copilot.js.map +0 -1
- package/dist/providers/github-copilot.models.d.ts.map +0 -1
- package/dist/providers/github-copilot.models.js.map +0 -1
- package/dist/providers/google-shared.d.ts.map +0 -1
- package/dist/providers/google-shared.js.map +0 -1
- package/dist/providers/google-vertex.d.ts.map +0 -1
- package/dist/providers/google-vertex.js.map +0 -1
- package/dist/providers/google-vertex.models.d.ts.map +0 -1
- package/dist/providers/google-vertex.models.js.map +0 -1
- package/dist/providers/google.d.ts.map +0 -1
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/google.models.d.ts.map +0 -1
- package/dist/providers/google.models.js.map +0 -1
- package/dist/providers/groq.d.ts.map +0 -1
- package/dist/providers/groq.js.map +0 -1
- package/dist/providers/groq.models.d.ts.map +0 -1
- package/dist/providers/groq.models.js.map +0 -1
- package/dist/providers/huggingface.d.ts.map +0 -1
- package/dist/providers/huggingface.js.map +0 -1
- package/dist/providers/huggingface.models.d.ts.map +0 -1
- package/dist/providers/huggingface.models.js.map +0 -1
- package/dist/providers/images/register-builtins.d.ts.map +0 -1
- package/dist/providers/images/register-builtins.js.map +0 -1
- package/dist/providers/kimi-coding-auth.d.ts.map +0 -1
- package/dist/providers/kimi-coding-auth.js.map +0 -1
- package/dist/providers/kimi-coding.d.ts.map +0 -1
- package/dist/providers/kimi-coding.js.map +0 -1
- package/dist/providers/kimi-coding.models.d.ts.map +0 -1
- package/dist/providers/kimi-coding.models.js.map +0 -1
- package/dist/providers/minimax-cn.d.ts.map +0 -1
- package/dist/providers/minimax-cn.js.map +0 -1
- package/dist/providers/minimax-cn.models.d.ts.map +0 -1
- package/dist/providers/minimax-cn.models.js.map +0 -1
- package/dist/providers/minimax.d.ts.map +0 -1
- package/dist/providers/minimax.js.map +0 -1
- package/dist/providers/minimax.models.d.ts.map +0 -1
- package/dist/providers/minimax.models.js.map +0 -1
- package/dist/providers/mistral.d.ts.map +0 -1
- package/dist/providers/mistral.js.map +0 -1
- package/dist/providers/mistral.models.d.ts.map +0 -1
- package/dist/providers/mistral.models.js.map +0 -1
- package/dist/providers/moonshotai-cn.d.ts.map +0 -1
- package/dist/providers/moonshotai-cn.js.map +0 -1
- package/dist/providers/moonshotai-cn.models.d.ts.map +0 -1
- package/dist/providers/moonshotai-cn.models.js.map +0 -1
- package/dist/providers/moonshotai.d.ts.map +0 -1
- package/dist/providers/moonshotai.js.map +0 -1
- package/dist/providers/moonshotai.models.d.ts.map +0 -1
- package/dist/providers/moonshotai.models.js.map +0 -1
- package/dist/providers/nvidia.d.ts.map +0 -1
- package/dist/providers/nvidia.js.map +0 -1
- package/dist/providers/nvidia.models.d.ts.map +0 -1
- package/dist/providers/nvidia.models.js.map +0 -1
- package/dist/providers/ollama.d.ts.map +0 -1
- package/dist/providers/ollama.js.map +0 -1
- package/dist/providers/openai-completions.d.ts.map +0 -1
- package/dist/providers/openai-completions.js.map +0 -1
- package/dist/providers/openai-images.d.ts.map +0 -1
- package/dist/providers/openai-images.js.map +0 -1
- package/dist/providers/openai-responses-shared.d.ts.map +0 -1
- package/dist/providers/openai-responses-shared.js.map +0 -1
- package/dist/providers/openai-responses.d.ts.map +0 -1
- package/dist/providers/openai-responses.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/openai.models.d.ts.map +0 -1
- package/dist/providers/openai.models.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-go.models.d.ts.map +0 -1
- package/dist/providers/opencode-go.models.js.map +0 -1
- package/dist/providers/opencode-headers.d.ts.map +0 -1
- package/dist/providers/opencode-headers.js.map +0 -1
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js.map +0 -1
- package/dist/providers/opencode.models.d.ts.map +0 -1
- package/dist/providers/opencode.models.js.map +0 -1
- package/dist/providers/opengateway.d.ts.map +0 -1
- package/dist/providers/opengateway.js.map +0 -1
- package/dist/providers/opengateway.models.d.ts.map +0 -1
- package/dist/providers/opengateway.models.js.map +0 -1
- package/dist/providers/openrouter-images.d.ts.map +0 -1
- package/dist/providers/openrouter-images.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/openrouter.models.d.ts.map +0 -1
- package/dist/providers/openrouter.models.js.map +0 -1
- package/dist/providers/qwen-token-plan-cn.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan-cn.js.map +0 -1
- package/dist/providers/qwen-token-plan-cn.models.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan-cn.models.js.map +0 -1
- package/dist/providers/qwen-token-plan-individual.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan-individual.js.map +0 -1
- package/dist/providers/qwen-token-plan-individual.models.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan-individual.models.js.map +0 -1
- package/dist/providers/qwen-token-plan.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan.js.map +0 -1
- package/dist/providers/qwen-token-plan.models.d.ts.map +0 -1
- package/dist/providers/qwen-token-plan.models.js.map +0 -1
- package/dist/providers/radius-config.d.ts.map +0 -1
- package/dist/providers/radius-config.js.map +0 -1
- package/dist/providers/radius.d.ts.map +0 -1
- package/dist/providers/radius.js.map +0 -1
- package/dist/providers/register-builtins.d.ts.map +0 -1
- package/dist/providers/register-builtins.js.map +0 -1
- package/dist/providers/together.d.ts.map +0 -1
- package/dist/providers/together.js.map +0 -1
- package/dist/providers/together.models.d.ts.map +0 -1
- package/dist/providers/together.models.js.map +0 -1
- package/dist/providers/venice.d.ts.map +0 -1
- package/dist/providers/venice.js.map +0 -1
- package/dist/providers/venice.models.d.ts.map +0 -1
- package/dist/providers/venice.models.js.map +0 -1
- package/dist/providers/vercel-ai-gateway.d.ts.map +0 -1
- package/dist/providers/vercel-ai-gateway.js.map +0 -1
- package/dist/providers/vercel-ai-gateway.models.d.ts.map +0 -1
- package/dist/providers/vercel-ai-gateway.models.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/xai.models.d.ts.map +0 -1
- package/dist/providers/xai.models.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-ams.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-ams.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-cn.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-cn.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-sgp.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-sgp.js.map +0 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +0 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js.map +0 -1
- package/dist/providers/xiaomi.d.ts.map +0 -1
- package/dist/providers/xiaomi.js.map +0 -1
- package/dist/providers/xiaomi.models.d.ts.map +0 -1
- package/dist/providers/xiaomi.models.js.map +0 -1
- package/dist/providers/zai-coding-cn.d.ts.map +0 -1
- package/dist/providers/zai-coding-cn.js.map +0 -1
- package/dist/providers/zai-coding-cn.models.d.ts.map +0 -1
- package/dist/providers/zai-coding-cn.models.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zai.models.d.ts.map +0 -1
- package/dist/providers/zai.models.js.map +0 -1
- package/dist/session-resources.d.ts.map +0 -1
- package/dist/session-resources.js.map +0 -1
- package/dist/stream.d.ts.map +0 -1
- package/dist/stream.js.map +0 -1
- package/dist/tool-call-middleware/context-transformer.d.ts.map +0 -1
- package/dist/tool-call-middleware/context-transformer.js.map +0 -1
- package/dist/tool-call-middleware/index.d.ts.map +0 -1
- package/dist/tool-call-middleware/index.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/index.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/index.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-stream-helpers.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-stream-helpers.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-syntax.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-syntax.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/recovery-stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/recovery-stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/recovery-wrapper-state.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/recovery-wrapper-state.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/coerce-parameters.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/config.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/config.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/format.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/format.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/index.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/index.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/parse.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/parse.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/recovery-stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/recovery-stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/repair.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/repair.js.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/antml/stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/gemma4.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/gemma4.js.map +0 -1
- package/dist/tool-call-middleware/protocols/hermes.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/hermes.js.map +0 -1
- package/dist/tool-call-middleware/protocols/json-mix.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/json-mix.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/format.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/format.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/index.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/index.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/markers.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/markers.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/parse.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/parse.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery-stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery-stream.js.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.js.map +0 -1
- package/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/morph-xml.js.map +0 -1
- package/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js.map +0 -1
- package/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +0 -1
- package/dist/tool-call-middleware/protocols/yaml-xml.js.map +0 -1
- package/dist/tool-call-middleware/recovery-code-mask.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-code-mask.js.map +0 -1
- package/dist/tool-call-middleware/recovery-content-lifecycle.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-content-lifecycle.js.map +0 -1
- package/dist/tool-call-middleware/recovery-diagnostics.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-diagnostics.js.map +0 -1
- package/dist/tool-call-middleware/recovery-event-stream.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-event-stream.js.map +0 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.js.map +0 -1
- package/dist/tool-call-middleware/recovery-native-projection.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-native-projection.js.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-failure.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-failure.js.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-terminal.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-terminal.js.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-wrapper.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-stream-wrapper.js.map +0 -1
- package/dist/tool-call-middleware/recovery-text-projection.d.ts.map +0 -1
- package/dist/tool-call-middleware/recovery-text-projection.js.map +0 -1
- package/dist/tool-call-middleware/stream-message-metadata.d.ts.map +0 -1
- package/dist/tool-call-middleware/stream-message-metadata.js.map +0 -1
- package/dist/tool-call-middleware/stream-thinking-projection.d.ts.map +0 -1
- package/dist/tool-call-middleware/stream-thinking-projection.js.map +0 -1
- package/dist/tool-call-middleware/stream-wrapper-shared.d.ts.map +0 -1
- package/dist/tool-call-middleware/stream-wrapper-shared.js.map +0 -1
- package/dist/tool-call-middleware/stream-wrapper.d.ts.map +0 -1
- package/dist/tool-call-middleware/stream-wrapper.js.map +0 -1
- package/dist/tool-call-middleware/types.d.ts.map +0 -1
- package/dist/tool-call-middleware/types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/abort-signals.d.ts.map +0 -1
- package/dist/utils/abort-signals.js.map +0 -1
- package/dist/utils/abort.d.ts.map +0 -1
- package/dist/utils/abort.js.map +0 -1
- package/dist/utils/assistant-message-frame.d.ts.map +0 -1
- package/dist/utils/assistant-message-frame.js.map +0 -1
- package/dist/utils/block-symbols.d.ts.map +0 -1
- package/dist/utils/block-symbols.js.map +0 -1
- package/dist/utils/chatgpt-subscription-auth.d.ts.map +0 -1
- package/dist/utils/chatgpt-subscription-auth.js.map +0 -1
- package/dist/utils/claude-code-version-cache.d.ts.map +0 -1
- package/dist/utils/claude-code-version-cache.js.map +0 -1
- package/dist/utils/claude-code-version.d.ts.map +0 -1
- package/dist/utils/claude-code-version.js.map +0 -1
- package/dist/utils/cursor-context-limit.d.ts.map +0 -1
- package/dist/utils/cursor-context-limit.js.map +0 -1
- package/dist/utils/deferred-tools.d.ts.map +0 -1
- package/dist/utils/deferred-tools.js.map +0 -1
- package/dist/utils/diagnostics.d.ts.map +0 -1
- package/dist/utils/diagnostics.js.map +0 -1
- package/dist/utils/drop-failed-assistant-turns.d.ts.map +0 -1
- package/dist/utils/drop-failed-assistant-turns.js.map +0 -1
- package/dist/utils/empty-response-errors.d.ts.map +0 -1
- package/dist/utils/empty-response-errors.js.map +0 -1
- package/dist/utils/error-body.d.ts.map +0 -1
- package/dist/utils/error-body.js.map +0 -1
- package/dist/utils/estimate.d.ts.map +0 -1
- package/dist/utils/estimate.js.map +0 -1
- package/dist/utils/event-stream.d.ts.map +0 -1
- package/dist/utils/event-stream.js.map +0 -1
- package/dist/utils/github-copilot-tool-limit.d.ts.map +0 -1
- package/dist/utils/github-copilot-tool-limit.js.map +0 -1
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/headers.d.ts.map +0 -1
- package/dist/utils/headers.js.map +0 -1
- package/dist/utils/json-parse.d.ts.map +0 -1
- package/dist/utils/json-parse.js.map +0 -1
- package/dist/utils/node-http-proxy.d.ts.map +0 -1
- package/dist/utils/node-http-proxy.js.map +0 -1
- package/dist/utils/overflow.d.ts.map +0 -1
- package/dist/utils/overflow.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/dist/utils/process-singleton.d.ts.map +0 -1
- package/dist/utils/process-singleton.js.map +0 -1
- package/dist/utils/prompt-cache-ttl.d.ts.map +0 -1
- package/dist/utils/prompt-cache-ttl.js.map +0 -1
- package/dist/utils/provider-diagnostic-carrier.d.ts.map +0 -1
- package/dist/utils/provider-diagnostic-carrier.js.map +0 -1
- package/dist/utils/provider-diagnostic-sources.d.ts.map +0 -1
- package/dist/utils/provider-diagnostic-sources.js.map +0 -1
- package/dist/utils/provider-diagnostic-vocabulary.d.ts.map +0 -1
- package/dist/utils/provider-diagnostic-vocabulary.js.map +0 -1
- package/dist/utils/provider-env.d.ts.map +0 -1
- package/dist/utils/provider-env.js.map +0 -1
- package/dist/utils/provider-failure-description.d.ts.map +0 -1
- package/dist/utils/provider-failure-description.js.map +0 -1
- package/dist/utils/provider-retry.d.ts.map +0 -1
- package/dist/utils/provider-retry.js.map +0 -1
- package/dist/utils/retry-hint.d.ts.map +0 -1
- package/dist/utils/retry-hint.js.map +0 -1
- package/dist/utils/retry-profile/backoff.d.ts.map +0 -1
- package/dist/utils/retry-profile/backoff.js.map +0 -1
- package/dist/utils/retry-profile/classifiers.d.ts.map +0 -1
- package/dist/utils/retry-profile/classifiers.js.map +0 -1
- package/dist/utils/retry-profile/failure.d.ts.map +0 -1
- package/dist/utils/retry-profile/failure.js.map +0 -1
- package/dist/utils/retry-profile/index.d.ts.map +0 -1
- package/dist/utils/retry-profile/index.js.map +0 -1
- package/dist/utils/retry-profile/planner.d.ts.map +0 -1
- package/dist/utils/retry-profile/planner.js.map +0 -1
- package/dist/utils/retry-profile/profiles.d.ts.map +0 -1
- package/dist/utils/retry-profile/profiles.js.map +0 -1
- package/dist/utils/retry-profile/types.d.ts.map +0 -1
- package/dist/utils/retry-profile/types.js.map +0 -1
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/sanitize-unicode.d.ts.map +0 -1
- package/dist/utils/sanitize-unicode.js.map +0 -1
- package/dist/utils/server-fallback-receipt.d.ts.map +0 -1
- package/dist/utils/server-fallback-receipt.js.map +0 -1
- package/dist/utils/sleep.d.ts.map +0 -1
- package/dist/utils/sleep.js.map +0 -1
- package/dist/utils/stop-details.d.ts.map +0 -1
- package/dist/utils/stop-details.js.map +0 -1
- package/dist/utils/text.d.ts.map +0 -1
- package/dist/utils/text.js.map +0 -1
- package/dist/utils/tool-call-id.d.ts.map +0 -1
- package/dist/utils/tool-call-id.js.map +0 -1
- package/dist/utils/tool-choice-fallback.d.ts.map +0 -1
- package/dist/utils/tool-choice-fallback.js.map +0 -1
- package/dist/utils/tool-name-match.d.ts.map +0 -1
- package/dist/utils/tool-name-match.js.map +0 -1
- package/dist/utils/tool-pair-repair.d.ts.map +0 -1
- package/dist/utils/tool-pair-repair.js.map +0 -1
- package/dist/utils/tool-schema-compat.d.ts.map +0 -1
- package/dist/utils/tool-schema-compat.js.map +0 -1
- package/dist/utils/typebox-helpers.d.ts.map +0 -1
- package/dist/utils/typebox-helpers.js.map +0 -1
- package/dist/utils/unavailable-tool-text.d.ts.map +0 -1
- package/dist/utils/unavailable-tool-text.js.map +0 -1
- package/dist/utils/uuid.d.ts.map +0 -1
- package/dist/utils/uuid.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
- package/dist/utils/visible-text.d.ts.map +0 -1
- package/dist/utils/visible-text.js.map +0 -1
- package/dist/wire-identity.d.ts.map +0 -1
- package/dist/wire-identity.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry-hint.js","sourceRoot":"","sources":["../../src/utils/retry-hint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAC/C,MAAM,kBAAkB,GACvB,gIAAgI,CAAC;AAClI,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACtC,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,oBAAoB;CACpB,CAAC,CAAC;AACH,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAUjC,uCAAuC;AAEvC,SAAS,aAAa,CAAC,MAA0B,EAAE,QAAgB;IAClE,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,mEAAmE;IACnE,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,YAAY,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAC9F,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAC;YACxE,IAAI,CAAC,KAAK,GAAG;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,KAAK;YAAE,OAA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AM,UAAU,wBAAwB,CAAC,OAAe,EAAE,MAAc;IACvE,OAAO,GAAG,OAAO,qBAAqB,MAAM,GAAG,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACtD,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * Strict 429 retry-hint extractor with canonical marker helpers.\n *\n * Precedence (first match wins, malformed source falls through):\n * 1. retry-after-ms header (strict `^\\d+(?:\\.\\d+)?$`, ceil)\n * 2. retry-after header (strict integer delta-seconds `^\\d+$`, else HTTP-date)\n * 3. x-ratelimit-reset{,-requests,-tokens} (epoch seconds, max-wins)\n * 4. JSON retryDelay strings (ms/s/m units, recursive, max-wins; numeric rejected)\n * 5. body prose (ms-marker, seconds-marker, relative, resets-at ISO8601)\n *\n * Eligibility gate: status 429 OR body marks rate-limit error.\n * Explicit zero = 0 (beats lower-precedence positives).\n * Past absolute times clamp to 0.\n * Absolute times resolve against response Date header (clock-skew safe), else nowMs.\n */\n\nconst MARKER_RE = /\\(retry-after-ms: (\\d+)\\)$/;\nconst RATE_LIMIT_BODY_RE =\n\t/\\b(rate_limit_error|rate_limit_exceeded|too_many_requests|resource_exhausted|rate limit (?:exceeded|hit)|too many requests)\\b/i;\nconst RATE_LIMIT_JSON_VALUES = new Set([\n\t\"rate_limit_error\",\n\t\"rate_limit_exceeded\",\n\t\"too_many_requests\",\n\t\"resource_exhausted\",\n]);\nconst RETRY_AFTER_MS_RE = /^\\d+(?:\\.\\d+)?$/;\nconst DELTA_SECONDS_RE = /^\\d+$/;\n\n/* ---------- public types ---------- */\n\nexport interface RetryHintInput {\n\tstatus?: number;\n\theaders?: Headers;\n\tbodyText: string;\n}\n\n/* ---------- eligibility ---------- */\n\nfunction isRateLimited(status: number | undefined, bodyText: string): boolean {\n\tif (status === 429) return true;\n\tif (RATE_LIMIT_BODY_RE.test(bodyText)) return true;\n\t// JSON type/code fields or retryDelay presence (rate-limit signal)\n\tconst json = tryParseJSON(bodyText);\n\tif (json !== undefined) {\n\t\tconst found = scanValue(json, (v, k) => {\n\t\t\tif (k !== undefined && k.toLowerCase() === \"retrydelay\" && typeof v === \"string\") return true;\n\t\t\tif (typeof v === \"string\" && RATE_LIMIT_JSON_VALUES.has(v)) return true;\n\t\t\tif (v === 429) return true;\n\t\t\treturn false;\n\t\t});\n\t\tif (found) return true;\n\t}\n\treturn false;\n}\n\n/* ---------- 1. retry-after-ms header ---------- */\n\nfunction fromRetryAfterMsHeader(h: Headers | undefined): number | undefined {\n\tconst raw = h?.get(\"retry-after-ms\");\n\tif (raw === null || raw === undefined) return undefined;\n\tif (!RETRY_AFTER_MS_RE.test(raw)) return undefined;\n\tconst val = Number.parseFloat(raw);\n\tif (!Number.isFinite(val) || val < 0) return undefined;\n\treturn Math.ceil(val);\n}\n\n/* ---------- 2. retry-after header ---------- */\n\nfunction fromRetryAfterHeader(h: Headers | undefined, nowMs: number): number | undefined {\n\tconst raw = h?.get(\"retry-after\");\n\tif (raw === null || raw === undefined) return undefined;\n\t// integer delta-seconds\n\tif (DELTA_SECONDS_RE.test(raw)) {\n\t\treturn Number.parseInt(raw, 10) * 1000;\n\t}\n\t// HTTP-date — must contain alphabetic chars to be a real date string\n\tif (/[a-zA-Z]/.test(raw)) {\n\t\tconst parsed = Date.parse(raw);\n\t\tif (!Number.isNaN(parsed)) {\n\t\t\tconst base = dateHeaderMs(h) ?? nowMs;\n\t\t\treturn clampAbsolute(parsed, base);\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/* ---------- 3. x-ratelimit-reset* headers ---------- */\n\nfunction fromXRateLimitReset(h: Headers | undefined, nowMs: number): number | undefined {\n\tlet best: number | undefined;\n\tfor (const key of [\"x-ratelimit-reset\", \"x-ratelimit-reset-requests\", \"x-ratelimit-reset-tokens\"]) {\n\t\tconst raw = h?.get(key);\n\t\tif (raw === null || raw === undefined) continue;\n\t\tconst epoch = Number.parseFloat(raw);\n\t\tif (!Number.isFinite(epoch) || epoch < 0) continue;\n\t\t// reject \"12abc\" — strict number check\n\t\tif (!/^\\d+(?:\\.\\d+)?$/.test(raw)) continue;\n\t\tconst delta = Math.ceil(epoch * 1000 - nowMs);\n\t\tconst clamped = Math.max(0, delta);\n\t\tif (best === undefined || clamped > best) best = clamped;\n\t}\n\treturn best;\n}\n\n/* ---------- 4. JSON retryDelay (recursive, max-wins) ---------- */\n\nconst RETRY_DELAY_RE = /^(\\d+(?:\\.\\d+)?)\\s*(ms|s|m)$/;\n\nfunction fromJsonRetryDelay(bodyText: string): number | undefined {\n\tconst json = tryParseJSON(bodyText);\n\tif (json === undefined) return undefined;\n\tlet best: number | undefined;\n\tscanValue(json, (v) => {\n\t\tif (typeof v !== \"string\") return false;\n\t\tconst m = v.match(RETRY_DELAY_RE);\n\t\tif (!m) return false;\n\t\tconst num = Number.parseFloat(m[1]);\n\t\tconst unit = m[2];\n\t\tconst ms = unit === \"ms\" ? num : unit === \"s\" ? num * 1000 : num * 60_000;\n\t\tconst intMs = Math.ceil(ms);\n\t\tif (best === undefined || intMs > best) best = intMs;\n\t\treturn false; // keep scanning\n\t});\n\treturn best;\n}\n\n/* ---------- 5. body prose ---------- */\n\nfunction fromBodyProse(bodyText: string, nowMs: number): number | undefined {\n\t// ms-marker: retry-after-ms: <N>\n\tlet m = bodyText.match(/retry-after-ms:\\s*(\\d+)/i);\n\tif (m) return Number.parseInt(m[1], 10);\n\n\t// seconds-marker: retry-after: <N>\n\tm = bodyText.match(/retry-after:\\s*(\\d+)/i);\n\tif (m) return Number.parseInt(m[1], 10) * 1000;\n\n\t// relative prose: try again | retry | wait after ... [in] N <unit>\n\tm = bodyText.match(\n\t\t/(?:try again|retry|wait after).*?(?:in\\s+)?(\\d+(?:\\.\\d+)?)\\s*(ms|s|sec|seconds?|m|min|minutes?)\\b/i,\n\t);\n\tif (m) return convertUnit(Number.parseFloat(m[1]), m[2]);\n\n\t// resets at <ISO8601-with-tz>\n\tm = bodyText.match(/resets?\\s+at\\s+(\\S+)/i);\n\tif (m) {\n\t\tconst parsed = Date.parse(m[1]);\n\t\tif (!Number.isNaN(parsed)) return clampAbsolute(parsed, nowMs);\n\t}\n\n\treturn undefined;\n}\n\n/* ---------- helpers ---------- */\n\nfunction dateHeaderMs(h: Headers | undefined): number | undefined {\n\tconst raw = h?.get(\"date\");\n\tif (raw === null || raw === undefined) return undefined;\n\tconst parsed = Date.parse(raw);\n\treturn Number.isNaN(parsed) ? undefined : parsed;\n}\n\nfunction clampAbsolute(targetMs: number, baseMs: number): number {\n\treturn Math.max(0, targetMs - baseMs);\n}\n\nfunction convertUnit(num: number, unit: string): number {\n\tconst u = unit.toLowerCase();\n\tif (u === \"ms\") return Math.ceil(num);\n\tif (u === \"s\" || u === \"sec\" || u === \"second\" || u === \"seconds\") return Math.ceil(num * 1000);\n\treturn Math.ceil(num * 60_000); // m / min / minute / minutes\n}\n\n/** Recursively walk JSON, calling fn on every leaf value with its key. */\nfunction scanValue(\n\tvalue: unknown,\n\tfn: (v: string | number | boolean | null, key?: string) => boolean,\n\tkey?: string,\n): boolean {\n\tif (value === null) return fn(null, key);\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") return fn(value, key);\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tif (scanValue(item, fn, key)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\tif (typeof value === \"object\") {\n\t\tfor (const [k, v] of Object.entries(value)) {\n\t\t\tif (scanValue(v, fn, k)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\treturn false;\n}\n\nfunction tryParseJSON(text: string): unknown {\n\t// strip SSE data: prefix lines\n\tconst cleaned = text.replace(/^data:\\s*/gm, \"\").trim();\n\tif (!cleaned.startsWith(\"{\") && !cleaned.startsWith(\"[\")) return undefined;\n\ttry {\n\t\treturn JSON.parse(cleaned);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/* ---------- main extractor ---------- */\n\nexport function extract429RetryAfterMs(input: RetryHintInput, nowMs?: number): number | undefined {\n\tconst now = nowMs ?? Date.now();\n\n\tif (!isRateLimited(input.status, input.bodyText)) return undefined;\n\n\t// 1. retry-after-ms header\n\tconst fromMs = fromRetryAfterMsHeader(input.headers);\n\tif (fromMs !== undefined) return fromMs;\n\n\t// 2. retry-after header\n\tconst fromRa = fromRetryAfterHeader(input.headers, now);\n\tif (fromRa !== undefined) return fromRa;\n\n\t// 3. x-ratelimit-reset* headers\n\tconst fromXrl = fromXRateLimitReset(input.headers, now);\n\tif (fromXrl !== undefined) return fromXrl;\n\n\t// 4. JSON retryDelay\n\tconst fromJson = fromJsonRetryDelay(input.bodyText);\n\tif (fromJson !== undefined) return fromJson;\n\n\t// 5. body prose\n\treturn fromBodyProse(input.bodyText, now);\n}\n\n/* ---------- marker helpers ---------- */\n\nexport function appendRetryAfterMsMarker(message: string, hintMs: number): string {\n\treturn `${message} (retry-after-ms: ${hintMs})`;\n}\n\nexport function parseRetryAfterMsMarker(message: string): number | undefined {\n\tconst m = message.match(MARKER_RE);\n\tif (!m) return undefined;\n\treturn Number.parseInt(m[1], 10);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/backoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW3G"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backoff.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/backoff.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA0B,EAAE,WAAmB,EAAE,MAAc;IAClG,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IAClF,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAC7G,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5B,KAAK,MAAM;YACV,OAAO,MAAM,CAAC;QACf,KAAK,UAAU;YACd,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;QACvD,KAAK,aAAa;YACjB,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;IACxD,CAAC;AACF,CAAC","sourcesContent":["import type { RetryBackoffPolicy } from \"./types.ts\";\n\n/**\n * Pure per-attempt retry delay for a stage's backoff policy.\n *\n * The exponential base is `baseDelayMs * growthFactor ** (retryNumber - 1)`\n * with `retryNumber` 1-based. The per-attempt cap is applied to that base\n * BEFORE jitter (`null` = no cap, `0` = literal zero cap), then the jitter\n * mode scales the capped value by the injected `random` sample in `[0, 1)`:\n * `none` returns the capped delay, `additive` grows it by up to `ratio`,\n * `subtractive` shrinks it by up to `ratio`. No `Math.random` here — callers\n * inject the sample so the schedule stays deterministic and testable.\n */\nexport function retryBackoffDelayMs(policy: RetryBackoffPolicy, retryNumber: number, random: number): number {\n\tconst exponential = policy.baseDelayMs * policy.growthFactor ** (retryNumber - 1);\n\tconst capped = policy.perAttemptCapMs === null ? exponential : Math.min(exponential, policy.perAttemptCapMs);\n\tswitch (policy.jitter.mode) {\n\t\tcase \"none\":\n\t\t\treturn capped;\n\t\tcase \"additive\":\n\t\t\treturn capped + random * policy.jitter.ratio * capped;\n\t\tcase \"subtractive\":\n\t\t\treturn capped - random * policy.jitter.ratio * capped;\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classifiers.d.ts","sourceRoot":"","sources":["../../../src/utils/retry-profile/classifiers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,eAAe,EAAgB,MAAM,YAAY,CAAC;AAqBrF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAoBjC,CAAC;AAsBF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,EAAE,eAwB3C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classifiers.js","sourceRoot":"","sources":["../../../src/utils/retry-profile/classifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG3E;;;;;GAKG;AACH,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE3G,SAAS,sBAAsB,CAAC,UAA8B;IAC7D,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpF,CAAC;AAED,SAAS,WAAW,CAAC,IAAW;IAC/B,MAAM,IA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kBG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAoB,CAAC,OAAO,EAAE,EAAE;IACzE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,OAAO,CAAC;QACb,KAAK,SAAS,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,iBAAiB,CAAC;QACvB,KAAK,cAAc;YAClB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAI,YAAY,KAAK,eAAe;QAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAErE,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAClE,IAAI,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,wCAAwC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAC/F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,YAAY,KAAK,WAAW;QAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAElE,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,uCAAuC,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACzG,OAAO,OAAO,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { classifyErrorMessage, USAGE_LIMIT_EXHAUSTION } from \"../retry.ts\";\nimport type { RetryClassification, RetryClassifier, RetryFailure } from \"./types.ts\";\n\n/**\n * Status codes Kimi's provider-request stage treats as retryable. 429 is its\n * own `rate-limited` verdict (the turn budget treats it through hint tiers);\n * the other whitelisted codes are ordinary `transient`. Every other status —\n * client errors and non-whitelisted 5xx alike — is `terminal`.\n */\nconst KIMI_RETRYABLE_STATUS_CODES: ReadonlySet<number> = new Set([408, 409, 429, 500, 502, 503, 504, 529]);\n\nfunction classifyKimiHttpStatus(statusCode: number | undefined): RetryClassification {\n\tif (statusCode === undefined || !KIMI_RETRYABLE_STATUS_CODES.has(statusCode)) {\n\t\treturn { verdict: \"terminal\" };\n\t}\n\treturn statusCode === 429 ? { verdict: \"rate-limited\" } : { verdict: \"transient\" };\n}\n\nfunction assertNever(kind: never): never {\n\tthrow new Error(`Unhandled retry failure kind: ${kind}`);\n}\n\n/**\n * Kimi provider-request classifier, ported from the source provider's retry\n * policy (policy only, not its code). The switch is exhaustive over\n * {@link RetryFailure}[\"kind\"]:\n *\n * - abort / refusal / sensitive / quota-exhausted / image-format / unknown are\n * terminal: user cancellations, content refusals, dead accounts, rejected\n * payloads, and unrecognized failures never recover by re-sending.\n * - connection / timeout / provider failures are transient transport noise.\n * - empty-response is transient unless the model said `finishReason` was\n * \"filtered\", which is a deterministic content rejection.\n * - http-status is retryable only for the whitelisted codes above.\n */\nexport const classifyKimiFailure: RetryClassifier = (failure) => {\n\tswitch (failure.kind) {\n\t\tcase \"abort\":\n\t\tcase \"refusal\":\n\t\tcase \"sensitive\":\n\t\tcase \"quota-exhausted\":\n\t\tcase \"image-format\":\n\t\tcase \"unknown\":\n\t\t\treturn { verdict: \"terminal\" };\n\t\tcase \"connection\":\n\t\tcase \"timeout\":\n\t\tcase \"provider\":\n\t\t\treturn { verdict: \"transient\" };\n\t\tcase \"empty-response\":\n\t\t\treturn failure.finishReason === \"filtered\" ? { verdict: \"terminal\" } : { verdict: \"transient\" };\n\t\tcase \"http-status\":\n\t\t\treturn classifyKimiHttpStatus(failure.statusCode);\n\t\tdefault:\n\t\t\treturn assertNever(failure.kind);\n\t}\n};\n\n/**\n * Structured status codes the senpi default classifier treats as retryable\n * when — and only when — the message regexes have no opinion. Mirrors the\n * transient half of Kimi's table plus the Cloudflare gateway codes senpi\n * already retries by regex.\n */\nconst SENPI_STRUCTURED_RETRYABLE_STATUS_CODES: ReadonlySet<number> = new Set([\n\t408, 409, 429, 500, 502, 503, 504, 522, 524, 529,\n]);\n\n/** Provider error codes that prove a dead account regardless of message text. */\nconst SENPI_STRUCTURED_TERMINAL_PROVIDER_CODES: ReadonlySet<string> = new Set([\n\t\"insufficient_quota\",\n\t\"credits_required\",\n\t// OpenAI hard account-quota exhaustion (senpi#1969). Declared once in\n\t// ../retry.ts as USAGE_LIMIT_EXHAUSTION and consumed here so the two\n\t// packages/ai lists cannot drift.\n\t...USAGE_LIMIT_EXHAUSTION.codes,\n]);\n\n/**\n * Senpi assistant-turn classifier: the existing message regexes decide first;\n * structured failure facts are consulted only where the regexes are silent.\n *\n * Precedence (terminal wins at every tie):\n * 1. Deterministic failure kinds (abort/refusal/sensitive/quota/image-format)\n * are terminal before any text inspection.\n * 2. A non-retryable regex match is terminal — request-shape and quota wording\n * outrank any structured status (a 500 carrying invalid-tool-schema text\n * stays terminal, unlike under {@link classifyKimiFailure}).\n * 3. Structured terminal facts (`shouldRetry: false`, quota provider codes).\n * 4. A retryable regex match is transient — e.g. a 400 carrying Anthropic's\n * server-tool pairing text stays retryable because the request builder\n * repairs the replayed history.\n * 5. Only when the regexes have no opinion does the structured status decide:\n * whitelisted transient codes retry, everything else is terminal.\n * 6. No regex match and no structured facts: terminal, exactly the legacy\n * boolean fallback.\n */\nexport const classifySenpiAssistantFailure: RetryClassifier = (failure) => {\n\tswitch (failure.kind) {\n\t\tcase \"abort\":\n\t\tcase \"refusal\":\n\t\tcase \"sensitive\":\n\t\tcase \"quota-exhausted\":\n\t\tcase \"image-format\":\n\t\t\treturn { verdict: \"terminal\" };\n\t}\n\n\tconst regexVerdict = classifyErrorMessage(failure.message);\n\tif (regexVerdict === \"non-retryable\") return { verdict: \"terminal\" };\n\n\tif (failure.shouldRetry === false) return { verdict: \"terminal\" };\n\tif (failure.providerCodes?.some((code) => SENPI_STRUCTURED_TERMINAL_PROVIDER_CODES.has(code))) {\n\t\treturn { verdict: \"terminal\" };\n\t}\n\n\tif (regexVerdict === \"retryable\") return { verdict: \"transient\" };\n\n\tif (failure.statusCode !== undefined && SENPI_STRUCTURED_RETRYABLE_STATUS_CODES.has(failure.statusCode)) {\n\t\treturn failure.statusCode === 429 ? { verdict: \"rate-limited\" } : { verdict: \"transient\" };\n\t}\n\treturn { verdict: \"terminal\" };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,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,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE3E,MAAM,iBAAiB,GAAG,OAAO,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5G,OAAO;QACN,MAAM,EAAE,oBAAoB;QAC5B,IAAI;QACJ,OAAO,EAAE,OAAO,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,YA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AC;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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,kBA2CzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBA4CrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAuB;IAC9D,EAAE,EAAE,eAAe;IACnB,eAAe,EAAE;QAChB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AU,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\t// 5 attempts matches opencode's session retry budget and codex's\n\t\t// stream_max_retries default for slow long-thinking providers.\n\t\tmaxRetries: 5,\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,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|
|
|
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/**\n * Ceiling on a server-requested wait for `override`-mode hint policies.\n *\n * On the turn stage this ceiling is profile-owned end to end: besides driving\n * the planner's `over-ceiling` verdict, an override-mode `maxDelayMs` also\n * governs the coding-agent session's agent-level wait clamp — `null` passes\n * every admitted wait through verbatim, a number is the profile's own cap, and\n * the session's `retry.maxAgentDelayMs` default applies only to profiles that\n * declare no ceiling of their own.\n */\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AAIxD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAUD;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;IAClC,+EAA+E;aAC/E,KAAK,YAAG,qBAAqB,EAAE,oBAAoB;IACnD,+EAA+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C5D,CAAC;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC/D,IAAI,OAAO,CAAC,WAAW,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACpD,IAAI,0BAA0B,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACrD,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrF,OAAO,wCAAwC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC3D,OAAO,oBAAoB,CAAC,YAAY,CAAC,KAAK,WAAW,CAAC;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACxD,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,IAAI,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;IACnD,IAAI,oCAAoC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,eAAe,CAAC;IAC5E,IAAI,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC;IACpE,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import type { AssistantMessage } from \"../types.ts\";\nimport { FORWARDED_EMPTY_RESPONSE_ERROR, FORWARDED_EMPTY_TOOL_USE_ERROR } from \"./empty-response-errors.ts\";\n\n// A provider's support request id is opaque hex like `C6FD:AB660:AEB5548:6ABA4D81`.\n// It can contain `429` or `500`, which message classifiers read as HTTP statuses,\n// so every id is rendered behind this marker and removed before classification.\nexport const PROVIDER_REQUEST_ID_MARKER = \"request id:\";\n\nconst REQUEST_ID_SEGMENT = /request id: [^\\s,;)]+/gi;\n\nexport function formatProviderRequestId(label: string, id: string): string {\n\treturn `${label} ${PROVIDER_REQUEST_ID_MARKER} ${id}`;\n}\n\nexport function stripProviderRequestIds(text: string): string {\n\treturn text.replace(REQUEST_ID_SEGMENT, PROVIDER_REQUEST_ID_MARKER);\n}\n\nfunction buildProviderErrorPattern(patterns: readonly string[]): RegExp {\n\treturn new RegExp(patterns.join(\"|\"), \"i\");\n}\n\nfunction escapeRegExp(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * OpenAI hard account-quota exhaustion (senpi#1969). The wire evidence is a 429\n * whose body is `{\"type\":\"usage_limit_reached\",\"message\":\"The usage limit has\n * been reached\"}`; `usage_not_included` is the sibling entitlement code. The\n * account cannot serve more requests until its quota resets or its plan changes,\n * so every consumer treats the family as terminal. Declared once here and\n * consumed by both the non-retryable pattern below and the structured terminal\n * provider codes in `retry-profile/classifiers.ts`, so the two lists cannot\n * drift.\n */\nexport const USAGE_LIMIT_EXHAUSTION = {\n\t/** Structured error codes, as extracted into `providerCodes` failure facts. */\n\tcodes: [\"usage_limit_reached\", \"usage_not_included\"],\n\t/** Message markers: the codes appear verbatim in bodies, plus the sentence. */\n\tmarkers: [\"usage_limit_reached\", \"usage_not_included\", \"usage limit has been reached\"],\n} as const;\n\n/**\n * Account quota, budget, credit, and billing exhaustion: the account cannot\n * serve more requests until the user pays or the quota resets. Shared by the\n * terminal classifier below and the fallback circuit breaker, so both recognise\n * the same exhaustion wording.\n */\nconst QUOTA_EXHAUSTION_PATTERNS = [\n\t// OpenCode Go/free-tier limits returned as 429 JSON error types by OpenCode's\n\t// Zen API. These are subscription/account limits, not transient throttles.\n\t\"GoUsageLimitError\",\n\t\"FreeUsageLimitError\",\n\n\t// OpenCode Go subscription-limit text asks users to enable available-balance\n\t// usage after rolling/weekly/monthly limits are reached.\n\t\"Monthly usage limit reached\",\n\t\"available balance\",\n\n\t// Generic quota/budget/billing exhaustion. `insufficient_quota` is OpenAI's\n\t// quota/billing error code; the other strings cover common gateway wording.\n\t\"insufficient_quota\",\n\t\"out of budget\",\n\t\"quota exceeded\",\n\t\"billing\",\n\n\t// Anthropic Console credit exhaustion: a 429 rate_limit_error whose details\n\t// carry error_code credits_required (\"Usage credits are required for this\n\t// model.\"). The account is dead until the user buys credits or raises the\n\t// spend limit, so same-model retries can never recover it.\n\t\"credits_required\",\n\t\"credits are required\",\n\n\t// OpenAI hard account-quota exhaustion (senpi#1969): the 429 body carries\n\t// `usage_limit_reached` / \"The usage limit has been reached\", and the account\n\t// stays dead until its quota resets — every same-account retry is guaranteed\n\t// to fail, so the failure is terminal, not rate-limited.\n\t...USAGE_LIMIT_EXHAUSTION.markers,\n] as const;\n\nconst QUOTA_EXHAUSTION_PATTERN = buildProviderErrorPattern(QUOTA_EXHAUSTION_PATTERNS);\n\nexport function isQuotaExhaustionMessage(errorMessage: string | undefined): boolean {\n\treturn errorMessage !== undefined && QUOTA_EXHAUSTION_PATTERN.test(stripProviderRequestIds(errorMessage));\n}\n\nconst NON_RETRYABLE_PROVIDER_ERROR_PATTERN = buildProviderErrorPattern([\n\t...QUOTA_EXHAUSTION_PATTERNS,\n\n\t// Request-shape rejections: the provider refused the payload we built, not the\n\t// work it describes. Gateways wrap these in whatever status they like — the\n\t// observed Apitopia/Kimi case arrives as `500 server_error: Invalid request:\n\t// tools.function.parameters.type is required and must be \"object\"` — so the\n\t// status text alone would classify a permanent failure as transient. The same\n\t// bytes are rejected on every attempt and on every fallback model, so retrying\n\t// can only burn the turn. Anchored on the `tools[...]`/`functions[...]` request\n\t// path so unrelated prose mentioning tools stays retryable.\n\t\"invalid request: tools\\\\.\",\n\t\"invalid request: functions\\\\.\",\n\t\"tools\\\\.[^ ]*function\\\\.parameters\",\n\t\"tools\\\\.\\\\d+\\\\.function\\\\.parameters\",\n\t\"invalid tool schema\",\n]);\n\nconst RETRYABLE_PROVIDER_ERROR_PATTERN = buildProviderErrorPattern([\n\t// Local credential/auth sidecar lock exhaustion is infrastructure contention,\n\t// not a provider failure and must stay on the transient retry path.\n\t\"Credential store is busy: lock\",\n\t// Generic provider load, HTTP status, and server-side transient failures.\n\t\"overloaded\",\n\t\"rate.?limit\",\n\t\"too many requests\",\n\t\"429\",\n\t\"500\",\n\t\"502\",\n\t\"503\",\n\t\"504\",\n\t// Cloudflare 522 (Connection timed out): origin stopped responding; transient\n\t// like the other 5xx gateway statuses, surfaced as \"Error: error code: 522\".\n\t\"522\",\n\t\"524\",\n\t\"service.?unavailable\",\n\t\"server.?error\",\n\t\"internal.?error\",\n\n\t// Wrapper/provider text for transient upstream failures, including OpenRouter\n\t// \"Provider returned error\" responses (#2264).\n\t\"provider.?returned.?error\",\n\t\"exceeded request buffer limit while retrying upstream\",\n\n\t// Network, proxy, and fetch transport failures. This includes OpenAI Codex\n\t// raw-fetch failures such as \"upstream connect\", \"connection refused\", and\n\t// \"reset before headers\" (#733), plus OpenRouter connection drops (#3317).\n\t\"network.?error\",\n\t\"connection.?error\",\n\t\"connection.?refused\",\n\t\"connection.?lost\",\n\t\"other side closed\",\n\t\"fetch failed\",\n\t\"getaddrinfo\",\n\t\"ENOTFOUND\",\n\t\"EAI_AGAIN\",\n\t\"upstream.?connect\",\n\t\"upstream.?unavailable\",\n\t\"reset before headers\",\n\t\"socket hang up\",\n\t\"socket connection was closed\",\n\t\"timed? out\",\n\t\"timeout\",\n\t\"terminated\",\n\n\t// WebSocket transports can report close/error text instead of HTTP/fetch text.\n\t\"websocket.?closed\",\n\t\"websocket.?error\",\n\n\t// Premature stream endings from SDKs and transports. Anthropic can throw\n\t// \"stream ended without ...\" and \"Anthropic stream ended before message_stop\"\n\t// (#4433); Bedrock/Smithy can throw an HTTP/2 no-response error (#3594).\n\t\"ended without\",\n\t\"stream ended before message_stop\",\n\t\"stream ended before a terminal response event\",\n\t\"http2 request did not get a response\",\n\n\t// Provider-requested retry delay cap failures should flow through the outer\n\t// retry policy so callers can surface/abort the backoff (#1123).\n\t\"retry delay\",\n\n\t// Explicit retry guidance emitted mid-stream by OpenAI Responses and Bedrock\n\t// stream exceptions (#6019).\n\t\"you can retry your request\",\n\t\"try your request again\",\n\t\"please retry your request\",\n\n\t// Gateway/proxy-side rejection of the whole model request, e.g. \"Error: The\n\t// model request was rejected. Check the request and try again.\" (observed in a\n\t// live session, 2026-08-11). Coupling the rejection sentence to its explicit\n\t// retry instruction keeps unrelated permission, request-shape, and content-\n\t// policy rejections terminal while the bounded retry policy absorbs this\n\t// transient wrapper wording.\n\t\"the model request was rejected\\\\.\\\\s*check the request and try again\\\\.?\",\n\n\t// Anthropic server-tool pairing rejections, e.g. \"`web_search` tool use with id\n\t// `srvtoolu_...` was found without a corresponding `web_search_tool_result`\n\t// block\". A turn closed before its deferred server tool could answer leaves\n\t// the unpairable half in history, and replaying it 400s every later request.\n\t// The Anthropic request builder repairs the replayed history, so a retry sends\n\t// a valid payload; keeping the class retryable is what lets retry and the model\n\t// fallback chain unwedge such a session instead of dead-ending it. The trailing\n\t// backtick keeps the pattern on Anthropic's pairing-error template.\n\t\"was found without a corresponding `\",\n\n\t// Replayed-reasoning rejections, e.g. \"the reasoning_details at position 1271 entry 0\n\t// must not contain streaming index\". A gateway refuses an input reasoning entry that\n\t// still carries the streaming-assembly `index`, and because the merged array is\n\t// persisted in the assistant block, every later request in that conversation is\n\t// rejected identically. The openai-completions request builder strips the field before\n\t// the retried request is built, so the retry sends a valid payload; same reasoning as\n\t// the pairing class above, and the retry stays bounded by the policy's attempt budget.\n\t\"must not contain streaming index\",\n\n\t// An empty stop or tool_use-without-tool-call on a model whose reasoning had already streamed\n\t// live. The stream-level wrapper (pi-agent-core empty-assistant-recovery) cannot replay such an\n\t// attempt, so it ends the turn with these exact texts for the turn retry to re-request; the\n\t// \"twice\" variants are deliberately absent because the wrapper already spent its own retry.\n\tescapeRegExp(FORWARDED_EMPTY_RESPONSE_ERROR),\n\tescapeRegExp(FORWARDED_EMPTY_TOOL_USE_ERROR),\n\n\t// gRPC based providers (e.g. NVIDIA NIM)\n\t\"ResourceExhausted\",\n\n\t// Claude Agent SDK session.json lock contention. A second stream/resume\n\t// hits proper-lockfile while the previous subprocess still holds the file.\n\t// Same-process retry recovers; hopping providers cannot release that lock.\n\t\"Lock file is already being held\",\n]);\n\n/**\n * Retry policy: bounded attempts with exponential backoff (`baseDelayMs * 2^(attempt-1)`).\n * `maxAgentDelayMs` caps each computed delay and defaults to 60 seconds.\n * Matches `settings.retry` (`enabled`, `maxRetries`, `baseDelayMs`, `maxAgentDelayMs`) in coding-agent; kept\n * here so the classifier and the policy-driven retry loop live together and stay reusable\n * by the SDK and other callers.\n */\nexport interface RetryPolicy {\n\tenabled: boolean;\n\t/** Max retry attempts (0 = no retries). The initial call never counts as a retry. */\n\tmaxRetries: number;\n\t/** Base delay in ms. Per-attempt delay is `baseDelayMs * 2^(attempt-1)` before jitter. */\n\tbaseDelayMs: number;\n\t/** Optional cap for agent-level retry delays in ms. Defaults to 60 seconds. */\n\tmaxAgentDelayMs?: number;\n\t/** Injectable source used for Codex-style +/-10% backoff jitter. */\n\trandom?: () => number;\n}\n\nexport const DEFAULT_MAX_AGENT_RETRY_DELAY_MS = 60_000;\n\n/**\n * Per-attempt backoff: `baseDelayMs * 2^(attempt-1)`, jittered by +/-10% through the\n * injectable `random` source, then clamped to `maxAgentDelayMs` (60s by default). The\n * jitter runs before the clamp so a capped delay stays exactly at the cap instead of\n * scattering above it, and the safe-integer guard keeps a large `attempt` from producing\n * `Infinity` before the clamp.\n */\nexport function retryDelayMs(\n\tpolicy: Pick<RetryPolicy, \"baseDelayMs\" | \"maxAgentDelayMs\" | \"random\">,\n\tattempt: number,\n): number {\n\tconst scheduledDelayMs = policy.baseDelayMs * 2 ** Math.max(0, attempt - 1);\n\tconst sample = Math.min(1, Math.max(0, (policy.random ?? Math.random)()));\n\tconst jitteredDelayMs = Math.round(scheduledDelayMs * (0.9 + sample * 0.2));\n\tconst safeDelay = Number.isSafeInteger(jitteredDelayMs) ? jitteredDelayMs : Number.MAX_SAFE_INTEGER;\n\treturn Math.min(safeDelay, policy.maxAgentDelayMs ?? DEFAULT_MAX_AGENT_RETRY_DELAY_MS);\n}\n\n/** Optional callbacks emitted by {@link retryAssistantCall} around each retry. */\nexport interface RetryCallbacks {\n\t/** Emitted before the backoff sleep of each retry attempt (1-indexed). */\n\tonRetryScheduled?: (\n\t\tattempt: number,\n\t\tmaxAttempts: number,\n\t\tdelayMs: number,\n\t\terrorMessage: string,\n\t) => void | Promise<void>;\n\t/** Emitted after the backoff sleep, immediately before the retried call starts. */\n\tonRetryAttemptStart?: () => void | Promise<void>;\n\t/** Emitted once when the loop ends: success if a later call completed normally. */\n\tonRetryFinished?: (success: boolean, attempt: number, finalError?: string) => void | Promise<void>;\n}\n\nclass RetrySleepAbortError extends Error {\n\tconstructor() {\n\t\tsuper(\"Aborted\");\n\t}\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new RetrySleepAbortError());\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\treject(new RetrySleepAbortError());\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n\n/**\n * Run a producer that signals failure by THROWING, with the same bounded\n * backoff, abort, and callback semantics as {@link retryAssistantCall}.\n *\n * `retryAssistantCall` is value-based: its producer reports failure by resolving\n * an `AssistantMessage` with `stopReason: \"error\"`. Callers that instead reject\n * (compaction summarization, and any other request pipeline that throws) need\n * the identical retry policy without reshaping their failures into assistant\n * messages first, so both live here and share one implementation of the delay,\n * abort, and callback contract.\n *\n * Behavior:\n * - A resolved value is returned immediately.\n * - A throw that `isRetryable` rejects is rethrown at once: deterministic\n * failures never spend a retry.\n * - Otherwise the call is retried up to `policy.maxRetries` times with the same\n * exponential backoff (`baseDelayMs * 2^(attempt-1)`), rethrowing the final\n * error when the budget is exhausted.\n * - An abort during the backoff sleep stops the loop and rethrows; unlike the\n * assistant-message path there is no aborted value to normalize to.\n *\n * When `policy` is undefined or disabled the producer runs exactly once and its\n * error propagates unchanged.\n */\nexport async function retryTransientCall<T>(\n\tproduce: () => Promise<T>,\n\tisRetryable: (error: unknown) => boolean,\n\tpolicy: RetryPolicy | undefined,\n\tsignal: AbortSignal | undefined,\n\tcallbacks?: RetryCallbacks,\n): Promise<T> {\n\tconst maxAttempts = policy?.enabled ? policy.maxRetries : 0;\n\n\tlet attempt = 0;\n\tlet lastRetry: { attempt: number; errorMessage: string } | undefined;\n\tfor (;;) {\n\t\ttry {\n\t\t\tconst value = await produce();\n\t\t\tif (lastRetry) await callbacks?.onRetryFinished?.(true, lastRetry.attempt);\n\t\t\treturn value;\n\t\t} catch (error) {\n\t\t\tif (error instanceof RetrySleepAbortError) throw error;\n\t\t\tif (attempt >= maxAttempts || !isRetryable(error)) {\n\t\t\t\tif (lastRetry) {\n\t\t\t\t\tawait callbacks?.onRetryFinished?.(false, lastRetry.attempt, errorMessageOf(error));\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tattempt++;\n\t\t\tlastRetry = { attempt, errorMessage: errorMessageOf(error) };\n\t\t\tconst delayMs = retryDelayMs(policy!, attempt);\n\t\t\tawait callbacks?.onRetryScheduled?.(attempt, maxAttempts, delayMs, lastRetry.errorMessage);\n\n\t\t\ttry {\n\t\t\t\tawait sleep(delayMs, signal);\n\t\t\t} catch (sleepError) {\n\t\t\t\tawait callbacks?.onRetryFinished?.(false, attempt, lastRetry.errorMessage);\n\t\t\t\tthrow sleepError instanceof RetrySleepAbortError ? error : sleepError;\n\t\t\t}\n\t\t\tawait callbacks?.onRetryAttemptStart?.();\n\t\t}\n\t}\n}\n\nfunction errorMessageOf(error: unknown): string {\n\tif (error instanceof Error) return error.message || \"Unknown error\";\n\treturn String(error) || \"Unknown error\";\n}\n\n/**\n * Run a single assistant-producing call with bounded retry on transient errors.\n *\n * Behavior:\n * - A successful response is returned immediately. Aborts are terminal and never\n * retried, but reported as unsuccessful if they happen after a retry was scheduled.\n * Aborts during the backoff sleep are normalized to an aborted `AssistantMessage`\n * too, so callers do not need to care when cancellation happened.\n * - A non-retryable error (per {@link isRetryableAssistantError}, including quota/\n * billing exhaustion) is returned immediately so deterministic errors fail fast.\n * - Otherwise retries up to `maxRetries` times with exponential backoff, emitting\n * `onRetryScheduled` before each sleep, `onRetryAttemptStart` after each sleep before\n * the retried call starts, and `onRetryFinished` once at the end (whether the loop\n * ends in success, exhausted retries, or an aborted backoff).\n *\n * When `policy` is undefined or disabled, the first response is returned unchanged\n * (equivalent to calling `produce()` directly).\n */\nexport async function retryAssistantCall(\n\tproduce: () => Promise<AssistantMessage>,\n\tpolicy: RetryPolicy | undefined,\n\tsignal: AbortSignal | undefined,\n\tcallbacks?: RetryCallbacks,\n): Promise<AssistantMessage> {\n\tconst maxAttempts = policy?.enabled ? policy.maxRetries : 0;\n\n\tlet attempt = 0;\n\tlet lastRetry: { attempt: number; errorMessage: string } | undefined;\n\tfor (;;) {\n\t\tconst response = await produce();\n\n\t\t// Abort: terminal but not successful. Never retry an aborted message.\n\t\tif (response.stopReason === \"aborted\") {\n\t\t\tif (lastRetry) await callbacks?.onRetryFinished?.(false, lastRetry.attempt);\n\t\t\treturn response;\n\t\t}\n\n\t\t// Success: non-error, non-abort responses return as-is.\n\t\tif (response.stopReason !== \"error\") {\n\t\t\tif (lastRetry) await callbacks?.onRetryFinished?.(true, lastRetry.attempt);\n\t\t\treturn response;\n\t\t}\n\n\t\t// Non-retryable, or budget exhausted: return the final error message.\n\t\tif (attempt >= maxAttempts || !isRetryableAssistantError(response)) {\n\t\t\tif (lastRetry) await callbacks?.onRetryFinished?.(false, lastRetry.attempt, response.errorMessage);\n\t\t\treturn response;\n\t\t}\n\n\t\tattempt++;\n\t\tlastRetry = { attempt, errorMessage: response.errorMessage || \"Unknown error\" };\n\t\tconst delayMs = retryDelayMs(policy!, attempt);\n\t\tawait callbacks?.onRetryScheduled?.(attempt, maxAttempts, delayMs, lastRetry.errorMessage);\n\n\t\t// Normalize aborts during retry backoff to the same AssistantMessage shape as\n\t\t// provider stream aborts, so callers do not need to care when cancellation happened.\n\t\ttry {\n\t\t\tawait sleep(delayMs, signal);\n\t\t} catch (error) {\n\t\t\tawait callbacks?.onRetryFinished?.(false, attempt, lastRetry.errorMessage);\n\t\t\tif (error instanceof RetrySleepAbortError) {\n\t\t\t\tconst { errorMessage: _errorMessage, ...rest } = response;\n\t\t\t\treturn { ...rest, stopReason: \"aborted\" };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tawait callbacks?.onRetryAttemptStart?.();\n\t}\n}\n\n/**\n * Classifies whether a failed assistant message looks like a transient provider\n * or transport error, so callers can decide if the last assistant turn should be\n * restarted.\n *\n * This does not implement retry policy. Callers should first handle context\n * overflow separately, then apply their own retry budget, backoff, and reporting\n * before restarting the assistant turn.\n */\nexport function isRetryableAssistantError(message: AssistantMessage): boolean {\n\tif (\n\t\tmessage.stopReason !== \"error\" ||\n\t\tmessage.stopDetails?.type === \"refusal\" ||\n\t\tmessage.stopDetails?.type === \"sensitive\" ||\n\t\t!message.errorMessage\n\t) {\n\t\treturn false;\n\t}\n\treturn isRetryableErrorMessage(message.errorMessage);\n}\n\n/**\n * Matches the agent-loop stream watchdog failures (\"Idle timeout waiting for\n * provider stream after <n>ms\" and \"Provider stream start timed out after\n * <n>ms\"), the WebSocket liveness verdict (\"WebSocket liveness timeout after\n * <n>ms (<k> pings unanswered)\"), and the Responses completion-phase verdict\n * (\"Provider stream stalled after the last output item: response.completed\n * timed out after <n>ms\"). These anchored shapes\n * distinguish provider-stream stalls from unrelated extension, command, or MCP\n * timeout diagnostics.\n */\nconst PROVIDER_STREAM_STALL_ERROR_PATTERN =\n\t/^(?:Idle timeout waiting for provider stream after \\d+ms|Provider stream start timed out after \\d+ms(?: \\([^)]*\\))?|WebSocket liveness timeout after \\d+ms \\(\\d+ pings unanswered\\)|Provider stream stalled after the last output item: response\\.completed timed out after \\d+ms)$/i;\nconst PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN = /^Request timed out\\.?$/i;\n\nexport function isProviderStreamStallError(message: AssistantMessage): boolean {\n\treturn message.stopReason === \"error\" && PROVIDER_STREAM_STALL_ERROR_PATTERN.test(message.errorMessage ?? \"\");\n}\n\n/** One row per stall watchdog: how to read its message, and how to explain it. */\nconst PROVIDER_STALL_PHASES: ReadonlyArray<{\n\tpattern: RegExp;\n\t/** What the provider failed to do, in the user's words. */\n\tsymptom: string;\n\t/** The setting that widens this bound, when one exists. */\n\tsetting?: string;\n}> = [\n\t{\n\t\tpattern: /^Provider stream start timed out after (\\d+)ms/i,\n\t\tsymptom: \"accepted the request but never started sending a response\",\n\t\tsetting: \"retry.provider.streamStartTimeoutMs\",\n\t},\n\t{\n\t\tpattern: /^Idle timeout waiting for provider stream after (\\d+)ms/i,\n\t\tsymptom: \"started the response and then went silent\",\n\t\tsetting: \"retry.provider.timeoutMs\",\n\t},\n\t{\n\t\tpattern: /^WebSocket liveness timeout after (\\d+)ms/i,\n\t\tsymptom: \"stopped answering connection health checks\",\n\t},\n\t{\n\t\tpattern: /^Provider stream stalled after the last output item: response\\.completed timed out after (\\d+)ms/i,\n\t\tsymptom: \"finished its output but never sent the end-of-response event\",\n\t},\n];\n\nexport interface ProviderStallDescriptionOptions {\n\t/** Same-model attempts already spent on this turn. */\n\tattempts?: number;\n\t/** Selector of the model that stalled, for example `anthropic/claude-opus-5`. */\n\tmodel?: string;\n\t/**\n\t * Appends the \"what to do next\" sentence. Omit it while the turn can still\n\t * recover: a retry in flight is not the moment to tell the user to act.\n\t */\n\trecovery?: \"no-fallback-configured\" | \"chain-exhausted\";\n}\n\nexport function formatStallDuration(timeoutMs: number): string {\n\tif (timeoutMs < 1000) return `${timeoutMs}ms`;\n\tif (timeoutMs < 120_000) return `${Math.round(timeoutMs / 100) / 10}s`;\n\treturn `${Math.round(timeoutMs / 6000) / 10}m`;\n}\n\n/**\n * Plain-language replacement for a stall watchdog's own `Error.message`.\n *\n * The watchdog wording (`Provider stream start timed out after 180000ms ...`)\n * is a classifier token - {@link isProviderStreamStallError} and the turn retry\n * gate both match on it - so it must stay on the assistant message. It was also\n * the only thing the user ever saw when a turn died on a stall, which explains\n * nothing and names no next step (senpi#1740). Every user-facing surface routes\n * the message through here first and falls back to the raw text for anything\n * that is not a stall.\n */\nexport function describeProviderStallForUser(\n\terrorMessage: string | undefined,\n\toptions: ProviderStallDescriptionOptions = {},\n): string | undefined {\n\tif (!errorMessage) return undefined;\n\tfor (const { pattern, symptom, setting } of PROVIDER_STALL_PHASES) {\n\t\tconst match = pattern.exec(errorMessage);\n\t\tif (!match) continue;\n\t\tconst subject = options.model ? `The provider for ${options.model}` : \"The provider\";\n\t\tconst duration = formatStallDuration(Number(match[1]));\n\t\tconst sentences = [`${subject} ${symptom} within ${duration}, so the request was cancelled.`];\n\t\tconst attempts = options.attempts ?? 0;\n\t\tif (attempts > 0) {\n\t\t\tsentences.push(`Retried ${attempts} time${attempts === 1 ? \"\" : \"s\"} on the same model with the same result.`);\n\t\t}\n\t\tif (options.recovery) {\n\t\t\tconst raise = setting ? `, or raise ${setting} in settings (0 disables the bound)` : \"\";\n\t\t\tconst lead =\n\t\t\t\toptions.recovery === \"no-fallback-configured\"\n\t\t\t\t\t? \"No fallback model is configured for it, so nothing could take the turn over: run /fallback to add one\"\n\t\t\t\t\t: \"Every model in its fallback chain was tried as well: run /fallback to review the chain\";\n\t\t\tsentences.push(`${lead}, send the message again${raise}.`);\n\t\t}\n\t\treturn sentences.join(\" \");\n\t}\n\treturn undefined;\n}\n\n/**\n * Classifies timeout failures that originate from the provider stream or its\n * transport. Transport timeouts may arrive as `aborted`; stream watchdog\n * failures are ordinary error responses.\n */\nexport function isProviderTimeoutError(message: AssistantMessage): boolean {\n\tif (message.abortSource === \"provider\") return true;\n\tif (isProviderStreamStallError(message)) return true;\n\tif (message.stopReason !== \"error\" && message.stopReason !== \"aborted\") return false;\n\treturn PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN.test(message.errorMessage ?? \"\");\n}\n\n/**\n * Classifies a raw error-message string with the same transient-vs-terminal\n * rules as {@link isRetryableAssistantError}, for callers that hold a thrown\n * `Error` instead of an `AssistantMessage` (e.g. compaction summarization\n * failures that must decide between degrading and surfacing loudly).\n */\nexport function isRetryableErrorMessage(errorMessage: string): boolean {\n\treturn classifyErrorMessage(errorMessage) === \"retryable\";\n}\n\n/**\n * Tri-state form of {@link isRetryableErrorMessage}. The regexes only carry\n * three outcomes — a non-retryable match, a retryable match, or no match at\n * all — and callers that hold structured failure facts (status codes, provider\n * error codes) need to distinguish \"the regexes say terminal\" from \"the\n * regexes say nothing\" so they can consult the structured facts only in the\n * latter case. Non-retryable still outranks retryable, exactly as before.\n */\nexport function classifyErrorMessage(errorMessage: string): \"non-retryable\" | \"retryable\" | \"unknown\" {\n\tif (!errorMessage) return \"unknown\";\n\tconst text = stripProviderRequestIds(errorMessage);\n\tif (NON_RETRYABLE_PROVIDER_ERROR_PATTERN.test(text)) return \"non-retryable\";\n\tif (RETRYABLE_PROVIDER_ERROR_PATTERN.test(text)) return \"retryable\";\n\treturn \"unknown\";\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize-unicode.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize-unicode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize-unicode.js","sourceRoot":"","sources":["../../src/utils/sanitize-unicode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,iFAAiF;IACjF,iFAAiF;IACjF,OAAO,IAAI,CAAC,OAAO,CAAC,yEAAyE,EAAE,EAAE,CAAC,CAAC;AACpG,CAAC","sourcesContent":["/**\n * Removes unpaired Unicode surrogate characters from a string.\n *\n * Unpaired surrogates (high surrogates 0xD800-0xDBFF without matching low surrogates 0xDC00-0xDFFF,\n * or vice versa) cause JSON serialization errors in many API providers.\n *\n * Valid emoji and other characters outside the Basic Multilingual Plane use properly paired\n * surrogates and will NOT be affected by this function.\n *\n * @param text - The text to sanitize\n * @returns The sanitized text with unpaired surrogates removed\n *\n * @example\n * // Valid emoji (properly paired surrogates) are preserved\n * sanitizeSurrogates(\"Hello 🙈 World\") // => \"Hello 🙈 World\"\n *\n * // Unpaired high surrogate is removed\n * const unpaired = String.fromCharCode(0xD83D); // high surrogate without low\n * sanitizeSurrogates(`Text ${unpaired} here`) // => \"Text here\"\n */\nexport function sanitizeSurrogates(text: string): string {\n\t// Replace unpaired high surrogates (0xD800-0xDBFF not followed by low surrogate)\n\t// Replace unpaired low surrogates (0xDC00-0xDFFF not preceded by high surrogate)\n\treturn text.replace(/[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g, \"\");\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-fallback-receipt.d.ts","sourceRoot":"","sources":["../../src/utils/server-fallback-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAG3D,eAAO,MAAM,kCAAkC,4BAA4B,CAAC;AAC5E,eAAO,MAAM,6BAA6B,0CAA0C,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC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GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAyB,EAAE,OAA8B;IACjG,MAAM,WAAW,GAAG,gCAAgC,CAAC,OAAO,CAAC,CAAC;IAC9D,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;IACrB,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC;IAC7B,OAAO,CAAC,WAAW,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IACvD,OAAO,CAAC,YAAY,GAAG,WAAW,CAAC;IACnC,gCAAgC,CAAC,OAAO,EAAE;QACzC,IAAI,EAAE,kCAAkC;QACxC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE;KAC/C,CAAC,CAAC;IACH,gCAAgC,CAAC,OAAO,EAAE;QACzC,IAAI,EAAE,6BAA6B;QACnC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,EAAE,MAAM,EAAE,wDAAwD,EAAE;KAC7E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { AssistantMessage, Model } from \"../types.ts\";\nimport { appendAssistantMessageDiagnostic } from \"./diagnostics.ts\";\n\nexport const SERVER_FALLBACK_ABORTED_DIAGNOSTIC = \"server_fallback_aborted\";\nexport const BILLING_INCOMPLETE_DIAGNOSTIC = \"billing_incomplete_after_client_abort\";\n\nexport interface ServerFallbackReceipt {\n\treadonly from: string;\n\treadonly to: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readModel(value: unknown): string | undefined {\n\tif (!isRecord(value)) return undefined;\n\treturn typeof value.model === \"string\" && value.model.length > 0 ? value.model : undefined;\n}\n\n/**\n * Anthropic marks a classifier handoff with `{type:\"fallback\", from:{model}, to:{model}}`\n * (`server-side-fallback-*` betas). Returns undefined for anything else, so an\n * unrelated or malformed provider-native block falls through to normal handling.\n */\nexport function parseServerFallbackReceipt(block: unknown): ServerFallbackReceipt | undefined {\n\tif (!isRecord(block) || block.type !== \"fallback\") return undefined;\n\tconst from = readModel(block.from);\n\tconst to = readModel(block.to);\n\treturn from !== undefined && to !== undefined ? { from, to } : undefined;\n}\n\n/**\n * Sticky routing serves later turns of a fallen-back conversation from the\n * substitute model with no `fallback` block at all; a `fallback_message` entry\n * in `usage.iterations` is the documented signal. A served-model string\n * comparison is deliberately NOT used: gateways and Bedrock-style endpoints\n * rewrite model ids, so a mismatch is not evidence of a fallback.\n */\nexport function parseStickyFallbackReceipt(\n\tusage: unknown,\n\trequestedModel: string,\n\tservedModel?: string,\n): ServerFallbackReceipt | undefined {\n\tif (!isRecord(usage) || !Array.isArray(usage.iterations)) return undefined;\n\tfor (let index = usage.iterations.length - 1; index >= 0; index--) {\n\t\tconst entry: unknown = usage.iterations[index];\n\t\tif (!isRecord(entry) || entry.type !== \"fallback_message\") continue;\n\t\tconst entryModel = typeof entry.model === \"string\" && entry.model.length > 0 ? entry.model : undefined;\n\t\tconst to = entryModel ?? servedModel;\n\t\treturn to !== undefined ? { from: requestedModel, to } : undefined;\n\t}\n\treturn undefined;\n}\n\nexport function serverFallbackRefusalExplanation(receipt: ServerFallbackReceipt): string {\n\treturn `Server-side fallback (${receipt.from} -> ${receipt.to}) aborted by client policy`;\n}\n\nexport function applyServerFallbackContinuation(\n\tmessage: AssistantMessage,\n\tmodel: Model<\"anthropic-messages\">,\n\treceipt: ServerFallbackReceipt,\n): Model<\"anthropic-messages\"> {\n\t// Keep source indices stable for stream projections while making abandoned\n\t// client calls audit-only before the agent can execute the completed message.\n\tfor (const [index, block] of message.content.entries()) {\n\t\tif (block.type === \"toolCall\") {\n\t\t\tmessage.content[index] = { type: \"providerNative\", subtype: \"discarded_tool_call\", raw: block };\n\t\t}\n\t}\n\tmessage.model = receipt.to;\n\tconst fallback = model.compat?.allowedFallbackModels?.find(\n\t\t(candidate) =>\n\t\t\ttypeof candidate !== \"string\" && candidate.provider === model.provider && candidate.model === receipt.to,\n\t);\n\treturn {\n\t\t...model,\n\t\tid: receipt.to,\n\t\tcost: fallback && typeof fallback !== \"string\" ? fallback.cost : model.cost,\n\t};\n}\n\n/**\n * Rewrites an aborted turn into the same shape a pre-output classifier refusal\n * has, so `isClassifierRefusal()` routes it through the caller's fallback chain.\n * Content is dropped: the substitute model's partial output was never requested,\n * and replaying a half-turn containing a fallback marker breaks Anthropic replay.\n */\nexport function applyServerFallbackAbort(message: AssistantMessage, receipt: ServerFallbackReceipt): void {\n\tconst explanation = serverFallbackRefusalExplanation(receipt);\n\tmessage.content = [];\n\tmessage.stopReason = \"error\";\n\tmessage.stopDetails = { type: \"refusal\", explanation };\n\tmessage.errorMessage = explanation;\n\tappendAssistantMessageDiagnostic(message, {\n\t\ttype: SERVER_FALLBACK_ABORTED_DIAGNOSTIC,\n\t\ttimestamp: Date.now(),\n\t\tdetails: { from: receipt.from, to: receipt.to },\n\t});\n\tappendAssistantMessageDiagnostic(message, {\n\t\ttype: BILLING_INCOMPLETE_DIAGNOSTIC,\n\t\ttimestamp: Date.now(),\n\t\tdetails: { reason: \"per-attempt usage does not arrive after a client abort\" },\n\t});\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAapE"}
|
package/dist/utils/sleep.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,MAAmB;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC/B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,OAAO,EAAE,CAAC;QACX,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["export function sleep(ms: number, signal: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tsignal.throwIfAborted();\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(signal.reason);\n\t\t};\n\t\tconst timeout = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-details.d.ts","sourceRoot":"","sources":["../../src/utils/stop-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAItE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-details.js","sourceRoot":"","sources":["../../src/utils/stop-details.ts"],"names":[],"mappings":"AAEA,MAAM,gCAAgC,GACrC,mGAAmG,CAAC;AAErG,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,OAAyB;IAC5D,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrF,IAAI,OAAO,CAAC,WAAW,EAAE,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACtG,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnG,CAAC","sourcesContent":["import type { AssistantMessage } from \"../types.ts\";\n\nconst ANTHROPIC_POLICY_REFUSAL_PATTERN =\n\t/This request triggered restrictions on [\\s\\S]+? and was blocked under Anthropic's Usage Policy\\b/i;\n\n/** Returns true when an assistant response represents a refusal or sensitive stop. */\nexport function isClassifierRefusal(message: AssistantMessage): boolean {\n\tif (message.stopReason !== \"error\" && message.stopReason !== \"toolUse\") return false;\n\tif (message.stopDetails?.type === \"refusal\" || message.stopDetails?.type === \"sensitive\") return true;\n\treturn message.errorMessage ? ANTHROPIC_POLICY_REFUSAL_PATTERN.test(message.errorMessage) : false;\n}\n"]}
|
package/dist/utils/text.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/G,KAAK,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,QAAQ,GAAG,qBAAqB,CAAC;AAE/F,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,EAAE,SAAS,SAAO,GAAG,MAAM,CAM1F"}
|
package/dist/utils/text.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,MAAM,UAAU,WAAW,CAAC,OAAoC,EAAE,SAAS,GAAG,IAAI;IACjF,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,OAAO,OAAO;SACZ,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;SACxC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC1B,IAAI,CAAC,SAAS,CAAC,CAAC;AACnB,CAAC","sourcesContent":["import type { ImageContent, ProviderNativeContent, TextContent, ThinkingContent, ToolCall } from \"../types.ts\";\n\ntype Content = TextContent | ImageContent | ThinkingContent | ToolCall | ProviderNativeContent;\n\n/** Extract and join text from message content. */\nexport function contentText(content: string | readonly Content[], separator = \"\\n\"): string {\n\tif (typeof content === \"string\") return content;\n\treturn content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(separator);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-id.d.ts","sourceRoot":"","sources":["../../src/utils/tool-call-id.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-id.js","sourceRoot":"","sources":["../../src/utils/tool-call-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAU;IAC7C,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACrD,IAAI,SAAS,CAAC,MAAM,IAAI,uBAAuB;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;AAClF,CAAC","sourcesContent":["import { shortHash } from \"./hash.ts\";\n\nexport const TOOL_CALL_ID_MAX_LENGTH = 64;\n\n/**\n * Normalize tool call IDs to match the pattern and length Anthropic-family APIs\n * require (max 64 chars, alphanumeric/underscore/dash). Long foreign ids (OpenAI\n * Responses ids run 450+ chars) must not collide after truncation, so over-long\n * ids keep a readable prefix plus a hash of the full id.\n */\nexport function normalizeToolCallId(id: string): string {\n\tconst sanitized = id.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n\tif (sanitized.length <= TOOL_CALL_ID_MAX_LENGTH) return sanitized;\n\tconst suffix = `_${shortHash(id)}`;\n\treturn `${sanitized.slice(0, TOOL_CALL_ID_MAX_LENGTH - suffix.length)}${suffix}`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-choice-fallback.d.ts","sourceRoot":"","sources":["../../src/utils/tool-choice-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE9C,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAyC7F,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,OAAO,GAA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,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,MAAM,CAAC;YAAE,MAAM,KAAK,CAAC;QACpE,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1C,mGAAmG;QACnG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAAE,wBAAwB,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACrG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;AACF,CAAC","sourcesContent":["import type { Api, Model } from \"../types.ts\";\n\n/** The wire identity a forced tool_choice refusal is remembered under. */\nexport type ForcedToolChoiceTarget = Pick<Model<Api>, \"api\" | \"provider\" | \"baseUrl\" | \"id\">;\n\n/**\n * Models that refused a forced tool_choice and then accepted the same request without one, for the\n * life of the process. Later requests to them send no forced choice instead of paying the refused\n * request again (senpi#2218).\n */\nconst forcedToolChoiceRefusals = new Set<string>();\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction extractHttpStatus(error: unknown): number | undefined {\n\tif (!isRecord(error)) {\n\t\treturn undefined;\n\t}\n\n\tconst status = error.status;\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\tconst response = error.response;\n\tif (isRecord(response) && typeof response.status === \"number\") {\n\t\treturn response.status;\n\t}\n\n\treturn undefined;\n}\n\nfunction errorMessage(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\tif (typeof error === \"string\") {\n\t\treturn error;\n\t}\n\treturn String(error);\n}\n\nexport function isForcedToolChoiceUnsupportedError(error: unknown, sentForcedToolChoice: boolean): boolean {\n\tif (!sentForcedToolChoice || extractHttpStatus(error) !== 400) {\n\t\treturn false;\n\t}\n\n\tconst message = errorMessage(error);\n\treturn (\n\t\t/tool[_\\s-]?choices?\\b.*?(not\\s+(?:currently\\s+)?compatible|incompatible|not\\s+(?:currently\\s+)?supported|unsupported)/is.test(\n\t\t\tmessage,\n\t\t) ||\n\t\t/forces?\\s+tool\\s+use.*?(not\\s+(?:currently\\s+)?compatible|incompatible|not\\s+(?:currently\\s+)?supported|unsupported)/is.test(\n\t\t\tmessage,\n\t\t) ||\n\t\t/does\\s+not\\s+support\\s+forced\\s+tool[_\\s-]?choices?/is.test(message) ||\n\t\t// Auto-only tool-choice upstreams. OmniRoute serving opencode-go/muse-spark-1.3-contributor\n\t\t// (2026-09-27): \"only `\\\"auto\\\"` is supported for `tool_choice`. `\\\"none\\\"`, `\\\"required\\\"`, and named\n\t\t// function choices are not currently supported\". Kiro behind an OpenAI-compatible proxy\n\t\t// (senpi#2218): \"Kiro supports only automatic tool choice or tool_choice:none\".\n\t\t/\\bonly\\s+[`\"]*auto(?:matic)?[`\"]*\\s.{0,40}?tool[_\\s-]?choice/is.test(message) ||\n\t\t// Anthropic Messages with extended thinking on: \"Thinking may not be enabled when tool_choice forces tool use.\"\n\t\t/thinking\\s+may\\s+not\\s+be\\s+enabled\\s+when\\s+tool[_\\s-]?choice\\s+forces\\s+tool\\s+use/is.test(message) ||\n\t\t// OpenAI-compatible gateways serving always-thinking Claude models (observed on opengateway for\n\t\t// claude-fable-5-1, 2026-09-24): \"This model always runs with thinking enabled, so tool_choice\n\t\t// cannot force tool use. Use tool_choice 'auto' or 'none'.\"\n\t\t/tool[_\\s-]?choice\\s+cannot\\s+force\\s+tool\\s+use/is.test(message)\n\t);\n}\n\nexport function omitToolChoiceParam<TParams extends { tool_choice?: unknown }>(params: TParams): TParams {\n\tconst nextParams = { ...params };\n\tdelete nextParams.tool_choice;\n\treturn nextParams;\n}\n\nfunction refusalKey(target: ForcedToolChoiceTarget): string {\n\treturn JSON.stringify([target.api, target.provider, target.baseUrl, target.id]);\n}\n\n/** Whether `target` refused a forced tool_choice earlier in this process. */\nexport function hasRefusedForcedToolChoice(target: ForcedToolChoiceTarget): boolean {\n\treturn forcedToolChoiceRefusals.has(refusalKey(target));\n}\n\n/** Forgets every remembered refusal; tests isolate their models with it. */\nexport function clearForcedToolChoiceRefusals(): void {\n\tforcedToolChoiceRefusals.clear();\n}\n\nexport type ForcedToolChoiceRequest<TParams extends { tool_choice?: unknown }, TResult> = {\n\treadonly target: ForcedToolChoiceTarget;\n\treadonly params: TParams;\n\t/** The model's declared capability (`compat.supportsForcedToolChoice`, default true). */\n\treadonly acceptsForcedToolChoice: boolean;\n\treadonly isForced: (toolChoice: TParams[\"tool_choice\"]) => boolean;\n\treadonly send: (params: TParams) => Promise<TResult>;\n};\n\n/**\n * Sends a request whose `tool_choice` may force a tool. A model declared or remembered as refusing\n * forced choices gets the request without `tool_choice` up front. Otherwise a 400 refusing the forced\n * choice is retried once without it, and the model is remembered once that retry is accepted, unless\n * the refusal blamed thinking; a retry that fails too surfaces its own error and records nothing.\n */\nexport async function sendWithForcedToolChoiceFallback<TParams extends { tool_choice?: unknown }, TResult>(\n\trequest: ForcedToolChoiceRequest<TParams, TResult>,\n): Promise<{ readonly params: TParams; readonly result: TResult }> {\n\tconst forced = request.isForced(request.params.tool_choice);\n\tif (forced && (!request.acceptsForcedToolChoice || hasRefusedForcedToolChoice(request.target))) {\n\t\tconst params = omitToolChoiceParam(request.params);\n\t\treturn { params, result: await request.send(params) };\n\t}\n\ttry {\n\t\treturn { params: request.params, result: await request.send(request.params) };\n\t} catch (error) {\n\t\tif (!isForcedToolChoiceUnsupportedError(error, forced)) throw error;\n\t\tconst params = omitToolChoiceParam(request.params);\n\t\tconst result = await request.send(params);\n\t\t// A refusal that names thinking depends on the request's thinking setting, not on the model alone.\n\t\tif (!/thinking/i.test(errorMessage(error))) forcedToolChoiceRefusals.add(refusalKey(request.target));\n\t\treturn { params, result };\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-name-match.d.ts","sourceRoot":"","sources":["../../src/utils/tool-name-match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAcpD;AAOD,yGAAyG;AACzG,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAevG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-name-match.js","sourceRoot":"","sources":["../../src/utils/tool-name-match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAE/C,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,OA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,CAAC;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACxE,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAC9C,aAAa,CAAC,IAAI,CAAC;aACjB,KAAK,CAAC,CAAC,CAAC;aACR,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,CAChE,CAAC;QACF,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,UAAU,CAAC;IACjD,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Lenient tool-name matching shared by the inbound tool-call resolver\n * (`@earendil-works/pi-agent-core` `resolveToolNameAlias`) and the Anthropic\n * tool-reference repair, so both paths accept the same shapes.\n *\n * Models write tool names in shapes no tool was registered under: recased\n * (`LazyWeather` for `lazy_weather`), under a gateway namespace in any case\n * (`mcp__686f__Eval`, `MCP__686f__Eval`), under a namespace whose id contains\n * underscores (`mcp__my_server__Memory`), or without the `mcp_<server>_`\n * prefix senpi's own MCP tools carry (`create_issue` for\n * `mcp_github_create_issue`).\n *\n * A namespace is cut only at its delimiter: `__` for the gateway form, the\n * first `_` for `mcp_<server>_<tool>`. It is never cut inside the tool's own\n * name, so `mcp__sandbox__run_bash` cannot fall through to a local `bash`.\n * Each form is tried most specific first (exact, case/separator fold, then a\n * registered tool whose unprefixed name folds the same), and a step resolves\n * only when exactly one tool matches it: the matcher never guesses between two\n * candidates.\n */\n\nconst GATEWAY_NAMESPACE = /^mcp__(.+)$/i;\nconst GATEWAY_DELIMITER = /_{2,}/g;\nconst SERVER_NAMESPACE = /^mcp_([^_]+)_(.+)$/i;\n\nexport function foldToolName(name: string): string {\n\treturn name.toLowerCase().replaceAll(/[-_]/g, \"\");\n}\n\n/**\n * The name itself, then its unprefixed remainders, longest first:\n * `mcp__my_srv__x__Tool` -> `x__Tool`, `Tool`; `mcp_github_create_issue` ->\n * `create_issue`.\n */\nexport function toolNameForms(name: string): string[] {\n\tconst forms = [name];\n\tconst gateway = GATEWAY_NAMESPACE.exec(name);\n\tif (gateway) {\n\t\tconst rest = gateway[1] ?? \"\";\n\t\tfor (const run of rest.matchAll(GATEWAY_DELIMITER)) {\n\t\t\tconst suffix = rest.slice(run.index + run[0].length);\n\t\t\tif (run.index > 0 && suffix.length > 0) forms.push(suffix);\n\t\t}\n\t\treturn forms;\n\t}\n\tconst tool = SERVER_NAMESPACE.exec(name)?.[2];\n\tif (tool !== undefined) forms.push(tool);\n\treturn forms;\n}\n\nfunction uniqueMatch(names: readonly string[], matches: (name: string) => boolean): string | undefined {\n\tconst found = names.filter(matches);\n\treturn found.length === 1 ? found[0] : undefined;\n}\n\n/** Resolve `requested` to the one available tool it names, or `undefined` when none or several match. */\nexport function resolveToolNameMatch(requested: string, available: Iterable<string>): string | undefined {\n\tconst names = [...new Set(available)];\n\tfor (const form of toolNameForms(requested)) {\n\t\tif (names.includes(form)) return form;\n\t\tconst key = foldToolName(form);\n\t\tconst folded = uniqueMatch(names, (name) => foldToolName(name) === key);\n\t\tif (folded !== undefined) return folded;\n\t\tconst unprefixed = uniqueMatch(names, (name) =>\n\t\t\ttoolNameForms(name)\n\t\t\t\t.slice(1)\n\t\t\t\t.some((registeredForm) => foldToolName(registeredForm) === key),\n\t\t);\n\t\tif (unprefixed !== undefined) return unprefixed;\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-pair-repair.d.ts","sourceRoot":"","sources":["../../src/utils/tool-pair-repair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,uBAAuB,gDAAg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AAK,CAAC,EAAE;oBACpB,QAAQ,EAAE,KAAK,CAAC,IAAI;oBACpB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;oBACjC,OAAO,EAAE,UAAU;oBACnB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;iBACjE,CAAC,CAAC;gBACH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Message, TextContent } from \"../types.ts\";\n\nexport const TOOL_RESULT_PLACEHOLDER = \"Tool output unavailable (context compacted)\";\n\n/**\n * Retry diagnostic for a dangling tool call flagged `incomplete` by the text\n * tool-call middleware (truncated and unrecoverable at stream end). Tells the\n * model the call never ran and should be re-issued with complete arguments.\n * Duplicated verbatim in the sibling pair-repair copy — the two packages\n * intentionally do not share this constant (no new cross-package dependency).\n */\nfunction incompleteToolCallRetryText(name: string, errorMessage?: string): string {\n\tif (errorMessage !== undefined) {\n\t\treturn `${errorMessage}${errorMessage.endsWith(\".\") ? \"\" : \".\"} Re-issue the tool call with complete arguments.`;\n\t}\n\treturn `Tool call \"${name}\" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`;\n}\n\n/** Repairs orphaned tool results and dangling tool calls. */\nexport function repairOrphanedToolResults(messages: Message[]): Message[] {\n\tconst toolCallIds = new Set<string>();\n\tconst toolResultIds = new Set<string>();\n\tfor (const message of messages) {\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type === \"toolCall\") toolCallIds.add(block.id);\n\t\t\t}\n\t\t}\n\t\tif (message.role === \"toolResult\") toolResultIds.add(message.toolCallId);\n\t}\n\n\tconst output: Message[] = [];\n\tconst dangling = new Set([...toolCallIds].filter((id) => !toolResultIds.has(id)));\n\n\tfor (const message of messages) {\n\t\tif (message.role === \"toolResult\") {\n\t\t\tif (!toolCallIds.has(message.toolCallId)) {\n\t\t\t\toutput.push({\n\t\t\t\t\t...message,\n\t\t\t\t\tcontent: [{ type: \"text\", text: TOOL_RESULT_PLACEHOLDER }] satisfies TextContent[],\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\toutput.push(message);\n\t\t\tcontinue;\n\t\t}\n\n\t\toutput.push(message);\n\t\tif (message.role === \"assistant\") {\n\t\t\t// Errored/aborted assistants are dropped downstream by transformMessages;\n\t\t\t// synthesizing results for their calls would only create orphans there.\n\t\t\tif (message.stopReason === \"error\" || message.stopReason === \"aborted\") continue;\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type !== \"toolCall\" || !dangling.has(block.id)) continue;\n\t\t\t\tconst incomplete = block.incomplete === true;\n\t\t\t\tconst text = incomplete\n\t\t\t\t\t? incompleteToolCallRetryText(block.name, block.errorMessage)\n\t\t\t\t\t: TOOL_RESULT_PLACEHOLDER;\n\t\t\t\toutput.push({\n\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\ttoolCallId: block.id,\n\t\t\t\t\ttoolName: block.name,\n\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\tisError: incomplete,\n\t\t\t\t\ttimestamp: message.timestamp ? message.timestamp + 1 : Date.now(),\n\t\t\t\t});\n\t\t\t\tdangling.delete(block.id);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn output;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-schema-compat.d.ts","sourceRoot":"","sources":["../../src/utils/tool-schema-compat.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAsM/C;;;GAGG;AACH,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM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AC,CAAC;QACjD,CAAC;IACF,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;YAAE,SAAS;QACjC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * JSON Schema normalization for tool parameters sent to OpenAI-compatible\n * backends. Some gateways (e.g. Apitopia → Kimi / Moonshot) enforce a stricter\n * subset that rejects a sibling `type` keyword on schemas that also declare\n * `anyOf` / `oneOf` / `allOf`. This helper removes that redundancy while\n * preserving the schema's semantics.\n */\n\nexport type ToolSchemaFlavor = \"moonshot-mfjs\";\n\nconst COMBINER_KEYS = [\"anyOf\", \"oneOf\", \"allOf\"] as const;\nconst SCHEMA_MAP_KEYS = [\"properties\", \"patternProperties\", \"$defs\", \"definitions\"] as const;\nconst SCHEMA_SINGLE_KEYS = [\n\t\"items\",\n\t\"additionalProperties\",\n\t\"contains\",\n\t\"propertyNames\",\n\t\"if\",\n\t\"then\",\n\t\"else\",\n\t\"not\",\n] as const;\n\nfunction isJsonObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isScalarType(type: unknown): type is \"string\" | \"number\" | \"integer\" | \"boolean\" {\n\treturn type === \"string\" || type === \"number\" || type === \"integer\" || type === \"boolean\";\n}\n\n/**\n * Move a parent-level `type` keyword into combiner branches that do not already\n * declare one, then drop the parent `type`. This keeps the schema equivalent\n * while satisfying validators that require `type` to live inside each branch.\n */\nfunction moveTypeIntoCombinerBranches(node: Record<string, unknown>): void {\n\tif (!(\"type\" in node)) return;\n\n\tconst parentType = node.type;\n\tfor (const combiner of COMBINER_KEYS) {\n\t\tconst branches = node[combiner];\n\t\tif (!Array.isArray(branches)) continue;\n\n\t\tfor (const branch of branches) {\n\t\t\tif (isJsonObject(branch) && !(\"type\" in branch)) {\n\t\t\t\tbranch.type = parentType;\n\t\t\t}\n\t\t}\n\t}\n\n\tdelete node.type;\n}\n\n/**\n * Collapse a homogeneous all-`const` union into a typed `enum`. This is the\n * wire shape many OpenAI-compatible gateways expect for literal unions.\n */\nfunction collapseConstUnion(node: Record<string, unknown>): void {\n\tconst branches = node.anyOf;\n\tif (!Array.isArray(branches) || branches.length < 2) return;\n\tif (\"type\" in node) return;\n\n\tconst values: unknown[] = [];\n\tlet sharedType: string | undefined;\n\n\tfor (const branch of branches) {\n\t\tif (!isJsonObject(branch)) return;\n\t\tif (!Object.hasOwn(branch, \"const\")) return;\n\n\t\tconst keys = Object.keys(branch);\n\t\tif (keys.length !== 2 || !keys.includes(\"type\")) return;\n\n\t\tconst branchType = branch.type;\n\t\tif (!isScalarType(branchType)) return;\n\n\t\tif (sharedType === undefined) {\n\t\t\tsharedType = branchType;\n\t\t} else if (sharedType !== branchType) {\n\t\t\treturn;\n\t\t}\n\n\t\tvalues.push(branch.const);\n\t}\n\n\tif (sharedType === undefined || values.length === 0) return;\n\n\tdelete node.anyOf;\n\tnode.type = sharedType;\n\tnode.enum = values;\n}\n\n/**\n * Collapse a root-level object union into one object schema.\n *\n * A tool's root parameters schema must be a plain `{\"type\":\"object\"}` schema:\n * OpenAI-compatible gateways reject a root that only carries `anyOf`/`oneOf`\n * with `tools.function.parameters.type is required and must be \"object\"`. The\n * merge is intentionally lossy in the direction of permissiveness — branch\n * exclusivity becomes advisory — but it must never lose a declared parameter,\n * so the root's own `properties` and `required` are merged with the branches'\n * rather than replaced by them.\n */\nfunction mergeRootObjectUnion(schema: Record<string, unknown>): Record<string, unknown> | undefined {\n\tconst branches = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : undefined;\n\tif (branches === undefined || branches.length === 0) return undefined;\n\tif (schema.properties !== undefined && !isJsonObject(schema.properties)) return undefined;\n\tif (schema.required !== undefined && !Array.isArray(schema.required)) return undefined;\n\n\tconst objectBranches: Record<string, unknown>[] = [];\n\tfor (const branch of branches) {\n\t\t// An untyped branch is a constraint-only variant (e.g. `{ required: [...] }`)\n\t\t// over the root's own properties, so it merges like an object branch.\n\t\tif (!isJsonObject(branch) || (branch.type !== \"object\" && branch.type !== undefined)) return undefined;\n\t\tif (branch.properties !== undefined && !isJsonObject(branch.properties)) return undefined;\n\t\tif (branch.required !== undefined && !Array.isArray(branch.required)) return undefined;\n\t\tobjectBranches.push(branch);\n\t}\n\n\tconst properties: Record<string, unknown> = isJsonObject(schema.properties) ? { ...schema.properties } : {};\n\tfor (const branch of objectBranches) {\n\t\tif (!isJsonObject(branch.properties)) continue;\n\t\tfor (const [name, propertySchema] of Object.entries(branch.properties)) {\n\t\t\tconst existing = properties[name];\n\t\t\tproperties[name] =\n\t\t\t\texisting === undefined || JSON.stringify(existing) === JSON.stringify(propertySchema)\n\t\t\t\t\t? propertySchema\n\t\t\t\t\t: { anyOf: [existing, propertySchema] };\n\t\t}\n\t}\n\n\t// Only names required by EVERY branch stay required; a name required by one\n\t// branch alone would reject payloads the union accepts. Root-level `required`\n\t// applies to all branches, so it is unioned back in.\n\tconst rootRequired = Array.isArray(schema.required)\n\t\t? schema.required.filter((name): name is string => typeof name === \"string\")\n\t\t: [];\n\tconst branchRequiredSets = objectBranches.map(\n\t\t(branch) =>\n\t\t\tnew Set(\n\t\t\t\tArray.isArray(branch.required)\n\t\t\t\t\t? branch.required.filter((name): name is string => typeof name === \"string\")\n\t\t\t\t\t: [],\n\t\t\t),\n\t);\n\tconst firstBranchRequired = branchRequiredSets[0];\n\tconst commonBranchRequired = firstBranchRequired\n\t\t? [...firstBranchRequired].filter((name) => branchRequiredSets.every((names) => names.has(name)))\n\t\t: [];\n\tconst required = [...new Set([...rootRequired, ...commonBranchRequired])];\n\n\tconst { anyOf: _anyOf, oneOf: _oneOf, ...rest } = schema;\n\treturn {\n\t\t...rest,\n\t\ttype: \"object\",\n\t\tproperties,\n\t\t...(required.length > 0 ? { required } : {}),\n\t};\n}\n\nfunction normalizeNode(node: unknown, isRoot = false): unknown {\n\tif (Array.isArray(node)) {\n\t\treturn node.map((child) => normalizeNode(child));\n\t}\n\n\tif (!isJsonObject(node)) {\n\t\treturn node;\n\t}\n\n\tdelete node.optional;\n\n\tconst hasCombiner = COMBINER_KEYS.some((key) => Array.isArray(node[key]));\n\t// The root of a tool's parameters must keep `type: \"object\"`; hoisting it into\n\t// the branches leaves a typeless root that gateways reject outright.\n\tif (hasCombiner && !isRoot) {\n\t\tmoveTypeIntoCombinerBranches(node);\n\t}\n\n\tfor (const combiner of COMBINER_KEYS) {\n\t\tconst branches = node[combiner];\n\t\tif (Array.isArray(branches)) {\n\t\t\tnode[combiner] = branches.map((branch) => normalizeNode(branch));\n\t\t}\n\t}\n\n\tif (Array.isArray(node.anyOf)) {\n\t\tcollapseConstUnion(node);\n\t}\n\n\tfor (const key of SCHEMA_SINGLE_KEYS) {\n\t\tif (Object.hasOwn(node, key)) {\n\t\t\tnode[key] = normalizeNode(node[key]);\n\t\t}\n\t}\n\n\tfor (const key of SCHEMA_MAP_KEYS) {\n\t\tconst map = node[key];\n\t\tif (!isJsonObject(map)) continue;\n\t\tfor (const name of Object.keys(map)) {\n\t\t\tmap[name] = normalizeNode(map[name]);\n\t\t}\n\t}\n\n\treturn node;\n}\n\n/**\n * Return a deep-normalized copy of a tool's JSON Schema parameters, suitable\n * for OpenAI-compatible Chat Completions backends.\n */\nexport function normalizeToolParametersForOpenAICompat(schema: Record<string, unknown>): Record<string, unknown> {\n\tconst normalized = normalizeNode(structuredClone(schema), true) as Record<string, unknown>;\n\treturn ensureRootObjectSchema(normalized);\n}\n\n/**\n * Guarantee the wire shape every OpenAI-compatible backend requires for tool\n * parameters: a root object schema. A root union of object shapes is merged into\n * one object schema; a root that merely lost its `type` gets it restored.\n *\n * A root whose branches are not object shapes is left alone: forcing\n * `type: \"object\"` onto a scalar union would assert something the schema\n * contradicts, which is worse than the missing keyword. Tool parameters are\n * objects in practice, so this only guards against corrupting an exotic schema.\n */\nfunction ensureRootObjectSchema(schema: Record<string, unknown>): Record<string, unknown> {\n\tconst merged = mergeRootObjectUnion(schema);\n\tif (merged) return merged;\n\tif (schema.type !== undefined) return schema;\n\tconst hasCombiner = COMBINER_KEYS.some((key) => Array.isArray(schema[key]));\n\tif (hasCombiner) return schema;\n\treturn { ...schema, type: \"object\" };\n}\n\n/**\n * Moonshot-flavored JSON Schema subset: in addition to the OpenAI-compatible\n * normalization, drop non-structural annotation keywords that Moonshot rejects.\n */\nexport function normalizeToolParametersForMoonshot(schema: Record<string, unknown>): Record<string, unknown> {\n\treturn stripMoonshotAnnotations(normalizeToolParametersForOpenAICompat(schema));\n}\n\n/**\n * Resolve a tool's root parameters into a single object schema, without the\n * OpenAI-specific rewrites. Wire formats that read a tool's parameters from\n * top-level `properties`/`required` need this: a root union carries neither, so\n * they would otherwise describe the tool to the model as taking no arguments.\n * Schemas that are already plain objects are returned untouched.\n */\nexport function resolveRootObjectSchema(schema: Record<string, unknown>): Record<string, unknown> {\n\treturn mergeRootObjectUnion(structuredClone(schema)) ?? schema;\n}\n\nfunction stripMoonshotAnnotations(node: unknown): Record<string, unknown> {\n\tif (Array.isArray(node)) {\n\t\treturn node.map((child) => stripMoonshotAnnotations(child)) as unknown as Record<string, unknown>;\n\t}\n\n\tif (!isJsonObject(node)) {\n\t\treturn node as Record<string, unknown>;\n\t}\n\n\t// Moonshot does not support JSON Schema validators like `format` or\n\t// annotation-only keywords like `examples` inside function parameters.\n\tdelete node.format;\n\tdelete node.examples;\n\tdelete node.readOnly;\n\tdelete node.writeOnly;\n\tdelete node.deprecated;\n\tdelete node.$schema;\n\tdelete node.$id;\n\n\tfor (const combiner of COMBINER_KEYS) {\n\t\tconst branches = node[combiner];\n\t\tif (Array.isArray(branches)) {\n\t\t\tnode[combiner] = branches.map((branch) => stripMoonshotAnnotations(branch));\n\t\t}\n\t}\n\n\tfor (const key of SCHEMA_SINGLE_KEYS) {\n\t\tif (Object.hasOwn(node, key)) {\n\t\t\tnode[key] = stripMoonshotAnnotations(node[key]);\n\t\t}\n\t}\n\n\tfor (const key of SCHEMA_MAP_KEYS) {\n\t\tconst map = node[key];\n\t\tif (!isJsonObject(map)) continue;\n\t\tfor (const name of Object.keys(map)) {\n\t\t\tmap[name] = stripMoonshotAnnotations(map[name]);\n\t\t}\n\t}\n\n\treturn node;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typebox-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/typebox-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EACrD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAOpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typebox-helpers.js","sourceRoot":"","sources":["../../src/utils/typebox-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACzB,MAAS,EACT,OAAuD;IAEvD,OAAO,IAAI,CAAC,MAAM,CAAY;QAC7B,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAa;QACnB,GAAG,CAAC,OAAO,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QACjE,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;KACrD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type TUnsafe, Type } from \"typebox\";\n\n/**\n * Creates a string enum schema compatible with Google's API and other providers\n * that don't support anyOf/const patterns.\n *\n * @example\n * const OperationSchema = StringEnum([\"add\", \"subtract\", \"multiply\", \"divide\"], {\n * description: \"The operation to perform\"\n * });\n *\n * type Operation = Static<typeof OperationSchema>; // \"add\" | \"subtract\" | \"multiply\" | \"divide\"\n */\nexport function StringEnum<T extends readonly string[]>(\n\tvalues: T,\n\toptions?: { description?: string; default?: T[number] },\n): TUnsafe<T[number]> {\n\treturn Type.Unsafe<T[number]>({\n\t\ttype: \"string\",\n\t\tenum: values as any,\n\t\t...(options?.description && { description: options.description }),\n\t\t...(options?.default && { default: options.default }),\n\t});\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unavailable-tool-text.d.ts","sourceRoot":"","sources":["../../src/utils/unavailable-tool-text.ts"],"names":[],"mappings":"AAqBA,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,eAAe,EAAE,OAAO,GACtB,MAAM,CAUR;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI3E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unavailable-tool-text.js","sourceRoot":"","sources":["../../src/utils/unavailable-tool-text.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,SAAS,kBAAkB,CAAC,KAAa;IACxC,OAAO,KAAK;SACV,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxG,OAAO,kCAAkC,WAAW,KAAK,WAAW,4BAA4B,CAAC;AAClG,CAAC","sourcesContent":["const MAX_LISTED_TOOLS = 8;\n\nfunction escapeXmlAttribute(value: string): string {\n\treturn value\n\t\t.replaceAll(\"&\", \"&\")\n\t\t.replaceAll('\"', \""\")\n\t\t.replaceAll(\"'\", \"'\")\n\t\t.replaceAll(\"<\", \"<\")\n\t\t.replaceAll(\">\", \">\");\n}\n\nfunction availableToolGuidance(availableToolNames: readonly string[]): string {\n\tif (availableToolNames.length === 0) {\n\t\treturn \"To edit files, call only tools available in this request.\";\n\t}\n\tconst listed = availableToolNames.slice(0, MAX_LISTED_TOOLS).join(\", \");\n\tconst omitted = availableToolNames.length - MAX_LISTED_TOOLS;\n\tconst suffix = omitted > 0 ? ` (and ${omitted} more)` : \"\";\n\treturn `To edit files, call your own tools: ${listed}${suffix}.`;\n}\n\nexport function demotedToolCallText(\n\tname: string,\n\tavailableToolNames: readonly string[],\n\tfirstOccurrence: boolean,\n): string {\n\tconst escapedName = escapeXmlAttribute(name);\n\tif (!firstOccurrence) return `<unavailable-tool-call name=\"${escapedName}\"/>`;\n\treturn [\n\t\t`<unavailable-tool-call name=\"${escapedName}\">`,\n\t\t\"Transcript record, not an action available to you. An earlier model in this session\",\n\t\t`called \"${escapedName}\"; that tool does not exist for you and its input is omitted.`,\n\t\tavailableToolGuidance(availableToolNames),\n\t\t\"</unavailable-tool-call>\",\n\t].join(\"\\n\");\n}\n\nexport function demotedToolResultText(name: string, content: string): string {\n\tconst escapedName = escapeXmlAttribute(name);\n\tconst safeContent = content.replace(/<\\/unavailable-tool-result/gi, (match) => `<${match.slice(1)}`);\n\treturn `<unavailable-tool-result name=\"${escapedName}\">${safeContent}</unavailable-tool-result>`;\n}\n"]}
|
package/dist/utils/uuid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAiBA,0FAA0F;AAC1F,wBAAgB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAoCnD"}
|
package/dist/utils/uuid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAC7C,MAAM,YAAY,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AAEtC,IAAI,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC/B,IAAI,QAA4B,CAAC;AAEjC,SAAS,eAAe,CAAC,KAA8B;IACtD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,IAAI,MAAM,EAAE,eAAe,EAAE,CAAC;QAC7B,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO;IACR,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IAC5C,CAAC;AACF,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,MAAM,CAAC,WAAoB;IAC1C,MAAM,kBAAkB,GAAG,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,GAAG,CAAC,IAAI,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;QACnH,MAAM,IAAI,UAAU,CAAC,qDAAqD,qBAAqB,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,MAAM,kBAAkB,GACvB,WAAW,KAAK,SAAS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AAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACrJ,CAAC","sourcesContent":["const MAX_UUID_V7_TIMESTAMP = 0xffffffffffff;\nconst MAX_SEQUENCE = (1n << 41n) - 1n;\n\nlet lastOrdinaryTimestamp = -1;\nlet sequence: bigint | undefined;\n\nfunction fillRandomBytes(bytes: Uint8Array<ArrayBuffer>): void {\n\tconst crypto = globalThis.crypto;\n\tif (crypto?.getRandomValues) {\n\t\tcrypto.getRandomValues(bytes);\n\t\treturn;\n\t}\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tbytes[i] = Math.floor(Math.random() * 256);\n\t}\n}\n\n/** Generate a time-ordered UUIDv7. A supplied timestamp is preserved for follower ids. */\nexport function uuidv7(timestampMs?: number): string {\n\tconst requestedTimestamp = timestampMs ?? Date.now();\n\tif (!Number.isInteger(requestedTimestamp) || requestedTimestamp < 0 || requestedTimestamp > MAX_UUID_V7_TIMESTAMP) {\n\t\tthrow new RangeError(`UUIDv7 timestamp must be an integer between 0 and ${MAX_UUID_V7_TIMESTAMP}`);\n\t}\n\n\tconst effectiveTimestamp =\n\t\ttimestampMs === undefined ? Math.max(requestedTimestamp, lastOrdinaryTimestamp) : timestampMs;\n\tif (timestampMs === undefined) lastOrdinaryTimestamp = effectiveTimestamp;\n\n\tconst bytes: Uint8Array<ArrayBuffer> = new Uint8Array(16);\n\tfillRandomBytes(bytes);\n\tif (sequence === undefined) {\n\t\tsequence =\n\t\t\t(BigInt(bytes[1]) << 32n) |\n\t\t\t(BigInt(bytes[2]) << 24n) |\n\t\t\t(BigInt(bytes[3]) << 16n) |\n\t\t\t(BigInt(bytes[4]) << 8n) |\n\t\t\tBigInt(bytes[5]);\n\t} else {\n\t\tif (sequence === MAX_SEQUENCE) throw new RangeError(\"UUIDv7 generator sequence exhausted\");\n\t\tsequence++;\n\t}\n\n\tconst timestamp = BigInt(effectiveTimestamp);\n\tfor (let index = 5; index >= 0; index--) {\n\t\tbytes[index] = Number(timestamp >> BigInt((5 - index) * 8)) & 0xff;\n\t}\n\tbytes[6] = 0x70 | Number((sequence >> 37n) & 0x0fn);\n\tbytes[7] = Number((sequence >> 29n) & 0xffn);\n\tbytes[8] = 0x80 | Number((sequence >> 23n) & 0x3fn);\n\tbytes[9] = Number((sequence >> 15n) & 0xffn);\n\tbytes[10] = Number((sequence >> 7n) & 0xffn);\n\tbytes[11] = Number((sequence & 0x7fn) << 1n) | (bytes[11] & 0x01);\n\n\treturn formatUuid(bytes);\n}\n\nfunction formatUuid(bytes: Uint8Array<ArrayBuffer>): string {\n\tconst hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n\treturn `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(6, 8).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmSlD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAMvE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAiCzE"}
|