@opencode-ai/ai 0.0.0-beta-17492

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 (194) hide show
  1. package/README.md +392 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +121 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +19 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +102 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +230 -0
  11. package/dist/llm.js +77 -0
  12. package/dist/protocols/anthropic-messages.d.ts +633 -0
  13. package/dist/protocols/anthropic-messages.js +860 -0
  14. package/dist/protocols/bedrock-converse.d.ts +533 -0
  15. package/dist/protocols/bedrock-converse.js +584 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +73 -0
  18. package/dist/protocols/gemini.d.ts +300 -0
  19. package/dist/protocols/gemini.js +512 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +191 -0
  22. package/dist/protocols/index.d.ts +10 -0
  23. package/dist/protocols/index.js +10 -0
  24. package/dist/protocols/open-responses-channel.d.ts +26 -0
  25. package/dist/protocols/open-responses-channel.js +120 -0
  26. package/dist/protocols/open-responses.d.ts +951 -0
  27. package/dist/protocols/open-responses.js +873 -0
  28. package/dist/protocols/openai-chat.d.ts +795 -0
  29. package/dist/protocols/openai-chat.js +718 -0
  30. package/dist/protocols/openai-compatible-chat.d.ts +107 -0
  31. package/dist/protocols/openai-compatible-chat.js +20 -0
  32. package/dist/protocols/openai-compatible-responses.d.ts +96 -0
  33. package/dist/protocols/openai-compatible-responses.js +17 -0
  34. package/dist/protocols/openai-images.d.ts +32 -0
  35. package/dist/protocols/openai-images.js +188 -0
  36. package/dist/protocols/openai-responses-channel.d.ts +12 -0
  37. package/dist/protocols/openai-responses-channel.js +142 -0
  38. package/dist/protocols/openai-responses.d.ts +596 -0
  39. package/dist/protocols/openai-responses.js +208 -0
  40. package/dist/protocols/shared.d.ts +194 -0
  41. package/dist/protocols/shared.js +238 -0
  42. package/dist/protocols/utils/bedrock-auth.d.ts +21 -0
  43. package/dist/protocols/utils/bedrock-auth.js +43 -0
  44. package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
  45. package/dist/protocols/utils/bedrock-cache.js +29 -0
  46. package/dist/protocols/utils/bedrock-media.d.ts +49 -0
  47. package/dist/protocols/utils/bedrock-media.js +70 -0
  48. package/dist/protocols/utils/cache.d.ts +6 -0
  49. package/dist/protocols/utils/cache.js +8 -0
  50. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  51. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  52. package/dist/protocols/utils/image-input.d.ts +21 -0
  53. package/dist/protocols/utils/image-input.js +22 -0
  54. package/dist/protocols/utils/lifecycle.d.ts +20 -0
  55. package/dist/protocols/utils/lifecycle.js +68 -0
  56. package/dist/protocols/utils/open-responses-options.d.ts +21 -0
  57. package/dist/protocols/utils/open-responses-options.js +41 -0
  58. package/dist/protocols/utils/openai-image.d.ts +5 -0
  59. package/dist/protocols/utils/openai-image.js +18 -0
  60. package/dist/protocols/utils/openai-options.d.ts +14 -0
  61. package/dist/protocols/utils/openai-options.js +14 -0
  62. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  63. package/dist/protocols/utils/tool-schema.js +81 -0
  64. package/dist/protocols/utils/tool-stream.d.ts +639 -0
  65. package/dist/protocols/utils/tool-stream.js +141 -0
  66. package/dist/protocols/xai-images.d.ts +26 -0
  67. package/dist/protocols/xai-images.js +111 -0
  68. package/dist/protocols/zai-images.d.ts +22 -0
  69. package/dist/protocols/zai-images.js +84 -0
  70. package/dist/protocols.d.ts +1 -0
  71. package/dist/protocols.js +1 -0
  72. package/dist/provider-error.d.ts +14 -0
  73. package/dist/provider-error.js +130 -0
  74. package/dist/provider-package.d.ts +15 -0
  75. package/dist/provider-package.js +1 -0
  76. package/dist/provider.d.ts +23 -0
  77. package/dist/provider.js +2 -0
  78. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  79. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  80. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  81. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  82. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  83. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  84. package/dist/providers/amazon-bedrock-mantle.d.ts +247 -0
  85. package/dist/providers/amazon-bedrock-mantle.js +68 -0
  86. package/dist/providers/amazon-bedrock.d.ts +172 -0
  87. package/dist/providers/amazon-bedrock.js +41 -0
  88. package/dist/providers/anthropic-compatible.d.ts +218 -0
  89. package/dist/providers/anthropic-compatible.js +45 -0
  90. package/dist/providers/anthropic.d.ts +216 -0
  91. package/dist/providers/anthropic.js +40 -0
  92. package/dist/providers/azure/chat.d.ts +2 -0
  93. package/dist/providers/azure/chat.js +1 -0
  94. package/dist/providers/azure/responses.d.ts +2 -0
  95. package/dist/providers/azure/responses.js +1 -0
  96. package/dist/providers/azure.d.ts +248 -0
  97. package/dist/providers/azure.js +90 -0
  98. package/dist/providers/cloudflare.d.ts +338 -0
  99. package/dist/providers/cloudflare.js +87 -0
  100. package/dist/providers/google-vertex/chat.d.ts +2 -0
  101. package/dist/providers/google-vertex/chat.js +1 -0
  102. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  103. package/dist/providers/google-vertex/gemini.js +1 -0
  104. package/dist/providers/google-vertex/messages.d.ts +2 -0
  105. package/dist/providers/google-vertex/messages.js +1 -0
  106. package/dist/providers/google-vertex/responses.d.ts +2 -0
  107. package/dist/providers/google-vertex/responses.js +1 -0
  108. package/dist/providers/google-vertex-chat.d.ts +131 -0
  109. package/dist/providers/google-vertex-chat.js +50 -0
  110. package/dist/providers/google-vertex-messages.d.ts +215 -0
  111. package/dist/providers/google-vertex-messages.js +75 -0
  112. package/dist/providers/google-vertex-responses.d.ts +122 -0
  113. package/dist/providers/google-vertex-responses.js +51 -0
  114. package/dist/providers/google-vertex-shared.d.ts +22 -0
  115. package/dist/providers/google-vertex-shared.js +61 -0
  116. package/dist/providers/google-vertex.d.ts +115 -0
  117. package/dist/providers/google-vertex.js +64 -0
  118. package/dist/providers/google.d.ts +112 -0
  119. package/dist/providers/google.js +43 -0
  120. package/dist/providers/index.d.ts +18 -0
  121. package/dist/providers/index.js +18 -0
  122. package/dist/providers/open-responses-options.d.ts +16 -0
  123. package/dist/providers/open-responses-options.js +1 -0
  124. package/dist/providers/openai/chat.d.ts +2 -0
  125. package/dist/providers/openai/chat.js +1 -0
  126. package/dist/providers/openai/responses.d.ts +2 -0
  127. package/dist/providers/openai/responses.js +1 -0
  128. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  129. package/dist/providers/openai-compatible/responses.js +1 -0
  130. package/dist/providers/openai-compatible-profile.d.ts +43 -0
  131. package/dist/providers/openai-compatible-profile.js +12 -0
  132. package/dist/providers/openai-compatible-responses.d.ts +120 -0
  133. package/dist/providers/openai-compatible-responses.js +33 -0
  134. package/dist/providers/openai-compatible.d.ts +167 -0
  135. package/dist/providers/openai-compatible.js +55 -0
  136. package/dist/providers/openai-options.d.ts +21 -0
  137. package/dist/providers/openai-options.js +41 -0
  138. package/dist/providers/openai.d.ts +264 -0
  139. package/dist/providers/openai.js +83 -0
  140. package/dist/providers/openrouter.d.ts +537 -0
  141. package/dist/providers/openrouter.js +117 -0
  142. package/dist/providers/xai.d.ts +249 -0
  143. package/dist/providers/xai.js +79 -0
  144. package/dist/providers/zai.d.ts +24 -0
  145. package/dist/providers/zai.js +21 -0
  146. package/dist/providers.d.ts +1 -0
  147. package/dist/providers.js +1 -0
  148. package/dist/route/auth-options.d.ts +34 -0
  149. package/dist/route/auth-options.js +14 -0
  150. package/dist/route/auth.d.ts +51 -0
  151. package/dist/route/auth.js +89 -0
  152. package/dist/route/client.d.ts +348 -0
  153. package/dist/route/client.js +214 -0
  154. package/dist/route/endpoint.d.ts +28 -0
  155. package/dist/route/endpoint.js +21 -0
  156. package/dist/route/executor.d.ts +23 -0
  157. package/dist/route/executor.js +227 -0
  158. package/dist/route/framing.d.ts +23 -0
  159. package/dist/route/framing.js +4 -0
  160. package/dist/route/index.d.ts +16 -0
  161. package/dist/route/index.js +9 -0
  162. package/dist/route/protocol.d.ts +77 -0
  163. package/dist/route/protocol.js +17 -0
  164. package/dist/route/transport/http.d.ts +34 -0
  165. package/dist/route/transport/http.js +63 -0
  166. package/dist/route/transport/index.d.ts +39 -0
  167. package/dist/route/transport/index.js +4 -0
  168. package/dist/route/transport/websocket-channel.d.ts +56 -0
  169. package/dist/route/transport/websocket-channel.js +1 -0
  170. package/dist/route/transport/websocket.d.ts +55 -0
  171. package/dist/route/transport/websocket.js +326 -0
  172. package/dist/route.d.ts +1 -0
  173. package/dist/route.js +1 -0
  174. package/dist/schema/errors.d.ts +159 -0
  175. package/dist/schema/errors.js +155 -0
  176. package/dist/schema/events.d.ts +4587 -0
  177. package/dist/schema/events.js +492 -0
  178. package/dist/schema/ids.d.ts +30 -0
  179. package/dist/schema/ids.js +19 -0
  180. package/dist/schema/index.d.ts +5 -0
  181. package/dist/schema/index.js +5 -0
  182. package/dist/schema/messages.d.ts +402 -0
  183. package/dist/schema/messages.js +244 -0
  184. package/dist/schema/options.d.ts +159 -0
  185. package/dist/schema/options.js +202 -0
  186. package/dist/testing.d.ts +1493 -0
  187. package/dist/testing.js +88 -0
  188. package/dist/tool-runtime.d.ts +15 -0
  189. package/dist/tool-runtime.js +54 -0
  190. package/dist/tool.d.ts +135 -0
  191. package/dist/tool.js +66 -0
  192. package/dist/utils/record.d.ts +2 -0
  193. package/dist/utils/record.js +2 -0
  194. package/package.json +47 -0
@@ -0,0 +1,795 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { Route } from "../route/client.js";
3
+ import { HttpTransport } from "../route/transport/index.js";
4
+ import { Protocol } from "../route/protocol.js";
5
+ import { AIError, LLMEvent, Usage, type FinishReasonDetails, type CacheHint, type LLMRequest } from "../schema/index.js";
6
+ import { Lifecycle } from "./utils/lifecycle.js";
7
+ import { ToolStream } from "./utils/tool-stream.js";
8
+ export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
9
+ export declare const PATH = "/chat/completions";
10
+ declare const OpenAIChatCacheControl: Schema.Struct<{
11
+ readonly type: Schema.Literal<"ephemeral">;
12
+ readonly ttl: Schema.optional<Schema.String>;
13
+ }>;
14
+ export declare const bodyFields: {
15
+ model: Schema.String;
16
+ messages: Schema.$Array<Schema.toTaggedUnion<"role", readonly [Schema.Struct<{
17
+ readonly role: Schema.Literal<"system">;
18
+ readonly content: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
19
+ readonly type: Schema.Literal<"text">;
20
+ readonly text: Schema.String;
21
+ readonly cache_control: Schema.optional<Schema.Struct<{
22
+ readonly type: Schema.Literal<"ephemeral">;
23
+ readonly ttl: Schema.optional<Schema.String>;
24
+ }>>;
25
+ }>, Schema.Struct<{
26
+ readonly type: Schema.Literal<"image_url">;
27
+ readonly image_url: Schema.Struct<{
28
+ readonly url: Schema.String;
29
+ }>;
30
+ }>]>>]>;
31
+ }>, Schema.Struct<{
32
+ readonly role: Schema.Literal<"user">;
33
+ readonly content: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
34
+ readonly type: Schema.Literal<"text">;
35
+ readonly text: Schema.String;
36
+ readonly cache_control: Schema.optional<Schema.Struct<{
37
+ readonly type: Schema.Literal<"ephemeral">;
38
+ readonly ttl: Schema.optional<Schema.String>;
39
+ }>>;
40
+ }>, Schema.Struct<{
41
+ readonly type: Schema.Literal<"image_url">;
42
+ readonly image_url: Schema.Struct<{
43
+ readonly url: Schema.String;
44
+ }>;
45
+ }>]>>]>;
46
+ }>, Schema.StructWithRest<Schema.Struct<{
47
+ readonly role: Schema.Literal<"assistant">;
48
+ readonly content: Schema.NullOr<Schema.String>;
49
+ readonly tool_calls: Schema.optional<Schema.$Array<Schema.Struct<{
50
+ readonly id: Schema.String;
51
+ readonly type: Schema.tag<"function">;
52
+ readonly function: Schema.Struct<{
53
+ readonly name: Schema.String;
54
+ readonly arguments: Schema.String;
55
+ }>;
56
+ }>>>;
57
+ readonly reasoning_content: Schema.optional<Schema.String>;
58
+ readonly reasoning: Schema.optional<Schema.String>;
59
+ readonly reasoning_text: Schema.optional<Schema.String>;
60
+ readonly reasoning_details: Schema.optional<Schema.Unknown>;
61
+ readonly cache_control: Schema.optional<Schema.Struct<{
62
+ readonly type: Schema.Literal<"ephemeral">;
63
+ readonly ttl: Schema.optional<Schema.String>;
64
+ }>>;
65
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
66
+ readonly role: Schema.Literal<"tool">;
67
+ readonly tool_call_id: Schema.String;
68
+ readonly content: Schema.String;
69
+ readonly cache_control: Schema.optional<Schema.Struct<{
70
+ readonly type: Schema.Literal<"ephemeral">;
71
+ readonly ttl: Schema.optional<Schema.String>;
72
+ }>>;
73
+ }>]>>;
74
+ tools: Schema.optional<Schema.$Array<Schema.Struct<{
75
+ readonly type: Schema.tag<"function">;
76
+ readonly function: Schema.Struct<{
77
+ readonly name: Schema.String;
78
+ readonly description: Schema.String;
79
+ readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
80
+ }>;
81
+ readonly cache_control: Schema.optional<Schema.Struct<{
82
+ readonly type: Schema.Literal<"ephemeral">;
83
+ readonly ttl: Schema.optional<Schema.String>;
84
+ }>>;
85
+ }>>>;
86
+ tool_choice: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
87
+ readonly type: Schema.tag<"function">;
88
+ readonly function: Schema.Struct<{
89
+ readonly name: Schema.String;
90
+ }>;
91
+ }>]>>;
92
+ stream: Schema.Literal<true>;
93
+ stream_options: Schema.optional<Schema.Struct<{
94
+ readonly include_usage: Schema.Boolean;
95
+ }>>;
96
+ store: Schema.optional<Schema.Boolean>;
97
+ prompt_cache_key: Schema.optional<Schema.String>;
98
+ reasoning_effort: Schema.optional<Schema.String>;
99
+ max_completion_tokens: Schema.optional<Schema.Number>;
100
+ max_tokens: Schema.optional<Schema.Number>;
101
+ temperature: Schema.optional<Schema.Number>;
102
+ top_p: Schema.optional<Schema.Number>;
103
+ frequency_penalty: Schema.optional<Schema.Number>;
104
+ presence_penalty: Schema.optional<Schema.Number>;
105
+ seed: Schema.optional<Schema.Number>;
106
+ stop: Schema.optional<Schema.$Array<Schema.String>>;
107
+ };
108
+ declare const OpenAIChatBody: Schema.Struct<{
109
+ model: Schema.String;
110
+ messages: Schema.$Array<Schema.toTaggedUnion<"role", readonly [Schema.Struct<{
111
+ readonly role: Schema.Literal<"system">;
112
+ readonly content: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
113
+ readonly type: Schema.Literal<"text">;
114
+ readonly text: Schema.String;
115
+ readonly cache_control: Schema.optional<Schema.Struct<{
116
+ readonly type: Schema.Literal<"ephemeral">;
117
+ readonly ttl: Schema.optional<Schema.String>;
118
+ }>>;
119
+ }>, Schema.Struct<{
120
+ readonly type: Schema.Literal<"image_url">;
121
+ readonly image_url: Schema.Struct<{
122
+ readonly url: Schema.String;
123
+ }>;
124
+ }>]>>]>;
125
+ }>, Schema.Struct<{
126
+ readonly role: Schema.Literal<"user">;
127
+ readonly content: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
128
+ readonly type: Schema.Literal<"text">;
129
+ readonly text: Schema.String;
130
+ readonly cache_control: Schema.optional<Schema.Struct<{
131
+ readonly type: Schema.Literal<"ephemeral">;
132
+ readonly ttl: Schema.optional<Schema.String>;
133
+ }>>;
134
+ }>, Schema.Struct<{
135
+ readonly type: Schema.Literal<"image_url">;
136
+ readonly image_url: Schema.Struct<{
137
+ readonly url: Schema.String;
138
+ }>;
139
+ }>]>>]>;
140
+ }>, Schema.StructWithRest<Schema.Struct<{
141
+ readonly role: Schema.Literal<"assistant">;
142
+ readonly content: Schema.NullOr<Schema.String>;
143
+ readonly tool_calls: Schema.optional<Schema.$Array<Schema.Struct<{
144
+ readonly id: Schema.String;
145
+ readonly type: Schema.tag<"function">;
146
+ readonly function: Schema.Struct<{
147
+ readonly name: Schema.String;
148
+ readonly arguments: Schema.String;
149
+ }>;
150
+ }>>>;
151
+ readonly reasoning_content: Schema.optional<Schema.String>;
152
+ readonly reasoning: Schema.optional<Schema.String>;
153
+ readonly reasoning_text: Schema.optional<Schema.String>;
154
+ readonly reasoning_details: Schema.optional<Schema.Unknown>;
155
+ readonly cache_control: Schema.optional<Schema.Struct<{
156
+ readonly type: Schema.Literal<"ephemeral">;
157
+ readonly ttl: Schema.optional<Schema.String>;
158
+ }>>;
159
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
160
+ readonly role: Schema.Literal<"tool">;
161
+ readonly tool_call_id: Schema.String;
162
+ readonly content: Schema.String;
163
+ readonly cache_control: Schema.optional<Schema.Struct<{
164
+ readonly type: Schema.Literal<"ephemeral">;
165
+ readonly ttl: Schema.optional<Schema.String>;
166
+ }>>;
167
+ }>]>>;
168
+ tools: Schema.optional<Schema.$Array<Schema.Struct<{
169
+ readonly type: Schema.tag<"function">;
170
+ readonly function: Schema.Struct<{
171
+ readonly name: Schema.String;
172
+ readonly description: Schema.String;
173
+ readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
174
+ }>;
175
+ readonly cache_control: Schema.optional<Schema.Struct<{
176
+ readonly type: Schema.Literal<"ephemeral">;
177
+ readonly ttl: Schema.optional<Schema.String>;
178
+ }>>;
179
+ }>>>;
180
+ tool_choice: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
181
+ readonly type: Schema.tag<"function">;
182
+ readonly function: Schema.Struct<{
183
+ readonly name: Schema.String;
184
+ }>;
185
+ }>]>>;
186
+ stream: Schema.Literal<true>;
187
+ stream_options: Schema.optional<Schema.Struct<{
188
+ readonly include_usage: Schema.Boolean;
189
+ }>>;
190
+ store: Schema.optional<Schema.Boolean>;
191
+ prompt_cache_key: Schema.optional<Schema.String>;
192
+ reasoning_effort: Schema.optional<Schema.String>;
193
+ max_completion_tokens: Schema.optional<Schema.Number>;
194
+ max_tokens: Schema.optional<Schema.Number>;
195
+ temperature: Schema.optional<Schema.Number>;
196
+ top_p: Schema.optional<Schema.Number>;
197
+ frequency_penalty: Schema.optional<Schema.Number>;
198
+ presence_penalty: Schema.optional<Schema.Number>;
199
+ seed: Schema.optional<Schema.Number>;
200
+ stop: Schema.optional<Schema.$Array<Schema.String>>;
201
+ }>;
202
+ export type OpenAIChatBody = Schema.Schema.Type<typeof OpenAIChatBody>;
203
+ export declare const OpenAIChatEvent: Schema.Struct<{
204
+ readonly choices: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
205
+ readonly delta: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
206
+ readonly content: Schema.optional<Schema.NullOr<Schema.String>>;
207
+ readonly reasoning_content: Schema.optional<Schema.NullOr<Schema.String>>;
208
+ readonly reasoning: Schema.optional<Schema.NullOr<Schema.String>>;
209
+ readonly reasoning_text: Schema.optional<Schema.NullOr<Schema.String>>;
210
+ readonly reasoning_details: Schema.optional<Schema.NullOr<Schema.Unknown>>;
211
+ readonly tool_calls: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
212
+ readonly index: Schema.optional<Schema.NullOr<Schema.Number>>;
213
+ readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
214
+ readonly function: Schema.optional<Schema.NullOr<Schema.Struct<{
215
+ readonly name: Schema.optional<Schema.NullOr<Schema.String>>;
216
+ readonly arguments: Schema.optional<Schema.NullOr<Schema.String>>;
217
+ }>>>;
218
+ }>>>>;
219
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
220
+ readonly finish_reason: Schema.optional<Schema.NullOr<Schema.String>>;
221
+ readonly native_finish_reason: Schema.optional<Schema.NullOr<Schema.String>>;
222
+ }>>>>;
223
+ readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
224
+ readonly prompt_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
225
+ readonly completion_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
226
+ readonly total_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
227
+ readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
228
+ readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
229
+ readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
230
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
231
+ readonly completion_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
232
+ readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
233
+ readonly accepted_prediction_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
234
+ readonly rejected_prediction_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
235
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
236
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
237
+ readonly error: Schema.optional<Schema.NullOr<Schema.Struct<{
238
+ readonly code: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Number]>>>;
239
+ readonly message: Schema.String;
240
+ }>>>;
241
+ }>;
242
+ export type OpenAIChatEvent = Schema.Schema.Type<typeof OpenAIChatEvent>;
243
+ interface PendingToolDelta {
244
+ readonly id?: string;
245
+ readonly name?: string;
246
+ readonly input: string;
247
+ }
248
+ export interface ParserState {
249
+ readonly tools: ToolStream.State<number>;
250
+ readonly pendingTools: Partial<Record<number, PendingToolDelta>>;
251
+ readonly toolCallEvents: ReadonlyArray<LLMEvent>;
252
+ readonly usage?: Usage;
253
+ readonly finishReason?: FinishReasonDetails;
254
+ readonly lifecycle: Lifecycle.State;
255
+ readonly reasoningField?: string;
256
+ readonly reasoningDetails: Array<unknown>;
257
+ readonly reasoningDetailsObserved: boolean;
258
+ readonly reasoningEmitted: boolean;
259
+ readonly latestToolIndex?: number;
260
+ readonly nextToolIndex: number;
261
+ }
262
+ interface LoweringOptions {
263
+ readonly cacheControl?: (cache: CacheHint | undefined) => Schema.Schema.Type<typeof OpenAIChatCacheControl> | undefined;
264
+ }
265
+ export declare const fromRequest: (request: LLMRequest, options?: LoweringOptions | undefined) => Effect.Effect<{
266
+ reasoning_effort?: string | undefined;
267
+ prompt_cache_key?: string | undefined;
268
+ store?: boolean | undefined;
269
+ temperature: number | undefined;
270
+ top_p: number | undefined;
271
+ frequency_penalty: number | undefined;
272
+ presence_penalty: number | undefined;
273
+ seed: number | undefined;
274
+ stop: readonly string[] | undefined;
275
+ max_completion_tokens: number | undefined;
276
+ model: string & import("effect/Brand").Brand<"AI.ModelID">;
277
+ messages: ({
278
+ readonly role: "system";
279
+ readonly content: string | readonly ({
280
+ readonly type: "text";
281
+ readonly text: string;
282
+ readonly cache_control?: {
283
+ readonly type: "ephemeral";
284
+ readonly ttl?: string | undefined;
285
+ } | undefined;
286
+ } | {
287
+ readonly type: "image_url";
288
+ readonly image_url: {
289
+ readonly url: string;
290
+ };
291
+ })[];
292
+ } | {
293
+ readonly role: "user";
294
+ readonly content: string | readonly ({
295
+ readonly type: "text";
296
+ readonly text: string;
297
+ readonly cache_control?: {
298
+ readonly type: "ephemeral";
299
+ readonly ttl?: string | undefined;
300
+ } | undefined;
301
+ } | {
302
+ readonly type: "image_url";
303
+ readonly image_url: {
304
+ readonly url: string;
305
+ };
306
+ })[];
307
+ } | {
308
+ readonly [x: string]: unknown;
309
+ readonly content: string | null;
310
+ readonly role: "assistant";
311
+ readonly reasoning?: string | undefined;
312
+ readonly reasoning_content?: string | undefined;
313
+ readonly reasoning_text?: string | undefined;
314
+ readonly cache_control?: {
315
+ readonly type: "ephemeral";
316
+ readonly ttl?: string | undefined;
317
+ } | undefined;
318
+ readonly tool_calls?: readonly {
319
+ readonly id: string;
320
+ readonly type: "function";
321
+ readonly function: {
322
+ readonly name: string;
323
+ readonly arguments: string;
324
+ };
325
+ }[] | undefined;
326
+ readonly reasoning_details?: unknown;
327
+ } | {
328
+ readonly content: string;
329
+ readonly role: "tool";
330
+ readonly tool_call_id: string;
331
+ readonly cache_control?: {
332
+ readonly type: "ephemeral";
333
+ readonly ttl?: string | undefined;
334
+ } | undefined;
335
+ })[];
336
+ tools: {
337
+ readonly function: {
338
+ readonly name: string;
339
+ readonly description: string;
340
+ readonly parameters: {
341
+ readonly [x: string]: unknown;
342
+ };
343
+ };
344
+ readonly type: "function";
345
+ readonly cache_control?: {
346
+ readonly type: "ephemeral";
347
+ readonly ttl?: string | undefined;
348
+ } | undefined;
349
+ }[] | undefined;
350
+ tool_choice: "required" | "none" | "auto" | {
351
+ type: "function";
352
+ function: {
353
+ name: string;
354
+ };
355
+ } | undefined;
356
+ stream: true;
357
+ stream_options: {
358
+ include_usage: boolean;
359
+ };
360
+ } | {
361
+ reasoning_effort?: string | undefined;
362
+ prompt_cache_key?: string | undefined;
363
+ store?: boolean | undefined;
364
+ temperature: number | undefined;
365
+ top_p: number | undefined;
366
+ frequency_penalty: number | undefined;
367
+ presence_penalty: number | undefined;
368
+ seed: number | undefined;
369
+ stop: readonly string[] | undefined;
370
+ max_tokens: number | undefined;
371
+ model: string & import("effect/Brand").Brand<"AI.ModelID">;
372
+ messages: ({
373
+ readonly role: "system";
374
+ readonly content: string | readonly ({
375
+ readonly type: "text";
376
+ readonly text: string;
377
+ readonly cache_control?: {
378
+ readonly type: "ephemeral";
379
+ readonly ttl?: string | undefined;
380
+ } | undefined;
381
+ } | {
382
+ readonly type: "image_url";
383
+ readonly image_url: {
384
+ readonly url: string;
385
+ };
386
+ })[];
387
+ } | {
388
+ readonly role: "user";
389
+ readonly content: string | readonly ({
390
+ readonly type: "text";
391
+ readonly text: string;
392
+ readonly cache_control?: {
393
+ readonly type: "ephemeral";
394
+ readonly ttl?: string | undefined;
395
+ } | undefined;
396
+ } | {
397
+ readonly type: "image_url";
398
+ readonly image_url: {
399
+ readonly url: string;
400
+ };
401
+ })[];
402
+ } | {
403
+ readonly [x: string]: unknown;
404
+ readonly content: string | null;
405
+ readonly role: "assistant";
406
+ readonly reasoning?: string | undefined;
407
+ readonly reasoning_content?: string | undefined;
408
+ readonly reasoning_text?: string | undefined;
409
+ readonly cache_control?: {
410
+ readonly type: "ephemeral";
411
+ readonly ttl?: string | undefined;
412
+ } | undefined;
413
+ readonly tool_calls?: readonly {
414
+ readonly id: string;
415
+ readonly type: "function";
416
+ readonly function: {
417
+ readonly name: string;
418
+ readonly arguments: string;
419
+ };
420
+ }[] | undefined;
421
+ readonly reasoning_details?: unknown;
422
+ } | {
423
+ readonly content: string;
424
+ readonly role: "tool";
425
+ readonly tool_call_id: string;
426
+ readonly cache_control?: {
427
+ readonly type: "ephemeral";
428
+ readonly ttl?: string | undefined;
429
+ } | undefined;
430
+ })[];
431
+ tools: {
432
+ readonly function: {
433
+ readonly name: string;
434
+ readonly description: string;
435
+ readonly parameters: {
436
+ readonly [x: string]: unknown;
437
+ };
438
+ };
439
+ readonly type: "function";
440
+ readonly cache_control?: {
441
+ readonly type: "ephemeral";
442
+ readonly ttl?: string | undefined;
443
+ } | undefined;
444
+ }[] | undefined;
445
+ tool_choice: "required" | "none" | "auto" | {
446
+ type: "function";
447
+ function: {
448
+ name: string;
449
+ };
450
+ } | undefined;
451
+ stream: true;
452
+ stream_options: {
453
+ include_usage: boolean;
454
+ };
455
+ }, AIError, never>;
456
+ /**
457
+ * The OpenAI Chat protocol — request body construction, body schema, and the
458
+ * streaming-event state machine. Reused by every route that speaks OpenAI Chat
459
+ * over HTTP+SSE: native OpenAI, DeepSeek, TogetherAI, Cerebras, Baseten,
460
+ * Fireworks, DeepInfra, and (once added) Azure OpenAI Chat.
461
+ */
462
+ export declare const protocol: Protocol<{
463
+ readonly model: string;
464
+ readonly messages: readonly ({
465
+ readonly role: "system";
466
+ readonly content: string | readonly ({
467
+ readonly type: "text";
468
+ readonly text: string;
469
+ readonly cache_control?: {
470
+ readonly type: "ephemeral";
471
+ readonly ttl?: string | undefined;
472
+ } | undefined;
473
+ } | {
474
+ readonly type: "image_url";
475
+ readonly image_url: {
476
+ readonly url: string;
477
+ };
478
+ })[];
479
+ } | {
480
+ readonly role: "user";
481
+ readonly content: string | readonly ({
482
+ readonly type: "text";
483
+ readonly text: string;
484
+ readonly cache_control?: {
485
+ readonly type: "ephemeral";
486
+ readonly ttl?: string | undefined;
487
+ } | undefined;
488
+ } | {
489
+ readonly type: "image_url";
490
+ readonly image_url: {
491
+ readonly url: string;
492
+ };
493
+ })[];
494
+ } | {
495
+ readonly [x: string]: unknown;
496
+ readonly content: string | null;
497
+ readonly role: "assistant";
498
+ readonly reasoning?: string | undefined;
499
+ readonly reasoning_content?: string | undefined;
500
+ readonly reasoning_text?: string | undefined;
501
+ readonly cache_control?: {
502
+ readonly type: "ephemeral";
503
+ readonly ttl?: string | undefined;
504
+ } | undefined;
505
+ readonly tool_calls?: readonly {
506
+ readonly id: string;
507
+ readonly type: "function";
508
+ readonly function: {
509
+ readonly name: string;
510
+ readonly arguments: string;
511
+ };
512
+ }[] | undefined;
513
+ readonly reasoning_details?: unknown;
514
+ } | {
515
+ readonly content: string;
516
+ readonly role: "tool";
517
+ readonly tool_call_id: string;
518
+ readonly cache_control?: {
519
+ readonly type: "ephemeral";
520
+ readonly ttl?: string | undefined;
521
+ } | undefined;
522
+ })[];
523
+ readonly stream: true;
524
+ readonly stop?: readonly string[] | undefined;
525
+ readonly max_completion_tokens?: number | undefined;
526
+ readonly max_tokens?: number | undefined;
527
+ readonly tools?: readonly {
528
+ readonly function: {
529
+ readonly name: string;
530
+ readonly description: string;
531
+ readonly parameters: {
532
+ readonly [x: string]: unknown;
533
+ };
534
+ };
535
+ readonly type: "function";
536
+ readonly cache_control?: {
537
+ readonly type: "ephemeral";
538
+ readonly ttl?: string | undefined;
539
+ } | undefined;
540
+ }[] | undefined;
541
+ readonly temperature?: number | undefined;
542
+ readonly seed?: number | undefined;
543
+ readonly tool_choice?: "required" | "none" | "auto" | {
544
+ readonly type: "function";
545
+ readonly function: {
546
+ readonly name: string;
547
+ };
548
+ } | undefined;
549
+ readonly top_p?: number | undefined;
550
+ readonly store?: boolean | undefined;
551
+ readonly stream_options?: {
552
+ readonly include_usage: boolean;
553
+ } | undefined;
554
+ readonly prompt_cache_key?: string | undefined;
555
+ readonly reasoning_effort?: string | undefined;
556
+ readonly frequency_penalty?: number | undefined;
557
+ readonly presence_penalty?: number | undefined;
558
+ }, string, {
559
+ readonly error?: {
560
+ readonly message: string;
561
+ readonly code?: string | number | null | undefined;
562
+ } | null | undefined;
563
+ readonly usage?: {
564
+ readonly [x: string]: unknown;
565
+ readonly prompt_tokens?: number | null | undefined;
566
+ readonly completion_tokens?: number | null | undefined;
567
+ readonly total_tokens?: number | null | undefined;
568
+ readonly prompt_tokens_details?: {
569
+ readonly [x: string]: unknown;
570
+ readonly cached_tokens?: number | null | undefined;
571
+ readonly cache_write_tokens?: number | null | undefined;
572
+ } | null | undefined;
573
+ readonly completion_tokens_details?: {
574
+ readonly [x: string]: unknown;
575
+ readonly reasoning_tokens?: number | null | undefined;
576
+ readonly accepted_prediction_tokens?: number | null | undefined;
577
+ readonly rejected_prediction_tokens?: number | null | undefined;
578
+ } | null | undefined;
579
+ } | null | undefined;
580
+ readonly choices?: readonly {
581
+ readonly delta?: {
582
+ readonly [x: string]: unknown;
583
+ readonly reasoning?: string | null | undefined;
584
+ readonly reasoning_content?: string | null | undefined;
585
+ readonly reasoning_text?: string | null | undefined;
586
+ readonly content?: string | null | undefined;
587
+ readonly tool_calls?: readonly {
588
+ readonly function?: {
589
+ readonly name?: string | null | undefined;
590
+ readonly arguments?: string | null | undefined;
591
+ } | null | undefined;
592
+ readonly id?: string | null | undefined;
593
+ readonly index?: number | null | undefined;
594
+ }[] | null | undefined;
595
+ readonly reasoning_details?: unknown;
596
+ } | null | undefined;
597
+ readonly finish_reason?: string | null | undefined;
598
+ readonly native_finish_reason?: string | null | undefined;
599
+ }[] | null | undefined;
600
+ }, ParserState>;
601
+ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
602
+ readonly model: string;
603
+ readonly messages: readonly ({
604
+ readonly role: "system";
605
+ readonly content: string | readonly ({
606
+ readonly type: "text";
607
+ readonly text: string;
608
+ readonly cache_control?: {
609
+ readonly type: "ephemeral";
610
+ readonly ttl?: string | undefined;
611
+ } | undefined;
612
+ } | {
613
+ readonly type: "image_url";
614
+ readonly image_url: {
615
+ readonly url: string;
616
+ };
617
+ })[];
618
+ } | {
619
+ readonly role: "user";
620
+ readonly content: string | readonly ({
621
+ readonly type: "text";
622
+ readonly text: string;
623
+ readonly cache_control?: {
624
+ readonly type: "ephemeral";
625
+ readonly ttl?: string | undefined;
626
+ } | undefined;
627
+ } | {
628
+ readonly type: "image_url";
629
+ readonly image_url: {
630
+ readonly url: string;
631
+ };
632
+ })[];
633
+ } | {
634
+ readonly [x: string]: unknown;
635
+ readonly content: string | null;
636
+ readonly role: "assistant";
637
+ readonly reasoning?: string | undefined;
638
+ readonly reasoning_content?: string | undefined;
639
+ readonly reasoning_text?: string | undefined;
640
+ readonly cache_control?: {
641
+ readonly type: "ephemeral";
642
+ readonly ttl?: string | undefined;
643
+ } | undefined;
644
+ readonly tool_calls?: readonly {
645
+ readonly id: string;
646
+ readonly type: "function";
647
+ readonly function: {
648
+ readonly name: string;
649
+ readonly arguments: string;
650
+ };
651
+ }[] | undefined;
652
+ readonly reasoning_details?: unknown;
653
+ } | {
654
+ readonly content: string;
655
+ readonly role: "tool";
656
+ readonly tool_call_id: string;
657
+ readonly cache_control?: {
658
+ readonly type: "ephemeral";
659
+ readonly ttl?: string | undefined;
660
+ } | undefined;
661
+ })[];
662
+ readonly stream: true;
663
+ readonly stop?: readonly string[] | undefined;
664
+ readonly max_completion_tokens?: number | undefined;
665
+ readonly max_tokens?: number | undefined;
666
+ readonly tools?: readonly {
667
+ readonly function: {
668
+ readonly name: string;
669
+ readonly description: string;
670
+ readonly parameters: {
671
+ readonly [x: string]: unknown;
672
+ };
673
+ };
674
+ readonly type: "function";
675
+ readonly cache_control?: {
676
+ readonly type: "ephemeral";
677
+ readonly ttl?: string | undefined;
678
+ } | undefined;
679
+ }[] | undefined;
680
+ readonly temperature?: number | undefined;
681
+ readonly seed?: number | undefined;
682
+ readonly tool_choice?: "required" | "none" | "auto" | {
683
+ readonly type: "function";
684
+ readonly function: {
685
+ readonly name: string;
686
+ };
687
+ } | undefined;
688
+ readonly top_p?: number | undefined;
689
+ readonly store?: boolean | undefined;
690
+ readonly stream_options?: {
691
+ readonly include_usage: boolean;
692
+ } | undefined;
693
+ readonly prompt_cache_key?: string | undefined;
694
+ readonly reasoning_effort?: string | undefined;
695
+ readonly frequency_penalty?: number | undefined;
696
+ readonly presence_penalty?: number | undefined;
697
+ }, string>;
698
+ export declare const route: Route<{
699
+ readonly model: string;
700
+ readonly messages: readonly ({
701
+ readonly role: "system";
702
+ readonly content: string | readonly ({
703
+ readonly type: "text";
704
+ readonly text: string;
705
+ readonly cache_control?: {
706
+ readonly type: "ephemeral";
707
+ readonly ttl?: string | undefined;
708
+ } | undefined;
709
+ } | {
710
+ readonly type: "image_url";
711
+ readonly image_url: {
712
+ readonly url: string;
713
+ };
714
+ })[];
715
+ } | {
716
+ readonly role: "user";
717
+ readonly content: string | readonly ({
718
+ readonly type: "text";
719
+ readonly text: string;
720
+ readonly cache_control?: {
721
+ readonly type: "ephemeral";
722
+ readonly ttl?: string | undefined;
723
+ } | undefined;
724
+ } | {
725
+ readonly type: "image_url";
726
+ readonly image_url: {
727
+ readonly url: string;
728
+ };
729
+ })[];
730
+ } | {
731
+ readonly [x: string]: unknown;
732
+ readonly content: string | null;
733
+ readonly role: "assistant";
734
+ readonly reasoning?: string | undefined;
735
+ readonly reasoning_content?: string | undefined;
736
+ readonly reasoning_text?: string | undefined;
737
+ readonly cache_control?: {
738
+ readonly type: "ephemeral";
739
+ readonly ttl?: string | undefined;
740
+ } | undefined;
741
+ readonly tool_calls?: readonly {
742
+ readonly id: string;
743
+ readonly type: "function";
744
+ readonly function: {
745
+ readonly name: string;
746
+ readonly arguments: string;
747
+ };
748
+ }[] | undefined;
749
+ readonly reasoning_details?: unknown;
750
+ } | {
751
+ readonly content: string;
752
+ readonly role: "tool";
753
+ readonly tool_call_id: string;
754
+ readonly cache_control?: {
755
+ readonly type: "ephemeral";
756
+ readonly ttl?: string | undefined;
757
+ } | undefined;
758
+ })[];
759
+ readonly stream: true;
760
+ readonly stop?: readonly string[] | undefined;
761
+ readonly max_completion_tokens?: number | undefined;
762
+ readonly max_tokens?: number | undefined;
763
+ readonly tools?: readonly {
764
+ readonly function: {
765
+ readonly name: string;
766
+ readonly description: string;
767
+ readonly parameters: {
768
+ readonly [x: string]: unknown;
769
+ };
770
+ };
771
+ readonly type: "function";
772
+ readonly cache_control?: {
773
+ readonly type: "ephemeral";
774
+ readonly ttl?: string | undefined;
775
+ } | undefined;
776
+ }[] | undefined;
777
+ readonly temperature?: number | undefined;
778
+ readonly seed?: number | undefined;
779
+ readonly tool_choice?: "required" | "none" | "auto" | {
780
+ readonly type: "function";
781
+ readonly function: {
782
+ readonly name: string;
783
+ };
784
+ } | undefined;
785
+ readonly top_p?: number | undefined;
786
+ readonly store?: boolean | undefined;
787
+ readonly stream_options?: {
788
+ readonly include_usage: boolean;
789
+ } | undefined;
790
+ readonly prompt_cache_key?: string | undefined;
791
+ readonly reasoning_effort?: string | undefined;
792
+ readonly frequency_penalty?: number | undefined;
793
+ readonly presence_penalty?: number | undefined;
794
+ }, HttpTransport.HttpPrepared<string>>;
795
+ export * as OpenAIChat from "./openai-chat.js";