@tanstack/ai-bedrock 0.1.3 → 0.1.5

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.
@@ -1,21 +1,24 @@
1
+ //#region src/converse/tool-converter.ts
1
2
  function toToolConfig(tools, choice) {
2
- if (!tools.length) return void 0;
3
- const toolChoice = mapChoice();
4
- return {
5
- tools: tools.map((t) => ({
6
- toolSpec: {
7
- name: t.name,
8
- ...t.description ? { description: t.description } : {},
9
- inputSchema: { json: t.inputSchema }
10
- }
11
- })),
12
- ...toolChoice ? { toolChoice } : {}
13
- };
3
+ if (!tools.length) return void 0;
4
+ if (choice === "none") return void 0;
5
+ const toolChoice = mapChoice(choice);
6
+ return {
7
+ tools: tools.map((t) => ({ toolSpec: {
8
+ name: t.name,
9
+ ...t.description ? { description: t.description } : {},
10
+ inputSchema: { json: t.inputSchema }
11
+ } })),
12
+ ...toolChoice ? { toolChoice } : {}
13
+ };
14
14
  }
15
15
  function mapChoice(choice) {
16
- return { auto: {} };
16
+ if (!choice || choice === "auto") return { auto: {} };
17
+ if (choice === "required") return { any: {} };
18
+ if (choice === "none") return void 0;
19
+ return { tool: { name: choice.name } };
17
20
  }
18
- export {
19
- toToolConfig
20
- };
21
- //# sourceMappingURL=tool-converter.js.map
21
+ //#endregion
22
+ export { toToolConfig };
23
+
24
+ //# sourceMappingURL=tool-converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-converter.js","sources":["../../../src/converse/tool-converter.ts"],"sourcesContent":["import type {\n ToolChoice,\n ToolConfiguration,\n} from '@aws-sdk/client-bedrock-runtime'\nimport type { DocumentType } from '@smithy/types'\n\nexport interface ConverseToolInput {\n name: string\n description?: string\n inputSchema: unknown\n}\n\nexport type ToolChoiceInput =\n | 'auto'\n | 'required'\n | 'none'\n | { type: 'tool'; name: string }\n\nexport function toToolConfig(\n tools: Array<ConverseToolInput>,\n choice: ToolChoiceInput | undefined,\n): ToolConfiguration | undefined {\n if (!tools.length) return undefined\n // `none` means \"don't call tools\" — omit the tool config entirely, since\n // Bedrock treats a present tool config with no `toolChoice` as auto.\n if (choice === 'none') return undefined\n const toolChoice = mapChoice(choice)\n return {\n tools: tools.map((t) => ({\n toolSpec: {\n name: t.name,\n ...(t.description ? { description: t.description } : {}),\n inputSchema: { json: t.inputSchema as DocumentType },\n },\n })),\n ...(toolChoice ? { toolChoice } : {}),\n }\n}\n\nfunction mapChoice(\n choice: ToolChoiceInput | undefined,\n): ToolChoice | undefined {\n if (!choice || choice === 'auto') return { auto: {} }\n if (choice === 'required') return { any: {} }\n // `none` is handled earlier in toToolConfig (omits the tool config); this\n // branch keeps the string union narrowed so `choice.name` type-checks.\n if (choice === 'none') return undefined\n return { tool: { name: choice.name } }\n}\n"],"names":[],"mappings":"AAkBO,SAAS,aACd,OACA,QAC+B;AAC/B,MAAI,CAAC,MAAM,OAAQ,QAAO;AAI1B,QAAM,aAAa,UAAgB;AACnC,SAAO;AAAA,IACL,OAAO,MAAM,IAAI,CAAC,OAAO;AAAA,MACvB,UAAU;AAAA,QACR,MAAM,EAAE;AAAA,QACR,GAAI,EAAE,cAAc,EAAE,aAAa,EAAE,YAAA,IAAgB,CAAA;AAAA,QACrD,aAAa,EAAE,MAAM,EAAE,YAAA;AAAA,MAA4B;AAAA,IACrD,EACA;AAAA,IACF,GAAI,aAAa,EAAE,eAAe,CAAA;AAAA,EAAC;AAEvC;AAEA,SAAS,UACP,QACwB;SACiB,EAAE,MAAM,GAAC;AAMpD;"}
1
+ {"version":3,"file":"tool-converter.js","names":[],"sources":["../../../src/converse/tool-converter.ts"],"sourcesContent":["import type {\n ToolChoice,\n ToolConfiguration,\n} from '@aws-sdk/client-bedrock-runtime'\nimport type { DocumentType } from '@smithy/types'\n\nexport interface ConverseToolInput {\n name: string\n description?: string\n inputSchema: unknown\n}\n\nexport type ToolChoiceInput =\n | 'auto'\n | 'required'\n | 'none'\n | { type: 'tool'; name: string }\n\nexport function toToolConfig(\n tools: Array<ConverseToolInput>,\n choice: ToolChoiceInput | undefined,\n): ToolConfiguration | undefined {\n if (!tools.length) return undefined\n // `none` means \"don't call tools\" — omit the tool config entirely, since\n // Bedrock treats a present tool config with no `toolChoice` as auto.\n if (choice === 'none') return undefined\n const toolChoice = mapChoice(choice)\n return {\n tools: tools.map((t) => ({\n toolSpec: {\n name: t.name,\n ...(t.description ? { description: t.description } : {}),\n inputSchema: { json: t.inputSchema as DocumentType },\n },\n })),\n ...(toolChoice ? { toolChoice } : {}),\n }\n}\n\nfunction mapChoice(\n choice: ToolChoiceInput | undefined,\n): ToolChoice | undefined {\n if (!choice || choice === 'auto') return { auto: {} }\n if (choice === 'required') return { any: {} }\n // `none` is handled earlier in toToolConfig (omits the tool config); this\n // branch keeps the string union narrowed so `choice.name` type-checks.\n if (choice === 'none') return undefined\n return { tool: { name: choice.name } }\n}\n"],"mappings":";AAkBA,SAAgB,aACd,OACA,QAC+B;CAC/B,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAA;CAG1B,IAAI,WAAW,QAAQ,OAAO,KAAA;CAC9B,MAAM,aAAa,UAAU,MAAM;CACnC,OAAO;EACL,OAAO,MAAM,KAAK,OAAO,EACvB,UAAU;GACR,MAAM,EAAE;GACR,GAAI,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,IAAI,CAAC;GACtD,aAAa,EAAE,MAAM,EAAE,YAA4B;EACrD,EACF,EAAE;EACF,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;CACrC;AACF;AAEA,SAAS,UACP,QACwB;CACxB,IAAI,CAAC,UAAU,WAAW,QAAQ,OAAO,EAAE,MAAM,CAAC,EAAE;CACpD,IAAI,WAAW,YAAY,OAAO,EAAE,KAAK,CAAC,EAAE;CAG5C,IAAI,WAAW,QAAQ,OAAO,KAAA;CAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,KAAK,EAAE;AACvC"}
package/dist/esm/index.js CHANGED
@@ -1,62 +1,61 @@
1
- import { BedrockTextAdapter } from "./adapters/text.js";
2
- import { createBedrockChat } from "./adapters/text.js";
3
- import { BedrockResponsesTextAdapter } from "./adapters/responses-text.js";
4
- import { createBedrockResponsesText } from "./adapters/responses-text.js";
5
- import { BedrockConverseTextAdapter } from "./adapters/converse-text.js";
6
- import { createBedrockConverse } from "./adapters/converse-text.js";
7
- import { BEDROCK_RESPONSES_MODELS, BEDROCK_CHAT_MODELS } from "./model-meta.js";
8
- import { BEDROCK_CONVERSE_MODELS } from "./model-meta.js";
9
- import { withBedrockDefaults } from "./utils/client.js";
10
1
  import { resolveBedrockAuth } from "./utils/auth.js";
2
+ import { withBedrockDefaults } from "./utils/client.js";
3
+ import { BedrockTextAdapter, createBedrockChat } from "./adapters/text.js";
4
+ import { BedrockResponsesTextAdapter, createBedrockResponsesText } from "./adapters/responses-text.js";
5
+ import { BedrockConverseTextAdapter, createBedrockConverse } from "./adapters/converse-text.js";
6
+ import { BEDROCK_CHAT_MODELS, BEDROCK_CONVERSE_MODELS, BEDROCK_RESPONSES_MODELS } from "./model-meta.js";
7
+ //#region src/index.ts
8
+ /**
9
+ * @module @tanstack/ai-bedrock
10
+ *
11
+ * Amazon Bedrock adapter for TanStack AI via Bedrock's OpenAI-compatible APIs
12
+ * and the native Converse API. The public `bedrockText` / `createBedrockText`
13
+ * factory branches between the Converse adapter (DEFAULT), the Chat Completions
14
+ * adapter (`api: 'chat'`), and the Responses adapter (`api: 'responses'`).
15
+ */
16
+ /** Cast-free runtime guard: is this model in the Responses-capable subset? */
11
17
  function isResponsesModel(model) {
12
- return BEDROCK_RESPONSES_MODELS.some((m) => m === model);
18
+ return BEDROCK_RESPONSES_MODELS.some((m) => m === model);
13
19
  }
20
+ /** Cast-free runtime guard: is this model in the Chat-capable subset? */
14
21
  function isChatModel(model) {
15
- return BEDROCK_CHAT_MODELS.some((m) => m === model);
22
+ return BEDROCK_CHAT_MODELS.some((m) => m === model);
16
23
  }
24
+ /** Strip the `api` discriminator from a config without an unused-var lint error. */
17
25
  function stripApi(config) {
18
- const { api, ...rest } = config;
19
- return rest;
26
+ const { api, ...rest } = config;
27
+ return rest;
20
28
  }
29
+ /**
30
+ * Shared branching used by both public factories. Constructs the adapter
31
+ * classes directly so their constructors run the full auth cascade lazily
32
+ * (config.apiKey → BEDROCK_API_KEY → AWS_BEARER_TOKEN_BEDROCK → SigV4). No
33
+ * eager env-key fetch here, so `auth: 'sigv4'` never throws for a missing key.
34
+ *
35
+ * Default path → Converse adapter; opt-in via `api: 'chat'` or `api: 'responses'`.
36
+ */
21
37
  function build(model, config) {
22
- if (config?.api === "responses") {
23
- const rest = stripApi(config);
24
- if (!isResponsesModel(model)) {
25
- throw new Error(
26
- `Model "${model}" is not available on the Bedrock Responses API. Responses-capable models: ${BEDROCK_RESPONSES_MODELS.join(", ")}.`
27
- );
28
- }
29
- return new BedrockResponsesTextAdapter(rest, model);
30
- }
31
- if (config?.api === "chat") {
32
- if (!isChatModel(model)) {
33
- throw new Error(
34
- `Model "${model}" is not available on the Bedrock Chat Completions API. Chat-capable models: ${BEDROCK_CHAT_MODELS.join(", ")}.`
35
- );
36
- }
37
- return new BedrockTextAdapter(stripApi(config), model);
38
- }
39
- return new BedrockConverseTextAdapter(config ? stripApi(config) : {}, model);
38
+ if (config?.api === "responses") {
39
+ const rest = stripApi(config);
40
+ if (!isResponsesModel(model)) throw new Error(`Model "${model}" is not available on the Bedrock Responses API. Responses-capable models: ${BEDROCK_RESPONSES_MODELS.join(", ")}.`);
41
+ return new BedrockResponsesTextAdapter(rest, model);
42
+ }
43
+ if (config?.api === "chat") {
44
+ if (!isChatModel(model)) throw new Error(`Model "${model}" is not available on the Bedrock Chat Completions API. Chat-capable models: ${BEDROCK_CHAT_MODELS.join(", ")}.`);
45
+ return new BedrockTextAdapter(stripApi(config), model);
46
+ }
47
+ return new BedrockConverseTextAdapter(config ? stripApi(config) : {}, model);
40
48
  }
41
49
  function createBedrockText(model, apiKey, config) {
42
- return build(model, { ...config, apiKey });
50
+ return build(model, {
51
+ ...config,
52
+ apiKey
53
+ });
43
54
  }
44
55
  function bedrockText(model, config) {
45
- return build(model, config);
56
+ return build(model, config);
46
57
  }
47
- export {
48
- BEDROCK_CHAT_MODELS,
49
- BEDROCK_CONVERSE_MODELS,
50
- BEDROCK_RESPONSES_MODELS,
51
- BedrockConverseTextAdapter,
52
- BedrockResponsesTextAdapter,
53
- BedrockTextAdapter,
54
- bedrockText,
55
- createBedrockChat,
56
- createBedrockConverse,
57
- createBedrockResponsesText,
58
- createBedrockText,
59
- resolveBedrockAuth,
60
- withBedrockDefaults
61
- };
62
- //# sourceMappingURL=index.js.map
58
+ //#endregion
59
+ export { BEDROCK_CHAT_MODELS, BEDROCK_CONVERSE_MODELS, BEDROCK_RESPONSES_MODELS, BedrockConverseTextAdapter, BedrockResponsesTextAdapter, BedrockTextAdapter, bedrockText, createBedrockChat, createBedrockConverse, createBedrockResponsesText, createBedrockText, resolveBedrockAuth, withBedrockDefaults };
60
+
61
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["/**\n * @module @tanstack/ai-bedrock\n *\n * Amazon Bedrock adapter for TanStack AI via Bedrock's OpenAI-compatible APIs\n * and the native Converse API. The public `bedrockText` / `createBedrockText`\n * factory branches between the Converse adapter (DEFAULT), the Chat Completions\n * adapter (`api: 'chat'`), and the Responses adapter (`api: 'responses'`).\n */\nimport { BedrockTextAdapter } from './adapters/text'\nimport { BedrockResponsesTextAdapter } from './adapters/responses-text'\nimport { BedrockConverseTextAdapter } from './adapters/converse-text'\nimport { BEDROCK_CHAT_MODELS, BEDROCK_RESPONSES_MODELS } from './model-meta'\nimport type { BedrockTextConfig } from './adapters/text'\nimport type { BedrockResponsesConfig } from './adapters/responses-text'\nimport type { BedrockConverseConfig } from './adapters/converse-text'\nimport type { BedrockClientConfig } from './utils/client'\nimport type {\n BedrockChatModels,\n BedrockConverseModels,\n BedrockResponsesModels,\n} from './model-meta'\n\n/** Config for the branching factory's converse mode (default, or api: 'converse'). */\nexport type BedrockConverseApiConfig = BedrockConverseConfig & {\n api?: 'converse'\n}\n/** Config for the branching factory's chat mode (api: 'chat' required). */\nexport type BedrockChatApiConfig = BedrockTextConfig & {\n api: 'chat'\n}\n/** Config for the branching factory's responses mode (api: 'responses' required). */\nexport type BedrockResponsesApiConfig = BedrockResponsesConfig & {\n api: 'responses'\n}\n\ntype AnyBedrockAdapter =\n | BedrockConverseTextAdapter<BedrockConverseModels>\n | BedrockTextAdapter<BedrockChatModels>\n | BedrockResponsesTextAdapter<BedrockResponsesModels>\n\n/** Cast-free runtime guard: is this model in the Responses-capable subset? */\nfunction isResponsesModel(model: string): model is BedrockResponsesModels {\n return BEDROCK_RESPONSES_MODELS.some((m) => m === model)\n}\n\n/** Cast-free runtime guard: is this model in the Chat-capable subset? */\nfunction isChatModel(model: string): model is BedrockChatModels {\n return BEDROCK_CHAT_MODELS.some((m) => m === model)\n}\n\n/** Strip the `api` discriminator from a config without an unused-var lint error. */\nfunction stripApi<T extends { api?: unknown }>(config: T): Omit<T, 'api'> {\n const { api, ...rest } = config\n void api\n return rest\n}\n\n/**\n * Shared branching used by both public factories. Constructs the adapter\n * classes directly so their constructors run the full auth cascade lazily\n * (config.apiKey → BEDROCK_API_KEY → AWS_BEARER_TOKEN_BEDROCK → SigV4). No\n * eager env-key fetch here, so `auth: 'sigv4'` never throws for a missing key.\n *\n * Default path → Converse adapter; opt-in via `api: 'chat'` or `api: 'responses'`.\n */\nfunction build(\n model: BedrockConverseModels,\n config?: BedrockClientConfig & { api?: 'converse' | 'chat' | 'responses' },\n): AnyBedrockAdapter {\n if (config?.api === 'responses') {\n const rest = stripApi(config)\n if (!isResponsesModel(model)) {\n throw new Error(\n `Model \"${model}\" is not available on the Bedrock Responses API. ` +\n `Responses-capable models: ${BEDROCK_RESPONSES_MODELS.join(', ')}.`,\n )\n }\n return new BedrockResponsesTextAdapter(rest, model)\n }\n if (config?.api === 'chat') {\n if (!isChatModel(model)) {\n throw new Error(\n `Model \"${model}\" is not available on the Bedrock Chat Completions API. ` +\n `Chat-capable models: ${BEDROCK_CHAT_MODELS.join(', ')}.`,\n )\n }\n return new BedrockTextAdapter(stripApi(config), model)\n }\n // Default + explicit 'converse'\n return new BedrockConverseTextAdapter(config ? stripApi(config) : {}, model)\n}\n\n// --- createBedrockText: explicit key, overloaded on `api` ---\nexport function createBedrockText<TModel extends BedrockConverseModels>(\n model: TModel,\n apiKey: string,\n config?: BedrockConverseApiConfig,\n): BedrockConverseTextAdapter<TModel>\nexport function createBedrockText<TModel extends BedrockChatModels>(\n model: TModel,\n apiKey: string,\n config: BedrockChatApiConfig,\n): BedrockTextAdapter<TModel>\nexport function createBedrockText<TModel extends BedrockResponsesModels>(\n model: TModel,\n apiKey: string,\n config: BedrockResponsesApiConfig,\n): BedrockResponsesTextAdapter<TModel>\nexport function createBedrockText(\n model: BedrockConverseModels,\n apiKey: string,\n config?:\n | BedrockConverseApiConfig\n | BedrockChatApiConfig\n | BedrockResponsesApiConfig,\n): AnyBedrockAdapter {\n // Explicit apiKey is authoritative — spread config first so it can't override.\n return build(model, { ...config, apiKey })\n}\n\n// --- bedrockText: env-key counterpart, same overloads ---\nexport function bedrockText<TModel extends BedrockConverseModels>(\n model: TModel,\n config?: BedrockConverseApiConfig,\n): BedrockConverseTextAdapter<TModel>\nexport function bedrockText<TModel extends BedrockChatModels>(\n model: TModel,\n config: BedrockChatApiConfig,\n): BedrockTextAdapter<TModel>\nexport function bedrockText<TModel extends BedrockResponsesModels>(\n model: TModel,\n config: BedrockResponsesApiConfig,\n): BedrockResponsesTextAdapter<TModel>\nexport function bedrockText(\n model: BedrockConverseModels,\n config?:\n | BedrockConverseApiConfig\n | BedrockChatApiConfig\n | BedrockResponsesApiConfig,\n): AnyBedrockAdapter {\n // No eager env-key fetch: the adapter constructor resolves auth lazily so\n // SigV4 (and the env-key fallback) work without a forced API key here.\n return build(model, config)\n}\n\n// --- Re-exports ---\nexport {\n BedrockTextAdapter,\n createBedrockChat,\n type BedrockTextConfig,\n type BedrockTextProviderOptions,\n} from './adapters/text'\nexport {\n BedrockResponsesTextAdapter,\n createBedrockResponsesText,\n type BedrockResponsesConfig,\n type BedrockResponsesProviderOptions,\n} from './adapters/responses-text'\nexport {\n BedrockConverseTextAdapter,\n createBedrockConverse,\n type BedrockConverseConfig,\n} from './adapters/converse-text'\nexport type { BedrockConverseProviderOptions } from './converse/provider-options'\nexport {\n resolveBedrockAuth,\n withBedrockDefaults,\n type BedrockClientConfig,\n type BedrockEndpoint,\n type ResolvedBedrockAuth,\n} from './utils/client'\nexport {\n BEDROCK_CHAT_MODELS,\n BEDROCK_RESPONSES_MODELS,\n BEDROCK_CONVERSE_MODELS,\n type BedrockChatModels,\n type BedrockResponsesModels,\n type BedrockConverseModels,\n type BedrockChatModelProviderOptionsByName,\n type BedrockChatModelToolCapabilitiesByName,\n type BedrockModelInputModalitiesByName,\n} from './model-meta'\nexport type {\n BedrockMessageMetadataByModality,\n BedrockTextMetadata,\n BedrockImageMetadata,\n BedrockAudioMetadata,\n BedrockVideoMetadata,\n BedrockDocumentMetadata,\n} from './message-types'\n"],"names":[],"mappings":";;;;;;;;;;AAyCA,SAAS,iBAAiB,OAAgD;AACxE,SAAO,yBAAyB,KAAK,CAAC,MAAM,MAAM,KAAK;AACzD;AAGA,SAAS,YAAY,OAA2C;AAC9D,SAAO,oBAAoB,KAAK,CAAC,MAAM,MAAM,KAAK;AACpD;AAGA,SAAS,SAAsC,QAA2B;AACxE,QAAM,EAAE,KAAK,GAAG,KAAA,IAAS;AAEzB,SAAO;AACT;AAUA,SAAS,MACP,OACA,QACmB;AACnB,MAAI,QAAQ,QAAQ,aAAa;AAC/B,UAAM,OAAO,SAAS,MAAM;AAC5B,QAAI,CAAC,iBAAiB,KAAK,GAAG;AAC5B,YAAM,IAAI;AAAA,QACR,UAAU,KAAK,8EACgB,yBAAyB,KAAK,IAAI,CAAC;AAAA,MAAA;AAAA,IAEtE;AACA,WAAO,IAAI,4BAA4B,MAAM,KAAK;AAAA,EACpD;AACA,MAAI,QAAQ,QAAQ,QAAQ;AAC1B,QAAI,CAAC,YAAY,KAAK,GAAG;AACvB,YAAM,IAAI;AAAA,QACR,UAAU,KAAK,gFACW,oBAAoB,KAAK,IAAI,CAAC;AAAA,MAAA;AAAA,IAE5D;AACA,WAAO,IAAI,mBAAmB,SAAS,MAAM,GAAG,KAAK;AAAA,EACvD;AAEA,SAAO,IAAI,2BAA2B,SAAS,SAAS,MAAM,IAAI,CAAA,GAAI,KAAK;AAC7E;AAkBO,SAAS,kBACd,OACA,QACA,QAImB;AAEnB,SAAO,MAAM,OAAO,EAAE,GAAG,QAAQ,QAAQ;AAC3C;AAeO,SAAS,YACd,OACA,QAImB;AAGnB,SAAO,MAAM,OAAO,MAAM;AAC5B;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @module @tanstack/ai-bedrock\n *\n * Amazon Bedrock adapter for TanStack AI via Bedrock's OpenAI-compatible APIs\n * and the native Converse API. The public `bedrockText` / `createBedrockText`\n * factory branches between the Converse adapter (DEFAULT), the Chat Completions\n * adapter (`api: 'chat'`), and the Responses adapter (`api: 'responses'`).\n */\nimport { BedrockTextAdapter } from './adapters/text'\nimport { BedrockResponsesTextAdapter } from './adapters/responses-text'\nimport { BedrockConverseTextAdapter } from './adapters/converse-text'\nimport { BEDROCK_CHAT_MODELS, BEDROCK_RESPONSES_MODELS } from './model-meta'\nimport type { BedrockTextConfig } from './adapters/text'\nimport type { BedrockResponsesConfig } from './adapters/responses-text'\nimport type { BedrockConverseConfig } from './adapters/converse-text'\nimport type { BedrockClientConfig } from './utils/client'\nimport type {\n BedrockChatModels,\n BedrockConverseModels,\n BedrockResponsesModels,\n} from './model-meta'\n\n/** Config for the branching factory's converse mode (default, or api: 'converse'). */\nexport type BedrockConverseApiConfig = BedrockConverseConfig & {\n api?: 'converse'\n}\n/** Config for the branching factory's chat mode (api: 'chat' required). */\nexport type BedrockChatApiConfig = BedrockTextConfig & {\n api: 'chat'\n}\n/** Config for the branching factory's responses mode (api: 'responses' required). */\nexport type BedrockResponsesApiConfig = BedrockResponsesConfig & {\n api: 'responses'\n}\n\ntype AnyBedrockAdapter =\n | BedrockConverseTextAdapter<BedrockConverseModels>\n | BedrockTextAdapter<BedrockChatModels>\n | BedrockResponsesTextAdapter<BedrockResponsesModels>\n\n/** Cast-free runtime guard: is this model in the Responses-capable subset? */\nfunction isResponsesModel(model: string): model is BedrockResponsesModels {\n return BEDROCK_RESPONSES_MODELS.some((m) => m === model)\n}\n\n/** Cast-free runtime guard: is this model in the Chat-capable subset? */\nfunction isChatModel(model: string): model is BedrockChatModels {\n return BEDROCK_CHAT_MODELS.some((m) => m === model)\n}\n\n/** Strip the `api` discriminator from a config without an unused-var lint error. */\nfunction stripApi<T extends { api?: unknown }>(config: T): Omit<T, 'api'> {\n const { api, ...rest } = config\n void api\n return rest\n}\n\n/**\n * Shared branching used by both public factories. Constructs the adapter\n * classes directly so their constructors run the full auth cascade lazily\n * (config.apiKey → BEDROCK_API_KEY → AWS_BEARER_TOKEN_BEDROCK → SigV4). No\n * eager env-key fetch here, so `auth: 'sigv4'` never throws for a missing key.\n *\n * Default path → Converse adapter; opt-in via `api: 'chat'` or `api: 'responses'`.\n */\nfunction build(\n model: BedrockConverseModels,\n config?: BedrockClientConfig & { api?: 'converse' | 'chat' | 'responses' },\n): AnyBedrockAdapter {\n if (config?.api === 'responses') {\n const rest = stripApi(config)\n if (!isResponsesModel(model)) {\n throw new Error(\n `Model \"${model}\" is not available on the Bedrock Responses API. ` +\n `Responses-capable models: ${BEDROCK_RESPONSES_MODELS.join(', ')}.`,\n )\n }\n return new BedrockResponsesTextAdapter(rest, model)\n }\n if (config?.api === 'chat') {\n if (!isChatModel(model)) {\n throw new Error(\n `Model \"${model}\" is not available on the Bedrock Chat Completions API. ` +\n `Chat-capable models: ${BEDROCK_CHAT_MODELS.join(', ')}.`,\n )\n }\n return new BedrockTextAdapter(stripApi(config), model)\n }\n // Default + explicit 'converse'\n return new BedrockConverseTextAdapter(config ? stripApi(config) : {}, model)\n}\n\n// --- createBedrockText: explicit key, overloaded on `api` ---\nexport function createBedrockText<TModel extends BedrockConverseModels>(\n model: TModel,\n apiKey: string,\n config?: BedrockConverseApiConfig,\n): BedrockConverseTextAdapter<TModel>\nexport function createBedrockText<TModel extends BedrockChatModels>(\n model: TModel,\n apiKey: string,\n config: BedrockChatApiConfig,\n): BedrockTextAdapter<TModel>\nexport function createBedrockText<TModel extends BedrockResponsesModels>(\n model: TModel,\n apiKey: string,\n config: BedrockResponsesApiConfig,\n): BedrockResponsesTextAdapter<TModel>\nexport function createBedrockText(\n model: BedrockConverseModels,\n apiKey: string,\n config?:\n | BedrockConverseApiConfig\n | BedrockChatApiConfig\n | BedrockResponsesApiConfig,\n): AnyBedrockAdapter {\n // Explicit apiKey is authoritative — spread config first so it can't override.\n return build(model, { ...config, apiKey })\n}\n\n// --- bedrockText: env-key counterpart, same overloads ---\nexport function bedrockText<TModel extends BedrockConverseModels>(\n model: TModel,\n config?: BedrockConverseApiConfig,\n): BedrockConverseTextAdapter<TModel>\nexport function bedrockText<TModel extends BedrockChatModels>(\n model: TModel,\n config: BedrockChatApiConfig,\n): BedrockTextAdapter<TModel>\nexport function bedrockText<TModel extends BedrockResponsesModels>(\n model: TModel,\n config: BedrockResponsesApiConfig,\n): BedrockResponsesTextAdapter<TModel>\nexport function bedrockText(\n model: BedrockConverseModels,\n config?:\n | BedrockConverseApiConfig\n | BedrockChatApiConfig\n | BedrockResponsesApiConfig,\n): AnyBedrockAdapter {\n // No eager env-key fetch: the adapter constructor resolves auth lazily so\n // SigV4 (and the env-key fallback) work without a forced API key here.\n return build(model, config)\n}\n\n// --- Re-exports ---\nexport {\n BedrockTextAdapter,\n createBedrockChat,\n type BedrockTextConfig,\n type BedrockTextProviderOptions,\n} from './adapters/text'\nexport {\n BedrockResponsesTextAdapter,\n createBedrockResponsesText,\n type BedrockResponsesConfig,\n type BedrockResponsesProviderOptions,\n} from './adapters/responses-text'\nexport {\n BedrockConverseTextAdapter,\n createBedrockConverse,\n type BedrockConverseConfig,\n} from './adapters/converse-text'\nexport type { BedrockConverseProviderOptions } from './converse/provider-options'\nexport {\n resolveBedrockAuth,\n withBedrockDefaults,\n type BedrockClientConfig,\n type BedrockEndpoint,\n type ResolvedBedrockAuth,\n} from './utils/client'\nexport {\n BEDROCK_CHAT_MODELS,\n BEDROCK_RESPONSES_MODELS,\n BEDROCK_CONVERSE_MODELS,\n type BedrockChatModels,\n type BedrockResponsesModels,\n type BedrockConverseModels,\n type BedrockChatModelProviderOptionsByName,\n type BedrockChatModelToolCapabilitiesByName,\n type BedrockModelInputModalitiesByName,\n} from './model-meta'\nexport type {\n BedrockMessageMetadataByModality,\n BedrockTextMetadata,\n BedrockImageMetadata,\n BedrockAudioMetadata,\n BedrockVideoMetadata,\n BedrockDocumentMetadata,\n} from './message-types'\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,SAAS,iBAAiB,OAAgD;CACxE,OAAO,yBAAyB,MAAM,MAAM,MAAM,KAAK;AACzD;;AAGA,SAAS,YAAY,OAA2C;CAC9D,OAAO,oBAAoB,MAAM,MAAM,MAAM,KAAK;AACpD;;AAGA,SAAS,SAAsC,QAA2B;CACxE,MAAM,EAAE,KAAK,GAAG,SAAS;CAEzB,OAAO;AACT;;;;;;;;;AAUA,SAAS,MACP,OACA,QACmB;CACnB,IAAI,QAAQ,QAAQ,aAAa;EAC/B,MAAM,OAAO,SAAS,MAAM;EAC5B,IAAI,CAAC,iBAAiB,KAAK,GACzB,MAAM,IAAI,MACR,UAAU,MAAM,6EACe,yBAAyB,KAAK,IAAI,EAAE,EACrE;EAEF,OAAO,IAAI,4BAA4B,MAAM,KAAK;CACpD;CACA,IAAI,QAAQ,QAAQ,QAAQ;EAC1B,IAAI,CAAC,YAAY,KAAK,GACpB,MAAM,IAAI,MACR,UAAU,MAAM,+EACU,oBAAoB,KAAK,IAAI,EAAE,EAC3D;EAEF,OAAO,IAAI,mBAAmB,SAAS,MAAM,GAAG,KAAK;CACvD;CAEA,OAAO,IAAI,2BAA2B,SAAS,SAAS,MAAM,IAAI,CAAC,GAAG,KAAK;AAC7E;AAkBA,SAAgB,kBACd,OACA,QACA,QAImB;CAEnB,OAAO,MAAM,OAAO;EAAE,GAAG;EAAQ;CAAO,CAAC;AAC3C;AAeA,SAAgB,YACd,OACA,QAImB;CAGnB,OAAO,MAAM,OAAO,MAAM;AAC5B"}
@@ -1,90 +1,171 @@
1
- const GENERATED_BEDROCK_MODELS = [
2
- {
3
- id: "openai.gpt-oss-120b-1:0",
4
- input: ["text"],
5
- output: ["text"],
6
- apis: { converse: true, chat: true, responses: true }
7
- },
8
- {
9
- id: "openai.gpt-oss-20b-1:0",
10
- input: ["text"],
11
- output: ["text"],
12
- apis: { converse: true, chat: true, responses: true }
13
- },
14
- {
15
- id: "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
16
- input: ["text", "image", "document"],
17
- output: ["text"],
18
- apis: { converse: true, chat: false, responses: false }
19
- },
20
- {
21
- id: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
22
- input: ["text", "image", "document"],
23
- output: ["text"],
24
- apis: { converse: true, chat: false, responses: false }
25
- },
26
- {
27
- id: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
28
- input: ["text", "image", "document"],
29
- output: ["text"],
30
- apis: { converse: true, chat: false, responses: false }
31
- },
32
- {
33
- id: "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
34
- input: ["text", "image", "document"],
35
- output: ["text"],
36
- apis: { converse: true, chat: false, responses: false }
37
- },
38
- {
39
- id: "us.anthropic.claude-3-5-haiku-20241022-v1:0",
40
- input: ["text"],
41
- output: ["text"],
42
- apis: { converse: true, chat: false, responses: false }
43
- },
44
- {
45
- id: "us.amazon.nova-pro-v1:0",
46
- input: ["text", "image", "document"],
47
- output: ["text"],
48
- apis: { converse: true, chat: false, responses: false }
49
- },
50
- {
51
- id: "us.amazon.nova-lite-v1:0",
52
- input: ["text", "image", "document"],
53
- output: ["text"],
54
- apis: { converse: true, chat: false, responses: false }
55
- },
56
- {
57
- id: "us.amazon.nova-micro-v1:0",
58
- input: ["text"],
59
- output: ["text"],
60
- apis: { converse: true, chat: false, responses: false }
61
- },
62
- {
63
- id: "us.meta.llama3-3-70b-instruct-v1:0",
64
- input: ["text"],
65
- output: ["text"],
66
- apis: { converse: true, chat: false, responses: false }
67
- },
68
- {
69
- id: "us.meta.llama4-maverick-17b-instruct-v1:0",
70
- input: ["text", "image"],
71
- output: ["text"],
72
- apis: { converse: true, chat: false, responses: false }
73
- },
74
- {
75
- id: "us.mistral.pixtral-large-2502-v1:0",
76
- input: ["text", "image"],
77
- output: ["text"],
78
- apis: { converse: true, chat: false, responses: false }
79
- },
80
- {
81
- id: "us.deepseek.r1-v1:0",
82
- input: ["text"],
83
- output: ["text"],
84
- apis: { converse: true, chat: false, responses: false }
85
- }
1
+ //#region src/model-catalog.generated.ts
2
+ var GENERATED_BEDROCK_MODELS = [
3
+ {
4
+ id: "openai.gpt-oss-120b-1:0",
5
+ input: ["text"],
6
+ output: ["text"],
7
+ apis: {
8
+ converse: true,
9
+ chat: true,
10
+ responses: true
11
+ }
12
+ },
13
+ {
14
+ id: "openai.gpt-oss-20b-1:0",
15
+ input: ["text"],
16
+ output: ["text"],
17
+ apis: {
18
+ converse: true,
19
+ chat: true,
20
+ responses: true
21
+ }
22
+ },
23
+ {
24
+ id: "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
25
+ input: [
26
+ "text",
27
+ "image",
28
+ "document"
29
+ ],
30
+ output: ["text"],
31
+ apis: {
32
+ converse: true,
33
+ chat: false,
34
+ responses: false
35
+ }
36
+ },
37
+ {
38
+ id: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
39
+ input: [
40
+ "text",
41
+ "image",
42
+ "document"
43
+ ],
44
+ output: ["text"],
45
+ apis: {
46
+ converse: true,
47
+ chat: false,
48
+ responses: false
49
+ }
50
+ },
51
+ {
52
+ id: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
53
+ input: [
54
+ "text",
55
+ "image",
56
+ "document"
57
+ ],
58
+ output: ["text"],
59
+ apis: {
60
+ converse: true,
61
+ chat: false,
62
+ responses: false
63
+ }
64
+ },
65
+ {
66
+ id: "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
67
+ input: [
68
+ "text",
69
+ "image",
70
+ "document"
71
+ ],
72
+ output: ["text"],
73
+ apis: {
74
+ converse: true,
75
+ chat: false,
76
+ responses: false
77
+ }
78
+ },
79
+ {
80
+ id: "us.anthropic.claude-3-5-haiku-20241022-v1:0",
81
+ input: ["text"],
82
+ output: ["text"],
83
+ apis: {
84
+ converse: true,
85
+ chat: false,
86
+ responses: false
87
+ }
88
+ },
89
+ {
90
+ id: "us.amazon.nova-pro-v1:0",
91
+ input: [
92
+ "text",
93
+ "image",
94
+ "document"
95
+ ],
96
+ output: ["text"],
97
+ apis: {
98
+ converse: true,
99
+ chat: false,
100
+ responses: false
101
+ }
102
+ },
103
+ {
104
+ id: "us.amazon.nova-lite-v1:0",
105
+ input: [
106
+ "text",
107
+ "image",
108
+ "document"
109
+ ],
110
+ output: ["text"],
111
+ apis: {
112
+ converse: true,
113
+ chat: false,
114
+ responses: false
115
+ }
116
+ },
117
+ {
118
+ id: "us.amazon.nova-micro-v1:0",
119
+ input: ["text"],
120
+ output: ["text"],
121
+ apis: {
122
+ converse: true,
123
+ chat: false,
124
+ responses: false
125
+ }
126
+ },
127
+ {
128
+ id: "us.meta.llama3-3-70b-instruct-v1:0",
129
+ input: ["text"],
130
+ output: ["text"],
131
+ apis: {
132
+ converse: true,
133
+ chat: false,
134
+ responses: false
135
+ }
136
+ },
137
+ {
138
+ id: "us.meta.llama4-maverick-17b-instruct-v1:0",
139
+ input: ["text", "image"],
140
+ output: ["text"],
141
+ apis: {
142
+ converse: true,
143
+ chat: false,
144
+ responses: false
145
+ }
146
+ },
147
+ {
148
+ id: "us.mistral.pixtral-large-2502-v1:0",
149
+ input: ["text", "image"],
150
+ output: ["text"],
151
+ apis: {
152
+ converse: true,
153
+ chat: false,
154
+ responses: false
155
+ }
156
+ },
157
+ {
158
+ id: "us.deepseek.r1-v1:0",
159
+ input: ["text"],
160
+ output: ["text"],
161
+ apis: {
162
+ converse: true,
163
+ chat: false,
164
+ responses: false
165
+ }
166
+ }
86
167
  ];
87
- export {
88
- GENERATED_BEDROCK_MODELS
89
- };
90
- //# sourceMappingURL=model-catalog.generated.js.map
168
+ //#endregion
169
+ export { GENERATED_BEDROCK_MODELS };
170
+
171
+ //# sourceMappingURL=model-catalog.generated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-catalog.generated.js","sources":["../../src/model-catalog.generated.ts"],"sourcesContent":["// GENERATED by scripts/fetch-bedrock-models.ts — do not edit by hand.\n// Refresh: AWS_REGION=us-east-1 pnpm tsx scripts/fetch-bedrock-models.ts\nexport const GENERATED_BEDROCK_MODELS = [\n {\n id: 'openai.gpt-oss-120b-1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: true, responses: true },\n },\n {\n id: 'openai.gpt-oss-20b-1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: true, responses: true },\n },\n {\n id: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-haiku-4-5-20251001-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-5-haiku-20241022-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-pro-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-lite-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-micro-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.meta.llama3-3-70b-instruct-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.meta.llama4-maverick-17b-instruct-v1:0',\n input: ['text', 'image'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.mistral.pixtral-large-2502-v1:0',\n input: ['text', 'image'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.deepseek.r1-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n] as const\n"],"names":[],"mappings":"AAEO,MAAM,2BAA2B;AAAA,EACtC;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,MAAM,WAAW,KAAA;AAAA,EAAK;AAAA,EAEtD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,MAAM,WAAW,KAAA;AAAA,EAAK;AAAA,EAEtD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,SAAS,UAAU;AAAA,IACnC,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,OAAO;AAAA,IACvB,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,QAAQ,OAAO;AAAA,IACvB,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAAA,EAExD;AAAA,IACE,IAAI;AAAA,IACJ,OAAO,CAAC,MAAM;AAAA,IACd,QAAQ,CAAC,MAAM;AAAA,IACf,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO,WAAW,MAAA;AAAA,EAAM;AAE1D;"}
1
+ {"version":3,"file":"model-catalog.generated.js","names":[],"sources":["../../src/model-catalog.generated.ts"],"sourcesContent":["// GENERATED by scripts/fetch-bedrock-models.ts — do not edit by hand.\n// Refresh: AWS_REGION=us-east-1 pnpm tsx scripts/fetch-bedrock-models.ts\nexport const GENERATED_BEDROCK_MODELS = [\n {\n id: 'openai.gpt-oss-120b-1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: true, responses: true },\n },\n {\n id: 'openai.gpt-oss-20b-1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: true, responses: true },\n },\n {\n id: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-haiku-4-5-20251001-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.anthropic.claude-3-5-haiku-20241022-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-pro-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-lite-v1:0',\n input: ['text', 'image', 'document'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.amazon.nova-micro-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.meta.llama3-3-70b-instruct-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.meta.llama4-maverick-17b-instruct-v1:0',\n input: ['text', 'image'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.mistral.pixtral-large-2502-v1:0',\n input: ['text', 'image'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n {\n id: 'us.deepseek.r1-v1:0',\n input: ['text'],\n output: ['text'],\n apis: { converse: true, chat: false, responses: false },\n },\n] as const\n"],"mappings":";AAEA,IAAa,2BAA2B;CACtC;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAM,WAAW;EAAK;CACtD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAM,WAAW;EAAK;CACtD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO;GAAC;GAAQ;GAAS;EAAU;EACnC,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,QAAQ,OAAO;EACvB,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,QAAQ,OAAO;EACvB,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;CACA;EACE,IAAI;EACJ,OAAO,CAAC,MAAM;EACd,QAAQ,CAAC,MAAM;EACf,MAAM;GAAE,UAAU;GAAM,MAAM;GAAO,WAAW;EAAM;CACxD;AACF"}
@@ -1,14 +1,10 @@
1
1
  import { GENERATED_BEDROCK_MODELS } from "./model-catalog.generated.js";
2
- const BEDROCK_CONVERSE_MODELS = GENERATED_BEDROCK_MODELS.map((m) => m.id);
3
- const BEDROCK_CHAT_MODELS = GENERATED_BEDROCK_MODELS.filter(
4
- (m) => m.apis.chat
5
- ).map((m) => m.id);
6
- const BEDROCK_RESPONSES_MODELS = GENERATED_BEDROCK_MODELS.filter(
7
- (m) => m.apis.responses
8
- ).map((m) => m.id);
9
- export {
10
- BEDROCK_CHAT_MODELS,
11
- BEDROCK_CONVERSE_MODELS,
12
- BEDROCK_RESPONSES_MODELS
13
- };
14
- //# sourceMappingURL=model-meta.js.map
2
+ //#region src/model-meta.ts
3
+ /** Runtime catalogs. Cast-free narrowing via a type predicate (the ai-bedrock pattern). */
4
+ var BEDROCK_CONVERSE_MODELS = GENERATED_BEDROCK_MODELS.map((m) => m.id);
5
+ var BEDROCK_CHAT_MODELS = GENERATED_BEDROCK_MODELS.filter((m) => m.apis.chat).map((m) => m.id);
6
+ var BEDROCK_RESPONSES_MODELS = GENERATED_BEDROCK_MODELS.filter((m) => m.apis.responses).map((m) => m.id);
7
+ //#endregion
8
+ export { BEDROCK_CHAT_MODELS, BEDROCK_CONVERSE_MODELS, BEDROCK_RESPONSES_MODELS };
9
+
10
+ //# sourceMappingURL=model-meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import { GENERATED_BEDROCK_MODELS } from './model-catalog.generated.js'\nimport type { BedrockTextProviderOptions } from './text/text-provider-options'\nimport type { BedrockConverseProviderOptions } from './converse/provider-options'\n\ntype Entry = (typeof GENERATED_BEDROCK_MODELS)[number]\n\n/**\n * Type-level per-API filter over the generated catalog. Because the catalog is\n * `as const`, `Extract` preserves literal `id` unions (no widening to `string`).\n */\ntype IdsWhere<TApi extends 'converse' | 'chat' | 'responses'> = Extract<\n Entry,\n { apis: Record<TApi, true> }\n>['id']\n\nexport type BedrockConverseModels = IdsWhere<'converse'>\nexport type BedrockChatModels = IdsWhere<'chat'>\nexport type BedrockResponsesModels = IdsWhere<'responses'>\n\n/** Runtime catalogs. Cast-free narrowing via a type predicate (the ai-bedrock pattern). */\n// Every catalog entry advertises `converse: true` (Converse is the universal\n// Bedrock surface), so the id list is the full catalog — no runtime filter needed.\nexport const BEDROCK_CONVERSE_MODELS: ReadonlyArray<BedrockConverseModels> =\n GENERATED_BEDROCK_MODELS.map((m) => m.id)\n\nexport const BEDROCK_CHAT_MODELS: ReadonlyArray<BedrockChatModels> =\n GENERATED_BEDROCK_MODELS.filter(\n (m): m is Extract<Entry, { apis: { chat: true } }> => m.apis.chat,\n ).map((m) => m.id)\n\nexport const BEDROCK_RESPONSES_MODELS: ReadonlyArray<BedrockResponsesModels> =\n GENERATED_BEDROCK_MODELS.filter(\n (m): m is Extract<Entry, { apis: { responses: true } }> => m.apis.responses,\n ).map((m) => m.id)\n\n/** Per-model input modalities (drives type-safe multimodal content). Covers ALL models. */\nexport type BedrockModelInputModalitiesByName = {\n [E in Entry as E['id']]: E['input']\n}\n\n/** Provider options per model. Same options for every model; keyed over the full catalog. */\nexport type BedrockChatModelProviderOptionsByName = {\n [E in Entry as E['id']]: BedrockTextProviderOptions\n}\n\n/** Converse provider options per model (narrower than the Chat Completions set). */\nexport type BedrockConverseModelProviderOptionsByName = {\n [E in Entry as E['id']]: BedrockConverseProviderOptions\n}\n\n/** No provider-specific tools — empty tuple makes cross-provider ProviderTool a compile error. */\nexport type BedrockChatModelToolCapabilitiesByName = {\n [E in Entry as E['id']]: readonly []\n}\n\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof BedrockChatModelProviderOptionsByName\n ? BedrockChatModelProviderOptionsByName[TModel]\n : BedrockTextProviderOptions\n\nexport type ResolveConverseProviderOptions<TModel extends string> =\n TModel extends keyof BedrockConverseModelProviderOptionsByName\n ? BedrockConverseModelProviderOptionsByName[TModel]\n : BedrockConverseProviderOptions\n\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof BedrockModelInputModalitiesByName\n ? BedrockModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"names":[],"mappings":";AAsBO,MAAM,0BACX,yBAAyB,IAAI,CAAC,MAAM,EAAE,EAAE;AAEnC,MAAM,sBACX,yBAAyB;AAAA,EACvB,CAAC,MAAqD,EAAE,KAAK;AAC/D,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;AAEZ,MAAM,2BACX,yBAAyB;AAAA,EACvB,CAAC,MAA0D,EAAE,KAAK;AACpE,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;"}
1
+ {"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import { GENERATED_BEDROCK_MODELS } from './model-catalog.generated.js'\nimport type { BedrockTextProviderOptions } from './text/text-provider-options'\nimport type { BedrockConverseProviderOptions } from './converse/provider-options'\n\ntype Entry = (typeof GENERATED_BEDROCK_MODELS)[number]\n\n/**\n * Type-level per-API filter over the generated catalog. Because the catalog is\n * `as const`, `Extract` preserves literal `id` unions (no widening to `string`).\n */\ntype IdsWhere<TApi extends 'converse' | 'chat' | 'responses'> = Extract<\n Entry,\n { apis: Record<TApi, true> }\n>['id']\n\nexport type BedrockConverseModels = IdsWhere<'converse'>\nexport type BedrockChatModels = IdsWhere<'chat'>\nexport type BedrockResponsesModels = IdsWhere<'responses'>\n\n/** Runtime catalogs. Cast-free narrowing via a type predicate (the ai-bedrock pattern). */\n// Every catalog entry advertises `converse: true` (Converse is the universal\n// Bedrock surface), so the id list is the full catalog — no runtime filter needed.\nexport const BEDROCK_CONVERSE_MODELS: ReadonlyArray<BedrockConverseModels> =\n GENERATED_BEDROCK_MODELS.map((m) => m.id)\n\nexport const BEDROCK_CHAT_MODELS: ReadonlyArray<BedrockChatModels> =\n GENERATED_BEDROCK_MODELS.filter(\n (m): m is Extract<Entry, { apis: { chat: true } }> => m.apis.chat,\n ).map((m) => m.id)\n\nexport const BEDROCK_RESPONSES_MODELS: ReadonlyArray<BedrockResponsesModels> =\n GENERATED_BEDROCK_MODELS.filter(\n (m): m is Extract<Entry, { apis: { responses: true } }> => m.apis.responses,\n ).map((m) => m.id)\n\n/** Per-model input modalities (drives type-safe multimodal content). Covers ALL models. */\nexport type BedrockModelInputModalitiesByName = {\n [E in Entry as E['id']]: E['input']\n}\n\n/** Provider options per model. Same options for every model; keyed over the full catalog. */\nexport type BedrockChatModelProviderOptionsByName = {\n [E in Entry as E['id']]: BedrockTextProviderOptions\n}\n\n/** Converse provider options per model (narrower than the Chat Completions set). */\nexport type BedrockConverseModelProviderOptionsByName = {\n [E in Entry as E['id']]: BedrockConverseProviderOptions\n}\n\n/** No provider-specific tools — empty tuple makes cross-provider ProviderTool a compile error. */\nexport type BedrockChatModelToolCapabilitiesByName = {\n [E in Entry as E['id']]: readonly []\n}\n\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof BedrockChatModelProviderOptionsByName\n ? BedrockChatModelProviderOptionsByName[TModel]\n : BedrockTextProviderOptions\n\nexport type ResolveConverseProviderOptions<TModel extends string> =\n TModel extends keyof BedrockConverseModelProviderOptionsByName\n ? BedrockConverseModelProviderOptionsByName[TModel]\n : BedrockConverseProviderOptions\n\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof BedrockModelInputModalitiesByName\n ? BedrockModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"mappings":";;;AAsBA,IAAa,0BACX,yBAAyB,KAAK,MAAM,EAAE,EAAE;AAE1C,IAAa,sBACX,yBAAyB,QACtB,MAAqD,EAAE,KAAK,IAC/D,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE;AAEnB,IAAa,2BACX,yBAAyB,QACtB,MAA0D,EAAE,KAAK,SACpE,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE"}
@@ -1,49 +1,39 @@
1
+ //#region src/utils/auth.ts
2
+ /** SigV4 service name differs per endpoint. */
1
3
  function sigv4Service(endpoint) {
2
- return endpoint === "mantle" ? "bedrock-mantle" : "bedrock";
4
+ return endpoint === "mantle" ? "bedrock-mantle" : "bedrock";
3
5
  }
4
- const DEFAULT_REGION = "us-east-1";
6
+ var DEFAULT_REGION = "us-east-1";
5
7
  function readApiKeyFromEnv() {
6
- const env = typeof process !== "undefined" ? process.env : void 0;
7
- for (const value of [env?.BEDROCK_API_KEY, env?.AWS_BEARER_TOKEN_BEDROCK]) {
8
- if (value && value.trim() !== "") return value;
9
- }
10
- return void 0;
8
+ const env = typeof process !== "undefined" ? process.env : void 0;
9
+ for (const value of [env?.BEDROCK_API_KEY, env?.AWS_BEARER_TOKEN_BEDROCK]) if (value && value.trim() !== "") return value;
11
10
  }
11
+ /** apiKey -> BEDROCK_API_KEY -> AWS_BEARER_TOKEN_BEDROCK -> SigV4 (credential chain). */
12
12
  function resolveBedrockAuth(config, endpoint) {
13
- const mode = config.auth ?? "auto";
14
- const region = config.region ?? DEFAULT_REGION;
15
- if (mode !== "sigv4") {
16
- const token = config.apiKey ?? readApiKeyFromEnv();
17
- if (token) return { kind: "bearer", token };
18
- if (mode === "apikey") {
19
- throw new Error(
20
- 'No Bedrock API key found. Set BEDROCK_API_KEY (or AWS_BEARER_TOKEN_BEDROCK), pass `apiKey`, or use auth: "sigv4".'
21
- );
22
- }
23
- }
24
- return {
25
- kind: "sigv4",
26
- region,
27
- service: sigv4Service(endpoint),
28
- // Lazy credential provider: the AWS SDK is Node/server-only, so we defer the
29
- // dynamic import until SigV4 actually needs to resolve credentials. The
30
- // specifier is held in a variable (not a string literal) so bundler dep
31
- // scanners (e.g. Vite/esbuild optimizeDeps) cannot statically discover the
32
- // AWS SDK and try to pre-bundle it for the browser — it would fail on the
33
- // SDK's Node-only `fromTokenFile` export chain. `typeof import(...)` is a
34
- // type-only reference (erased at emit) so we keep full typing.
35
- credentials: async (...args) => {
36
- const mod = "@aws-sdk/credential-providers";
37
- const { fromNodeProviderChain } = await import(
38
- /* @vite-ignore */
39
- mod
40
- );
41
- return fromNodeProviderChain()(...args);
42
- }
43
- };
13
+ const mode = config.auth ?? "auto";
14
+ const region = config.region ?? DEFAULT_REGION;
15
+ if (mode !== "sigv4") {
16
+ const token = config.apiKey ?? readApiKeyFromEnv();
17
+ if (token) return {
18
+ kind: "bearer",
19
+ token
20
+ };
21
+ if (mode === "apikey") throw new Error("No Bedrock API key found. Set BEDROCK_API_KEY (or AWS_BEARER_TOKEN_BEDROCK), pass `apiKey`, or use auth: \"sigv4\".");
22
+ }
23
+ return {
24
+ kind: "sigv4",
25
+ region,
26
+ service: sigv4Service(endpoint),
27
+ credentials: async (...args) => {
28
+ const { fromNodeProviderChain } = await import(
29
+ /* @vite-ignore */
30
+ "@aws-sdk/credential-providers"
31
+ );
32
+ return fromNodeProviderChain()(...args);
33
+ }
34
+ };
44
35
  }
45
- export {
46
- resolveBedrockAuth,
47
- sigv4Service
48
- };
49
- //# sourceMappingURL=auth.js.map
36
+ //#endregion
37
+ export { resolveBedrockAuth, sigv4Service };
38
+
39
+ //# sourceMappingURL=auth.js.map