@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
package/dist/video.js
CHANGED
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
import { Effect, Schema
|
|
2
|
-
import { Generation, ProgressEvent, QueuedEvent } from "./generation.js";
|
|
1
|
+
import { Duration, Effect, Schema } from "effect";
|
|
3
2
|
import { Media } from "./media.js";
|
|
4
|
-
import { MediaModel,
|
|
3
|
+
import { MediaModel, composeQueuedRoute, tryRequest } from "./media-model.js";
|
|
5
4
|
import { MediaRoute } from "./route/media.js";
|
|
6
5
|
import { AIError, MediaUsage, ProviderMetadata, ProviderOptions, } from "./schema/index.js";
|
|
7
6
|
import { VideoClient, Service } from "./video-client.js";
|
|
8
7
|
export class VideoModel extends MediaModel {
|
|
8
|
+
/** A video route's token is the provider's job ID, so `VideoJob.id` is exactly what `status` and `result` take. */
|
|
9
9
|
static fromRoute(route, input) {
|
|
10
10
|
return new VideoModel({
|
|
11
11
|
id: input.id,
|
|
12
12
|
provider: route.protocol.provider,
|
|
13
13
|
http: input.http,
|
|
14
14
|
providerOptions: input.providerOptions,
|
|
15
|
-
route:
|
|
15
|
+
route: composeQueuedRoute(route, input),
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
export const VideoModelSchema = Schema.declare((value) => value instanceof VideoModel, {
|
|
20
20
|
expected: "Video.Model",
|
|
21
21
|
});
|
|
22
|
-
export const VideoAspectRatio = Media.AspectRatio;
|
|
23
|
-
|
|
24
|
-
export const VideoFrames = Schema.Struct({
|
|
25
|
-
first: Schema.optional(Media.AssetSchema),
|
|
26
|
-
last: Schema.optional(Media.AssetSchema),
|
|
27
|
-
}).annotate({ identifier: "Video.Frames" });
|
|
22
|
+
export const VideoAspectRatio = Schema.Union([Media.AspectRatio, Schema.Literal("auto")]);
|
|
23
|
+
export const VideoDuration = Schema.declare((value) => typeof value === "string" && /^\d+(?:\.\d+)? seconds?$/.test(value), { title: "Video.Duration" });
|
|
28
24
|
const VideoRequestSchema = Schema.Struct({
|
|
29
25
|
model: VideoModelSchema,
|
|
30
26
|
prompt: Schema.String,
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
/** Image the video starts on exactly. */
|
|
28
|
+
start: Schema.optional(Media.ImageAssetSchema),
|
|
29
|
+
/** Image the video ends on exactly. */
|
|
30
|
+
end: Schema.optional(Media.ImageAssetSchema),
|
|
31
|
+
/** Images, videos or audio that guide the subject or style without pinning a frame. */
|
|
33
32
|
references: Schema.optional(Schema.Array(Media.AssetSchema)),
|
|
34
|
-
|
|
35
|
-
video: Schema.optional(Media.AssetSchema),
|
|
36
|
-
durationSeconds: Schema.optional(Schema.Number),
|
|
33
|
+
duration: Schema.optional(VideoDuration),
|
|
37
34
|
aspect: Schema.optional(VideoAspectRatio),
|
|
38
35
|
resolution: Schema.optional(Schema.String),
|
|
39
|
-
/** Whether
|
|
40
|
-
|
|
41
|
-
n: Schema.optional(Schema.Int),
|
|
42
|
-
seed: Schema.optional(Schema.Number),
|
|
43
|
-
negativePrompt: Schema.optional(Schema.String),
|
|
36
|
+
/** Whether the video has a generated soundtrack; unset leaves the model's default. */
|
|
37
|
+
sound: Schema.optional(Schema.Boolean),
|
|
44
38
|
providerOptions: Schema.optional(ProviderOptions),
|
|
45
39
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
40
|
+
/** Seconds in a request's `duration`, for protocols that send a number. */
|
|
41
|
+
export const seconds = (duration) => Duration.toSeconds(Duration.fromInputUnsafe(duration));
|
|
49
42
|
export class VideoResponse extends Schema.Class("Video.Response")({
|
|
50
43
|
videos: Schema.Array(Media.AssetSchema),
|
|
51
44
|
usage: Schema.optional(MediaUsage),
|
|
@@ -55,42 +48,15 @@ export class VideoResponse extends Schema.Class("Video.Response")({
|
|
|
55
48
|
return this.videos[0];
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
|
-
export const VideoOutputEvent = Schema.Struct({
|
|
59
|
-
type: Schema.tag("video"),
|
|
60
|
-
index: Schema.Number,
|
|
61
|
-
video: Media.AssetSchema,
|
|
62
|
-
}).annotate({ identifier: "Video.Event.Video" });
|
|
63
|
-
export const VideoFinishEvent = Schema.Struct({
|
|
64
|
-
type: Schema.tag("finish"),
|
|
65
|
-
usage: Schema.optional(MediaUsage),
|
|
66
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
67
|
-
}).annotate({ identifier: "Video.Event.Finish" });
|
|
68
|
-
const videoEventTagged = Schema.Union([QueuedEvent, ProgressEvent, VideoOutputEvent, VideoFinishEvent]).pipe(Schema.toTaggedUnion("type"));
|
|
69
|
-
export const VideoEvent = Object.assign(videoEventTagged, {
|
|
70
|
-
is: {
|
|
71
|
-
generationQueued: videoEventTagged.guards["generation-queued"],
|
|
72
|
-
generationProgress: videoEventTagged.guards["generation-progress"],
|
|
73
|
-
video: videoEventTagged.guards.video,
|
|
74
|
-
finish: videoEventTagged.guards.finish,
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
const collectResponse = (events) => {
|
|
78
|
-
const finish = events.find(VideoEvent.is.finish);
|
|
79
|
-
// A streaming video protocol's `finish` emits the terminal event or fails, so a completed stream always has one.
|
|
80
|
-
if (finish === undefined)
|
|
81
|
-
return Effect.die(new Error("The video stream completed without a finish event"));
|
|
82
|
-
return Effect.succeed(new VideoResponse({
|
|
83
|
-
videos: events.filter(VideoEvent.is.video).map((event) => event.video),
|
|
84
|
-
usage: finish.usage,
|
|
85
|
-
providerMetadata: finish.providerMetadata,
|
|
86
|
-
}));
|
|
87
|
-
};
|
|
88
51
|
// ---------------------------------------------------------------------------
|
|
89
|
-
//
|
|
52
|
+
// Call API
|
|
90
53
|
// ---------------------------------------------------------------------------
|
|
91
54
|
/** Normalize video request input into a plain `VideoRequest`. */
|
|
92
55
|
export const request = (input) => ({
|
|
93
56
|
...input,
|
|
57
|
+
start: input.start === undefined ? undefined : Media.image(input.start),
|
|
58
|
+
end: input.end === undefined ? undefined : Media.image(input.end),
|
|
59
|
+
references: input.references?.map((reference) => Media.make(reference)),
|
|
94
60
|
});
|
|
95
61
|
const validate = Schema.decodeUnknownSync(VideoRequestSchema);
|
|
96
62
|
const requestEffect = (input) => tryRequest(() => {
|
|
@@ -101,18 +67,16 @@ const requestEffect = (input) => tryRequest(() => {
|
|
|
101
67
|
export function start(input) {
|
|
102
68
|
return requestEffect(input).pipe(Effect.flatMap((request) => VideoClient.start(request)));
|
|
103
69
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export
|
|
110
|
-
return Stream.unwrap(requestEffect(input).pipe(Effect.map((request) => VideoClient.stream(request, options))));
|
|
111
|
-
}
|
|
70
|
+
/** One status read for a job ID. */
|
|
71
|
+
export const status = (model, id) => VideoClient.status(model, id);
|
|
72
|
+
/** The finished videos; fails while the job is still running, or with the provider's reason when it failed. */
|
|
73
|
+
export const result = (model, id) => VideoClient.result(model, id);
|
|
74
|
+
/** Ask the provider to stop the job; fails with `UnsupportedOperation` when the provider has no cancel call. */
|
|
75
|
+
export const cancel = (model, id) => VideoClient.cancel(model, id);
|
|
112
76
|
export const Video = {
|
|
113
77
|
request,
|
|
114
78
|
start,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
79
|
+
status,
|
|
80
|
+
result,
|
|
81
|
+
cancel,
|
|
118
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -128,6 +128,14 @@
|
|
|
128
128
|
"types": "./dist/providers/baseten/decisions.d.ts",
|
|
129
129
|
"import": "./dist/providers/baseten/decisions.js"
|
|
130
130
|
},
|
|
131
|
+
"./providers/byteplus": {
|
|
132
|
+
"types": "./dist/providers/byteplus.d.ts",
|
|
133
|
+
"import": "./dist/providers/byteplus.js"
|
|
134
|
+
},
|
|
135
|
+
"./providers/byteplus/videos": {
|
|
136
|
+
"types": "./dist/providers/byteplus/videos.d.ts",
|
|
137
|
+
"import": "./dist/providers/byteplus/videos.js"
|
|
138
|
+
},
|
|
131
139
|
"./providers/cartesia": {
|
|
132
140
|
"types": "./dist/providers/cartesia.d.ts",
|
|
133
141
|
"import": "./dist/providers/cartesia.js"
|
|
@@ -260,6 +268,10 @@
|
|
|
260
268
|
"types": "./dist/providers/google-vertex/responses.d.ts",
|
|
261
269
|
"import": "./dist/providers/google-vertex/responses.js"
|
|
262
270
|
},
|
|
271
|
+
"./providers/google/decisions": {
|
|
272
|
+
"types": "./dist/providers/google/decisions.d.ts",
|
|
273
|
+
"import": "./dist/providers/google/decisions.js"
|
|
274
|
+
},
|
|
263
275
|
"./providers/google/embeddings": {
|
|
264
276
|
"types": "./dist/providers/google/embeddings.d.ts",
|
|
265
277
|
"import": "./dist/providers/google/embeddings.js"
|
|
@@ -272,6 +284,10 @@
|
|
|
272
284
|
"types": "./dist/providers/google/interactions.d.ts",
|
|
273
285
|
"import": "./dist/providers/google/interactions.js"
|
|
274
286
|
},
|
|
287
|
+
"./providers/google/videos": {
|
|
288
|
+
"types": "./dist/providers/google/videos.d.ts",
|
|
289
|
+
"import": "./dist/providers/google/videos.js"
|
|
290
|
+
},
|
|
275
291
|
"./providers/groq": {
|
|
276
292
|
"types": "./dist/providers/groq.d.ts",
|
|
277
293
|
"import": "./dist/providers/groq.js"
|
|
@@ -316,6 +332,10 @@
|
|
|
316
332
|
"types": "./dist/providers/minimax/responses.d.ts",
|
|
317
333
|
"import": "./dist/providers/minimax/responses.js"
|
|
318
334
|
},
|
|
335
|
+
"./providers/minimax/videos": {
|
|
336
|
+
"types": "./dist/providers/minimax/videos.d.ts",
|
|
337
|
+
"import": "./dist/providers/minimax/videos.js"
|
|
338
|
+
},
|
|
319
339
|
"./providers/mistral": {
|
|
320
340
|
"types": "./dist/providers/mistral.d.ts",
|
|
321
341
|
"import": "./dist/providers/mistral.js"
|
|
@@ -348,6 +368,10 @@
|
|
|
348
368
|
"types": "./dist/providers/openai-compatible-responses.d.ts",
|
|
349
369
|
"import": "./dist/providers/openai-compatible-responses.js"
|
|
350
370
|
},
|
|
371
|
+
"./providers/openai-compatible/decisions": {
|
|
372
|
+
"types": "./dist/providers/openai-compatible/decisions.d.ts",
|
|
373
|
+
"import": "./dist/providers/openai-compatible/decisions.js"
|
|
374
|
+
},
|
|
351
375
|
"./providers/openai-compatible/embeddings": {
|
|
352
376
|
"types": "./dist/providers/openai-compatible/embeddings.d.ts",
|
|
353
377
|
"import": "./dist/providers/openai-compatible/embeddings.js"
|
|
@@ -400,14 +424,14 @@
|
|
|
400
424
|
"types": "./dist/providers/openrouter/images.d.ts",
|
|
401
425
|
"import": "./dist/providers/openrouter/images.js"
|
|
402
426
|
},
|
|
427
|
+
"./providers/openrouter/videos": {
|
|
428
|
+
"types": "./dist/providers/openrouter/videos.d.ts",
|
|
429
|
+
"import": "./dist/providers/openrouter/videos.js"
|
|
430
|
+
},
|
|
403
431
|
"./providers/openrouter/responses": {
|
|
404
432
|
"types": "./dist/providers/openrouter/responses.d.ts",
|
|
405
433
|
"import": "./dist/providers/openrouter/responses.js"
|
|
406
434
|
},
|
|
407
|
-
"./providers/runway": {
|
|
408
|
-
"types": "./dist/providers/runway.d.ts",
|
|
409
|
-
"import": "./dist/providers/runway.js"
|
|
410
|
-
},
|
|
411
435
|
"./providers/togetherai": {
|
|
412
436
|
"types": "./dist/providers/togetherai.d.ts",
|
|
413
437
|
"import": "./dist/providers/togetherai.js"
|
|
@@ -428,6 +452,14 @@
|
|
|
428
452
|
"types": "./dist/providers/venice/responses.d.ts",
|
|
429
453
|
"import": "./dist/providers/venice/responses.js"
|
|
430
454
|
},
|
|
455
|
+
"./providers/volcengine": {
|
|
456
|
+
"types": "./dist/providers/volcengine.d.ts",
|
|
457
|
+
"import": "./dist/providers/volcengine.js"
|
|
458
|
+
},
|
|
459
|
+
"./providers/volcengine/videos": {
|
|
460
|
+
"types": "./dist/providers/volcengine/videos.d.ts",
|
|
461
|
+
"import": "./dist/providers/volcengine/videos.js"
|
|
462
|
+
},
|
|
431
463
|
"./providers/vercel-ai-gateway": {
|
|
432
464
|
"types": "./dist/providers/vercel-ai-gateway.d.ts",
|
|
433
465
|
"import": "./dist/providers/vercel-ai-gateway.js"
|
|
@@ -464,6 +496,10 @@
|
|
|
464
496
|
"types": "./dist/providers/xai/images.d.ts",
|
|
465
497
|
"import": "./dist/providers/xai/images.js"
|
|
466
498
|
},
|
|
499
|
+
"./providers/xai/videos": {
|
|
500
|
+
"types": "./dist/providers/xai/videos.d.ts",
|
|
501
|
+
"import": "./dist/providers/xai/videos.js"
|
|
502
|
+
},
|
|
467
503
|
"./providers/zai": {
|
|
468
504
|
"types": "./dist/providers/zai.d.ts",
|
|
469
505
|
"import": "./dist/providers/zai.js"
|
|
@@ -512,10 +548,18 @@
|
|
|
512
548
|
"types": "./dist/protocols/deepgram-transcription.d.ts",
|
|
513
549
|
"import": "./dist/protocols/deepgram-transcription.js"
|
|
514
550
|
},
|
|
551
|
+
"./protocols/google-decisions": {
|
|
552
|
+
"types": "./dist/protocols/google-decisions.d.ts",
|
|
553
|
+
"import": "./dist/protocols/google-decisions.js"
|
|
554
|
+
},
|
|
515
555
|
"./protocols/google-images": {
|
|
516
556
|
"types": "./dist/protocols/google-images.d.ts",
|
|
517
557
|
"import": "./dist/protocols/google-images.js"
|
|
518
558
|
},
|
|
559
|
+
"./protocols/google-interactions-video": {
|
|
560
|
+
"types": "./dist/protocols/google-interactions-video.d.ts",
|
|
561
|
+
"import": "./dist/protocols/google-interactions-video.js"
|
|
562
|
+
},
|
|
519
563
|
"./protocols/google-speech": {
|
|
520
564
|
"types": "./dist/protocols/google-speech.d.ts",
|
|
521
565
|
"import": "./dist/protocols/google-speech.js"
|
|
@@ -540,6 +584,10 @@
|
|
|
540
584
|
"types": "./dist/protocols/openai-images.d.ts",
|
|
541
585
|
"import": "./dist/protocols/openai-images.js"
|
|
542
586
|
},
|
|
587
|
+
"./protocols/openrouter-video": {
|
|
588
|
+
"types": "./dist/protocols/openrouter-video.d.ts",
|
|
589
|
+
"import": "./dist/protocols/openrouter-video.js"
|
|
590
|
+
},
|
|
543
591
|
"./protocols/openai-responses": {
|
|
544
592
|
"types": "./dist/protocols/openai-responses.d.ts",
|
|
545
593
|
"import": "./dist/protocols/openai-responses.js"
|
|
@@ -552,6 +600,10 @@
|
|
|
552
600
|
"types": "./dist/protocols/openai-transcription.d.ts",
|
|
553
601
|
"import": "./dist/protocols/openai-transcription.js"
|
|
554
602
|
},
|
|
603
|
+
"./protocols/seedance-video": {
|
|
604
|
+
"types": "./dist/protocols/seedance-video.d.ts",
|
|
605
|
+
"import": "./dist/protocols/seedance-video.js"
|
|
606
|
+
},
|
|
555
607
|
"./protocols/system-one": {
|
|
556
608
|
"types": "./dist/protocols/system-one.d.ts",
|
|
557
609
|
"import": "./dist/protocols/system-one.js"
|
|
@@ -572,7 +624,7 @@
|
|
|
572
624
|
"devDependencies": {
|
|
573
625
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
574
626
|
"@effect/platform-node": "4.1.0",
|
|
575
|
-
"@opencode/http-recorder": "2.
|
|
627
|
+
"@opencode/http-recorder": "2.3.1",
|
|
576
628
|
"@tsconfig/bun": "1.0.9",
|
|
577
629
|
"@types/bun": "1.4.3",
|
|
578
630
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -582,7 +634,7 @@
|
|
|
582
634
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
583
635
|
"@smithy/eventstream-codec": "4.2.14",
|
|
584
636
|
"@smithy/util-utf8": "4.2.2",
|
|
585
|
-
"@opencode/schema": "2.
|
|
637
|
+
"@opencode/schema": "2.3.1",
|
|
586
638
|
"aws4fetch": "1.0.20",
|
|
587
639
|
"effect": "4.1.0",
|
|
588
640
|
"google-auth-library": "10.5.0"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
3
|
-
import { MediaRoute } from "../route/media.js";
|
|
4
|
-
import { type OpenString } from "../schema/index.js";
|
|
5
|
-
import { VideoModel, VideoResponse, type VideoRequest } from "../video.js";
|
|
6
|
-
export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
7
|
-
/** Provider-native `parameters`. Common fields (`aspect`, `resolution`, `durationSeconds`, `seed`) live on the request. */
|
|
8
|
-
export type GoogleVideoOptions = {
|
|
9
|
-
readonly personGeneration?: OpenString<"allow_all" | "allow_adult" | "dont_allow">;
|
|
10
|
-
} & Record<string, unknown>;
|
|
11
|
-
export type Request = VideoRequest<VideoModel<GoogleVideoOptions>>;
|
|
12
|
-
/** The long-running operation name, e.g. `models/veo-3.1-generate-preview/operations/abc123`. */
|
|
13
|
-
export declare const Token: Schema.Struct<{
|
|
14
|
-
readonly operation: Schema.String;
|
|
15
|
-
}>;
|
|
16
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
17
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
18
|
-
readonly operation: string;
|
|
19
|
-
}>;
|
|
20
|
-
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<GoogleVideoOptions>;
|
|
21
|
-
export declare const GoogleVideo: {
|
|
22
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
23
|
-
readonly operation: string;
|
|
24
|
-
}>;
|
|
25
|
-
readonly model: typeof model;
|
|
26
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Duration, Effect, Schema } from "effect";
|
|
2
|
-
import { Media } from "../media.js";
|
|
3
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
|
-
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
-
import { VideoModel, VideoResponse } from "../video.js";
|
|
7
|
-
import { ProviderShared, optionalArray } from "./shared.js";
|
|
8
|
-
const route = MediaProtocol.identity({ id: "google-video", name: "Google Veo", provider: "google" });
|
|
9
|
-
export const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
10
|
-
/** Veo keeps generated files for two days; the asset carries that deadline so callers materialize in time. */
|
|
11
|
-
const FILE_RETENTION = Duration.days(2);
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// 2. Token and response schemas
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
/** The long-running operation name, e.g. `models/veo-3.1-generate-preview/operations/abc123`. */
|
|
16
|
-
export const Token = Schema.Struct({ operation: Schema.String });
|
|
17
|
-
const StartResponse = Schema.Struct({ name: Schema.String });
|
|
18
|
-
const Operation = Schema.Struct({
|
|
19
|
-
done: Schema.optional(Schema.Boolean),
|
|
20
|
-
error: Schema.optional(Schema.Struct({ code: Schema.optional(Schema.Number), message: Schema.optional(Schema.String) })),
|
|
21
|
-
response: Schema.optional(Schema.Struct({
|
|
22
|
-
generateVideoResponse: Schema.optional(Schema.Struct({
|
|
23
|
-
generatedSamples: optionalArray(Schema.Struct({
|
|
24
|
-
video: Schema.optional(Schema.Struct({
|
|
25
|
-
uri: Schema.optional(Schema.String),
|
|
26
|
-
mimeType: Schema.optional(Schema.String),
|
|
27
|
-
})),
|
|
28
|
-
})),
|
|
29
|
-
raiMediaFilteredCount: Schema.optional(Schema.Number),
|
|
30
|
-
raiMediaFilteredReasons: optionalArray(Schema.String),
|
|
31
|
-
})),
|
|
32
|
-
})),
|
|
33
|
-
metadata: Schema.optional(Schema.Unknown),
|
|
34
|
-
});
|
|
35
|
-
// Operation errors are `google.rpc.Status`; unlisted codes (INTERNAL, UNAVAILABLE, ...) are provider-side.
|
|
36
|
-
const FAILURE = {
|
|
37
|
-
3: "InvalidRequest", // INVALID_ARGUMENT
|
|
38
|
-
7: "Authentication", // PERMISSION_DENIED
|
|
39
|
-
8: "RateLimit", // RESOURCE_EXHAUSTED
|
|
40
|
-
9: "InvalidRequest", // FAILED_PRECONDITION
|
|
41
|
-
11: "InvalidRequest", // OUT_OF_RANGE
|
|
42
|
-
16: "Authentication", // UNAUTHENTICATED
|
|
43
|
-
};
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
// 5. Request body construction
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Veo takes inline media only; a prior Veo output is `Media.url` with transient auth, so materialize it first.
|
|
48
|
-
const inlineMedia = (asset) => ProviderShared.requireInlineMedia(route.name, asset).pipe(Effect.map((inline) => ({ inlineData: { mimeType: inline.mime, data: inline.base64 } })));
|
|
49
|
-
const fromRequest = Effect.fn("GoogleVideo.fromRequest")(function* (request) {
|
|
50
|
-
if (request.n !== undefined && request.n > 1)
|
|
51
|
-
return yield* route.unsupported("video.n", `${route.name} generates one video per request; call it once per video instead of n=${request.n}`);
|
|
52
|
-
if (request.audio === false)
|
|
53
|
-
return yield* route.unsupported("video.audio", `${route.name} always generates audio; audio: false cannot be honored`);
|
|
54
|
-
if (request.frames?.last !== undefined && request.frames.first === undefined)
|
|
55
|
-
return yield* ProviderShared.invalidRequest(`${route.name} requires frames.first when frames.last is set`);
|
|
56
|
-
const image = request.frames?.first === undefined ? undefined : yield* inlineMedia(request.frames.first);
|
|
57
|
-
const lastFrame = request.frames?.last === undefined ? undefined : yield* inlineMedia(request.frames.last);
|
|
58
|
-
const video = request.video === undefined ? undefined : yield* inlineMedia(request.video);
|
|
59
|
-
const referenceImages = yield* Effect.forEach(request.references ?? [], (asset) => inlineMedia(asset).pipe(Effect.map((image) => ({ image, referenceType: "asset" }))));
|
|
60
|
-
return MediaProtocol.json(mergeJsonRecords({
|
|
61
|
-
instances: [
|
|
62
|
-
{
|
|
63
|
-
prompt: request.prompt,
|
|
64
|
-
image,
|
|
65
|
-
lastFrame,
|
|
66
|
-
referenceImages: referenceImages.length === 0 ? undefined : referenceImages,
|
|
67
|
-
video,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
parameters: mergeJsonRecords({
|
|
71
|
-
aspectRatio: request.aspect,
|
|
72
|
-
resolution: request.resolution,
|
|
73
|
-
durationSeconds: request.durationSeconds,
|
|
74
|
-
negativePrompt: request.negativePrompt,
|
|
75
|
-
seed: request.seed,
|
|
76
|
-
}, request.providerOptions),
|
|
77
|
-
}, request.http?.body) ?? {});
|
|
78
|
-
});
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// 6. Response decoding
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
83
|
-
token: { operation: value.name },
|
|
84
|
-
snapshot: { id: value.name, status: "running" },
|
|
85
|
-
}));
|
|
86
|
-
// Operations carry no status string: not done is running, done with `error` failed, otherwise completed.
|
|
87
|
-
const statusOf = (operation) => {
|
|
88
|
-
if (operation.done !== true)
|
|
89
|
-
return "running";
|
|
90
|
-
return operation.error === undefined ? "completed" : "failed";
|
|
91
|
-
};
|
|
92
|
-
const decodeOperation = route.decodeJson(Operation);
|
|
93
|
-
const decodeStatus = Effect.fn("GoogleVideo.decodeStatus")(function* (response, context) {
|
|
94
|
-
const output = yield* decodeOperation(response);
|
|
95
|
-
return { id: context.token.operation, status: statusOf(output.value) };
|
|
96
|
-
});
|
|
97
|
-
const decodeResult = Effect.fn("GoogleVideo.decodeResult")(function* (response, context) {
|
|
98
|
-
const output = yield* decodeOperation(response);
|
|
99
|
-
const operation = output.value;
|
|
100
|
-
const status = statusOf(operation);
|
|
101
|
-
if (status === "running")
|
|
102
|
-
return yield* output.pending(context.token.operation);
|
|
103
|
-
if (status === "failed")
|
|
104
|
-
return yield* output.ended("failed", `${route.name} operation failed${operation.error?.message === undefined ? "" : `: ${operation.error.message}`}`, MediaProtocol.failure(FAILURE, operation.error?.code));
|
|
105
|
-
const generated = operation.response?.generateVideoResponse;
|
|
106
|
-
// Downloads require the same API key as the poll; the asset carries it transiently and follows the redirect.
|
|
107
|
-
const videos = yield* Effect.forEach((generated?.generatedSamples ?? []).flatMap((sample) => sample.video?.uri === undefined ? [] : [{ uri: sample.video.uri, mimeType: sample.video.mimeType }]), (video) => MediaProtocol.expiringUrl(video.uri, FILE_RETENTION, {
|
|
108
|
-
mediaType: video.mimeType ?? "video/mp4",
|
|
109
|
-
headers: context.auth,
|
|
110
|
-
}));
|
|
111
|
-
const reasons = generated?.raiMediaFilteredReasons ?? [];
|
|
112
|
-
if (videos.length === 0 && (reasons.length > 0 || (generated?.raiMediaFilteredCount ?? 0) > 0))
|
|
113
|
-
return yield* output.contentPolicy(`${route.name} filtered every video${reasons.length === 0 ? "" : `: ${reasons.join("; ")}`}`);
|
|
114
|
-
if (videos.length === 0)
|
|
115
|
-
return yield* output.invalid(`${route.name} operation completed without any video`);
|
|
116
|
-
return new VideoResponse({
|
|
117
|
-
videos,
|
|
118
|
-
providerMetadata: {
|
|
119
|
-
google: {
|
|
120
|
-
operation: context.token.operation,
|
|
121
|
-
raiMediaFilteredCount: generated?.raiMediaFilteredCount,
|
|
122
|
-
raiMediaFilteredReasons: generated?.raiMediaFilteredReasons,
|
|
123
|
-
metadata: operation.metadata,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
// 7. Protocol and route
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
const operationPath = (token) => `/${token.operation}`;
|
|
132
|
-
export const protocol = MediaProtocol.queued(route, {
|
|
133
|
-
token: Token,
|
|
134
|
-
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
135
|
-
status: { path: operationPath, decode: decodeStatus },
|
|
136
|
-
result: { path: operationPath, decode: decodeResult },
|
|
137
|
-
});
|
|
138
|
-
export const model = (input) => VideoModel.fromRoute({
|
|
139
|
-
protocol,
|
|
140
|
-
baseURL: DEFAULT_BASE_URL,
|
|
141
|
-
path: ({ request }) => `/models/${request.model.id}:predictLongRunning`,
|
|
142
|
-
}, input);
|
|
143
|
-
export const GoogleVideo = {
|
|
144
|
-
protocol,
|
|
145
|
-
model,
|
|
146
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
3
|
-
import { MediaRoute } from "../route/media.js";
|
|
4
|
-
import { type OpenString } from "../schema/index.js";
|
|
5
|
-
import { VideoModel, VideoResponse, type VideoRequest } from "../video.js";
|
|
6
|
-
export declare const DEFAULT_BASE_URL = "https://api.dev.runwayml.com/v1";
|
|
7
|
-
/** Every Runway request must pin the API version. */
|
|
8
|
-
export declare const API_VERSION = "2024-11-06";
|
|
9
|
-
export declare const TEXT_TO_VIDEO_PATH = "/text_to_video";
|
|
10
|
-
export declare const IMAGE_TO_VIDEO_PATH = "/image_to_video";
|
|
11
|
-
export declare const VIDEO_TO_VIDEO_PATH = "/video_to_video";
|
|
12
|
-
export declare const TASKS_PATH = "/tasks";
|
|
13
|
-
/**
|
|
14
|
-
* Provider-native options. Common fields lower to Runway's names: `aspect` → `ratio` (Runway expects pixel
|
|
15
|
-
* ratios such as `1280:720` for most models), `durationSeconds` → `duration`, `audio`, `negativePrompt`,
|
|
16
|
-
* `resolution`, `references`, and `frames` → `promptImage`.
|
|
17
|
-
*/
|
|
18
|
-
export type RunwayVideoOptions = {
|
|
19
|
-
readonly contentModeration?: {
|
|
20
|
-
readonly publicFigureThreshold?: OpenString<"auto" | "low">;
|
|
21
|
-
};
|
|
22
|
-
readonly outputFormat?: OpenString<"mp4" | "prores" | "png_sequence">;
|
|
23
|
-
} & Record<string, unknown>;
|
|
24
|
-
export type Request = VideoRequest<VideoModel<RunwayVideoOptions>>;
|
|
25
|
-
export declare const Token: Schema.Struct<{
|
|
26
|
-
readonly taskID: Schema.String;
|
|
27
|
-
}>;
|
|
28
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
29
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
30
|
-
readonly taskID: string;
|
|
31
|
-
}>;
|
|
32
|
-
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<RunwayVideoOptions>;
|
|
33
|
-
export declare const RunwayVideo: {
|
|
34
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
35
|
-
readonly taskID: string;
|
|
36
|
-
}>;
|
|
37
|
-
readonly model: typeof model;
|
|
38
|
-
};
|