jeopi-ai 16.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4347 -0
- package/README.md +1193 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +73 -0
- package/dist/types/auth-broker/discover.d.ts +35 -0
- package/dist/types/auth-broker/index.d.ts +7 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +102 -0
- package/dist/types/auth-broker/server.d.ts +43 -0
- package/dist/types/auth-broker/snapshot-cache.d.ts +17 -0
- package/dist/types/auth-broker/types.d.ts +107 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +411 -0
- package/dist/types/auth-gateway/http.d.ts +39 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +36 -0
- package/dist/types/auth-gateway/types.d.ts +123 -0
- package/dist/types/auth-retry.d.ts +124 -0
- package/dist/types/auth-storage.d.ts +1026 -0
- package/dist/types/dialect/anthropic.d.ts +15 -0
- package/dist/types/dialect/catalog.d.ts +3 -0
- package/dist/types/dialect/coercion.d.ts +23 -0
- package/dist/types/dialect/deepseek.d.ts +14 -0
- package/dist/types/dialect/demotion.d.ts +23 -0
- package/dist/types/dialect/examples.d.ts +2 -0
- package/dist/types/dialect/factory.d.ts +3 -0
- package/dist/types/dialect/fenced-thinking.d.ts +53 -0
- package/dist/types/dialect/gemini.d.ts +17 -0
- package/dist/types/dialect/gemma.d.ts +15 -0
- package/dist/types/dialect/glm.d.ts +9 -0
- package/dist/types/dialect/harmony.d.ts +8 -0
- package/dist/types/dialect/hermes.d.ts +9 -0
- package/dist/types/dialect/history.d.ts +3 -0
- package/dist/types/dialect/index.d.ts +11 -0
- package/dist/types/dialect/inventory.d.ts +12 -0
- package/dist/types/dialect/kimi.d.ts +14 -0
- package/dist/types/dialect/minimax.d.ts +3 -0
- package/dist/types/dialect/owned-stream.d.ts +4 -0
- package/dist/types/dialect/qwen3.d.ts +9 -0
- package/dist/types/dialect/rendering.d.ts +45 -0
- package/dist/types/dialect/thinking.d.ts +6 -0
- package/dist/types/dialect/types.d.ts +69 -0
- package/dist/types/dialect/xml.d.ts +9 -0
- package/dist/types/error/abort.d.ts +14 -0
- package/dist/types/error/auth-classify.d.ts +16 -0
- package/dist/types/error/auth.d.ts +27 -0
- package/dist/types/error/aws.d.ts +23 -0
- package/dist/types/error/classes.d.ts +102 -0
- package/dist/types/error/finalize.d.ts +39 -0
- package/dist/types/error/flags.d.ts +79 -0
- package/dist/types/error/format.d.ts +20 -0
- package/dist/types/error/gateway.d.ts +20 -0
- package/dist/types/error/index.d.ts +13 -0
- package/dist/types/error/oauth.d.ts +43 -0
- package/dist/types/error/provider.d.ts +42 -0
- package/dist/types/error/rate-limit.d.ts +59 -0
- package/dist/types/error/retryable.d.ts +27 -0
- package/dist/types/error/validation.d.ts +32 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/providers/__tests__/google-auth.test.d.ts +1 -0
- package/dist/types/providers/__tests__/kimi-code-thinking.test.d.ts +1 -0
- package/dist/types/providers/__tests__/openai-codex-error.test.d.ts +1 -0
- package/dist/types/providers/amazon-bedrock.d.ts +39 -0
- package/dist/types/providers/anthropic-client.d.ts +94 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +497 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic-wire.d.ts +318 -0
- package/dist/types/providers/anthropic.d.ts +248 -0
- package/dist/types/providers/aws-credentials.d.ts +53 -0
- package/dist/types/providers/aws-eventstream.d.ts +39 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +16 -0
- package/dist/types/providers/cursor.d.ts +91 -0
- package/dist/types/providers/devin.d.ts +12 -0
- package/dist/types/providers/error-message.d.ts +27 -0
- package/dist/types/providers/github-copilot-headers.d.ts +40 -0
- package/dist/types/providers/gitlab-duo-workflow.d.ts +254 -0
- package/dist/types/providers/gitlab-duo.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +32 -0
- package/dist/types/providers/google-gemini-cli.d.ts +118 -0
- package/dist/types/providers/google-interactions.d.ts +65 -0
- package/dist/types/providers/google-shared.d.ts +203 -0
- package/dist/types/providers/google-types.d.ts +155 -0
- package/dist/types/providers/google-vertex.d.ts +7 -0
- package/dist/types/providers/google.d.ts +4 -0
- package/dist/types/providers/grammar.d.ts +1 -0
- package/dist/types/providers/kimi.d.ts +27 -0
- package/dist/types/providers/mock.d.ts +178 -0
- package/dist/types/providers/ollama.d.ts +7 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +695 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-chat-wire.d.ts +644 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +54 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +26 -0
- package/dist/types/providers/openai-codex-responses.d.ts +108 -0
- package/dist/types/providers/openai-completions.d.ts +45 -0
- package/dist/types/providers/openai-reasoning-fallback.d.ts +25 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +349 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
- package/dist/types/providers/openai-responses.d.ts +126 -0
- package/dist/types/providers/openai-shared.d.ts +506 -0
- package/dist/types/providers/pi-native-client.d.ts +13 -0
- package/dist/types/providers/pi-native-server.d.ts +69 -0
- package/dist/types/providers/register-builtins.d.ts +32 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +11 -0
- package/dist/types/providers/vision-guard.d.ts +20 -0
- package/dist/types/registry/aimlapi.d.ts +4 -0
- package/dist/types/registry/alibaba-coding-plan.d.ts +8 -0
- package/dist/types/registry/amazon-bedrock.d.ts +5 -0
- package/dist/types/registry/anthropic.d.ts +10 -0
- package/dist/types/registry/api-key-login.d.ts +42 -0
- package/dist/types/registry/api-key-validation.d.ts +43 -0
- package/dist/types/registry/azure.d.ts +4 -0
- package/dist/types/registry/cerebras.d.ts +7 -0
- package/dist/types/registry/cloudflare-ai-gateway.d.ts +13 -0
- package/dist/types/registry/coreweave.d.ts +7 -0
- package/dist/types/registry/cursor.d.ts +7 -0
- package/dist/types/registry/deepseek.d.ts +8 -0
- package/dist/types/registry/derived.d.ts +5 -0
- package/dist/types/registry/devin.d.ts +8 -0
- package/dist/types/registry/firepass.d.ts +16 -0
- package/dist/types/registry/fireworks.d.ts +7 -0
- package/dist/types/registry/github-copilot.d.ts +7 -0
- package/dist/types/registry/gitlab-duo-workflow.d.ts +10 -0
- package/dist/types/registry/gitlab-duo.d.ts +9 -0
- package/dist/types/registry/google-antigravity.d.ts +9 -0
- package/dist/types/registry/google-gemini-cli.d.ts +9 -0
- package/dist/types/registry/google-vertex.d.ts +5 -0
- package/dist/types/registry/google.d.ts +4 -0
- package/dist/types/registry/groq.d.ts +4 -0
- package/dist/types/registry/huggingface.d.ts +7 -0
- package/dist/types/registry/index.d.ts +4 -0
- package/dist/types/registry/kagi.d.ts +14 -0
- package/dist/types/registry/kilo.d.ts +7 -0
- package/dist/types/registry/kimi-code.d.ts +7 -0
- package/dist/types/registry/litellm.d.ts +13 -0
- package/dist/types/registry/llama-cpp.d.ts +8 -0
- package/dist/types/registry/lm-studio.d.ts +8 -0
- package/dist/types/registry/minimax-code-cn.d.ts +6 -0
- package/dist/types/registry/minimax-code.d.ts +6 -0
- package/dist/types/registry/minimax.d.ts +4 -0
- package/dist/types/registry/mistral.d.ts +4 -0
- package/dist/types/registry/moonshot.d.ts +7 -0
- package/dist/types/registry/nanogpt.d.ts +7 -0
- package/dist/types/registry/nvidia.d.ts +7 -0
- package/dist/types/registry/oauth/__tests__/xai-oauth.test.d.ts +1 -0
- package/dist/types/registry/oauth/anthropic.d.ts +23 -0
- package/dist/types/registry/oauth/callback-server.d.ts +72 -0
- package/dist/types/registry/oauth/cursor.d.ts +15 -0
- package/dist/types/registry/oauth/devin.d.ts +5 -0
- package/dist/types/registry/oauth/github-copilot.d.ts +30 -0
- package/dist/types/registry/oauth/gitlab-duo-workflow.d.ts +6 -0
- package/dist/types/registry/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/registry/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/registry/oauth/google-gemini-cli.d.ts +10 -0
- package/dist/types/registry/oauth/google-oauth-shared.d.ts +22 -0
- package/dist/types/registry/oauth/index.d.ts +64 -0
- package/dist/types/registry/oauth/kimi.d.ts +21 -0
- package/dist/types/registry/oauth/minimax-code.d.ts +27 -0
- package/dist/types/registry/oauth/openai-codex.d.ts +33 -0
- package/dist/types/registry/oauth/opencode.d.ts +18 -0
- package/dist/types/registry/oauth/perplexity.d.ts +9 -0
- package/dist/types/registry/oauth/pkce.d.ts +8 -0
- package/dist/types/registry/oauth/types.d.ts +56 -0
- package/dist/types/registry/oauth/wafer.d.ts +1 -0
- package/dist/types/registry/oauth/xai-oauth.d.ts +52 -0
- package/dist/types/registry/oauth/xiaomi.d.ts +25 -0
- package/dist/types/registry/ollama-cloud.d.ts +7 -0
- package/dist/types/registry/ollama.d.ts +12 -0
- package/dist/types/registry/openai-codex-device.d.ts +8 -0
- package/dist/types/registry/openai-codex.d.ts +9 -0
- package/dist/types/registry/openai.d.ts +4 -0
- package/dist/types/registry/opencode-go.d.ts +6 -0
- package/dist/types/registry/opencode-zen.d.ts +6 -0
- package/dist/types/registry/openrouter.d.ts +13 -0
- package/dist/types/registry/parallel.d.ts +14 -0
- package/dist/types/registry/perplexity.d.ts +7 -0
- package/dist/types/registry/qianfan.d.ts +7 -0
- package/dist/types/registry/qwen-portal.d.ts +7 -0
- package/dist/types/registry/registry.d.ts +303 -0
- package/dist/types/registry/sakana.d.ts +7 -0
- package/dist/types/registry/synthetic.d.ts +6 -0
- package/dist/types/registry/tavily.d.ts +14 -0
- package/dist/types/registry/together.d.ts +6 -0
- package/dist/types/registry/types.d.ts +51 -0
- package/dist/types/registry/umans.d.ts +7 -0
- package/dist/types/registry/venice.d.ts +13 -0
- package/dist/types/registry/vercel-ai-gateway.d.ts +7 -0
- package/dist/types/registry/vllm.d.ts +7 -0
- package/dist/types/registry/wafer-serverless.d.ts +6 -0
- package/dist/types/registry/xai-oauth.d.ts +7 -0
- package/dist/types/registry/xai.d.ts +4 -0
- package/dist/types/registry/xiaomi-token-plan-ams.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-cn.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-sgp.d.ts +6 -0
- package/dist/types/registry/xiaomi.d.ts +6 -0
- package/dist/types/registry/zai.d.ts +7 -0
- package/dist/types/registry/zenmux.d.ts +7 -0
- package/dist/types/registry/zhipu-coding-plan.d.ts +7 -0
- package/dist/types/stream.d.ts +44 -0
- package/dist/types/types.d.ts +715 -0
- package/dist/types/usage/claude.d.ts +4 -0
- package/dist/types/usage/gemini.d.ts +2 -0
- package/dist/types/usage/github-copilot.d.ts +7 -0
- package/dist/types/usage/google-antigravity.d.ts +15 -0
- package/dist/types/usage/kimi.d.ts +2 -0
- package/dist/types/usage/minimax-code.d.ts +2 -0
- package/dist/types/usage/ollama.d.ts +5 -0
- package/dist/types/usage/openai-codex-base-url.d.ts +18 -0
- package/dist/types/usage/openai-codex-reset.d.ts +79 -0
- package/dist/types/usage/openai-codex.d.ts +3 -0
- package/dist/types/usage/opencode-go.d.ts +2 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/zai.d.ts +2 -0
- package/dist/types/usage.d.ts +346 -0
- package/dist/types/utils/abort.d.ts +25 -0
- package/dist/types/utils/anthropic-auth.d.ts +35 -0
- package/dist/types/utils/block-symbols.d.ts +20 -0
- package/dist/types/utils/deterministic-id.d.ts +16 -0
- package/dist/types/utils/empty-completion-retry.d.ts +21 -0
- package/dist/types/utils/event-stream.d.ts +30 -0
- package/dist/types/utils/foundry.d.ts +1 -0
- package/dist/types/utils/google-validation.d.ts +2 -0
- package/dist/types/utils/harmony-leak.d.ts +118 -0
- package/dist/types/utils/http-inspector.d.ts +30 -0
- package/dist/types/utils/idle-iterator.d.ts +137 -0
- package/dist/types/utils/leaked-thinking-stream.d.ts +29 -0
- package/dist/types/utils/openai-http.d.ts +54 -0
- package/dist/types/utils/openrouter-headers.d.ts +1 -0
- package/dist/types/utils/parse-bind.d.ts +23 -0
- package/dist/types/utils/provider-response.d.ts +3 -0
- package/dist/types/utils/proxy.d.ts +29 -0
- package/dist/types/utils/request-debug.d.ts +29 -0
- package/dist/types/utils/retry-after.d.ts +4 -0
- package/dist/types/utils/retry.d.ts +14 -0
- package/dist/types/utils/schema/adapt.d.ts +24 -0
- package/dist/types/utils/schema/compatibility.d.ts +30 -0
- package/dist/types/utils/schema/dereference.d.ts +11 -0
- package/dist/types/utils/schema/draft.d.ts +10 -0
- package/dist/types/utils/schema/equality.d.ts +4 -0
- package/dist/types/utils/schema/fields.d.ts +54 -0
- package/dist/types/utils/schema/index.d.ts +15 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +20 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +124 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +17 -0
- package/dist/types/utils/schema/strict-tool-validation.d.ts +16 -0
- package/dist/types/utils/schema/types.d.ts +4 -0
- package/dist/types/utils/schema/typescript.d.ts +18 -0
- package/dist/types/utils/schema/wire.d.ts +92 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
- package/dist/types/utils/sdk-stream-timeout.d.ts +33 -0
- package/dist/types/utils/sse-debug.d.ts +5 -0
- package/dist/types/utils/stream-markup-healing.d.ts +87 -0
- package/dist/types/utils/thinking-loop.d.ts +102 -0
- package/dist/types/utils/tool-call-loop-guard.d.ts +26 -0
- package/dist/types/utils/tool-choice.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +42 -0
- package/dist/types/utils.d.ts +24 -0
- package/package.json +139 -0
- package/src/api-registry.ts +109 -0
- package/src/auth-broker/client.ts +359 -0
- package/src/auth-broker/discover.ts +222 -0
- package/src/auth-broker/index.ts +7 -0
- package/src/auth-broker/refresher.ts +117 -0
- package/src/auth-broker/remote-store.ts +657 -0
- package/src/auth-broker/server.ts +646 -0
- package/src/auth-broker/snapshot-cache.ts +191 -0
- package/src/auth-broker/types.ts +130 -0
- package/src/auth-broker/wire-schemas.ts +249 -0
- package/src/auth-gateway/http.ts +194 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +802 -0
- package/src/auth-gateway/types.ts +151 -0
- package/src/auth-retry.ts +250 -0
- package/src/auth-storage.ts +5576 -0
- package/src/dialect/anthropic.md +31 -0
- package/src/dialect/anthropic.ts +608 -0
- package/src/dialect/catalog.ts +29 -0
- package/src/dialect/coercion.ts +136 -0
- package/src/dialect/deepseek.md +24 -0
- package/src/dialect/deepseek.ts +609 -0
- package/src/dialect/demotion.ts +36 -0
- package/src/dialect/examples.ts +33 -0
- package/src/dialect/factory.ts +34 -0
- package/src/dialect/fenced-thinking.ts +184 -0
- package/src/dialect/gemini.md +44 -0
- package/src/dialect/gemini.ts +597 -0
- package/src/dialect/gemma.md +33 -0
- package/src/dialect/gemma.ts +387 -0
- package/src/dialect/glm.md +32 -0
- package/src/dialect/glm.ts +456 -0
- package/src/dialect/harmony.md +31 -0
- package/src/dialect/harmony.ts +346 -0
- package/src/dialect/hermes.md +25 -0
- package/src/dialect/hermes.ts +206 -0
- package/src/dialect/history.ts +81 -0
- package/src/dialect/index.ts +15 -0
- package/src/dialect/inventory.ts +73 -0
- package/src/dialect/kimi.md +24 -0
- package/src/dialect/kimi.ts +340 -0
- package/src/dialect/minimax.md +31 -0
- package/src/dialect/minimax.ts +95 -0
- package/src/dialect/owned-stream.ts +470 -0
- package/src/dialect/prompt-template.md +12 -0
- package/src/dialect/qwen3.md +28 -0
- package/src/dialect/qwen3.ts +240 -0
- package/src/dialect/rendering.ts +249 -0
- package/src/dialect/thinking.ts +122 -0
- package/src/dialect/types.ts +57 -0
- package/src/dialect/xml.md +22 -0
- package/src/dialect/xml.ts +90 -0
- package/src/error/abort.ts +18 -0
- package/src/error/auth-classify.ts +30 -0
- package/src/error/auth.ts +48 -0
- package/src/error/aws.ts +31 -0
- package/src/error/classes.ts +186 -0
- package/src/error/finalize.ts +69 -0
- package/src/error/flags.ts +506 -0
- package/src/error/format.ts +45 -0
- package/src/error/gateway.ts +96 -0
- package/src/error/index.ts +13 -0
- package/src/error/oauth.ts +58 -0
- package/src/error/provider.ts +62 -0
- package/src/error/rate-limit.ts +161 -0
- package/src/error/retryable.ts +70 -0
- package/src/error/validation.ts +44 -0
- package/src/index.ts +49 -0
- package/src/provider-details.ts +90 -0
- package/src/providers/__tests__/google-auth.test.ts +144 -0
- package/src/providers/__tests__/kimi-code-thinking.test.ts +112 -0
- package/src/providers/__tests__/openai-codex-error.test.ts +84 -0
- package/src/providers/amazon-bedrock.ts +1042 -0
- package/src/providers/anthropic-client.ts +295 -0
- package/src/providers/anthropic-messages-server-schema.ts +252 -0
- package/src/providers/anthropic-messages-server.ts +756 -0
- package/src/providers/anthropic-wire.ts +318 -0
- package/src/providers/anthropic.ts +4078 -0
- package/src/providers/aws-credentials.ts +586 -0
- package/src/providers/aws-eventstream.ts +181 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +382 -0
- package/src/providers/cursor/proto/agent.proto +3526 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor.ts +2695 -0
- package/src/providers/devin/proto/buf/validate/validate.proto +468 -0
- package/src/providers/devin/proto/buf.gen.yaml +33 -0
- package/src/providers/devin/proto/buf.yaml +17 -0
- package/src/providers/devin/proto/cel/expr/checked.proto +103 -0
- package/src/providers/devin/proto/cel/expr/eval.proto +38 -0
- package/src/providers/devin/proto/cel/expr/explain.proto +15 -0
- package/src/providers/devin/proto/cel/expr/syntax.proto +113 -0
- package/src/providers/devin/proto/cel/expr/value.proto +41 -0
- package/src/providers/devin/proto/connectext/grpc/status/v1/status.proto +11 -0
- package/src/providers/devin/proto/errorspb/errors.proto +56 -0
- package/src/providers/devin/proto/errorspb/hintdetail.proto +7 -0
- package/src/providers/devin/proto/errorspb/markers.proto +10 -0
- package/src/providers/devin/proto/errorspb/tags.proto +12 -0
- package/src/providers/devin/proto/errorspb/testing.proto +6 -0
- package/src/providers/devin/proto/exa/analytics_pb/analytics.proto +188 -0
- package/src/providers/devin/proto/exa/api_server_pb/api_server.proto +2461 -0
- package/src/providers/devin/proto/exa/auth_pb/auth.proto +19 -0
- package/src/providers/devin/proto/exa/auto_cascade_common_pb/auto_cascade_common.proto +79 -0
- package/src/providers/devin/proto/exa/browser_preview_pb/browser_preview.proto +32 -0
- package/src/providers/devin/proto/exa/bug_checker_pb/bug_checker.proto +22 -0
- package/src/providers/devin/proto/exa/cascade_plugins_pb/cascade_plugins.proto +262 -0
- package/src/providers/devin/proto/exa/chat_client_server_pb/chat_client_server.proto +57 -0
- package/src/providers/devin/proto/exa/chat_pb/chat.proto +449 -0
- package/src/providers/devin/proto/exa/code_edit/code_edit_pb/code_edit.proto +186 -0
- package/src/providers/devin/proto/exa/codeium_common_pb/codeium_common.proto +4157 -0
- package/src/providers/devin/proto/exa/context_module_pb/context_module.proto +175 -0
- package/src/providers/devin/proto/exa/cortex_pb/cortex.proto +3268 -0
- package/src/providers/devin/proto/exa/dev_pb/dev.proto +26 -0
- package/src/providers/devin/proto/exa/diff_action_pb/diff_action.proto +75 -0
- package/src/providers/devin/proto/exa/eval/pr_eval/datasets_pb/datasets.proto +103 -0
- package/src/providers/devin/proto/exa/eval_pb/eval.proto +1315 -0
- package/src/providers/devin/proto/exa/extension_server_pb/extension_server.proto +556 -0
- package/src/providers/devin/proto/exa/file_system_provider_pb/file_system_provider.proto +75 -0
- package/src/providers/devin/proto/exa/index_pb/index.proto +461 -0
- package/src/providers/devin/proto/exa/knowledge_base_pb/knowledge_base.proto +144 -0
- package/src/providers/devin/proto/exa/language_server_pb/language_server.proto +2385 -0
- package/src/providers/devin/proto/exa/model_management_pb/model_management.proto +186 -0
- package/src/providers/devin/proto/exa/opensearch_clients_pb/opensearch_clients.proto +503 -0
- package/src/providers/devin/proto/exa/product_analytics_pb/product_analytics.proto +37 -0
- package/src/providers/devin/proto/exa/prompt_pb/prompt.proto +92 -0
- package/src/providers/devin/proto/exa/reactive_component_pb/reactive_component.proto +96 -0
- package/src/providers/devin/proto/exa/seat_management_pb/seat_management.proto +2680 -0
- package/src/providers/devin/proto/exa/tokenizer_pb/tokenizer.proto +37 -0
- package/src/providers/devin/proto/exa/trainer_pb/config.proto +647 -0
- package/src/providers/devin/proto/exa/tree_sitter/language_data_pb/language_data.proto +14 -0
- package/src/providers/devin/proto/exa/trust_pb/trust.proto +157 -0
- package/src/providers/devin/proto/exa/user_analytics_pb/user_analytics.proto +519 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/base/api_base.proto +28 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/datastore/datastore_v3.proto +484 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/log/log_service.proto +136 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/remote_api/remote_api.proto +42 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +61 -0
- package/src/providers/devin/proto/grpc/binlog/v1/binarylog.proto +84 -0
- package/src/providers/devin/proto/io/prometheus/client/metrics.proto +98 -0
- package/src/providers/devin.ts +577 -0
- package/src/providers/error-message.ts +21 -0
- package/src/providers/github-copilot-headers.ts +141 -0
- package/src/providers/gitlab-duo-workflow-chatml-note.md +1 -0
- package/src/providers/gitlab-duo-workflow.ts +3058 -0
- package/src/providers/gitlab-duo.ts +395 -0
- package/src/providers/google-auth.ts +350 -0
- package/src/providers/google-gemini-cli.ts +1362 -0
- package/src/providers/google-interactions.ts +753 -0
- package/src/providers/google-shared.ts +1103 -0
- package/src/providers/google-types.ts +180 -0
- package/src/providers/google-vertex.ts +183 -0
- package/src/providers/google.ts +87 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/mock.ts +507 -0
- package/src/providers/ollama.ts +773 -0
- package/src/providers/openai-anthropic-shim.ts +152 -0
- package/src/providers/openai-chat-server-schema.ts +242 -0
- package/src/providers/openai-chat-server.ts +715 -0
- package/src/providers/openai-chat-wire.ts +847 -0
- package/src/providers/openai-codex/request-transformer.ts +295 -0
- package/src/providers/openai-codex/response-handler.ts +102 -0
- package/src/providers/openai-codex-responses.ts +3468 -0
- package/src/providers/openai-completions.ts +2173 -0
- package/src/providers/openai-reasoning-fallback.ts +269 -0
- package/src/providers/openai-responses-reasoning-suppression.md +1 -0
- package/src/providers/openai-responses-server-schema.ts +282 -0
- package/src/providers/openai-responses-server.ts +1280 -0
- package/src/providers/openai-responses-wire.ts +6391 -0
- package/src/providers/openai-responses.ts +1022 -0
- package/src/providers/openai-shared.ts +2648 -0
- package/src/providers/pi-native-client.ts +266 -0
- package/src/providers/pi-native-server.ts +242 -0
- package/src/providers/register-builtins.ts +475 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.ts +787 -0
- package/src/providers/vision-guard.ts +54 -0
- package/src/registry/aimlapi.ts +6 -0
- package/src/registry/alibaba-coding-plan.ts +95 -0
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/registry/api-key-login.ts +112 -0
- package/src/registry/api-key-validation.ts +161 -0
- package/src/registry/azure.ts +6 -0
- package/src/registry/cerebras.ts +23 -0
- package/src/registry/cloudflare-ai-gateway.ts +45 -0
- package/src/registry/coreweave.ts +40 -0
- package/src/registry/cursor.ts +20 -0
- package/src/registry/deepseek.ts +46 -0
- package/src/registry/derived.ts +9 -0
- package/src/registry/devin.ts +15 -0
- package/src/registry/firepass.ts +32 -0
- package/src/registry/fireworks.ts +28 -0
- package/src/registry/github-copilot.ts +22 -0
- package/src/registry/gitlab-duo-workflow.ts +20 -0
- package/src/registry/gitlab-duo.ts +19 -0
- package/src/registry/google-antigravity.ts +22 -0
- package/src/registry/google-gemini-cli.ts +22 -0
- package/src/registry/google-vertex.ts +38 -0
- package/src/registry/google.ts +6 -0
- package/src/registry/groq.ts +6 -0
- package/src/registry/huggingface.ts +29 -0
- package/src/registry/index.ts +4 -0
- package/src/registry/kagi.ts +46 -0
- package/src/registry/kilo.ts +114 -0
- package/src/registry/kimi-code.ts +17 -0
- package/src/registry/litellm.ts +45 -0
- package/src/registry/llama-cpp.ts +35 -0
- package/src/registry/lm-studio.ts +31 -0
- package/src/registry/minimax-code-cn.ts +12 -0
- package/src/registry/minimax-code.ts +12 -0
- package/src/registry/minimax.ts +6 -0
- package/src/registry/mistral.ts +6 -0
- package/src/registry/moonshot.ts +22 -0
- package/src/registry/nanogpt.ts +22 -0
- package/src/registry/nvidia.ts +61 -0
- package/src/registry/oauth/__tests__/xai-oauth.test.ts +104 -0
- package/src/registry/oauth/anthropic.ts +311 -0
- package/src/registry/oauth/callback-server.ts +315 -0
- package/src/registry/oauth/cursor.ts +171 -0
- package/src/registry/oauth/devin.ts +124 -0
- package/src/registry/oauth/github-copilot.ts +369 -0
- package/src/registry/oauth/gitlab-duo-workflow.ts +146 -0
- package/src/registry/oauth/gitlab-duo.ts +222 -0
- package/src/registry/oauth/google-antigravity.ts +209 -0
- package/src/registry/oauth/google-gemini-cli.ts +273 -0
- package/src/registry/oauth/google-oauth-shared.ts +125 -0
- package/src/registry/oauth/index.ts +269 -0
- package/src/registry/oauth/kimi.ts +289 -0
- package/src/registry/oauth/minimax-code.ts +53 -0
- package/src/registry/oauth/oauth.html +311 -0
- package/src/registry/oauth/openai-codex.ts +364 -0
- package/src/registry/oauth/opencode.ts +50 -0
- package/src/registry/oauth/perplexity.ts +228 -0
- package/src/registry/oauth/pkce.ts +18 -0
- package/src/registry/oauth/types.ts +65 -0
- package/src/registry/oauth/wafer.ts +24 -0
- package/src/registry/oauth/xai-oauth.ts +394 -0
- package/src/registry/oauth/xiaomi.ts +211 -0
- package/src/registry/ollama-cloud.ts +36 -0
- package/src/registry/ollama.ts +43 -0
- package/src/registry/openai-codex-device.ts +18 -0
- package/src/registry/openai-codex.ts +19 -0
- package/src/registry/openai.ts +6 -0
- package/src/registry/opencode-go.ts +12 -0
- package/src/registry/opencode-zen.ts +12 -0
- package/src/registry/openrouter.ts +28 -0
- package/src/registry/parallel.ts +45 -0
- package/src/registry/perplexity.ts +13 -0
- package/src/registry/qianfan.ts +27 -0
- package/src/registry/qwen-portal.ts +50 -0
- package/src/registry/registry.ts +161 -0
- package/src/registry/sakana.ts +22 -0
- package/src/registry/synthetic.ts +21 -0
- package/src/registry/tavily.ts +45 -0
- package/src/registry/together.ts +22 -0
- package/src/registry/types.ts +56 -0
- package/src/registry/umans.ts +23 -0
- package/src/registry/venice.ts +33 -0
- package/src/registry/vercel-ai-gateway.ts +38 -0
- package/src/registry/vllm.ts +34 -0
- package/src/registry/wafer-serverless.ts +12 -0
- package/src/registry/xai-oauth.ts +17 -0
- package/src/registry/xai.ts +6 -0
- package/src/registry/xiaomi-token-plan-ams.ts +12 -0
- package/src/registry/xiaomi-token-plan-cn.ts +12 -0
- package/src/registry/xiaomi-token-plan-sgp.ts +12 -0
- package/src/registry/xiaomi.ts +12 -0
- package/src/registry/zai.ts +27 -0
- package/src/registry/zenmux.ts +22 -0
- package/src/registry/zhipu-coding-plan.ts +27 -0
- package/src/stream.ts +1778 -0
- package/src/types.ts +856 -0
- package/src/usage/claude.ts +485 -0
- package/src/usage/gemini.ts +258 -0
- package/src/usage/github-copilot.ts +424 -0
- package/src/usage/google-antigravity.ts +497 -0
- package/src/usage/kimi.ts +271 -0
- package/src/usage/minimax-code.ts +30 -0
- package/src/usage/ollama.ts +41 -0
- package/src/usage/openai-codex-base-url.ts +35 -0
- package/src/usage/openai-codex-reset.ts +174 -0
- package/src/usage/openai-codex.ts +535 -0
- package/src/usage/opencode-go.ts +89 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/zai.ts +321 -0
- package/src/usage.ts +333 -0
- package/src/utils/abort.ts +67 -0
- package/src/utils/anthropic-auth.ts +93 -0
- package/src/utils/block-symbols.ts +32 -0
- package/src/utils/deterministic-id.ts +20 -0
- package/src/utils/empty-completion-retry.ts +159 -0
- package/src/utils/event-stream.ts +171 -0
- package/src/utils/foundry.ts +8 -0
- package/src/utils/google-validation.ts +25 -0
- package/src/utils/harmony-leak.ts +456 -0
- package/src/utils/http-inspector.ts +168 -0
- package/src/utils/idle-iterator.ts +473 -0
- package/src/utils/leaked-thinking-stream.ts +294 -0
- package/src/utils/openai-http.ts +122 -0
- package/src/utils/openrouter-headers.ts +12 -0
- package/src/utils/parse-bind.ts +56 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/proxy.ts +240 -0
- package/src/utils/request-debug.ts +351 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry.ts +59 -0
- package/src/utils/schema/CONSTRAINTS.md +166 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.ts +207 -0
- package/src/utils/schema/index.ts +15 -0
- package/src/utils/schema/json-schema-validator.ts +595 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.ts +1901 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.ts +109 -0
- package/src/utils/schema/strict-tool-validation.ts +117 -0
- package/src/utils/schema/types.ts +10 -0
- package/src/utils/schema/typescript.ts +198 -0
- package/src/utils/schema/wire.ts +789 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -0
- package/src/utils/sdk-stream-timeout.ts +43 -0
- package/src/utils/sse-debug.ts +18 -0
- package/src/utils/stream-markup-healing.ts +247 -0
- package/src/utils/thinking-loop.ts +552 -0
- package/src/utils/tool-call-loop-guard.ts +107 -0
- package/src/utils/tool-choice.ts +99 -0
- package/src/utils/validation.ts +1507 -0
- package/src/utils.ts +171 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFoundryEnabled(): boolean;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GPT-5 Harmony-header leakage detection and recovery.
|
|
3
|
+
*
|
|
4
|
+
* Background and policy: see `docs/ERRATA-GPT5-HARMONY.md`. This module
|
|
5
|
+
* implements §3 of that document: detection by signal fusion, plus a
|
|
6
|
+
* truncate-and-resume primitive for the `edit` tool when its input is in
|
|
7
|
+
* hashline DSL form. Other tools and surfaces fall through to
|
|
8
|
+
* abort-and-retry handled by the agent loop.
|
|
9
|
+
*/
|
|
10
|
+
import type { AssistantMessage, Model, ToolCall } from "../types";
|
|
11
|
+
declare const SIGNAL_ORDER: readonly ["M", "C", "G", "S", "B", "R", "T"];
|
|
12
|
+
export type HarmonySignalClass = "H" | (typeof SIGNAL_ORDER)[number];
|
|
13
|
+
export type HarmonySurface = "assistant_text" | "assistant_thinking" | "tool_arg";
|
|
14
|
+
export interface HarmonySignal {
|
|
15
|
+
classes: HarmonySignalClass[];
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HarmonyDetection {
|
|
21
|
+
surface: HarmonySurface;
|
|
22
|
+
contentIndex?: number;
|
|
23
|
+
toolName?: string;
|
|
24
|
+
toolCallId?: string;
|
|
25
|
+
signals: HarmonySignal[];
|
|
26
|
+
}
|
|
27
|
+
export interface HarmonyAuditEvent {
|
|
28
|
+
action: "truncate_resume" | "abort_retry" | "escalated";
|
|
29
|
+
surface: HarmonySurface;
|
|
30
|
+
signal: string;
|
|
31
|
+
retryN: number;
|
|
32
|
+
model: string;
|
|
33
|
+
provider: string;
|
|
34
|
+
toolName?: string;
|
|
35
|
+
removedLen: number;
|
|
36
|
+
removedSha8: string;
|
|
37
|
+
removedPreview: string;
|
|
38
|
+
removedBlob?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface HarmonyRecoveredToolCall {
|
|
41
|
+
message: AssistantMessage;
|
|
42
|
+
removed: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether to run leak detection on responses from this model. We default-on
|
|
46
|
+
* for every openai-codex model rather than enumerating ids, so a future
|
|
47
|
+
* gpt-5.6 (or whatever) doesn't silently bypass the mitigation. Detection
|
|
48
|
+
* itself is cheap; the cost of missing a leak on a new model is not.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isHarmonyLeakMitigationTarget(model: Model): boolean;
|
|
51
|
+
export declare function signalListLabel(signals: readonly HarmonySignal[]): string;
|
|
52
|
+
/**
|
|
53
|
+
* Detect harmony-protocol leakage in `text`. Returns undefined if clean.
|
|
54
|
+
*
|
|
55
|
+
* Trip rule: `H` alone, or `M` paired with at least one co-signal
|
|
56
|
+
* (`C`/`G`/`S`/`B`/`R`/`T`). Bare `M` does not trip — this document, its
|
|
57
|
+
* tests, and bug reports legitimately carry the marker.
|
|
58
|
+
*
|
|
59
|
+
* The `tool_arg` surface is held to a stricter rule. A tool argument is
|
|
60
|
+
* arbitrary file/data content that can legitimately carry the marker, a
|
|
61
|
+
* channel word, harmony control tokens, or a non-Latin script run (editing
|
|
62
|
+
* these very fixtures does exactly that). The only robust leak signal there
|
|
63
|
+
* is content trailing the structurally-valid parse, so a `tool_arg` detection
|
|
64
|
+
* additionally requires the `T` co-signal. Absent a `parsedEnd` boundary `T`
|
|
65
|
+
* is never set, so `tool_arg` scanning stays inert and a legitimate codex tool
|
|
66
|
+
* call is never hard-aborted. `assistant_text`/`assistant_thinking` keep the
|
|
67
|
+
* base rule.
|
|
68
|
+
*
|
|
69
|
+
* `parsedEnd`, when supplied, marks the byte at which a structurally valid
|
|
70
|
+
* tool-argument parse ends; markers at or past it set the `T` co-signal.
|
|
71
|
+
* `contentIndex`/`toolName`/`toolCallId` flow through to the returned
|
|
72
|
+
* detection for downstream auditing.
|
|
73
|
+
*/
|
|
74
|
+
export declare function detectHarmonyLeak(text: string, surface: HarmonySurface, options?: {
|
|
75
|
+
parsedEnd?: number;
|
|
76
|
+
contentIndex?: number;
|
|
77
|
+
toolName?: string;
|
|
78
|
+
toolCallId?: string;
|
|
79
|
+
}): HarmonyDetection | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Scan an assistant message's content blocks; return the first detection.
|
|
82
|
+
*
|
|
83
|
+
* `toolArgParseEnd`, when supplied, resolves the byte offset at which a tool
|
|
84
|
+
* call's structurally-valid argument parse ends (the `T` co-signal in
|
|
85
|
+
* {@link detectHarmonyLeak}). Callers that can parse a tool's argument DSL pass
|
|
86
|
+
* it to enable `tool_arg` leak detection; omitting it keeps that surface inert
|
|
87
|
+
* — the safe default the agent loop relies on, since it cannot bound a streamed
|
|
88
|
+
* tool DSL and must never hard-abort a legitimate tool call.
|
|
89
|
+
*/
|
|
90
|
+
export declare function detectHarmonyLeakInAssistantMessage(message: AssistantMessage, toolArgParseEnd?: (toolCall: ToolCall) => number | undefined): HarmonyDetection | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Truncate a contaminated tool call at the start of the contaminated line and
|
|
93
|
+
* append the tool's recovery sentinel. Returns a recovered AssistantMessage
|
|
94
|
+
* (containing only the cleaned tool call), a synthetic continuation user
|
|
95
|
+
* message asking the model to re-issue the rest, and the removed substring
|
|
96
|
+
* for auditing. Returns undefined when the tool is not recovery-eligible or
|
|
97
|
+
* the truncation would leave nothing meaningful to dispatch.
|
|
98
|
+
*
|
|
99
|
+
* `providerPayload` is dropped from the recovered message: for Codex the
|
|
100
|
+
* encrypted reasoning blob is opaque/signed and we cannot validate that it is
|
|
101
|
+
* uncontaminated. The model re-reasons on the next turn.
|
|
102
|
+
*/
|
|
103
|
+
export declare function recoverHarmonyToolCall(message: AssistantMessage, detection: HarmonyDetection): HarmonyRecoveredToolCall | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Return the contaminated substring from `message` for audit purposes when
|
|
106
|
+
* recovery is not applicable (abort path). Walks from the first detected
|
|
107
|
+
* signal to end-of-content within the relevant block. Returns "" if the
|
|
108
|
+
* detection cannot be resolved against the message.
|
|
109
|
+
*/
|
|
110
|
+
export declare function extractHarmonyRemoved(message: AssistantMessage, detection: HarmonyDetection): string;
|
|
111
|
+
export declare function createHarmonyAuditEvent(params: {
|
|
112
|
+
action: HarmonyAuditEvent["action"];
|
|
113
|
+
detection: HarmonyDetection;
|
|
114
|
+
model: Model;
|
|
115
|
+
retryN: number;
|
|
116
|
+
removed: string;
|
|
117
|
+
}): HarmonyAuditEvent;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type RawHttpRequestDump = {
|
|
2
|
+
provider: string;
|
|
3
|
+
api: string;
|
|
4
|
+
model: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
body?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type CapturedHttpErrorResponse = {
|
|
11
|
+
status: number;
|
|
12
|
+
headers?: Headers;
|
|
13
|
+
bodyText?: string;
|
|
14
|
+
bodyJson?: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare function appendRawHttpRequestDumpFor400(message: string, error: unknown, dump: RawHttpRequestDump | undefined): Promise<string>;
|
|
17
|
+
export declare function finalizeErrorMessage(error: unknown, rawRequestDump: RawHttpRequestDump | undefined, capturedErrorResponse?: CapturedHttpErrorResponse): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Rewrite error message for GitHub Copilot request failures.
|
|
20
|
+
* Must run AFTER finalizeErrorMessage since it replaces the message entirely.
|
|
21
|
+
*
|
|
22
|
+
* 400 `model_not_supported` = Copilot routing rollout gap for our OAuth client.
|
|
23
|
+
* A preview model (gpt-5.3-codex, gpt-5.4*, ...) flaps between 200 and
|
|
24
|
+
* 400 because only some of Copilot's backends have the model. After the
|
|
25
|
+
* in-request retry exhausts, surface guidance rather than the raw error.
|
|
26
|
+
* 401 = token invalid/expired → credential removal is safe, prompt re-login.
|
|
27
|
+
* 403 = token valid but access denied (plan, model policy, org restriction) →
|
|
28
|
+
* do NOT reuse the auth-failed string (which triggers credential removal).
|
|
29
|
+
*/
|
|
30
|
+
export declare function rewriteCopilotError(errorMessage: string, error: unknown, provider: string): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the idle timeout used for provider streaming transports.
|
|
3
|
+
*
|
|
4
|
+
* `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` is accepted as a backward-compatible alias.
|
|
5
|
+
* Set `PI_STREAM_IDLE_TIMEOUT_MS=0` to disable the watchdog.
|
|
6
|
+
*
|
|
7
|
+
* Providers that legitimately stream much slower than the global default can pass
|
|
8
|
+
* `fallbackMs` to widen the floor used when neither env var nor caller option is set.
|
|
9
|
+
* Caller options still take precedence; env overrides still trump the fallback.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getStreamIdleTimeoutMs(fallbackMs?: number): number | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the idle timeout used for OpenAI-family streaming transports.
|
|
14
|
+
*
|
|
15
|
+
* `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` takes precedence over the generic
|
|
16
|
+
* `PI_STREAM_IDLE_TIMEOUT_MS` because some deployments tune OpenAI-compatible
|
|
17
|
+
* backends separately from Anthropic/Gemini-style transports.
|
|
18
|
+
*
|
|
19
|
+
* Set `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS=0` to disable the watchdog.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getOpenAIStreamIdleTimeoutMs(fallbackMs?: number): number | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the timeout used while waiting for the first stream event.
|
|
24
|
+
* The first token can legitimately take longer than later inter-event gaps,
|
|
25
|
+
* so the default never undershoots the steady-state idle timeout.
|
|
26
|
+
*
|
|
27
|
+
* Set `PI_STREAM_FIRST_EVENT_TIMEOUT_MS=0` to disable the watchdog.
|
|
28
|
+
*
|
|
29
|
+
* Providers whose first response can legitimately take longer (heavy reasoning,
|
|
30
|
+
* slow cold-start proxies) can pass `fallbackMs` to widen the floor used when
|
|
31
|
+
* neither env var nor caller option is set. Caller options still take precedence;
|
|
32
|
+
* env overrides still trump the fallback.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getStreamFirstEventTimeoutMs(idleTimeoutMs?: number, fallbackMs?: number): number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the first-event timeout used for OpenAI-family streaming transports.
|
|
37
|
+
*
|
|
38
|
+
* Precedence: explicit `PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS` (including a
|
|
39
|
+
* `"0"` disable) wins outright. Otherwise the resolved idle (caller-supplied
|
|
40
|
+
* `idleTimeoutMs` — which itself already encompasses per-call
|
|
41
|
+
* `streamIdleTimeoutMs` or `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` resolved
|
|
42
|
+
* upstream) floors the first-event budget so slow local OpenAI-compatible
|
|
43
|
+
* servers are not undercut by a shorter `PI_STREAM_FIRST_EVENT_TIMEOUT_MS`
|
|
44
|
+
* or the global default during prompt processing.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when an explicit env knob disables the watchdog.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getOpenAIStreamFirstEventTimeoutMs(idleTimeoutMs?: number, fallbackMs?: number): number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Arms a clearable pre-response (time-to-first-byte) abort guard for a streaming
|
|
51
|
+
* fetch, combined with the caller's signal.
|
|
52
|
+
*
|
|
53
|
+
* `AbortSignal.timeout(ms)` is an *absolute* wall-clock deadline: once handed to
|
|
54
|
+
* `fetch` it keeps governing the request after the response headers arrive, so
|
|
55
|
+
* it aborts an actively-streaming body the moment it fires — not just a stalled
|
|
56
|
+
* pre-response request (issue #2422 regression: large `write` tool-call streams
|
|
57
|
+
* died at the budget with `TimeoutError: The operation timed out.` despite
|
|
58
|
+
* deltas actively flowing). This arms a `clearTimeout`-able timer instead;
|
|
59
|
+
* callers MUST `clear()` as soon as `fetchWithRetry` resolves (headers in) so
|
|
60
|
+
* the body stream is left to the iterator-level idle watchdog. The timer aborts
|
|
61
|
+
* with a `TimeoutError` matching `AbortSignal.timeout`, so a genuine pre-response
|
|
62
|
+
* stall behaves exactly as the prior code did — `fetchWithRetry` normalizes the
|
|
63
|
+
* abort to "Request was aborted" either way (only a post-headers abort ever
|
|
64
|
+
* surfaced the raw `"The operation timed out."`, which clearing now prevents).
|
|
65
|
+
*
|
|
66
|
+
* Returns the caller signal unchanged (and a no-op `clear`) when no positive
|
|
67
|
+
* timeout is configured.
|
|
68
|
+
*/
|
|
69
|
+
export declare function armPreResponseTimeout(callerSignal: AbortSignal | undefined, timeoutMs: number | undefined): {
|
|
70
|
+
signal: AbortSignal | undefined;
|
|
71
|
+
clear: () => void;
|
|
72
|
+
};
|
|
73
|
+
export interface IdleTimeoutIteratorOptions {
|
|
74
|
+
idleTimeoutMs?: number;
|
|
75
|
+
firstItemTimeoutMs?: number;
|
|
76
|
+
errorMessage: string;
|
|
77
|
+
firstItemErrorMessage?: string;
|
|
78
|
+
onIdle?: () => void;
|
|
79
|
+
onFirstItemTimeout?: () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Optional semantic-progress predicate. Non-progress items are still yielded,
|
|
82
|
+
* but they do not reset the idle deadline. This prevents provider
|
|
83
|
+
* keepalive/no-op events from keeping a stalled tool call alive forever.
|
|
84
|
+
*/
|
|
85
|
+
isProgressItem?: (item: unknown) => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Cancel iteration as soon as this signal aborts. Required for caller-driven
|
|
88
|
+
* cancellation (ESC) when the underlying transport does not surface signal
|
|
89
|
+
* aborts to the iterator (HTTP/2 proxies, native sockets, mocked fetch).
|
|
90
|
+
* Without this, the consumer sleeps on iterator.next() until the idle/first
|
|
91
|
+
* -event watchdog fires — observable as the issue #912 "Working… forever"
|
|
92
|
+
* symptom on the github-copilot provider.
|
|
93
|
+
*/
|
|
94
|
+
abortSignal?: AbortSignal;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Yields items from an async iterable while enforcing a maximum idle gap between items.
|
|
98
|
+
*
|
|
99
|
+
* The first item may use a shorter timeout so stuck requests can be aborted and retried
|
|
100
|
+
* before any user-visible content has streamed.
|
|
101
|
+
*/
|
|
102
|
+
export declare function iterateWithIdleTimeout<T>(iterable: AsyncIterable<T>, options: IdleTimeoutIteratorOptions): AsyncGenerator<T>;
|
|
103
|
+
export interface TerminalGraceIteratorOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Epoch-ms timestamp at which the consumer observed a logically terminal
|
|
106
|
+
* item (e.g. a chat-completions chunk carrying `finish_reason`), or
|
|
107
|
+
* `undefined` while the stream is still mid-response. Read before every
|
|
108
|
+
* pull, so the consumer can flip it between yields.
|
|
109
|
+
*/
|
|
110
|
+
finishedAtMs: () => number | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Post-terminal budget: how long after `finishedAtMs()` to keep draining
|
|
113
|
+
* trailing items (e.g. a usage-only chunk or the `[DONE]` sentinel) before
|
|
114
|
+
* ending the iteration cleanly. The deadline is fixed at
|
|
115
|
+
* `finishedAtMs() + graceMs`; trailing items do not extend it, so
|
|
116
|
+
* keepalive-only servers cannot hold the stream open.
|
|
117
|
+
*/
|
|
118
|
+
graceMs: number;
|
|
119
|
+
/**
|
|
120
|
+
* Invoked when the grace window closes with the source still open. Use it
|
|
121
|
+
* to abort the underlying request: the source generator is typically parked
|
|
122
|
+
* mid-`next()` (not at a yield), so a queued `.return()` alone cannot reach
|
|
123
|
+
* the transport until that pending read settles.
|
|
124
|
+
*/
|
|
125
|
+
onGraceEnd?: () => void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Yields items from an async iterable until the consumer marks the stream
|
|
129
|
+
* logically finished AND the source stays silent past a short grace window.
|
|
130
|
+
*
|
|
131
|
+
* Misbehaving OpenAI-compatible servers deliver the terminal chunk but never
|
|
132
|
+
* send `[DONE]` nor close the connection; without this guard the consumer
|
|
133
|
+
* hangs on `iterator.next()` until the idle watchdog converts an
|
|
134
|
+
* already-successful turn into a timeout error. Grace expiry is a clean end
|
|
135
|
+
* of iteration, never an error.
|
|
136
|
+
*/
|
|
137
|
+
export declare function iterateWithTerminalGrace<T>(iterable: AsyncIterable<T>, options: TerminalGraceIteratorOptions): AsyncGenerator<T>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central live healing for leaked reasoning markup in the visible text channel.
|
|
3
|
+
*
|
|
4
|
+
* Some providers emit their canonical reasoning idioms (` ```thinking `,
|
|
5
|
+
* `<think>`, Gemma/Harmony channels, …) into the *visible* text stream instead
|
|
6
|
+
* of a structured thinking part. {@link wrapLeakedThinkingStream} re-projects any
|
|
7
|
+
* provider stream into a fresh {@link AssistantMessageEventStream}, splitting the
|
|
8
|
+
* leaked fences out into proper `thinking` blocks *live* as deltas arrive — so
|
|
9
|
+
* every provider gets the same healing, not just the three with provider-local
|
|
10
|
+
* {@link StreamMarkupHealing} loops.
|
|
11
|
+
*
|
|
12
|
+
* The healing is idempotent: a second pass over already-clean text finds no
|
|
13
|
+
* fences, so wrapping a provider that already heals (or wrapping twice) is a
|
|
14
|
+
* harmless pass-through. Signatures are load-bearing for Google/Gemini/Vertex
|
|
15
|
+
* thought round-tripping, so text sub-blocks carry the source `textSignature`,
|
|
16
|
+
* forwarded thinking blocks their `thinkingSignature`, and forwarded tool calls
|
|
17
|
+
* their `thoughtSignature`.
|
|
18
|
+
*
|
|
19
|
+
* Modeled on {@link wrapInbandToolStream} / `InbandStreamProjector` in
|
|
20
|
+
* `../dialect/owned-stream.ts`, minus all in-band tool-call grammar: tool-call
|
|
21
|
+
* events are forwarded verbatim.
|
|
22
|
+
*/
|
|
23
|
+
import { AssistantMessageEventStream } from "./event-stream";
|
|
24
|
+
/**
|
|
25
|
+
* Wrap a provider stream so leaked reasoning fences are healed into thinking
|
|
26
|
+
* blocks live, for every provider. Returns a new stream that re-projects the
|
|
27
|
+
* inner one; the inner stream is fully consumed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function wrapLeakedThinkingStream(inner: AssistantMessageEventStream): AssistantMessageEventStream;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-POST → SSE transport for OpenAI-wire streaming endpoints (chat
|
|
3
|
+
* completions, responses, azure responses). Replaces the `openai` SDK client:
|
|
4
|
+
*
|
|
5
|
+
* - Retries: `fetchWithRetry` (Retry-After/quota-hint aware; 5xx/408/429 and
|
|
6
|
+
* transient network errors). Default 6 total attempts — parity with the
|
|
7
|
+
* SDK's former `maxRetries: 5`.
|
|
8
|
+
* - SSE decode: `readSseJson` (spec-compliant framing, `[DONE]`-aware).
|
|
9
|
+
* `onSseEvent` observers now receive real wire frames instead of events
|
|
10
|
+
* re-synthesized from decoded SDK objects.
|
|
11
|
+
* - Errors: {@link OpenAIHttpError} exposes `status`/`headers`/`code`
|
|
12
|
+
* structurally (ProviderHttpError contract — `extractHttpStatusFromError`,
|
|
13
|
+
* retry-after extraction, copilot transient classification) and carries the
|
|
14
|
+
* captured response body for the strict-tools fallback and the responses
|
|
15
|
+
* chain-state detectors, which regex over `error.message`.
|
|
16
|
+
*/
|
|
17
|
+
import { type SseEventObserver } from "jeopi-utils";
|
|
18
|
+
import * as AIError from "../error";
|
|
19
|
+
import { OpenAIHttpError } from "../error";
|
|
20
|
+
export { OpenAIHttpError };
|
|
21
|
+
import type { FetchImpl } from "../types";
|
|
22
|
+
export interface OpenAIStreamRequestInit {
|
|
23
|
+
url: string;
|
|
24
|
+
headers: Record<string, string>;
|
|
25
|
+
/** JSON request body; serialized once per call (retries resend the same bytes). */
|
|
26
|
+
body: unknown;
|
|
27
|
+
signal: AbortSignal;
|
|
28
|
+
fetch?: FetchImpl;
|
|
29
|
+
/**
|
|
30
|
+
* Total attempts (initial + retries). Defaults to {@link DEFAULT_MAX_ATTEMPTS}.
|
|
31
|
+
* Pass `1` when a first-event watchdog is armed so retries cannot silently
|
|
32
|
+
* extend the caller's deadline (mirrors the old `maxRetries: 0` hint).
|
|
33
|
+
*/
|
|
34
|
+
maxAttempts?: number;
|
|
35
|
+
/** Raw wire-frame observer (`onSseEvent` debug pipeline). */
|
|
36
|
+
onSseEvent?: SseEventObserver;
|
|
37
|
+
}
|
|
38
|
+
export interface OpenAIStreamHandle<TEvent> {
|
|
39
|
+
/** Decoded `data:` payloads; terminates on `[DONE]` or stream end. */
|
|
40
|
+
events: AsyncGenerator<TEvent>;
|
|
41
|
+
response: Response;
|
|
42
|
+
/** `x-request-id` response header (the SDK's former `request_id`). */
|
|
43
|
+
requestId: string | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* POST a JSON body and stream back decoded SSE events.
|
|
47
|
+
*
|
|
48
|
+
* Throws {@link OpenAIHttpError} on a non-2xx terminal response. Aborts on
|
|
49
|
+
* `signal` propagate from `fetchWithRetry`/`readSseJson`; callers own the
|
|
50
|
+
* watchdog timers and abort-reason bookkeeping.
|
|
51
|
+
*/
|
|
52
|
+
export declare function postOpenAIStream<TEvent>(init: OpenAIStreamRequestInit): Promise<OpenAIStreamHandle<TEvent>>;
|
|
53
|
+
/** Decode a non-2xx response into an {@link OpenAIHttpError} without consuming it twice. */
|
|
54
|
+
export declare function captureOpenAIHttpError(response: Response): Promise<AIError.OpenAIHttpError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getOpenRouterHeaders(): Record<string, string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `host:port` parser used by the auth-broker and auth-gateway boot
|
|
3
|
+
* paths. Centralized so the two servers can't drift on what they accept (the
|
|
4
|
+
* gateway used to silently allow empty hostnames; this fixes it).
|
|
5
|
+
*/
|
|
6
|
+
export interface ParsedBind {
|
|
7
|
+
hostname: string;
|
|
8
|
+
port: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse a `host:port` (or bare `port`, which assumes loopback) string.
|
|
12
|
+
*
|
|
13
|
+
* Accepts:
|
|
14
|
+
* - `"4000"` → `127.0.0.1:4000`
|
|
15
|
+
* - `"0.0.0.0:4000"` → as written
|
|
16
|
+
* - `"[::1]:4000"` → as written (brackets retained, Bun handles them)
|
|
17
|
+
*
|
|
18
|
+
* Rejects:
|
|
19
|
+
* - empty input
|
|
20
|
+
* - empty hostname (`":4000"`)
|
|
21
|
+
* - non-integer / out-of-range port
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseBind(raw: string): ParsedBind;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Api, Model, ProviderResponseMetadata, StreamOptions } from "../types";
|
|
2
|
+
export declare function normalizeProviderResponse(response: Response, requestId?: string | null, metadata?: Record<string, unknown>): ProviderResponseMetadata;
|
|
3
|
+
export declare function notifyProviderResponse(options: Pick<StreamOptions, "onResponse"> | undefined, response: Response, model?: Model<Api>, requestId?: string | null, metadata?: Record<string, unknown>): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as tls from "node:tls";
|
|
2
|
+
import type { FetchImpl } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a host is local or cloud metadata, which should always bypass the proxy
|
|
5
|
+
* (e.g. localhost, 127/8, ::1, 169.254.169.254, metadata.google.internal).
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLocalOrMetadataHost(host: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the url should bypass the proxy due to hard-coded localhost/metadata checks
|
|
10
|
+
* or custom NO_PROXY/no_proxy environment variables rules.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shouldBypassProxy(urlObj: URL): boolean;
|
|
13
|
+
/** Test seam: clears the provider proxy cache. */
|
|
14
|
+
export declare function __resetProxyCache(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes provider id (e.g. github-copilot -> PI_PROXY_GITHUB_COPILOT) and looks it up.
|
|
17
|
+
* If not found, falls back to PI_PROXY. Results are memoized because env values are static
|
|
18
|
+
* for the lifetime of the process and this function is called for every outgoing request.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getProxyForProvider(provider: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Wraps a fetch implementation to inject proxy options for non-local hosts.
|
|
23
|
+
*/
|
|
24
|
+
export declare function wrapFetchForProxy(fetchImpl: FetchImpl, provider: string): FetchImpl;
|
|
25
|
+
/**
|
|
26
|
+
* Tunnel a socket connection through an HTTP CONNECT proxy.
|
|
27
|
+
* This is used specifically to wrap Node's `http2.connect(baseUrl, { createConnection })` for Cursor.
|
|
28
|
+
*/
|
|
29
|
+
export declare function connectProxiedSocket(proxyUrlStr: string, targetUrlStr: string): Promise<tls.TLSSocket>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FetchImpl } from "../types";
|
|
2
|
+
export type RequestDebugHeaders = Headers | Record<string, string | string[] | number | undefined | null> | undefined;
|
|
3
|
+
export interface RequestDebugPayload {
|
|
4
|
+
method: string;
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: RequestDebugHeaders;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
bodyText?: string;
|
|
9
|
+
bodyBase64?: string;
|
|
10
|
+
bodyUnavailable?: string;
|
|
11
|
+
protocol?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RequestDebugResponseLog {
|
|
14
|
+
write(chunk: Uint8Array | string): void;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface RequestDebugSession {
|
|
18
|
+
readonly id: number;
|
|
19
|
+
readonly requestPath: string;
|
|
20
|
+
readonly responsePath: string;
|
|
21
|
+
openResponseLog(statusLine: string, headers?: RequestDebugHeaders): Promise<RequestDebugResponseLog>;
|
|
22
|
+
wrapResponse(response: Response): Promise<Response>;
|
|
23
|
+
}
|
|
24
|
+
export declare function isRequestDebugEnabled(): boolean;
|
|
25
|
+
export declare function wrapFetchForRequestDebug(fetchImpl: FetchImpl): FetchImpl;
|
|
26
|
+
export declare function withRequestDebugFetch<T extends {
|
|
27
|
+
fetch?: FetchImpl;
|
|
28
|
+
} | undefined>(options: T): T;
|
|
29
|
+
export declare function createRequestDebugSession(payload: RequestDebugPayload): Promise<RequestDebugSession>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type HeadersLike = Headers | Record<string, string | undefined> | undefined | null;
|
|
2
|
+
export declare function formatErrorMessageWithRetryAfter(error: unknown, headers?: HeadersLike): string;
|
|
3
|
+
export declare function getRetryAfterMsFromHeaders(headers: HeadersLike): number | undefined;
|
|
4
|
+
export declare function getHeadersFromError(error: unknown): HeadersLike;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isCopilotTransientModelError } from "../error/flags";
|
|
2
|
+
export { isCopilotTransientModelError };
|
|
3
|
+
/**
|
|
4
|
+
* Wrap an initial Copilot request so transient `model_not_supported` 400s are
|
|
5
|
+
* retried a small number of times. No-op for non-Copilot providers.
|
|
6
|
+
*
|
|
7
|
+
* The callback **MUST** create a fresh in-flight request each invocation — a
|
|
8
|
+
* once-consumed AsyncIterable cannot be re-iterated.
|
|
9
|
+
*/
|
|
10
|
+
export declare function callWithCopilotModelRetry<T>(fn: () => Promise<T>, options: {
|
|
11
|
+
provider: string;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
retryBaseDelayMs?: number;
|
|
14
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set when callers want to globally bypass OpenAI strict-mode enforcement
|
|
3
|
+
* (e.g. for debugging a provider that misreports strict support, or when
|
|
4
|
+
* comparing strict vs non-strict outputs).
|
|
5
|
+
*
|
|
6
|
+
* Honored by every provider that emits `strict: true` on its function tools —
|
|
7
|
+
* see `openai-completions`, `openai-responses`, `openai-codex-responses`, and
|
|
8
|
+
* the strict candidate selection in `anthropic`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NO_STRICT: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Consolidated helper for OpenAI-style strict schema enforcement.
|
|
13
|
+
*
|
|
14
|
+
* Each provider computes its own `strict` boolean (logic differs), then calls
|
|
15
|
+
* this to handle the tryEnforceStrictSchema dance uniformly:
|
|
16
|
+
* - Draft-07-shaped inputs are upgraded to draft 2020-12 first.
|
|
17
|
+
* - If `strict` is false, passes the upgraded schema through unchanged.
|
|
18
|
+
* - If `strict` is true, attempts to enforce strict mode; falls back to
|
|
19
|
+
* non-strict if the schema isn't representable.
|
|
20
|
+
*/
|
|
21
|
+
export declare function adaptSchemaForStrict(schema: Record<string, unknown>, strict: boolean): {
|
|
22
|
+
schema: Record<string, unknown>;
|
|
23
|
+
strict: boolean;
|
|
24
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema compatibility audits.
|
|
3
|
+
*
|
|
4
|
+
* Each provider has a different idea of what JSON Schema features it accepts
|
|
5
|
+
* for tool definitions. The normalizers in `normalize.ts`, `strict-mode`,
|
|
6
|
+
* and `adapt.ts` rewrite incoming schemas to fit. This module is the
|
|
7
|
+
* *audit* counterpart: it walks a (presumably already-sanitized) schema and
|
|
8
|
+
* reports any feature the target provider would reject. Tests use it to lock
|
|
9
|
+
* down the contract; the runtime uses it to fail-open with diagnostic logs
|
|
10
|
+
* rather than silently shipping a broken tool definition.
|
|
11
|
+
*/
|
|
12
|
+
export type SchemaCompatibilityProvider = "openai-strict" | "google" | "cloud-code-assist-claude";
|
|
13
|
+
export interface SchemaCompatibilityViolation {
|
|
14
|
+
path: string;
|
|
15
|
+
rule: string;
|
|
16
|
+
message: string;
|
|
17
|
+
key?: string;
|
|
18
|
+
value?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface SchemaCompatibilityResult {
|
|
21
|
+
provider: SchemaCompatibilityProvider;
|
|
22
|
+
compatible: boolean;
|
|
23
|
+
violations: SchemaCompatibilityViolation[];
|
|
24
|
+
}
|
|
25
|
+
export interface StrictSchemaEnforcementResult {
|
|
26
|
+
schema: Record<string, unknown>;
|
|
27
|
+
strict: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function validateSchemaCompatibility(schema: unknown, provider: SchemaCompatibilityProvider): SchemaCompatibilityResult;
|
|
30
|
+
export declare function validateStrictSchemaEnforcement(originalSchema: Record<string, unknown>, result: StrictSchemaEnforcementResult): SchemaCompatibilityResult;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dereference all local `$ref` pointers in a JSON Schema, inlining definitions
|
|
3
|
+
* from `$defs` / `definitions`. The `$defs` block is stripped from the output.
|
|
4
|
+
*
|
|
5
|
+
* Non-local refs (e.g. `http://...`) are left untouched.
|
|
6
|
+
* Circular references are broken with `{}`.
|
|
7
|
+
*
|
|
8
|
+
* @returns A new schema object with all local refs inlined, or the input unchanged
|
|
9
|
+
* if it's not an object or has no `$defs`/`definitions`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dereferenceJsonSchema(schema: unknown): unknown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const JSON_SCHEMA_DRAFT_2020_12_URI = "https://json-schema.org/draft/2020-12/schema";
|
|
2
|
+
/** Pre-check entrypoint. Exposed so callers can decide whether to take the upgrade path at all. */
|
|
3
|
+
export declare function schemaNeedsDraft202012Upgrade(schema: unknown): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Upgrade legacy JSON Schema shapes to the draft 2020-12 form emitted by Zod.
|
|
6
|
+
*
|
|
7
|
+
* This keeps extension/MCP/TypeBox schemas compatible with providers whose tool
|
|
8
|
+
* validators reject draft-07 tuple and dependency keywords.
|
|
9
|
+
*/
|
|
10
|
+
export declare function upgradeJsonSchemaTo202012(schema: unknown): unknown;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JsonObject } from "./types";
|
|
2
|
+
export declare function areJsonValuesEqual(left: unknown, right: unknown): boolean;
|
|
3
|
+
export declare function mergeCompatibleEnumSchemas(existing: unknown, incoming: unknown): JsonObject | null;
|
|
4
|
+
export declare function mergePropertySchemas(existing: unknown, incoming: unknown): unknown;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field classification sets for JSON Schema sanitization across providers.
|
|
3
|
+
*
|
|
4
|
+
* Each set serves a different provider need. They overlap intentionally —
|
|
5
|
+
* co-locating them makes the overlap visible and maintainable.
|
|
6
|
+
*
|
|
7
|
+
* All keysets here are static and small (≤ ~40 entries) so they live as
|
|
8
|
+
* `Record<string, true>` literals — `k in REC` resolves through hidden
|
|
9
|
+
* class inline caches without the per-call hashtable cost of `Set.has`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Google Generative AI unsupported schema fields.
|
|
13
|
+
* Stripped during normalizeSchemaForGoogle / normalizeSchemaForCCA.
|
|
14
|
+
*/
|
|
15
|
+
export declare const UNSUPPORTED_SCHEMA_FIELDS: Record<string, true>;
|
|
16
|
+
/**
|
|
17
|
+
* Human-meaningful validation/decorative keywords that can be preserved in a
|
|
18
|
+
* sibling description when a provider-specific normalizer strips them from the
|
|
19
|
+
* wire schema.
|
|
20
|
+
*/
|
|
21
|
+
export declare const LIFTABLE_TO_DESCRIPTION_FIELDS: Record<string, true>;
|
|
22
|
+
/**
|
|
23
|
+
* Non-structural schema keys stripped during OpenAI strict mode sanitization.
|
|
24
|
+
* These are decorative/validation-only keywords that don't affect the structural
|
|
25
|
+
* shape OpenAI's strict mode enforces.
|
|
26
|
+
*/
|
|
27
|
+
export declare const NON_STRUCTURAL_SCHEMA_KEYS: Record<string, true>;
|
|
28
|
+
/**
|
|
29
|
+
* Cloud Code Assist type-specific allowed keys per JSON Schema type.
|
|
30
|
+
* Used when collapsing mixed-type combiner variants for CCA Claude.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CLOUD_CODE_ASSIST_TYPE_SPECIFIC_KEYS: Record<string, Record<string, true>>;
|
|
33
|
+
/**
|
|
34
|
+
* Flat set of every type-specific key across all CCA types.
|
|
35
|
+
* Used to identify sibling keys that need filtering during mixed-type collapse.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ALL_CCA_TYPE_SPECIFIC_KEYS: Record<string, true>;
|
|
38
|
+
/**
|
|
39
|
+
* Cloud Code Assist shared schema keys allowed on any type.
|
|
40
|
+
* Used alongside CLOUD_CODE_ASSIST_TYPE_SPECIFIC_KEYS for CCA combiner collapsing.
|
|
41
|
+
*/
|
|
42
|
+
export declare const CLOUD_CODE_ASSIST_SHARED_SCHEMA_KEYS: Record<string, true>;
|
|
43
|
+
/**
|
|
44
|
+
* Combinator keys used across schema sanitization modules.
|
|
45
|
+
* Defined once to avoid duplication in strict-mode.ts and normalize.ts.
|
|
46
|
+
*/
|
|
47
|
+
export declare const COMBINATOR_KEYS: readonly ["anyOf", "allOf", "oneOf"];
|
|
48
|
+
/**
|
|
49
|
+
* Cloud Code Assist Claude unsupported schema fields.
|
|
50
|
+
* Much smaller than UNSUPPORTED_SCHEMA_FIELDS (Google) because CCA supports
|
|
51
|
+
* validation keywords like additionalProperties, minLength, pattern, etc.
|
|
52
|
+
* Meta/reference keywords plus object-key validators that CCA cannot resolve are stripped.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CCA_UNSUPPORTED_SCHEMA_FIELDS: Record<string, true>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./adapt";
|
|
2
|
+
export * from "./compatibility";
|
|
3
|
+
export * from "./dereference";
|
|
4
|
+
export * from "./draft";
|
|
5
|
+
export * from "./equality";
|
|
6
|
+
export * from "./fields";
|
|
7
|
+
export * from "./json-schema-validator";
|
|
8
|
+
export * from "./meta-validator";
|
|
9
|
+
export * from "./normalize";
|
|
10
|
+
export * from "./spill";
|
|
11
|
+
export * from "./strict-tool-validation";
|
|
12
|
+
export * from "./types";
|
|
13
|
+
export * from "./typescript";
|
|
14
|
+
export * from "./wire";
|
|
15
|
+
export * from "./zod-decontaminate";
|