@opencode/ai 0.0.0-reserved → 2.0.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 (288) hide show
  1. package/README.md +879 -2
  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/alibaba-chat.d.ts +225 -0
  13. package/dist/protocols/alibaba-chat.js +75 -0
  14. package/dist/protocols/alibaba-messages.d.ts +350 -0
  15. package/dist/protocols/alibaba-messages.js +40 -0
  16. package/dist/protocols/alibaba-responses.d.ts +255 -0
  17. package/dist/protocols/alibaba-responses.js +80 -0
  18. package/dist/protocols/anthropic-messages.d.ts +980 -0
  19. package/dist/protocols/anthropic-messages.js +1460 -0
  20. package/dist/protocols/bedrock-converse.d.ts +499 -0
  21. package/dist/protocols/bedrock-converse.js +643 -0
  22. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  23. package/dist/protocols/bedrock-event-stream.js +97 -0
  24. package/dist/protocols/gemini.d.ts +285 -0
  25. package/dist/protocols/gemini.js +671 -0
  26. package/dist/protocols/google-images.d.ts +30 -0
  27. package/dist/protocols/google-images.js +181 -0
  28. package/dist/protocols/index.d.ts +12 -0
  29. package/dist/protocols/index.js +12 -0
  30. package/dist/protocols/meta-images.d.ts +26 -0
  31. package/dist/protocols/meta-images.js +89 -0
  32. package/dist/protocols/meta-messages.d.ts +356 -0
  33. package/dist/protocols/meta-messages.js +41 -0
  34. package/dist/protocols/meta-responses.d.ts +473 -0
  35. package/dist/protocols/meta-responses.js +173 -0
  36. package/dist/protocols/mistral-chat.d.ts +540 -0
  37. package/dist/protocols/mistral-chat.js +624 -0
  38. package/dist/protocols/open-responses-channel.d.ts +25 -0
  39. package/dist/protocols/open-responses-channel.js +141 -0
  40. package/dist/protocols/open-responses-continuation.d.ts +16 -0
  41. package/dist/protocols/open-responses-continuation.js +170 -0
  42. package/dist/protocols/open-responses.d.ts +1715 -0
  43. package/dist/protocols/open-responses.js +1228 -0
  44. package/dist/protocols/openai-chat.d.ts +860 -0
  45. package/dist/protocols/openai-chat.js +966 -0
  46. package/dist/protocols/openai-compatible-chat.d.ts +109 -0
  47. package/dist/protocols/openai-compatible-chat.js +19 -0
  48. package/dist/protocols/openai-compatible-responses.d.ts +172 -0
  49. package/dist/protocols/openai-compatible-responses.js +18 -0
  50. package/dist/protocols/openai-images.d.ts +32 -0
  51. package/dist/protocols/openai-images.js +183 -0
  52. package/dist/protocols/openai-responses.d.ts +1389 -0
  53. package/dist/protocols/openai-responses.js +260 -0
  54. package/dist/protocols/shared.d.ts +193 -0
  55. package/dist/protocols/shared.js +290 -0
  56. package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
  57. package/dist/protocols/utils/bedrock-auth.js +85 -0
  58. package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
  59. package/dist/protocols/utils/bedrock-cache.js +49 -0
  60. package/dist/protocols/utils/bedrock-media.d.ts +55 -0
  61. package/dist/protocols/utils/bedrock-media.js +73 -0
  62. package/dist/protocols/utils/cache.d.ts +6 -0
  63. package/dist/protocols/utils/cache.js +5 -0
  64. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  65. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  66. package/dist/protocols/utils/image-input.d.ts +21 -0
  67. package/dist/protocols/utils/image-input.js +20 -0
  68. package/dist/protocols/utils/lifecycle.d.ts +24 -0
  69. package/dist/protocols/utils/lifecycle.js +72 -0
  70. package/dist/protocols/utils/meta-image.d.ts +2 -0
  71. package/dist/protocols/utils/meta-image.js +13 -0
  72. package/dist/protocols/utils/open-responses-options.d.ts +56 -0
  73. package/dist/protocols/utils/open-responses-options.js +61 -0
  74. package/dist/protocols/utils/openai-image.d.ts +5 -0
  75. package/dist/protocols/utils/openai-image.js +18 -0
  76. package/dist/protocols/utils/openai-options.d.ts +16 -0
  77. package/dist/protocols/utils/openai-options.js +14 -0
  78. package/dist/protocols/utils/partial-json-options.d.ts +62 -0
  79. package/dist/protocols/utils/partial-json-options.js +52 -0
  80. package/dist/protocols/utils/partial-json.d.ts +8 -0
  81. package/dist/protocols/utils/partial-json.js +279 -0
  82. package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
  83. package/dist/protocols/utils/responses-checkpoint.js +107 -0
  84. package/dist/protocols/utils/responses-compaction.d.ts +4 -0
  85. package/dist/protocols/utils/responses-compaction.js +129 -0
  86. package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
  87. package/dist/protocols/utils/responses-hosted-tools.js +32 -0
  88. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  89. package/dist/protocols/utils/tool-schema.js +54 -0
  90. package/dist/protocols/utils/tool-stream.d.ts +710 -0
  91. package/dist/protocols/utils/tool-stream.js +155 -0
  92. package/dist/protocols/xai-images.d.ts +26 -0
  93. package/dist/protocols/xai-images.js +106 -0
  94. package/dist/protocols/xai-responses.d.ts +250 -0
  95. package/dist/protocols/xai-responses.js +81 -0
  96. package/dist/protocols/zai-chat.d.ts +202 -0
  97. package/dist/protocols/zai-chat.js +49 -0
  98. package/dist/protocols/zai-images.d.ts +22 -0
  99. package/dist/protocols/zai-images.js +79 -0
  100. package/dist/protocols/zai-messages.d.ts +344 -0
  101. package/dist/protocols/zai-messages.js +27 -0
  102. package/dist/protocols.d.ts +1 -0
  103. package/dist/protocols.js +1 -0
  104. package/dist/provider-error.d.ts +15 -0
  105. package/dist/provider-error.js +125 -0
  106. package/dist/provider-package.d.ts +15 -0
  107. package/dist/provider-package.js +1 -0
  108. package/dist/provider.d.ts +23 -0
  109. package/dist/provider.js +2 -0
  110. package/dist/providers/alibaba/chat.d.ts +1 -0
  111. package/dist/providers/alibaba/chat.js +1 -0
  112. package/dist/providers/alibaba/messages.d.ts +3 -0
  113. package/dist/providers/alibaba/messages.js +1 -0
  114. package/dist/providers/alibaba/responses.d.ts +3 -0
  115. package/dist/providers/alibaba/responses.js +1 -0
  116. package/dist/providers/alibaba.d.ts +711 -0
  117. package/dist/providers/alibaba.js +94 -0
  118. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  119. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  120. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  121. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  122. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  123. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  124. package/dist/providers/amazon-bedrock-mantle.d.ts +313 -0
  125. package/dist/providers/amazon-bedrock-mantle.js +79 -0
  126. package/dist/providers/amazon-bedrock.d.ts +173 -0
  127. package/dist/providers/amazon-bedrock.js +41 -0
  128. package/dist/providers/anthropic-compatible.d.ts +309 -0
  129. package/dist/providers/anthropic-compatible.js +50 -0
  130. package/dist/providers/anthropic.d.ts +307 -0
  131. package/dist/providers/anthropic.js +42 -0
  132. package/dist/providers/azure/chat.d.ts +2 -0
  133. package/dist/providers/azure/chat.js +1 -0
  134. package/dist/providers/azure/responses.d.ts +2 -0
  135. package/dist/providers/azure/responses.js +1 -0
  136. package/dist/providers/azure.d.ts +598 -0
  137. package/dist/providers/azure.js +115 -0
  138. package/dist/providers/baseten.d.ts +228 -0
  139. package/dist/providers/baseten.js +38 -0
  140. package/dist/providers/cerebras.d.ts +227 -0
  141. package/dist/providers/cerebras.js +40 -0
  142. package/dist/providers/cloudflare-ai-gateway.d.ts +237 -0
  143. package/dist/providers/cloudflare-ai-gateway.js +65 -0
  144. package/dist/providers/cloudflare-workers-ai.d.ts +231 -0
  145. package/dist/providers/cloudflare-workers-ai.js +51 -0
  146. package/dist/providers/deepinfra.d.ts +227 -0
  147. package/dist/providers/deepinfra.js +43 -0
  148. package/dist/providers/deepseek.d.ts +228 -0
  149. package/dist/providers/deepseek.js +41 -0
  150. package/dist/providers/fireworks.d.ts +228 -0
  151. package/dist/providers/fireworks.js +38 -0
  152. package/dist/providers/google-vertex/chat.d.ts +2 -0
  153. package/dist/providers/google-vertex/chat.js +1 -0
  154. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  155. package/dist/providers/google-vertex/gemini.js +1 -0
  156. package/dist/providers/google-vertex/messages.d.ts +2 -0
  157. package/dist/providers/google-vertex/messages.js +1 -0
  158. package/dist/providers/google-vertex/responses.d.ts +2 -0
  159. package/dist/providers/google-vertex/responses.js +1 -0
  160. package/dist/providers/google-vertex-chat.d.ts +132 -0
  161. package/dist/providers/google-vertex-chat.js +55 -0
  162. package/dist/providers/google-vertex-messages.d.ts +306 -0
  163. package/dist/providers/google-vertex-messages.js +75 -0
  164. package/dist/providers/google-vertex-responses.d.ts +197 -0
  165. package/dist/providers/google-vertex-responses.js +56 -0
  166. package/dist/providers/google-vertex-shared.d.ts +22 -0
  167. package/dist/providers/google-vertex-shared.js +72 -0
  168. package/dist/providers/google-vertex.d.ts +119 -0
  169. package/dist/providers/google-vertex.js +98 -0
  170. package/dist/providers/google.d.ts +114 -0
  171. package/dist/providers/google.js +42 -0
  172. package/dist/providers/groq.d.ts +314 -0
  173. package/dist/providers/groq.js +81 -0
  174. package/dist/providers/index.d.ts +31 -0
  175. package/dist/providers/index.js +31 -0
  176. package/dist/providers/meta/chat.d.ts +2 -0
  177. package/dist/providers/meta/chat.js +1 -0
  178. package/dist/providers/meta/messages.d.ts +2 -0
  179. package/dist/providers/meta/messages.js +1 -0
  180. package/dist/providers/meta/responses.d.ts +2 -0
  181. package/dist/providers/meta/responses.js +1 -0
  182. package/dist/providers/meta.d.ts +636 -0
  183. package/dist/providers/meta.js +113 -0
  184. package/dist/providers/minimax/chat.d.ts +4 -0
  185. package/dist/providers/minimax/chat.js +8 -0
  186. package/dist/providers/minimax/messages.d.ts +1 -0
  187. package/dist/providers/minimax/messages.js +1 -0
  188. package/dist/providers/minimax/responses.d.ts +4 -0
  189. package/dist/providers/minimax/responses.js +8 -0
  190. package/dist/providers/minimax.d.ts +598 -0
  191. package/dist/providers/minimax.js +89 -0
  192. package/dist/providers/mistral.d.ts +207 -0
  193. package/dist/providers/mistral.js +28 -0
  194. package/dist/providers/moonshot/chat.d.ts +1 -0
  195. package/dist/providers/moonshot/chat.js +1 -0
  196. package/dist/providers/moonshot/messages.d.ts +4 -0
  197. package/dist/providers/moonshot/messages.js +8 -0
  198. package/dist/providers/moonshot/responses.d.ts +4 -0
  199. package/dist/providers/moonshot/responses.js +8 -0
  200. package/dist/providers/moonshot.d.ts +596 -0
  201. package/dist/providers/moonshot.js +90 -0
  202. package/dist/providers/open-responses-options.d.ts +6 -0
  203. package/dist/providers/open-responses-options.js +1 -0
  204. package/dist/providers/openai/chat.d.ts +2 -0
  205. package/dist/providers/openai/chat.js +1 -0
  206. package/dist/providers/openai/responses.d.ts +2 -0
  207. package/dist/providers/openai/responses.js +1 -0
  208. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  209. package/dist/providers/openai-compatible/responses.js +1 -0
  210. package/dist/providers/openai-compatible-responses.d.ts +195 -0
  211. package/dist/providers/openai-compatible-responses.js +32 -0
  212. package/dist/providers/openai-compatible.d.ts +130 -0
  213. package/dist/providers/openai-compatible.js +33 -0
  214. package/dist/providers/openai-options.d.ts +26 -0
  215. package/dist/providers/openai-options.js +41 -0
  216. package/dist/providers/openai.d.ts +404 -0
  217. package/dist/providers/openai.js +82 -0
  218. package/dist/providers/openrouter.d.ts +563 -0
  219. package/dist/providers/openrouter.js +114 -0
  220. package/dist/providers/togetherai.d.ts +227 -0
  221. package/dist/providers/togetherai.js +40 -0
  222. package/dist/providers/xai.d.ts +163 -0
  223. package/dist/providers/xai.js +88 -0
  224. package/dist/providers/zai/chat.d.ts +1 -0
  225. package/dist/providers/zai/chat.js +1 -0
  226. package/dist/providers/zai-coding-plan/chat.d.ts +1 -0
  227. package/dist/providers/zai-coding-plan/chat.js +1 -0
  228. package/dist/providers/zai-coding-plan/messages.d.ts +4 -0
  229. package/dist/providers/zai-coding-plan/messages.js +8 -0
  230. package/dist/providers/zai-coding-plan/responses.d.ts +4 -0
  231. package/dist/providers/zai-coding-plan/responses.js +8 -0
  232. package/dist/providers/zai-coding-plan.d.ts +577 -0
  233. package/dist/providers/zai-coding-plan.js +63 -0
  234. package/dist/providers/zai.d.ts +149 -0
  235. package/dist/providers/zai.js +53 -0
  236. package/dist/providers.d.ts +1 -0
  237. package/dist/providers.js +1 -0
  238. package/dist/route/auth-options.d.ts +34 -0
  239. package/dist/route/auth-options.js +14 -0
  240. package/dist/route/auth.d.ts +51 -0
  241. package/dist/route/auth.js +87 -0
  242. package/dist/route/client.d.ts +430 -0
  243. package/dist/route/client.js +307 -0
  244. package/dist/route/endpoint.d.ts +28 -0
  245. package/dist/route/endpoint.js +21 -0
  246. package/dist/route/executor.d.ts +27 -0
  247. package/dist/route/executor.js +183 -0
  248. package/dist/route/framing.d.ts +29 -0
  249. package/dist/route/framing.js +14 -0
  250. package/dist/route/index.d.ts +16 -0
  251. package/dist/route/index.js +9 -0
  252. package/dist/route/protocol.d.ts +76 -0
  253. package/dist/route/protocol.js +16 -0
  254. package/dist/route/transport/http.d.ts +34 -0
  255. package/dist/route/transport/http.js +68 -0
  256. package/dist/route/transport/index.d.ts +41 -0
  257. package/dist/route/transport/index.js +4 -0
  258. package/dist/route/transport/websocket-channel.d.ts +57 -0
  259. package/dist/route/transport/websocket-channel.js +1 -0
  260. package/dist/route/transport/websocket.d.ts +56 -0
  261. package/dist/route/transport/websocket.js +370 -0
  262. package/dist/route.d.ts +1 -0
  263. package/dist/route.js +1 -0
  264. package/dist/schema/errors.d.ts +170 -0
  265. package/dist/schema/errors.js +131 -0
  266. package/dist/schema/events.d.ts +8123 -0
  267. package/dist/schema/events.js +550 -0
  268. package/dist/schema/ids.d.ts +17 -0
  269. package/dist/schema/ids.js +10 -0
  270. package/dist/schema/index.d.ts +5 -0
  271. package/dist/schema/index.js +5 -0
  272. package/dist/schema/messages.d.ts +646 -0
  273. package/dist/schema/messages.js +301 -0
  274. package/dist/schema/options.d.ts +159 -0
  275. package/dist/schema/options.js +189 -0
  276. package/dist/testing.d.ts +1693 -0
  277. package/dist/testing.js +129 -0
  278. package/dist/tool-history.d.ts +2 -0
  279. package/dist/tool-history.js +84 -0
  280. package/dist/tool-runtime.d.ts +15 -0
  281. package/dist/tool-runtime.js +62 -0
  282. package/dist/tool.d.ts +136 -0
  283. package/dist/tool.js +66 -0
  284. package/dist/utils/record.d.ts +2 -0
  285. package/dist/utils/record.js +2 -0
  286. package/dist/utils/sanitize.d.ts +1 -0
  287. package/dist/utils/sanitize.js +12 -0
  288. package/package.json +43 -10
@@ -0,0 +1,596 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
3
+ import { type ProviderAuthOption } from "../route/auth-options.js";
4
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
5
+ import { type ModelID } from "../schema/index.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type ReasoningEffort = "low" | "high" | "max" | (string & {});
8
+ export type ChatOptionsInput = {
9
+ /** K3 always reasons; omitted effort uses the model's default. */
10
+ readonly reasoningEffort?: ReasoningEffort;
11
+ /** K2.6 supports disabling thinking; K2.7 Code always thinks and preserves reasoning. */
12
+ readonly thinking?: {
13
+ readonly type: "enabled" | "disabled" | (string & {});
14
+ readonly keep?: "all" | (string & {}) | null;
15
+ };
16
+ };
17
+ export type MessagesOptionsInput = {
18
+ readonly effort?: ReasoningEffort;
19
+ readonly metadata?: AnthropicMessages.OptionsInput["metadata"];
20
+ };
21
+ export type ResponsesOptionsInput = {
22
+ readonly reasoningEffort?: ReasoningEffort;
23
+ readonly safetyIdentifier?: string;
24
+ };
25
+ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
26
+ /** Overrides the selected API's base URL, including its version prefix. */
27
+ readonly baseURL?: string;
28
+ readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
29
+ };
30
+ export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
31
+ readonly apiKey?: string;
32
+ readonly baseURL?: string;
33
+ };
34
+ export declare const routes: (Route<{
35
+ readonly max_tokens: number;
36
+ readonly model: string;
37
+ readonly messages: readonly ({
38
+ readonly role: "user";
39
+ readonly content: readonly ({
40
+ readonly type: "text";
41
+ readonly text: string;
42
+ readonly cache_control?: {
43
+ readonly type: "ephemeral";
44
+ readonly ttl?: "1h" | "5m" | undefined;
45
+ } | undefined;
46
+ } | {
47
+ readonly type: "image";
48
+ readonly source: {
49
+ readonly type: "base64";
50
+ readonly media_type: string;
51
+ readonly data: string;
52
+ } | {
53
+ readonly type: "url";
54
+ readonly url: string;
55
+ } | {
56
+ readonly type: "file";
57
+ readonly file_id: string;
58
+ };
59
+ readonly cache_control?: {
60
+ readonly type: "ephemeral";
61
+ readonly ttl?: "1h" | "5m" | undefined;
62
+ } | undefined;
63
+ readonly transformations?: {
64
+ readonly oversized_image?: "error" | "downsize" | undefined;
65
+ } | undefined;
66
+ } | {
67
+ readonly type: "document";
68
+ readonly source: {
69
+ readonly type: "base64";
70
+ readonly media_type: "application/pdf";
71
+ readonly data: string;
72
+ } | {
73
+ readonly type: "text";
74
+ readonly media_type: "text/plain";
75
+ readonly data: string;
76
+ } | {
77
+ readonly type: "url";
78
+ readonly url: string;
79
+ } | {
80
+ readonly type: "file";
81
+ readonly file_id: string;
82
+ };
83
+ readonly title?: string | undefined;
84
+ readonly context?: string | undefined;
85
+ readonly cache_control?: {
86
+ readonly type: "ephemeral";
87
+ readonly ttl?: "1h" | "5m" | undefined;
88
+ } | undefined;
89
+ readonly citations?: {
90
+ readonly enabled: boolean;
91
+ } | undefined;
92
+ } | {
93
+ readonly type: "tool_result";
94
+ readonly content: string | readonly ({
95
+ readonly type: "text";
96
+ readonly text: string;
97
+ readonly cache_control?: {
98
+ readonly type: "ephemeral";
99
+ readonly ttl?: "1h" | "5m" | undefined;
100
+ } | undefined;
101
+ } | {
102
+ readonly type: "image";
103
+ readonly source: {
104
+ readonly type: "base64";
105
+ readonly media_type: string;
106
+ readonly data: string;
107
+ } | {
108
+ readonly type: "url";
109
+ readonly url: string;
110
+ } | {
111
+ readonly type: "file";
112
+ readonly file_id: string;
113
+ };
114
+ readonly cache_control?: {
115
+ readonly type: "ephemeral";
116
+ readonly ttl?: "1h" | "5m" | undefined;
117
+ } | undefined;
118
+ readonly transformations?: {
119
+ readonly oversized_image?: "error" | "downsize" | undefined;
120
+ } | undefined;
121
+ } | {
122
+ readonly type: "document";
123
+ readonly source: {
124
+ readonly type: "base64";
125
+ readonly media_type: "application/pdf";
126
+ readonly data: string;
127
+ } | {
128
+ readonly type: "text";
129
+ readonly media_type: "text/plain";
130
+ readonly data: string;
131
+ } | {
132
+ readonly type: "url";
133
+ readonly url: string;
134
+ } | {
135
+ readonly type: "file";
136
+ readonly file_id: string;
137
+ };
138
+ readonly title?: string | undefined;
139
+ readonly context?: string | undefined;
140
+ readonly cache_control?: {
141
+ readonly type: "ephemeral";
142
+ readonly ttl?: "1h" | "5m" | undefined;
143
+ } | undefined;
144
+ readonly citations?: {
145
+ readonly enabled: boolean;
146
+ } | undefined;
147
+ })[];
148
+ readonly tool_use_id: string;
149
+ readonly cache_control?: {
150
+ readonly type: "ephemeral";
151
+ readonly ttl?: "1h" | "5m" | undefined;
152
+ } | undefined;
153
+ readonly is_error?: boolean | undefined;
154
+ })[];
155
+ } | {
156
+ readonly role: "assistant";
157
+ readonly content: readonly ({
158
+ readonly type: "text";
159
+ readonly text: string;
160
+ readonly cache_control?: {
161
+ readonly type: "ephemeral";
162
+ readonly ttl?: "1h" | "5m" | undefined;
163
+ } | undefined;
164
+ } | {
165
+ readonly id: string;
166
+ readonly type: "tool_use";
167
+ readonly name: string;
168
+ readonly input: unknown;
169
+ readonly cache_control?: {
170
+ readonly type: "ephemeral";
171
+ readonly ttl?: "1h" | "5m" | undefined;
172
+ } | undefined;
173
+ } | {
174
+ readonly id: string;
175
+ readonly type: "server_tool_use";
176
+ readonly name: string;
177
+ readonly input: unknown;
178
+ readonly cache_control?: {
179
+ readonly type: "ephemeral";
180
+ readonly ttl?: "1h" | "5m" | undefined;
181
+ } | undefined;
182
+ } | {
183
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
184
+ readonly content: unknown;
185
+ readonly tool_use_id: string;
186
+ readonly cache_control?: {
187
+ readonly type: "ephemeral";
188
+ readonly ttl?: "1h" | "5m" | undefined;
189
+ } | undefined;
190
+ } | {
191
+ readonly type: "thinking";
192
+ readonly thinking: string;
193
+ readonly signature: string;
194
+ readonly cache_control?: {
195
+ readonly type: "ephemeral";
196
+ readonly ttl?: "1h" | "5m" | undefined;
197
+ } | undefined;
198
+ } | {
199
+ readonly data: string;
200
+ readonly type: "redacted_thinking";
201
+ readonly cache_control?: {
202
+ readonly type: "ephemeral";
203
+ readonly ttl?: "1h" | "5m" | undefined;
204
+ } | undefined;
205
+ } | {
206
+ readonly type: "compaction";
207
+ readonly content: string | null;
208
+ })[];
209
+ } | {
210
+ readonly role: "system";
211
+ readonly content: readonly {
212
+ readonly type: "text";
213
+ readonly text: string;
214
+ readonly cache_control?: {
215
+ readonly type: "ephemeral";
216
+ readonly ttl?: "1h" | "5m" | undefined;
217
+ } | undefined;
218
+ }[];
219
+ })[];
220
+ readonly stream: true;
221
+ readonly metadata?: {
222
+ readonly user_id?: string | null | undefined;
223
+ } | undefined;
224
+ readonly tools?: readonly {
225
+ readonly description: string;
226
+ readonly name: string;
227
+ readonly input_schema: {
228
+ readonly [x: string]: unknown;
229
+ };
230
+ readonly cache_control?: {
231
+ readonly type: "ephemeral";
232
+ readonly ttl?: "1h" | "5m" | undefined;
233
+ } | undefined;
234
+ }[] | undefined;
235
+ readonly system?: readonly {
236
+ readonly type: "text";
237
+ readonly text: string;
238
+ readonly cache_control?: {
239
+ readonly type: "ephemeral";
240
+ readonly ttl?: "1h" | "5m" | undefined;
241
+ } | undefined;
242
+ }[] | undefined;
243
+ readonly temperature?: number | undefined;
244
+ readonly thinking?: {
245
+ readonly type: "enabled";
246
+ readonly budget_tokens: number;
247
+ readonly display?: "summarized" | "omitted" | undefined;
248
+ readonly block_binding?: {
249
+ readonly prefix_mismatch_behavior?: string | undefined;
250
+ } | undefined;
251
+ } | {
252
+ readonly type: "adaptive";
253
+ readonly display?: "summarized" | "omitted" | undefined;
254
+ readonly block_binding?: {
255
+ readonly prefix_mismatch_behavior?: string | undefined;
256
+ } | undefined;
257
+ } | {
258
+ readonly type: "disabled";
259
+ } | undefined;
260
+ readonly service_tier?: "auto" | "standard_only" | undefined;
261
+ readonly container?: string | {
262
+ readonly id?: string | null | undefined;
263
+ readonly skills?: readonly {
264
+ readonly [x: string]: unknown;
265
+ }[] | null | undefined;
266
+ } | null | undefined;
267
+ readonly inference_geo?: string | null | undefined;
268
+ readonly cache_control?: {
269
+ readonly type: "ephemeral";
270
+ readonly ttl?: "1h" | "5m" | undefined;
271
+ } | undefined;
272
+ readonly output_config?: {
273
+ readonly format?: {
274
+ readonly type: "json_schema";
275
+ readonly schema: {
276
+ readonly [x: string]: unknown;
277
+ };
278
+ } | null | undefined;
279
+ readonly effort?: string | undefined;
280
+ } | undefined;
281
+ readonly context_management?: {
282
+ readonly edits: readonly {
283
+ readonly type: "compact_20260112";
284
+ readonly instructions?: string | undefined;
285
+ readonly trigger?: {
286
+ readonly type: "input_tokens";
287
+ readonly value: number;
288
+ } | undefined;
289
+ readonly pause_after_compaction?: boolean | undefined;
290
+ }[];
291
+ } | undefined;
292
+ readonly tool_choice?: {
293
+ readonly type: "auto" | "none" | "any";
294
+ readonly disable_parallel_tool_use?: boolean | undefined;
295
+ } | {
296
+ readonly type: "tool";
297
+ readonly name: string;
298
+ readonly disable_parallel_tool_use?: boolean | undefined;
299
+ } | undefined;
300
+ readonly top_p?: number | undefined;
301
+ readonly top_k?: number | undefined;
302
+ readonly stop_sequences?: readonly string[] | undefined;
303
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
304
+ readonly input: readonly ({
305
+ readonly [x: string]: unknown;
306
+ readonly id: string;
307
+ readonly type: "web_search_call";
308
+ readonly status?: string | undefined;
309
+ readonly action?: {
310
+ readonly [x: string]: unknown;
311
+ } | null | undefined;
312
+ } | {
313
+ readonly [x: string]: unknown;
314
+ readonly id: string;
315
+ readonly type: "file_search_call";
316
+ readonly status?: string | undefined;
317
+ readonly queries?: readonly string[] | undefined;
318
+ readonly results?: readonly {
319
+ readonly [x: string]: unknown;
320
+ }[] | null | undefined;
321
+ } | {
322
+ readonly [x: string]: unknown;
323
+ readonly id: string;
324
+ readonly type: "code_interpreter_call";
325
+ readonly status?: string | undefined;
326
+ readonly code?: string | null | undefined;
327
+ readonly container_id?: string | null | undefined;
328
+ readonly outputs?: readonly {
329
+ readonly [x: string]: unknown;
330
+ }[] | null | undefined;
331
+ } | {
332
+ readonly [x: string]: unknown;
333
+ readonly id: string;
334
+ readonly type: "mcp_call";
335
+ readonly status?: string | undefined;
336
+ readonly name?: string | undefined;
337
+ readonly output?: string | null | undefined;
338
+ readonly error?: unknown;
339
+ readonly arguments?: string | undefined;
340
+ readonly server_label?: string | undefined;
341
+ } | {
342
+ readonly type: "reasoning";
343
+ readonly summary: readonly {
344
+ readonly type: "summary_text";
345
+ readonly text: string;
346
+ }[];
347
+ readonly id?: string | undefined;
348
+ readonly encrypted_content?: string | null | undefined;
349
+ } | {
350
+ readonly type: "compaction";
351
+ readonly encrypted_content: string;
352
+ readonly id?: string | null | undefined;
353
+ } | {
354
+ readonly role: "system";
355
+ readonly content: string;
356
+ } | {
357
+ readonly role: "developer";
358
+ readonly content: string;
359
+ } | {
360
+ readonly content: readonly ({
361
+ readonly type: "input_image";
362
+ readonly image_url: string;
363
+ readonly detail?: string | undefined;
364
+ } | {
365
+ readonly type: "input_file";
366
+ readonly filename: string;
367
+ readonly detail?: string | undefined;
368
+ readonly file_data?: string | undefined;
369
+ readonly file_url?: string | undefined;
370
+ } | {
371
+ readonly type: "input_text";
372
+ readonly text: string;
373
+ })[];
374
+ readonly role: "user";
375
+ readonly id?: string | undefined;
376
+ readonly type?: "message" | undefined;
377
+ readonly status?: string | undefined;
378
+ } | {
379
+ readonly type: "message";
380
+ readonly content: readonly {
381
+ readonly type: "output_text";
382
+ readonly text: string;
383
+ }[];
384
+ readonly role: "assistant";
385
+ readonly id?: string | undefined;
386
+ readonly status?: string | undefined;
387
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
388
+ } | {
389
+ readonly type: "function_call";
390
+ readonly name: string;
391
+ readonly arguments: string;
392
+ readonly call_id: string;
393
+ readonly id?: string | undefined;
394
+ readonly namespace?: string | undefined;
395
+ } | {
396
+ readonly type: "function_call_output";
397
+ readonly call_id: string;
398
+ readonly output: string | readonly ({
399
+ readonly type: "input_image";
400
+ readonly image_url: string;
401
+ readonly detail?: string | undefined;
402
+ } | {
403
+ readonly type: "input_file";
404
+ readonly filename: string;
405
+ readonly detail?: string | undefined;
406
+ readonly file_data?: string | undefined;
407
+ readonly file_url?: string | undefined;
408
+ } | {
409
+ readonly type: "input_text";
410
+ readonly text: string;
411
+ } | {
412
+ readonly type: "input_video";
413
+ readonly video_url: string;
414
+ })[];
415
+ })[];
416
+ readonly model: string;
417
+ readonly stream: true;
418
+ readonly metadata?: {
419
+ readonly [x: string]: string;
420
+ } | undefined;
421
+ readonly instructions?: string | undefined;
422
+ readonly reasoning?: {
423
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
424
+ readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
425
+ } | undefined;
426
+ readonly tools?: readonly {
427
+ readonly type: "function";
428
+ readonly description: string;
429
+ readonly name: string;
430
+ readonly parameters: {
431
+ readonly [x: string]: unknown;
432
+ };
433
+ readonly strict?: boolean | undefined;
434
+ }[] | undefined;
435
+ readonly text?: {
436
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
437
+ } | undefined;
438
+ readonly temperature?: number | undefined;
439
+ readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
440
+ readonly tool_choice?: "required" | "auto" | "none" | {
441
+ readonly type: "function";
442
+ readonly name: string;
443
+ } | {
444
+ readonly type: "allowed_tools";
445
+ readonly mode: "required" | "auto" | "none";
446
+ readonly tools: readonly {
447
+ readonly type: "function";
448
+ readonly name: string;
449
+ }[];
450
+ } | undefined;
451
+ readonly top_p?: number | undefined;
452
+ readonly frequency_penalty?: number | undefined;
453
+ readonly presence_penalty?: number | undefined;
454
+ readonly prompt_cache_key?: string | undefined;
455
+ readonly parallel_tool_calls?: boolean | undefined;
456
+ readonly store?: boolean | undefined;
457
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
458
+ readonly truncation?: "auto" | "disabled" | undefined;
459
+ readonly stream_options?: {
460
+ readonly include_obfuscation?: boolean | undefined;
461
+ } | undefined;
462
+ readonly safety_identifier?: string | undefined;
463
+ readonly top_logprobs?: number | undefined;
464
+ readonly max_output_tokens?: number | undefined;
465
+ readonly max_tool_calls?: number | undefined;
466
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
467
+ readonly model: string;
468
+ readonly messages: readonly ({
469
+ readonly role: "system";
470
+ readonly content: string | readonly ({
471
+ readonly type: "text";
472
+ readonly text: string;
473
+ readonly cache_control?: {
474
+ readonly type: "ephemeral";
475
+ readonly ttl?: string | undefined;
476
+ } | undefined;
477
+ } | {
478
+ readonly type: "image_url";
479
+ readonly image_url: {
480
+ readonly url: string;
481
+ };
482
+ })[];
483
+ } | {
484
+ readonly role: "user";
485
+ readonly content: string | readonly ({
486
+ readonly type: "text";
487
+ readonly text: string;
488
+ readonly cache_control?: {
489
+ readonly type: "ephemeral";
490
+ readonly ttl?: string | undefined;
491
+ } | undefined;
492
+ } | {
493
+ readonly type: "image_url";
494
+ readonly image_url: {
495
+ readonly url: string;
496
+ };
497
+ })[];
498
+ } | {
499
+ readonly [x: string]: unknown;
500
+ readonly content: string | null;
501
+ readonly role: "assistant";
502
+ readonly reasoning?: string | undefined;
503
+ readonly reasoning_content?: string | undefined;
504
+ readonly reasoning_text?: string | undefined;
505
+ readonly cache_control?: {
506
+ readonly type: "ephemeral";
507
+ readonly ttl?: string | undefined;
508
+ } | undefined;
509
+ readonly tool_calls?: readonly {
510
+ readonly id: string;
511
+ readonly type: "function";
512
+ readonly function: {
513
+ readonly name: string;
514
+ readonly arguments: string;
515
+ };
516
+ }[] | undefined;
517
+ readonly reasoning_details?: unknown;
518
+ } | {
519
+ readonly content: string;
520
+ readonly role: "tool";
521
+ readonly tool_call_id: string;
522
+ readonly cache_control?: {
523
+ readonly type: "ephemeral";
524
+ readonly ttl?: string | undefined;
525
+ } | undefined;
526
+ })[];
527
+ readonly stream: true;
528
+ readonly max_completion_tokens?: number | undefined;
529
+ readonly max_tokens?: number | undefined;
530
+ readonly tools?: readonly {
531
+ readonly function: {
532
+ readonly description: string;
533
+ readonly name: string;
534
+ readonly parameters: {
535
+ readonly [x: string]: unknown;
536
+ };
537
+ readonly strict?: boolean | undefined;
538
+ };
539
+ readonly type: "function";
540
+ readonly cache_control?: {
541
+ readonly type: "ephemeral";
542
+ readonly ttl?: string | undefined;
543
+ } | undefined;
544
+ }[] | undefined;
545
+ readonly stop?: readonly string[] | undefined;
546
+ readonly temperature?: number | undefined;
547
+ readonly seed?: number | undefined;
548
+ readonly thinking?: {
549
+ readonly type: string;
550
+ readonly keep?: string | null | undefined;
551
+ } | undefined;
552
+ readonly tool_choice?: "required" | "auto" | "none" | {
553
+ readonly type: "function";
554
+ readonly function: {
555
+ readonly name: string;
556
+ };
557
+ } | undefined;
558
+ readonly top_p?: number | undefined;
559
+ readonly frequency_penalty?: number | undefined;
560
+ readonly presence_penalty?: number | undefined;
561
+ readonly prompt_cache_key?: string | undefined;
562
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
563
+ readonly store?: boolean | undefined;
564
+ readonly stream_options?: {
565
+ readonly include_usage: boolean;
566
+ } | undefined;
567
+ readonly tool_stream?: boolean | undefined;
568
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
569
+ export declare const configure: (input?: Config) => {
570
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
571
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
572
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
573
+ messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MessagesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
574
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
575
+ configure: (input?: Config) => /*elided*/ any;
576
+ };
577
+ export declare const provider: {
578
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
579
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
580
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
581
+ messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MessagesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
582
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
583
+ configure: (input?: Config) => {
584
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
585
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
586
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
587
+ messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MessagesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
588
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
589
+ configure: /*elided*/ any;
590
+ };
591
+ };
592
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
593
+ export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MessagesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
594
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
595
+ export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
596
+ export * as Moonshot from "./moonshot.js";
@@ -0,0 +1,90 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
3
+ import { OpenAIChat } from "../protocols/openai-chat.js";
4
+ import { OpenResponses } from "../protocols/open-responses.js";
5
+ import { ProviderShared } from "../protocols/shared.js";
6
+ import { AuthOptions } from "../route/auth-options.js";
7
+ import { Route } from "../route/client.js";
8
+ import { Endpoint } from "../route/endpoint.js";
9
+ import { Framing } from "../route/framing.js";
10
+ import { Protocol } from "../route/protocol.js";
11
+ import { ProviderID } from "../schema/index.js";
12
+ export const id = ProviderID.make("moonshotai");
13
+ const ChatOptions = Schema.Struct({
14
+ reasoningEffort: Schema.optional(Schema.String),
15
+ thinking: Schema.optional(Schema.Struct({ type: Schema.String, keep: Schema.optional(Schema.NullOr(Schema.String)) })),
16
+ });
17
+ const chatProtocol = Protocol.make({
18
+ id: "moonshot-chat",
19
+ body: {
20
+ schema: Schema.Struct({ ...OpenAIChat.bodyFields, thinking: ChatOptions.fields.thinking }),
21
+ from: Effect.fn("Moonshot.chatFromRequest")(function* (request) {
22
+ const options = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(ChatOptions))(request.providerOptions ?? {});
23
+ return { ...(yield* OpenAIChat.protocol.body.from(request)), thinking: options.thinking };
24
+ }),
25
+ },
26
+ stream: OpenAIChat.protocol.stream,
27
+ });
28
+ const chatRoute = Route.make({
29
+ id: "moonshot-chat",
30
+ provider: id,
31
+ providerMetadataKey: "moonshot",
32
+ protocol: chatProtocol,
33
+ endpoint: Endpoint.path("/chat/completions", { baseURL: "https://api.moonshot.ai/v1" }),
34
+ framing: OpenAIChat.framing,
35
+ });
36
+ const messagesRoute = Route.make({
37
+ id: "moonshot-messages",
38
+ provider: id,
39
+ providerMetadataKey: "moonshot",
40
+ protocol: AnthropicMessages.protocol,
41
+ endpoint: Endpoint.path("/messages", { baseURL: "https://api.moonshot.ai/anthropic/v1" }),
42
+ framing: AnthropicMessages.framing,
43
+ });
44
+ const responsesRoute = Route.make({
45
+ id: "moonshot-responses",
46
+ provider: id,
47
+ providerMetadataKey: "moonshot",
48
+ protocol: OpenResponses.protocol,
49
+ endpoint: Endpoint.path("/responses", { baseURL: "https://api.moonshot.ai/v1" }),
50
+ framing: Framing.sse,
51
+ });
52
+ export const routes = [chatRoute, messagesRoute, responsesRoute];
53
+ export const configure = (input = {}) => {
54
+ const { apiKey: _apiKey, auth: _auth, baseURL, ...rest } = input;
55
+ const defaults = {
56
+ ...rest,
57
+ endpoint: baseURL === undefined ? undefined : { baseURL },
58
+ auth: AuthOptions.bearer(input, ["MOONSHOT_API_KEY", "MOONSHOTAI_API_KEY"]),
59
+ };
60
+ const chat = (modelID) => chatRoute.with(defaults).model({
61
+ id: modelID,
62
+ compatibility: {
63
+ maxTokensField: "max_tokens",
64
+ supportsStore: false,
65
+ supportsStrictMode: false,
66
+ toolSchema: "moonshot",
67
+ reasoningField: "reasoning_content",
68
+ },
69
+ });
70
+ const messages = (modelID) => messagesRoute.with(defaults).model({
71
+ id: modelID,
72
+ compatibility: { requireSignature: false, toolSchema: "moonshot" },
73
+ });
74
+ const responses = (modelID) => responsesRoute
75
+ .with(defaults)
76
+ .model({ id: modelID, compatibility: { toolSchema: "moonshot" } });
77
+ return { id, model: chat, chat, messages, responses, configure };
78
+ };
79
+ export const provider = configure();
80
+ export const chat = provider.chat;
81
+ export const messages = provider.messages;
82
+ export const responses = provider.responses;
83
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
84
+ apiKey,
85
+ baseURL,
86
+ headers,
87
+ http: body === undefined ? undefined : { body: { ...body } },
88
+ providerOptions,
89
+ }).model(modelID);
90
+ export * as Moonshot from "./moonshot.js";