@earendil-works/pi-ai 1.3.0 → 1.5.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/README.md +113 -38
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +66 -81
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/dist/api/azure-openai-responses.js +8 -10
- package/dist/api/azure-openai-responses.js.map +1 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.js +137 -103
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/classifier-shared.d.ts.map +1 -1
- package/dist/api/classifier-shared.js +4 -3
- package/dist/api/classifier-shared.js.map +1 -1
- package/dist/api/cloudflare-workers-ai-system-one.d.ts.map +1 -1
- package/dist/api/cloudflare-workers-ai-system-one.js +8 -0
- package/dist/api/cloudflare-workers-ai-system-one.js.map +1 -1
- package/dist/api/constrained-sampling.d.ts +15 -1
- package/dist/api/constrained-sampling.d.ts.map +1 -1
- package/dist/api/constrained-sampling.js +51 -18
- package/dist/api/constrained-sampling.js.map +1 -1
- package/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/api/google-generative-ai.js +4 -10
- package/dist/api/google-generative-ai.js.map +1 -1
- package/dist/api/google-shared.d.ts +2 -1
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +58 -3
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/api/google-vertex.js +9 -15
- package/dist/api/google-vertex.js.map +1 -1
- package/dist/api/lazy.d.ts +7 -2
- package/dist/api/lazy.d.ts.map +1 -1
- package/dist/api/lazy.js +24 -5
- package/dist/api/lazy.js.map +1 -1
- package/dist/api/llama-cpp-classify.d.ts.map +1 -1
- package/dist/api/llama-cpp-classify.js +2 -1
- package/dist/api/llama-cpp-classify.js.map +1 -1
- package/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +19 -46
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +17 -16
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +56 -62
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses-shared.d.ts +16 -0
- package/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/dist/api/openai-responses-shared.js +119 -66
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +17 -15
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/openrouter-images.d.ts.map +1 -1
- package/dist/api/openrouter-images.js +5 -3
- package/dist/api/openrouter-images.js.map +1 -1
- package/dist/api/pi-messages.d.ts +2 -0
- package/dist/api/pi-messages.d.ts.map +1 -1
- package/dist/api/pi-messages.js +27 -12
- package/dist/api/pi-messages.js.map +1 -1
- package/dist/api/simple-options.d.ts.map +1 -1
- package/dist/api/simple-options.js +2 -1
- package/dist/api/simple-options.js.map +1 -1
- package/dist/api/system-one-shared.d.ts +29 -2
- package/dist/api/system-one-shared.d.ts.map +1 -1
- package/dist/api/system-one-shared.js +55 -3
- package/dist/api/system-one-shared.js.map +1 -1
- package/dist/api/typesafe-system-one.d.ts.map +1 -1
- package/dist/api/typesafe-system-one.js +10 -0
- package/dist/api/typesafe-system-one.js.map +1 -1
- package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
- package/dist/auth/oauth/github-copilot.js +4 -11
- package/dist/auth/oauth/github-copilot.js.map +1 -1
- package/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
- package/dist/auth/oauth/kimi-coding.js +4 -22
- package/dist/auth/oauth/kimi-coding.js.map +1 -1
- package/dist/auth/oauth/meta.d.ts.map +1 -1
- package/dist/auth/oauth/meta.js +1 -14
- package/dist/auth/oauth/meta.js.map +1 -1
- package/dist/auth/oauth/radius.d.ts.map +1 -1
- package/dist/auth/oauth/radius.js +9 -3
- package/dist/auth/oauth/radius.js.map +1 -1
- package/dist/auth/oauth/trusted-url.d.ts +7 -0
- package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
- package/dist/auth/oauth/trusted-url.js +12 -0
- package/dist/auth/oauth/trusted-url.js.map +1 -0
- package/dist/auth/types.d.ts +4 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/compat/extension-oauth-types.d.ts +4 -0
- package/dist/compat/extension-oauth-types.d.ts.map +1 -1
- package/dist/compat/extension-oauth-types.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +4 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.js +1 -1
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +20 -6
- package/dist/models.js.map +1 -1
- package/dist/providers/amazon-bedrock.models.js +1 -1
- package/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/dist/providers/ant-ling.models.js +1 -1
- package/dist/providers/ant-ling.models.js.map +1 -1
- package/dist/providers/anthropic.models.js +1 -1
- package/dist/providers/anthropic.models.js.map +1 -1
- package/dist/providers/azure.models.js +1 -1
- package/dist/providers/azure.models.js.map +1 -1
- package/dist/providers/baseten.models.js +1 -1
- package/dist/providers/baseten.models.js.map +1 -1
- package/dist/providers/cerebras.models.js +1 -1
- package/dist/providers/cerebras.models.js.map +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +444 -304
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +155 -109
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cerebras.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/groq.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/kimi-coding.json +1 -1
- package/dist/providers/data/minimax-cn.json +1 -1
- package/dist/providers/data/minimax.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/providers/data/moonshotai.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/providers/data/radius.json +1 -1
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/typesafe.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/deepseek.models.js +1 -1
- package/dist/providers/deepseek.models.js.map +1 -1
- package/dist/providers/faux.d.ts.map +1 -1
- package/dist/providers/faux.js +7 -2
- package/dist/providers/faux.js.map +1 -1
- package/dist/providers/fireworks.models.js +1 -1
- package/dist/providers/fireworks.models.js.map +1 -1
- package/dist/providers/github-copilot.models.js +1 -1
- package/dist/providers/github-copilot.models.js.map +1 -1
- package/dist/providers/google-vertex.models.js +1 -1
- package/dist/providers/google-vertex.models.js.map +1 -1
- package/dist/providers/google.models.js +1 -1
- package/dist/providers/google.models.js.map +1 -1
- package/dist/providers/groq.models.js +1 -1
- package/dist/providers/groq.models.js.map +1 -1
- package/dist/providers/huggingface.models.js +1 -1
- package/dist/providers/huggingface.models.js.map +1 -1
- package/dist/providers/kimi-coding.models.js +1 -1
- package/dist/providers/kimi-coding.models.js.map +1 -1
- package/dist/providers/meta.models.js +1 -1
- package/dist/providers/meta.models.js.map +1 -1
- package/dist/providers/minimax-cn.models.js +1 -1
- package/dist/providers/minimax-cn.models.js.map +1 -1
- package/dist/providers/minimax.models.js +1 -1
- package/dist/providers/minimax.models.js.map +1 -1
- package/dist/providers/mistral.models.js +1 -1
- package/dist/providers/mistral.models.js.map +1 -1
- package/dist/providers/model-schema.d.ts +65 -65
- package/dist/providers/model-schema.d.ts.map +1 -1
- package/dist/providers/model-schema.js +44 -31
- package/dist/providers/model-schema.js.map +1 -1
- package/dist/providers/moonshotai-cn.models.js +1 -1
- package/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/dist/providers/moonshotai.models.js +1 -1
- package/dist/providers/moonshotai.models.js.map +1 -1
- package/dist/providers/nvidia.models.js +1 -1
- package/dist/providers/nvidia.models.js.map +1 -1
- package/dist/providers/openai-codex.models.js +1 -1
- package/dist/providers/openai-codex.models.js.map +1 -1
- package/dist/providers/openai.models.js +1 -1
- package/dist/providers/openai.models.js.map +1 -1
- package/dist/providers/opencode-go.models.js +1 -1
- package/dist/providers/opencode-go.models.js.map +1 -1
- package/dist/providers/opencode.js +1 -1
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/opencode.models.js +1 -1
- package/dist/providers/opencode.models.js.map +1 -1
- package/dist/providers/openrouter.models.js +1 -1
- package/dist/providers/openrouter.models.js.map +1 -1
- package/dist/providers/qwen-token-plan-cn.models.js +1 -1
- package/dist/providers/qwen-token-plan-cn.models.js.map +1 -1
- package/dist/providers/qwen-token-plan-individual.models.js +1 -1
- package/dist/providers/qwen-token-plan-individual.models.js.map +1 -1
- package/dist/providers/qwen-token-plan.models.js +1 -1
- package/dist/providers/qwen-token-plan.models.js.map +1 -1
- package/dist/providers/radius-config.d.ts.map +1 -1
- package/dist/providers/radius-config.js +2 -1
- package/dist/providers/radius-config.js.map +1 -1
- package/dist/providers/radius.models.js +1 -1
- package/dist/providers/radius.models.js.map +1 -1
- package/dist/providers/schema-builders.d.ts +10 -0
- package/dist/providers/schema-builders.d.ts.map +1 -0
- package/dist/providers/schema-builders.js +18 -0
- package/dist/providers/schema-builders.js.map +1 -0
- package/dist/providers/together.models.js +1 -1
- package/dist/providers/together.models.js.map +1 -1
- package/dist/providers/typesafe.models.js +1 -1
- package/dist/providers/typesafe.models.js.map +1 -1
- package/dist/providers/vercel-ai-gateway.models.js +1 -1
- package/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/dist/providers/xai.models.js +1 -1
- package/dist/providers/xai.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
- package/dist/providers/xiaomi.models.js +1 -1
- package/dist/providers/xiaomi.models.js.map +1 -1
- package/dist/providers/zai-coding-cn.models.js +1 -1
- package/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/dist/providers/zai.models.js +1 -1
- package/dist/providers/zai.models.js.map +1 -1
- package/dist/telemetry.d.ts +288 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +192 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/types.d.ts +25 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/error-body.d.ts.map +1 -1
- package/dist/utils/error-body.js +2 -1
- package/dist/utils/error-body.js.map +1 -1
- package/dist/utils/identity.d.ts +65 -0
- package/dist/utils/identity.d.ts.map +1 -0
- package/dist/utils/identity.js +141 -0
- package/dist/utils/identity.js.map +1 -0
- package/dist/utils/openrouter-cost.d.ts +24 -0
- package/dist/utils/openrouter-cost.d.ts.map +1 -0
- package/dist/utils/openrouter-cost.js +34 -0
- package/dist/utils/openrouter-cost.js.map +1 -0
- package/dist/utils/overflow.d.ts +1 -0
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +8 -1
- package/dist/utils/overflow.js.map +1 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +19 -7
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/streaming-json.d.ts +84 -0
- package/dist/utils/streaming-json.d.ts.map +1 -0
- package/dist/utils/streaming-json.js +513 -0
- package/dist/utils/streaming-json.js.map +1 -0
- package/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +5 -5
- package/dist/utils/string-enum.d.ts.map +1 -0
- package/dist/utils/{typebox-helpers.js → string-enum.js} +5 -6
- package/dist/utils/string-enum.js.map +1 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/transcript.d.ts +23 -9
- package/dist/utils/transcript.d.ts.map +1 -1
- package/dist/utils/transcript.js +30 -19
- package/dist/utils/transcript.js.map +1 -1
- package/dist/utils/validation.d.ts +5 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +27 -277
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +3 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +11 -10
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -12
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/dist/utils/typebox-helpers.d.ts.map +0 -1
- package/dist/utils/typebox-helpers.js.map +0 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EACX,uBAAuB,EACvB,aAAa,EACb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BAAqB,GAAG,kCAAkC,GAAG,eAAe,GAAG,KAAK,CAAC;CAC3G;AAED,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC5B,UAAU,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CAC3C;AAED,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC;AAE3C,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TelemetryContext } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type {\n\tAnthropicMessagesCompat,\n\tBedrockCompat,\n\tMistralConversationsCompat,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n} from \"./providers/compat-schema.ts\";\nimport type {\n\tCacheRetention,\n\tModelCost,\n\tModelInputLimits,\n\tModelInputModality,\n\tModelPromptCache,\n\tModelThinkingLevel,\n\tThinkingLevel,\n\tThinkingLevelMap,\n} from \"./providers/model-schema.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type {\n\tAnthropicAllowedFallbackModel,\n\tAnthropicMessagesCompat,\n\tBedrockCompat,\n\tChatTemplateKwargValue,\n\tMistralConversationsCompat,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n\tOpenRouterRouting,\n\tSessionAffinityFormat,\n\tThinkingTokenBudgetField,\n\tVercelGatewayRouting,\n} from \"./providers/compat-schema.ts\";\nexport type {\n\tCacheRetention,\n\tModelCost,\n\tModelCostRates,\n\tModelCostTier,\n\tModelImageInputLimits,\n\tModelImageResizeOptions,\n\tModelInputLimits,\n\tModelInputModality,\n\tModelPromptCache,\n\tModelThinkingLevel,\n\tThinkingLevel,\n\tThinkingLevelMap,\n} from \"./providers/model-schema.ts\";\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImageApi = \"openrouter-images\";\n\nexport type ImageApi = KnownImageApi | (string & {});\n\nexport type KnownClassifierApi =\n\t| \"typesafe-system-one\"\n\t| \"cloudflare-workers-ai-system-one\"\n\t| \"llama-cpp-classify\"\n\t| \"openai-decisions\";\n\nexport type ClassifierApi = KnownClassifierApi | (string & {});\n\nexport type KnownProvider =\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure\"\n\t| \"openai-codex\"\n\t| \"radius\"\n\t| \"typesafe\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"meta\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\";\nexport type ProviderId = KnownProvider | string;\n\nexport type ToolChoice = \"auto\" | \"none\";\nexport type SamplingParams = Record<string, unknown>;\nexport type SamplingParamsByThinkingLevel = Partial<Record<ModelThinkingLevel, SamplingParams>>;\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\n// Base options all providers share\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/** Explicit parent context for telemetry produced by this logical request. */\n\ttelemetryContext?: TelemetryContext;\n\tapiKey?: string;\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (payload: unknown, model: TModel) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Optional callback invoked after an HTTP response is received and before\n\t * its body stream is consumed.\n\t */\n\tonResponse?: (response: ProviderResponse, model: Model<Api>) => void | Promise<void>;\n\t/**\n\t * Optional observer for each parsed provider stream event before Pi normalization.\n\t * Event data is adapter-owned and must be treated as read-only.\n\t * Adapter support is explicit; unsupported adapters do not invoke it.\n\t */\n\tonProviderStreamEvent?: (data: unknown, model: Model<Api>) => void | Promise<void>;\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: SamplingParams;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: TranscriptContext, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and\n * `createProvider({ images })` pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\n/** The uniform contract implemented by classifier API modules. */\nexport interface ProviderClassifier {\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\nexport interface ClassifierOptions extends ProviderRequestOptions<ClassifierModel<ClassifierApi>> {\n\t/**\n\t * Divides the answer logits by this value before they are normalized into probabilities.\n\t * Values above 1 soften the distribution; values below 1 sharpen it. Must be positive.\n\t * APIs that cannot apply it ignore it.\n\t */\n\ttemperature?: number;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImageModel<ImageApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\t/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */\n\ttoolChoice?: ToolChoice;\n\treasoning?: ThinkingLevel;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n}\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Receives a normalized transcript: the system prompt and tools live in the\n// leading system message, never on the context itself.\n// - Must return an AssistantMessageEventStream.\n// - Direct streamSimple() calls may throw synchronously when request auth is\n// missing. Once a stream is returned, request/model/runtime failures should\n// be encoded in that stream.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: TranscriptContext,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImageModel<ImageApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport type ClassifierFunction<TOptions extends ClassifierOptions = ClassifierOptions> = (\n\tmodel: ClassifierModel<ClassifierApi>,\n\tcontext: ClassifierContext,\n\toptions?: TOptions,\n) => Promise<ClassifierResult>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\tthinkingSignature?: string; // Provider-specific opaque or serialized reasoning replay data\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\"\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: JsonObject;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n\t/** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */\n\tnamespace?: string;\n\t/**\n\t * Set when the model's complete arguments text was not a valid JSON object. `arguments` is then `{}`.\n\t * Describes the problem and includes the text the model sent; tool argument validation fails with it.\n\t */\n\targumentsError?: string;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = null | boolean | number | string | readonly JsonValue[] | JsonObject;\nexport type JsonObject = { [key: string]: JsonValue };\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\ntype IsExactlyJsonValue<T> = [T] extends [JsonValue] ? ([JsonValue] extends [T] ? true : false) : false;\ntype IsJsonProperty<T> = IsAny<T> extends true\n\t? false\n\t: unknown extends T\n\t\t? false\n\t\t: [Exclude<T, undefined>] extends [never]\n\t\t\t? true\n\t\t\t: IsJsonCompatible<Exclude<T, undefined>>;\ntype InvalidJsonKeys<T extends object> = {\n\t[TKey in keyof T]-?: TKey extends string | number ? (IsJsonProperty<T[TKey]> extends true ? never : TKey) : TKey;\n}[keyof T];\ntype IsJsonCompatible<T> = IsAny<T> extends true\n\t? false\n\t: unknown extends T\n\t\t? false\n\t\t: IsExactlyJsonValue<T> extends true\n\t\t\t? true\n\t\t\t: T extends null | boolean | number | string\n\t\t\t\t? true\n\t\t\t\t: T extends undefined\n\t\t\t\t\t? false\n\t\t\t\t\t: T extends readonly (infer TItem)[]\n\t\t\t\t\t\t? IsJsonCompatible<TItem>\n\t\t\t\t\t\t: T extends (...args: never[]) => unknown\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: T extends object\n\t\t\t\t\t\t\t\t? [InvalidJsonKeys<T>] extends [never]\n\t\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: false;\n\n/** The JSON representation of a typed in-memory value. Optional object properties remain optional. */\nexport type JsonRepresentation<T> = IsAny<T> extends true\n\t? JsonValue\n\t: unknown extends T\n\t\t? JsonValue\n\t\t: [T] extends [JsonValue]\n\t\t\t? T\n\t\t\t: T extends readonly unknown[]\n\t\t\t\t? { [TKey in keyof T]: JsonRepresentation<Exclude<T[TKey], undefined>> }\n\t\t\t\t: T extends object\n\t\t\t\t\t? { [TKey in keyof T]: JsonRepresentation<Exclude<T[TKey], undefined>> }\n\t\t\t\t\t: never;\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\n/**\n * System instructions and tool declarations at one point in the transcript.\n *\n * The leading system message is the system prompt. Later system messages change it:\n * `content` adds instructions from that point on, `sections` replace or remove named\n * prompt sections, and `toolsAdded`/`toolsRemoved` change the tool set. Replaying\n * every system message in order yields the current prompt and tools. Providers that\n * accept system messages mid-conversation send each one in place; other providers\n * rebuild the leading system message from the replayed state.\n */\nexport interface SystemMessage {\n\trole: \"system\";\n\t/** Instruction text. On the leading message this is the base prompt; later, additional instructions. */\n\tcontent: string | TextContent[];\n\t/**\n\t * Named, ordered prompt sections rendered verbatim after `content`. The leading message\n\t * declares them; later messages replace sections by name, and `null` removes one. Keep\n\t * each section self-delimiting (a tag, a heading) so the model can relate an update to\n\t * the original. Avoid integer-like names; JSON objects reorder those.\n\t */\n\tsections?: Record<string, string | null>;\n\t/** Complete definitions of tools that become available at this point. */\n\ttoolsAdded?: Tool[];\n\t/** Tools that stop being available at this point. */\n\ttoolsRemoved?: ToolReference[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete model reported by the provider when different from the requested `model`\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\t/** Exact provider-native effort level used for this response. Absent for legacy or unmanaged responses. */\n\tproviderThinkingLevel?: string;\n\t/** Pi thinking level the agent loop requested for this response. Absent outside the agent loop and for legacy responses. */\n\tthinkingLevel?: ModelThinkingLevel;\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\trawStopReason?: string;\n\t/**\n\t * Provider indication of whether the model explicitly ended its turn.\n\t * Preserved for debugging and does not currently affect agent control flow.\n\t */\n\tendTurn?: boolean;\n\t/** Unix timestamp in milliseconds when the request started. */\n\ttimestamp: number;\n\t/**\n\t * Milliseconds from `timestamp` until the response ended, measured with a monotonic clock. Set by\n\t * `AssistantMessageEventStream` on the final message of a response it saw start; absent for legacy messages and\n\t * for deferred results fetched later.\n\t */\n\tdurationMs?: number;\n}\n\n/** A tool call that another tool made while it ran, for example from a codemode script. */\nexport interface NestedToolCallRecord {\n\tid: string;\n\tname: string;\n\t/** Omitted when over the size limits; `argumentsBytes` then gives their size. */\n\targuments?: JsonObject;\n\t/** UTF-8 size of the arguments as JSON, set when `arguments` is omitted. */\n\targumentsBytes?: number;\n\t/** `unfinished`: the call was still running when the calling tool finished. */\n\tstatus: \"ok\" | \"error\" | \"unfinished\";\n\tdurationMs?: number;\n\t/** Error text, truncated. */\n\terror?: string;\n}\n\n/** Bounded record of the nested calls a tool made. Results are not recorded. */\nexport interface NestedToolCalls {\n\tcalls: NestedToolCallRecord[];\n\t/** False when calls were dropped, arguments omitted, or calls had not finished. */\n\tcomplete: boolean;\n}\n\nexport type ToolResultMessage<TDetails = JsonValue> = IsJsonCompatible<TDetails> extends true\n\t? {\n\t\t\trole: \"toolResult\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\t\t\tdetails?: JsonRepresentation<TDetails>;\n\t\t\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\t\t\tusage?: Usage;\n\t\t\t/** Calls this tool made to other tools. Kept for the session record; not sent to the model. */\n\t\t\tnestedCalls?: NestedToolCalls;\n\t\t\tisError: boolean;\n\t\t\t/** Unix timestamp in milliseconds when the result was created. */\n\t\t\ttimestamp: number;\n\t\t\t/** Milliseconds the tool's execution took, measured with a monotonic clock. Absent for legacy results. */\n\t\t\tdurationMs?: number;\n\t\t}\n\t: never;\n\nexport type Message = SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImageApi;\n\tprovider: ProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ClassifierChoiceQuestion {\n\ttype: \"choice\";\n\tinstructions: string;\n\tcriteria: Record<string, string>;\n}\n\nexport interface ClassifierScoreQuestion {\n\ttype: \"score\";\n\tinstructions: string;\n\tcriteria: string[];\n}\n\nexport interface ClassifierBoolQuestion {\n\ttype: \"bool\";\n\tinstructions: string;\n\tcriteria: { true: string; false: string };\n}\n\nexport type ClassifierQuestion = ClassifierChoiceQuestion | ClassifierScoreQuestion | ClassifierBoolQuestion;\n\nexport interface ClassifierContext {\n\tstate: JsonObject;\n\t/**\n\t * Images judged together with `state`. Only models whose `input` includes `\"image\"` accept them;\n\t * other models return an error result.\n\t */\n\timages?: ImageContent[];\n\tquestions: Record<string, ClassifierQuestion>;\n}\n\nexport interface ClassifierChoiceAnswer {\n\ttype: \"choice\";\n\tchoice: string;\n\tprobabilities: Record<string, number>;\n\tconfidence: number;\n}\n\nexport interface ClassifierScoreAnswer {\n\ttype: \"score\";\n\tscore: number;\n\tconfidence: number;\n}\n\nexport interface ClassifierBoolAnswer {\n\ttype: \"bool\";\n\tprobability: number;\n}\n\nexport type ClassifierAnswer = ClassifierChoiceAnswer | ClassifierScoreAnswer | ClassifierBoolAnswer;\nexport type ClassifierStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface ClassifierResult {\n\tapi: ClassifierApi;\n\tprovider: ProviderId;\n\tmodel: string;\n\tanswers: Record<string, ClassifierAnswer>;\n\t/** Token usage and its cost at the model's catalog price, when the service reports token counts. */\n\tusage?: Usage;\n\tstopReason: ClassifierStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nimport type { TSchema } from \"typebox\";\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\n\nexport interface Tool<TParameters extends TSchema = TSchema> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface ToolReference {\n\tname: string;\n}\n\n/**\n * Request input accepted by the public stream entry points (`Models.stream()`,\n * `streamSimple()`, ...). `systemPrompt` and `tools` are shorthand for a leading\n * system message; `normalizeContext()` folds them into one before the request\n * reaches a provider.\n */\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\ndeclare const transcriptContextBrand: unique symbol;\n\n/**\n * Normalized request context passed to providers and API implementations. The\n * prompt and tool declarations are carried by the transcript's system messages.\n * Only `normalizeContext()` produces this type, so a raw `Context` cannot reach\n * provider code by accident.\n */\nexport type TranscriptContext = {\n\tmessages: Message[];\n\treadonly [transcriptContextBrand]: true;\n};\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Successful streams emit `start` before partial updates and terminate with\n * `done`. A stream may terminate directly with `error` when request setup fails\n * before generation starts; after `start`, failures also terminate with `error`.\n * Direct `streamSimple()` calls throw synchronously when request auth is missing.\n * Updates and `done` must never appear before `start`.\n *\n * `partial` is the shared live response-so-far helper, not an event-time\n * snapshot. Text and thinking blocks are empty when their `*_start` event is\n * emitted and grow only through their corresponding `*_delta` events until the\n * authoritative `*_end`. Redacted thinking may be complete at start and emit no\n * deltas. Tool-call arguments at `toolcall_start` are provider-specific;\n * `toolcall_delta` carries subsequent JSON updates.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/** Fields shared by every catalog entry, regardless of what you can do with it. */\nexport interface BaseModel<TApi extends string> {\n\tid: string;\n\tname: string;\n\tapi: TApi;\n\tprovider: ProviderId;\n\tbaseUrl: string;\n\tinput: ModelInputModality[];\n\t/** Provider input limits and cache-safe preprocessing metadata. */\n\tinputLimits?: ModelInputLimits;\n\tcost: ModelCost;\n\theaders?: Record<string, string>;\n}\n\n/** Chat model: usable with `stream()` and friends. */\nexport interface Model<TApi extends Api> extends BaseModel<TApi> {\n\t/**\n\t * Optional: chat is the default model type, so models without `type` are chat\n\t * models. Narrow mixed model lists with `isModelType()` instead of comparing\n\t * `type` directly.\n\t */\n\ttype?: \"chat\";\n\treasoning: boolean;\n\t/**\n\t * Maps pi thinking levels to provider/model-specific values.\n\t * Missing keys use provider defaults. null marks a level as unsupported.\n\t */\n\tthinkingLevelMap?: ThinkingLevelMap;\n\t/** Prompt cache lifetimes per retention tier. Unset when the provider's cache behavior is unknown. */\n\tpromptCache?: ModelPromptCache;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\t/** Default sampling parameters for this model. See {@link StreamOptions.samplingParams}; per-request keys override these. */\n\tsamplingParams?: SamplingParams;\n\t/** Sampling parameter overrides selected by the effective pi thinking level. */\n\tsamplingParamsByThinkingLevel?: SamplingParamsByThinkingLevel;\n\t/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */\n\tcompat?: TApi extends \"openai-completions\"\n\t\t? OpenAICompletionsCompat\n\t\t: TApi extends \"openai-responses\" | \"azure-openai-responses\" | \"openai-codex-responses\"\n\t\t\t? OpenAIResponsesCompat\n\t\t\t: TApi extends \"anthropic-messages\"\n\t\t\t\t? AnthropicMessagesCompat\n\t\t\t\t: TApi extends \"bedrock-converse-stream\"\n\t\t\t\t\t? BedrockCompat\n\t\t\t\t\t: TApi extends \"mistral-conversations\"\n\t\t\t\t\t\t? MistralConversationsCompat\n\t\t\t\t\t\t: never;\n}\n\n/** Image-generation model: usable with `generateImages()` only. */\nexport interface ImageModel<TApi extends ImageApi> extends BaseModel<TApi> {\n\ttype: \"image\";\n\t/** Output modalities. Always includes `\"image\"`; `\"text\"` means the model can also return text blocks. */\n\toutput: (\"text\" | \"image\")[];\n}\n\n/** Structured classifier model: usable with `classify()` only. */\nexport interface ClassifierModel<TApi extends ClassifierApi> extends BaseModel<TApi> {\n\ttype: \"classifier\";\n\tcontextWindow: number;\n}\n\n/** Model shape for each model type. */\nexport interface ModelTypeMap {\n\tchat: Model<Api>;\n\timage: ImageModel<ImageApi>;\n\tclassifier: ClassifierModel<ClassifierApi>;\n}\n\n/** What a catalog entry is for. Decides which `Models` operation accepts it. */\nexport type ModelType = keyof ModelTypeMap;\n\n/** Anything a provider can list. Narrow with `isModelType()`. */\nexport type AnyModel = ModelTypeMap[ModelType];\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TelemetrySpan } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type {\n\tAnthropicMessagesCompat,\n\tBedrockCompat,\n\tMistralConversationsCompat,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n\tSystemOneCompat,\n} from \"./providers/compat-schema.ts\";\nimport type {\n\tCacheRetention,\n\tModelCost,\n\tModelInputLimits,\n\tModelInputModality,\n\tModelPromptCache,\n\tModelThinkingLevel,\n\tThinkingLevel,\n\tThinkingLevelMap,\n} from \"./providers/model-schema.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\nimport type { ClientIdentity } from \"./utils/identity.ts\";\n\nexport type {\n\tAnthropicAllowedFallbackModel,\n\tAnthropicMessagesCompat,\n\tBedrockCompat,\n\tChatTemplateKwargValue,\n\tMistralConversationsCompat,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n\tOpenRouterRouting,\n\tSessionAffinityFormat,\n\tSystemOneCompat,\n\tThinkingTokenBudgetField,\n\tVercelGatewayRouting,\n} from \"./providers/compat-schema.ts\";\nexport type {\n\tCacheRetention,\n\tModelCost,\n\tModelCostRates,\n\tModelCostTier,\n\tModelImageInputLimits,\n\tModelImageResizeOptions,\n\tModelInputLimits,\n\tModelInputModality,\n\tModelPromptCache,\n\tModelThinkingLevel,\n\tThinkingLevel,\n\tThinkingLevelMap,\n} from \"./providers/model-schema.ts\";\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImageApi = \"openrouter-images\";\n\nexport type ImageApi = KnownImageApi | (string & {});\n\nexport type KnownClassifierApi =\n\t| \"typesafe-system-one\"\n\t| \"cloudflare-workers-ai-system-one\"\n\t| \"llama-cpp-classify\"\n\t| \"openai-decisions\";\n\nexport type ClassifierApi = KnownClassifierApi | (string & {});\n\nexport type KnownProvider =\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure\"\n\t| \"openai-codex\"\n\t| \"radius\"\n\t| \"typesafe\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"meta\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\";\nexport type ProviderId = KnownProvider | string;\n\nexport type ToolChoice = \"auto\" | \"none\";\nexport type SamplingParams = Record<string, unknown>;\nexport type SamplingParamsByThinkingLevel = Partial<Record<ModelThinkingLevel, SamplingParams>>;\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\n// Base options all providers share\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/** Explicit parent span for telemetry produced by this logical request. */\n\ttelemetry?: TelemetrySpan;\n\tapiKey?: string;\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (payload: unknown, model: TModel) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * How the request identifies the calling app: `User-Agent` and provider attribution headers.\n\t * Absent fields use pi-ai's defaults: a detailed `User-Agent` and no attribution.\n\t */\n\tidentity?: ClientIdentity;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Optional callback invoked after an HTTP response is received and before\n\t * its body stream is consumed.\n\t */\n\tonResponse?: (response: ProviderResponse, model: Model<Api>) => void | Promise<void>;\n\t/**\n\t * Optional observer for each parsed provider stream event before Pi normalization.\n\t * Event data is adapter-owned and must be treated as read-only.\n\t * Adapter support is explicit; unsupported adapters do not invoke it.\n\t */\n\tonProviderStreamEvent?: (data: unknown, model: Model<Api>) => void | Promise<void>;\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: SamplingParams;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: TranscriptContext, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and\n * `createProvider({ images })` pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\n/** The uniform contract implemented by classifier API modules. */\nexport interface ProviderClassifier {\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ClassifierOptions,\n\t): Promise<ClassifierResult>;\n}\n\nexport interface ClassifierOptions extends ProviderRequestOptions<ClassifierModel<ClassifierApi>> {\n\t/**\n\t * Divides the answer logits by this value before they are normalized into probabilities.\n\t * Values above 1 soften the distribution; values below 1 sharpen it. Must be positive.\n\t * APIs that cannot apply it ignore it.\n\t */\n\ttemperature?: number;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImageModel<ImageApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\t/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */\n\ttoolChoice?: ToolChoice;\n\treasoning?: ThinkingLevel;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n}\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Receives a normalized transcript: the system prompt and tools live in the\n// leading system message, never on the context itself.\n// - Must return an AssistantMessageEventStream.\n// - Direct streamSimple() calls may throw synchronously when request auth is\n// missing. Once a stream is returned, request/model/runtime failures should\n// be encoded in that stream.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: TranscriptContext,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImageModel<ImageApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport type ClassifierFunction<TOptions extends ClassifierOptions = ClassifierOptions> = (\n\tmodel: ClassifierModel<ClassifierApi>,\n\tcontext: ClassifierContext,\n\toptions?: TOptions,\n) => Promise<ClassifierResult>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\tthinkingSignature?: string; // Provider-specific opaque or serialized reasoning replay data\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\"\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: JsonObject;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n\t/** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */\n\tnamespace?: string;\n\t/**\n\t * Set when the model's complete arguments text was not a valid JSON object. `arguments` is then `{}`.\n\t * Describes the problem and includes the text the model sent; tool argument validation fails with it.\n\t */\n\targumentsError?: string;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\t/** Catalog-derived input cost. */\n\t\tinput: number;\n\t\t/** Catalog-derived output cost. */\n\t\toutput: number;\n\t\t/** Catalog-derived cache-read cost. */\n\t\tcacheRead: number;\n\t\t/** Catalog-derived cache-write cost. */\n\t\tcacheWrite: number;\n\t\t/** Best available total: provider-reported billed cost when supported, otherwise the catalog estimate. */\n\t\ttotal: number;\n\t\t/** True when `total` is the billed cost reported by the provider. False when it is a catalog estimate; absent also means false. */\n\t\ttotalFromProvider?: boolean;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = null | boolean | number | string | readonly JsonValue[] | JsonObject;\nexport type JsonObject = { [key: string]: JsonValue };\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\ntype IsExactlyJsonValue<T> = [T] extends [JsonValue] ? ([JsonValue] extends [T] ? true : false) : false;\ntype IsJsonProperty<T> = IsAny<T> extends true\n\t? false\n\t: unknown extends T\n\t\t? false\n\t\t: [Exclude<T, undefined>] extends [never]\n\t\t\t? true\n\t\t\t: IsJsonCompatible<Exclude<T, undefined>>;\ntype InvalidJsonKeys<T extends object> = {\n\t[TKey in keyof T]-?: TKey extends string | number ? (IsJsonProperty<T[TKey]> extends true ? never : TKey) : TKey;\n}[keyof T];\ntype IsJsonCompatible<T> = IsAny<T> extends true\n\t? false\n\t: unknown extends T\n\t\t? false\n\t\t: IsExactlyJsonValue<T> extends true\n\t\t\t? true\n\t\t\t: T extends null | boolean | number | string\n\t\t\t\t? true\n\t\t\t\t: T extends undefined\n\t\t\t\t\t? false\n\t\t\t\t\t: T extends readonly (infer TItem)[]\n\t\t\t\t\t\t? IsJsonCompatible<TItem>\n\t\t\t\t\t\t: T extends (...args: never[]) => unknown\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: T extends object\n\t\t\t\t\t\t\t\t? [InvalidJsonKeys<T>] extends [never]\n\t\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: false;\n\n/** The JSON representation of a typed in-memory value. Optional object properties remain optional. */\nexport type JsonRepresentation<T> = IsAny<T> extends true\n\t? JsonValue\n\t: unknown extends T\n\t\t? JsonValue\n\t\t: [T] extends [JsonValue]\n\t\t\t? T\n\t\t\t: T extends readonly unknown[]\n\t\t\t\t? { [TKey in keyof T]: JsonRepresentation<Exclude<T[TKey], undefined>> }\n\t\t\t\t: T extends object\n\t\t\t\t\t? { [TKey in keyof T]: JsonRepresentation<Exclude<T[TKey], undefined>> }\n\t\t\t\t\t: never;\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\n/**\n * System instructions and tool declarations at one point in the transcript.\n *\n * The leading system message is the system prompt. Later system messages change it:\n * `content` adds instructions from that point on, `sections` replace or remove named\n * prompt sections, and `toolsAdded`/`toolsRemoved` change the tool set. Replaying\n * every system message in order yields the current prompt and tools. Providers that\n * accept system messages mid-conversation send each one in place; other providers\n * rebuild the leading system message from the replayed state.\n */\nexport interface SystemMessage {\n\trole: \"system\";\n\t/** Instruction text. On the leading message this is the base prompt; later, additional instructions. */\n\tcontent: string | TextContent[];\n\t/**\n\t * Named, ordered prompt sections rendered verbatim after `content`. The leading message\n\t * declares them; later messages replace sections by name, and `null` removes one. Keep\n\t * each section self-delimiting (a tag, a heading) so the model can relate an update to\n\t * the original. Avoid integer-like names; JSON objects reorder those.\n\t */\n\tsections?: Record<string, string | null>;\n\t/** Complete definitions of tools that become available at this point. */\n\ttoolsAdded?: Tool[];\n\t/** Tools that stop being available at this point. */\n\ttoolsRemoved?: ToolReference[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete model reported by the provider, when reported. May equal the requested `model`\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\t/** Exact provider-native effort level used for this response. Absent for legacy or unmanaged responses. */\n\tproviderThinkingLevel?: string;\n\t/** Pi thinking level the agent loop requested for this response. Absent outside the agent loop and for legacy responses. */\n\tthinkingLevel?: ModelThinkingLevel;\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\trawStopReason?: string;\n\t/**\n\t * Provider indication of whether the model explicitly ended its turn.\n\t * Preserved for debugging and does not currently affect agent control flow.\n\t */\n\tendTurn?: boolean;\n\t/** Unix timestamp in milliseconds when the request started. */\n\ttimestamp: number;\n\t/**\n\t * Milliseconds from `timestamp` until the response ended, measured with a monotonic clock. Set by\n\t * `AssistantMessageEventStream` on the final message of a response it saw start; absent for legacy messages and\n\t * for deferred results fetched later.\n\t */\n\tdurationMs?: number;\n}\n\n/** A tool call that another tool made while it ran, for example from a codemode script. */\nexport interface NestedToolCallRecord {\n\tid: string;\n\tname: string;\n\t/** Omitted when over the size limits; `argumentsBytes` then gives their size. */\n\targuments?: JsonObject;\n\t/** UTF-8 size of the arguments as JSON, set when `arguments` is omitted. */\n\targumentsBytes?: number;\n\t/** `unfinished`: the call was still running when the calling tool finished. */\n\tstatus: \"ok\" | \"error\" | \"unfinished\";\n\tdurationMs?: number;\n\t/** Error text, truncated. */\n\terror?: string;\n}\n\n/** Bounded record of the nested calls a tool made. Results are not recorded. */\nexport interface NestedToolCalls {\n\tcalls: NestedToolCallRecord[];\n\t/** False when calls were dropped, arguments omitted, or calls had not finished. */\n\tcomplete: boolean;\n}\n\nexport type ToolResultMessage<TDetails = JsonValue> = IsJsonCompatible<TDetails> extends true\n\t? {\n\t\t\trole: \"toolResult\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\t\t\tdetails?: JsonRepresentation<TDetails>;\n\t\t\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\t\t\tusage?: Usage;\n\t\t\t/** Calls this tool made to other tools. Kept for the session record; not sent to the model. */\n\t\t\tnestedCalls?: NestedToolCalls;\n\t\t\tisError: boolean;\n\t\t\t/** Unix timestamp in milliseconds when the result was created. */\n\t\t\ttimestamp: number;\n\t\t\t/** Milliseconds the tool's execution took, measured with a monotonic clock. Absent for legacy results. */\n\t\t\tdurationMs?: number;\n\t\t}\n\t: never;\n\nexport type Message = SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImageApi;\n\tprovider: ProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ClassifierChoiceQuestion {\n\ttype: \"choice\";\n\tinstructions: string;\n\tcriteria: Record<string, string>;\n}\n\nexport interface ClassifierScoreQuestion {\n\ttype: \"score\";\n\tinstructions: string;\n\tcriteria: string[];\n}\n\nexport interface ClassifierBoolQuestion {\n\ttype: \"bool\";\n\tinstructions: string;\n\tcriteria: { true: string; false: string };\n}\n\nexport type ClassifierQuestion = ClassifierChoiceQuestion | ClassifierScoreQuestion | ClassifierBoolQuestion;\n\nexport interface ClassifierContext {\n\tstate: JsonObject;\n\t/**\n\t * Images judged together with `state`. Only models whose `input` includes `\"image\"` accept them;\n\t * other models return an error result.\n\t */\n\timages?: ImageContent[];\n\tquestions: Record<string, ClassifierQuestion>;\n}\n\nexport interface ClassifierChoiceAnswer {\n\ttype: \"choice\";\n\tchoice: string;\n\tprobabilities: Record<string, number>;\n\tconfidence: number;\n}\n\nexport interface ClassifierScoreAnswer {\n\ttype: \"score\";\n\tscore: number;\n\tconfidence: number;\n}\n\nexport interface ClassifierBoolAnswer {\n\ttype: \"bool\";\n\tprobability: number;\n}\n\nexport type ClassifierAnswer = ClassifierChoiceAnswer | ClassifierScoreAnswer | ClassifierBoolAnswer;\nexport type ClassifierStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface ClassifierResult {\n\tapi: ClassifierApi;\n\tprovider: ProviderId;\n\tmodel: string;\n\tanswers: Record<string, ClassifierAnswer>;\n\t/** Token usage and its cost at the model's catalog price, when the service reports token counts. */\n\tusage?: Usage;\n\tstopReason: ClassifierStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\n\n/**\n * A tool the model may call. `parameters` is the JSON Schema of its arguments: pi-schema's builders (which also type\n * the arguments, see `Static` in `@earendil-works/pi-schema`), TypeBox schemas, or any JSON Schema object.\n */\nexport interface Tool<TParameters extends object = object> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface ToolReference {\n\tname: string;\n}\n\n/**\n * Request input accepted by the public stream entry points (`Models.stream()`,\n * `streamSimple()`, ...). `systemPrompt` and `tools` are shorthand for a leading\n * system message; `normalizeContext()` folds them into one before the request\n * reaches a provider.\n */\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\ndeclare const transcriptContextBrand: unique symbol;\n\n/**\n * Normalized request context passed to providers and API implementations. The\n * prompt and tool declarations are carried by the transcript's system messages.\n * Only `normalizeContext()` produces this type, so a raw `Context` cannot reach\n * provider code by accident.\n */\nexport type TranscriptContext = {\n\tmessages: Message[];\n\treadonly [transcriptContextBrand]: true;\n};\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Successful streams emit `start` before partial updates and terminate with\n * `done`. A stream may terminate directly with `error` when request setup fails\n * before generation starts; after `start`, failures also terminate with `error`.\n * Direct `streamSimple()` calls throw synchronously when request auth is missing.\n * Updates and `done` must never appear before `start`.\n *\n * `partial` is the shared live response-so-far helper, not an event-time\n * snapshot. Text and thinking blocks are empty when their `*_start` event is\n * emitted and grow only through their corresponding `*_delta` events until the\n * authoritative `*_end`. Redacted thinking may be complete at start and emit no\n * deltas. Tool-call arguments at `toolcall_start` are provider-specific;\n * `toolcall_delta` carries subsequent JSON updates.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/** Fields shared by every catalog entry, regardless of what you can do with it. */\nexport interface BaseModel<TApi extends string> {\n\tid: string;\n\tname: string;\n\tapi: TApi;\n\tprovider: ProviderId;\n\tbaseUrl: string;\n\tinput: ModelInputModality[];\n\t/** Provider input limits and cache-safe preprocessing metadata. */\n\tinputLimits?: ModelInputLimits;\n\tcost: ModelCost;\n\theaders?: Record<string, string>;\n}\n\n/** Chat model: usable with `stream()` and friends. */\nexport interface Model<TApi extends Api> extends BaseModel<TApi> {\n\t/**\n\t * Optional: chat is the default model type, so models without `type` are chat\n\t * models. Narrow mixed model lists with `isModelType()` instead of comparing\n\t * `type` directly.\n\t */\n\ttype?: \"chat\";\n\treasoning: boolean;\n\t/**\n\t * Maps pi thinking levels to provider/model-specific values.\n\t * Missing keys use provider defaults. null marks a level as unsupported.\n\t */\n\tthinkingLevelMap?: ThinkingLevelMap;\n\t/** Prompt cache lifetimes per retention tier. Unset when the provider's cache behavior is unknown. */\n\tpromptCache?: ModelPromptCache;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\t/** Default sampling parameters for this model. See {@link StreamOptions.samplingParams}; per-request keys override these. */\n\tsamplingParams?: SamplingParams;\n\t/** Sampling parameter overrides selected by the effective pi thinking level. */\n\tsamplingParamsByThinkingLevel?: SamplingParamsByThinkingLevel;\n\t/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */\n\tcompat?: TApi extends \"openai-completions\"\n\t\t? OpenAICompletionsCompat\n\t\t: TApi extends \"openai-responses\" | \"azure-openai-responses\" | \"openai-codex-responses\"\n\t\t\t? OpenAIResponsesCompat\n\t\t\t: TApi extends \"anthropic-messages\"\n\t\t\t\t? AnthropicMessagesCompat\n\t\t\t\t: TApi extends \"bedrock-converse-stream\"\n\t\t\t\t\t? BedrockCompat\n\t\t\t\t\t: TApi extends \"mistral-conversations\"\n\t\t\t\t\t\t? MistralConversationsCompat\n\t\t\t\t\t\t: never;\n}\n\n/** Image-generation model: usable with `generateImages()` only. */\nexport interface ImageModel<TApi extends ImageApi> extends BaseModel<TApi> {\n\ttype: \"image\";\n\t/** Output modalities. Always includes `\"image\"`; `\"text\"` means the model can also return text blocks. */\n\toutput: (\"text\" | \"image\")[];\n}\n\n/** Structured classifier model: usable with `classify()` only. */\nexport interface ClassifierModel<TApi extends ClassifierApi> extends BaseModel<TApi> {\n\ttype: \"classifier\";\n\tcontextWindow: number;\n\t/** Compatibility overrides for System One APIs. If not set, auto-detected from provider, baseUrl, and id. */\n\tcompat?: TApi extends \"typesafe-system-one\" | \"cloudflare-workers-ai-system-one\" ? SystemOneCompat : never;\n}\n\n/** Model shape for each model type. */\nexport interface ModelTypeMap {\n\tchat: Model<Api>;\n\timage: ImageModel<ImageApi>;\n\tclassifier: ClassifierModel<ClassifierApi>;\n}\n\n/** What a catalog entry is for. Decides which `Models` operation accepts it. */\nexport type ModelType = keyof ModelTypeMap;\n\n/** Anything a provider can list. Narrow with `isModelType()`. */\nexport type AnyModel = ModelTypeMap[ModelType];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-body.d.ts","sourceRoot":"","sources":["../../src/utils/error-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-body.d.ts","sourceRoot":"","sources":["../../src/utils/error-body.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,MAAM,WAAW,uBAAuB;IACvC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAWD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAgB9E;AAiED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOxD"}
|
package/dist/utils/error-body.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// composes into its display string. The `messageCarriesBody` flag captures the
|
|
13
13
|
// Anthropic / `@google/genai` happy path where the SDK already folded the body
|
|
14
14
|
// into the message, so providers can preserve it without double-printing.
|
|
15
|
+
import { ownedSlice } from "./text.js";
|
|
15
16
|
export const MAX_PROVIDER_ERROR_BODY_CHARS = 4000;
|
|
16
17
|
export function normalizeProviderError(error) {
|
|
17
18
|
if (!(error instanceof Error)) {
|
|
@@ -119,7 +120,7 @@ export function formatProviderError(norm, prefix) {
|
|
|
119
120
|
export function truncateErrorText(text, maxChars) {
|
|
120
121
|
if (text.length <= maxChars)
|
|
121
122
|
return text;
|
|
122
|
-
return `${text
|
|
123
|
+
return `${ownedSlice(text, 0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
123
124
|
}
|
|
124
125
|
export function safeJsonStringify(value) {
|
|
125
126
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-body.js","sourceRoot":"","sources":["../../src/utils/error-body.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,yCAAyC;AACzC,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,0EAA0E;AAE1E,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAsBlD,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACzE,CAAC;IAED,MAAM,QAAQ,GAAG,KAAsB,CAAC;IACxC,MAAM,MAAM,GAAG,aAAa,CA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AAK,SAAS;YACvD,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE;YAC/C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;AAC3G,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,QAAgB;IAC/D,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,kBAAkB,IAAI,CAAC,MAAM,GAAG,QAAQ,SAAS,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC/C,IAAI,CAAC;QACJ,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["// Shared normalization for provider HTTP error objects.\n//\n// Endpoints behind a proxy / gateway may return a non-2xx response whose body\n// the provider SDK cannot fold into `error.message`. The SDK error object still\n// carries the HTTP status and the raw/parsed body, but under SDK-specific field\n// names. Provider catch blocks that read only `error.message` therefore drop\n// the body and surface opaque messages like `\"403 status code (no body)\"` or\n// collapse to `\"Unknown: UnknownError\"`.\n//\n// `normalizeProviderError` probes the known SDK field shapes (Mistral,\n// `openai`, `@google/genai`, AWS Bedrock) and returns a struct each provider\n// composes into its display string. The `messageCarriesBody` flag captures the\n// Anthropic / `@google/genai` happy path where the SDK already folded the body\n// into the message, so providers can preserve it without double-printing.\n\nexport const MAX_PROVIDER_ERROR_BODY_CHARS = 4000;\n\nexport interface NormalizedProviderError {\n\t/** HTTP status code, when one could be extracted from the SDK error object. */\n\tstatus?: number;\n\t/** Raw HTTP body reason, already trimmed and truncated to the cap. */\n\tbody?: string;\n\t/** `error.message`, or `safeJsonStringify(error)` for a non-`Error` throw. */\n\tmessage: string;\n\t/** True when `message` already contains the body (no separate body to add). */\n\tmessageCarriesBody: boolean;\n}\n\ntype SdkErrorShape = Error & {\n\tstatusCode?: unknown;\n\tstatus?: unknown;\n\tbody?: unknown;\n\terror?: unknown;\n\t$metadata?: { httpStatusCode?: unknown };\n\t$response?: { statusCode?: unknown; body?: unknown };\n};\n\nexport function normalizeProviderError(error: unknown): NormalizedProviderError {\n\tif (!(error instanceof Error)) {\n\t\treturn { message: safeJsonStringify(error), messageCarriesBody: false };\n\t}\n\n\tconst sdkError = error as SdkErrorShape;\n\tconst status = extractStatus(sdkError);\n\tconst body = extractBody(sdkError);\n\tconst messageCarriesBody = body === undefined || error.message.includes(body);\n\n\treturn {\n\t\tstatus,\n\t\tbody,\n\t\tmessage: error.message,\n\t\tmessageCarriesBody,\n\t} satisfies NormalizedProviderError;\n}\n\n/**\n * Probe the HTTP status, first numeric hit wins, in SDK-field order:\n * `statusCode` (Mistral) → `status` (`openai`, `@google/genai`) →\n * `$metadata.httpStatusCode` (Bedrock) → `$response.statusCode` (Bedrock).\n */\nfunction extractStatus(error: SdkErrorShape): number | undefined {\n\tif (typeof error.statusCode === \"number\") return error.statusCode;\n\tif (typeof error.status === \"number\") return error.status;\n\tif (typeof error.$metadata?.httpStatusCode === \"number\") return error.$metadata.httpStatusCode;\n\tif (typeof error.$response?.statusCode === \"number\") return error.$response.statusCode;\n\treturn undefined;\n}\n\n/**\n * Probe the raw body reason, first usable hit wins, in SDK-field order:\n * `body` string (Mistral) → `error` parsed JSON body object (`openai` SDK's\n * `this.error`) → `$response.body` (Bedrock). Empty objects and unread response\n * streams are treated as no body so they do not surface as `\"{}\"` or serialized\n * stream internals. The chosen body is truncated to the cap.\n */\nfunction extractBody(error: SdkErrorShape): string | undefined {\n\tconst bodyText = pickBodyText(error);\n\tif (bodyText === undefined) return undefined;\n\tconst trimmed = bodyText.trim();\n\tif (trimmed.length === 0) return undefined;\n\treturn truncateErrorText(trimmed, MAX_PROVIDER_ERROR_BODY_CHARS);\n}\n\nfunction pickBodyText(error: SdkErrorShape): string | undefined {\n\tif (typeof error.body === \"string\") return error.body;\n\tif (isPlainNonEmptyObject(error.error)) return safeJsonStringify(error.error);\n\tconst responseBody = error.$response?.body;\n\tif (typeof responseBody === \"string\") return responseBody;\n\tif (isReadableStreamLike(responseBody)) return undefined;\n\tif (isPlainNonEmptyObject(responseBody)) return safeJsonStringify(responseBody);\n\treturn undefined;\n}\n\nfunction isReadableStreamLike(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && \"pipe\" in value && typeof value.pipe === \"function\";\n}\n\n/**\n * Only a PLAIN object counts as an HTTP body. SDK error fields can hold class\n * instances instead of parsed bodies — AWS SDK v3's `$response.body` is an\n * HTTP stream/response wrapper object, and stringifying one produced garbage\n * like `{\"_events\":...}` as the \"body\", which then REPLACED `error.message`\n * in the composed display string. `error.message` is where the SDK puts the\n * real deserialized exception text (\"Input is too long...\", schema validation\n * details, ...), so the one useful string was discarded for noise. A class\n * instance yields no body, `messageCarriesBody` stays true, and the real\n * message survives. Complements the `pipe` sniffing above: web\n * ReadableStreams (pipeTo/pipeThrough, no `pipe`) and non-stream SDK wrapper\n * classes fail the prototype check, while parsed JSON bodies (plain objects\n * by construction) still pass.\n */\nfunction isPlainNonEmptyObject(value: unknown): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\tif (proto !== Object.prototype && proto !== null) return false;\n\treturn Object.keys(value).length > 0;\n}\n\n/**\n * Compose a display string from a normalized error. When the message already\n * carries the body (Anthropic / `@google/genai` happy path) or no body/status\n * was extracted, the message is returned unchanged. Otherwise the status and\n * body are surfaced, with an optional provider prefix.\n *\n * - no prefix: `\"<status>: <body>\"`\n * - prefix: `\"<prefix> (<status>): <body>\"`\n */\nexport function formatProviderError(norm: NormalizedProviderError, prefix?: string): string {\n\tif (norm.messageCarriesBody || norm.status === undefined || norm.body === undefined) {\n\t\treturn prefix !== undefined && norm.status !== undefined\n\t\t\t? `${prefix} (${norm.status}): ${norm.message}`\n\t\t\t: norm.message;\n\t}\n\treturn prefix !== undefined ? `${prefix} (${norm.status}): ${norm.body}` : `${norm.status}: ${norm.body}`;\n}\n\nexport function truncateErrorText(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\treturn `${text.slice(0, maxChars)}... [truncated ${text.length - maxChars} chars]`;\n}\n\nexport function safeJsonStringify(value: unknown): string {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\treturn serialized === undefined ? String(value) : serialized;\n\t} catch {\n\t\treturn String(value);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error-body.js","sourceRoot":"","sources":["../../src/utils/error-body.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,yCAAyC;AACzC,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,0EAA0E;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAsBlD,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAA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,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACrF,OAAO,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YACvD,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE;YAC/C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;AAC3G,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,QAAgB;IAC/D,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,kBAAkB,IAAI,CAAC,MAAM,GAAG,QAAQ,SAAS,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC/C,IAAI,CAAC;QACJ,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["// Shared normalization for provider HTTP error objects.\n//\n// Endpoints behind a proxy / gateway may return a non-2xx response whose body\n// the provider SDK cannot fold into `error.message`. The SDK error object still\n// carries the HTTP status and the raw/parsed body, but under SDK-specific field\n// names. Provider catch blocks that read only `error.message` therefore drop\n// the body and surface opaque messages like `\"403 status code (no body)\"` or\n// collapse to `\"Unknown: UnknownError\"`.\n//\n// `normalizeProviderError` probes the known SDK field shapes (Mistral,\n// `openai`, `@google/genai`, AWS Bedrock) and returns a struct each provider\n// composes into its display string. The `messageCarriesBody` flag captures the\n// Anthropic / `@google/genai` happy path where the SDK already folded the body\n// into the message, so providers can preserve it without double-printing.\n\nimport { ownedSlice } from \"./text.ts\";\n\nexport const MAX_PROVIDER_ERROR_BODY_CHARS = 4000;\n\nexport interface NormalizedProviderError {\n\t/** HTTP status code, when one could be extracted from the SDK error object. */\n\tstatus?: number;\n\t/** Raw HTTP body reason, already trimmed and truncated to the cap. */\n\tbody?: string;\n\t/** `error.message`, or `safeJsonStringify(error)` for a non-`Error` throw. */\n\tmessage: string;\n\t/** True when `message` already contains the body (no separate body to add). */\n\tmessageCarriesBody: boolean;\n}\n\ntype SdkErrorShape = Error & {\n\tstatusCode?: unknown;\n\tstatus?: unknown;\n\tbody?: unknown;\n\terror?: unknown;\n\t$metadata?: { httpStatusCode?: unknown };\n\t$response?: { statusCode?: unknown; body?: unknown };\n};\n\nexport function normalizeProviderError(error: unknown): NormalizedProviderError {\n\tif (!(error instanceof Error)) {\n\t\treturn { message: safeJsonStringify(error), messageCarriesBody: false };\n\t}\n\n\tconst sdkError = error as SdkErrorShape;\n\tconst status = extractStatus(sdkError);\n\tconst body = extractBody(sdkError);\n\tconst messageCarriesBody = body === undefined || error.message.includes(body);\n\n\treturn {\n\t\tstatus,\n\t\tbody,\n\t\tmessage: error.message,\n\t\tmessageCarriesBody,\n\t} satisfies NormalizedProviderError;\n}\n\n/**\n * Probe the HTTP status, first numeric hit wins, in SDK-field order:\n * `statusCode` (Mistral) → `status` (`openai`, `@google/genai`) →\n * `$metadata.httpStatusCode` (Bedrock) → `$response.statusCode` (Bedrock).\n */\nfunction extractStatus(error: SdkErrorShape): number | undefined {\n\tif (typeof error.statusCode === \"number\") return error.statusCode;\n\tif (typeof error.status === \"number\") return error.status;\n\tif (typeof error.$metadata?.httpStatusCode === \"number\") return error.$metadata.httpStatusCode;\n\tif (typeof error.$response?.statusCode === \"number\") return error.$response.statusCode;\n\treturn undefined;\n}\n\n/**\n * Probe the raw body reason, first usable hit wins, in SDK-field order:\n * `body` string (Mistral) → `error` parsed JSON body object (`openai` SDK's\n * `this.error`) → `$response.body` (Bedrock). Empty objects and unread response\n * streams are treated as no body so they do not surface as `\"{}\"` or serialized\n * stream internals. The chosen body is truncated to the cap.\n */\nfunction extractBody(error: SdkErrorShape): string | undefined {\n\tconst bodyText = pickBodyText(error);\n\tif (bodyText === undefined) return undefined;\n\tconst trimmed = bodyText.trim();\n\tif (trimmed.length === 0) return undefined;\n\treturn truncateErrorText(trimmed, MAX_PROVIDER_ERROR_BODY_CHARS);\n}\n\nfunction pickBodyText(error: SdkErrorShape): string | undefined {\n\tif (typeof error.body === \"string\") return error.body;\n\tif (isPlainNonEmptyObject(error.error)) return safeJsonStringify(error.error);\n\tconst responseBody = error.$response?.body;\n\tif (typeof responseBody === \"string\") return responseBody;\n\tif (isReadableStreamLike(responseBody)) return undefined;\n\tif (isPlainNonEmptyObject(responseBody)) return safeJsonStringify(responseBody);\n\treturn undefined;\n}\n\nfunction isReadableStreamLike(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && \"pipe\" in value && typeof value.pipe === \"function\";\n}\n\n/**\n * Only a PLAIN object counts as an HTTP body. SDK error fields can hold class\n * instances instead of parsed bodies — AWS SDK v3's `$response.body` is an\n * HTTP stream/response wrapper object, and stringifying one produced garbage\n * like `{\"_events\":...}` as the \"body\", which then REPLACED `error.message`\n * in the composed display string. `error.message` is where the SDK puts the\n * real deserialized exception text (\"Input is too long...\", schema validation\n * details, ...), so the one useful string was discarded for noise. A class\n * instance yields no body, `messageCarriesBody` stays true, and the real\n * message survives. Complements the `pipe` sniffing above: web\n * ReadableStreams (pipeTo/pipeThrough, no `pipe`) and non-stream SDK wrapper\n * classes fail the prototype check, while parsed JSON bodies (plain objects\n * by construction) still pass.\n */\nfunction isPlainNonEmptyObject(value: unknown): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\tif (proto !== Object.prototype && proto !== null) return false;\n\treturn Object.keys(value).length > 0;\n}\n\n/**\n * Compose a display string from a normalized error. When the message already\n * carries the body (Anthropic / `@google/genai` happy path) or no body/status\n * was extracted, the message is returned unchanged. Otherwise the status and\n * body are surfaced, with an optional provider prefix.\n *\n * - no prefix: `\"<status>: <body>\"`\n * - prefix: `\"<prefix> (<status>): <body>\"`\n */\nexport function formatProviderError(norm: NormalizedProviderError, prefix?: string): string {\n\tif (norm.messageCarriesBody || norm.status === undefined || norm.body === undefined) {\n\t\treturn prefix !== undefined && norm.status !== undefined\n\t\t\t? `${prefix} (${norm.status}): ${norm.message}`\n\t\t\t: norm.message;\n\t}\n\treturn prefix !== undefined ? `${prefix} (${norm.status}): ${norm.body}` : `${norm.status}: ${norm.body}`;\n}\n\nexport function truncateErrorText(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\treturn `${ownedSlice(text, 0, maxChars)}... [truncated ${text.length - maxChars} chars]`;\n}\n\nexport function safeJsonStringify(value: unknown): string {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\treturn serialized === undefined ? String(value) : serialized;\n\t} catch {\n\t\treturn String(value);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Models, MutableModels } from "../models.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The `User-Agent` sent to providers:
|
|
4
|
+
* - `"detailed"`: `pi/<version> (<platform>; <runtime>/<runtime version>; <arch>)`, or `pi/<version> (browser)`
|
|
5
|
+
* outside Node.js and Bun.
|
|
6
|
+
* - `"short"`: `pi`.
|
|
7
|
+
* - `{ custom }`: the given value.
|
|
8
|
+
*/
|
|
9
|
+
export type UserAgentMode = "short" | "detailed" | {
|
|
10
|
+
custom: string;
|
|
11
|
+
};
|
|
12
|
+
/** Who requests are attributed to. `getAttributionHeaders()` maps the fields to each provider's headers. */
|
|
13
|
+
export interface ClientAttribution {
|
|
14
|
+
/** App name: OpenRouter app title, NVIDIA invoke origin (first letter upper-cased), OpenCode client. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** App URL: OpenRouter `HTTP-Referer`, the app's identity in OpenRouter's rankings, grouped by origin. */
|
|
17
|
+
url: string;
|
|
18
|
+
/** App categories, e.g. `["cli-agent"]`: OpenRouter `X-OpenRouter-Categories`, comma-separated. */
|
|
19
|
+
categories?: string[];
|
|
20
|
+
}
|
|
21
|
+
/** pi's attribution, used by pi-agent-core, pi-durable, and the coding agent. */
|
|
22
|
+
export declare const PI_ATTRIBUTION: ClientAttribution;
|
|
23
|
+
/**
|
|
24
|
+
* How pi-ai identifies the calling app to providers. Every field is optional; absent fields use pi-ai's defaults:
|
|
25
|
+
* a detailed `User-Agent` with pi-ai's version and no attribution headers. Plain JSON, so it can be persisted.
|
|
26
|
+
*/
|
|
27
|
+
export interface ClientIdentity {
|
|
28
|
+
/** Default: `"detailed"`. */
|
|
29
|
+
userAgent?: UserAgentMode;
|
|
30
|
+
/** Provider attribution headers. Absent or `null`: none; `null` also turns off attribution set by a merged identity. */
|
|
31
|
+
attribution?: ClientAttribution | null;
|
|
32
|
+
/** Version in the detailed `User-Agent`. Default: the pi-ai version. */
|
|
33
|
+
version?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The provider and endpoint a request goes to. */
|
|
36
|
+
export interface ClientIdentityTarget {
|
|
37
|
+
readonly provider: string;
|
|
38
|
+
readonly baseUrl: string;
|
|
39
|
+
}
|
|
40
|
+
/** Merge identities field by field; later sources win and undefined fields are skipped. */
|
|
41
|
+
export declare function mergeClientIdentity(...sources: (ClientIdentity | undefined)[]): ClientIdentity | undefined;
|
|
42
|
+
/** The version in the detailed `User-Agent`. */
|
|
43
|
+
export declare function getClientVersion(identity?: ClientIdentity): string;
|
|
44
|
+
/** The `User-Agent` value of an identity. */
|
|
45
|
+
export declare function formatUserAgent(identity?: ClientIdentity): string;
|
|
46
|
+
/** Provider attribution headers of an identity for a request target. Empty when attribution is off. */
|
|
47
|
+
export declare function getAttributionHeaders(target: ClientIdentityTarget, identity?: ClientIdentity): Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* OpenCode's per-conversation routing header for requests to OpenCode, including custom providers pointing at it.
|
|
50
|
+
* Undefined without a session or for other targets.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getOpenCodeSessionHeaders(target: ClientIdentityTarget, sessionId: string | undefined): Record<string, string> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Default headers an identity adds to a request: `User-Agent` and provider attribution. APIs apply them below model,
|
|
55
|
+
* provider, and request headers, so configured headers override them and `null` request headers remove them.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getIdentityHeaders(target: ClientIdentityTarget, identity?: ClientIdentity): Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* `models` with `identity` as the default identity of its requests: a request's `identity` overrides it field by
|
|
60
|
+
* field, and it overrides the identity `models` was created with. Everything else is delegated unchanged; a
|
|
61
|
+
* `MutableModels` stays mutable.
|
|
62
|
+
*/
|
|
63
|
+
export declare function withClientIdentity(models: MutableModels, identity: ClientIdentity): MutableModels;
|
|
64
|
+
export declare function withClientIdentity(models: Models, identity: ClientIdentity): Models;
|
|
65
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/utils/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,4GAA4G;AAC5G,MAAM,WAAW,iBAAiB;IACjC,wGAAwG;IACxG,IAAI,EAAE,MAAM,CAAC;IACb,0G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EAAE,MAAM,CAAC,CAElH;AAMD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,GAAG,aAAa,CAAC;AACnG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { PI_AI_VERSION } from "./version.js";
|
|
2
|
+
/** pi's attribution, used by pi-agent-core, pi-durable, and the coding agent. */
|
|
3
|
+
export const PI_ATTRIBUTION = { name: "pi", url: "https://pi.dev", categories: ["cli-agent"] };
|
|
4
|
+
const NVIDIA_NIM_HOST = "integrate.api.nvidia.com";
|
|
5
|
+
const OPENCODE_HOST = "opencode.ai";
|
|
6
|
+
/** Merge identities field by field; later sources win and undefined fields are skipped. */
|
|
7
|
+
export function mergeClientIdentity(...sources) {
|
|
8
|
+
let merged;
|
|
9
|
+
for (const source of sources) {
|
|
10
|
+
if (!source)
|
|
11
|
+
continue;
|
|
12
|
+
merged = { ...merged };
|
|
13
|
+
if (source.userAgent !== undefined)
|
|
14
|
+
merged.userAgent = source.userAgent;
|
|
15
|
+
if (source.attribution !== undefined)
|
|
16
|
+
merged.attribution = source.attribution;
|
|
17
|
+
if (source.version !== undefined)
|
|
18
|
+
merged.version = source.version;
|
|
19
|
+
}
|
|
20
|
+
return merged;
|
|
21
|
+
}
|
|
22
|
+
/** The version in the detailed `User-Agent`. */
|
|
23
|
+
export function getClientVersion(identity) {
|
|
24
|
+
return identity?.version ?? PI_AI_VERSION;
|
|
25
|
+
}
|
|
26
|
+
function runtimeDescription() {
|
|
27
|
+
if (typeof process === "undefined")
|
|
28
|
+
return undefined;
|
|
29
|
+
const versions = process.versions;
|
|
30
|
+
if (versions?.bun)
|
|
31
|
+
return `bun/${versions.bun}`;
|
|
32
|
+
if (versions?.node)
|
|
33
|
+
return `node/${process.version}`;
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The `User-Agent` value of an identity. */
|
|
37
|
+
export function formatUserAgent(identity) {
|
|
38
|
+
const mode = identity?.userAgent ?? "detailed";
|
|
39
|
+
if (typeof mode === "object")
|
|
40
|
+
return mode.custom;
|
|
41
|
+
if (mode === "short")
|
|
42
|
+
return "pi";
|
|
43
|
+
const product = `pi/${getClientVersion(identity)}`;
|
|
44
|
+
const runtime = runtimeDescription();
|
|
45
|
+
return runtime ? `${product} (${process.platform}; ${runtime}; ${process.arch})` : `${product} (browser)`;
|
|
46
|
+
}
|
|
47
|
+
function matchesHost(baseUrl, expectedHost) {
|
|
48
|
+
try {
|
|
49
|
+
return new URL(baseUrl).hostname === expectedHost;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function isOpenRouter(target) {
|
|
56
|
+
return target.provider === "openrouter" || target.baseUrl.includes("openrouter.ai");
|
|
57
|
+
}
|
|
58
|
+
function isNvidiaNim(target) {
|
|
59
|
+
return target.provider === "nvidia" || matchesHost(target.baseUrl, NVIDIA_NIM_HOST);
|
|
60
|
+
}
|
|
61
|
+
function isOpenCode(target) {
|
|
62
|
+
return (target.provider === "opencode" || target.provider === "opencode-go" || matchesHost(target.baseUrl, OPENCODE_HOST));
|
|
63
|
+
}
|
|
64
|
+
/** Provider attribution headers of an identity for a request target. Empty when attribution is off. */
|
|
65
|
+
export function getAttributionHeaders(target, identity) {
|
|
66
|
+
const attribution = identity?.attribution;
|
|
67
|
+
if (!attribution)
|
|
68
|
+
return {};
|
|
69
|
+
const { name, url, categories } = attribution;
|
|
70
|
+
if (isOpenRouter(target)) {
|
|
71
|
+
return {
|
|
72
|
+
"HTTP-Referer": url,
|
|
73
|
+
"X-OpenRouter-Title": name,
|
|
74
|
+
...(categories === undefined || categories.length === 0
|
|
75
|
+
? {}
|
|
76
|
+
: { "X-OpenRouter-Categories": categories.join(",") }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// NVIDIA expects a capitalized origin, such as `Pi`.
|
|
80
|
+
if (isNvidiaNim(target))
|
|
81
|
+
return { "X-BILLING-INVOKE-ORIGIN": name.charAt(0).toUpperCase() + name.slice(1) };
|
|
82
|
+
if (isOpenCode(target))
|
|
83
|
+
return { "x-opencode-client": name };
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* OpenCode's per-conversation routing header for requests to OpenCode, including custom providers pointing at it.
|
|
88
|
+
* Undefined without a session or for other targets.
|
|
89
|
+
*/
|
|
90
|
+
export function getOpenCodeSessionHeaders(target, sessionId) {
|
|
91
|
+
return sessionId && isOpenCode(target) ? { "x-opencode-session": sessionId } : undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Default headers an identity adds to a request: `User-Agent` and provider attribution. APIs apply them below model,
|
|
95
|
+
* provider, and request headers, so configured headers override them and `null` request headers remove them.
|
|
96
|
+
*/
|
|
97
|
+
export function getIdentityHeaders(target, identity) {
|
|
98
|
+
return { "User-Agent": formatUserAgent(identity), ...getAttributionHeaders(target, identity) };
|
|
99
|
+
}
|
|
100
|
+
function isMutableModels(models) {
|
|
101
|
+
return "setProvider" in models && "deleteProvider" in models && "clearProviders" in models;
|
|
102
|
+
}
|
|
103
|
+
export function withClientIdentity(models, identity) {
|
|
104
|
+
const withIdentity = (options) => ({ ...options, identity: mergeClientIdentity(identity, options?.identity) });
|
|
105
|
+
const wrapped = {
|
|
106
|
+
getProviders: () => models.getProviders(),
|
|
107
|
+
getProvider: (id) => models.getProvider(id),
|
|
108
|
+
getModels: (provider) => models.getModels(provider),
|
|
109
|
+
getModel: (provider, id) => models.getModel(provider, id),
|
|
110
|
+
getModelsOfType: (type, provider) => models.getModelsOfType(type, provider),
|
|
111
|
+
getModelOfType: (type, provider, id) => models.getModelOfType(type, provider, id),
|
|
112
|
+
getAllModels: (provider) => models.getAllModels(provider),
|
|
113
|
+
refresh: (options) => models.refresh(options),
|
|
114
|
+
checkAuth: (providerId, options) => models.checkAuth(providerId, options),
|
|
115
|
+
getAvailable: (providerId, options) => models.getAvailable(providerId, options),
|
|
116
|
+
getAvailableOfType: (type, providerId, options) => models.getAvailableOfType(type, providerId, options),
|
|
117
|
+
getAllAvailable: (providerId, options) => models.getAllAvailable(providerId, options),
|
|
118
|
+
getAuth: models.getAuth.bind(models),
|
|
119
|
+
login: (providerId, type, interaction, options) => models.login(providerId, type, interaction, options),
|
|
120
|
+
logout: (providerId, options) => models.logout(providerId, options),
|
|
121
|
+
stream: (model, context, options) => models.stream(model, context, withIdentity(options)),
|
|
122
|
+
complete: (model, context, options) => models.complete(model, context, withIdentity(options)),
|
|
123
|
+
streamSimple: (model, context, options) => models.streamSimple(model, context, withIdentity(options)),
|
|
124
|
+
completeSimple: (model, context, options) => models.completeSimple(model, context, withIdentity(options)),
|
|
125
|
+
streamDeferred: (model, handle, options) => models.streamDeferred(model, handle, withIdentity(options)),
|
|
126
|
+
fetchDeferred: (model, handle, options) => models.fetchDeferred(model, handle, withIdentity(options)),
|
|
127
|
+
cancelDeferred: (model, handle, options) => models.cancelDeferred(model, handle, withIdentity(options)),
|
|
128
|
+
generateImages: (model, context, options) => models.generateImages(model, context, withIdentity(options)),
|
|
129
|
+
classify: (model, context, options) => models.classify(model, context, withIdentity(options)),
|
|
130
|
+
};
|
|
131
|
+
if (!isMutableModels(models))
|
|
132
|
+
return wrapped;
|
|
133
|
+
const mutable = {
|
|
134
|
+
...wrapped,
|
|
135
|
+
setProvider: (provider) => models.setProvider(provider),
|
|
136
|
+
deleteProvider: (id) => models.deleteProvider(id),
|
|
137
|
+
clearProviders: () => models.clearProviders(),
|
|
138
|
+
};
|
|
139
|
+
return mutable;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/utils/identity.ts"],"names":[],"mappings":"AACA,OAAO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CAAC,MAAM,CAAC,cAAc,EAAE;KAC7C,CAAC;IACF,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import type { Models, MutableModels } from \"../models.ts\";\nimport { PI_AI_VERSION } from \"./version.ts\";\n\n/**\n * The `User-Agent` sent to providers:\n * - `\"detailed\"`: `pi/<version> (<platform>; <runtime>/<runtime version>; <arch>)`, or `pi/<version> (browser)`\n * outside Node.js and Bun.\n * - `\"short\"`: `pi`.\n * - `{ custom }`: the given value.\n */\nexport type UserAgentMode = \"short\" | \"detailed\" | { custom: string };\n\n/** Who requests are attributed to. `getAttributionHeaders()` maps the fields to each provider's headers. */\nexport interface ClientAttribution {\n\t/** App name: OpenRouter app title, NVIDIA invoke origin (first letter upper-cased), OpenCode client. */\n\tname: string;\n\t/** App URL: OpenRouter `HTTP-Referer`, the app's identity in OpenRouter's rankings, grouped by origin. */\n\turl: string;\n\t/** App categories, e.g. `[\"cli-agent\"]`: OpenRouter `X-OpenRouter-Categories`, comma-separated. */\n\tcategories?: string[];\n}\n\n/** pi's attribution, used by pi-agent-core, pi-durable, and the coding agent. */\nexport const PI_ATTRIBUTION: ClientAttribution = { name: \"pi\", url: \"https://pi.dev\", categories: [\"cli-agent\"] };\n\n/**\n * How pi-ai identifies the calling app to providers. Every field is optional; absent fields use pi-ai's defaults:\n * a detailed `User-Agent` with pi-ai's version and no attribution headers. Plain JSON, so it can be persisted.\n */\nexport interface ClientIdentity {\n\t/** Default: `\"detailed\"`. */\n\tuserAgent?: UserAgentMode;\n\t/** Provider attribution headers. Absent or `null`: none; `null` also turns off attribution set by a merged identity. */\n\tattribution?: ClientAttribution | null;\n\t/** Version in the detailed `User-Agent`. Default: the pi-ai version. */\n\tversion?: string;\n}\n\n/** The provider and endpoint a request goes to. */\nexport interface ClientIdentityTarget {\n\treadonly provider: string;\n\treadonly baseUrl: string;\n}\n\nconst NVIDIA_NIM_HOST = \"integrate.api.nvidia.com\";\nconst OPENCODE_HOST = \"opencode.ai\";\n\n/** Merge identities field by field; later sources win and undefined fields are skipped. */\nexport function mergeClientIdentity(...sources: (ClientIdentity | undefined)[]): ClientIdentity | undefined {\n\tlet merged: ClientIdentity | undefined;\n\tfor (const source of sources) {\n\t\tif (!source) continue;\n\t\tmerged = { ...merged };\n\t\tif (source.userAgent !== undefined) merged.userAgent = source.userAgent;\n\t\tif (source.attribution !== undefined) merged.attribution = source.attribution;\n\t\tif (source.version !== undefined) merged.version = source.version;\n\t}\n\treturn merged;\n}\n\n/** The version in the detailed `User-Agent`. */\nexport function getClientVersion(identity?: ClientIdentity): string {\n\treturn identity?.version ?? PI_AI_VERSION;\n}\n\nfunction runtimeDescription(): string | undefined {\n\tif (typeof process === \"undefined\") return undefined;\n\tconst versions = process.versions;\n\tif (versions?.bun) return `bun/${versions.bun}`;\n\tif (versions?.node) return `node/${process.version}`;\n\treturn undefined;\n}\n\n/** The `User-Agent` value of an identity. */\nexport function formatUserAgent(identity?: ClientIdentity): string {\n\tconst mode = identity?.userAgent ?? \"detailed\";\n\tif (typeof mode === \"object\") return mode.custom;\n\tif (mode === \"short\") return \"pi\";\n\tconst product = `pi/${getClientVersion(identity)}`;\n\tconst runtime = runtimeDescription();\n\treturn runtime ? `${product} (${process.platform}; ${runtime}; ${process.arch})` : `${product} (browser)`;\n}\n\nfunction matchesHost(baseUrl: string, expectedHost: string): boolean {\n\ttry {\n\t\treturn new URL(baseUrl).hostname === expectedHost;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isOpenRouter(target: ClientIdentityTarget): boolean {\n\treturn target.provider === \"openrouter\" || target.baseUrl.includes(\"openrouter.ai\");\n}\n\nfunction isNvidiaNim(target: ClientIdentityTarget): boolean {\n\treturn target.provider === \"nvidia\" || matchesHost(target.baseUrl, NVIDIA_NIM_HOST);\n}\n\nfunction isOpenCode(target: ClientIdentityTarget): boolean {\n\treturn (\n\t\ttarget.provider === \"opencode\" || target.provider === \"opencode-go\" || matchesHost(target.baseUrl, OPENCODE_HOST)\n\t);\n}\n\n/** Provider attribution headers of an identity for a request target. Empty when attribution is off. */\nexport function getAttributionHeaders(target: ClientIdentityTarget, identity?: ClientIdentity): Record<string, string> {\n\tconst attribution = identity?.attribution;\n\tif (!attribution) return {};\n\tconst { name, url, categories } = attribution;\n\tif (isOpenRouter(target)) {\n\t\treturn {\n\t\t\t\"HTTP-Referer\": url,\n\t\t\t\"X-OpenRouter-Title\": name,\n\t\t\t...(categories === undefined || categories.length === 0\n\t\t\t\t? {}\n\t\t\t\t: { \"X-OpenRouter-Categories\": categories.join(\",\") }),\n\t\t};\n\t}\n\t// NVIDIA expects a capitalized origin, such as `Pi`.\n\tif (isNvidiaNim(target)) return { \"X-BILLING-INVOKE-ORIGIN\": name.charAt(0).toUpperCase() + name.slice(1) };\n\tif (isOpenCode(target)) return { \"x-opencode-client\": name };\n\treturn {};\n}\n\n/**\n * OpenCode's per-conversation routing header for requests to OpenCode, including custom providers pointing at it.\n * Undefined without a session or for other targets.\n */\nexport function getOpenCodeSessionHeaders(\n\ttarget: ClientIdentityTarget,\n\tsessionId: string | undefined,\n): Record<string, string> | undefined {\n\treturn sessionId && isOpenCode(target) ? { \"x-opencode-session\": sessionId } : undefined;\n}\n\n/**\n * Default headers an identity adds to a request: `User-Agent` and provider attribution. APIs apply them below model,\n * provider, and request headers, so configured headers override them and `null` request headers remove them.\n */\nexport function getIdentityHeaders(target: ClientIdentityTarget, identity?: ClientIdentity): Record<string, string> {\n\treturn { \"User-Agent\": formatUserAgent(identity), ...getAttributionHeaders(target, identity) };\n}\n\nfunction isMutableModels(models: Models): models is MutableModels {\n\treturn \"setProvider\" in models && \"deleteProvider\" in models && \"clearProviders\" in models;\n}\n\n/**\n * `models` with `identity` as the default identity of its requests: a request's `identity` overrides it field by\n * field, and it overrides the identity `models` was created with. Everything else is delegated unchanged; a\n * `MutableModels` stays mutable.\n */\nexport function withClientIdentity(models: MutableModels, identity: ClientIdentity): MutableModels;\nexport function withClientIdentity(models: Models, identity: ClientIdentity): Models;\nexport function withClientIdentity(models: Models, identity: ClientIdentity): Models {\n\tconst withIdentity = <T extends { identity?: ClientIdentity }>(options: T | undefined): T =>\n\t\t({ ...options, identity: mergeClientIdentity(identity, options?.identity) }) as T;\n\tconst wrapped: Models = {\n\t\tgetProviders: () => models.getProviders(),\n\t\tgetProvider: (id) => models.getProvider(id),\n\t\tgetModels: (provider) => models.getModels(provider),\n\t\tgetModel: (provider, id) => models.getModel(provider, id),\n\t\tgetModelsOfType: (type, provider) => models.getModelsOfType(type, provider),\n\t\tgetModelOfType: (type, provider, id) => models.getModelOfType(type, provider, id),\n\t\tgetAllModels: (provider) => models.getAllModels(provider),\n\t\trefresh: (options) => models.refresh(options),\n\t\tcheckAuth: (providerId, options) => models.checkAuth(providerId, options),\n\t\tgetAvailable: (providerId, options) => models.getAvailable(providerId, options),\n\t\tgetAvailableOfType: (type, providerId, options) => models.getAvailableOfType(type, providerId, options),\n\t\tgetAllAvailable: (providerId, options) => models.getAllAvailable(providerId, options),\n\t\tgetAuth: models.getAuth.bind(models),\n\t\tlogin: (providerId, type, interaction, options) => models.login(providerId, type, interaction, options),\n\t\tlogout: (providerId, options) => models.logout(providerId, options),\n\t\tstream: (model, context, options) => models.stream(model, context, withIdentity(options)),\n\t\tcomplete: (model, context, options) => models.complete(model, context, withIdentity(options)),\n\t\tstreamSimple: (model, context, options) => models.streamSimple(model, context, withIdentity(options)),\n\t\tcompleteSimple: (model, context, options) => models.completeSimple(model, context, withIdentity(options)),\n\t\tstreamDeferred: (model, handle, options) => models.streamDeferred(model, handle, withIdentity(options)),\n\t\tfetchDeferred: (model, handle, options) => models.fetchDeferred(model, handle, withIdentity(options)),\n\t\tcancelDeferred: (model, handle, options) => models.cancelDeferred(model, handle, withIdentity(options)),\n\t\tgenerateImages: (model, context, options) => models.generateImages(model, context, withIdentity(options)),\n\t\tclassify: (model, context, options) => models.classify(model, context, withIdentity(options)),\n\t};\n\tif (!isMutableModels(models)) return wrapped;\n\tconst mutable: MutableModels = {\n\t\t...wrapped,\n\t\tsetProvider: (provider) => models.setProvider(provider),\n\t\tdeleteProvider: (id) => models.deleteProvider(id),\n\t\tclearProviders: () => models.clearProviders(),\n\t};\n\treturn mutable;\n}\n"]}
|