@opencode/ai 2.0.22 → 2.0.23
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 +61 -1
- package/dist/cache-policy.js +1 -0
- package/dist/protocols/alibaba-chat.d.ts +3 -3
- package/dist/protocols/alibaba-responses.d.ts +16 -12
- package/dist/protocols/alibaba-responses.js +3 -5
- package/dist/protocols/anthropic-messages.js +44 -39
- package/dist/protocols/bedrock-converse.js +3 -3
- package/dist/protocols/cartesia-speech.js +3 -3
- package/dist/protocols/cohere-chat.d.ts +178 -0
- package/dist/protocols/cohere-chat.js +299 -0
- package/dist/protocols/elevenlabs-speech.js +3 -3
- package/dist/protocols/gemini.d.ts +2 -2
- package/dist/protocols/gemini.js +3 -3
- package/dist/protocols/google-interactions.d.ts +236 -0
- package/dist/protocols/google-interactions.js +478 -0
- package/dist/protocols/google-speech.js +1 -1
- package/dist/protocols/google-transcription.js +1 -1
- package/dist/protocols/index.d.ts +2 -0
- package/dist/protocols/index.js +2 -0
- package/dist/protocols/meta-responses.d.ts +31 -58
- package/dist/protocols/meta-responses.js +8 -27
- package/dist/protocols/mistral-chat.d.ts +24 -9
- package/dist/protocols/mistral-chat.js +22 -10
- package/dist/protocols/open-responses.d.ts +406 -91
- package/dist/protocols/open-responses.js +25 -15
- package/dist/protocols/openai-chat.d.ts +401 -5
- package/dist/protocols/openai-chat.js +18 -21
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +16 -4
- package/dist/protocols/openai-images.js +2 -2
- package/dist/protocols/openai-responses.d.ts +87 -223
- package/dist/protocols/openai-responses.js +6 -13
- package/dist/protocols/openai-speech.js +1 -1
- package/dist/protocols/openai-transcription.js +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/stability-images.js +1 -1
- package/dist/protocols/utils/bedrock-media.js +2 -2
- package/dist/protocols/utils/responses-checkpoint.js +2 -2
- package/dist/protocols/utils/responses-hosted-tools.js +1 -1
- package/dist/protocols/utils/tool-stream.js +15 -7
- package/dist/protocols/venice-chat.d.ts +280 -0
- package/dist/protocols/venice-chat.js +283 -0
- package/dist/protocols/xai-responses.d.ts +18 -21
- package/dist/protocols/xai-responses.js +2 -8
- package/dist/protocols/zai-chat.d.ts +3 -3
- package/dist/provider-error.js +7 -1
- package/dist/providers/alibaba.d.ts +17 -13
- package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
- package/dist/providers/amazon-bedrock-mantle.js +28 -3
- package/dist/providers/azure.d.ts +13 -61
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
- package/dist/providers/cohere/chat.d.ts +4 -0
- package/dist/providers/cohere/chat.js +8 -0
- package/dist/providers/cohere.d.ts +395 -0
- package/dist/providers/cohere.js +48 -0
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/digitalocean.d.ts +5 -5
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/google/interactions.d.ts +7 -0
- package/dist/providers/google/interactions.js +8 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-responses.d.ts +16 -4
- package/dist/providers/google-vertex.d.ts +1 -1
- package/dist/providers/google.d.ts +95 -4
- package/dist/providers/google.js +8 -1
- package/dist/providers/groq.d.ts +4 -4
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/meta.d.ts +15 -28
- package/dist/providers/minimax.d.ts +17 -5
- package/dist/providers/mistral.d.ts +10 -4
- package/dist/providers/moonshot.d.ts +17 -5
- package/dist/providers/openai-compatible-responses.d.ts +16 -4
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai-options.d.ts +1 -1
- package/dist/providers/openai.d.ts +7 -31
- package/dist/providers/openrouter.d.ts +5 -5
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/venice.d.ts +183 -0
- package/dist/providers/venice.js +38 -0
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +17 -5
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.js +2 -5
- package/dist/route/framing.js +23 -23
- package/package.json +3 -3
|
@@ -21,17 +21,11 @@ const XAIResponsesHostedToolItem = Schema.Union([
|
|
|
21
21
|
error: Schema.optional(Schema.Unknown),
|
|
22
22
|
}), [JsonObject]),
|
|
23
23
|
]);
|
|
24
|
-
const XAIResponsesBody = Schema.Struct({
|
|
25
|
-
...OpenResponses.coreFields,
|
|
26
|
-
input: Schema.Array(Schema.Union([OpenResponses.InputItem, XAIResponsesHostedToolItem])),
|
|
27
|
-
stream: Schema.Literal(true),
|
|
28
|
-
});
|
|
29
24
|
const adapter = {
|
|
30
25
|
id: ADAPTER,
|
|
31
26
|
name: NAME,
|
|
32
27
|
restoreHostedToolItem: (item) => (Schema.is(XAIResponsesHostedToolItem)(item) ? item : undefined),
|
|
33
28
|
};
|
|
34
|
-
const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(XAIResponsesBody));
|
|
35
29
|
const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
|
|
36
30
|
if (request.providerOptions?.contextManagement !== undefined)
|
|
37
31
|
return yield* ProviderShared.unsupportedOperation({
|
|
@@ -40,7 +34,7 @@ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
|
|
|
40
34
|
route: request.model.route.id,
|
|
41
35
|
message: "xAI requires explicit compaction through LLMClient.compact; automatic context management is not supported",
|
|
42
36
|
});
|
|
43
|
-
return yield*
|
|
37
|
+
return yield* OpenResponses.fromRequestWithAdapter(request, adapter);
|
|
44
38
|
});
|
|
45
39
|
const HOSTED_TOOLS = {
|
|
46
40
|
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
@@ -67,7 +61,7 @@ const step = (state, input) => {
|
|
|
67
61
|
export const protocol = Protocol.make({
|
|
68
62
|
id: ADAPTER,
|
|
69
63
|
body: {
|
|
70
|
-
schema:
|
|
64
|
+
schema: OpenResponses.OpenResponsesBody,
|
|
71
65
|
from: fromRequest,
|
|
72
66
|
},
|
|
73
67
|
stream: {
|
|
@@ -142,9 +142,9 @@ export declare const protocol: Protocol<{
|
|
|
142
142
|
readonly top_p?: number | undefined;
|
|
143
143
|
readonly frequency_penalty?: number | undefined;
|
|
144
144
|
readonly presence_penalty?: number | undefined;
|
|
145
|
+
readonly store?: boolean | undefined;
|
|
145
146
|
readonly prompt_cache_key?: string | undefined;
|
|
146
147
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
147
|
-
readonly store?: boolean | undefined;
|
|
148
148
|
readonly stream_options?: {
|
|
149
149
|
readonly include_usage: boolean;
|
|
150
150
|
} | undefined;
|
|
@@ -165,9 +165,9 @@ export declare const protocol: Protocol<{
|
|
|
165
165
|
readonly [x: string]: unknown;
|
|
166
166
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
167
167
|
readonly cached_tokens?: number | null | undefined;
|
|
168
|
+
readonly total_tokens?: number | null | undefined;
|
|
168
169
|
readonly prompt_tokens?: number | null | undefined;
|
|
169
170
|
readonly completion_tokens?: number | null | undefined;
|
|
170
|
-
readonly total_tokens?: number | null | undefined;
|
|
171
171
|
readonly prompt_tokens_details?: {
|
|
172
172
|
readonly [x: string]: unknown;
|
|
173
173
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -206,9 +206,9 @@ export declare const protocol: Protocol<{
|
|
|
206
206
|
readonly [x: string]: unknown;
|
|
207
207
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
208
208
|
readonly cached_tokens?: number | null | undefined;
|
|
209
|
+
readonly total_tokens?: number | null | undefined;
|
|
209
210
|
readonly prompt_tokens?: number | null | undefined;
|
|
210
211
|
readonly completion_tokens?: number | null | undefined;
|
|
211
|
-
readonly total_tokens?: number | null | undefined;
|
|
212
212
|
readonly prompt_tokens_details?: {
|
|
213
213
|
readonly [x: string]: unknown;
|
|
214
214
|
readonly cached_tokens?: number | null | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -40,7 +40,13 @@ const patterns = [
|
|
|
40
40
|
/request_too_large/i,
|
|
41
41
|
];
|
|
42
42
|
const payloadPatterns = [/request entity too large/i, /payload too large/i, /request too large/i];
|
|
43
|
-
const exclusions = [
|
|
43
|
+
const exclusions = [
|
|
44
|
+
/^(throttling error|service unavailable):/i,
|
|
45
|
+
/rate limit/i,
|
|
46
|
+
/too many requests/i,
|
|
47
|
+
// Cohere reports an output limit above the model maximum as "too many tokens"; compaction cannot fix it.
|
|
48
|
+
/max[_ ]tokens must be less than/i,
|
|
49
|
+
];
|
|
44
50
|
export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
|
|
45
51
|
(patterns.some((pattern) => pattern.test(message)) || /^4(?:00|13)\s*(status code)?\s*\(no body\)/i.test(message));
|
|
46
52
|
export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message));
|
|
@@ -141,10 +141,10 @@ export declare const routes: (Route<{
|
|
|
141
141
|
readonly top_k?: number | undefined;
|
|
142
142
|
readonly frequency_penalty?: number | undefined;
|
|
143
143
|
readonly presence_penalty?: number | undefined;
|
|
144
|
+
readonly store?: boolean | undefined;
|
|
144
145
|
readonly prompt_cache_key?: string | undefined;
|
|
145
146
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
146
147
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
147
|
-
readonly store?: boolean | undefined;
|
|
148
148
|
readonly stream_options?: {
|
|
149
149
|
readonly include_usage: boolean;
|
|
150
150
|
} | undefined;
|
|
@@ -464,6 +464,15 @@ export declare const routes: (Route<{
|
|
|
464
464
|
readonly error?: unknown;
|
|
465
465
|
readonly arguments?: string | undefined;
|
|
466
466
|
readonly server_label?: string | undefined;
|
|
467
|
+
} | {
|
|
468
|
+
readonly type: "configuration_update";
|
|
469
|
+
readonly reasoning: {
|
|
470
|
+
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
471
|
+
};
|
|
472
|
+
} | {
|
|
473
|
+
readonly [x: string]: unknown;
|
|
474
|
+
readonly type: string;
|
|
475
|
+
readonly id: string;
|
|
467
476
|
} | {
|
|
468
477
|
readonly type: "reasoning";
|
|
469
478
|
readonly summary: readonly {
|
|
@@ -540,12 +549,6 @@ export declare const routes: (Route<{
|
|
|
540
549
|
readonly type: "input_video";
|
|
541
550
|
readonly video_url: string;
|
|
542
551
|
})[];
|
|
543
|
-
} | {
|
|
544
|
-
readonly [x: string]: unknown;
|
|
545
|
-
readonly id: string;
|
|
546
|
-
readonly type: "web_extractor_call";
|
|
547
|
-
readonly urls?: readonly string[] | undefined;
|
|
548
|
-
readonly goal?: string | undefined;
|
|
549
552
|
})[];
|
|
550
553
|
readonly model: string;
|
|
551
554
|
readonly stream: true;
|
|
@@ -558,6 +561,9 @@ export declare const routes: (Route<{
|
|
|
558
561
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
559
562
|
} | undefined;
|
|
560
563
|
readonly tools?: readonly ({
|
|
564
|
+
readonly [x: string]: unknown;
|
|
565
|
+
readonly type: string;
|
|
566
|
+
} | {
|
|
561
567
|
readonly type: "function";
|
|
562
568
|
readonly description: string;
|
|
563
569
|
readonly name: string;
|
|
@@ -565,8 +571,6 @@ export declare const routes: (Route<{
|
|
|
565
571
|
readonly [x: string]: unknown;
|
|
566
572
|
};
|
|
567
573
|
readonly strict?: boolean | undefined;
|
|
568
|
-
} | {
|
|
569
|
-
readonly type: "web_search" | "code_interpreter" | "web_extractor";
|
|
570
574
|
})[] | undefined;
|
|
571
575
|
readonly text?: {
|
|
572
576
|
readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
|
|
@@ -587,9 +591,10 @@ export declare const routes: (Route<{
|
|
|
587
591
|
readonly top_p?: number | undefined;
|
|
588
592
|
readonly frequency_penalty?: number | undefined;
|
|
589
593
|
readonly presence_penalty?: number | undefined;
|
|
594
|
+
readonly store?: boolean | undefined;
|
|
595
|
+
readonly max_output_tokens?: number | undefined;
|
|
590
596
|
readonly prompt_cache_key?: string | undefined;
|
|
591
597
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
592
|
-
readonly store?: boolean | undefined;
|
|
593
598
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
594
599
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
595
600
|
readonly stream_options?: {
|
|
@@ -597,7 +602,6 @@ export declare const routes: (Route<{
|
|
|
597
602
|
} | undefined;
|
|
598
603
|
readonly safety_identifier?: string | undefined;
|
|
599
604
|
readonly top_logprobs?: number | undefined;
|
|
600
|
-
readonly max_output_tokens?: number | undefined;
|
|
601
605
|
readonly max_tool_calls?: number | undefined;
|
|
602
606
|
readonly previous_response_id?: string | undefined;
|
|
603
607
|
readonly conversation?: string | undefined;
|
|
@@ -657,8 +661,8 @@ export declare const configure: (input: Config) => {
|
|
|
657
661
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
658
662
|
messages: (id: string | ModelID) => import("../schema/options.js").LanguageModel<AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
659
663
|
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
660
|
-
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
661
664
|
readonly store?: boolean | undefined;
|
|
665
|
+
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
662
666
|
readonly conversation?: string | undefined;
|
|
663
667
|
readonly enableThinking?: boolean | undefined;
|
|
664
668
|
readonly previousResponseId?: string | undefined;
|
|
@@ -721,8 +725,8 @@ export declare const provider: {
|
|
|
721
725
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
722
726
|
messages: (id: string | ModelID) => import("../schema/options.js").LanguageModel<AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
723
727
|
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
724
|
-
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
725
728
|
readonly store?: boolean | undefined;
|
|
729
|
+
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
726
730
|
readonly conversation?: string | undefined;
|
|
727
731
|
readonly enableThinking?: boolean | undefined;
|
|
728
732
|
readonly previousResponseId?: string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { messagesModel as model } from "../../amazon-bedrock-mantle.js";
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
4
|
import { type Credentials } from "../protocols/utils/bedrock-auth.js";
|
|
4
5
|
import { type ModelID } from "../schema/index.js";
|
|
5
6
|
import { type OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type
|
|
8
|
+
export type OpenAIOptionsInput = OpenAIProviderOptionsInput;
|
|
9
|
+
export type MessagesOptionsInput = AnthropicMessages.ProviderOptionsInput;
|
|
10
|
+
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & {
|
|
8
11
|
/** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
|
|
9
12
|
readonly apiKey?: string;
|
|
10
13
|
/** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
|
|
@@ -15,9 +18,9 @@ export type Config = RouteDefaultsInput & {
|
|
|
15
18
|
/** Shared config profile for the default credential chain. */
|
|
16
19
|
readonly profile?: string;
|
|
17
20
|
readonly region?: string;
|
|
18
|
-
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
21
|
+
readonly providerOptions?: OpenAIProviderOptionsInput | AnthropicMessages.ProviderOptionsInput;
|
|
19
22
|
};
|
|
20
|
-
export type Settings = ProviderPackage.Settings &
|
|
23
|
+
export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
21
24
|
readonly apiKey?: string;
|
|
22
25
|
readonly auth?: "bearer" | "sigv4";
|
|
23
26
|
readonly baseURL?: string;
|
|
@@ -26,7 +29,280 @@ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
|
26
29
|
readonly region?: string;
|
|
27
30
|
readonly topP?: number;
|
|
28
31
|
};
|
|
32
|
+
export type MessagesSettings = Settings<AnthropicMessages.ProviderOptionsInput>;
|
|
29
33
|
export declare const routes: (Route<{
|
|
34
|
+
readonly max_tokens: number;
|
|
35
|
+
readonly model: string;
|
|
36
|
+
readonly messages: readonly ({
|
|
37
|
+
readonly role: "user";
|
|
38
|
+
readonly content: readonly ({
|
|
39
|
+
readonly type: "text";
|
|
40
|
+
readonly text: string;
|
|
41
|
+
readonly cache_control?: {
|
|
42
|
+
readonly type: "ephemeral";
|
|
43
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "image";
|
|
47
|
+
readonly source: {
|
|
48
|
+
readonly type: "base64";
|
|
49
|
+
readonly media_type: string;
|
|
50
|
+
readonly data: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly type: "url";
|
|
53
|
+
readonly url: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "file";
|
|
56
|
+
readonly file_id: string;
|
|
57
|
+
};
|
|
58
|
+
readonly cache_control?: {
|
|
59
|
+
readonly type: "ephemeral";
|
|
60
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
readonly transformations?: {
|
|
63
|
+
readonly oversized_image?: "error" | "downsize" | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
readonly type: "document";
|
|
67
|
+
readonly source: {
|
|
68
|
+
readonly type: "base64";
|
|
69
|
+
readonly media_type: "application/pdf";
|
|
70
|
+
readonly data: string;
|
|
71
|
+
} | {
|
|
72
|
+
readonly type: "text";
|
|
73
|
+
readonly media_type: "text/plain";
|
|
74
|
+
readonly data: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "url";
|
|
77
|
+
readonly url: string;
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: "file";
|
|
80
|
+
readonly file_id: string;
|
|
81
|
+
};
|
|
82
|
+
readonly title?: string | undefined;
|
|
83
|
+
readonly context?: string | undefined;
|
|
84
|
+
readonly cache_control?: {
|
|
85
|
+
readonly type: "ephemeral";
|
|
86
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
readonly citations?: {
|
|
89
|
+
readonly enabled: boolean;
|
|
90
|
+
} | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
readonly type: "tool_result";
|
|
93
|
+
readonly content: string | readonly ({
|
|
94
|
+
readonly type: "text";
|
|
95
|
+
readonly text: string;
|
|
96
|
+
readonly cache_control?: {
|
|
97
|
+
readonly type: "ephemeral";
|
|
98
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
} | {
|
|
101
|
+
readonly type: "image";
|
|
102
|
+
readonly source: {
|
|
103
|
+
readonly type: "base64";
|
|
104
|
+
readonly media_type: string;
|
|
105
|
+
readonly data: string;
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: "url";
|
|
108
|
+
readonly url: string;
|
|
109
|
+
} | {
|
|
110
|
+
readonly type: "file";
|
|
111
|
+
readonly file_id: string;
|
|
112
|
+
};
|
|
113
|
+
readonly cache_control?: {
|
|
114
|
+
readonly type: "ephemeral";
|
|
115
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
readonly transformations?: {
|
|
118
|
+
readonly oversized_image?: "error" | "downsize" | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
} | {
|
|
121
|
+
readonly type: "document";
|
|
122
|
+
readonly source: {
|
|
123
|
+
readonly type: "base64";
|
|
124
|
+
readonly media_type: "application/pdf";
|
|
125
|
+
readonly data: string;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "text";
|
|
128
|
+
readonly media_type: "text/plain";
|
|
129
|
+
readonly data: string;
|
|
130
|
+
} | {
|
|
131
|
+
readonly type: "url";
|
|
132
|
+
readonly url: string;
|
|
133
|
+
} | {
|
|
134
|
+
readonly type: "file";
|
|
135
|
+
readonly file_id: string;
|
|
136
|
+
};
|
|
137
|
+
readonly title?: string | undefined;
|
|
138
|
+
readonly context?: string | undefined;
|
|
139
|
+
readonly cache_control?: {
|
|
140
|
+
readonly type: "ephemeral";
|
|
141
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
readonly citations?: {
|
|
144
|
+
readonly enabled: boolean;
|
|
145
|
+
} | undefined;
|
|
146
|
+
})[];
|
|
147
|
+
readonly tool_use_id: string;
|
|
148
|
+
readonly cache_control?: {
|
|
149
|
+
readonly type: "ephemeral";
|
|
150
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
151
|
+
} | undefined;
|
|
152
|
+
readonly is_error?: boolean | undefined;
|
|
153
|
+
})[];
|
|
154
|
+
} | {
|
|
155
|
+
readonly role: "assistant";
|
|
156
|
+
readonly content: readonly ({
|
|
157
|
+
readonly type: "text";
|
|
158
|
+
readonly text: string;
|
|
159
|
+
readonly cache_control?: {
|
|
160
|
+
readonly type: "ephemeral";
|
|
161
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
162
|
+
} | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
readonly type: "tool_use";
|
|
166
|
+
readonly name: string;
|
|
167
|
+
readonly input: unknown;
|
|
168
|
+
readonly cache_control?: {
|
|
169
|
+
readonly type: "ephemeral";
|
|
170
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
171
|
+
} | undefined;
|
|
172
|
+
} | {
|
|
173
|
+
readonly id: string;
|
|
174
|
+
readonly type: "server_tool_use";
|
|
175
|
+
readonly name: string;
|
|
176
|
+
readonly input: unknown;
|
|
177
|
+
readonly cache_control?: {
|
|
178
|
+
readonly type: "ephemeral";
|
|
179
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | {
|
|
182
|
+
readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
|
|
183
|
+
readonly content: unknown;
|
|
184
|
+
readonly tool_use_id: string;
|
|
185
|
+
readonly cache_control?: {
|
|
186
|
+
readonly type: "ephemeral";
|
|
187
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
} | {
|
|
190
|
+
readonly type: "thinking";
|
|
191
|
+
readonly thinking: string;
|
|
192
|
+
readonly signature: string;
|
|
193
|
+
readonly cache_control?: {
|
|
194
|
+
readonly type: "ephemeral";
|
|
195
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
196
|
+
} | undefined;
|
|
197
|
+
} | {
|
|
198
|
+
readonly data: string;
|
|
199
|
+
readonly type: "redacted_thinking";
|
|
200
|
+
readonly cache_control?: {
|
|
201
|
+
readonly type: "ephemeral";
|
|
202
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
203
|
+
} | undefined;
|
|
204
|
+
} | {
|
|
205
|
+
readonly type: "compaction";
|
|
206
|
+
readonly content: string | null;
|
|
207
|
+
})[];
|
|
208
|
+
} | {
|
|
209
|
+
readonly content: readonly {
|
|
210
|
+
readonly type: "text";
|
|
211
|
+
readonly text: string;
|
|
212
|
+
readonly cache_control?: {
|
|
213
|
+
readonly type: "ephemeral";
|
|
214
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
}[];
|
|
217
|
+
readonly role: "system";
|
|
218
|
+
readonly output_config?: {
|
|
219
|
+
readonly effort: string;
|
|
220
|
+
} | undefined;
|
|
221
|
+
})[];
|
|
222
|
+
readonly stream: true;
|
|
223
|
+
readonly metadata?: {
|
|
224
|
+
readonly user_id?: string | null | undefined;
|
|
225
|
+
} | undefined;
|
|
226
|
+
readonly tools?: readonly {
|
|
227
|
+
readonly description: string;
|
|
228
|
+
readonly name: string;
|
|
229
|
+
readonly input_schema: {
|
|
230
|
+
readonly [x: string]: unknown;
|
|
231
|
+
};
|
|
232
|
+
readonly cache_control?: {
|
|
233
|
+
readonly type: "ephemeral";
|
|
234
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
235
|
+
} | undefined;
|
|
236
|
+
}[] | undefined;
|
|
237
|
+
readonly system?: readonly {
|
|
238
|
+
readonly type: "text";
|
|
239
|
+
readonly text: string;
|
|
240
|
+
readonly cache_control?: {
|
|
241
|
+
readonly type: "ephemeral";
|
|
242
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
243
|
+
} | undefined;
|
|
244
|
+
}[] | undefined;
|
|
245
|
+
readonly temperature?: number | undefined;
|
|
246
|
+
readonly thinking?: {
|
|
247
|
+
readonly type: "enabled";
|
|
248
|
+
readonly budget_tokens: number;
|
|
249
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
250
|
+
readonly block_binding?: {
|
|
251
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
252
|
+
} | undefined;
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: "adaptive";
|
|
255
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
256
|
+
readonly block_binding?: {
|
|
257
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
258
|
+
} | undefined;
|
|
259
|
+
} | {
|
|
260
|
+
readonly type: "disabled";
|
|
261
|
+
} | undefined;
|
|
262
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
263
|
+
readonly container?: string | {
|
|
264
|
+
readonly id?: string | null | undefined;
|
|
265
|
+
readonly skills?: readonly {
|
|
266
|
+
readonly [x: string]: unknown;
|
|
267
|
+
}[] | null | undefined;
|
|
268
|
+
} | null | undefined;
|
|
269
|
+
readonly inference_geo?: string | null | undefined;
|
|
270
|
+
readonly cache_control?: {
|
|
271
|
+
readonly type: "ephemeral";
|
|
272
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
273
|
+
} | undefined;
|
|
274
|
+
readonly output_config?: {
|
|
275
|
+
readonly format?: {
|
|
276
|
+
readonly type: "json_schema";
|
|
277
|
+
readonly schema: {
|
|
278
|
+
readonly [x: string]: unknown;
|
|
279
|
+
};
|
|
280
|
+
} | null | undefined;
|
|
281
|
+
readonly effort?: string | undefined;
|
|
282
|
+
} | undefined;
|
|
283
|
+
readonly context_management?: {
|
|
284
|
+
readonly edits: readonly {
|
|
285
|
+
readonly type: "compact_20260112";
|
|
286
|
+
readonly instructions?: string | undefined;
|
|
287
|
+
readonly trigger?: {
|
|
288
|
+
readonly type: "input_tokens";
|
|
289
|
+
readonly value: number;
|
|
290
|
+
} | undefined;
|
|
291
|
+
readonly pause_after_compaction?: boolean | undefined;
|
|
292
|
+
}[];
|
|
293
|
+
} | undefined;
|
|
294
|
+
readonly tool_choice?: {
|
|
295
|
+
readonly type: "auto" | "none" | "any";
|
|
296
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
297
|
+
} | {
|
|
298
|
+
readonly type: "tool";
|
|
299
|
+
readonly name: string;
|
|
300
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
301
|
+
} | undefined;
|
|
302
|
+
readonly top_p?: number | undefined;
|
|
303
|
+
readonly top_k?: number | undefined;
|
|
304
|
+
readonly stop_sequences?: readonly string[] | undefined;
|
|
305
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
30
306
|
readonly model: string;
|
|
31
307
|
readonly messages: readonly ({
|
|
32
308
|
readonly role: "system";
|
|
@@ -140,9 +416,9 @@ export declare const routes: (Route<{
|
|
|
140
416
|
readonly top_p?: number | undefined;
|
|
141
417
|
readonly frequency_penalty?: number | undefined;
|
|
142
418
|
readonly presence_penalty?: number | undefined;
|
|
419
|
+
readonly store?: boolean | undefined;
|
|
143
420
|
readonly prompt_cache_key?: string | undefined;
|
|
144
421
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
145
|
-
readonly store?: boolean | undefined;
|
|
146
422
|
readonly stream_options?: {
|
|
147
423
|
readonly include_usage: boolean;
|
|
148
424
|
} | undefined;
|
|
@@ -185,6 +461,15 @@ export declare const routes: (Route<{
|
|
|
185
461
|
readonly error?: unknown;
|
|
186
462
|
readonly arguments?: string | undefined;
|
|
187
463
|
readonly server_label?: string | undefined;
|
|
464
|
+
} | {
|
|
465
|
+
readonly type: "configuration_update";
|
|
466
|
+
readonly reasoning: {
|
|
467
|
+
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
468
|
+
};
|
|
469
|
+
} | {
|
|
470
|
+
readonly [x: string]: unknown;
|
|
471
|
+
readonly type: string;
|
|
472
|
+
readonly id: string;
|
|
188
473
|
} | {
|
|
189
474
|
readonly type: "reasoning";
|
|
190
475
|
readonly summary: readonly {
|
|
@@ -272,7 +557,10 @@ export declare const routes: (Route<{
|
|
|
272
557
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
273
558
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
274
559
|
} | undefined;
|
|
275
|
-
readonly tools?: readonly {
|
|
560
|
+
readonly tools?: readonly ({
|
|
561
|
+
readonly [x: string]: unknown;
|
|
562
|
+
readonly type: string;
|
|
563
|
+
} | {
|
|
276
564
|
readonly type: "function";
|
|
277
565
|
readonly description: string;
|
|
278
566
|
readonly name: string;
|
|
@@ -280,7 +568,7 @@ export declare const routes: (Route<{
|
|
|
280
568
|
readonly [x: string]: unknown;
|
|
281
569
|
};
|
|
282
570
|
readonly strict?: boolean | undefined;
|
|
283
|
-
}[] | undefined;
|
|
571
|
+
})[] | undefined;
|
|
284
572
|
readonly text?: {
|
|
285
573
|
readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
|
|
286
574
|
} | undefined;
|
|
@@ -300,9 +588,10 @@ export declare const routes: (Route<{
|
|
|
300
588
|
readonly top_p?: number | undefined;
|
|
301
589
|
readonly frequency_penalty?: number | undefined;
|
|
302
590
|
readonly presence_penalty?: number | undefined;
|
|
591
|
+
readonly store?: boolean | undefined;
|
|
592
|
+
readonly max_output_tokens?: number | undefined;
|
|
303
593
|
readonly prompt_cache_key?: string | undefined;
|
|
304
594
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
305
|
-
readonly store?: boolean | undefined;
|
|
306
595
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
307
596
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
308
597
|
readonly stream_options?: {
|
|
@@ -310,13 +599,13 @@ export declare const routes: (Route<{
|
|
|
310
599
|
} | undefined;
|
|
311
600
|
readonly safety_identifier?: string | undefined;
|
|
312
601
|
readonly top_logprobs?: number | undefined;
|
|
313
|
-
readonly max_output_tokens?: number | undefined;
|
|
314
602
|
readonly max_tool_calls?: number | undefined;
|
|
315
603
|
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
|
|
316
604
|
export declare const configure: (input?: Config) => {
|
|
317
605
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
318
606
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
319
607
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
608
|
+
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
320
609
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
321
610
|
configure: (input?: Config) => /*elided*/ any;
|
|
322
611
|
};
|
|
@@ -324,15 +613,18 @@ export declare const provider: {
|
|
|
324
613
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
325
614
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
326
615
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
616
|
+
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
327
617
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
328
618
|
configure: (input?: Config) => {
|
|
329
619
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
330
620
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
331
621
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
622
|
+
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
332
623
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
333
624
|
configure: /*elided*/ any;
|
|
334
625
|
};
|
|
335
626
|
};
|
|
336
627
|
export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
|
|
628
|
+
export declare const messagesModel: ProviderPackage.Definition<MessagesSettings, AnthropicMessages.ProviderOptionsInput>["model"];
|
|
337
629
|
export declare const responsesModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
|
|
338
|
-
export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
630
|
+
export declare const model: (modelID: string, settings: Settings<import("./openai-options.js").OpenAIOptionsInput>) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Route } from "../route/client.js";
|
|
2
2
|
import { Endpoint } from "../route/endpoint.js";
|
|
3
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
4
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
4
5
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
5
6
|
import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
|
|
7
|
+
import { claudeVersion } from "../protocols/utils/claude-model.js";
|
|
6
8
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
7
9
|
import { withOpenAIOptions } from "./openai-options.js";
|
|
8
10
|
export const id = ProviderID.make("amazon-bedrock");
|
|
@@ -20,11 +22,30 @@ const chatRoute = OpenAIChat.route.with({
|
|
|
20
22
|
provider: id,
|
|
21
23
|
providerMetadataKey: "mantle",
|
|
22
24
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const messagesRoute = Route.make({
|
|
26
|
+
id: "bedrock-mantle-messages",
|
|
27
|
+
provider: id,
|
|
28
|
+
providerMetadataKey: "mantle",
|
|
29
|
+
protocol: {
|
|
30
|
+
...AnthropicMessages.protocol,
|
|
31
|
+
// Mantle rejects mid-conversation `output_config` on Opus 5.0; support starts at 5.1+.
|
|
32
|
+
supportsEffortUpdates: (request) => {
|
|
33
|
+
const override = request.model.compatibility?.supportsEffortUpdates;
|
|
34
|
+
if (override !== undefined)
|
|
35
|
+
return override;
|
|
36
|
+
const version = claudeVersion(request.model.id);
|
|
37
|
+
return version !== undefined && (version.major > 5 || (version.major === 5 && version.minor >= 1));
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
endpoint: Endpoint.path(AnthropicMessages.PATH),
|
|
41
|
+
transport: AnthropicMessages.transport(),
|
|
42
|
+
headers: () => ({ "anthropic-version": "2023-06-01" }),
|
|
43
|
+
});
|
|
44
|
+
export const routes = [responsesRoute, chatRoute, messagesRoute];
|
|
45
|
+
const configuredRoute = (route, input, defaultBaseURL = (region) => `https://bedrock-mantle.${region}.api.aws/v1`) => {
|
|
25
46
|
const region = BedrockAuth.resolveRegion(input);
|
|
26
47
|
return route.with({
|
|
27
|
-
endpoint: { baseURL: input.baseURL ??
|
|
48
|
+
endpoint: { baseURL: input.baseURL ?? defaultBaseURL(region) },
|
|
28
49
|
auth: BedrockAuth.resolveAuth(input, region, {
|
|
29
50
|
service: "bedrock-mantle",
|
|
30
51
|
name: "Bedrock Mantle",
|
|
@@ -46,6 +67,7 @@ export const configure = (input = {}) => {
|
|
|
46
67
|
});
|
|
47
68
|
const configuredResponsesRoute = configuredRoute(responsesRoute, input);
|
|
48
69
|
const configuredChatRoute = configuredRoute(chatRoute, input);
|
|
70
|
+
const configuredMessagesRoute = configuredRoute(messagesRoute, input, (region) => `https://bedrock-mantle.${region}.api.aws/anthropic/v1`);
|
|
49
71
|
const modelDefaults = defaults(input);
|
|
50
72
|
const responses = (modelID) => configuredResponsesRoute
|
|
51
73
|
.with(withOpenAIOptions(modelID, modelDefaults))
|
|
@@ -53,10 +75,12 @@ export const configure = (input = {}) => {
|
|
|
53
75
|
const chat = (modelID) => configuredChatRoute
|
|
54
76
|
.with(withOpenAIOptions(modelID, modelDefaults))
|
|
55
77
|
.model({ id: modelID });
|
|
78
|
+
const messages = (modelID) => configuredMessagesRoute.with(modelDefaults).model({ id: modelID });
|
|
56
79
|
return {
|
|
57
80
|
id,
|
|
58
81
|
model: responses,
|
|
59
82
|
chat,
|
|
83
|
+
messages,
|
|
60
84
|
responses,
|
|
61
85
|
configure,
|
|
62
86
|
};
|
|
@@ -75,5 +99,6 @@ const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profi
|
|
|
75
99
|
region,
|
|
76
100
|
});
|
|
77
101
|
export const chatModel = (modelID, settings) => fromSettings(settings).chat(modelID);
|
|
102
|
+
export const messagesModel = (modelID, settings) => fromSettings(settings).messages(modelID);
|
|
78
103
|
export const responsesModel = (modelID, settings) => fromSettings(settings).responses(modelID);
|
|
79
104
|
export const model = responsesModel;
|