@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,94 @@
1
+ import { Struct } from "effect";
2
+ import { AlibabaChat } from "../protocols/alibaba-chat.js";
3
+ import { AlibabaMessages } from "../protocols/alibaba-messages.js";
4
+ import { AlibabaResponses } from "../protocols/alibaba-responses.js";
5
+ import { AuthOptions } from "../route/auth-options.js";
6
+ import { Route } from "../route/client.js";
7
+ import { Endpoint } from "../route/endpoint.js";
8
+ import { Framing } from "../route/framing.js";
9
+ import { ProviderConfigurationError, ProviderID, ToolDefinition } from "../schema/index.js";
10
+ export const id = ProviderID.make("alibaba");
11
+ const hosts = new Map([
12
+ ["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
13
+ ["cn-beijing", "dashscope.aliyuncs.com"],
14
+ ["cn-hongkong", "cn-hongkong.dashscope.aliyuncs.com"],
15
+ ["us-east-1", "dashscope-us.aliyuncs.com"],
16
+ ]);
17
+ const chatRoute = Route.make({
18
+ id: "alibaba-chat",
19
+ provider: id,
20
+ providerMetadataKey: "alibaba",
21
+ protocol: AlibabaChat.protocol,
22
+ endpoint: Endpoint.path("/chat/completions"),
23
+ framing: Framing.sse,
24
+ });
25
+ const messagesRoute = Route.make({
26
+ id: "alibaba-messages",
27
+ provider: id,
28
+ providerMetadataKey: "alibaba",
29
+ protocol: AlibabaMessages.protocol,
30
+ endpoint: Endpoint.path("/messages"),
31
+ framing: Framing.sse,
32
+ headers: () => ({ "anthropic-version": "2023-06-01" }),
33
+ });
34
+ const responsesRoute = Route.make({
35
+ id: "alibaba-responses",
36
+ provider: id,
37
+ providerMetadataKey: "alibaba",
38
+ protocol: AlibabaResponses.protocol,
39
+ endpoint: Endpoint.path("/responses"),
40
+ framing: Framing.sse,
41
+ });
42
+ export const routes = [chatRoute, messagesRoute, responsesRoute];
43
+ export const configure = (input) => {
44
+ const { apiKey: _key, auth: _auth, region, workspaceID, baseURL, ...rest } = input;
45
+ const host = region === undefined
46
+ ? undefined
47
+ : workspaceID === undefined
48
+ ? hosts.get(region)
49
+ : `${workspaceID}.${region}.maas.aliyuncs.com`;
50
+ if (baseURL === undefined) {
51
+ if (region === undefined)
52
+ throw new ProviderConfigurationError({ provider: id, message: "Alibaba requires region or baseURL" });
53
+ if (host === undefined)
54
+ throw new ProviderConfigurationError({
55
+ provider: id,
56
+ message: `Alibaba region ${region} requires workspaceID or baseURL`,
57
+ });
58
+ }
59
+ const opts = { ...rest, auth: AuthOptions.bearer(input, ["DASHSCOPE_API_KEY", "ALIBABA_API_KEY"]) };
60
+ const common = { ...opts, endpoint: { baseURL: baseURL ?? `https://${host}/compatible-mode/v1` } };
61
+ const chat = (id) => chatRoute.with(common).model({ id, compatibility: AlibabaChat.compatibility });
62
+ const messages = (id) => messagesRoute
63
+ .with({
64
+ ...opts,
65
+ endpoint: { baseURL: baseURL ?? `https://${host}/apps/anthropic/v1` },
66
+ })
67
+ .model({ id, compatibility: { requireSignature: false } });
68
+ const responses = (id) => responsesRoute.with(common).model({ id });
69
+ return { id, model: chat, chat, messages, responses, configure };
70
+ };
71
+ export const provider = { id, configure };
72
+ export const model = (id, input) => fromSettings(input).chat(id);
73
+ export const messagesModel = (id, input) => fromSettings(input).messages(id);
74
+ export const responsesModel = (id, input) => fromSettings(input).responses(id);
75
+ function fromSettings(input) {
76
+ const { body, ...rest } = input;
77
+ return configure({
78
+ ...rest,
79
+ http: body === undefined ? undefined : { body },
80
+ providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
81
+ });
82
+ }
83
+ export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.");
84
+ export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.");
85
+ export const codeInterpreter = () => hostedTool("code_interpreter", "Execute code with Alibaba's hosted interpreter.");
86
+ function hostedTool(type, description) {
87
+ return ToolDefinition.make({
88
+ name: type,
89
+ description,
90
+ inputSchema: { type: "object", properties: {} },
91
+ native: { alibaba: { type } },
92
+ });
93
+ }
94
+ export * as Alibaba from "./alibaba.js";
@@ -0,0 +1,2 @@
1
+ export { chatModel as model } from "../../amazon-bedrock-mantle.js";
2
+ export type { Settings } from "../../amazon-bedrock-mantle.js";
@@ -0,0 +1 @@
1
+ export { chatModel as model } from "../../amazon-bedrock-mantle.js";
@@ -0,0 +1,2 @@
1
+ export { responsesModel as model } from "../../amazon-bedrock-mantle.js";
2
+ export type { Settings } from "../../amazon-bedrock-mantle.js";
@@ -0,0 +1 @@
1
+ export { responsesModel as model } from "../../amazon-bedrock-mantle.js";
@@ -0,0 +1,2 @@
1
+ export { responsesModel as model } from "../amazon-bedrock-mantle.js";
2
+ export type { Settings } from "../amazon-bedrock-mantle.js";
@@ -0,0 +1 @@
1
+ export { responsesModel as model } from "../amazon-bedrock-mantle.js";
@@ -0,0 +1,313 @@
1
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
2
+ import type { ProviderPackage } from "../provider-package.js";
3
+ import { type Credentials } from "../protocols/utils/bedrock-auth.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import { type OpenAIProviderOptionsInput } from "./openai-options.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type Config = RouteDefaultsInput & {
8
+ /** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
9
+ readonly apiKey?: string;
10
+ /** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
11
+ readonly auth?: "bearer" | "sigv4";
12
+ readonly baseURL?: string;
13
+ /** Static SigV4 credentials. When omitted the AWS default credential chain resolves them per request. */
14
+ readonly credentials?: Credentials;
15
+ /** Shared config profile for the default credential chain. */
16
+ readonly profile?: string;
17
+ readonly region?: string;
18
+ readonly providerOptions?: OpenAIProviderOptionsInput;
19
+ };
20
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
21
+ readonly apiKey?: string;
22
+ readonly auth?: "bearer" | "sigv4";
23
+ readonly baseURL?: string;
24
+ readonly credentials?: Credentials;
25
+ readonly profile?: string;
26
+ readonly region?: string;
27
+ readonly topP?: number;
28
+ };
29
+ export declare const routes: (Route<{
30
+ readonly model: string;
31
+ readonly messages: readonly ({
32
+ readonly role: "system";
33
+ readonly content: string | readonly ({
34
+ readonly type: "text";
35
+ readonly text: string;
36
+ readonly cache_control?: {
37
+ readonly type: "ephemeral";
38
+ readonly ttl?: string | undefined;
39
+ } | undefined;
40
+ } | {
41
+ readonly type: "image_url";
42
+ readonly image_url: {
43
+ readonly url: string;
44
+ };
45
+ })[];
46
+ } | {
47
+ readonly role: "user";
48
+ readonly content: string | readonly ({
49
+ readonly type: "text";
50
+ readonly text: string;
51
+ readonly cache_control?: {
52
+ readonly type: "ephemeral";
53
+ readonly ttl?: string | undefined;
54
+ } | undefined;
55
+ } | {
56
+ readonly type: "image_url";
57
+ readonly image_url: {
58
+ readonly url: string;
59
+ };
60
+ })[];
61
+ } | {
62
+ readonly [x: string]: unknown;
63
+ readonly content: string | null;
64
+ readonly role: "assistant";
65
+ readonly reasoning?: string | undefined;
66
+ readonly reasoning_content?: string | undefined;
67
+ readonly reasoning_text?: string | undefined;
68
+ readonly cache_control?: {
69
+ readonly type: "ephemeral";
70
+ readonly ttl?: string | undefined;
71
+ } | undefined;
72
+ readonly tool_calls?: readonly {
73
+ readonly id: string;
74
+ readonly type: "function";
75
+ readonly function: {
76
+ readonly name: string;
77
+ readonly arguments: string;
78
+ };
79
+ }[] | undefined;
80
+ readonly reasoning_details?: unknown;
81
+ } | {
82
+ readonly content: string;
83
+ readonly role: "tool";
84
+ readonly tool_call_id: string;
85
+ readonly cache_control?: {
86
+ readonly type: "ephemeral";
87
+ readonly ttl?: string | undefined;
88
+ } | undefined;
89
+ })[];
90
+ readonly stream: true;
91
+ readonly max_completion_tokens?: number | undefined;
92
+ readonly max_tokens?: number | undefined;
93
+ readonly tools?: readonly {
94
+ readonly function: {
95
+ readonly description: string;
96
+ readonly name: string;
97
+ readonly parameters: {
98
+ readonly [x: string]: unknown;
99
+ };
100
+ readonly strict?: boolean | undefined;
101
+ };
102
+ readonly type: "function";
103
+ readonly cache_control?: {
104
+ readonly type: "ephemeral";
105
+ readonly ttl?: string | undefined;
106
+ } | undefined;
107
+ }[] | undefined;
108
+ readonly stop?: readonly string[] | undefined;
109
+ readonly temperature?: number | undefined;
110
+ readonly seed?: number | undefined;
111
+ readonly tool_choice?: "required" | "auto" | "none" | {
112
+ readonly type: "function";
113
+ readonly function: {
114
+ readonly name: string;
115
+ };
116
+ } | undefined;
117
+ readonly top_p?: number | undefined;
118
+ readonly frequency_penalty?: number | undefined;
119
+ readonly presence_penalty?: number | undefined;
120
+ readonly prompt_cache_key?: string | undefined;
121
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
122
+ readonly store?: boolean | undefined;
123
+ readonly stream_options?: {
124
+ readonly include_usage: boolean;
125
+ } | undefined;
126
+ readonly tool_stream?: boolean | undefined;
127
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
128
+ readonly input: readonly ({
129
+ readonly [x: string]: unknown;
130
+ readonly id: string;
131
+ readonly type: "web_search_call";
132
+ readonly status?: string | undefined;
133
+ readonly action?: {
134
+ readonly [x: string]: unknown;
135
+ } | null | undefined;
136
+ } | {
137
+ readonly [x: string]: unknown;
138
+ readonly id: string;
139
+ readonly type: "file_search_call";
140
+ readonly status?: string | undefined;
141
+ readonly queries?: readonly string[] | undefined;
142
+ readonly results?: readonly {
143
+ readonly [x: string]: unknown;
144
+ }[] | null | undefined;
145
+ } | {
146
+ readonly [x: string]: unknown;
147
+ readonly id: string;
148
+ readonly type: "code_interpreter_call";
149
+ readonly status?: string | undefined;
150
+ readonly code?: string | null | undefined;
151
+ readonly container_id?: string | null | undefined;
152
+ readonly outputs?: readonly {
153
+ readonly [x: string]: unknown;
154
+ }[] | null | undefined;
155
+ } | {
156
+ readonly [x: string]: unknown;
157
+ readonly id: string;
158
+ readonly type: "mcp_call";
159
+ readonly status?: string | undefined;
160
+ readonly name?: string | undefined;
161
+ readonly output?: string | null | undefined;
162
+ readonly error?: unknown;
163
+ readonly arguments?: string | undefined;
164
+ readonly server_label?: string | undefined;
165
+ } | {
166
+ readonly type: "reasoning";
167
+ readonly summary: readonly {
168
+ readonly type: "summary_text";
169
+ readonly text: string;
170
+ }[];
171
+ readonly id?: string | undefined;
172
+ readonly encrypted_content?: string | null | undefined;
173
+ } | {
174
+ readonly type: "compaction";
175
+ readonly encrypted_content: string;
176
+ readonly id?: string | null | undefined;
177
+ } | {
178
+ readonly role: "system";
179
+ readonly content: string;
180
+ } | {
181
+ readonly role: "developer";
182
+ readonly content: string;
183
+ } | {
184
+ readonly content: readonly ({
185
+ readonly type: "input_image";
186
+ readonly image_url: string;
187
+ readonly detail?: string | undefined;
188
+ } | {
189
+ readonly type: "input_file";
190
+ readonly filename: string;
191
+ readonly detail?: string | undefined;
192
+ readonly file_data?: string | undefined;
193
+ readonly file_url?: string | undefined;
194
+ } | {
195
+ readonly type: "input_text";
196
+ readonly text: string;
197
+ })[];
198
+ readonly role: "user";
199
+ readonly id?: string | undefined;
200
+ readonly type?: "message" | undefined;
201
+ readonly status?: string | undefined;
202
+ } | {
203
+ readonly type: "message";
204
+ readonly content: readonly {
205
+ readonly type: "output_text";
206
+ readonly text: string;
207
+ }[];
208
+ readonly role: "assistant";
209
+ readonly id?: string | undefined;
210
+ readonly status?: string | undefined;
211
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
212
+ } | {
213
+ readonly type: "function_call";
214
+ readonly name: string;
215
+ readonly arguments: string;
216
+ readonly call_id: string;
217
+ readonly id?: string | undefined;
218
+ readonly namespace?: string | undefined;
219
+ } | {
220
+ readonly type: "function_call_output";
221
+ readonly call_id: string;
222
+ readonly output: string | readonly ({
223
+ readonly type: "input_image";
224
+ readonly image_url: string;
225
+ readonly detail?: string | undefined;
226
+ } | {
227
+ readonly type: "input_file";
228
+ readonly filename: string;
229
+ readonly detail?: string | undefined;
230
+ readonly file_data?: string | undefined;
231
+ readonly file_url?: string | undefined;
232
+ } | {
233
+ readonly type: "input_text";
234
+ readonly text: string;
235
+ } | {
236
+ readonly type: "input_video";
237
+ readonly video_url: string;
238
+ })[];
239
+ })[];
240
+ readonly model: string;
241
+ readonly stream: true;
242
+ readonly metadata?: {
243
+ readonly [x: string]: string;
244
+ } | undefined;
245
+ readonly instructions?: string | undefined;
246
+ readonly reasoning?: {
247
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
248
+ readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
249
+ } | undefined;
250
+ readonly tools?: readonly {
251
+ readonly type: "function";
252
+ readonly description: string;
253
+ readonly name: string;
254
+ readonly parameters: {
255
+ readonly [x: string]: unknown;
256
+ };
257
+ readonly strict?: boolean | undefined;
258
+ }[] | undefined;
259
+ readonly text?: {
260
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
261
+ } | undefined;
262
+ readonly temperature?: number | undefined;
263
+ readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
264
+ readonly tool_choice?: "required" | "auto" | "none" | {
265
+ readonly type: "function";
266
+ readonly name: string;
267
+ } | {
268
+ readonly type: "allowed_tools";
269
+ readonly mode: "required" | "auto" | "none";
270
+ readonly tools: readonly {
271
+ readonly type: "function";
272
+ readonly name: string;
273
+ }[];
274
+ } | undefined;
275
+ readonly top_p?: number | undefined;
276
+ readonly frequency_penalty?: number | undefined;
277
+ readonly presence_penalty?: number | undefined;
278
+ readonly prompt_cache_key?: string | undefined;
279
+ readonly parallel_tool_calls?: boolean | undefined;
280
+ readonly store?: boolean | undefined;
281
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
282
+ readonly truncation?: "auto" | "disabled" | undefined;
283
+ readonly stream_options?: {
284
+ readonly include_obfuscation?: boolean | undefined;
285
+ } | undefined;
286
+ readonly safety_identifier?: string | undefined;
287
+ readonly top_logprobs?: number | undefined;
288
+ readonly max_output_tokens?: number | undefined;
289
+ readonly max_tool_calls?: number | undefined;
290
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
291
+ export declare const configure: (input?: Config) => {
292
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
293
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
294
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
295
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
296
+ configure: (input?: Config) => /*elided*/ any;
297
+ };
298
+ export declare const provider: {
299
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
300
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
301
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
302
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
303
+ configure: (input?: Config) => {
304
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
305
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
306
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
307
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
308
+ configure: /*elided*/ any;
309
+ };
310
+ };
311
+ export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
312
+ export declare const responsesModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
313
+ export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
@@ -0,0 +1,79 @@
1
+ import { Route } from "../route/client.js";
2
+ import { Endpoint } from "../route/endpoint.js";
3
+ import { OpenAIChat } from "../protocols/openai-chat.js";
4
+ import { OpenResponses } from "../protocols/open-responses.js";
5
+ import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
6
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
7
+ import { withOpenAIOptions } from "./openai-options.js";
8
+ export const id = ProviderID.make("amazon-bedrock");
9
+ const responsesRoute = Route.make({
10
+ id: "bedrock-mantle-responses",
11
+ provider: id,
12
+ providerMetadataKey: "mantle",
13
+ protocol: OpenResponses.protocol,
14
+ endpoint: Endpoint.path(OpenResponses.PATH),
15
+ transport: OpenResponses.httpTransport,
16
+ defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
17
+ });
18
+ const chatRoute = OpenAIChat.route.with({
19
+ id: "bedrock-mantle-chat",
20
+ provider: id,
21
+ providerMetadataKey: "mantle",
22
+ });
23
+ export const routes = [responsesRoute, chatRoute];
24
+ const configuredRoute = (route, input) => {
25
+ const region = BedrockAuth.resolveRegion(input);
26
+ return route.with({
27
+ endpoint: { baseURL: input.baseURL ?? `https://bedrock-mantle.${region}.api.aws/v1` },
28
+ auth: BedrockAuth.resolveAuth(input, region, {
29
+ service: "bedrock-mantle",
30
+ name: "Bedrock Mantle",
31
+ mode: input.auth,
32
+ }),
33
+ });
34
+ };
35
+ const defaults = (input) => {
36
+ const { apiKey: _, auth: _auth, baseURL: _baseURL, credentials: _credentials, profile: _profile, region: _region, ...rest } = input;
37
+ return rest;
38
+ };
39
+ export const configure = (input = {}) => {
40
+ if (input.auth === "bearer" && input.apiKey === undefined && process.env.AWS_BEARER_TOKEN_BEDROCK === undefined)
41
+ throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock Mantle bearer auth requires apiKey" });
42
+ if (input.auth === "sigv4" && input.apiKey !== undefined)
43
+ throw new ProviderConfigurationError({
44
+ provider: id,
45
+ message: "Amazon Bedrock Mantle SigV4 auth does not accept apiKey",
46
+ });
47
+ const configuredResponsesRoute = configuredRoute(responsesRoute, input);
48
+ const configuredChatRoute = configuredRoute(chatRoute, input);
49
+ const modelDefaults = defaults(input);
50
+ const responses = (modelID) => configuredResponsesRoute
51
+ .with(withOpenAIOptions(modelID, modelDefaults))
52
+ .model({ id: modelID });
53
+ const chat = (modelID) => configuredChatRoute
54
+ .with(withOpenAIOptions(modelID, modelDefaults))
55
+ .model({ id: modelID });
56
+ return {
57
+ id,
58
+ model: responses,
59
+ chat,
60
+ responses,
61
+ configure,
62
+ };
63
+ };
64
+ export const provider = configure();
65
+ const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions }) => configure({
66
+ apiKey,
67
+ auth,
68
+ baseURL,
69
+ credentials,
70
+ generation: topP === undefined ? undefined : { topP },
71
+ headers: headers === undefined ? undefined : { ...headers },
72
+ http: body === undefined ? undefined : { body: { ...body } },
73
+ profile,
74
+ providerOptions,
75
+ region,
76
+ });
77
+ export const chatModel = (modelID, settings) => fromSettings(settings).chat(modelID);
78
+ export const responsesModel = (modelID, settings) => fromSettings(settings).responses(modelID);
79
+ export const model = responsesModel;