@opencode/ai 2.2.0 → 2.2.2
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.
- package/README.md +66 -62
- package/dist/effect.d.ts +1 -1
- package/dist/effect.js +1 -1
- package/dist/image-client.d.ts +45 -0
- package/dist/image.d.ts +1 -0
- package/dist/index.d.ts +38 -20
- package/dist/index.js +14 -2
- package/dist/media-client.d.ts +1 -0
- package/dist/media-client.js +1 -0
- package/dist/protocols/alibaba-chat.d.ts +39 -4
- package/dist/protocols/alibaba-responses.d.ts +20 -3
- package/dist/protocols/google-images.js +3 -1
- package/dist/protocols/meta-responses.d.ts +40 -6
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/open-responses.d.ts +182 -27
- package/dist/protocols/open-responses.js +108 -36
- package/dist/protocols/openai-chat.d.ts +438 -46
- package/dist/protocols/openai-chat.js +121 -39
- package/dist/protocols/openai-compatible-chat.d.ts +35 -4
- package/dist/protocols/openai-compatible-responses.d.ts +20 -3
- package/dist/protocols/openai-freeform.d.ts +47 -0
- package/dist/protocols/openai-freeform.js +54 -0
- package/dist/protocols/openai-images.d.ts +16 -1
- package/dist/protocols/openai-images.js +49 -17
- package/dist/protocols/openai-responses.d.ts +120 -18
- package/dist/protocols/openai-responses.js +17 -8
- package/dist/protocols/venice-chat.d.ts +39 -4
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/xai-images.d.ts +6 -0
- package/dist/protocols/xai-images.js +4 -5
- package/dist/protocols/xai-responses.d.ts +20 -3
- package/dist/protocols/xai-responses.js +2 -1
- package/dist/protocols/zai-chat.d.ts +39 -4
- package/dist/provider-error.js +5 -4
- package/dist/provider-package.d.ts +2 -0
- package/dist/providers/alibaba.d.ts +58 -10
- package/dist/providers/amazon-bedrock-mantle.d.ts +66 -11
- package/dist/providers/amazon-bedrock-mantle.js +1 -1
- package/dist/providers/amazon-bedrock.d.ts +1 -1
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/azure.d.ts +79 -15
- package/dist/providers/baseten.d.ts +74 -12
- package/dist/providers/baseten.js +1 -1
- package/dist/providers/cerebras.d.ts +73 -11
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +113 -17
- package/dist/providers/cloudflare-workers-ai.d.ts +73 -11
- package/dist/providers/cohere/chat.d.ts +1 -1
- package/dist/providers/cohere/chat.js +1 -1
- package/dist/providers/cohere.d.ts +73 -11
- package/dist/providers/cohere.js +1 -1
- package/dist/providers/deepinfra.d.ts +73 -11
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +73 -11
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +320 -21
- package/dist/providers/digitalocean.js +18 -7
- package/dist/providers/fireworks.d.ts +73 -11
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +1 -1
- package/dist/providers/google-vertex-chat.d.ts +36 -5
- package/dist/providers/google-vertex-chat.js +1 -1
- package/dist/providers/google-vertex-interactions.d.ts +1 -1
- package/dist/providers/google-vertex-interactions.js +1 -1
- package/dist/providers/google-vertex-messages.d.ts +1 -1
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-mistral.d.ts +1 -1
- package/dist/providers/google-vertex-mistral.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +21 -4
- package/dist/providers/google-vertex-responses.js +1 -1
- package/dist/providers/google-vertex.d.ts +2 -2
- package/dist/providers/google-vertex.js +1 -1
- package/dist/providers/google.d.ts +2 -2
- package/dist/providers/google.js +1 -1
- package/dist/providers/groq.d.ts +77 -11
- package/dist/providers/groq.js +1 -1
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/meta/images.d.ts +2 -0
- package/dist/providers/meta/images.js +1 -0
- package/dist/providers/meta.d.ts +61 -12
- package/dist/providers/meta.js +2 -1
- package/dist/providers/minimax/chat.d.ts +1 -1
- package/dist/providers/minimax/chat.js +1 -1
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax/responses.d.ts +1 -1
- package/dist/providers/minimax/responses.js +1 -1
- package/dist/providers/minimax.d.ts +63 -9
- package/dist/providers/minimax.js +22 -9
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/moonshot/messages.d.ts +1 -1
- package/dist/providers/moonshot/messages.js +1 -1
- package/dist/providers/moonshot/responses.d.ts +1 -1
- package/dist/providers/moonshot/responses.js +1 -1
- package/dist/providers/moonshot.d.ts +56 -8
- package/dist/providers/moonshot.js +1 -1
- package/dist/providers/openai-compatible-responses.d.ts +21 -4
- package/dist/providers/openai-compatible.d.ts +38 -7
- package/dist/providers/openai-compatible.js +9 -2
- package/dist/providers/openai.d.ts +59 -11
- package/dist/providers/openai.js +4 -2
- package/dist/providers/opencode.d.ts +3 -3
- package/dist/providers/opencode.js +1 -1
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +356 -26
- package/dist/providers/openrouter.js +42 -13
- package/dist/providers/togetherai.d.ts +73 -11
- package/dist/providers/togetherai.js +1 -1
- package/dist/providers/typesafe-ai.d.ts +3 -3
- package/dist/providers/typesafe-ai.js +1 -1
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +242 -9
- package/dist/providers/venice.js +33 -17
- package/dist/providers/vercel-ai-gateway.d.ts +8 -8
- package/dist/providers/vercel-ai-gateway.js +12 -2
- package/dist/providers/xai.d.ts +39 -8
- package/dist/providers/xai.js +1 -1
- package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
- package/dist/providers/zai-coding-plan/messages.js +1 -1
- package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
- package/dist/providers/zai-coding-plan/responses.js +1 -1
- package/dist/providers/zai-coding-plan.d.ts +56 -8
- package/dist/providers/zai-coding-plan.js +1 -1
- package/dist/providers/zai.d.ts +37 -6
- package/dist/providers/zai.js +1 -1
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +2 -4
- package/dist/route/media.d.ts +1 -1
- package/dist/route/media.js +2 -4
- package/dist/schema/events.d.ts +2 -0
- package/dist/schema/messages.d.ts +35 -1
- package/dist/schema/messages.js +20 -0
- package/dist/speech-client.d.ts +48 -0
- package/dist/speech.d.ts +1 -0
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +10 -21
- package/dist/testing.js +11 -54
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js +10 -2
- package/dist/transcription-client.d.ts +64 -0
- package/dist/transcription.d.ts +1 -0
- package/dist/video-client.d.ts +41 -0
- package/dist/video.d.ts +1 -0
- package/package.json +24 -40
- package/dist/protocols/bfl-images.d.ts +0 -47
- package/dist/protocols/bfl-images.js +0 -155
- package/dist/protocols/fal-images.d.ts +0 -34
- package/dist/protocols/fal-images.js +0 -95
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -44
- package/dist/protocols/stability-images.js +0 -131
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
|
@@ -21,7 +21,7 @@ export declare const protocol: Protocol<{
|
|
|
21
21
|
readonly role: "developer";
|
|
22
22
|
readonly content: string;
|
|
23
23
|
} | {
|
|
24
|
-
readonly type: "function_call_output";
|
|
24
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
25
25
|
readonly call_id: string;
|
|
26
26
|
readonly output: string | readonly ({
|
|
27
27
|
readonly type: "input_text";
|
|
@@ -91,6 +91,12 @@ export declare const protocol: Protocol<{
|
|
|
91
91
|
readonly name: string;
|
|
92
92
|
readonly namespace?: string | undefined;
|
|
93
93
|
readonly arguments: string;
|
|
94
|
+
} | {
|
|
95
|
+
readonly type: "custom_tool_call";
|
|
96
|
+
readonly id?: string | undefined;
|
|
97
|
+
readonly call_id: string;
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly input: string;
|
|
94
100
|
} | {
|
|
95
101
|
readonly [x: string]: unknown;
|
|
96
102
|
readonly type: "web_search_call";
|
|
@@ -135,6 +141,17 @@ export declare const protocol: Protocol<{
|
|
|
135
141
|
})[];
|
|
136
142
|
readonly instructions?: string | undefined;
|
|
137
143
|
readonly tools?: readonly ({
|
|
144
|
+
readonly type: "custom";
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly description: string;
|
|
147
|
+
readonly format: {
|
|
148
|
+
readonly type: "text";
|
|
149
|
+
} | {
|
|
150
|
+
readonly type: "grammar";
|
|
151
|
+
readonly syntax: "lark" | "regex";
|
|
152
|
+
readonly definition: string;
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
138
155
|
readonly type: "function";
|
|
139
156
|
readonly name: string;
|
|
140
157
|
readonly description: string;
|
|
@@ -147,13 +164,13 @@ export declare const protocol: Protocol<{
|
|
|
147
164
|
readonly type: string;
|
|
148
165
|
})[] | undefined;
|
|
149
166
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
150
|
-
readonly type: "function";
|
|
167
|
+
readonly type: "custom" | "function";
|
|
151
168
|
readonly name: string;
|
|
152
169
|
} | {
|
|
153
170
|
readonly type: "allowed_tools";
|
|
154
171
|
readonly mode: "auto" | "none" | "required";
|
|
155
172
|
readonly tools: readonly {
|
|
156
|
-
readonly type: "function";
|
|
173
|
+
readonly type: "custom" | "function";
|
|
157
174
|
readonly name: string;
|
|
158
175
|
}[];
|
|
159
176
|
} | undefined;
|
|
@@ -4,6 +4,7 @@ import { OpenResponses } from "./open-responses.js";
|
|
|
4
4
|
import { JsonObject, optionalNull, ProviderShared } from "./shared.js";
|
|
5
5
|
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
6
6
|
import { ResponsesCompaction } from "./utils/responses-compaction.js";
|
|
7
|
+
import { OpenAIFreeform } from "./openai-freeform.js";
|
|
7
8
|
const ADAPTER = "xai-responses";
|
|
8
9
|
const NAME = "xAI Responses";
|
|
9
10
|
const XAIResponsesHostedToolItem = Schema.Union([
|
|
@@ -97,5 +98,5 @@ export const protocol = Protocol.make({
|
|
|
97
98
|
terminal: OpenResponses.terminal,
|
|
98
99
|
},
|
|
99
100
|
});
|
|
100
|
-
export const compact = ResponsesCompaction.make(adapter, (request) => OpenResponses.lowerTools(ProviderShared.flattenTools(request.tools), adapter));
|
|
101
|
+
export const compact = ResponsesCompaction.make(adapter, (request) => OpenResponses.lowerTools(ProviderShared.flattenTools(request.tools), adapter, OpenAIFreeform.tools(request)));
|
|
101
102
|
export * as XAIResponses from "./xai-responses.js";
|
|
@@ -101,7 +101,14 @@ export declare const protocol: Protocol<{
|
|
|
101
101
|
readonly ttl?: string | undefined;
|
|
102
102
|
} | undefined;
|
|
103
103
|
}[] | null;
|
|
104
|
-
readonly tool_calls?: readonly {
|
|
104
|
+
readonly tool_calls?: readonly ({
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly type: "custom";
|
|
107
|
+
readonly custom: {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly input: string;
|
|
110
|
+
};
|
|
111
|
+
} | {
|
|
105
112
|
readonly id: string;
|
|
106
113
|
readonly type: "function";
|
|
107
114
|
readonly function: {
|
|
@@ -113,13 +120,13 @@ export declare const protocol: Protocol<{
|
|
|
113
120
|
readonly thought_signature: string;
|
|
114
121
|
};
|
|
115
122
|
} | undefined;
|
|
116
|
-
}[] | undefined;
|
|
123
|
+
})[] | undefined;
|
|
117
124
|
readonly reasoning_content?: string | undefined;
|
|
118
125
|
readonly reasoning?: string | undefined;
|
|
119
126
|
readonly reasoning_text?: string | undefined;
|
|
120
127
|
readonly reasoning_details?: unknown;
|
|
121
128
|
})[];
|
|
122
|
-
readonly tools?: readonly {
|
|
129
|
+
readonly tools?: readonly ({
|
|
123
130
|
readonly type: "function";
|
|
124
131
|
readonly function: {
|
|
125
132
|
readonly name: string;
|
|
@@ -133,12 +140,36 @@ export declare const protocol: Protocol<{
|
|
|
133
140
|
readonly type: "ephemeral";
|
|
134
141
|
readonly ttl?: string | undefined;
|
|
135
142
|
} | undefined;
|
|
136
|
-
}
|
|
143
|
+
} | {
|
|
144
|
+
readonly type: "custom";
|
|
145
|
+
readonly custom: {
|
|
146
|
+
readonly name: string;
|
|
147
|
+
readonly description: string;
|
|
148
|
+
readonly format: {
|
|
149
|
+
readonly type: "text";
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: "grammar";
|
|
152
|
+
readonly grammar: {
|
|
153
|
+
readonly syntax: "lark" | "regex";
|
|
154
|
+
readonly definition: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
readonly cache_control?: {
|
|
159
|
+
readonly type: "ephemeral";
|
|
160
|
+
readonly ttl?: string | undefined;
|
|
161
|
+
} | undefined;
|
|
162
|
+
})[] | undefined;
|
|
137
163
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
138
164
|
readonly type: "function";
|
|
139
165
|
readonly function: {
|
|
140
166
|
readonly name: string;
|
|
141
167
|
};
|
|
168
|
+
} | {
|
|
169
|
+
readonly type: "custom";
|
|
170
|
+
readonly custom: {
|
|
171
|
+
readonly name: string;
|
|
172
|
+
};
|
|
142
173
|
} | undefined;
|
|
143
174
|
readonly stream: true;
|
|
144
175
|
readonly stream_options?: {
|
|
@@ -196,6 +227,10 @@ export declare const protocol: Protocol<{
|
|
|
196
227
|
readonly name?: string | null | undefined;
|
|
197
228
|
readonly arguments?: string | null | undefined;
|
|
198
229
|
} | null | undefined;
|
|
230
|
+
readonly custom?: {
|
|
231
|
+
readonly name?: string | null | undefined;
|
|
232
|
+
readonly input?: string | null | undefined;
|
|
233
|
+
} | null | undefined;
|
|
199
234
|
readonly extra_content?: unknown;
|
|
200
235
|
}[] | null | undefined;
|
|
201
236
|
} | null | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -154,7 +154,8 @@ const AUTH_TEXT = /incorrect api key provided/i;
|
|
|
154
154
|
const RATE_LIMIT_TEXT = /rate increased too quickly|rate[-_\s]?limit|too[_\s]?many[_\s]?requests/i;
|
|
155
155
|
// Only consulted on 429, where throttles and account caps share a status.
|
|
156
156
|
// Z.ai reports balance, plan expiry, plan limits, and plan model access on 429.
|
|
157
|
-
|
|
157
|
+
// Cerebras reports its per-minute token throttle as `token_quota_exceeded`; that is a rate limit.
|
|
158
|
+
const QUOTA_TEXT = /insufficient[-_\s]?(?:quota|balance)|(?<!token_)quota[-_\s]?exceeded|budget exceeded|usage limit|limit exhausted|package has expired|plan does not yet include/i;
|
|
158
159
|
// Policy rejections without a dedicated code, matched against the provider's own
|
|
159
160
|
// explanation only. OpenAI reuses `invalid_prompt` for usage-policy rejections while
|
|
160
161
|
// Bedrock Mantle reuses it for schema validation; Anthropic reports blocked output
|
|
@@ -203,7 +204,9 @@ export function classifyProviderFailure(input) {
|
|
|
203
204
|
(codes.includes("context_length_exceeded") ||
|
|
204
205
|
codes.includes("model_context_window_exceeded") ||
|
|
205
206
|
codes.includes("request_too_large") ||
|
|
206
|
-
|
|
207
|
+
// 429 bodies are throttles even when their wording matches an overflow phrase, e.g. Cerebras's
|
|
208
|
+
// "too many tokens processed". Text matching stays on for 4xx and mid-stream errors without a status.
|
|
209
|
+
(input.status !== 429 && !codes.includes("throttlingexception") && isContextOverflow(text))))
|
|
207
210
|
return new InvalidRequestError({ ...details, classification: "context-overflow" });
|
|
208
211
|
if (input.status === 413 || isPayloadTooLarge(text))
|
|
209
212
|
return new InvalidRequestError({ ...details, classification: "payload-too-large" });
|
|
@@ -260,8 +263,6 @@ function providerCodes(value) {
|
|
|
260
263
|
decoded.code,
|
|
261
264
|
...awsErrorType(decoded.__type),
|
|
262
265
|
...awsErrorType(decoded.code),
|
|
263
|
-
// Stability's `{ id, name, errors }` bodies carry the code in `name`.
|
|
264
|
-
Array.isArray(decoded.errors) ? decoded.name : undefined,
|
|
265
266
|
decoded.error_type,
|
|
266
267
|
error?.code,
|
|
267
268
|
error?.type,
|
|
@@ -12,4 +12,6 @@ export interface Settings extends Readonly<Record<string, unknown>> {
|
|
|
12
12
|
export interface Definition<ProviderSettings extends Settings = Settings, Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined> {
|
|
13
13
|
readonly model: (modelID: string, settings: ProviderSettings) => LanguageModel<Options, Compact>;
|
|
14
14
|
}
|
|
15
|
+
/** A provider's `model` export. Settings are optional when every key is optional. */
|
|
16
|
+
export type Model<ProviderSettings extends Settings = Settings, Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = (modelID: string, ...settings: {} extends ProviderSettings ? [settings?: ProviderSettings] : [settings: ProviderSettings]) => LanguageModel<Options, Compact>;
|
|
15
17
|
export * as ProviderPackage from "./provider-package.js";
|
|
@@ -100,7 +100,14 @@ export declare const routes: (Route<{
|
|
|
100
100
|
readonly ttl?: string | undefined;
|
|
101
101
|
} | undefined;
|
|
102
102
|
}[] | null;
|
|
103
|
-
readonly tool_calls?: readonly {
|
|
103
|
+
readonly tool_calls?: readonly ({
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly type: "custom";
|
|
106
|
+
readonly custom: {
|
|
107
|
+
readonly name: string;
|
|
108
|
+
readonly input: string;
|
|
109
|
+
};
|
|
110
|
+
} | {
|
|
104
111
|
readonly id: string;
|
|
105
112
|
readonly type: "function";
|
|
106
113
|
readonly function: {
|
|
@@ -112,13 +119,13 @@ export declare const routes: (Route<{
|
|
|
112
119
|
readonly thought_signature: string;
|
|
113
120
|
};
|
|
114
121
|
} | undefined;
|
|
115
|
-
}[] | undefined;
|
|
122
|
+
})[] | undefined;
|
|
116
123
|
readonly reasoning_content?: string | undefined;
|
|
117
124
|
readonly reasoning?: string | undefined;
|
|
118
125
|
readonly reasoning_text?: string | undefined;
|
|
119
126
|
readonly reasoning_details?: unknown;
|
|
120
127
|
})[];
|
|
121
|
-
readonly tools?: readonly {
|
|
128
|
+
readonly tools?: readonly ({
|
|
122
129
|
readonly type: "function";
|
|
123
130
|
readonly function: {
|
|
124
131
|
readonly name: string;
|
|
@@ -132,12 +139,36 @@ export declare const routes: (Route<{
|
|
|
132
139
|
readonly type: "ephemeral";
|
|
133
140
|
readonly ttl?: string | undefined;
|
|
134
141
|
} | undefined;
|
|
135
|
-
}
|
|
142
|
+
} | {
|
|
143
|
+
readonly type: "custom";
|
|
144
|
+
readonly custom: {
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly description: string;
|
|
147
|
+
readonly format: {
|
|
148
|
+
readonly type: "text";
|
|
149
|
+
} | {
|
|
150
|
+
readonly type: "grammar";
|
|
151
|
+
readonly grammar: {
|
|
152
|
+
readonly syntax: "lark" | "regex";
|
|
153
|
+
readonly definition: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly cache_control?: {
|
|
158
|
+
readonly type: "ephemeral";
|
|
159
|
+
readonly ttl?: string | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
})[] | undefined;
|
|
136
162
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
137
163
|
readonly type: "function";
|
|
138
164
|
readonly function: {
|
|
139
165
|
readonly name: string;
|
|
140
166
|
};
|
|
167
|
+
} | {
|
|
168
|
+
readonly type: "custom";
|
|
169
|
+
readonly custom: {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
};
|
|
141
172
|
} | undefined;
|
|
142
173
|
readonly stream: true;
|
|
143
174
|
readonly stream_options?: {
|
|
@@ -498,7 +529,7 @@ export declare const routes: (Route<{
|
|
|
498
529
|
readonly role: "developer";
|
|
499
530
|
readonly content: string;
|
|
500
531
|
} | {
|
|
501
|
-
readonly type: "function_call_output";
|
|
532
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
502
533
|
readonly call_id: string;
|
|
503
534
|
readonly output: string | readonly ({
|
|
504
535
|
readonly type: "input_text";
|
|
@@ -568,6 +599,12 @@ export declare const routes: (Route<{
|
|
|
568
599
|
readonly name: string;
|
|
569
600
|
readonly namespace?: string | undefined;
|
|
570
601
|
readonly arguments: string;
|
|
602
|
+
} | {
|
|
603
|
+
readonly type: "custom_tool_call";
|
|
604
|
+
readonly id?: string | undefined;
|
|
605
|
+
readonly call_id: string;
|
|
606
|
+
readonly name: string;
|
|
607
|
+
readonly input: string;
|
|
571
608
|
} | {
|
|
572
609
|
readonly [x: string]: unknown;
|
|
573
610
|
readonly type: "web_search_call";
|
|
@@ -612,6 +649,17 @@ export declare const routes: (Route<{
|
|
|
612
649
|
})[];
|
|
613
650
|
readonly instructions?: string | undefined;
|
|
614
651
|
readonly tools?: readonly ({
|
|
652
|
+
readonly type: "custom";
|
|
653
|
+
readonly name: string;
|
|
654
|
+
readonly description: string;
|
|
655
|
+
readonly format: {
|
|
656
|
+
readonly type: "text";
|
|
657
|
+
} | {
|
|
658
|
+
readonly type: "grammar";
|
|
659
|
+
readonly syntax: "lark" | "regex";
|
|
660
|
+
readonly definition: string;
|
|
661
|
+
};
|
|
662
|
+
} | {
|
|
615
663
|
readonly type: "function";
|
|
616
664
|
readonly name: string;
|
|
617
665
|
readonly description: string;
|
|
@@ -624,13 +672,13 @@ export declare const routes: (Route<{
|
|
|
624
672
|
readonly type: string;
|
|
625
673
|
})[] | undefined;
|
|
626
674
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
627
|
-
readonly type: "function";
|
|
675
|
+
readonly type: "custom" | "function";
|
|
628
676
|
readonly name: string;
|
|
629
677
|
} | {
|
|
630
678
|
readonly type: "allowed_tools";
|
|
631
679
|
readonly mode: "auto" | "none" | "required";
|
|
632
680
|
readonly tools: readonly {
|
|
633
|
-
readonly type: "function";
|
|
681
|
+
readonly type: "custom" | "function";
|
|
634
682
|
readonly name: string;
|
|
635
683
|
}[];
|
|
636
684
|
} | undefined;
|
|
@@ -733,9 +781,9 @@ export declare const provider: {
|
|
|
733
781
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
734
782
|
configure: typeof configure;
|
|
735
783
|
};
|
|
736
|
-
export declare const model: ProviderPackage.
|
|
737
|
-
export declare const messagesModel: ProviderPackage.
|
|
738
|
-
export declare const responsesModel: ProviderPackage.
|
|
784
|
+
export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
|
|
785
|
+
export declare const messagesModel: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput>;
|
|
786
|
+
export declare const responsesModel: ProviderPackage.Model<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>;
|
|
739
787
|
export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
|
|
740
788
|
export declare const webSearch: () => ToolDefinition;
|
|
741
789
|
export declare const webExtractor: () => ToolDefinition;
|
|
@@ -12,6 +12,12 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & {
|
|
|
12
12
|
readonly apiKey?: string;
|
|
13
13
|
/** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
|
|
14
14
|
readonly auth?: "bearer" | "sigv4";
|
|
15
|
+
/**
|
|
16
|
+
* Mantle serves each model under one path prefix and rejects it on the others. Responses and Chat default to
|
|
17
|
+
* `https://bedrock-mantle.<region>.api.aws/v1`, which serves open-weight models such as `openai.gpt-oss-120b`.
|
|
18
|
+
* Others, including GPT models such as `openai.gpt-5.4`, need `.../openai/v1`; each AWS model card lists the base
|
|
19
|
+
* URL under Programmatic Access. Messages defaults to `.../anthropic/v1`.
|
|
20
|
+
*/
|
|
15
21
|
readonly baseURL?: string;
|
|
16
22
|
/** Static SigV4 credentials. When omitted the AWS default credential chain resolves them per request. */
|
|
17
23
|
readonly credentials?: Credentials;
|
|
@@ -23,6 +29,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & {
|
|
|
23
29
|
export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
24
30
|
readonly apiKey?: string;
|
|
25
31
|
readonly auth?: "bearer" | "sigv4";
|
|
32
|
+
/** See {@link Config.baseURL}: GPT models such as `openai.gpt-5.4` need `https://bedrock-mantle.<region>.api.aws/openai/v1`. */
|
|
26
33
|
readonly baseURL?: string;
|
|
27
34
|
readonly credentials?: Credentials;
|
|
28
35
|
readonly profile?: string;
|
|
@@ -353,7 +360,7 @@ export declare const routes: (Route<{
|
|
|
353
360
|
readonly role: "developer";
|
|
354
361
|
readonly content: string;
|
|
355
362
|
} | {
|
|
356
|
-
readonly type: "function_call_output";
|
|
363
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
357
364
|
readonly call_id: string;
|
|
358
365
|
readonly output: string | readonly ({
|
|
359
366
|
readonly type: "input_text";
|
|
@@ -423,6 +430,12 @@ export declare const routes: (Route<{
|
|
|
423
430
|
readonly name: string;
|
|
424
431
|
readonly namespace?: string | undefined;
|
|
425
432
|
readonly arguments: string;
|
|
433
|
+
} | {
|
|
434
|
+
readonly type: "custom_tool_call";
|
|
435
|
+
readonly id?: string | undefined;
|
|
436
|
+
readonly call_id: string;
|
|
437
|
+
readonly name: string;
|
|
438
|
+
readonly input: string;
|
|
426
439
|
} | {
|
|
427
440
|
readonly [x: string]: unknown;
|
|
428
441
|
readonly type: "web_search_call";
|
|
@@ -467,6 +480,17 @@ export declare const routes: (Route<{
|
|
|
467
480
|
})[];
|
|
468
481
|
readonly instructions?: string | undefined;
|
|
469
482
|
readonly tools?: readonly ({
|
|
483
|
+
readonly type: "custom";
|
|
484
|
+
readonly name: string;
|
|
485
|
+
readonly description: string;
|
|
486
|
+
readonly format: {
|
|
487
|
+
readonly type: "text";
|
|
488
|
+
} | {
|
|
489
|
+
readonly type: "grammar";
|
|
490
|
+
readonly syntax: "lark" | "regex";
|
|
491
|
+
readonly definition: string;
|
|
492
|
+
};
|
|
493
|
+
} | {
|
|
470
494
|
readonly type: "function";
|
|
471
495
|
readonly name: string;
|
|
472
496
|
readonly description: string;
|
|
@@ -479,13 +503,13 @@ export declare const routes: (Route<{
|
|
|
479
503
|
readonly type: string;
|
|
480
504
|
})[] | undefined;
|
|
481
505
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
482
|
-
readonly type: "function";
|
|
506
|
+
readonly type: "custom" | "function";
|
|
483
507
|
readonly name: string;
|
|
484
508
|
} | {
|
|
485
509
|
readonly type: "allowed_tools";
|
|
486
510
|
readonly mode: "auto" | "none" | "required";
|
|
487
511
|
readonly tools: readonly {
|
|
488
|
-
readonly type: "function";
|
|
512
|
+
readonly type: "custom" | "function";
|
|
489
513
|
readonly name: string;
|
|
490
514
|
}[];
|
|
491
515
|
} | undefined;
|
|
@@ -593,7 +617,14 @@ export declare const routes: (Route<{
|
|
|
593
617
|
readonly ttl?: string | undefined;
|
|
594
618
|
} | undefined;
|
|
595
619
|
}[] | null;
|
|
596
|
-
readonly tool_calls?: readonly {
|
|
620
|
+
readonly tool_calls?: readonly ({
|
|
621
|
+
readonly id: string;
|
|
622
|
+
readonly type: "custom";
|
|
623
|
+
readonly custom: {
|
|
624
|
+
readonly name: string;
|
|
625
|
+
readonly input: string;
|
|
626
|
+
};
|
|
627
|
+
} | {
|
|
597
628
|
readonly id: string;
|
|
598
629
|
readonly type: "function";
|
|
599
630
|
readonly function: {
|
|
@@ -605,13 +636,13 @@ export declare const routes: (Route<{
|
|
|
605
636
|
readonly thought_signature: string;
|
|
606
637
|
};
|
|
607
638
|
} | undefined;
|
|
608
|
-
}[] | undefined;
|
|
639
|
+
})[] | undefined;
|
|
609
640
|
readonly reasoning_content?: string | undefined;
|
|
610
641
|
readonly reasoning?: string | undefined;
|
|
611
642
|
readonly reasoning_text?: string | undefined;
|
|
612
643
|
readonly reasoning_details?: unknown;
|
|
613
644
|
})[];
|
|
614
|
-
readonly tools?: readonly {
|
|
645
|
+
readonly tools?: readonly ({
|
|
615
646
|
readonly type: "function";
|
|
616
647
|
readonly function: {
|
|
617
648
|
readonly name: string;
|
|
@@ -625,12 +656,36 @@ export declare const routes: (Route<{
|
|
|
625
656
|
readonly type: "ephemeral";
|
|
626
657
|
readonly ttl?: string | undefined;
|
|
627
658
|
} | undefined;
|
|
628
|
-
}
|
|
659
|
+
} | {
|
|
660
|
+
readonly type: "custom";
|
|
661
|
+
readonly custom: {
|
|
662
|
+
readonly name: string;
|
|
663
|
+
readonly description: string;
|
|
664
|
+
readonly format: {
|
|
665
|
+
readonly type: "text";
|
|
666
|
+
} | {
|
|
667
|
+
readonly type: "grammar";
|
|
668
|
+
readonly grammar: {
|
|
669
|
+
readonly syntax: "lark" | "regex";
|
|
670
|
+
readonly definition: string;
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
readonly cache_control?: {
|
|
675
|
+
readonly type: "ephemeral";
|
|
676
|
+
readonly ttl?: string | undefined;
|
|
677
|
+
} | undefined;
|
|
678
|
+
})[] | undefined;
|
|
629
679
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
630
680
|
readonly type: "function";
|
|
631
681
|
readonly function: {
|
|
632
682
|
readonly name: string;
|
|
633
683
|
};
|
|
684
|
+
} | {
|
|
685
|
+
readonly type: "custom";
|
|
686
|
+
readonly custom: {
|
|
687
|
+
readonly name: string;
|
|
688
|
+
};
|
|
634
689
|
} | undefined;
|
|
635
690
|
readonly stream: true;
|
|
636
691
|
readonly stream_options?: {
|
|
@@ -676,7 +731,7 @@ export declare const provider: {
|
|
|
676
731
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
677
732
|
configure: typeof configure;
|
|
678
733
|
};
|
|
679
|
-
export declare const chatModel: ProviderPackage.
|
|
680
|
-
export declare const messagesModel: ProviderPackage.
|
|
681
|
-
export declare const responsesModel: ProviderPackage.
|
|
682
|
-
export declare const model:
|
|
734
|
+
export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
735
|
+
export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
|
|
736
|
+
export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
737
|
+
export declare const model: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -87,7 +87,7 @@ export const configure = (input = {}) => {
|
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
export const provider = configure();
|
|
90
|
-
const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions }) => configure({
|
|
90
|
+
const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions } = {}) => configure({
|
|
91
91
|
apiKey,
|
|
92
92
|
auth,
|
|
93
93
|
baseURL,
|
|
@@ -189,4 +189,4 @@ export declare const provider: {
|
|
|
189
189
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<BedrockConverse.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
190
190
|
configure: typeof configure;
|
|
191
191
|
};
|
|
192
|
-
export declare const model: ProviderPackage.
|
|
192
|
+
export declare const model: ProviderPackage.Model<Settings, BedrockConverse.OptionsInput>;
|
|
@@ -28,7 +28,7 @@ export const configure = (input = {}) => {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
export const provider = configure();
|
|
31
|
-
export const model = (modelID, { apiKey, auth, baseURL, credentials, profile, region, topP, headers, body, ...providerOptions }) => configure({
|
|
31
|
+
export const model = (modelID, { apiKey, auth, baseURL, credentials, profile, region, topP, headers, body, ...providerOptions } = {}) => configure({
|
|
32
32
|
apiKey,
|
|
33
33
|
auth,
|
|
34
34
|
baseURL,
|
|
@@ -339,5 +339,5 @@ export declare const provider: {
|
|
|
339
339
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
340
340
|
configure: typeof configure;
|
|
341
341
|
};
|
|
342
|
-
export declare const model: ProviderPackage.
|
|
342
|
+
export declare const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput>;
|
|
343
343
|
export * as AnthropicCompatible from "./anthropic-compatible.js";
|
|
@@ -338,4 +338,4 @@ export declare const provider: {
|
|
|
338
338
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
339
339
|
configure: typeof configure;
|
|
340
340
|
};
|
|
341
|
-
export declare const model: ProviderPackage.
|
|
341
|
+
export declare const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput>;
|
|
@@ -26,7 +26,7 @@ export const configure = (input = {}) => {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export const provider = configure();
|
|
29
|
-
export const model = (modelID, { apiKey, authToken, baseURL, body, headers, ...providerOptions }) => {
|
|
29
|
+
export const model = (modelID, { apiKey, authToken, baseURL, body, headers, ...providerOptions } = {}) => {
|
|
30
30
|
if (apiKey !== undefined && authToken !== undefined)
|
|
31
31
|
throw new ProviderConfigurationError({
|
|
32
32
|
provider: id,
|