@opencode/ai 2.2.7 → 2.3.1
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 +164 -99
- package/dist/cache-policy.js +4 -2
- package/dist/effect.d.ts +11 -8
- package/dist/effect.js +2 -1
- package/dist/experimental.d.ts +0 -4
- package/dist/experimental.js +0 -3
- package/dist/generation.d.ts +10 -10
- package/dist/generation.js +8 -14
- package/dist/image-client.d.ts +56 -59
- package/dist/image-client.js +47 -12
- package/dist/image.d.ts +36 -95
- package/dist/image.js +11 -14
- package/dist/index.d.ts +31 -68
- package/dist/index.js +54 -30
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +10 -1
- package/dist/media-client.d.ts +18 -6
- package/dist/media-client.js +42 -37
- package/dist/media-model.d.ts +2 -0
- package/dist/media-model.js +3 -1
- package/dist/media.d.ts +26 -4
- package/dist/media.js +52 -11
- package/dist/protocols/alibaba-messages.d.ts +24 -2
- package/dist/protocols/alibaba-responses.d.ts +26 -0
- package/dist/protocols/anthropic-messages.d.ts +70 -6
- package/dist/protocols/anthropic-messages.js +74 -9
- package/dist/protocols/assemblyai-transcription.js +7 -6
- package/dist/protocols/cartesia-speech.d.ts +0 -8
- package/dist/protocols/deepgram-speech.d.ts +0 -8
- package/dist/protocols/elevenlabs-speech.d.ts +0 -8
- package/dist/protocols/google-decisions.d.ts +13 -0
- package/dist/protocols/google-decisions.js +133 -0
- package/dist/protocols/google-interactions-video.d.ts +38 -0
- package/dist/protocols/google-interactions-video.js +185 -0
- package/dist/protocols/google-interactions.d.ts +14 -1
- package/dist/protocols/google-interactions.js +1 -1
- package/dist/protocols/google-speech.d.ts +0 -8
- package/dist/protocols/google-transcription.d.ts +0 -8
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/protocols/meta-messages.d.ts +24 -2
- package/dist/protocols/meta-responses.d.ts +52 -0
- package/dist/protocols/minimax-video.d.ts +45 -0
- package/dist/protocols/minimax-video.js +290 -0
- package/dist/protocols/open-responses.d.ts +250 -24
- package/dist/protocols/open-responses.js +40 -24
- package/dist/protocols/openai-chat.js +7 -3
- package/dist/protocols/openai-compatible-responses.d.ts +26 -0
- package/dist/protocols/openai-freeform.d.ts +1 -1
- package/dist/protocols/openai-freeform.js +9 -5
- package/dist/protocols/openai-images.d.ts +0 -8
- package/dist/protocols/openai-responses.d.ts +153 -0
- package/dist/protocols/openai-responses.js +68 -7
- package/dist/protocols/openai-speech.d.ts +0 -8
- package/dist/protocols/openai-transcription.d.ts +0 -8
- package/dist/protocols/openrouter-video.d.ts +36 -0
- package/dist/protocols/openrouter-video.js +139 -0
- package/dist/protocols/seedance-video.d.ts +45 -0
- package/dist/protocols/seedance-video.js +217 -0
- package/dist/protocols/system-one.d.ts +45 -1
- package/dist/protocols/system-one.js +42 -7
- package/dist/protocols/utils/gateway-protocol.js +1 -0
- package/dist/protocols/utils/responses-compaction.js +8 -4
- package/dist/protocols/xai-responses.d.ts +26 -0
- package/dist/protocols/xai-video.d.ts +12 -11
- package/dist/protocols/xai-video.js +33 -24
- package/dist/protocols/zai-messages.d.ts +24 -2
- package/dist/provider-error.js +7 -1
- package/dist/providers/alibaba.d.ts +50 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +50 -2
- package/dist/providers/anthropic-compatible.d.ts +24 -2
- package/dist/providers/anthropic.d.ts +24 -2
- package/dist/providers/azure.d.ts +76 -2
- package/dist/providers/byteplus/videos.d.ts +2 -0
- package/dist/providers/byteplus/videos.js +1 -0
- package/dist/providers/byteplus.d.ts +26 -0
- package/dist/providers/byteplus.js +21 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +100 -4
- package/dist/providers/digitalocean.d.ts +26 -0
- package/dist/providers/google/decisions.d.ts +2 -0
- package/dist/providers/google/decisions.js +1 -0
- package/dist/providers/google/videos.d.ts +2 -0
- package/dist/providers/google/videos.js +1 -0
- package/dist/providers/google-vertex-messages.d.ts +24 -2
- package/dist/providers/google-vertex-messages.js +1 -0
- package/dist/providers/google-vertex-responses.d.ts +26 -0
- package/dist/providers/google.d.ts +11 -4
- package/dist/providers/google.js +16 -3
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.js +2 -1
- package/dist/providers/meta.d.ts +50 -2
- package/dist/providers/minimax/videos.d.ts +3 -0
- package/dist/providers/minimax/videos.js +1 -0
- package/dist/providers/minimax.d.ts +56 -3
- package/dist/providers/minimax.js +10 -1
- package/dist/providers/moonshot.d.ts +50 -2
- package/dist/providers/openai-compatible/decisions.d.ts +2 -0
- package/dist/providers/openai-compatible/decisions.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +26 -0
- package/dist/providers/openai-compatible.d.ts +2 -0
- package/dist/providers/openai-compatible.js +14 -0
- package/dist/providers/openai.d.ts +26 -0
- package/dist/providers/openrouter/videos.d.ts +2 -0
- package/dist/providers/openrouter/videos.js +1 -0
- package/dist/providers/openrouter.d.ts +31 -0
- package/dist/providers/openrouter.js +8 -0
- package/dist/providers/venice.d.ts +26 -0
- package/dist/providers/volcengine/videos.d.ts +2 -0
- package/dist/providers/volcengine/videos.js +1 -0
- package/dist/providers/volcengine.d.ts +26 -0
- package/dist/providers/volcengine.js +21 -0
- package/dist/providers/xai/videos.d.ts +2 -0
- package/dist/providers/xai/videos.js +1 -0
- package/dist/providers/xai.d.ts +4 -3
- package/dist/providers/xai.js +5 -1
- package/dist/providers/zai-coding-plan.d.ts +50 -2
- package/dist/public.d.ts +7 -4
- package/dist/public.js +2 -1
- package/dist/route/client.d.ts +2 -0
- package/dist/route/client.js +5 -1
- package/dist/route/executor-service.d.ts +20 -1
- package/dist/route/executor-service.js +35 -1
- package/dist/route/executor.d.ts +11 -2
- package/dist/route/executor.js +25 -5
- package/dist/route/media-protocol.d.ts +21 -15
- package/dist/route/media-protocol.js +11 -4
- package/dist/route/media.d.ts +2 -0
- package/dist/route/media.js +40 -22
- package/dist/route/protocol.d.ts +3 -0
- package/dist/route/transport/http.js +1 -1
- package/dist/schema/events.d.ts +5 -0
- package/dist/schema/messages.d.ts +25 -2
- package/dist/schema/messages.js +27 -7
- package/dist/schema/options.d.ts +18 -2
- package/dist/schema/options.js +1 -0
- package/dist/speech-client.d.ts +6 -6
- package/dist/speech-client.js +4 -4
- package/dist/speech.d.ts +7 -88
- package/dist/speech.js +1 -3
- package/dist/tool-updates.d.ts +34 -0
- package/dist/tool-updates.js +93 -0
- package/dist/tool.d.ts +6 -1
- package/dist/tool.js +1 -1
- package/dist/transcription-client.d.ts +6 -6
- package/dist/transcription-client.js +1 -2
- package/dist/transcription.d.ts +7 -88
- package/dist/transcription.js +1 -3
- package/dist/video-client.d.ts +16 -84
- package/dist/video-client.js +30 -13
- package/dist/video.d.ts +54 -1126
- package/dist/video.js +29 -65
- package/package.json +59 -7
- package/dist/protocols/google-video.d.ts +0 -26
- package/dist/protocols/google-video.js +0 -146
- package/dist/protocols/runway-video.d.ts +0 -38
- package/dist/protocols/runway-video.js +0 -141
- package/dist/providers/runway.d.ts +0 -20
- package/dist/providers/runway.js +0 -17
|
@@ -12,6 +12,32 @@ export declare const protocol: Protocol<{
|
|
|
12
12
|
readonly reasoning: {
|
|
13
13
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
14
14
|
};
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: "additional_tools";
|
|
17
|
+
readonly role: "developer";
|
|
18
|
+
readonly tools: readonly ({
|
|
19
|
+
readonly type: "custom";
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
readonly format: {
|
|
23
|
+
readonly type: "text";
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: "grammar";
|
|
26
|
+
readonly syntax: "lark" | "regex";
|
|
27
|
+
readonly definition: string;
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly description: string;
|
|
33
|
+
readonly parameters: {
|
|
34
|
+
readonly [x: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
readonly strict?: boolean | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
readonly [x: string]: unknown;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
})[];
|
|
15
41
|
} | {
|
|
16
42
|
readonly type: "message";
|
|
17
43
|
readonly role: "system";
|
|
@@ -8,27 +8,28 @@ export declare const EDIT_PATH = "/videos/edits";
|
|
|
8
8
|
export declare const EXTEND_PATH = "/videos/extensions";
|
|
9
9
|
export declare const STATUS_PATH = "/videos";
|
|
10
10
|
/**
|
|
11
|
-
* Provider-native options. Common fields (`
|
|
12
|
-
* `
|
|
11
|
+
* Provider-native options. Common fields (`start`, `end`, `references`, `duration`, `aspect`, `resolution`,
|
|
12
|
+
* `sound`) live on the request. `mode` sends the request to the edit or extension endpoint with a native
|
|
13
|
+
* `video: { url }` source; `reference_audios` takes preset `voice_id`s.
|
|
13
14
|
*/
|
|
14
15
|
export type XAIVideoOptions = {
|
|
15
16
|
readonly mode?: "edit" | "extend";
|
|
17
|
+
readonly video?: {
|
|
18
|
+
readonly url: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly file_id: string;
|
|
21
|
+
};
|
|
16
22
|
readonly reference_audios?: ReadonlyArray<{
|
|
17
23
|
readonly voice_id: string;
|
|
18
24
|
}>;
|
|
19
25
|
} & Record<string, unknown>;
|
|
20
26
|
export type Request = VideoRequest<VideoModel<XAIVideoOptions>>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}>;
|
|
27
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
28
|
+
export declare const Token: Schema.String;
|
|
24
29
|
export type Token = Schema.Schema.Type<typeof Token>;
|
|
25
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
26
|
-
readonly requestID: string;
|
|
27
|
-
}>;
|
|
30
|
+
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
28
31
|
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<XAIVideoOptions>;
|
|
29
32
|
export declare const XAIVideo: {
|
|
30
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse,
|
|
31
|
-
readonly requestID: string;
|
|
32
|
-
}>;
|
|
33
|
+
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, string>;
|
|
33
34
|
readonly model: typeof model;
|
|
34
35
|
};
|
|
@@ -3,7 +3,7 @@ import { Media } from "../media.js";
|
|
|
3
3
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
5
|
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
-
import { VideoModel, VideoResponse } from "../video.js";
|
|
6
|
+
import { VideoModel, VideoResponse, seconds } from "../video.js";
|
|
7
7
|
import { ProviderShared, optionalNull } from "./shared.js";
|
|
8
8
|
const route = MediaProtocol.identity({ id: "xai-video", name: "xAI Video", provider: "xai" });
|
|
9
9
|
export const DEFAULT_BASE_URL = "https://api.x.ai/v1";
|
|
@@ -14,7 +14,8 @@ export const STATUS_PATH = "/videos";
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
// 2. Token and response schemas
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
|
-
|
|
17
|
+
/** The provider's job ID; it is all a later status, result or cancel call needs. */
|
|
18
|
+
export const Token = Schema.String;
|
|
18
19
|
const StartResponse = Schema.Struct({ request_id: Schema.String });
|
|
19
20
|
const VideoStatus = Schema.Struct({
|
|
20
21
|
status: Schema.String,
|
|
@@ -53,28 +54,32 @@ const nativeOptions = (options) => {
|
|
|
53
54
|
return native;
|
|
54
55
|
};
|
|
55
56
|
const fromRequest = Effect.fn("XAIVideo.fromRequest")(function* (request) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
57
|
+
const references = request.references ?? [];
|
|
58
|
+
if (references.some((asset) => asset.kind === "video"))
|
|
59
|
+
return yield* route.unsupported("video.references", `${route.name} has no reference video input`);
|
|
60
|
+
const image = request.start === undefined ? undefined : yield* mediaInput(request.start);
|
|
61
|
+
const lastFrame = request.end === undefined ? undefined : yield* mediaInput(request.end);
|
|
62
|
+
const images = yield* Effect.forEach(references.filter((asset) => asset.kind !== "audio"), mediaInput);
|
|
63
|
+
const audios = yield* Effect.forEach(references.filter((asset) => asset.kind === "audio"), (asset) => ProviderShared.mediaReference(asset, route.provider, route.name).pipe(Effect.map((reference) => ({ url: reference.value }))));
|
|
60
64
|
return MediaProtocol.json(mergeJsonRecords({
|
|
61
65
|
model: request.model.id,
|
|
62
66
|
prompt: request.prompt,
|
|
63
67
|
image,
|
|
64
68
|
last_frame: lastFrame,
|
|
65
|
-
reference_images:
|
|
66
|
-
|
|
67
|
-
duration: request.
|
|
68
|
-
|
|
69
|
+
reference_images: images.length === 0 ? undefined : images,
|
|
70
|
+
reference_audios: audios.length === 0 ? undefined : audios,
|
|
71
|
+
duration: request.duration === undefined ? undefined : seconds(request.duration),
|
|
72
|
+
// xAI follows the input image's shape when a start frame is set, which is what `auto` asks for.
|
|
73
|
+
aspect_ratio: request.aspect === "auto" && request.start !== undefined ? undefined : request.aspect,
|
|
69
74
|
resolution: request.resolution,
|
|
70
|
-
generate_audio: request.
|
|
75
|
+
generate_audio: request.sound,
|
|
71
76
|
}, nativeOptions(request.providerOptions), request.http?.body) ?? {});
|
|
72
77
|
});
|
|
73
78
|
// ---------------------------------------------------------------------------
|
|
74
79
|
// 6. Response decoding
|
|
75
80
|
// ---------------------------------------------------------------------------
|
|
76
81
|
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
77
|
-
token:
|
|
82
|
+
token: value.request_id,
|
|
78
83
|
snapshot: { id: value.request_id, status: "running" },
|
|
79
84
|
}));
|
|
80
85
|
// `progress` is undocumented but observed live as a 0..100 percentage (recorded cassette: 1 → 10 → 37 → 100).
|
|
@@ -82,22 +87,25 @@ const fraction = (progress) => progress !== undefined && progress !== null && pr
|
|
|
82
87
|
const decodeVideoStatus = route.decodeJson(VideoStatus);
|
|
83
88
|
const decodeStatus = Effect.fn("XAIVideo.decodeStatus")(function* (response, context) {
|
|
84
89
|
const output = yield* decodeVideoStatus(response);
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
return {
|
|
91
|
+
id: context.token,
|
|
92
|
+
...MediaProtocol.status(STATUS, output.value.status),
|
|
93
|
+
progress: fraction(output.value.progress),
|
|
94
|
+
};
|
|
87
95
|
});
|
|
88
96
|
const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, context) {
|
|
89
97
|
const output = yield* decodeVideoStatus(response);
|
|
90
98
|
const decoded = output.value;
|
|
91
|
-
const status = MediaProtocol.
|
|
99
|
+
const status = MediaProtocol.state(STATUS, decoded.status);
|
|
92
100
|
if (status === "running")
|
|
93
|
-
return yield* output.pending(context.token
|
|
101
|
+
return yield* output.pending(context.token);
|
|
94
102
|
if (status === "failed") {
|
|
95
103
|
const code = decoded.error?.code ?? undefined;
|
|
96
104
|
const message = decoded.error?.message ?? undefined;
|
|
97
105
|
return yield* output.ended("failed", `${route.name} generation failed${code === undefined ? "" : ` (${code})`}${message === undefined ? "" : `: ${message}`}`, MediaProtocol.failure(FAILURE, code));
|
|
98
106
|
}
|
|
99
107
|
if (status !== "completed")
|
|
100
|
-
return yield* output.ended("expired", `${route.name} request ${context.token
|
|
108
|
+
return yield* output.ended("expired", `${route.name} request ${context.token} expired`);
|
|
101
109
|
// `respect_moderation: false` marks a filtered result; a URL may still be present, so only a missing one fails.
|
|
102
110
|
const moderated = decoded.video?.respect_moderation === false;
|
|
103
111
|
const url = decoded.video?.url ?? undefined;
|
|
@@ -115,7 +123,7 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
115
123
|
],
|
|
116
124
|
providerMetadata: {
|
|
117
125
|
xai: {
|
|
118
|
-
requestId: context.token
|
|
126
|
+
requestId: context.token,
|
|
119
127
|
model: decoded.model ?? undefined,
|
|
120
128
|
respectModeration: decoded.video?.respect_moderation ?? undefined,
|
|
121
129
|
},
|
|
@@ -125,19 +133,20 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
125
133
|
// ---------------------------------------------------------------------------
|
|
126
134
|
// 7. Protocol and route
|
|
127
135
|
// ---------------------------------------------------------------------------
|
|
128
|
-
const statusPath = (token) => `${STATUS_PATH}/${token
|
|
136
|
+
const statusPath = (token) => `${STATUS_PATH}/${encodeURIComponent(token)}`;
|
|
129
137
|
export const protocol = MediaProtocol.queued(route, {
|
|
130
138
|
token: Token,
|
|
131
|
-
unsupported: ["n", "seed", "negativePrompt"],
|
|
132
139
|
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
133
140
|
status: { path: statusPath, decode: decodeStatus },
|
|
134
141
|
result: { path: statusPath, decode: decodeResult },
|
|
135
142
|
});
|
|
136
|
-
//
|
|
143
|
+
// `providerOptions.mode` sends the native `video` source to the edit or extension endpoint.
|
|
137
144
|
const startPath = (request) => {
|
|
138
|
-
if (request.
|
|
139
|
-
return
|
|
140
|
-
|
|
145
|
+
if (request.providerOptions?.mode === "edit")
|
|
146
|
+
return EDIT_PATH;
|
|
147
|
+
if (request.providerOptions?.mode === "extend")
|
|
148
|
+
return EXTEND_PATH;
|
|
149
|
+
return PATH;
|
|
141
150
|
};
|
|
142
151
|
export const model = (input) => VideoModel.fromRoute({
|
|
143
152
|
protocol,
|
|
@@ -237,14 +237,36 @@ export declare const protocol: Protocol<{
|
|
|
237
237
|
})[];
|
|
238
238
|
} | {
|
|
239
239
|
readonly role: "system";
|
|
240
|
-
readonly content: readonly {
|
|
240
|
+
readonly content: readonly ({
|
|
241
|
+
readonly type: "tool_addition";
|
|
242
|
+
readonly tool: {
|
|
243
|
+
readonly type: "tool_definition";
|
|
244
|
+
readonly definition: {
|
|
245
|
+
readonly name: string;
|
|
246
|
+
readonly description: string;
|
|
247
|
+
readonly input_schema: {
|
|
248
|
+
readonly [x: string]: unknown;
|
|
249
|
+
};
|
|
250
|
+
readonly cache_control?: {
|
|
251
|
+
readonly type: "ephemeral";
|
|
252
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
253
|
+
} | undefined;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
readonly type: "tool_removal";
|
|
258
|
+
readonly tool: {
|
|
259
|
+
readonly type: "tool_reference";
|
|
260
|
+
readonly name: string;
|
|
261
|
+
};
|
|
262
|
+
} | {
|
|
241
263
|
readonly type: "text";
|
|
242
264
|
readonly text: string;
|
|
243
265
|
readonly cache_control?: {
|
|
244
266
|
readonly type: "ephemeral";
|
|
245
267
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
246
268
|
} | undefined;
|
|
247
|
-
}[];
|
|
269
|
+
})[];
|
|
248
270
|
readonly output_config?: {
|
|
249
271
|
readonly effort: string;
|
|
250
272
|
} | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -110,6 +110,12 @@ const CONTENT_POLICY_CODES = new Set([
|
|
|
110
110
|
"refusal",
|
|
111
111
|
"datainspectionfailed",
|
|
112
112
|
"moderation_blocked",
|
|
113
|
+
// Gemini Decisions rejects blocked input with these `error.code` strings on a 400.
|
|
114
|
+
"safety",
|
|
115
|
+
"prohibited_content",
|
|
116
|
+
"blocklist",
|
|
117
|
+
"image_safety",
|
|
118
|
+
"content_blocked",
|
|
113
119
|
]);
|
|
114
120
|
// OpenCode Zen replaces upstream codes outside its allow-list but keeps the original
|
|
115
121
|
// as a `[code]` label at the start of the rewritten message.
|
|
@@ -120,7 +126,7 @@ const RATE_LIMIT_TEXT = /rate increased too quickly|rate[-_\s]?limit|too[_\s]?ma
|
|
|
120
126
|
// Only consulted on 429, where throttles and account caps share a status.
|
|
121
127
|
// Z.ai reports balance, plan expiry, plan limits, and plan model access on 429.
|
|
122
128
|
// Cerebras reports its per-minute token throttle as `token_quota_exceeded`; that is a rate limit.
|
|
123
|
-
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;
|
|
129
|
+
const QUOTA_TEXT = /insufficient[-_\s]?(?:quota|balance)|(?<!token_)quota[-_\s]?exceeded|budget exceeded|usage limit|(?<!rate[-_\s]?)limit exhausted|package has expired|plan does not yet include/i;
|
|
124
130
|
// Policy rejections without a dedicated code, matched against the provider's own
|
|
125
131
|
// explanation only. OpenAI reuses `invalid_prompt` for usage-policy rejections while
|
|
126
132
|
// Bedrock Mantle reuses it for schema validation; Anthropic reports blocked output
|
|
@@ -448,14 +448,36 @@ export declare const routes: (Route<{
|
|
|
448
448
|
})[];
|
|
449
449
|
} | {
|
|
450
450
|
readonly role: "system";
|
|
451
|
-
readonly content: readonly {
|
|
451
|
+
readonly content: readonly ({
|
|
452
|
+
readonly type: "tool_addition";
|
|
453
|
+
readonly tool: {
|
|
454
|
+
readonly type: "tool_definition";
|
|
455
|
+
readonly definition: {
|
|
456
|
+
readonly name: string;
|
|
457
|
+
readonly description: string;
|
|
458
|
+
readonly input_schema: {
|
|
459
|
+
readonly [x: string]: unknown;
|
|
460
|
+
};
|
|
461
|
+
readonly cache_control?: {
|
|
462
|
+
readonly type: "ephemeral";
|
|
463
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
464
|
+
} | undefined;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
} | {
|
|
468
|
+
readonly type: "tool_removal";
|
|
469
|
+
readonly tool: {
|
|
470
|
+
readonly type: "tool_reference";
|
|
471
|
+
readonly name: string;
|
|
472
|
+
};
|
|
473
|
+
} | {
|
|
452
474
|
readonly type: "text";
|
|
453
475
|
readonly text: string;
|
|
454
476
|
readonly cache_control?: {
|
|
455
477
|
readonly type: "ephemeral";
|
|
456
478
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
457
479
|
} | undefined;
|
|
458
|
-
}[];
|
|
480
|
+
})[];
|
|
459
481
|
readonly output_config?: {
|
|
460
482
|
readonly effort: string;
|
|
461
483
|
} | undefined;
|
|
@@ -521,6 +543,32 @@ export declare const routes: (Route<{
|
|
|
521
543
|
readonly reasoning: {
|
|
522
544
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
523
545
|
};
|
|
546
|
+
} | {
|
|
547
|
+
readonly type: "additional_tools";
|
|
548
|
+
readonly role: "developer";
|
|
549
|
+
readonly tools: readonly ({
|
|
550
|
+
readonly type: "custom";
|
|
551
|
+
readonly name: string;
|
|
552
|
+
readonly description: string;
|
|
553
|
+
readonly format: {
|
|
554
|
+
readonly type: "text";
|
|
555
|
+
} | {
|
|
556
|
+
readonly type: "grammar";
|
|
557
|
+
readonly syntax: "lark" | "regex";
|
|
558
|
+
readonly definition: string;
|
|
559
|
+
};
|
|
560
|
+
} | {
|
|
561
|
+
readonly type: "function";
|
|
562
|
+
readonly name: string;
|
|
563
|
+
readonly description: string;
|
|
564
|
+
readonly parameters: {
|
|
565
|
+
readonly [x: string]: unknown;
|
|
566
|
+
};
|
|
567
|
+
readonly strict?: boolean | undefined;
|
|
568
|
+
} | {
|
|
569
|
+
readonly [x: string]: unknown;
|
|
570
|
+
readonly type: string;
|
|
571
|
+
})[];
|
|
524
572
|
} | {
|
|
525
573
|
readonly type: "message";
|
|
526
574
|
readonly role: "system";
|
|
@@ -266,14 +266,36 @@ export declare const routes: (Route<{
|
|
|
266
266
|
})[];
|
|
267
267
|
} | {
|
|
268
268
|
readonly role: "system";
|
|
269
|
-
readonly content: readonly {
|
|
269
|
+
readonly content: readonly ({
|
|
270
|
+
readonly type: "tool_addition";
|
|
271
|
+
readonly tool: {
|
|
272
|
+
readonly type: "tool_definition";
|
|
273
|
+
readonly definition: {
|
|
274
|
+
readonly name: string;
|
|
275
|
+
readonly description: string;
|
|
276
|
+
readonly input_schema: {
|
|
277
|
+
readonly [x: string]: unknown;
|
|
278
|
+
};
|
|
279
|
+
readonly cache_control?: {
|
|
280
|
+
readonly type: "ephemeral";
|
|
281
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
282
|
+
} | undefined;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
} | {
|
|
286
|
+
readonly type: "tool_removal";
|
|
287
|
+
readonly tool: {
|
|
288
|
+
readonly type: "tool_reference";
|
|
289
|
+
readonly name: string;
|
|
290
|
+
};
|
|
291
|
+
} | {
|
|
270
292
|
readonly type: "text";
|
|
271
293
|
readonly text: string;
|
|
272
294
|
readonly cache_control?: {
|
|
273
295
|
readonly type: "ephemeral";
|
|
274
296
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
275
297
|
} | undefined;
|
|
276
|
-
}[];
|
|
298
|
+
})[];
|
|
277
299
|
readonly output_config?: {
|
|
278
300
|
readonly effort: string;
|
|
279
301
|
} | undefined;
|
|
@@ -351,6 +373,32 @@ export declare const routes: (Route<{
|
|
|
351
373
|
readonly reasoning: {
|
|
352
374
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
353
375
|
};
|
|
376
|
+
} | {
|
|
377
|
+
readonly type: "additional_tools";
|
|
378
|
+
readonly role: "developer";
|
|
379
|
+
readonly tools: readonly ({
|
|
380
|
+
readonly type: "custom";
|
|
381
|
+
readonly name: string;
|
|
382
|
+
readonly description: string;
|
|
383
|
+
readonly format: {
|
|
384
|
+
readonly type: "text";
|
|
385
|
+
} | {
|
|
386
|
+
readonly type: "grammar";
|
|
387
|
+
readonly syntax: "lark" | "regex";
|
|
388
|
+
readonly definition: string;
|
|
389
|
+
};
|
|
390
|
+
} | {
|
|
391
|
+
readonly type: "function";
|
|
392
|
+
readonly name: string;
|
|
393
|
+
readonly description: string;
|
|
394
|
+
readonly parameters: {
|
|
395
|
+
readonly [x: string]: unknown;
|
|
396
|
+
};
|
|
397
|
+
readonly strict?: boolean | undefined;
|
|
398
|
+
} | {
|
|
399
|
+
readonly [x: string]: unknown;
|
|
400
|
+
readonly type: string;
|
|
401
|
+
})[];
|
|
354
402
|
} | {
|
|
355
403
|
readonly type: "message";
|
|
356
404
|
readonly role: "system";
|
|
@@ -250,14 +250,36 @@ export declare const routes: import("../route.js").Route<{
|
|
|
250
250
|
})[];
|
|
251
251
|
} | {
|
|
252
252
|
readonly role: "system";
|
|
253
|
-
readonly content: readonly {
|
|
253
|
+
readonly content: readonly ({
|
|
254
|
+
readonly type: "tool_addition";
|
|
255
|
+
readonly tool: {
|
|
256
|
+
readonly type: "tool_definition";
|
|
257
|
+
readonly definition: {
|
|
258
|
+
readonly name: string;
|
|
259
|
+
readonly description: string;
|
|
260
|
+
readonly input_schema: {
|
|
261
|
+
readonly [x: string]: unknown;
|
|
262
|
+
};
|
|
263
|
+
readonly cache_control?: {
|
|
264
|
+
readonly type: "ephemeral";
|
|
265
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
266
|
+
} | undefined;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
} | {
|
|
270
|
+
readonly type: "tool_removal";
|
|
271
|
+
readonly tool: {
|
|
272
|
+
readonly type: "tool_reference";
|
|
273
|
+
readonly name: string;
|
|
274
|
+
};
|
|
275
|
+
} | {
|
|
254
276
|
readonly type: "text";
|
|
255
277
|
readonly text: string;
|
|
256
278
|
readonly cache_control?: {
|
|
257
279
|
readonly type: "ephemeral";
|
|
258
280
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
259
281
|
} | undefined;
|
|
260
|
-
}[];
|
|
282
|
+
})[];
|
|
261
283
|
readonly output_config?: {
|
|
262
284
|
readonly effort: string;
|
|
263
285
|
} | undefined;
|
|
@@ -235,14 +235,36 @@ export declare const routes: import("../route.js").Route<{
|
|
|
235
235
|
})[];
|
|
236
236
|
} | {
|
|
237
237
|
readonly role: "system";
|
|
238
|
-
readonly content: readonly {
|
|
238
|
+
readonly content: readonly ({
|
|
239
|
+
readonly type: "tool_addition";
|
|
240
|
+
readonly tool: {
|
|
241
|
+
readonly type: "tool_definition";
|
|
242
|
+
readonly definition: {
|
|
243
|
+
readonly name: string;
|
|
244
|
+
readonly description: string;
|
|
245
|
+
readonly input_schema: {
|
|
246
|
+
readonly [x: string]: unknown;
|
|
247
|
+
};
|
|
248
|
+
readonly cache_control?: {
|
|
249
|
+
readonly type: "ephemeral";
|
|
250
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
251
|
+
} | undefined;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
} | {
|
|
255
|
+
readonly type: "tool_removal";
|
|
256
|
+
readonly tool: {
|
|
257
|
+
readonly type: "tool_reference";
|
|
258
|
+
readonly name: string;
|
|
259
|
+
};
|
|
260
|
+
} | {
|
|
239
261
|
readonly type: "text";
|
|
240
262
|
readonly text: string;
|
|
241
263
|
readonly cache_control?: {
|
|
242
264
|
readonly type: "ephemeral";
|
|
243
265
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
244
266
|
} | undefined;
|
|
245
|
-
}[];
|
|
267
|
+
})[];
|
|
246
268
|
readonly output_config?: {
|
|
247
269
|
readonly effort: string;
|
|
248
270
|
} | undefined;
|
|
@@ -29,6 +29,32 @@ declare const responsesRoute: Route<{
|
|
|
29
29
|
readonly reasoning: {
|
|
30
30
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
31
31
|
};
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "additional_tools";
|
|
34
|
+
readonly role: "developer";
|
|
35
|
+
readonly tools: readonly ({
|
|
36
|
+
readonly type: "custom";
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly description: string;
|
|
39
|
+
readonly format: {
|
|
40
|
+
readonly type: "text";
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "grammar";
|
|
43
|
+
readonly syntax: "lark" | "regex";
|
|
44
|
+
readonly definition: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "function";
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly description: string;
|
|
50
|
+
readonly parameters: {
|
|
51
|
+
readonly [x: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
readonly strict?: boolean | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
readonly [x: string]: unknown;
|
|
56
|
+
readonly type: string;
|
|
57
|
+
})[];
|
|
32
58
|
} | {
|
|
33
59
|
readonly type: "message";
|
|
34
60
|
readonly role: "system";
|
|
@@ -483,14 +509,36 @@ export declare const routes: (Route<{
|
|
|
483
509
|
})[];
|
|
484
510
|
} | {
|
|
485
511
|
readonly role: "system";
|
|
486
|
-
readonly content: readonly {
|
|
512
|
+
readonly content: readonly ({
|
|
513
|
+
readonly type: "tool_addition";
|
|
514
|
+
readonly tool: {
|
|
515
|
+
readonly type: "tool_definition";
|
|
516
|
+
readonly definition: {
|
|
517
|
+
readonly name: string;
|
|
518
|
+
readonly description: string;
|
|
519
|
+
readonly input_schema: {
|
|
520
|
+
readonly [x: string]: unknown;
|
|
521
|
+
};
|
|
522
|
+
readonly cache_control?: {
|
|
523
|
+
readonly type: "ephemeral";
|
|
524
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
525
|
+
} | undefined;
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
} | {
|
|
529
|
+
readonly type: "tool_removal";
|
|
530
|
+
readonly tool: {
|
|
531
|
+
readonly type: "tool_reference";
|
|
532
|
+
readonly name: string;
|
|
533
|
+
};
|
|
534
|
+
} | {
|
|
487
535
|
readonly type: "text";
|
|
488
536
|
readonly text: string;
|
|
489
537
|
readonly cache_control?: {
|
|
490
538
|
readonly type: "ephemeral";
|
|
491
539
|
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
492
540
|
} | undefined;
|
|
493
|
-
}[];
|
|
541
|
+
})[];
|
|
494
542
|
readonly output_config?: {
|
|
495
543
|
readonly effort: string;
|
|
496
544
|
} | undefined;
|
|
@@ -742,6 +790,32 @@ export declare const routes: (Route<{
|
|
|
742
790
|
readonly reasoning: {
|
|
743
791
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
744
792
|
};
|
|
793
|
+
} | {
|
|
794
|
+
readonly type: "additional_tools";
|
|
795
|
+
readonly role: "developer";
|
|
796
|
+
readonly tools: readonly ({
|
|
797
|
+
readonly type: "custom";
|
|
798
|
+
readonly name: string;
|
|
799
|
+
readonly description: string;
|
|
800
|
+
readonly format: {
|
|
801
|
+
readonly type: "text";
|
|
802
|
+
} | {
|
|
803
|
+
readonly type: "grammar";
|
|
804
|
+
readonly syntax: "lark" | "regex";
|
|
805
|
+
readonly definition: string;
|
|
806
|
+
};
|
|
807
|
+
} | {
|
|
808
|
+
readonly type: "function";
|
|
809
|
+
readonly name: string;
|
|
810
|
+
readonly description: string;
|
|
811
|
+
readonly parameters: {
|
|
812
|
+
readonly [x: string]: unknown;
|
|
813
|
+
};
|
|
814
|
+
readonly strict?: boolean | undefined;
|
|
815
|
+
} | {
|
|
816
|
+
readonly [x: string]: unknown;
|
|
817
|
+
readonly type: string;
|
|
818
|
+
})[];
|
|
745
819
|
} | {
|
|
746
820
|
readonly type: "message";
|
|
747
821
|
readonly role: "system";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { videoModel as model } from "../byteplus.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import { type HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
+
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
+
readonly baseURL?: string;
|
|
7
|
+
readonly headers?: Record<string, string>;
|
|
8
|
+
readonly http?: HttpOptions;
|
|
9
|
+
};
|
|
10
|
+
export type Settings = ProviderPackage.Settings & {
|
|
11
|
+
readonly apiKey?: string | false;
|
|
12
|
+
readonly baseURL?: string;
|
|
13
|
+
};
|
|
14
|
+
export type { SeedanceVideoOptions } from "../protocols/seedance-video.js";
|
|
15
|
+
export declare const configure: (input?: Config) => {
|
|
16
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
17
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
18
|
+
configure: typeof configure;
|
|
19
|
+
};
|
|
20
|
+
export declare const provider: {
|
|
21
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
22
|
+
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
23
|
+
configure: typeof configure;
|
|
24
|
+
};
|
|
25
|
+
export declare const videoModel: (modelID: string, settings?: Settings) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
26
|
+
export declare const video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/seedance-video.js").SeedanceVideoOptions>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SeedanceVideo } from "../protocols/seedance-video.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
+
import { MediaRoute } from "../route/media.js";
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { toConfig } from "./settings.js";
|
|
6
|
+
export const id = ProviderID.make("byteplus");
|
|
7
|
+
const auth = (options) => AuthOptions.bearer(options, "BYTEPLUS_API_KEY");
|
|
8
|
+
export const configure = (input = {}) => {
|
|
9
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
10
|
+
return {
|
|
11
|
+
id,
|
|
12
|
+
video: (modelID, providerOptions) => SeedanceVideo.byteplus.model({ ...media, id: modelID, providerOptions }),
|
|
13
|
+
configure,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const provider = configure();
|
|
17
|
+
export const videoModel = (modelID, settings) => {
|
|
18
|
+
const input = toConfig(settings);
|
|
19
|
+
return configure(input).video(modelID, input.providerOptions);
|
|
20
|
+
};
|
|
21
|
+
export const video = provider.video;
|