@opencode-ai/ai 0.0.0-beta-17492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +392 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +121 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +19 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +102 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +230 -0
  11. package/dist/llm.js +77 -0
  12. package/dist/protocols/anthropic-messages.d.ts +633 -0
  13. package/dist/protocols/anthropic-messages.js +860 -0
  14. package/dist/protocols/bedrock-converse.d.ts +533 -0
  15. package/dist/protocols/bedrock-converse.js +584 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +73 -0
  18. package/dist/protocols/gemini.d.ts +300 -0
  19. package/dist/protocols/gemini.js +512 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +191 -0
  22. package/dist/protocols/index.d.ts +10 -0
  23. package/dist/protocols/index.js +10 -0
  24. package/dist/protocols/open-responses-channel.d.ts +26 -0
  25. package/dist/protocols/open-responses-channel.js +120 -0
  26. package/dist/protocols/open-responses.d.ts +951 -0
  27. package/dist/protocols/open-responses.js +873 -0
  28. package/dist/protocols/openai-chat.d.ts +795 -0
  29. package/dist/protocols/openai-chat.js +718 -0
  30. package/dist/protocols/openai-compatible-chat.d.ts +107 -0
  31. package/dist/protocols/openai-compatible-chat.js +20 -0
  32. package/dist/protocols/openai-compatible-responses.d.ts +96 -0
  33. package/dist/protocols/openai-compatible-responses.js +17 -0
  34. package/dist/protocols/openai-images.d.ts +32 -0
  35. package/dist/protocols/openai-images.js +188 -0
  36. package/dist/protocols/openai-responses-channel.d.ts +12 -0
  37. package/dist/protocols/openai-responses-channel.js +142 -0
  38. package/dist/protocols/openai-responses.d.ts +596 -0
  39. package/dist/protocols/openai-responses.js +208 -0
  40. package/dist/protocols/shared.d.ts +194 -0
  41. package/dist/protocols/shared.js +238 -0
  42. package/dist/protocols/utils/bedrock-auth.d.ts +21 -0
  43. package/dist/protocols/utils/bedrock-auth.js +43 -0
  44. package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
  45. package/dist/protocols/utils/bedrock-cache.js +29 -0
  46. package/dist/protocols/utils/bedrock-media.d.ts +49 -0
  47. package/dist/protocols/utils/bedrock-media.js +70 -0
  48. package/dist/protocols/utils/cache.d.ts +6 -0
  49. package/dist/protocols/utils/cache.js +8 -0
  50. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  51. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  52. package/dist/protocols/utils/image-input.d.ts +21 -0
  53. package/dist/protocols/utils/image-input.js +22 -0
  54. package/dist/protocols/utils/lifecycle.d.ts +20 -0
  55. package/dist/protocols/utils/lifecycle.js +68 -0
  56. package/dist/protocols/utils/open-responses-options.d.ts +21 -0
  57. package/dist/protocols/utils/open-responses-options.js +41 -0
  58. package/dist/protocols/utils/openai-image.d.ts +5 -0
  59. package/dist/protocols/utils/openai-image.js +18 -0
  60. package/dist/protocols/utils/openai-options.d.ts +14 -0
  61. package/dist/protocols/utils/openai-options.js +14 -0
  62. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  63. package/dist/protocols/utils/tool-schema.js +81 -0
  64. package/dist/protocols/utils/tool-stream.d.ts +639 -0
  65. package/dist/protocols/utils/tool-stream.js +141 -0
  66. package/dist/protocols/xai-images.d.ts +26 -0
  67. package/dist/protocols/xai-images.js +111 -0
  68. package/dist/protocols/zai-images.d.ts +22 -0
  69. package/dist/protocols/zai-images.js +84 -0
  70. package/dist/protocols.d.ts +1 -0
  71. package/dist/protocols.js +1 -0
  72. package/dist/provider-error.d.ts +14 -0
  73. package/dist/provider-error.js +130 -0
  74. package/dist/provider-package.d.ts +15 -0
  75. package/dist/provider-package.js +1 -0
  76. package/dist/provider.d.ts +23 -0
  77. package/dist/provider.js +2 -0
  78. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  79. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  80. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  81. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  82. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  83. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  84. package/dist/providers/amazon-bedrock-mantle.d.ts +247 -0
  85. package/dist/providers/amazon-bedrock-mantle.js +68 -0
  86. package/dist/providers/amazon-bedrock.d.ts +172 -0
  87. package/dist/providers/amazon-bedrock.js +41 -0
  88. package/dist/providers/anthropic-compatible.d.ts +218 -0
  89. package/dist/providers/anthropic-compatible.js +45 -0
  90. package/dist/providers/anthropic.d.ts +216 -0
  91. package/dist/providers/anthropic.js +40 -0
  92. package/dist/providers/azure/chat.d.ts +2 -0
  93. package/dist/providers/azure/chat.js +1 -0
  94. package/dist/providers/azure/responses.d.ts +2 -0
  95. package/dist/providers/azure/responses.js +1 -0
  96. package/dist/providers/azure.d.ts +248 -0
  97. package/dist/providers/azure.js +90 -0
  98. package/dist/providers/cloudflare.d.ts +338 -0
  99. package/dist/providers/cloudflare.js +87 -0
  100. package/dist/providers/google-vertex/chat.d.ts +2 -0
  101. package/dist/providers/google-vertex/chat.js +1 -0
  102. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  103. package/dist/providers/google-vertex/gemini.js +1 -0
  104. package/dist/providers/google-vertex/messages.d.ts +2 -0
  105. package/dist/providers/google-vertex/messages.js +1 -0
  106. package/dist/providers/google-vertex/responses.d.ts +2 -0
  107. package/dist/providers/google-vertex/responses.js +1 -0
  108. package/dist/providers/google-vertex-chat.d.ts +131 -0
  109. package/dist/providers/google-vertex-chat.js +50 -0
  110. package/dist/providers/google-vertex-messages.d.ts +215 -0
  111. package/dist/providers/google-vertex-messages.js +75 -0
  112. package/dist/providers/google-vertex-responses.d.ts +122 -0
  113. package/dist/providers/google-vertex-responses.js +51 -0
  114. package/dist/providers/google-vertex-shared.d.ts +22 -0
  115. package/dist/providers/google-vertex-shared.js +61 -0
  116. package/dist/providers/google-vertex.d.ts +115 -0
  117. package/dist/providers/google-vertex.js +64 -0
  118. package/dist/providers/google.d.ts +112 -0
  119. package/dist/providers/google.js +43 -0
  120. package/dist/providers/index.d.ts +18 -0
  121. package/dist/providers/index.js +18 -0
  122. package/dist/providers/open-responses-options.d.ts +16 -0
  123. package/dist/providers/open-responses-options.js +1 -0
  124. package/dist/providers/openai/chat.d.ts +2 -0
  125. package/dist/providers/openai/chat.js +1 -0
  126. package/dist/providers/openai/responses.d.ts +2 -0
  127. package/dist/providers/openai/responses.js +1 -0
  128. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  129. package/dist/providers/openai-compatible/responses.js +1 -0
  130. package/dist/providers/openai-compatible-profile.d.ts +43 -0
  131. package/dist/providers/openai-compatible-profile.js +12 -0
  132. package/dist/providers/openai-compatible-responses.d.ts +120 -0
  133. package/dist/providers/openai-compatible-responses.js +33 -0
  134. package/dist/providers/openai-compatible.d.ts +167 -0
  135. package/dist/providers/openai-compatible.js +55 -0
  136. package/dist/providers/openai-options.d.ts +21 -0
  137. package/dist/providers/openai-options.js +41 -0
  138. package/dist/providers/openai.d.ts +264 -0
  139. package/dist/providers/openai.js +83 -0
  140. package/dist/providers/openrouter.d.ts +537 -0
  141. package/dist/providers/openrouter.js +117 -0
  142. package/dist/providers/xai.d.ts +249 -0
  143. package/dist/providers/xai.js +79 -0
  144. package/dist/providers/zai.d.ts +24 -0
  145. package/dist/providers/zai.js +21 -0
  146. package/dist/providers.d.ts +1 -0
  147. package/dist/providers.js +1 -0
  148. package/dist/route/auth-options.d.ts +34 -0
  149. package/dist/route/auth-options.js +14 -0
  150. package/dist/route/auth.d.ts +51 -0
  151. package/dist/route/auth.js +89 -0
  152. package/dist/route/client.d.ts +348 -0
  153. package/dist/route/client.js +214 -0
  154. package/dist/route/endpoint.d.ts +28 -0
  155. package/dist/route/endpoint.js +21 -0
  156. package/dist/route/executor.d.ts +23 -0
  157. package/dist/route/executor.js +227 -0
  158. package/dist/route/framing.d.ts +23 -0
  159. package/dist/route/framing.js +4 -0
  160. package/dist/route/index.d.ts +16 -0
  161. package/dist/route/index.js +9 -0
  162. package/dist/route/protocol.d.ts +77 -0
  163. package/dist/route/protocol.js +17 -0
  164. package/dist/route/transport/http.d.ts +34 -0
  165. package/dist/route/transport/http.js +63 -0
  166. package/dist/route/transport/index.d.ts +39 -0
  167. package/dist/route/transport/index.js +4 -0
  168. package/dist/route/transport/websocket-channel.d.ts +56 -0
  169. package/dist/route/transport/websocket-channel.js +1 -0
  170. package/dist/route/transport/websocket.d.ts +55 -0
  171. package/dist/route/transport/websocket.js +326 -0
  172. package/dist/route.d.ts +1 -0
  173. package/dist/route.js +1 -0
  174. package/dist/schema/errors.d.ts +159 -0
  175. package/dist/schema/errors.js +155 -0
  176. package/dist/schema/events.d.ts +4587 -0
  177. package/dist/schema/events.js +492 -0
  178. package/dist/schema/ids.d.ts +30 -0
  179. package/dist/schema/ids.js +19 -0
  180. package/dist/schema/index.d.ts +5 -0
  181. package/dist/schema/index.js +5 -0
  182. package/dist/schema/messages.d.ts +402 -0
  183. package/dist/schema/messages.js +244 -0
  184. package/dist/schema/options.d.ts +159 -0
  185. package/dist/schema/options.js +202 -0
  186. package/dist/testing.d.ts +1493 -0
  187. package/dist/testing.js +88 -0
  188. package/dist/tool-runtime.d.ts +15 -0
  189. package/dist/tool-runtime.js +54 -0
  190. package/dist/tool.d.ts +135 -0
  191. package/dist/tool.js +66 -0
  192. package/dist/utils/record.d.ts +2 -0
  193. package/dist/utils/record.js +2 -0
  194. package/package.json +47 -0
@@ -0,0 +1,247 @@
1
+ import type { Route as RouteDef, 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
+ readonly apiKey?: string;
9
+ readonly baseURL?: string;
10
+ readonly credentials?: Credentials;
11
+ readonly region?: string;
12
+ readonly providerOptions?: OpenAIProviderOptionsInput;
13
+ };
14
+ export interface Settings extends ProviderPackage.Settings {
15
+ readonly apiKey?: string;
16
+ readonly auth?: "bearer" | "sigv4";
17
+ readonly baseURL?: string;
18
+ readonly credentials?: Credentials;
19
+ readonly region?: string;
20
+ readonly providerOptions?: OpenAIProviderOptionsInput;
21
+ }
22
+ export declare const routes: (RouteDef<{
23
+ readonly model: string;
24
+ readonly messages: readonly ({
25
+ readonly role: "system";
26
+ readonly content: string | readonly ({
27
+ readonly type: "text";
28
+ readonly text: string;
29
+ readonly cache_control?: {
30
+ readonly type: "ephemeral";
31
+ readonly ttl?: string | undefined;
32
+ } | undefined;
33
+ } | {
34
+ readonly type: "image_url";
35
+ readonly image_url: {
36
+ readonly url: string;
37
+ };
38
+ })[];
39
+ } | {
40
+ readonly role: "user";
41
+ readonly content: string | readonly ({
42
+ readonly type: "text";
43
+ readonly text: string;
44
+ readonly cache_control?: {
45
+ readonly type: "ephemeral";
46
+ readonly ttl?: string | undefined;
47
+ } | undefined;
48
+ } | {
49
+ readonly type: "image_url";
50
+ readonly image_url: {
51
+ readonly url: string;
52
+ };
53
+ })[];
54
+ } | {
55
+ readonly [x: string]: unknown;
56
+ readonly content: string | null;
57
+ readonly role: "assistant";
58
+ readonly reasoning?: string | undefined;
59
+ readonly reasoning_content?: string | undefined;
60
+ readonly reasoning_text?: string | undefined;
61
+ readonly cache_control?: {
62
+ readonly type: "ephemeral";
63
+ readonly ttl?: string | undefined;
64
+ } | undefined;
65
+ readonly tool_calls?: readonly {
66
+ readonly id: string;
67
+ readonly type: "function";
68
+ readonly function: {
69
+ readonly name: string;
70
+ readonly arguments: string;
71
+ };
72
+ }[] | undefined;
73
+ readonly reasoning_details?: unknown;
74
+ } | {
75
+ readonly content: string;
76
+ readonly role: "tool";
77
+ readonly tool_call_id: string;
78
+ readonly cache_control?: {
79
+ readonly type: "ephemeral";
80
+ readonly ttl?: string | undefined;
81
+ } | undefined;
82
+ })[];
83
+ readonly stream: true;
84
+ readonly stop?: readonly string[] | undefined;
85
+ readonly max_completion_tokens?: number | undefined;
86
+ readonly max_tokens?: number | undefined;
87
+ readonly tools?: readonly {
88
+ readonly function: {
89
+ readonly name: string;
90
+ readonly description: string;
91
+ readonly parameters: {
92
+ readonly [x: string]: unknown;
93
+ };
94
+ };
95
+ readonly type: "function";
96
+ readonly cache_control?: {
97
+ readonly type: "ephemeral";
98
+ readonly ttl?: string | undefined;
99
+ } | undefined;
100
+ }[] | undefined;
101
+ readonly temperature?: number | undefined;
102
+ readonly seed?: number | undefined;
103
+ readonly tool_choice?: "required" | "none" | "auto" | {
104
+ readonly type: "function";
105
+ readonly function: {
106
+ readonly name: string;
107
+ };
108
+ } | undefined;
109
+ readonly top_p?: number | undefined;
110
+ readonly store?: boolean | undefined;
111
+ readonly stream_options?: {
112
+ readonly include_usage: boolean;
113
+ } | undefined;
114
+ readonly prompt_cache_key?: string | undefined;
115
+ readonly reasoning_effort?: string | undefined;
116
+ readonly frequency_penalty?: number | undefined;
117
+ readonly presence_penalty?: number | undefined;
118
+ }, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
119
+ readonly input: readonly ({
120
+ readonly type: "reasoning";
121
+ readonly summary: readonly {
122
+ readonly type: "summary_text";
123
+ readonly text: string;
124
+ }[];
125
+ readonly id?: string | undefined;
126
+ readonly encrypted_content?: string | null | undefined;
127
+ } | {
128
+ readonly type: "item_reference";
129
+ readonly id: string;
130
+ } | {
131
+ readonly role: "system";
132
+ readonly content: string;
133
+ } | {
134
+ readonly role: "user";
135
+ readonly content: readonly ({
136
+ readonly type: "input_image";
137
+ readonly image_url: string;
138
+ } | {
139
+ readonly type: "input_file";
140
+ readonly filename: string;
141
+ readonly file_data: string;
142
+ readonly mime_type?: string | undefined;
143
+ } | {
144
+ readonly type: "input_text";
145
+ readonly text: string;
146
+ })[];
147
+ } | {
148
+ readonly content: readonly {
149
+ readonly type: "output_text";
150
+ readonly text: string;
151
+ }[];
152
+ readonly role: "assistant";
153
+ readonly phase?: "commentary" | "final_answer" | undefined;
154
+ } | {
155
+ readonly type: "function_call";
156
+ readonly call_id: string;
157
+ readonly name: string;
158
+ readonly arguments: string;
159
+ } | {
160
+ readonly type: "function_call_output";
161
+ readonly call_id: string;
162
+ readonly output: string | readonly ({
163
+ readonly type: "input_image";
164
+ readonly image_url: string;
165
+ } | {
166
+ readonly type: "input_file";
167
+ readonly filename: string;
168
+ readonly file_data: string;
169
+ readonly mime_type?: string | undefined;
170
+ } | {
171
+ readonly type: "input_text";
172
+ readonly text: string;
173
+ })[];
174
+ } | {
175
+ readonly content: readonly {
176
+ readonly type: "output_text";
177
+ readonly text: string;
178
+ }[];
179
+ readonly role: "assistant";
180
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
181
+ })[];
182
+ readonly model: string;
183
+ readonly stream: true;
184
+ readonly instructions?: string | undefined;
185
+ readonly reasoning?: {
186
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
187
+ readonly effort?: string | undefined;
188
+ } | undefined;
189
+ readonly tools?: readonly ({
190
+ readonly type: "function";
191
+ readonly description: string;
192
+ readonly name: string;
193
+ readonly parameters: {
194
+ readonly [x: string]: unknown;
195
+ };
196
+ readonly strict?: boolean | undefined;
197
+ } | {
198
+ readonly type: "image_generation";
199
+ readonly size?: string | undefined;
200
+ readonly action?: "generate" | "auto" | "edit" | undefined;
201
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
202
+ readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
203
+ readonly background?: "auto" | "opaque" | "transparent" | undefined;
204
+ readonly output_compression?: number | undefined;
205
+ readonly input_fidelity?: "low" | "high" | undefined;
206
+ readonly partial_images?: number | undefined;
207
+ })[] | undefined;
208
+ readonly text?: {
209
+ readonly verbosity?: "low" | "medium" | "high" | undefined;
210
+ } | undefined;
211
+ readonly temperature?: number | undefined;
212
+ readonly tool_choice?: "required" | "none" | "auto" | {
213
+ readonly type: "function";
214
+ readonly name: string;
215
+ } | {
216
+ readonly type: "image_generation";
217
+ } | undefined;
218
+ readonly top_p?: number | undefined;
219
+ readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
220
+ readonly store?: boolean | undefined;
221
+ readonly prompt_cache_key?: string | undefined;
222
+ readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
223
+ readonly max_output_tokens?: number | undefined;
224
+ }, import("../protocols/open-responses-channel.js").Prepared>)[];
225
+ export declare const configure: (input?: Config) => {
226
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
227
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
228
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
229
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
230
+ configure: (input?: Config) => /*elided*/ any;
231
+ };
232
+ export declare const provider: {
233
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
234
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
235
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
236
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
237
+ configure: (input?: Config) => {
238
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
239
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
240
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
241
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
242
+ configure: /*elided*/ any;
243
+ };
244
+ };
245
+ export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
246
+ export declare const responsesModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
247
+ export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
@@ -0,0 +1,68 @@
1
+ import { Auth } from "../route/auth.js";
2
+ import { OpenAIChat } from "../protocols/openai-chat.js";
3
+ import { OpenAIResponses } from "../protocols/openai-responses.js";
4
+ import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
5
+ import { ProviderID } from "../schema/index.js";
6
+ import { withOpenAIOptions } from "./openai-options.js";
7
+ export const id = ProviderID.make("amazon-bedrock");
8
+ const responsesRoute = OpenAIResponses.route.with({
9
+ id: "bedrock-mantle-responses",
10
+ provider: id,
11
+ });
12
+ const chatRoute = OpenAIChat.route.with({
13
+ id: "bedrock-mantle-chat",
14
+ provider: id,
15
+ });
16
+ export const routes = [responsesRoute, chatRoute];
17
+ const configuredRoute = (route, input) => {
18
+ const region = input.region ?? input.credentials?.region ?? "us-east-1";
19
+ const credentials = input.credentials === undefined ? undefined : { ...input.credentials, region };
20
+ return route.with({
21
+ endpoint: { baseURL: input.baseURL ?? `https://bedrock-mantle.${region}.api.aws/v1` },
22
+ auth: input.apiKey === undefined
23
+ ? BedrockAuth.sigV4(credentials, { service: "bedrock-mantle", name: "Bedrock Mantle" })
24
+ : Auth.bearer(input.apiKey),
25
+ });
26
+ };
27
+ const defaults = (input) => {
28
+ const { apiKey: _, baseURL: _baseURL, credentials: _credentials, region: _region, ...rest } = input;
29
+ return rest;
30
+ };
31
+ export const configure = (input = {}) => {
32
+ const configuredResponsesRoute = configuredRoute(responsesRoute, input);
33
+ const configuredChatRoute = configuredRoute(chatRoute, input);
34
+ const modelDefaults = defaults(input);
35
+ const responses = (modelID) => configuredResponsesRoute
36
+ .with(withOpenAIOptions(modelID, modelDefaults))
37
+ .model({ id: modelID });
38
+ const chat = (modelID) => configuredChatRoute
39
+ .with(withOpenAIOptions(modelID, modelDefaults))
40
+ .model({ id: modelID });
41
+ return {
42
+ id,
43
+ model: chat,
44
+ chat,
45
+ responses,
46
+ configure,
47
+ };
48
+ };
49
+ export const provider = configure();
50
+ const config = (settings) => {
51
+ if (settings.auth === "bearer" && settings.apiKey === undefined)
52
+ throw new Error("Amazon Bedrock Mantle bearer auth requires apiKey");
53
+ if (settings.auth === "sigv4" && settings.apiKey !== undefined)
54
+ throw new Error("Amazon Bedrock Mantle SigV4 auth does not accept apiKey");
55
+ return {
56
+ apiKey: settings.auth === "sigv4" ? undefined : settings.apiKey,
57
+ baseURL: settings.baseURL,
58
+ credentials: settings.credentials,
59
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
60
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
61
+ limits: settings.limits,
62
+ providerOptions: settings.providerOptions,
63
+ region: settings.region,
64
+ };
65
+ };
66
+ export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
67
+ export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
68
+ export const model = chatModel;
@@ -0,0 +1,172 @@
1
+ import type { RouteDefaultsInput } from "../route/client.js";
2
+ import type { ProviderPackage } from "../provider-package.js";
3
+ import { type ModelID } from "../schema/index.js";
4
+ import type { BedrockCredentials } from "../protocols/bedrock-converse.js";
5
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
6
+ export type Config = RouteDefaultsInput & {
7
+ readonly apiKey?: string;
8
+ readonly headers?: Record<string, string>;
9
+ readonly credentials?: BedrockCredentials;
10
+ /** AWS region. Defaults to `us-east-1` when neither this nor `credentials.region` is set. */
11
+ readonly region?: string;
12
+ /** Override the computed `https://bedrock-runtime.<region>.amazonaws.com` URL. */
13
+ readonly baseURL?: string;
14
+ };
15
+ export interface Settings extends ProviderPackage.Settings {
16
+ readonly apiKey?: string;
17
+ readonly auth?: "bearer" | "sigv4";
18
+ readonly baseURL?: string;
19
+ readonly credentials?: BedrockCredentials;
20
+ readonly region?: string;
21
+ readonly topP?: number;
22
+ }
23
+ export declare const routes: import("../route/client.js").Route<{
24
+ readonly messages: readonly ({
25
+ readonly role: "user";
26
+ readonly content: readonly ({
27
+ readonly cachePoint: {
28
+ readonly type: "default";
29
+ readonly ttl?: "1h" | "5m" | undefined;
30
+ };
31
+ } | {
32
+ readonly image: {
33
+ readonly format: "png" | "jpeg" | "gif" | "webp";
34
+ readonly source: {
35
+ readonly bytes: string;
36
+ };
37
+ };
38
+ } | {
39
+ readonly document: {
40
+ readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
41
+ readonly name: string;
42
+ readonly source: {
43
+ readonly bytes: string;
44
+ };
45
+ };
46
+ } | {
47
+ readonly text: string;
48
+ } | {
49
+ readonly toolResult: {
50
+ readonly content: readonly ({
51
+ readonly image: {
52
+ readonly format: "png" | "jpeg" | "gif" | "webp";
53
+ readonly source: {
54
+ readonly bytes: string;
55
+ };
56
+ };
57
+ } | {
58
+ readonly document: {
59
+ readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
60
+ readonly name: string;
61
+ readonly source: {
62
+ readonly bytes: string;
63
+ };
64
+ };
65
+ } | {
66
+ readonly text: string;
67
+ } | {
68
+ readonly json: unknown;
69
+ })[];
70
+ readonly toolUseId: string;
71
+ readonly status?: "error" | "success" | undefined;
72
+ };
73
+ })[];
74
+ } | {
75
+ readonly role: "assistant";
76
+ readonly content: readonly ({
77
+ readonly cachePoint: {
78
+ readonly type: "default";
79
+ readonly ttl?: "1h" | "5m" | undefined;
80
+ };
81
+ } | {
82
+ readonly text: string;
83
+ } | {
84
+ readonly toolUse: {
85
+ readonly toolUseId: string;
86
+ readonly name: string;
87
+ readonly input: unknown;
88
+ };
89
+ } | {
90
+ readonly reasoningContent: {
91
+ readonly reasoningText: {
92
+ readonly text: string;
93
+ readonly signature?: string | undefined;
94
+ };
95
+ } | {
96
+ readonly redactedContent: string;
97
+ };
98
+ })[];
99
+ })[];
100
+ readonly modelId: string;
101
+ readonly system?: readonly ({
102
+ readonly cachePoint: {
103
+ readonly type: "default";
104
+ readonly ttl?: "1h" | "5m" | undefined;
105
+ };
106
+ } | {
107
+ readonly text: string;
108
+ })[] | undefined;
109
+ readonly inferenceConfig?: {
110
+ readonly maxTokens?: number | undefined;
111
+ readonly temperature?: number | undefined;
112
+ readonly topP?: number | undefined;
113
+ readonly stopSequences?: readonly string[] | undefined;
114
+ } | undefined;
115
+ readonly toolConfig?: {
116
+ readonly tools: readonly ({
117
+ readonly cachePoint: {
118
+ readonly type: "default";
119
+ readonly ttl?: "1h" | "5m" | undefined;
120
+ };
121
+ } | {
122
+ readonly toolSpec: {
123
+ readonly name: string;
124
+ readonly description: string;
125
+ readonly inputSchema: {
126
+ readonly json: {
127
+ readonly [x: string]: unknown;
128
+ };
129
+ };
130
+ };
131
+ })[];
132
+ readonly toolChoice?: {
133
+ readonly auto: {};
134
+ } | {
135
+ readonly any: {};
136
+ } | {
137
+ readonly tool: {
138
+ readonly name: string;
139
+ };
140
+ } | undefined;
141
+ } | undefined;
142
+ readonly additionalModelRequestFields?: {
143
+ readonly [x: string]: unknown;
144
+ } | undefined;
145
+ }, import("../route/transport/http.js").HttpPrepared<object>>[];
146
+ export declare const configure: (input?: Config) => {
147
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
148
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
149
+ readonly [x: string]: {
150
+ readonly [x: string]: unknown;
151
+ };
152
+ }>;
153
+ configure: (input?: Config) => /*elided*/ any;
154
+ };
155
+ export declare const provider: {
156
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
157
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
158
+ readonly [x: string]: {
159
+ readonly [x: string]: unknown;
160
+ };
161
+ }>;
162
+ configure: (input?: Config) => {
163
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
164
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
165
+ readonly [x: string]: {
166
+ readonly [x: string]: unknown;
167
+ };
168
+ }>;
169
+ configure: /*elided*/ any;
170
+ };
171
+ };
172
+ export declare const model: ProviderPackage.Definition<Settings>["model"];
@@ -0,0 +1,41 @@
1
+ import { Auth } from "../route/auth.js";
2
+ import { ProviderID } from "../schema/index.js";
3
+ import * as BedrockConverse from "../protocols/bedrock-converse.js";
4
+ export const id = ProviderID.make("amazon-bedrock");
5
+ export const routes = [BedrockConverse.route];
6
+ const bedrockBaseURL = (region) => `https://bedrock-runtime.${region}.amazonaws.com`;
7
+ const configuredRoute = (input) => {
8
+ const { apiKey, credentials, region, baseURL, ...rest } = input;
9
+ const resolvedRegion = region ?? credentials?.region ?? "us-east-1";
10
+ return BedrockConverse.route.with({
11
+ ...rest,
12
+ provider: id,
13
+ endpoint: { baseURL: baseURL ?? bedrockBaseURL(resolvedRegion) },
14
+ auth: apiKey === undefined ? BedrockConverse.sigV4Auth(credentials) : Auth.bearer(apiKey),
15
+ });
16
+ };
17
+ export const configure = (input = {}) => {
18
+ const route = configuredRoute(input);
19
+ return {
20
+ id,
21
+ model: (modelID) => route.model({ id: modelID }),
22
+ configure,
23
+ };
24
+ };
25
+ export const provider = configure();
26
+ export const model = (modelID, settings) => {
27
+ if (settings.auth === "bearer" && settings.apiKey === undefined)
28
+ throw new Error("Amazon Bedrock bearer auth requires apiKey");
29
+ if (settings.auth === "sigv4" && settings.apiKey !== undefined)
30
+ throw new Error("Amazon Bedrock SigV4 auth does not accept apiKey");
31
+ return configure({
32
+ apiKey: settings.auth === "sigv4" ? undefined : settings.apiKey,
33
+ baseURL: settings.baseURL,
34
+ credentials: settings.credentials,
35
+ generation: settings.topP === undefined ? undefined : { topP: settings.topP },
36
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
37
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
38
+ limits: settings.limits,
39
+ region: settings.region,
40
+ }).model(modelID);
41
+ };