@vib-rato/ai 0.16.0
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 +3354 -0
- package/README.md +1194 -0
- package/dist/types/adapter-internals/provider-safety-stop.d.ts +45 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +80 -0
- package/dist/types/auth-broker/index.d.ts +5 -0
- package/dist/types/auth-broker/redact.d.ts +7 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +153 -0
- package/dist/types/auth-broker/server.d.ts +32 -0
- package/dist/types/auth-broker/types.d.ts +132 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +555 -0
- package/dist/types/auth-gateway/http.d.ts +40 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +70 -0
- package/dist/types/auth-gateway/types.d.ts +129 -0
- package/dist/types/auth-storage.d.ts +1074 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/codex-tools.d.ts +4 -0
- package/dist/types/context-cap-policy.d.ts +68 -0
- package/dist/types/core.d.ts +35 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/model-cache.d.ts +24 -0
- package/dist/types/model-manager.d.ts +77 -0
- package/dist/types/model-pricing.d.ts +3 -0
- package/dist/types/model-retirements.d.ts +6 -0
- package/dist/types/model-thinking.d.ts +100 -0
- package/dist/types/models.d.ts +21 -0
- package/dist/types/openai-completions-compat.d.ts +34 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/provider-models/bundled-references.d.ts +4 -0
- package/dist/types/provider-models/descriptors.d.ts +48 -0
- package/dist/types/provider-models/google.d.ts +20 -0
- package/dist/types/provider-models/index.d.ts +5 -0
- package/dist/types/provider-models/ollama.d.ts +7 -0
- package/dist/types/provider-models/openai-compat.d.ts +293 -0
- package/dist/types/provider-models/special.d.ts +29 -0
- package/dist/types/providers/amazon-bedrock.d.ts +60 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +450 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic.d.ts +280 -0
- package/dist/types/providers/aws-credential-config.d.ts +19 -0
- package/dist/types/providers/aws-credentials.d.ts +43 -0
- package/dist/types/providers/aws-eventstream.d.ts +38 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +22 -0
- package/dist/types/providers/composer-discipline.d.ts +32 -0
- package/dist/types/providers/cursor/client-version.d.ts +10 -0
- package/dist/types/providers/cursor/exec-modern.d.ts +98 -0
- package/dist/types/providers/cursor/gen/agent_pb.d.ts +16769 -0
- package/dist/types/providers/cursor-pi-args.d.ts +119 -0
- package/dist/types/providers/cursor.d.ts +72 -0
- package/dist/types/providers/dashscope-token-plan-headers.d.ts +57 -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.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +26 -0
- package/dist/types/providers/google-gemini-cli.d.ts +75 -0
- package/dist/types/providers/google-gemini-headers.d.ts +43 -0
- package/dist/types/providers/google-shared.d.ts +183 -0
- package/dist/types/providers/google-types.d.ts +138 -0
- package/dist/types/providers/google-vertex.d.ts +11 -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/kiro-api-key.d.ts +50 -0
- package/dist/types/providers/kiro-codewhisperer.d.ts +11 -0
- package/dist/types/providers/mock.d.ts +189 -0
- package/dist/types/providers/ollama.d.ts +41 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-bounded-rate-limits.d.ts +3 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +1733 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-codex/constants.d.ts +26 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +50 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +18 -0
- package/dist/types/providers/openai-codex-responses.d.ts +71 -0
- package/dist/types/providers/openai-completions-compat.d.ts +6 -0
- package/dist/types/providers/openai-completions.d.ts +35 -0
- package/dist/types/providers/openai-opencodex-responses.d.ts +10 -0
- package/dist/types/providers/openai-request-transform.d.ts +4 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +392 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-shared.d.ts +106 -0
- package/dist/types/providers/openai-responses.d.ts +37 -0
- package/dist/types/providers/pi-native-client.d.ts +29 -0
- package/dist/types/providers/pi-native-server.d.ts +60 -0
- package/dist/types/providers/register-builtins.d.ts +59 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +33 -0
- package/dist/types/providers/vision-guard.d.ts +8 -0
- package/dist/types/rate-limit-utils.d.ts +19 -0
- package/dist/types/stream.d.ts +45 -0
- package/dist/types/types.d.ts +1073 -0
- package/dist/types/usage/claude.d.ts +3 -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 +2 -0
- package/dist/types/usage/grok-cli.d.ts +17 -0
- package/dist/types/usage/kimi.d.ts +4 -0
- package/dist/types/usage/minimax-code.d.ts +2 -0
- package/dist/types/usage/openai-codex.d.ts +3 -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 +264 -0
- package/dist/types/utils/abort.d.ts +19 -0
- package/dist/types/utils/anthropic-auth.d.ts +39 -0
- package/dist/types/utils/block-symbols.d.ts +6 -0
- package/dist/types/utils/discovery/antigravity.d.ts +67 -0
- package/dist/types/utils/discovery/codex.d.ts +38 -0
- package/dist/types/utils/discovery/cursor.d.ts +49 -0
- package/dist/types/utils/discovery/gemini.d.ts +25 -0
- package/dist/types/utils/discovery/index.d.ts +4 -0
- package/dist/types/utils/discovery/openai-compatible.d.ts +81 -0
- package/dist/types/utils/event-stream.d.ts +41 -0
- package/dist/types/utils/fallback-transport.d.ts +110 -0
- package/dist/types/utils/fireworks-model-id.d.ts +10 -0
- package/dist/types/utils/foundry.d.ts +11 -0
- package/dist/types/utils/h2-fetch.d.ts +22 -0
- package/dist/types/utils/http-inspector.d.ts +59 -0
- package/dist/types/utils/idle-iterator.d.ts +122 -0
- package/dist/types/utils/json-parse.d.ts +98 -0
- package/dist/types/utils/oauth/alibaba-token-plan.d.ts +19 -0
- package/dist/types/utils/oauth/anthropic.d.ts +41 -0
- package/dist/types/utils/oauth/api-key-login.d.ts +38 -0
- package/dist/types/utils/oauth/api-key-validation.d.ts +39 -0
- package/dist/types/utils/oauth/bizrouter.d.ts +1 -0
- package/dist/types/utils/oauth/callback-server.d.ts +80 -0
- package/dist/types/utils/oauth/cerebras.d.ts +1 -0
- package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/commandcode.d.ts +1 -0
- package/dist/types/utils/oauth/cursor.d.ts +15 -0
- package/dist/types/utils/oauth/deepinfra.d.ts +1 -0
- package/dist/types/utils/oauth/deepseek.d.ts +10 -0
- package/dist/types/utils/oauth/firepass.d.ts +1 -0
- package/dist/types/utils/oauth/fireworks.d.ts +1 -0
- package/dist/types/utils/oauth/fugu.d.ts +1 -0
- package/dist/types/utils/oauth/github-copilot.d.ts +38 -0
- package/dist/types/utils/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/utils/oauth/glm-zcode.d.ts +71 -0
- package/dist/types/utils/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/utils/oauth/google-gemini-cli.d.ts +10 -0
- package/dist/types/utils/oauth/google-oauth-shared.d.ts +28 -0
- package/dist/types/utils/oauth/huggingface.d.ts +19 -0
- package/dist/types/utils/oauth/index.d.ts +39 -0
- package/dist/types/utils/oauth/kagi.d.ts +17 -0
- package/dist/types/utils/oauth/kilo.d.ts +5 -0
- package/dist/types/utils/oauth/kimi.d.ts +17 -0
- package/dist/types/utils/oauth/kiro.d.ts +71 -0
- package/dist/types/utils/oauth/litellm.d.ts +18 -0
- package/dist/types/utils/oauth/lm-studio.d.ts +17 -0
- package/dist/types/utils/oauth/mara.d.ts +1 -0
- package/dist/types/utils/oauth/minimax-code.d.ts +28 -0
- package/dist/types/utils/oauth/moonshot.d.ts +1 -0
- package/dist/types/utils/oauth/nanogpt.d.ts +1 -0
- package/dist/types/utils/oauth/nvidia.d.ts +18 -0
- package/dist/types/utils/oauth/ollama-cloud.d.ts +2 -0
- package/dist/types/utils/oauth/ollama.d.ts +18 -0
- package/dist/types/utils/oauth/openai-codex.d.ts +21 -0
- package/dist/types/utils/oauth/opencode.d.ts +18 -0
- package/dist/types/utils/oauth/opengateway.d.ts +1 -0
- package/dist/types/utils/oauth/openrouter.d.ts +1 -0
- package/dist/types/utils/oauth/parallel.d.ts +17 -0
- package/dist/types/utils/oauth/perplexity.d.ts +4 -0
- package/dist/types/utils/oauth/pkce.d.ts +8 -0
- package/dist/types/utils/oauth/qianfan.d.ts +17 -0
- package/dist/types/utils/oauth/qwen-portal.d.ts +19 -0
- package/dist/types/utils/oauth/sglang.d.ts +16 -0
- package/dist/types/utils/oauth/synthetic.d.ts +1 -0
- package/dist/types/utils/oauth/tavily.d.ts +17 -0
- package/dist/types/utils/oauth/together.d.ts +1 -0
- package/dist/types/utils/oauth/types.d.ts +56 -0
- package/dist/types/utils/oauth/venice.d.ts +18 -0
- package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/vllm.d.ts +16 -0
- package/dist/types/utils/oauth/xai.d.ts +30 -0
- package/dist/types/utils/oauth/xiaomi.d.ts +25 -0
- package/dist/types/utils/oauth/zai.d.ts +18 -0
- package/dist/types/utils/oauth/zenmux.d.ts +1 -0
- package/dist/types/utils/overflow.d.ts +14 -0
- package/dist/types/utils/parse-bind.d.ts +26 -0
- package/dist/types/utils/provider-response.d.ts +6 -0
- package/dist/types/utils/provider-safety-stop.d.ts +8 -0
- package/dist/types/utils/proxy.d.ts +7 -0
- package/dist/types/utils/retry-after.d.ts +3 -0
- package/dist/types/utils/retry-budget.d.ts +1 -0
- package/dist/types/utils/retry.d.ts +29 -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 +49 -0
- package/dist/types/utils/schema/index.d.ts +14 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +12 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +93 -0
- package/dist/types/utils/schema/root-combinator.d.ts +12 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +25 -0
- package/dist/types/utils/schema/types.d.ts +4 -0
- package/dist/types/utils/schema/wire.d.ts +54 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
- package/dist/types/utils/sse-debug.d.ts +10 -0
- package/dist/types/utils/tool-call-healing.d.ts +80 -0
- package/dist/types/utils/tool-choice-capability.d.ts +57 -0
- package/dist/types/utils/tool-choice.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +17 -0
- package/dist/types/utils.d.ts +117 -0
- package/package.json +152 -0
- package/src/adapter-internals/provider-safety-stop.d.ts +45 -0
- package/src/adapter-internals/provider-safety-stop.ts +156 -0
- package/src/api-registry.d.ts +30 -0
- package/src/api-registry.ts +96 -0
- package/src/auth-broker/client.ts +444 -0
- package/src/auth-broker/index.ts +5 -0
- package/src/auth-broker/redact.ts +39 -0
- package/src/auth-broker/refresher.ts +130 -0
- package/src/auth-broker/remote-store.ts +1576 -0
- package/src/auth-broker/server.ts +764 -0
- package/src/auth-broker/types.ts +164 -0
- package/src/auth-broker/wire-schemas.ts +261 -0
- package/src/auth-gateway/http.ts +198 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +1315 -0
- package/src/auth-gateway/types.ts +160 -0
- package/src/auth-storage.ts +7312 -0
- package/src/cli.ts +269 -0
- package/src/codex-tools.d.ts +4 -0
- package/src/codex-tools.ts +24 -0
- package/src/context-cap-policy.d.ts +68 -0
- package/src/context-cap-policy.ts +123 -0
- package/src/core.ts +44 -0
- package/src/index.ts +61 -0
- package/src/model-cache.ts +236 -0
- package/src/model-manager.ts +744 -0
- package/src/model-pricing.d.ts +3 -0
- package/src/model-pricing.ts +68 -0
- package/src/model-retirements.d.ts +6 -0
- package/src/model-retirements.ts +19 -0
- package/src/model-thinking.d.ts +100 -0
- package/src/model-thinking.ts +1054 -0
- package/src/models.d.ts +21 -0
- package/src/models.json +94672 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +126 -0
- package/src/openai-completions-compat.d.ts +34 -0
- package/src/openai-completions-compat.ts +383 -0
- package/src/prompts/composer-bash-policy-recovery.md +1 -0
- package/src/prompts/cursor-composer-bash-policy-recovery.md +1 -0
- package/src/prompts/cursor-composer-edit-discipline.md +7 -0
- package/src/prompts/turn-aborted-guidance.md +4 -0
- package/src/provider-details.ts +90 -0
- package/src/provider-models/bundled-references.ts +38 -0
- package/src/provider-models/descriptors.ts +392 -0
- package/src/provider-models/google.ts +92 -0
- package/src/provider-models/index.ts +5 -0
- package/src/provider-models/ollama.ts +159 -0
- package/src/provider-models/openai-compat.ts +2920 -0
- package/src/provider-models/special.ts +185 -0
- package/src/providers/amazon-bedrock.d.ts +60 -0
- package/src/providers/amazon-bedrock.ts +939 -0
- package/src/providers/anthropic-messages-server-schema.ts +229 -0
- package/src/providers/anthropic-messages-server.ts +839 -0
- package/src/providers/anthropic.d.ts +280 -0
- package/src/providers/anthropic.ts +4421 -0
- package/src/providers/aws-credential-config.d.ts +19 -0
- package/src/providers/aws-credential-config.ts +179 -0
- package/src/providers/aws-credentials.d.ts +43 -0
- package/src/providers/aws-credentials.ts +457 -0
- package/src/providers/aws-eventstream.d.ts +38 -0
- package/src/providers/aws-eventstream.ts +185 -0
- package/src/providers/aws-sigv4.d.ts +55 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.d.ts +22 -0
- package/src/providers/azure-openai-responses.ts +447 -0
- package/src/providers/composer-discipline.d.ts +32 -0
- package/src/providers/composer-discipline.ts +95 -0
- package/src/providers/cursor/client-version.d.ts +10 -0
- package/src/providers/cursor/client-version.ts +10 -0
- package/src/providers/cursor/exec-modern.d.ts +98 -0
- package/src/providers/cursor/exec-modern.ts +497 -0
- package/src/providers/cursor/gen/agent_pb.d.ts +16769 -0
- package/src/providers/cursor/gen/agent_pb.ts +19780 -0
- package/src/providers/cursor/proto/agent.proto +4533 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor-pi-args.d.ts +119 -0
- package/src/providers/cursor-pi-args.ts +187 -0
- package/src/providers/cursor.d.ts +72 -0
- package/src/providers/cursor.ts +3396 -0
- package/src/providers/dashscope-token-plan-headers.d.ts +57 -0
- package/src/providers/dashscope-token-plan-headers.ts +84 -0
- package/src/providers/error-message.d.ts +27 -0
- package/src/providers/error-message.ts +21 -0
- package/src/providers/github-copilot-headers.d.ts +40 -0
- package/src/providers/github-copilot-headers.ts +140 -0
- package/src/providers/gitlab-duo.d.ts +27 -0
- package/src/providers/gitlab-duo.ts +393 -0
- package/src/providers/google-auth.d.ts +26 -0
- package/src/providers/google-auth.ts +262 -0
- package/src/providers/google-gemini-cli.d.ts +75 -0
- package/src/providers/google-gemini-cli.ts +969 -0
- package/src/providers/google-gemini-headers.d.ts +43 -0
- package/src/providers/google-gemini-headers.ts +100 -0
- package/src/providers/google-shared.d.ts +183 -0
- package/src/providers/google-shared.ts +1105 -0
- package/src/providers/google-types.d.ts +138 -0
- package/src/providers/google-types.ts +167 -0
- package/src/providers/google-vertex.d.ts +11 -0
- package/src/providers/google-vertex.ts +124 -0
- package/src/providers/google.d.ts +4 -0
- package/src/providers/google.ts +41 -0
- package/src/providers/grammar.d.ts +1 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.d.ts +27 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/kiro-api-key.d.ts +50 -0
- package/src/providers/kiro-api-key.ts +786 -0
- package/src/providers/kiro-codewhisperer.d.ts +11 -0
- package/src/providers/kiro-codewhisperer.ts +600 -0
- package/src/providers/mock.ts +526 -0
- package/src/providers/ollama.d.ts +41 -0
- package/src/providers/ollama.ts +645 -0
- package/src/providers/openai-anthropic-shim.d.ts +31 -0
- package/src/providers/openai-anthropic-shim.ts +156 -0
- package/src/providers/openai-bounded-rate-limits.d.ts +3 -0
- package/src/providers/openai-bounded-rate-limits.ts +57 -0
- package/src/providers/openai-chat-server-schema.ts +254 -0
- package/src/providers/openai-chat-server.ts +724 -0
- package/src/providers/openai-codex/constants.d.ts +26 -0
- package/src/providers/openai-codex/constants.ts +43 -0
- package/src/providers/openai-codex/request-transformer.d.ts +50 -0
- package/src/providers/openai-codex/request-transformer.ts +219 -0
- package/src/providers/openai-codex/response-handler.d.ts +18 -0
- package/src/providers/openai-codex/response-handler.ts +111 -0
- package/src/providers/openai-codex-responses.d.ts +71 -0
- package/src/providers/openai-codex-responses.ts +3288 -0
- package/src/providers/openai-completions-compat.d.ts +6 -0
- package/src/providers/openai-completions-compat.ts +6 -0
- package/src/providers/openai-completions.d.ts +35 -0
- package/src/providers/openai-completions.ts +2294 -0
- package/src/providers/openai-opencodex-responses.ts +174 -0
- package/src/providers/openai-request-transform.d.ts +4 -0
- package/src/providers/openai-request-transform.ts +136 -0
- package/src/providers/openai-responses-server-schema.ts +290 -0
- package/src/providers/openai-responses-server.ts +1268 -0
- package/src/providers/openai-responses-shared.d.ts +106 -0
- package/src/providers/openai-responses-shared.ts +1253 -0
- package/src/providers/openai-responses.d.ts +37 -0
- package/src/providers/openai-responses.ts +989 -0
- package/src/providers/pi-native-client.d.ts +29 -0
- package/src/providers/pi-native-client.ts +243 -0
- package/src/providers/pi-native-server.ts +488 -0
- package/src/providers/register-builtins.d.ts +59 -0
- package/src/providers/register-builtins.ts +544 -0
- package/src/providers/synthetic.d.ts +26 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.d.ts +33 -0
- package/src/providers/transform-messages.ts +408 -0
- package/src/providers/vision-guard.d.ts +8 -0
- package/src/providers/vision-guard.ts +31 -0
- package/src/rate-limit-utils.d.ts +19 -0
- package/src/rate-limit-utils.ts +102 -0
- package/src/stream.d.ts +45 -0
- package/src/stream.ts +1306 -0
- package/src/types.d.ts +1073 -0
- package/src/types.ts +1305 -0
- package/src/usage/claude.ts +449 -0
- package/src/usage/gemini.ts +250 -0
- package/src/usage/github-copilot.ts +421 -0
- package/src/usage/google-antigravity.ts +201 -0
- package/src/usage/grok-cli.ts +259 -0
- package/src/usage/kimi.ts +285 -0
- package/src/usage/minimax-code.ts +31 -0
- package/src/usage/openai-codex.ts +503 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/zai.ts +247 -0
- package/src/usage.ts +190 -0
- package/src/utils/abort.d.ts +19 -0
- package/src/utils/abort.ts +51 -0
- package/src/utils/anthropic-auth.ts +95 -0
- package/src/utils/block-symbols.d.ts +6 -0
- package/src/utils/block-symbols.ts +11 -0
- package/src/utils/discovery/antigravity.ts +275 -0
- package/src/utils/discovery/codex.ts +362 -0
- package/src/utils/discovery/cursor.ts +388 -0
- package/src/utils/discovery/gemini.ts +248 -0
- package/src/utils/discovery/index.ts +4 -0
- package/src/utils/discovery/openai-compatible.ts +379 -0
- package/src/utils/event-stream.d.ts +41 -0
- package/src/utils/event-stream.ts +269 -0
- package/src/utils/fallback-transport.d.ts +110 -0
- package/src/utils/fallback-transport.ts +411 -0
- package/src/utils/fireworks-model-id.d.ts +10 -0
- package/src/utils/fireworks-model-id.ts +30 -0
- package/src/utils/foundry.d.ts +11 -0
- package/src/utils/foundry.ts +18 -0
- package/src/utils/h2-fetch.ts +60 -0
- package/src/utils/http-inspector.d.ts +59 -0
- package/src/utils/http-inspector.ts +380 -0
- package/src/utils/idle-iterator.d.ts +122 -0
- package/src/utils/idle-iterator.ts +410 -0
- package/src/utils/json-parse.d.ts +98 -0
- package/src/utils/json-parse.ts +607 -0
- package/src/utils/oauth/alibaba-token-plan.ts +60 -0
- package/src/utils/oauth/anthropic.ts +233 -0
- package/src/utils/oauth/api-key-login.ts +98 -0
- package/src/utils/oauth/api-key-validation.ts +344 -0
- package/src/utils/oauth/bizrouter.ts +15 -0
- package/src/utils/oauth/callback-server.d.ts +80 -0
- package/src/utils/oauth/callback-server.ts +359 -0
- package/src/utils/oauth/cerebras.ts +16 -0
- package/src/utils/oauth/cloudflare-ai-gateway.ts +48 -0
- package/src/utils/oauth/commandcode.ts +17 -0
- package/src/utils/oauth/cursor.ts +157 -0
- package/src/utils/oauth/deepinfra.ts +15 -0
- package/src/utils/oauth/deepseek.ts +53 -0
- package/src/utils/oauth/firepass.ts +24 -0
- package/src/utils/oauth/fireworks.ts +15 -0
- package/src/utils/oauth/fugu.ts +15 -0
- package/src/utils/oauth/github-copilot.d.ts +38 -0
- package/src/utils/oauth/github-copilot.ts +362 -0
- package/src/utils/oauth/gitlab-duo.ts +123 -0
- package/src/utils/oauth/glm-zcode.d.ts +71 -0
- package/src/utils/oauth/glm-zcode.ts +433 -0
- package/src/utils/oauth/google-antigravity.ts +200 -0
- package/src/utils/oauth/google-gemini-cli.ts +256 -0
- package/src/utils/oauth/google-oauth-shared.ts +110 -0
- package/src/utils/oauth/huggingface.ts +62 -0
- package/src/utils/oauth/index.ts +558 -0
- package/src/utils/oauth/kagi.ts +47 -0
- package/src/utils/oauth/kilo.ts +87 -0
- package/src/utils/oauth/kimi.d.ts +17 -0
- package/src/utils/oauth/kimi.ts +275 -0
- package/src/utils/oauth/kiro.ts +448 -0
- package/src/utils/oauth/litellm.ts +47 -0
- package/src/utils/oauth/lm-studio.ts +38 -0
- package/src/utils/oauth/mara.ts +16 -0
- package/src/utils/oauth/minimax-code.ts +78 -0
- package/src/utils/oauth/moonshot.ts +16 -0
- package/src/utils/oauth/nanogpt.ts +15 -0
- package/src/utils/oauth/nvidia.ts +70 -0
- package/src/utils/oauth/oauth.html +199 -0
- package/src/utils/oauth/ollama-cloud.ts +28 -0
- package/src/utils/oauth/ollama.ts +47 -0
- package/src/utils/oauth/openai-codex.ts +299 -0
- package/src/utils/oauth/opencode.ts +49 -0
- package/src/utils/oauth/opengateway.ts +15 -0
- package/src/utils/oauth/openrouter.ts +16 -0
- package/src/utils/oauth/parallel.ts +46 -0
- package/src/utils/oauth/perplexity.ts +225 -0
- package/src/utils/oauth/pkce.ts +18 -0
- package/src/utils/oauth/qianfan.ts +58 -0
- package/src/utils/oauth/qwen-portal.ts +60 -0
- package/src/utils/oauth/sglang.ts +42 -0
- package/src/utils/oauth/synthetic.ts +15 -0
- package/src/utils/oauth/tavily.ts +46 -0
- package/src/utils/oauth/together.ts +16 -0
- package/src/utils/oauth/types.d.ts +56 -0
- package/src/utils/oauth/types.ts +122 -0
- package/src/utils/oauth/venice.ts +59 -0
- package/src/utils/oauth/vercel-ai-gateway.ts +47 -0
- package/src/utils/oauth/vllm.ts +42 -0
- package/src/utils/oauth/xai.ts +246 -0
- package/src/utils/oauth/xiaomi.ts +199 -0
- package/src/utils/oauth/zai.ts +60 -0
- package/src/utils/oauth/zenmux.ts +15 -0
- package/src/utils/overflow.ts +275 -0
- package/src/utils/parse-bind.ts +81 -0
- package/src/utils/provider-response.d.ts +6 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/provider-safety-stop.ts +8 -0
- package/src/utils/proxy.d.ts +7 -0
- package/src/utils/proxy.ts +652 -0
- package/src/utils/retry-after.d.ts +3 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry-budget.d.ts +1 -0
- package/src/utils/retry-budget.ts +4 -0
- package/src/utils/retry.d.ts +29 -0
- package/src/utils/retry.ts +67 -0
- package/src/utils/schema/CONSTRAINTS.md +164 -0
- package/src/utils/schema/adapt.d.ts +24 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.d.ts +30 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.d.ts +11 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.d.ts +10 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.d.ts +4 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.d.ts +49 -0
- package/src/utils/schema/fields.ts +190 -0
- package/src/utils/schema/index.d.ts +14 -0
- package/src/utils/schema/index.ts +14 -0
- package/src/utils/schema/json-schema-validator.d.ts +12 -0
- package/src/utils/schema/json-schema-validator.ts +577 -0
- package/src/utils/schema/meta-validator.d.ts +2 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.d.ts +93 -0
- package/src/utils/schema/normalize.ts +1588 -0
- package/src/utils/schema/root-combinator.d.ts +12 -0
- package/src/utils/schema/root-combinator.ts +143 -0
- package/src/utils/schema/spill.d.ts +8 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.d.ts +25 -0
- package/src/utils/schema/stamps.ts +97 -0
- package/src/utils/schema/types.d.ts +4 -0
- package/src/utils/schema/types.ts +11 -0
- package/src/utils/schema/wire.d.ts +54 -0
- package/src/utils/schema/wire.ts +213 -0
- package/src/utils/schema/zod-decontaminate.d.ts +31 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -0
- package/src/utils/sse-debug.d.ts +10 -0
- package/src/utils/sse-debug.ts +289 -0
- package/src/utils/tool-call-healing.d.ts +80 -0
- package/src/utils/tool-call-healing.ts +298 -0
- package/src/utils/tool-choice-capability.d.ts +57 -0
- package/src/utils/tool-choice-capability.ts +633 -0
- package/src/utils/tool-choice.d.ts +50 -0
- package/src/utils/tool-choice.ts +99 -0
- package/src/utils/validation.ts +1080 -0
- package/src/utils.d.ts +117 -0
- package/src/utils.ts +523 -0
package/src/cli.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import * as readline from "node:readline";
|
|
3
|
+
import { AuthStorage, SqliteAuthCredentialStore } from "./auth-storage";
|
|
4
|
+
import { getOAuthProviders } from "./utils/oauth";
|
|
5
|
+
import type { OAuthProvider } from "./utils/oauth/types";
|
|
6
|
+
|
|
7
|
+
const PROVIDERS = getOAuthProviders();
|
|
8
|
+
|
|
9
|
+
function prompt(rl: readline.Interface, question: string): Promise<string> {
|
|
10
|
+
const { promise, resolve, reject } = Promise.withResolvers<string>();
|
|
11
|
+
const input = process.stdin as NodeJS.ReadStream;
|
|
12
|
+
const supportsRawMode = input.isTTY && typeof input.setRawMode === "function";
|
|
13
|
+
const wasRaw = supportsRawMode ? input.isRaw : false;
|
|
14
|
+
let settled = false;
|
|
15
|
+
|
|
16
|
+
const cleanup = () => {
|
|
17
|
+
rl.off("SIGINT", onSigint);
|
|
18
|
+
if (supportsRawMode) {
|
|
19
|
+
input.off("keypress", onKeypress);
|
|
20
|
+
input.setRawMode?.(wasRaw);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const finish = (result: () => void) => {
|
|
25
|
+
if (settled) return;
|
|
26
|
+
settled = true;
|
|
27
|
+
cleanup();
|
|
28
|
+
result();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const cancel = () => {
|
|
32
|
+
finish(() => reject(new Error("Login cancelled")));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const onSigint = () => {
|
|
36
|
+
cancel();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const onKeypress = (_str: string, key: readline.Key) => {
|
|
40
|
+
if (key.name === "escape" || (key.ctrl && key.name === "c")) {
|
|
41
|
+
cancel();
|
|
42
|
+
rl.close();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (supportsRawMode) {
|
|
47
|
+
readline.emitKeypressEvents(input, rl);
|
|
48
|
+
input.setRawMode(true);
|
|
49
|
+
input.on("keypress", onKeypress);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
rl.once("SIGINT", onSigint);
|
|
53
|
+
rl.question(question, answer => {
|
|
54
|
+
finish(() => resolve(answer));
|
|
55
|
+
});
|
|
56
|
+
return promise;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function login(provider: OAuthProvider): Promise<void> {
|
|
60
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
61
|
+
const promptFn = (msg: string) => prompt(rl, `${msg} `);
|
|
62
|
+
const store = await SqliteAuthCredentialStore.open();
|
|
63
|
+
const storage = new AuthStorage(store);
|
|
64
|
+
await storage.reload();
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
await storage.login(provider, {
|
|
68
|
+
onAuth(info) {
|
|
69
|
+
const { url, instructions } = info;
|
|
70
|
+
console.log(`\nOpen this URL in your browser:\n${url}`);
|
|
71
|
+
if (instructions) console.log(instructions);
|
|
72
|
+
console.log();
|
|
73
|
+
},
|
|
74
|
+
onProgress(message) {
|
|
75
|
+
console.log(message);
|
|
76
|
+
},
|
|
77
|
+
onPrompt(p) {
|
|
78
|
+
return promptFn(`${p.message}${p.placeholder ? ` (${p.placeholder})` : ""}:`);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
console.log(`\nCredentials saved to ~/.vib/agent/agent.db`);
|
|
82
|
+
} finally {
|
|
83
|
+
store.close();
|
|
84
|
+
rl.close();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function main(): Promise<void> {
|
|
89
|
+
const args = process.argv.slice(2);
|
|
90
|
+
const command = args[0];
|
|
91
|
+
|
|
92
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
93
|
+
console.log(`Usage: bunx @vib-rato/ai <command> [provider]
|
|
94
|
+
|
|
95
|
+
Commands:
|
|
96
|
+
login [provider] Login to a provider
|
|
97
|
+
logout [provider] Logout from a provider
|
|
98
|
+
status Show logged-in providers
|
|
99
|
+
list List available providers
|
|
100
|
+
|
|
101
|
+
Providers:
|
|
102
|
+
anthropic Anthropic
|
|
103
|
+
github-copilot GitHub Copilot
|
|
104
|
+
google-gemini-cli Google Gemini CLI
|
|
105
|
+
google-antigravity Antigravity (Gemini 3, Anthropic, GPT-OSS)
|
|
106
|
+
openai-codex OpenAI code provider (ChatGPT Plus/Pro)
|
|
107
|
+
commandcode-goat Command Code GOAT (API key)
|
|
108
|
+
kimi-code Kimi Code
|
|
109
|
+
kilo Kilo Gateway
|
|
110
|
+
kagi Kagi
|
|
111
|
+
tavily Tavily
|
|
112
|
+
zai Z.AI (GLM Coding Plan)
|
|
113
|
+
glm-zcode GLM ZCode OAuth (unofficial, opt-in; at your own risk)
|
|
114
|
+
deepseek DeepSeek
|
|
115
|
+
deepinfra DeepInfra
|
|
116
|
+
xai xAI
|
|
117
|
+
nanogpt NanoGPT
|
|
118
|
+
minimax-code MiniMax Coding Plan (International)
|
|
119
|
+
minimax-code-cn MiniMax Coding Plan (China)
|
|
120
|
+
cursor Cursor (Anthropic, GPT, etc.)
|
|
121
|
+
zenmux ZenMux
|
|
122
|
+
opengateway OpenGateway by Sionic AI
|
|
123
|
+
bizrouter BizRouter
|
|
124
|
+
mara Mara Cloud
|
|
125
|
+
ollama-cloud Ollama Cloud
|
|
126
|
+
|
|
127
|
+
Examples:
|
|
128
|
+
bunx @vib-rato/ai login # interactive provider selection
|
|
129
|
+
bunx @vib-rato/ai login anthropic # login to specific provider
|
|
130
|
+
bunx @vib-rato/ai logout anthropic # logout from specific provider
|
|
131
|
+
bunx @vib-rato/ai status # show logged-in providers
|
|
132
|
+
bunx @vib-rato/ai list # list providers
|
|
133
|
+
`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (command === "status") {
|
|
138
|
+
const storage = await SqliteAuthCredentialStore.open();
|
|
139
|
+
try {
|
|
140
|
+
const providers = storage.listProviders();
|
|
141
|
+
if (providers.length === 0) {
|
|
142
|
+
console.log("No credentials stored.");
|
|
143
|
+
console.log(`Use 'bunx @vib-rato/ai login' to authenticate.`);
|
|
144
|
+
} else {
|
|
145
|
+
console.log("Logged-in providers:\n");
|
|
146
|
+
for (const provider of providers) {
|
|
147
|
+
const oauth = storage.getOAuth(provider);
|
|
148
|
+
if (oauth) {
|
|
149
|
+
const expires = new Date(oauth.expires);
|
|
150
|
+
const expired = Date.now() >= oauth.expires;
|
|
151
|
+
const status = expired ? "(expired)" : `(expires ${expires.toLocaleString()})`;
|
|
152
|
+
console.log(` ${provider.padEnd(20)} ${status}`);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const apiKey = storage.getApiKey(provider);
|
|
156
|
+
if (apiKey) {
|
|
157
|
+
console.log(` ${provider.padEnd(20)} (api key)`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} finally {
|
|
162
|
+
storage.close();
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (command === "list") {
|
|
168
|
+
console.log("Available providers:\n");
|
|
169
|
+
for (const p of PROVIDERS) {
|
|
170
|
+
console.log(` ${p.id.padEnd(20)} ${p.name}`);
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (command === "logout") {
|
|
176
|
+
let provider = args[1] as OAuthProvider | undefined;
|
|
177
|
+
const storage = await SqliteAuthCredentialStore.open();
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
if (!provider) {
|
|
181
|
+
const providers = storage.listProviders();
|
|
182
|
+
if (providers.length === 0) {
|
|
183
|
+
console.log("No credentials stored.");
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
188
|
+
console.log("Select a provider to logout:\n");
|
|
189
|
+
for (let i = 0; i < providers.length; i++) {
|
|
190
|
+
console.log(` ${i + 1}. ${providers[i]}`);
|
|
191
|
+
}
|
|
192
|
+
console.log();
|
|
193
|
+
|
|
194
|
+
const choice = await prompt(rl, `Enter number (1-${providers.length}): `);
|
|
195
|
+
rl.close();
|
|
196
|
+
|
|
197
|
+
const index = parseInt(choice, 10) - 1;
|
|
198
|
+
if (index < 0 || index >= providers.length) {
|
|
199
|
+
console.error("Invalid selection");
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
provider = providers[index] as OAuthProvider;
|
|
203
|
+
}
|
|
204
|
+
if (!provider) {
|
|
205
|
+
console.error("No provider selected");
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const oauth = storage.getOAuth(provider);
|
|
210
|
+
const apiKey = storage.getApiKey(provider);
|
|
211
|
+
if (!oauth && !apiKey) {
|
|
212
|
+
console.error(`Not logged in to ${provider}`);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
storage.deleteProvider(provider);
|
|
217
|
+
console.log(`Logged out from ${provider}`);
|
|
218
|
+
} finally {
|
|
219
|
+
storage.close();
|
|
220
|
+
}
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (command === "login") {
|
|
225
|
+
let provider = args[1] as OAuthProvider | undefined;
|
|
226
|
+
|
|
227
|
+
if (!provider) {
|
|
228
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
229
|
+
console.log("Select a provider:\n");
|
|
230
|
+
for (let i = 0; i < PROVIDERS.length; i++) {
|
|
231
|
+
console.log(` ${i + 1}. ${PROVIDERS[i].name}`);
|
|
232
|
+
}
|
|
233
|
+
console.log();
|
|
234
|
+
|
|
235
|
+
const choice = await prompt(rl, `Enter number (1-${PROVIDERS.length}): `);
|
|
236
|
+
rl.close();
|
|
237
|
+
|
|
238
|
+
const index = parseInt(choice, 10) - 1;
|
|
239
|
+
if (index < 0 || index >= PROVIDERS.length) {
|
|
240
|
+
console.error("Invalid selection");
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
provider = PROVIDERS[index].id as OAuthProvider;
|
|
244
|
+
}
|
|
245
|
+
if (!provider) {
|
|
246
|
+
console.error("No provider selected");
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!PROVIDERS.some(p => p.id === provider)) {
|
|
251
|
+
console.error(`Unknown provider: ${provider}`);
|
|
252
|
+
console.error(`Use 'bunx @vib-rato/ai list' to see available providers`);
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
console.log(`Logging in to ${provider}…`);
|
|
257
|
+
await login(provider);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
console.error(`Unknown command: ${command}`);
|
|
262
|
+
console.error(`Use 'bunx @vib-rato/ai --help' for usage`);
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
main().catch(err => {
|
|
267
|
+
console.error("Error:", err.message);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Maps a canonical tool name to the name Codex accepts on the wire. */
|
|
2
|
+
export declare function codexToolWireName(name: string): string;
|
|
3
|
+
/** Maps a Codex wire tool name back to the canonical harness tool name. */
|
|
4
|
+
export declare function codexToolCanonicalName(wireName: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core-safe Codex tool-name mapping.
|
|
3
|
+
*
|
|
4
|
+
* The mapping is shared by prompt metadata and the Codex transport, but it has
|
|
5
|
+
* no provider SDK or network dependencies. Keeping it here lets startup code
|
|
6
|
+
* use the canonical wire names without importing the Codex implementation.
|
|
7
|
+
*/
|
|
8
|
+
const CODEX_RESERVED_TOOL_WIRE_NAMES: ReadonlyMap<string, string> = new Map([
|
|
9
|
+
["browser", "browser_tool"],
|
|
10
|
+
["computer", "computer_tool"],
|
|
11
|
+
]);
|
|
12
|
+
const CODEX_CANONICAL_TOOL_NAMES: ReadonlyMap<string, string> = new Map(
|
|
13
|
+
Array.from(CODEX_RESERVED_TOOL_WIRE_NAMES, ([canonical, wire]) => [wire, canonical]),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/** Maps a canonical tool name to the name Codex accepts on the wire. */
|
|
17
|
+
export function codexToolWireName(name: string): string {
|
|
18
|
+
return CODEX_RESERVED_TOOL_WIRE_NAMES.get(name) ?? name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Maps a Codex wire tool name back to the canonical harness tool name. */
|
|
22
|
+
export function codexToolCanonicalName(wireName: string): string {
|
|
23
|
+
return CODEX_CANONICAL_TOOL_NAMES.get(wireName) ?? wireName;
|
|
24
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Api, Model } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Codex GPT-5.6 OAuth context-window policy.
|
|
4
|
+
*
|
|
5
|
+
* Authoritative source and ownership path
|
|
6
|
+
* ---------------------------------------
|
|
7
|
+
* The authenticated Codex backend discovery endpoint (`GET {base}/codex/models`
|
|
8
|
+
* with an OAuth bearer token) is the authoritative runtime source of Codex OAuth
|
|
9
|
+
* model context-window metadata (`models[].context_window`). OpenAI owns that
|
|
10
|
+
* value; Vibrato consumes it read-only via `fetchCodexModels` and must not silently
|
|
11
|
+
* invent a larger limit without upstream evidence.
|
|
12
|
+
*
|
|
13
|
+
* This bundled policy is a client-side conservative guard, not a primary source.
|
|
14
|
+
* It exists because OpenAI temporarily reverted the GPT-5.6 Sol product context
|
|
15
|
+
* limit from 372K to 272K on 2026-07-13 (staff announcement quoted in
|
|
16
|
+
* vib-rato issues #2240 / #2260), while planning to restore 372K later.
|
|
17
|
+
* `ceiling` must only be raised with an upstream evidence citation; an
|
|
18
|
+
* unverified report that "372K is live again" is not sufficient.
|
|
19
|
+
*
|
|
20
|
+
* Precedence (highest -> lowest)
|
|
21
|
+
* ------------------------------
|
|
22
|
+
* 1. Explicit user per-model override (`contextWindow` in `modelOverrides`).
|
|
23
|
+
* The model registry merges it into `model.contextWindow` before this cap and
|
|
24
|
+
* passes it here; it is honored when a positive finite number, with
|
|
25
|
+
* diagnostics emitted at the registry. Never silently discarded.
|
|
26
|
+
* 2. Live OAuth discovery metadata (`context_window`), forced to the enforced
|
|
27
|
+
* product window for the GPT-5.6 tier.
|
|
28
|
+
* 3. Bundled conservative generic window (`CODEX_GENERIC_CONTEXT_WINDOW`),
|
|
29
|
+
* used when discovery metadata is absent or invalid.
|
|
30
|
+
*/
|
|
31
|
+
export interface CodexGpt56ContextCapPolicy {
|
|
32
|
+
/**
|
|
33
|
+
* Usable prompt budget forced for the GPT-5.6 tier on the Codex product
|
|
34
|
+
* transport. The live OpenAI code backend metadata still reports the old
|
|
35
|
+
* 272K budget (or the total-window figure), so this is an explicit product
|
|
36
|
+
* override: the tier is forced to the enforced window regardless of what
|
|
37
|
+
* discovery reports.
|
|
38
|
+
*/
|
|
39
|
+
enforced: number;
|
|
40
|
+
}
|
|
41
|
+
export declare const CODEX_GPT_5_6_CONTEXT_CAP: CodexGpt56ContextCapPolicy;
|
|
42
|
+
/**
|
|
43
|
+
* Generic usable prompt budget for OpenAI code backend models outside the
|
|
44
|
+
* GPT-5.6 tier (e.g. gpt-5.5, gpt-5.4-codex, gpt-5.6-codex). Kept separate from
|
|
45
|
+
* {@link CODEX_GPT_5_6_CONTEXT_CAP} so the forced 5.6-tier window never leaks
|
|
46
|
+
* into unrelated Codex discovery rows.
|
|
47
|
+
*/
|
|
48
|
+
export declare const CODEX_GENERIC_CONTEXT_WINDOW = 272000;
|
|
49
|
+
export declare function isCodexProductTransport(model: Pick<Model<Api>, "api" | "provider">): boolean;
|
|
50
|
+
export declare function isCodexGpt56Tier(model: Pick<Model<Api>, "id">): boolean;
|
|
51
|
+
export declare function codexContextOverrideKey(provider: string, modelId: string): string;
|
|
52
|
+
export declare function resolveCodexGpt56DiscoveryContext(model: Pick<Model<Api>, "api" | "id" | "provider">, rawContextWindow: unknown, policy?: CodexGpt56ContextCapPolicy): number;
|
|
53
|
+
/**
|
|
54
|
+
* Applies the final Codex GPT-5.6 context ceiling, honoring explicit user
|
|
55
|
+
* overrides.
|
|
56
|
+
*
|
|
57
|
+
* `userContextWindowOverrides` maps provider-qualified composite keys
|
|
58
|
+
* (`provider:modelId`, both lowercased, built by
|
|
59
|
+
* {@link codexContextOverrideKey}) to the user's explicit `contextWindow` value
|
|
60
|
+
* (already merged into `model.contextWindow` by the model registry). A tier
|
|
61
|
+
* model present with a positive finite value keeps its value even above
|
|
62
|
+
* `enforced` — the user's explicit, diagnosed choice. Every other tier
|
|
63
|
+
* model is forced to `enforced`, so a stale larger live/cached observation
|
|
64
|
+
* (e.g. a pre-rollback 373K cache) cannot resurface without an override.
|
|
65
|
+
* Because the key is provider-qualified, an override only exempts the exact
|
|
66
|
+
* provider+model pair it was configured for.
|
|
67
|
+
*/
|
|
68
|
+
export declare function applyFinalCodexGpt56ContextCap<TApi extends Api>(models: readonly Model<TApi>[], policy?: CodexGpt56ContextCapPolicy, userContextWindowOverrides?: ReadonlyMap<string, number>): Model<TApi>[];
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Api, Model } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Codex GPT-5.6 OAuth context-window policy.
|
|
5
|
+
*
|
|
6
|
+
* Authoritative source and ownership path
|
|
7
|
+
* ---------------------------------------
|
|
8
|
+
* The authenticated Codex backend discovery endpoint (`GET {base}/codex/models`
|
|
9
|
+
* with an OAuth bearer token) is the authoritative runtime source of Codex OAuth
|
|
10
|
+
* model context-window metadata (`models[].context_window`). OpenAI owns that
|
|
11
|
+
* value; Vibrato consumes it read-only via `fetchCodexModels` and must not silently
|
|
12
|
+
* invent a larger limit without upstream evidence.
|
|
13
|
+
*
|
|
14
|
+
* This bundled policy is a client-side conservative guard, not a primary source.
|
|
15
|
+
* It exists because OpenAI temporarily reverted the GPT-5.6 Sol product context
|
|
16
|
+
* limit from 372K to 272K on 2026-07-13 (staff announcement quoted in
|
|
17
|
+
* vib-rato issues #2240 / #2260), while planning to restore 372K later.
|
|
18
|
+
* `ceiling` must only be raised with an upstream evidence citation; an
|
|
19
|
+
* unverified report that "372K is live again" is not sufficient.
|
|
20
|
+
*
|
|
21
|
+
* Precedence (highest -> lowest)
|
|
22
|
+
* ------------------------------
|
|
23
|
+
* 1. Explicit user per-model override (`contextWindow` in `modelOverrides`).
|
|
24
|
+
* The model registry merges it into `model.contextWindow` before this cap and
|
|
25
|
+
* passes it here; it is honored when a positive finite number, with
|
|
26
|
+
* diagnostics emitted at the registry. Never silently discarded.
|
|
27
|
+
* 2. Live OAuth discovery metadata (`context_window`), forced to the enforced
|
|
28
|
+
* product window for the GPT-5.6 tier.
|
|
29
|
+
* 3. Bundled conservative generic window (`CODEX_GENERIC_CONTEXT_WINDOW`),
|
|
30
|
+
* used when discovery metadata is absent or invalid.
|
|
31
|
+
*/
|
|
32
|
+
export interface CodexGpt56ContextCapPolicy {
|
|
33
|
+
/**
|
|
34
|
+
* Usable prompt budget forced for the GPT-5.6 tier on the Codex product
|
|
35
|
+
* transport. The live OpenAI code backend metadata still reports the old
|
|
36
|
+
* 272K budget (or the total-window figure), so this is an explicit product
|
|
37
|
+
* override: the tier is forced to the enforced window regardless of what
|
|
38
|
+
* discovery reports.
|
|
39
|
+
*/
|
|
40
|
+
enforced: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const CODEX_GPT_5_6_CONTEXT_CAP: CodexGpt56ContextCapPolicy = {
|
|
44
|
+
enforced: 372_000,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generic usable prompt budget for OpenAI code backend models outside the
|
|
49
|
+
* GPT-5.6 tier (e.g. gpt-5.5, gpt-5.4-codex, gpt-5.6-codex). Kept separate from
|
|
50
|
+
* {@link CODEX_GPT_5_6_CONTEXT_CAP} so the forced 5.6-tier window never leaks
|
|
51
|
+
* into unrelated Codex discovery rows.
|
|
52
|
+
*/
|
|
53
|
+
export const CODEX_GENERIC_CONTEXT_WINDOW = 272_000;
|
|
54
|
+
|
|
55
|
+
const CODEX_GPT_5_6_MODEL_IDS: ReadonlySet<string> = new Set([
|
|
56
|
+
"gpt-5.6",
|
|
57
|
+
"gpt-5.6-sol",
|
|
58
|
+
"gpt-5.6-terra",
|
|
59
|
+
"gpt-5.6-luna",
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
export function isCodexProductTransport(model: Pick<Model<Api>, "api" | "provider">): boolean {
|
|
63
|
+
return model.provider === "openai-codex" || model.api === "openai-codex-responses";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function isCodexGpt56Tier(model: Pick<Model<Api>, "id">): boolean {
|
|
67
|
+
return CODEX_GPT_5_6_MODEL_IDS.has(model.id.toLowerCase());
|
|
68
|
+
}
|
|
69
|
+
export function codexContextOverrideKey(provider: string, modelId: string): string {
|
|
70
|
+
return `${provider.toLowerCase()}:${modelId.toLowerCase()}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function resolveCodexGpt56DiscoveryContext(
|
|
74
|
+
model: Pick<Model<Api>, "api" | "id" | "provider">,
|
|
75
|
+
rawContextWindow: unknown,
|
|
76
|
+
policy: CodexGpt56ContextCapPolicy = CODEX_GPT_5_6_CONTEXT_CAP,
|
|
77
|
+
): number {
|
|
78
|
+
if (!isCodexGpt56Tier(model) || !isCodexProductTransport(model)) {
|
|
79
|
+
// Non-5.6 rows keep the generic Codex prompt budget as their fallback;
|
|
80
|
+
// live observations still pass through (the 272K pin for gpt-5.5 and
|
|
81
|
+
// gpt-5.6-codex is applied later by the generated-catalog policy).
|
|
82
|
+
return isPositiveFiniteNumber(rawContextWindow) ? rawContextWindow : CODEX_GENERIC_CONTEXT_WINDOW;
|
|
83
|
+
}
|
|
84
|
+
// Force the enforced window: the backend's current metadata under-reports
|
|
85
|
+
// the GPT-5.6 tier budget, and stale smaller observations must not win.
|
|
86
|
+
return policy.enforced;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Applies the final Codex GPT-5.6 context ceiling, honoring explicit user
|
|
91
|
+
* overrides.
|
|
92
|
+
*
|
|
93
|
+
* `userContextWindowOverrides` maps provider-qualified composite keys
|
|
94
|
+
* (`provider:modelId`, both lowercased, built by
|
|
95
|
+
* {@link codexContextOverrideKey}) to the user's explicit `contextWindow` value
|
|
96
|
+
* (already merged into `model.contextWindow` by the model registry). A tier
|
|
97
|
+
* model present with a positive finite value keeps its value even above
|
|
98
|
+
* `enforced` — the user's explicit, diagnosed choice. Every other tier
|
|
99
|
+
* model is forced to `enforced`, so a stale larger live/cached observation
|
|
100
|
+
* (e.g. a pre-rollback 373K cache) cannot resurface without an override.
|
|
101
|
+
* Because the key is provider-qualified, an override only exempts the exact
|
|
102
|
+
* provider+model pair it was configured for.
|
|
103
|
+
*/
|
|
104
|
+
export function applyFinalCodexGpt56ContextCap<TApi extends Api>(
|
|
105
|
+
models: readonly Model<TApi>[],
|
|
106
|
+
policy: CodexGpt56ContextCapPolicy = CODEX_GPT_5_6_CONTEXT_CAP,
|
|
107
|
+
userContextWindowOverrides: ReadonlyMap<string, number> = new Map(),
|
|
108
|
+
): Model<TApi>[] {
|
|
109
|
+
return models.map(model => {
|
|
110
|
+
if (!isCodexGpt56Tier(model as Model<Api>) || !isCodexProductTransport(model as Model<Api>)) {
|
|
111
|
+
return model;
|
|
112
|
+
}
|
|
113
|
+
const userOverride = userContextWindowOverrides.get(codexContextOverrideKey(model.provider, model.id));
|
|
114
|
+
if (userOverride !== undefined && isPositiveFiniteNumber(userOverride)) {
|
|
115
|
+
return model;
|
|
116
|
+
}
|
|
117
|
+
return { ...model, contextWindow: policy.enforced };
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function isPositiveFiniteNumber(value: unknown): value is number {
|
|
122
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
123
|
+
}
|
package/src/core.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight public AI runtime surface.
|
|
3
|
+
*
|
|
4
|
+
* This entrypoint intentionally exports core types, schemas, model metadata,
|
|
5
|
+
* stream dispatch, and lazy provider descriptors only. Concrete provider
|
|
6
|
+
* implementations stay behind `register-builtins` loaders and are not
|
|
7
|
+
* re-exported here.
|
|
8
|
+
*/
|
|
9
|
+
export { type ZodType, z } from "zod/v4";
|
|
10
|
+
export * from "./api-registry";
|
|
11
|
+
export * from "./auth-broker";
|
|
12
|
+
export * from "./auth-gateway/types";
|
|
13
|
+
export * from "./auth-storage";
|
|
14
|
+
export * from "./codex-tools";
|
|
15
|
+
export * from "./context-cap-policy";
|
|
16
|
+
export * from "./model-cache";
|
|
17
|
+
export * from "./model-manager";
|
|
18
|
+
export * from "./model-thinking";
|
|
19
|
+
export * from "./models";
|
|
20
|
+
export * from "./provider-models";
|
|
21
|
+
export {
|
|
22
|
+
getProviderRuntimeDescriptor,
|
|
23
|
+
PROVIDER_RUNTIME_DESCRIPTORS,
|
|
24
|
+
type ProviderRuntimeDescriptor,
|
|
25
|
+
} from "./providers/register-builtins";
|
|
26
|
+
export { hasAdjacentPrivateThinkingBlocks } from "./providers/transform-messages";
|
|
27
|
+
export * from "./rate-limit-utils";
|
|
28
|
+
export * from "./stream";
|
|
29
|
+
export * from "./types";
|
|
30
|
+
export * from "./usage";
|
|
31
|
+
export * from "./utils/event-stream";
|
|
32
|
+
export * from "./utils/fallback-transport";
|
|
33
|
+
export * from "./utils/oauth";
|
|
34
|
+
export type {
|
|
35
|
+
OAuthCredentials,
|
|
36
|
+
OAuthProvider,
|
|
37
|
+
OAuthProviderId,
|
|
38
|
+
OAuthProviderInfo,
|
|
39
|
+
} from "./utils/oauth/types";
|
|
40
|
+
export * from "./utils/overflow";
|
|
41
|
+
export * from "./utils/retry";
|
|
42
|
+
export * from "./utils/schema";
|
|
43
|
+
export * from "./utils/tool-choice-capability";
|
|
44
|
+
export * from "./utils/validation";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export { type ZodType, z } from "zod/v4";
|
|
2
|
+
export * from "./api-registry";
|
|
3
|
+
export * from "./auth-broker";
|
|
4
|
+
export { type AuthGatewayBootOptions, type ModelResolver, startAuthGateway } from "./auth-gateway/server";
|
|
5
|
+
export * from "./auth-gateway/types";
|
|
6
|
+
export * from "./auth-storage";
|
|
7
|
+
export * from "./context-cap-policy";
|
|
8
|
+
export * from "./model-cache";
|
|
9
|
+
export * from "./model-manager";
|
|
10
|
+
export * from "./model-thinking";
|
|
11
|
+
export * from "./models";
|
|
12
|
+
export * from "./provider-details";
|
|
13
|
+
export * from "./provider-models";
|
|
14
|
+
export * from "./providers/anthropic";
|
|
15
|
+
export * from "./providers/azure-openai-responses";
|
|
16
|
+
export type * from "./providers/cursor";
|
|
17
|
+
export * from "./providers/gitlab-duo";
|
|
18
|
+
export type * from "./providers/google";
|
|
19
|
+
export type * from "./providers/google-gemini-cli";
|
|
20
|
+
export * from "./providers/google-gemini-headers";
|
|
21
|
+
export type * from "./providers/google-vertex";
|
|
22
|
+
export * from "./providers/kimi";
|
|
23
|
+
export * from "./providers/mock";
|
|
24
|
+
export * from "./providers/ollama";
|
|
25
|
+
export * from "./providers/openai-codex-responses";
|
|
26
|
+
export * from "./providers/openai-completions";
|
|
27
|
+
export * from "./providers/openai-opencodex-responses";
|
|
28
|
+
export * from "./providers/openai-responses";
|
|
29
|
+
export * from "./providers/synthetic";
|
|
30
|
+
export * from "./rate-limit-utils";
|
|
31
|
+
export * from "./stream";
|
|
32
|
+
export * from "./types";
|
|
33
|
+
export * from "./usage";
|
|
34
|
+
export * from "./usage/claude";
|
|
35
|
+
export * from "./usage/gemini";
|
|
36
|
+
export * from "./usage/github-copilot";
|
|
37
|
+
export * from "./usage/google-antigravity";
|
|
38
|
+
export * from "./usage/grok-cli";
|
|
39
|
+
export * from "./usage/kimi";
|
|
40
|
+
export * from "./usage/minimax-code";
|
|
41
|
+
export * from "./usage/openai-codex";
|
|
42
|
+
export * from "./usage/zai";
|
|
43
|
+
export * from "./utils/anthropic-auth";
|
|
44
|
+
export * from "./utils/discovery";
|
|
45
|
+
export * from "./utils/event-stream";
|
|
46
|
+
export * from "./utils/fallback-transport";
|
|
47
|
+
export * from "./utils/h2-fetch";
|
|
48
|
+
export * from "./utils/oauth";
|
|
49
|
+
export type {
|
|
50
|
+
OAuthCredentials,
|
|
51
|
+
OAuthLoginOptions,
|
|
52
|
+
OAuthProvider,
|
|
53
|
+
OAuthProviderId,
|
|
54
|
+
OAuthProviderInfo,
|
|
55
|
+
} from "./utils/oauth/types";
|
|
56
|
+
export * from "./utils/overflow";
|
|
57
|
+
export * from "./utils/provider-safety-stop";
|
|
58
|
+
export * from "./utils/retry";
|
|
59
|
+
export * from "./utils/schema";
|
|
60
|
+
export * from "./utils/tool-choice-capability";
|
|
61
|
+
export * from "./utils/validation";
|