@ap3x/ai 0.1.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.
Files changed (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/api-registry.d.ts +23 -0
  4. package/dist/api-registry.d.ts.map +1 -0
  5. package/dist/auth/config-dir.d.ts +25 -0
  6. package/dist/auth/config-dir.d.ts.map +1 -0
  7. package/dist/auth/github-copilot.d.ts +74 -0
  8. package/dist/auth/github-copilot.d.ts.map +1 -0
  9. package/dist/auth/index.d.ts +10 -0
  10. package/dist/auth/index.d.ts.map +1 -0
  11. package/dist/auth/jwt.d.ts +32 -0
  12. package/dist/auth/jwt.d.ts.map +1 -0
  13. package/dist/auth/oauth-flow.d.ts +84 -0
  14. package/dist/auth/oauth-flow.d.ts.map +1 -0
  15. package/dist/auth/pkce.d.ts +20 -0
  16. package/dist/auth/pkce.d.ts.map +1 -0
  17. package/dist/auth/providers.d.ts +33 -0
  18. package/dist/auth/providers.d.ts.map +1 -0
  19. package/dist/auth/storage.d.ts +55 -0
  20. package/dist/auth/storage.d.ts.map +1 -0
  21. package/dist/auth/types.d.ts +88 -0
  22. package/dist/auth/types.d.ts.map +1 -0
  23. package/dist/auth/unified.d.ts +29 -0
  24. package/dist/auth/unified.d.ts.map +1 -0
  25. package/dist/env-api-keys.d.ts +16 -0
  26. package/dist/env-api-keys.d.ts.map +1 -0
  27. package/dist/event-stream.d.ts +33 -0
  28. package/dist/event-stream.d.ts.map +1 -0
  29. package/dist/generate-object.d.ts +63 -0
  30. package/dist/generate-object.d.ts.map +1 -0
  31. package/dist/images-models.d.ts +114 -0
  32. package/dist/images-models.d.ts.map +1 -0
  33. package/dist/images-registry.d.ts +23 -0
  34. package/dist/images-registry.d.ts.map +1 -0
  35. package/dist/images-schema.d.ts +21 -0
  36. package/dist/images-schema.d.ts.map +1 -0
  37. package/dist/images.d.ts +13 -0
  38. package/dist/images.d.ts.map +1 -0
  39. package/dist/index.d.ts +59 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +15656 -0
  42. package/dist/models/amazon-bedrock.models.generated.d.ts +1858 -0
  43. package/dist/models/amazon-bedrock.models.generated.d.ts.map +1 -0
  44. package/dist/models/ant-ling.models.generated.d.ts +86 -0
  45. package/dist/models/ant-ling.models.generated.d.ts.map +1 -0
  46. package/dist/models/anthropic.models.generated.d.ts +450 -0
  47. package/dist/models/anthropic.models.generated.d.ts.map +1 -0
  48. package/dist/models/azure-openai-responses.models.generated.d.ts +804 -0
  49. package/dist/models/azure-openai-responses.models.generated.d.ts.map +1 -0
  50. package/dist/models/cerebras.models.generated.d.ts +66 -0
  51. package/dist/models/cerebras.models.generated.d.ts.map +1 -0
  52. package/dist/models/cloudflare-ai-gateway.models.generated.d.ts +786 -0
  53. package/dist/models/cloudflare-ai-gateway.models.generated.d.ts.map +1 -0
  54. package/dist/models/cloudflare-workers-ai.models.generated.d.ts +302 -0
  55. package/dist/models/cloudflare-workers-ai.models.generated.d.ts.map +1 -0
  56. package/dist/models/deepseek.models.generated.d.ts +63 -0
  57. package/dist/models/deepseek.models.generated.d.ts.map +1 -0
  58. package/dist/models/fireworks.models.generated.d.ts +381 -0
  59. package/dist/models/fireworks.models.generated.d.ts.map +1 -0
  60. package/dist/models/github-copilot.models.generated.d.ts +698 -0
  61. package/dist/models/github-copilot.models.generated.d.ts.map +1 -0
  62. package/dist/models/google-vertex.models.generated.d.ts +202 -0
  63. package/dist/models/google-vertex.models.generated.d.ts.map +1 -0
  64. package/dist/models/google.models.generated.d.ts +351 -0
  65. package/dist/models/google.models.generated.d.ts.map +1 -0
  66. package/dist/models/groq.models.generated.d.ts +128 -0
  67. package/dist/models/groq.models.generated.d.ts.map +1 -0
  68. package/dist/models/huggingface.models.generated.d.ts +63 -0
  69. package/dist/models/huggingface.models.generated.d.ts.map +1 -0
  70. package/dist/models/kimi-coding.models.generated.d.ts +63 -0
  71. package/dist/models/kimi-coding.models.generated.d.ts.map +1 -0
  72. package/dist/models/minimax-cn.models.generated.d.ts +54 -0
  73. package/dist/models/minimax-cn.models.generated.d.ts.map +1 -0
  74. package/dist/models/minimax.models.generated.d.ts +54 -0
  75. package/dist/models/minimax.models.generated.d.ts.map +1 -0
  76. package/dist/models/mistral.models.generated.d.ts +513 -0
  77. package/dist/models/mistral.models.generated.d.ts.map +1 -0
  78. package/dist/models/moonshotai-cn.models.generated.d.ts +234 -0
  79. package/dist/models/moonshotai-cn.models.generated.d.ts.map +1 -0
  80. package/dist/models/moonshotai.models.generated.d.ts +234 -0
  81. package/dist/models/moonshotai.models.generated.d.ts.map +1 -0
  82. package/dist/models/nvidia.models.generated.d.ts +563 -0
  83. package/dist/models/nvidia.models.generated.d.ts.map +1 -0
  84. package/dist/models/openai.models.generated.d.ts +827 -0
  85. package/dist/models/openai.models.generated.d.ts.map +1 -0
  86. package/dist/models/opencode.models.generated.d.ts +69 -0
  87. package/dist/models/opencode.models.generated.d.ts.map +1 -0
  88. package/dist/models/openrouter.models.generated.d.ts +87 -0
  89. package/dist/models/openrouter.models.generated.d.ts.map +1 -0
  90. package/dist/models/together.models.generated.d.ts +598 -0
  91. package/dist/models/together.models.generated.d.ts.map +1 -0
  92. package/dist/models/vercel-ai-gateway.models.generated.d.ts +63 -0
  93. package/dist/models/vercel-ai-gateway.models.generated.d.ts.map +1 -0
  94. package/dist/models/xai.models.generated.d.ts +157 -0
  95. package/dist/models/xai.models.generated.d.ts.map +1 -0
  96. package/dist/models/xiaomi-token-plan-ams.models.generated.d.ts +108 -0
  97. package/dist/models/xiaomi-token-plan-ams.models.generated.d.ts.map +1 -0
  98. package/dist/models/xiaomi-token-plan-cn.models.generated.d.ts +108 -0
  99. package/dist/models/xiaomi-token-plan-cn.models.generated.d.ts.map +1 -0
  100. package/dist/models/xiaomi-token-plan-sgp.models.generated.d.ts +108 -0
  101. package/dist/models/xiaomi-token-plan-sgp.models.generated.d.ts.map +1 -0
  102. package/dist/models/xiaomi.models.generated.d.ts +129 -0
  103. package/dist/models/xiaomi.models.generated.d.ts.map +1 -0
  104. package/dist/models/zai-coding-cn.models.generated.d.ts +153 -0
  105. package/dist/models/zai-coding-cn.models.generated.d.ts.map +1 -0
  106. package/dist/models/zai.models.generated.d.ts +153 -0
  107. package/dist/models/zai.models.generated.d.ts.map +1 -0
  108. package/dist/models.d.ts +10734 -0
  109. package/dist/models.d.ts.map +1 -0
  110. package/dist/providers/amazon-bedrock.d.ts +173 -0
  111. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  112. package/dist/providers/anthropic.d.ts +25 -0
  113. package/dist/providers/anthropic.d.ts.map +1 -0
  114. package/dist/providers/azure-openai-responses.d.ts +17 -0
  115. package/dist/providers/azure-openai-responses.d.ts.map +1 -0
  116. package/dist/providers/cloudflare.d.ts +13 -0
  117. package/dist/providers/cloudflare.d.ts.map +1 -0
  118. package/dist/providers/faux-images.d.ts +41 -0
  119. package/dist/providers/faux-images.d.ts.map +1 -0
  120. package/dist/providers/faux.d.ts +61 -0
  121. package/dist/providers/faux.d.ts.map +1 -0
  122. package/dist/providers/github-copilot-headers.d.ts +14 -0
  123. package/dist/providers/github-copilot-headers.d.ts.map +1 -0
  124. package/dist/providers/google-images.d.ts +14 -0
  125. package/dist/providers/google-images.d.ts.map +1 -0
  126. package/dist/providers/google-shared.d.ts +53 -0
  127. package/dist/providers/google-shared.d.ts.map +1 -0
  128. package/dist/providers/google-vertex.d.ts +48 -0
  129. package/dist/providers/google-vertex.d.ts.map +1 -0
  130. package/dist/providers/google.d.ts +47 -0
  131. package/dist/providers/google.d.ts.map +1 -0
  132. package/dist/providers/mistral.d.ts +67 -0
  133. package/dist/providers/mistral.d.ts.map +1 -0
  134. package/dist/providers/openai-codex-responses.d.ts +17 -0
  135. package/dist/providers/openai-codex-responses.d.ts.map +1 -0
  136. package/dist/providers/openai-completions.d.ts +69 -0
  137. package/dist/providers/openai-completions.d.ts.map +1 -0
  138. package/dist/providers/openai-images.d.ts +17 -0
  139. package/dist/providers/openai-images.d.ts.map +1 -0
  140. package/dist/providers/openai-prompt-cache.d.ts +8 -0
  141. package/dist/providers/openai-prompt-cache.d.ts.map +1 -0
  142. package/dist/providers/openai-responses-shared.d.ts +128 -0
  143. package/dist/providers/openai-responses-shared.d.ts.map +1 -0
  144. package/dist/providers/openai-responses.d.ts +63 -0
  145. package/dist/providers/openai-responses.d.ts.map +1 -0
  146. package/dist/providers/provider-runtime.d.ts +34 -0
  147. package/dist/providers/provider-runtime.d.ts.map +1 -0
  148. package/dist/providers/register-builtins.d.ts +11 -0
  149. package/dist/providers/register-builtins.d.ts.map +1 -0
  150. package/dist/providers/register-images.d.ts +8 -0
  151. package/dist/providers/register-images.d.ts.map +1 -0
  152. package/dist/providers/request-dispatch.d.ts +52 -0
  153. package/dist/providers/request-dispatch.d.ts.map +1 -0
  154. package/dist/providers/simple-options.d.ts +42 -0
  155. package/dist/providers/simple-options.d.ts.map +1 -0
  156. package/dist/providers/tool-call-id.d.ts +46 -0
  157. package/dist/providers/tool-call-id.d.ts.map +1 -0
  158. package/dist/providers/transform-messages.d.ts +22 -0
  159. package/dist/providers/transform-messages.d.ts.map +1 -0
  160. package/dist/stream.d.ts +18 -0
  161. package/dist/stream.d.ts.map +1 -0
  162. package/dist/types.d.ts +448 -0
  163. package/dist/types.d.ts.map +1 -0
  164. package/dist/utils/abort-signals.d.ts +16 -0
  165. package/dist/utils/abort-signals.d.ts.map +1 -0
  166. package/dist/utils/estimate.d.ts +35 -0
  167. package/dist/utils/estimate.d.ts.map +1 -0
  168. package/dist/utils/hash.d.ts +7 -0
  169. package/dist/utils/hash.d.ts.map +1 -0
  170. package/dist/utils/json-parse.d.ts +16 -0
  171. package/dist/utils/json-parse.d.ts.map +1 -0
  172. package/dist/utils/node-http-proxy.d.ts +34 -0
  173. package/dist/utils/node-http-proxy.d.ts.map +1 -0
  174. package/dist/utils/overflow.d.ts +25 -0
  175. package/dist/utils/overflow.d.ts.map +1 -0
  176. package/dist/utils/sanitize-unicode.d.ts +9 -0
  177. package/dist/utils/sanitize-unicode.d.ts.map +1 -0
  178. package/dist/utils/sse.d.ts +21 -0
  179. package/dist/utils/sse.d.ts.map +1 -0
  180. package/dist/validation.d.ts +31 -0
  181. package/dist/validation.d.ts.map +1 -0
  182. package/package.json +35 -0
@@ -0,0 +1,67 @@
1
+ import type { Context, Message, Model, SimpleStreamOptions, StreamFunction, StreamOptions } from "../types";
2
+ type MistralReasoningEffort = "none" | "high";
3
+ export interface MistralOptions extends StreamOptions {
4
+ toolChoice?: "auto" | "none" | "any" | "required" | {
5
+ type: "function";
6
+ function: {
7
+ name: string;
8
+ };
9
+ };
10
+ promptMode?: "reasoning";
11
+ reasoningEffort?: MistralReasoningEffort;
12
+ }
13
+ type MistralContentPart = {
14
+ type: "text";
15
+ text: string;
16
+ } | {
17
+ type: "image_url";
18
+ image_url: string;
19
+ } | {
20
+ type: "thinking";
21
+ thinking: {
22
+ type: "text";
23
+ text: string;
24
+ }[];
25
+ };
26
+ interface MistralMessage {
27
+ role: "system" | "user" | "assistant" | "tool";
28
+ content?: string | MistralContentPart[];
29
+ tool_calls?: {
30
+ id: string;
31
+ type: "function";
32
+ function: {
33
+ name: string;
34
+ arguments: string;
35
+ };
36
+ }[];
37
+ tool_call_id?: string;
38
+ name?: string;
39
+ }
40
+ interface MistralRequestBody {
41
+ model: string;
42
+ stream: true;
43
+ messages: MistralMessage[];
44
+ temperature?: number;
45
+ max_tokens?: number;
46
+ tools?: {
47
+ type: "function";
48
+ function: {
49
+ name: string;
50
+ description: string;
51
+ parameters: unknown;
52
+ strict: boolean;
53
+ };
54
+ }[];
55
+ tool_choice?: unknown;
56
+ prompt_mode?: "reasoning";
57
+ reasoning_effort?: MistralReasoningEffort;
58
+ }
59
+ export declare function buildParams(model: Model<"mistral-conversations">, context: Context, messages: Message[], options: MistralOptions | undefined): MistralRequestBody;
60
+ /**
61
+ * Mistral adapter via its OpenAI-compatible streaming chat endpoint (native
62
+ * fetch + SSE). Tool-call ids are normalized to Mistral's exactly-9-char form.
63
+ */
64
+ export declare const streamMistral: StreamFunction<"mistral-conversations", MistralOptions>;
65
+ export declare const streamSimpleMistral: StreamFunction<"mistral-conversations", SimpleStreamOptions>;
66
+ export {};
67
+ //# sourceMappingURL=mistral.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mistral.d.ts","sourceRoot":"","sources":["../../src/providers/mistral.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EACP,OAAO,EACP,KAAK,EACL,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAId,MAAM,UAAU,CAAC;AAUlB,KAAK,sBAAsB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,UAAU,CAAC,EACP,MAAM,GACN,MAAM,GACN,KAAK,GACL,UAAU,GACV;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACrD,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,eAAe,CAAC,EAAE,sBAAsB,CAAC;CAC1C;AAED,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC;AAErE,UAAU,cAAc;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACxC,UAAU,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;IAC/F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,UAAU,CAAC;QACjB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,CAAC;KACvF,EAAE,CAAC;IACJ,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAuHD,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,EACrC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,kBAAkB,CA6BpB;AAsCD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,uBAAuB,EAAE,cAAc,CA2M9E,CAAC;AAqBL,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,uBAAuB,EAAE,mBAAmB,CAiB5F,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { SimpleStreamOptions, StreamFunction, StreamOptions } from "../types";
2
+ export interface OpenAICodexResponsesOptions extends StreamOptions {
3
+ reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
4
+ reasoningSummary?: "auto" | "concise" | "detailed" | "off" | "on" | null;
5
+ serviceTier?: string | null;
6
+ textVerbosity?: "low" | "medium" | "high";
7
+ }
8
+ /**
9
+ * OpenAI Codex Responses adapter (ChatGPT backend). Implements the SSE +
10
+ * bearer-token path: hand-rolled request body (`store:false`, `instructions`
11
+ * carries the system prompt, `include: ["reasoning.encrypted_content"]`),
12
+ * reusing the shared Responses stream processor. AP3X originator/User-Agent.
13
+ * OAuth + WebSocket transport are deferred.
14
+ */
15
+ export declare const streamOpenAICodexResponses: StreamFunction<"openai-codex-responses", OpenAICodexResponsesOptions>;
16
+ export declare const streamSimpleOpenAICodexResponses: StreamFunction<"openai-codex-responses", SimpleStreamOptions>;
17
+ //# sourceMappingURL=openai-codex-responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-codex-responses.d.ts","sourceRoot":"","sources":["../../src/providers/openai-codex-responses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAYnG,MAAM,WAAW,2BAA4B,SAAQ,aAAa;IAChE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3E,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IACzE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC3C;AA8ID;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,EAAE,cAAc,CACrD,wBAAwB,EACxB,2BAA2B,CAyCzB,CAAC;AAEL,eAAO,MAAM,gCAAgC,EAAE,cAAc,CAC3D,wBAAwB,EACxB,mBAAmB,CASpB,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { AssistantMessage, CacheRetention, Context, Model, OpenAICompletionsCompat, SimpleStreamOptions, StreamFunction, StreamOptions } from "../types";
2
+ export interface OpenAICompletionsOptions extends StreamOptions {
3
+ toolChoice?: "auto" | "none" | "required" | {
4
+ type: "function";
5
+ function: {
6
+ name: string;
7
+ };
8
+ };
9
+ reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
10
+ }
11
+ type ResolvedCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat"> & {
12
+ cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
13
+ };
14
+ interface OpenAICacheControl {
15
+ type: "ephemeral";
16
+ ttl?: string;
17
+ }
18
+ interface OpenAIChatMessage {
19
+ role: "system" | "developer" | "user" | "assistant" | "tool";
20
+ content?: string | OpenAIContentPart[] | null;
21
+ tool_calls?: {
22
+ id: string;
23
+ type: "function";
24
+ function: {
25
+ name: string;
26
+ arguments: string;
27
+ };
28
+ }[];
29
+ tool_call_id?: string;
30
+ name?: string;
31
+ reasoning_content?: string;
32
+ reasoning_details?: OpenAIReasoningDetail[];
33
+ }
34
+ /**
35
+ * OpenRouter streams reasoning as structured `reasoning_details` entries. The
36
+ * encrypted variant carries an opaque `data` blob that must be echoed back
37
+ * verbatim on the next request, or reasoning + tool-call continuity breaks. We
38
+ * carry it through the unified model as a redacted thinking block whose
39
+ * `thinkingSignature` is the JSON-encoded encrypted detail(s).
40
+ */
41
+ interface OpenAIReasoningDetail {
42
+ type?: string;
43
+ id?: string;
44
+ format?: string;
45
+ index?: number;
46
+ data?: string;
47
+ }
48
+ type OpenAIContentPart = {
49
+ type: "text";
50
+ text: string;
51
+ cache_control?: OpenAICacheControl;
52
+ } | {
53
+ type: "image_url";
54
+ image_url: {
55
+ url: string;
56
+ };
57
+ };
58
+ /** Exported for tests/handoff: build the chat message array for a context. */
59
+ export declare function convertMessages(model: Model<"openai-completions">, context: Context, compat: ResolvedCompat): OpenAIChatMessage[];
60
+ /** Exported for tests: build the streaming request body for a context. */
61
+ export declare function buildParams(model: Model<"openai-completions">, context: Context, options: OpenAICompletionsOptions | undefined, compat?: ResolvedCompat, cacheRetention?: CacheRetention): Record<string, unknown>;
62
+ /**
63
+ * OpenAI Chat Completions adapter (and OpenAI-compatible providers). Native
64
+ * fetch + SSE; correlates streamed tool-call deltas by both stream index and id.
65
+ */
66
+ export declare const streamOpenAICompletions: StreamFunction<"openai-completions", OpenAICompletionsOptions>;
67
+ export declare const streamSimpleOpenAICompletions: StreamFunction<"openai-completions", SimpleStreamOptions>;
68
+ export type { AssistantMessage };
69
+ //# sourceMappingURL=openai-completions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/providers/openai-completions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,cAAc,EACd,OAAO,EAEP,KAAK,EACL,uBAAuB,EACvB,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMd,MAAM,UAAU,CAAC;AAalB,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC7F,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CACnE;AAED,KAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,oBAAoB,CAAC,GAAG;IACpF,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;CACpE,CAAC;AAEF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAiJD,UAAU,iBAAiB;IACzB,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AChB,OAAO,EAAE,wBAAwB,GAAG,SAAS,EAC7C,MAAM,GAAE,cAAiC,EACzC,cAAc,GAAE,cAA+D,GAC9E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8CzB;AA6GD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,oBAAoB,EACpB,wBAAwB,CAsPtB,CAAC;AAEL,eAAO,MAAM,6BAA6B,EAAE,cAAc,CACxD,oBAAoB,EACpB,mBAAmB,CAOpB,CAAC;AAmBF,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { ImagesFunction, ImagesOptions } from "../types";
2
+ export interface OpenAIImagesOptions extends ImagesOptions {
3
+ /** Number of images to generate (1–10). */
4
+ n?: number;
5
+ /** Output dimensions, e.g. "1024x1024". */
6
+ size?: string;
7
+ /** Provider quality hint. */
8
+ quality?: string;
9
+ /** Provider style hint. */
10
+ style?: string;
11
+ }
12
+ /**
13
+ * OpenAI Images adapter (`/v1/images/generations`). Hand-rolled fetch returning
14
+ * base64 image content. API-key (bearer) auth; analytics off; no telemetry.
15
+ */
16
+ export declare const generateOpenAIImages: ImagesFunction<"openai-images", OpenAIImagesOptions>;
17
+ //# sourceMappingURL=openai-images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-images.d.ts","sourceRoot":"","sources":["../../src/providers/openai-images.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,cAAc,EAEd,aAAa,EAEd,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,2CAA2C;IAC3C,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAOD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CA4ErF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** OpenAI clamps the prompt-cache key by code points, not UTF-16 units. */
2
+ export declare const OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
3
+ /**
4
+ * Clamp a prompt-cache key to {@link OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH} code
5
+ * points (not UTF-16 units, so astral-plane characters are not split).
6
+ */
7
+ export declare function clampOpenAIPromptCacheKey(key: string | undefined): string | undefined;
8
+ //# sourceMappingURL=openai-prompt-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-prompt-cache.d.ts","sourceRoot":"","sources":["../../src/providers/openai-prompt-cache.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,kCAAkC,KAAK,CAAC;AAErD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKrF"}
@@ -0,0 +1,128 @@
1
+ import type { Api, AssistantMessage, AssistantMessageEventStream, Context, Model, StopReason, TextSignatureV1, Tool, Usage } from "../types";
2
+ import { buildForeignResponsesItemId } from "./tool-call-id";
3
+ declare function encodeTextSignatureV1(id: string, phase?: TextSignatureV1["phase"]): string;
4
+ export interface OpenAIResponsesStreamOptions {
5
+ serviceTier?: string | null;
6
+ resolveServiceTier?: (responseServiceTier: string | null | undefined, requestServiceTier: string | null | undefined) => string | null | undefined;
7
+ applyServiceTierPricing?: (usage: Usage, serviceTier: string | null | undefined) => void;
8
+ }
9
+ export interface ConvertResponsesMessagesOptions {
10
+ includeSystemPrompt?: boolean;
11
+ }
12
+ export interface ConvertResponsesToolsOptions {
13
+ strict?: boolean | null;
14
+ }
15
+ /** Items in the Responses `input` array. */
16
+ export type ResponseInputItem = {
17
+ role: "developer" | "system" | "user" | "assistant";
18
+ content: string | ResponseInputContent[];
19
+ } | {
20
+ type: "message";
21
+ role: "assistant";
22
+ content: {
23
+ type: "output_text";
24
+ text: string;
25
+ annotations: [];
26
+ }[];
27
+ status: "completed";
28
+ id: string;
29
+ phase?: "commentary" | "final_answer";
30
+ } | {
31
+ type: "reasoning";
32
+ [key: string]: unknown;
33
+ } | {
34
+ type: "function_call";
35
+ id?: string;
36
+ call_id: string;
37
+ name: string;
38
+ arguments: string;
39
+ } | {
40
+ type: "function_call_output";
41
+ call_id: string;
42
+ output: string | ResponseInputContent[];
43
+ };
44
+ export type ResponseInputContent = {
45
+ type: "input_text";
46
+ text: string;
47
+ } | {
48
+ type: "input_image";
49
+ detail: "auto";
50
+ image_url: string;
51
+ };
52
+ export interface ResponsesTool {
53
+ type: "function";
54
+ name: string;
55
+ description: string;
56
+ parameters: unknown;
57
+ strict: boolean | null;
58
+ }
59
+ /**
60
+ * Convert a unified context into the Responses `input` array. `allowedToolCallProviders`
61
+ * gates the `call_id|item_id` id-encoding (only providers that round-trip both parts).
62
+ */
63
+ export declare function convertResponsesMessages<TApi extends Api>(model: Model<TApi>, context: Context, allowedToolCallProviders: ReadonlySet<string>, options?: ConvertResponsesMessagesOptions): ResponseInputItem[];
64
+ export declare function convertResponsesTools(tools: Tool[], options?: ConvertResponsesToolsOptions): ResponsesTool[];
65
+ declare function mapStopReason(status: string | undefined): StopReason;
66
+ export interface ResponseStreamEvent {
67
+ type: string;
68
+ response?: {
69
+ id?: string;
70
+ status?: string;
71
+ service_tier?: string | null;
72
+ error?: {
73
+ code?: string;
74
+ type?: string;
75
+ message?: string;
76
+ } | null;
77
+ incomplete_details?: {
78
+ reason?: string;
79
+ } | null;
80
+ usage?: {
81
+ input_tokens?: number;
82
+ output_tokens?: number;
83
+ total_tokens?: number;
84
+ input_tokens_details?: {
85
+ cached_tokens?: number;
86
+ };
87
+ output_tokens_details?: {
88
+ reasoning_tokens?: number;
89
+ };
90
+ };
91
+ };
92
+ item?: {
93
+ type?: string;
94
+ id?: string;
95
+ call_id?: string;
96
+ name?: string;
97
+ arguments?: string;
98
+ summary?: {
99
+ text: string;
100
+ }[];
101
+ content?: {
102
+ type: string;
103
+ text?: string;
104
+ refusal?: string;
105
+ }[];
106
+ phase?: "commentary" | "final_answer" | null;
107
+ };
108
+ part?: {
109
+ type?: string;
110
+ text?: string;
111
+ };
112
+ delta?: string;
113
+ arguments?: string;
114
+ code?: string;
115
+ message?: string;
116
+ error?: {
117
+ code?: string;
118
+ type?: string;
119
+ message?: string;
120
+ } | null;
121
+ }
122
+ /**
123
+ * Drive the Responses stream into the unified event protocol. Used directly by
124
+ * the Responses adapter and reused (by feeding it events) by Azure and Codex.
125
+ */
126
+ export declare function processResponsesStream<TApi extends Api>(events: AsyncIterable<ResponseStreamEvent>, output: AssistantMessage, stream: AssistantMessageEventStream, model: Model<TApi>, options?: OpenAIResponsesStreamOptions): Promise<void>;
127
+ export { buildForeignResponsesItemId, encodeTextSignatureV1, mapStopReason };
128
+ //# sourceMappingURL=openai-responses-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-responses-shared.d.ts","sourceRoot":"","sources":["../../src/providers/openai-responses-shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,GAAG,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,OAAO,EAEP,KAAK,EACL,UAAU,EAEV,eAAe,EAEf,IAAI,EAEJ,KAAK,EACN,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,2BAA2B,EAAwB,MAAM,gBAAgB,CAAC;AAMnF,iBAAS,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,MAAM,CAInF;AAsBD,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,CAAC,EAAE,CACnB,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9C,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG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AAsB,CAAC,IAAI,SAAS,GAAG,EAC3D,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAC1C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,2BAA2B,EACnC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,IAAI,CAAC,CA6Mf;AAED,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { Api, AssistantMessageEventStream, CacheRetention, Context, Model, SimpleStreamOptions, StreamFunction, StreamOptions, Usage } from "../types";
2
+ import { type OpenAIResponsesStreamOptions, type ResponseInputItem, type ResponseStreamEvent, type ResponsesTool, processResponsesStream } from "./openai-responses-shared";
3
+ export interface OpenAIResponsesOptions extends StreamOptions {
4
+ reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
5
+ reasoningSummary?: "auto" | "detailed" | "concise" | null;
6
+ serviceTier?: string | null;
7
+ }
8
+ /** Providers whose Responses ids round-trip the full `call_id|item_id` form. */
9
+ export declare const RESPONSES_TOOL_CALL_ID_PROVIDERS: ReadonlySet<string>;
10
+ export interface ResponsesRequestBody {
11
+ model: string;
12
+ input: ResponseInputItem[];
13
+ stream: true;
14
+ store?: boolean;
15
+ include?: string[];
16
+ max_output_tokens?: number;
17
+ temperature?: number;
18
+ tools?: ResponsesTool[];
19
+ tool_choice?: string;
20
+ parallel_tool_calls?: boolean;
21
+ reasoning?: {
22
+ effort?: string;
23
+ summary?: string | null;
24
+ };
25
+ text?: {
26
+ verbosity?: string;
27
+ };
28
+ service_tier?: string | null;
29
+ prompt_cache_key?: string;
30
+ prompt_cache_retention?: string;
31
+ }
32
+ /**
33
+ * Reasoning models reject a tiny output budget (they need room for the reasoning
34
+ * pass before any visible tokens), so clamp `max_output_tokens` up to this floor.
35
+ */
36
+ export declare const MIN_OUTPUT_TOKENS = 16;
37
+ /** Exported for tests: build the Responses request body for a context. */
38
+ export declare function buildParams(model: Model<"openai-responses">, context: Context, options: OpenAIResponsesOptions | undefined, cacheRetention?: CacheRetention): ResponsesRequestBody;
39
+ /**
40
+ * Service-tier cost multiplier for the Responses API. `flex` is half price,
41
+ * `priority` is a premium; standard/unset is a 1× no-op so cost stays
42
+ * byte-identical when no tier is negotiated.
43
+ */
44
+ export declare function getServiceTierCostMultiplier(model: Pick<Model<"openai-responses">, "id">, serviceTier: string | null | undefined): number;
45
+ /**
46
+ * Scale a computed {@link Usage} cost by the negotiated service tier, mutating
47
+ * `usage.cost` in place. A standard/unset tier (multiplier 1) is a no-op, so
48
+ * the cost is byte-identical to plain {@link calculateCost} output.
49
+ */
50
+ export declare function applyServiceTierPricing(usage: Usage, serviceTier: string | null | undefined, model: Pick<Model<"openai-responses">, "id">): void;
51
+ /**
52
+ * Parse a Responses SSE byte stream into {@link ResponseStreamEvent}s. The event
53
+ * type lives in the JSON payload's `type` field (the SSE `event:` line mirrors it).
54
+ */
55
+ export declare function iterateResponsesEvents(body: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<ResponseStreamEvent>;
56
+ /**
57
+ * Generic Responses-API stream driver shared by the OpenAI, Azure and Codex
58
+ * adapters: issue the HTTP request, decode SSE, and run the shared processor.
59
+ */
60
+ export declare function streamResponsesRequest<TApi extends Api>(model: Model<TApi>, url: string, headers: Record<string, string>, body: unknown, options: StreamOptions | undefined, output: Parameters<typeof processResponsesStream>[1], stream: AssistantMessageEventStream, formatError?: (status: number, detail: string) => string | undefined, streamProcessorOptions?: OpenAIResponsesStreamOptions): Promise<void>;
61
+ export declare const streamOpenAIResponses: StreamFunction<"openai-responses", OpenAIResponsesOptions>;
62
+ export declare const streamSimpleOpenAIResponses: StreamFunction<"openai-responses", SimpleStreamOptions>;
63
+ //# sourceMappingURL=openai-responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-responses.d.ts","sourceRoot":"","sources":["../../src/providers/openai-responses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B,EACnC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EACpE,sBAAsB,CAAC,EAAE,4BAA4B,GACpD,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,kBAAkB,EAAE,sBAAsB,CAiBzF,CAAC;AAEL,eAAO,MAAM,2BAA2B,EAAE,cAAc,CACtD,kBAAkB,EAClB,mBAAmB,CAMpB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { AssistantMessageEventStream } from "../event-stream";
2
+ import type { Api, AssistantMessage, ImagesContext, Model, ProviderResponse, StreamOptions } from "../types";
3
+ /**
4
+ * Push the terminal `done` event and end the stream. Callers guarantee (by an
5
+ * earlier guard that throws on `error`/`aborted`) that `output.stopReason` is a
6
+ * success reason; this narrows it for the event type.
7
+ */
8
+ export declare function pushDone(stream: AssistantMessageEventStream, output: AssistantMessage): void;
9
+ /** A fresh assistant message with zeroed usage, ready for an adapter to fill. */
10
+ export declare function freshAssistantMessage<TApi extends Api>(model: Model<TApi>): AssistantMessage;
11
+ /**
12
+ * Strip transient streaming scratch fields off every content block. The keys
13
+ * must be removed (not nulled) so replayed messages carry only finalized data —
14
+ * hence `delete` rather than an `undefined` assignment.
15
+ */
16
+ export declare function stripScratchFields(message: AssistantMessage): void;
17
+ /**
18
+ * The unified streaming skeleton shared by every text adapter.
19
+ *
20
+ * Returns an {@link AssistantMessageEventStream} synchronously and launches a
21
+ * fire-and-forget task that runs `body`. `body` mutates the supplied `output`
22
+ * message and pushes fine-grained events; it is expected to push the terminal
23
+ * `done` event itself on success. Any thrown error (or an abort) is normalized
24
+ * into a terminal `error` event with `stopReason` `"aborted"`/`"error"` —
25
+ * the adapter never throws after invocation.
26
+ */
27
+ export declare function runStream<TApi extends Api>(model: Model<TApi>, options: StreamOptions | undefined, body: (output: AssistantMessage, stream: AssistantMessageEventStream) => Promise<void>): AssistantMessageEventStream;
28
+ /** Build the {@link ProviderResponse} surface passed to `onResponse`. */
29
+ export declare function toProviderResponse(response: Response): ProviderResponse;
30
+ /** Pull the text prompt out of an images context. */
31
+ export declare function promptFromContext(context: ImagesContext): string;
32
+ /** Read an error response body into a short, safe diagnostic string. */
33
+ export declare function readErrorBody(response: Response): Promise<string>;
34
+ //# sourceMappingURL=provider-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-runtime.d.ts","sourceRoot":"","sources":["../../src/providers/provider-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EACV,GAAG,EACH,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,gBAAgB,EAEhB,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,2BAA2B,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAS5F;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAkB5F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAiBlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAS,GAAG,EACxC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,IAAI,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,2BAA2B,KAAK,OAAO,CAAC,IAAI,CAAC,GACrF,2BAA2B,CAiB7B;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAMvE;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAKhE;AAED,wEAAwE;AACxE,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CASvE"}
@@ -0,0 +1,11 @@
1
+ import { setBedrockProviderModule } from "./amazon-bedrock";
2
+ export { setBedrockProviderModule } from "./amazon-bedrock";
3
+ /**
4
+ * Register every implemented built-in provider under its `api` id. Idempotent:
5
+ * a second call is a no-op until {@link resetApiProviders} clears the latch.
6
+ */
7
+ export declare function registerBuiltInApiProviders(): void;
8
+ /** Clear the registry and re-register built-ins (resets the latch). */
9
+ export declare function resetApiProviders(): void;
10
+ export declare const _bedrockInjectionHook: typeof setBedrockProviderModule;
11
+ //# sourceMappingURL=register-builtins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-builtins.d.ts","sourceRoot":"","sources":["../../src/providers/register-builtins.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAsC,MAAM,kBAAkB,CAAC;AAgBhG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAI5D;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAiDlD;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAGD,eAAO,MAAM,qBAAqB,iCAA2B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Register every built-in image provider under its `api` id. Idempotent: a
3
+ * second call is a no-op until {@link resetImagesProviders} clears the latch.
4
+ */
5
+ export declare function registerBuiltInImagesProviders(): void;
6
+ /** Clear the image registry and re-register built-ins (resets the latch). */
7
+ export declare function resetImagesProviders(): void;
8
+ //# sourceMappingURL=register-images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-images.d.ts","sourceRoot":"","sources":["../../src/providers/register-images.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAMrD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C"}
@@ -0,0 +1,52 @@
1
+ import type { StreamOptions } from "../types";
2
+ /**
3
+ * A `fetch` dispatcher (an undici `Dispatcher`). Kept opaque here so the
4
+ * no-proxy path never imports undici and never needs its types.
5
+ */
6
+ type FetchDispatcher = object;
7
+ /**
8
+ * Builds the `fetch` dispatcher that routes a request through `proxyUrl`.
9
+ * Injectable so tests can assert wiring without opening a real proxy
10
+ * connection, and lazy so undici is imported only when a proxy is actually in
11
+ * play.
12
+ */
13
+ export type ProxyDispatcherFactory = (proxyUrl: URL) => FetchDispatcher | Promise<FetchDispatcher>;
14
+ /**
15
+ * Override the proxy-dispatcher factory (test seam). Pass `undefined` to restore
16
+ * the default (undici `ProxyAgent`) factory.
17
+ */
18
+ export declare function setProxyDispatcherFactory(factory: ProxyDispatcherFactory | undefined): void;
19
+ /**
20
+ * Client-side retry attempts used when `options.maxRetries` is unset. Zero keeps
21
+ * the default behavior identical to a plain `fetch`: transient errors surface
22
+ * immediately and callers opt into retries by threading `maxRetries`.
23
+ */
24
+ export declare const DEFAULT_MAX_RETRIES = 0;
25
+ /** Base delay (ms) for the exponential backoff schedule (`base * 2 ** attempt`). */
26
+ export declare const BASE_RETRY_DELAY_MS = 1000;
27
+ /**
28
+ * Default cap (ms) on a server-requested (`Retry-After`) delay. When a provider
29
+ * asks to wait longer than this, the request fails fast surfacing the requested
30
+ * delay instead of blocking. `0` disables the cap. Mirrors the documented
31
+ * {@link StreamOptions.maxRetryDelayMs} contract.
32
+ */
33
+ export declare const DEFAULT_MAX_RETRY_DELAY_MS = 60000;
34
+ /**
35
+ * Establish a streaming provider request through a single shared policy:
36
+ *
37
+ * - **Retries** transient failures (connection errors, `429`, and `5xx`) *before
38
+ * the first byte* with exponential backoff + jitter, honoring `Retry-After`.
39
+ * Once a stream is flowing it is never retried. Consumes `options.maxRetries`
40
+ * (default {@link DEFAULT_MAX_RETRIES}).
41
+ * - **Per-request timeout** bounds request establishment via `options.timeoutMs`,
42
+ * composed with the caller's `options.signal` (an external abort still wins and
43
+ * short-circuits retries immediately).
44
+ * - **Idle timeout** wraps the response body so a stalled stream (no bytes for
45
+ * `options.timeoutMs`) aborts instead of hanging forever.
46
+ *
47
+ * When neither `timeoutMs` nor `maxRetries` is set, behavior is identical to a
48
+ * plain `fetch(url, { ...init, signal: options.signal })`.
49
+ */
50
+ export declare function dispatchStreamRequest(url: string, init: RequestInit, options: StreamOptions | undefined): Promise<Response>;
51
+ export {};
52
+ //# sourceMappingURL=request-dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-dispatch.d.ts","sourceRoot":"","sources":["../../src/providers/request-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;;GAGG;AACH,KAAK,eAAe,GAAG,MAAM,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAkBnG;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAAG,IAAI,CAE3F;AAcD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AA2JjD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,OAAO,CAAC,QAAQ,CAAC,CAqFnB"}
@@ -0,0 +1,42 @@
1
+ import type { Api, Context, Model, ProviderHeaders, SimpleStreamOptions, StreamOptions, ThinkingBudgets, ThinkingLevel } from "../types";
2
+ /**
3
+ * Merge caller header overrides onto a mutable set of provider/API default
4
+ * headers. A string value sets (or replaces) the header; a `null` value
5
+ * SUPPRESSES a default header of the same name (distinct from an absent key,
6
+ * which leaves the default untouched). No-op when `overrides` is undefined, so
7
+ * providers stay byte-identical when the caller passes no header overrides.
8
+ */
9
+ export declare function applyHeaderOverrides(headers: Record<string, string>, overrides: ProviderHeaders | undefined): void;
10
+ /**
11
+ * Clamp a desired output `maxTokens` to the room left in a model's context
12
+ * window: `contextWindow − estimatedContextTokens − safety`. This prevents long
13
+ * conversations from requesting more output than can fit (a provider 400). When
14
+ * there is ample room the requested value is returned unchanged; the result is
15
+ * never below {@link MIN_MAX_TOKENS}. Models without a known context window
16
+ * (`contextWindow <= 0`) are passed through untouched.
17
+ */
18
+ export declare function clampMaxTokensToContext(model: Model<Api>, context: Context, maxTokens: number): number;
19
+ /**
20
+ * Project a {@link SimpleStreamOptions} onto the {@link StreamOptions} base
21
+ * surface, injecting a resolved API key. The provider-agnostic `reasoning`
22
+ * knob is intentionally dropped here — each `streamSimple*` maps it onto its
23
+ * own native reasoning surface before delegating to the full entry point.
24
+ *
25
+ * The resolved output cap (`options.maxTokens`, falling back to the model cap)
26
+ * is clamped to the context window so it never requests more than remains.
27
+ */
28
+ export declare function buildBaseOptions(model: Model<Api>, context: Context, options?: SimpleStreamOptions, apiKey?: string): StreamOptions;
29
+ /** Collapse `xhigh` down to `high`; pass other levels through unchanged. */
30
+ export declare function clampReasoning(effort: ThinkingLevel | undefined): Exclude<ThinkingLevel, "xhigh"> | undefined;
31
+ /**
32
+ * Fit a thinking budget inside a max-tokens cap for budget-based reasoning.
33
+ *
34
+ * Returns the effective `maxTokens` (base cap plus budget, clamped to the
35
+ * model cap; the model cap alone when no base cap is supplied) and a
36
+ * `thinkingBudget` that always leaves at least a small output allowance.
37
+ */
38
+ export declare function adjustMaxTokensForThinking(baseMaxTokens: number | undefined, modelMaxTokens: number, reasoningLevel: ThinkingLevel, customBudgets?: ThinkingBudgets): {
39
+ maxTokens: number;
40
+ thinkingBudget: number;
41
+ };
42
+ //# sourceMappingURL=simple-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-options.d.ts","sourceRoot":"","sources":["../../src/providers/simple-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,OAAO,EACP,KAAK,EACL,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,SAAS,EAAE,eAAe,GAAG,SAAS,GACrC,IAAI,CAMN;AAOD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,MAAM,GACd,aAAa,CAmBf;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,GAAG,SAAS,GAChC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,SAAS,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,aAAa,EAC7B,aAAa,CAAC,EAAE,eAAe,GAC9B;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAsB/C"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Cross-provider tool-call-id normalization policy.
3
+ *
4
+ * Each provider family imposes different constraints on the ids that pair a
5
+ * tool call with its result. Replaying a conversation produced by one provider
6
+ * through another therefore requires rewriting ids to satisfy the *target*
7
+ * provider's rules. Rather than repeating these rules inline in every adapter,
8
+ * they live in one place, keyed by a target {@link ToolCallIdTarget}.
9
+ *
10
+ * Known constraints:
11
+ * - Anthropic: `^[a-zA-Z0-9_-]+$`, length <= 64.
12
+ * - OpenAI completions: length <= 40 (and sanitized for the pipe-encoded form).
13
+ * - OpenAI Responses: ids are `call_id|item_id`; each part <= 64, item id must
14
+ * start with `fc_`; foreign item ids are hashed to a bounded `fc_<hash>`.
15
+ * - Mistral: exactly 9 alphanumeric characters (derived via hash, with a
16
+ * collision-retry helper available through {@link createMistralToolCallIdNormalizer}).
17
+ * - Bedrock / Google: sanitize + length <= 64 (Google only when required).
18
+ */
19
+ export type ToolCallIdTarget = "anthropic" | "openai-completions" | "openai-responses" | "mistral" | "bedrock" | "google";
20
+ export declare const TOOL_CALL_ID_MAX_LENGTH: Record<ToolCallIdTarget, number>;
21
+ /** Build a bounded `fc_<hash>` item id for a foreign (cross-provider) call. */
22
+ export declare function buildForeignResponsesItemId(itemId: string): string;
23
+ /**
24
+ * Normalize a `call_id|item_id` Responses id. `foreign` controls whether the
25
+ * item id is hashed (cross-provider replay) or merely sanitized (same provider).
26
+ * The item id is always coerced to start with `fc_`.
27
+ */
28
+ export declare function normalizeResponsesId(id: string, foreign: boolean): string;
29
+ /**
30
+ * Derive a Mistral-shaped id: exactly 9 alphanumeric chars. If the source is
31
+ * already 9 alphanumerics it is used verbatim; otherwise a deterministic hash
32
+ * is taken. `attempt` salts the hash for collision retries.
33
+ */
34
+ export declare function deriveMistralToolCallId(id: string, attempt?: number): string;
35
+ /**
36
+ * A stateful normalizer for Mistral that guarantees uniqueness: distinct source
37
+ * ids never collapse to the same 9-char id (collisions retry with a salt).
38
+ */
39
+ export declare function createMistralToolCallIdNormalizer(): (id: string) => string;
40
+ /**
41
+ * Normalize a tool-call id for a given target provider family. For
42
+ * `openai-responses` the `foreign` flag selects hashing vs sanitizing of the
43
+ * item id; it is ignored by the other targets.
44
+ */
45
+ export declare function normalizeToolCallId(id: string, target: ToolCallIdTarget, foreign?: boolean): string;
46
+ //# sourceMappingURL=tool-call-id.d.ts.map