@opencode/ai 0.0.0-beta-19275

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 (252) hide show
  1. package/README.md +682 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +129 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +28 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +103 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +252 -0
  11. package/dist/llm.js +74 -0
  12. package/dist/protocols/anthropic-messages.d.ts +957 -0
  13. package/dist/protocols/anthropic-messages.js +1414 -0
  14. package/dist/protocols/bedrock-converse.d.ts +499 -0
  15. package/dist/protocols/bedrock-converse.js +643 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +97 -0
  18. package/dist/protocols/gemini.d.ts +285 -0
  19. package/dist/protocols/gemini.js +671 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +181 -0
  22. package/dist/protocols/index.d.ts +12 -0
  23. package/dist/protocols/index.js +12 -0
  24. package/dist/protocols/meta-images.d.ts +26 -0
  25. package/dist/protocols/meta-images.js +89 -0
  26. package/dist/protocols/meta-messages.d.ts +350 -0
  27. package/dist/protocols/meta-messages.js +41 -0
  28. package/dist/protocols/meta-responses.d.ts +473 -0
  29. package/dist/protocols/meta-responses.js +173 -0
  30. package/dist/protocols/mistral-chat.d.ts +540 -0
  31. package/dist/protocols/mistral-chat.js +624 -0
  32. package/dist/protocols/open-responses-channel.d.ts +23 -0
  33. package/dist/protocols/open-responses-channel.js +141 -0
  34. package/dist/protocols/open-responses-continuation.d.ts +12 -0
  35. package/dist/protocols/open-responses-continuation.js +161 -0
  36. package/dist/protocols/open-responses.d.ts +1583 -0
  37. package/dist/protocols/open-responses.js +1206 -0
  38. package/dist/protocols/openai-chat.d.ts +860 -0
  39. package/dist/protocols/openai-chat.js +966 -0
  40. package/dist/protocols/openai-compatible-chat.d.ts +109 -0
  41. package/dist/protocols/openai-compatible-chat.js +19 -0
  42. package/dist/protocols/openai-compatible-responses.d.ts +172 -0
  43. package/dist/protocols/openai-compatible-responses.js +18 -0
  44. package/dist/protocols/openai-images.d.ts +32 -0
  45. package/dist/protocols/openai-images.js +183 -0
  46. package/dist/protocols/openai-responses.d.ts +1389 -0
  47. package/dist/protocols/openai-responses.js +260 -0
  48. package/dist/protocols/shared.d.ts +193 -0
  49. package/dist/protocols/shared.js +290 -0
  50. package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
  51. package/dist/protocols/utils/bedrock-auth.js +85 -0
  52. package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
  53. package/dist/protocols/utils/bedrock-cache.js +49 -0
  54. package/dist/protocols/utils/bedrock-media.d.ts +55 -0
  55. package/dist/protocols/utils/bedrock-media.js +73 -0
  56. package/dist/protocols/utils/cache.d.ts +6 -0
  57. package/dist/protocols/utils/cache.js +5 -0
  58. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  59. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  60. package/dist/protocols/utils/image-input.d.ts +21 -0
  61. package/dist/protocols/utils/image-input.js +20 -0
  62. package/dist/protocols/utils/lifecycle.d.ts +24 -0
  63. package/dist/protocols/utils/lifecycle.js +72 -0
  64. package/dist/protocols/utils/meta-image.d.ts +2 -0
  65. package/dist/protocols/utils/meta-image.js +13 -0
  66. package/dist/protocols/utils/open-responses-options.d.ts +56 -0
  67. package/dist/protocols/utils/open-responses-options.js +61 -0
  68. package/dist/protocols/utils/openai-image.d.ts +5 -0
  69. package/dist/protocols/utils/openai-image.js +18 -0
  70. package/dist/protocols/utils/openai-options.d.ts +16 -0
  71. package/dist/protocols/utils/openai-options.js +14 -0
  72. package/dist/protocols/utils/partial-json-options.d.ts +62 -0
  73. package/dist/protocols/utils/partial-json-options.js +52 -0
  74. package/dist/protocols/utils/partial-json.d.ts +8 -0
  75. package/dist/protocols/utils/partial-json.js +279 -0
  76. package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
  77. package/dist/protocols/utils/responses-checkpoint.js +107 -0
  78. package/dist/protocols/utils/responses-compaction.d.ts +4 -0
  79. package/dist/protocols/utils/responses-compaction.js +129 -0
  80. package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
  81. package/dist/protocols/utils/responses-hosted-tools.js +32 -0
  82. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  83. package/dist/protocols/utils/tool-schema.js +54 -0
  84. package/dist/protocols/utils/tool-stream.d.ts +710 -0
  85. package/dist/protocols/utils/tool-stream.js +155 -0
  86. package/dist/protocols/xai-images.d.ts +26 -0
  87. package/dist/protocols/xai-images.js +106 -0
  88. package/dist/protocols/xai-responses.d.ts +250 -0
  89. package/dist/protocols/xai-responses.js +81 -0
  90. package/dist/protocols/zai-images.d.ts +22 -0
  91. package/dist/protocols/zai-images.js +79 -0
  92. package/dist/protocols.d.ts +1 -0
  93. package/dist/protocols.js +1 -0
  94. package/dist/provider-error.d.ts +15 -0
  95. package/dist/provider-error.js +125 -0
  96. package/dist/provider-package.d.ts +11 -0
  97. package/dist/provider-package.js +1 -0
  98. package/dist/provider.d.ts +23 -0
  99. package/dist/provider.js +2 -0
  100. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  101. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  102. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  103. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  104. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  105. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  106. package/dist/providers/amazon-bedrock-mantle.d.ts +371 -0
  107. package/dist/providers/amazon-bedrock-mantle.js +76 -0
  108. package/dist/providers/amazon-bedrock.d.ts +173 -0
  109. package/dist/providers/amazon-bedrock.js +41 -0
  110. package/dist/providers/anthropic-compatible.d.ts +304 -0
  111. package/dist/providers/anthropic-compatible.js +44 -0
  112. package/dist/providers/anthropic.d.ts +302 -0
  113. package/dist/providers/anthropic.js +39 -0
  114. package/dist/providers/azure/chat.d.ts +2 -0
  115. package/dist/providers/azure/chat.js +1 -0
  116. package/dist/providers/azure/responses.d.ts +2 -0
  117. package/dist/providers/azure/responses.js +1 -0
  118. package/dist/providers/azure.d.ts +599 -0
  119. package/dist/providers/azure.js +115 -0
  120. package/dist/providers/baseten.d.ts +229 -0
  121. package/dist/providers/baseten.js +38 -0
  122. package/dist/providers/cerebras.d.ts +228 -0
  123. package/dist/providers/cerebras.js +40 -0
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +238 -0
  125. package/dist/providers/cloudflare-ai-gateway.js +59 -0
  126. package/dist/providers/cloudflare-workers-ai.d.ts +232 -0
  127. package/dist/providers/cloudflare-workers-ai.js +45 -0
  128. package/dist/providers/deepinfra.d.ts +228 -0
  129. package/dist/providers/deepinfra.js +43 -0
  130. package/dist/providers/deepseek.d.ts +229 -0
  131. package/dist/providers/deepseek.js +41 -0
  132. package/dist/providers/fireworks.d.ts +229 -0
  133. package/dist/providers/fireworks.js +38 -0
  134. package/dist/providers/google-vertex/chat.d.ts +2 -0
  135. package/dist/providers/google-vertex/chat.js +1 -0
  136. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  137. package/dist/providers/google-vertex/gemini.js +1 -0
  138. package/dist/providers/google-vertex/messages.d.ts +2 -0
  139. package/dist/providers/google-vertex/messages.js +1 -0
  140. package/dist/providers/google-vertex/responses.d.ts +2 -0
  141. package/dist/providers/google-vertex/responses.js +1 -0
  142. package/dist/providers/google-vertex-chat.d.ts +133 -0
  143. package/dist/providers/google-vertex-chat.js +55 -0
  144. package/dist/providers/google-vertex-messages.d.ts +301 -0
  145. package/dist/providers/google-vertex-messages.js +75 -0
  146. package/dist/providers/google-vertex-responses.d.ts +198 -0
  147. package/dist/providers/google-vertex-responses.js +56 -0
  148. package/dist/providers/google-vertex-shared.d.ts +22 -0
  149. package/dist/providers/google-vertex-shared.js +61 -0
  150. package/dist/providers/google-vertex.d.ts +120 -0
  151. package/dist/providers/google-vertex.js +92 -0
  152. package/dist/providers/google.d.ts +115 -0
  153. package/dist/providers/google.js +42 -0
  154. package/dist/providers/groq.d.ts +315 -0
  155. package/dist/providers/groq.js +81 -0
  156. package/dist/providers/index.d.ts +28 -0
  157. package/dist/providers/index.js +28 -0
  158. package/dist/providers/meta/chat.d.ts +2 -0
  159. package/dist/providers/meta/chat.js +1 -0
  160. package/dist/providers/meta/messages.d.ts +2 -0
  161. package/dist/providers/meta/messages.js +1 -0
  162. package/dist/providers/meta/responses.d.ts +2 -0
  163. package/dist/providers/meta/responses.js +1 -0
  164. package/dist/providers/meta.d.ts +631 -0
  165. package/dist/providers/meta.js +113 -0
  166. package/dist/providers/minimax/chat.d.ts +4 -0
  167. package/dist/providers/minimax/chat.js +8 -0
  168. package/dist/providers/minimax/messages.d.ts +1 -0
  169. package/dist/providers/minimax/messages.js +1 -0
  170. package/dist/providers/minimax/responses.d.ts +4 -0
  171. package/dist/providers/minimax/responses.js +8 -0
  172. package/dist/providers/minimax.d.ts +593 -0
  173. package/dist/providers/minimax.js +89 -0
  174. package/dist/providers/mistral.d.ts +208 -0
  175. package/dist/providers/mistral.js +28 -0
  176. package/dist/providers/open-responses-options.d.ts +6 -0
  177. package/dist/providers/open-responses-options.js +1 -0
  178. package/dist/providers/openai/chat.d.ts +2 -0
  179. package/dist/providers/openai/chat.js +1 -0
  180. package/dist/providers/openai/responses.d.ts +2 -0
  181. package/dist/providers/openai/responses.js +1 -0
  182. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  183. package/dist/providers/openai-compatible/responses.js +1 -0
  184. package/dist/providers/openai-compatible-responses.d.ts +196 -0
  185. package/dist/providers/openai-compatible-responses.js +32 -0
  186. package/dist/providers/openai-compatible.d.ts +131 -0
  187. package/dist/providers/openai-compatible.js +33 -0
  188. package/dist/providers/openai-options.d.ts +26 -0
  189. package/dist/providers/openai-options.js +41 -0
  190. package/dist/providers/openai.d.ts +405 -0
  191. package/dist/providers/openai.js +82 -0
  192. package/dist/providers/openrouter.d.ts +564 -0
  193. package/dist/providers/openrouter.js +114 -0
  194. package/dist/providers/togetherai.d.ts +228 -0
  195. package/dist/providers/togetherai.js +40 -0
  196. package/dist/providers/xai.d.ts +164 -0
  197. package/dist/providers/xai.js +84 -0
  198. package/dist/providers/zai.d.ts +24 -0
  199. package/dist/providers/zai.js +21 -0
  200. package/dist/providers.d.ts +1 -0
  201. package/dist/providers.js +1 -0
  202. package/dist/route/auth-options.d.ts +34 -0
  203. package/dist/route/auth-options.js +14 -0
  204. package/dist/route/auth.d.ts +51 -0
  205. package/dist/route/auth.js +87 -0
  206. package/dist/route/client.d.ts +430 -0
  207. package/dist/route/client.js +304 -0
  208. package/dist/route/endpoint.d.ts +28 -0
  209. package/dist/route/endpoint.js +21 -0
  210. package/dist/route/executor.d.ts +27 -0
  211. package/dist/route/executor.js +183 -0
  212. package/dist/route/framing.d.ts +29 -0
  213. package/dist/route/framing.js +14 -0
  214. package/dist/route/index.d.ts +16 -0
  215. package/dist/route/index.js +9 -0
  216. package/dist/route/protocol.d.ts +76 -0
  217. package/dist/route/protocol.js +16 -0
  218. package/dist/route/transport/http.d.ts +34 -0
  219. package/dist/route/transport/http.js +68 -0
  220. package/dist/route/transport/index.d.ts +41 -0
  221. package/dist/route/transport/index.js +4 -0
  222. package/dist/route/transport/websocket-channel.d.ts +57 -0
  223. package/dist/route/transport/websocket-channel.js +1 -0
  224. package/dist/route/transport/websocket.d.ts +56 -0
  225. package/dist/route/transport/websocket.js +366 -0
  226. package/dist/route.d.ts +1 -0
  227. package/dist/route.js +1 -0
  228. package/dist/schema/errors.d.ts +158 -0
  229. package/dist/schema/errors.js +120 -0
  230. package/dist/schema/events.d.ts +8123 -0
  231. package/dist/schema/events.js +550 -0
  232. package/dist/schema/ids.d.ts +17 -0
  233. package/dist/schema/ids.js +10 -0
  234. package/dist/schema/index.d.ts +5 -0
  235. package/dist/schema/index.js +5 -0
  236. package/dist/schema/messages.d.ts +646 -0
  237. package/dist/schema/messages.js +301 -0
  238. package/dist/schema/options.d.ts +157 -0
  239. package/dist/schema/options.js +187 -0
  240. package/dist/testing.d.ts +1693 -0
  241. package/dist/testing.js +129 -0
  242. package/dist/tool-history.d.ts +2 -0
  243. package/dist/tool-history.js +84 -0
  244. package/dist/tool-runtime.d.ts +15 -0
  245. package/dist/tool-runtime.js +62 -0
  246. package/dist/tool.d.ts +136 -0
  247. package/dist/tool.js +66 -0
  248. package/dist/utils/record.d.ts +2 -0
  249. package/dist/utils/record.js +2 -0
  250. package/dist/utils/sanitize.d.ts +1 -0
  251. package/dist/utils/sanitize.js +12 -0
  252. package/package.json +48 -0
@@ -0,0 +1,350 @@
1
+ import { Protocol } from "../route/protocol.js";
2
+ export declare const protocol: Protocol<{
3
+ readonly max_tokens: number;
4
+ readonly model: string;
5
+ readonly messages: readonly ({
6
+ readonly role: "user";
7
+ readonly content: readonly ({
8
+ readonly type: "text";
9
+ readonly text: string;
10
+ readonly cache_control?: {
11
+ readonly type: "ephemeral";
12
+ readonly ttl?: "1h" | "5m" | undefined;
13
+ } | undefined;
14
+ } | {
15
+ readonly type: "image";
16
+ readonly source: {
17
+ readonly type: "base64";
18
+ readonly media_type: string;
19
+ readonly data: string;
20
+ } | {
21
+ readonly type: "url";
22
+ readonly url: string;
23
+ } | {
24
+ readonly type: "file";
25
+ readonly file_id: string;
26
+ };
27
+ readonly cache_control?: {
28
+ readonly type: "ephemeral";
29
+ readonly ttl?: "1h" | "5m" | undefined;
30
+ } | undefined;
31
+ readonly transformations?: {
32
+ readonly oversized_image?: "error" | "downsize" | undefined;
33
+ } | undefined;
34
+ } | {
35
+ readonly type: "document";
36
+ readonly source: {
37
+ readonly type: "base64";
38
+ readonly media_type: "application/pdf";
39
+ readonly data: string;
40
+ } | {
41
+ readonly type: "text";
42
+ readonly media_type: "text/plain";
43
+ readonly data: string;
44
+ } | {
45
+ readonly type: "url";
46
+ readonly url: string;
47
+ } | {
48
+ readonly type: "file";
49
+ readonly file_id: string;
50
+ };
51
+ readonly title?: string | undefined;
52
+ readonly context?: string | undefined;
53
+ readonly cache_control?: {
54
+ readonly type: "ephemeral";
55
+ readonly ttl?: "1h" | "5m" | undefined;
56
+ } | undefined;
57
+ readonly citations?: {
58
+ readonly enabled: boolean;
59
+ } | undefined;
60
+ } | {
61
+ readonly type: "tool_result";
62
+ readonly content: string | readonly ({
63
+ readonly type: "text";
64
+ readonly text: string;
65
+ readonly cache_control?: {
66
+ readonly type: "ephemeral";
67
+ readonly ttl?: "1h" | "5m" | undefined;
68
+ } | undefined;
69
+ } | {
70
+ readonly type: "image";
71
+ readonly source: {
72
+ readonly type: "base64";
73
+ readonly media_type: string;
74
+ readonly data: string;
75
+ } | {
76
+ readonly type: "url";
77
+ readonly url: string;
78
+ } | {
79
+ readonly type: "file";
80
+ readonly file_id: string;
81
+ };
82
+ readonly cache_control?: {
83
+ readonly type: "ephemeral";
84
+ readonly ttl?: "1h" | "5m" | undefined;
85
+ } | undefined;
86
+ readonly transformations?: {
87
+ readonly oversized_image?: "error" | "downsize" | undefined;
88
+ } | undefined;
89
+ } | {
90
+ readonly type: "document";
91
+ readonly source: {
92
+ readonly type: "base64";
93
+ readonly media_type: "application/pdf";
94
+ readonly data: string;
95
+ } | {
96
+ readonly type: "text";
97
+ readonly media_type: "text/plain";
98
+ readonly data: string;
99
+ } | {
100
+ readonly type: "url";
101
+ readonly url: string;
102
+ } | {
103
+ readonly type: "file";
104
+ readonly file_id: string;
105
+ };
106
+ readonly title?: string | undefined;
107
+ readonly context?: string | undefined;
108
+ readonly cache_control?: {
109
+ readonly type: "ephemeral";
110
+ readonly ttl?: "1h" | "5m" | undefined;
111
+ } | undefined;
112
+ readonly citations?: {
113
+ readonly enabled: boolean;
114
+ } | undefined;
115
+ })[];
116
+ readonly tool_use_id: string;
117
+ readonly cache_control?: {
118
+ readonly type: "ephemeral";
119
+ readonly ttl?: "1h" | "5m" | undefined;
120
+ } | undefined;
121
+ readonly is_error?: boolean | undefined;
122
+ })[];
123
+ } | {
124
+ readonly role: "assistant";
125
+ readonly content: readonly ({
126
+ readonly type: "text";
127
+ readonly text: string;
128
+ readonly cache_control?: {
129
+ readonly type: "ephemeral";
130
+ readonly ttl?: "1h" | "5m" | undefined;
131
+ } | undefined;
132
+ } | {
133
+ readonly id: string;
134
+ readonly type: "tool_use";
135
+ readonly name: string;
136
+ readonly input: unknown;
137
+ readonly cache_control?: {
138
+ readonly type: "ephemeral";
139
+ readonly ttl?: "1h" | "5m" | undefined;
140
+ } | undefined;
141
+ } | {
142
+ readonly id: string;
143
+ readonly type: "server_tool_use";
144
+ readonly name: string;
145
+ readonly input: unknown;
146
+ readonly cache_control?: {
147
+ readonly type: "ephemeral";
148
+ readonly ttl?: "1h" | "5m" | undefined;
149
+ } | undefined;
150
+ } | {
151
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
152
+ readonly content: unknown;
153
+ readonly tool_use_id: string;
154
+ readonly cache_control?: {
155
+ readonly type: "ephemeral";
156
+ readonly ttl?: "1h" | "5m" | undefined;
157
+ } | undefined;
158
+ } | {
159
+ readonly type: "thinking";
160
+ readonly thinking: string;
161
+ readonly signature: string;
162
+ readonly cache_control?: {
163
+ readonly type: "ephemeral";
164
+ readonly ttl?: "1h" | "5m" | undefined;
165
+ } | undefined;
166
+ } | {
167
+ readonly data: string;
168
+ readonly type: "redacted_thinking";
169
+ readonly cache_control?: {
170
+ readonly type: "ephemeral";
171
+ readonly ttl?: "1h" | "5m" | undefined;
172
+ } | undefined;
173
+ } | {
174
+ readonly type: "compaction";
175
+ readonly content: string | null;
176
+ })[];
177
+ } | {
178
+ readonly role: "system";
179
+ readonly content: readonly {
180
+ readonly type: "text";
181
+ readonly text: string;
182
+ readonly cache_control?: {
183
+ readonly type: "ephemeral";
184
+ readonly ttl?: "1h" | "5m" | undefined;
185
+ } | undefined;
186
+ }[];
187
+ })[];
188
+ readonly stream: true;
189
+ readonly metadata?: {
190
+ readonly user_id?: string | null | undefined;
191
+ } | undefined;
192
+ readonly tools?: readonly ({
193
+ readonly type: "web_search";
194
+ readonly name: "web_search";
195
+ readonly user_location?: {
196
+ readonly type: "approximate";
197
+ readonly region?: string | undefined;
198
+ readonly city?: string | undefined;
199
+ readonly country?: string | undefined;
200
+ readonly timezone?: string | undefined;
201
+ } | undefined;
202
+ } | {
203
+ readonly name: string;
204
+ readonly description: string;
205
+ readonly input_schema: {
206
+ readonly [x: string]: unknown;
207
+ };
208
+ })[] | undefined;
209
+ readonly system?: readonly {
210
+ readonly type: "text";
211
+ readonly text: string;
212
+ readonly cache_control?: {
213
+ readonly type: "ephemeral";
214
+ readonly ttl?: "1h" | "5m" | undefined;
215
+ } | undefined;
216
+ }[] | undefined;
217
+ readonly temperature?: number | undefined;
218
+ readonly thinking?: {
219
+ readonly type: "enabled";
220
+ readonly budget_tokens: number;
221
+ readonly display?: "summarized" | "omitted" | undefined;
222
+ } | {
223
+ readonly type: "adaptive";
224
+ readonly display?: "summarized" | "omitted" | undefined;
225
+ } | {
226
+ readonly type: "disabled";
227
+ } | undefined;
228
+ readonly service_tier?: "auto" | "standard_only" | undefined;
229
+ readonly container?: string | {
230
+ readonly id?: string | null | undefined;
231
+ readonly skills?: readonly {
232
+ readonly [x: string]: unknown;
233
+ }[] | null | undefined;
234
+ } | null | undefined;
235
+ readonly inference_geo?: string | null | undefined;
236
+ readonly cache_control?: {
237
+ readonly type: "ephemeral";
238
+ readonly ttl?: "1h" | "5m" | undefined;
239
+ } | undefined;
240
+ readonly output_config?: {
241
+ readonly format?: {
242
+ readonly type: "json_schema";
243
+ readonly schema: {
244
+ readonly [x: string]: unknown;
245
+ };
246
+ } | null | undefined;
247
+ readonly effort?: string | undefined;
248
+ } | undefined;
249
+ readonly context_management?: {
250
+ readonly edits: readonly {
251
+ readonly type: "compact_20260112";
252
+ readonly instructions?: string | undefined;
253
+ readonly trigger?: {
254
+ readonly type: "input_tokens";
255
+ readonly value: number;
256
+ } | undefined;
257
+ readonly pause_after_compaction?: boolean | undefined;
258
+ }[];
259
+ } | undefined;
260
+ readonly tool_choice?: {
261
+ readonly type: "auto" | "none" | "any";
262
+ readonly disable_parallel_tool_use?: boolean | undefined;
263
+ } | {
264
+ readonly type: "tool";
265
+ readonly name: string;
266
+ readonly disable_parallel_tool_use?: boolean | undefined;
267
+ } | undefined;
268
+ readonly top_p?: number | undefined;
269
+ readonly top_k?: number | undefined;
270
+ readonly stop_sequences?: readonly string[] | undefined;
271
+ }, string, {
272
+ readonly type: string;
273
+ readonly message?: {
274
+ readonly usage?: {
275
+ readonly [x: string]: unknown;
276
+ readonly input_tokens?: number | null | undefined;
277
+ readonly server_tool_use?: {
278
+ readonly [x: string]: unknown;
279
+ readonly web_search_requests?: number | undefined;
280
+ } | null | undefined;
281
+ readonly output_tokens?: number | undefined;
282
+ readonly cache_creation_input_tokens?: number | null | undefined;
283
+ readonly cache_read_input_tokens?: number | null | undefined;
284
+ readonly output_tokens_details?: {
285
+ readonly [x: string]: unknown;
286
+ readonly thinking_tokens?: number | undefined;
287
+ } | null | undefined;
288
+ readonly iterations?: readonly {
289
+ readonly [x: string]: unknown;
290
+ readonly input_tokens?: number | null | undefined;
291
+ readonly server_tool_use?: {
292
+ readonly [x: string]: unknown;
293
+ readonly web_search_requests?: number | undefined;
294
+ } | null | undefined;
295
+ readonly output_tokens?: number | undefined;
296
+ readonly cache_creation_input_tokens?: number | null | undefined;
297
+ readonly cache_read_input_tokens?: number | null | undefined;
298
+ readonly output_tokens_details?: {
299
+ readonly [x: string]: unknown;
300
+ readonly thinking_tokens?: number | undefined;
301
+ } | null | undefined;
302
+ }[] | undefined;
303
+ } | undefined;
304
+ } | undefined;
305
+ readonly error?: {
306
+ readonly type?: string | undefined;
307
+ readonly message?: string | undefined;
308
+ } | undefined;
309
+ readonly delta?: unknown;
310
+ readonly index?: number | undefined;
311
+ readonly usage?: {
312
+ readonly [x: string]: unknown;
313
+ readonly input_tokens?: number | null | undefined;
314
+ readonly server_tool_use?: {
315
+ readonly [x: string]: unknown;
316
+ readonly web_search_requests?: number | undefined;
317
+ } | null | undefined;
318
+ readonly output_tokens?: number | undefined;
319
+ readonly cache_creation_input_tokens?: number | null | undefined;
320
+ readonly cache_read_input_tokens?: number | null | undefined;
321
+ readonly output_tokens_details?: {
322
+ readonly [x: string]: unknown;
323
+ readonly thinking_tokens?: number | undefined;
324
+ } | null | undefined;
325
+ readonly iterations?: readonly {
326
+ readonly [x: string]: unknown;
327
+ readonly input_tokens?: number | null | undefined;
328
+ readonly server_tool_use?: {
329
+ readonly [x: string]: unknown;
330
+ readonly web_search_requests?: number | undefined;
331
+ } | null | undefined;
332
+ readonly output_tokens?: number | undefined;
333
+ readonly cache_creation_input_tokens?: number | null | undefined;
334
+ readonly cache_read_input_tokens?: number | null | undefined;
335
+ readonly output_tokens_details?: {
336
+ readonly [x: string]: unknown;
337
+ readonly thinking_tokens?: number | undefined;
338
+ } | null | undefined;
339
+ }[] | undefined;
340
+ } | undefined;
341
+ readonly content_block?: unknown;
342
+ }, {
343
+ provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
344
+ compactions: {};
345
+ providerMetadataKey: string;
346
+ tools: Partial<Record<number, import("./utils/tool-stream.js").PendingTool>>;
347
+ reasoningSignatures: {};
348
+ lifecycle: import("./utils/lifecycle.js").State;
349
+ }>;
350
+ export * as MetaMessages from "./meta-messages.js";
@@ -0,0 +1,41 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { Protocol } from "../route/protocol.js";
3
+ import { AnthropicMessages } from "./anthropic-messages.js";
4
+ import { MetaResponses } from "./meta-responses.js";
5
+ import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
6
+ const WebSearch = Schema.Struct({
7
+ type: Schema.Literal("web_search"),
8
+ name: Schema.Literal("web_search"),
9
+ user_location: MetaResponses.WebSearch.fields.user_location,
10
+ });
11
+ const Body = Schema.Struct({
12
+ ...AnthropicMessages.AnthropicMessagesBody.fields,
13
+ tools: optionalArray(Schema.Union([
14
+ Schema.Struct({ name: Schema.String, description: Schema.String, input_schema: JsonObject }),
15
+ WebSearch,
16
+ ])),
17
+ });
18
+ const fromRequest = Effect.fn("MetaMessages.fromRequest")(function* (request) {
19
+ const projected = ProviderShared.flattenToolRequest(request);
20
+ const body = yield* AnthropicMessages.protocol.body.from(projected.request);
21
+ return {
22
+ ...body,
23
+ tools: body.tools === undefined
24
+ ? undefined
25
+ : yield* Effect.forEach(body.tools, (tool, index) => Effect.gen(function* () {
26
+ const native = projected.tools[index]?.native;
27
+ if (native === undefined)
28
+ return tool;
29
+ const search = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(MetaResponses.WebSearch))(native.meta);
30
+ if (search.search_context_size !== undefined)
31
+ return yield* ProviderShared.invalidRequest("Meta Messages does not support searchContextSize");
32
+ return { type: "web_search", name: "web_search", user_location: search.user_location };
33
+ })),
34
+ };
35
+ });
36
+ export const protocol = Protocol.make({
37
+ id: "meta-messages",
38
+ body: { schema: Body, from: fromRequest },
39
+ stream: AnthropicMessages.protocol.stream,
40
+ });
41
+ export * as MetaMessages from "./meta-messages.js";