@opencode/ai 2.2.6 → 2.3.0
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 +208 -98
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/decision.d.ts +10 -0
- package/dist/decision.js +2 -0
- package/dist/effect.d.ts +14 -7
- package/dist/effect.js +6 -1
- package/dist/embedding-client.d.ts +21 -0
- package/dist/embedding-client.js +30 -0
- package/dist/embedding.d.ts +111 -0
- package/dist/embedding.js +75 -0
- package/dist/experimental.d.ts +0 -4
- package/dist/experimental.js +0 -3
- package/dist/image-client.d.ts +1 -1
- package/dist/image-client.js +2 -6
- package/dist/image.d.ts +0 -1
- package/dist/image.js +0 -3
- package/dist/index.d.ts +18 -50
- package/dist/index.js +35 -13
- package/dist/media-model.d.ts +2 -0
- package/dist/media-model.js +3 -1
- package/dist/media.d.ts +9 -3
- package/dist/media.js +27 -7
- package/dist/protocols/alibaba-chat.d.ts +4 -0
- package/dist/protocols/anthropic-messages.js +3 -3
- package/dist/protocols/google-decisions.d.ts +13 -0
- package/dist/protocols/google-decisions.js +133 -0
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-interactions-video.d.ts +43 -0
- package/dist/protocols/google-interactions-video.js +186 -0
- package/dist/protocols/google-interactions.d.ts +14 -1
- package/dist/protocols/google-interactions.js +1 -1
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/index.d.ts +4 -0
- package/dist/protocols/index.js +4 -0
- package/dist/protocols/minimax-video.d.ts +54 -0
- package/dist/protocols/minimax-video.js +292 -0
- package/dist/protocols/open-responses.d.ts +1 -1
- package/dist/protocols/open-responses.js +31 -8
- package/dist/protocols/openai-chat.d.ts +24 -0
- package/dist/protocols/openai-chat.js +37 -11
- package/dist/protocols/openai-compatible-chat.d.ts +1 -0
- package/dist/protocols/openai-decisions.js +14 -1
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/openrouter-video.d.ts +41 -0
- package/dist/protocols/openrouter-video.js +138 -0
- package/dist/protocols/seedance-video.d.ts +50 -0
- package/dist/protocols/seedance-video.js +216 -0
- package/dist/protocols/shared.d.ts +13 -3
- package/dist/protocols/shared.js +27 -4
- package/dist/protocols/system-one.d.ts +45 -1
- package/dist/protocols/system-one.js +50 -8
- package/dist/protocols/utils/responses-compaction.js +1 -1
- package/dist/protocols/venice-chat.d.ts +4 -0
- package/dist/protocols/xai-video.d.ts +8 -2
- package/dist/protocols/xai-video.js +20 -15
- package/dist/protocols/zai-chat.d.ts +4 -0
- package/dist/provider-error.js +7 -1
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba.d.ts +3 -0
- package/dist/providers/alibaba.js +14 -1
- package/dist/providers/amazon-bedrock-mantle.d.ts +1 -0
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure.d.ts +3 -0
- package/dist/providers/azure.js +15 -0
- package/dist/providers/baseten.d.ts +2 -0
- 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/cerebras.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -0
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +8 -0
- package/dist/providers/cohere.js +17 -1
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +6 -1
- package/dist/providers/deepinfra.js +15 -1
- package/dist/providers/deepseek.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean.d.ts +10 -0
- package/dist/providers/digitalocean.js +15 -0
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +6 -1
- package/dist/providers/fireworks.js +15 -1
- package/dist/providers/google/decisions.d.ts +2 -0
- package/dist/providers/google/decisions.js +1 -0
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.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/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -0
- package/dist/providers/google-vertex.d.ts +7 -0
- package/dist/providers/google-vertex.js +52 -0
- package/dist/providers/google.d.ts +17 -4
- package/dist/providers/google.js +27 -3
- package/dist/providers/groq.d.ts +5 -0
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.js +2 -1
- package/dist/providers/meta.d.ts +1 -0
- package/dist/providers/minimax/videos.d.ts +3 -0
- package/dist/providers/minimax/videos.js +1 -0
- package/dist/providers/minimax.d.ts +7 -1
- package/dist/providers/minimax.js +10 -1
- package/dist/providers/moonshot.d.ts +1 -0
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai-compatible/decisions.d.ts +2 -0
- package/dist/providers/openai-compatible/decisions.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible.d.ts +6 -0
- package/dist/providers/openai-compatible.js +27 -0
- package/dist/providers/openai.d.ts +7 -0
- package/dist/providers/openai.js +14 -0
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter/videos.d.ts +2 -0
- package/dist/providers/openrouter/videos.js +1 -0
- package/dist/providers/openrouter.d.ts +21 -0
- package/dist/providers/openrouter.js +23 -0
- package/dist/providers/togetherai.d.ts +2 -0
- package/dist/providers/venice.d.ts +1 -0
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +4 -0
- package/dist/providers/vercel-ai-gateway.js +15 -1
- 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.d.ts +1 -0
- package/dist/providers/zai-coding-plan.d.ts +1 -0
- package/dist/providers/zai.d.ts +1 -0
- package/dist/public.d.ts +4 -0
- package/dist/public.js +2 -0
- package/dist/route/embedding.d.ts +61 -0
- package/dist/route/embedding.js +88 -0
- package/dist/route/executor-service.d.ts +6 -0
- package/dist/route/executor-service.js +7 -0
- package/dist/route/executor.d.ts +7 -1
- package/dist/route/executor.js +7 -2
- package/dist/route/media-protocol.d.ts +12 -11
- package/dist/route/media.d.ts +2 -0
- package/dist/route/media.js +31 -22
- package/dist/route/transport/http.js +1 -1
- package/dist/schema/messages.d.ts +1 -1
- package/dist/schema/messages.js +1 -5
- package/dist/schema/options.d.ts +8 -0
- package/dist/schema/options.js +1 -0
- package/dist/speech-client.d.ts +1 -1
- package/dist/speech-client.js +4 -4
- package/dist/transcription-client.d.ts +1 -1
- package/dist/transcription-client.js +1 -2
- package/dist/video-client.d.ts +16 -84
- package/dist/video-client.js +28 -13
- package/dist/video.d.ts +56 -1072
- package/dist/video.js +28 -65
- package/package.json +355 -255
- 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,7 +1,6 @@
|
|
|
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";
|
|
@@ -12,40 +11,33 @@ export class VideoModel extends MediaModel {
|
|
|
12
11
|
provider: route.protocol.provider,
|
|
13
12
|
http: input.http,
|
|
14
13
|
providerOptions: input.providerOptions,
|
|
15
|
-
route:
|
|
14
|
+
route: composeQueuedRoute(route, input),
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
export const VideoModelSchema = Schema.declare((value) => value instanceof VideoModel, {
|
|
20
19
|
expected: "Video.Model",
|
|
21
20
|
});
|
|
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" });
|
|
21
|
+
export const VideoAspectRatio = Schema.Union([Media.AspectRatio, Schema.Literal("auto")]);
|
|
22
|
+
export const VideoDuration = Schema.declare((value) => typeof value === "string" && /^\d+(?:\.\d+)? seconds?$/.test(value), { title: "Video.Duration" });
|
|
28
23
|
const VideoRequestSchema = Schema.Struct({
|
|
29
24
|
model: VideoModelSchema,
|
|
30
25
|
prompt: Schema.String,
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
/** Image the video starts on exactly. */
|
|
27
|
+
start: Schema.optional(Media.AssetSchema),
|
|
28
|
+
/** Image the video ends on exactly. */
|
|
29
|
+
end: Schema.optional(Media.AssetSchema),
|
|
30
|
+
/** Images, videos or audio that guide the subject or style without pinning a frame. */
|
|
33
31
|
references: Schema.optional(Schema.Array(Media.AssetSchema)),
|
|
34
|
-
|
|
35
|
-
video: Schema.optional(Media.AssetSchema),
|
|
36
|
-
durationSeconds: Schema.optional(Schema.Number),
|
|
32
|
+
duration: Schema.optional(VideoDuration),
|
|
37
33
|
aspect: Schema.optional(VideoAspectRatio),
|
|
38
34
|
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),
|
|
35
|
+
/** Whether the video has a generated soundtrack; unset leaves the model's default. */
|
|
36
|
+
sound: Schema.optional(Schema.Boolean),
|
|
44
37
|
providerOptions: Schema.optional(ProviderOptions),
|
|
45
38
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
39
|
+
/** Seconds in a request's `duration`, for protocols that send a number. */
|
|
40
|
+
export const seconds = (duration) => Duration.toSeconds(Duration.fromInputUnsafe(duration));
|
|
49
41
|
export class VideoResponse extends Schema.Class("Video.Response")({
|
|
50
42
|
videos: Schema.Array(Media.AssetSchema),
|
|
51
43
|
usage: Schema.optional(MediaUsage),
|
|
@@ -55,42 +47,15 @@ export class VideoResponse extends Schema.Class("Video.Response")({
|
|
|
55
47
|
return this.videos[0];
|
|
56
48
|
}
|
|
57
49
|
}
|
|
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
50
|
// ---------------------------------------------------------------------------
|
|
89
|
-
//
|
|
51
|
+
// Call API
|
|
90
52
|
// ---------------------------------------------------------------------------
|
|
91
53
|
/** Normalize video request input into a plain `VideoRequest`. */
|
|
92
54
|
export const request = (input) => ({
|
|
93
55
|
...input,
|
|
56
|
+
start: input.start === undefined ? undefined : Media.make(input.start),
|
|
57
|
+
end: input.end === undefined ? undefined : Media.make(input.end),
|
|
58
|
+
references: input.references?.map((reference) => Media.make(reference)),
|
|
94
59
|
});
|
|
95
60
|
const validate = Schema.decodeUnknownSync(VideoRequestSchema);
|
|
96
61
|
const requestEffect = (input) => tryRequest(() => {
|
|
@@ -101,18 +66,16 @@ const requestEffect = (input) => tryRequest(() => {
|
|
|
101
66
|
export function start(input) {
|
|
102
67
|
return requestEffect(input).pipe(Effect.flatMap((request) => VideoClient.start(request)));
|
|
103
68
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export
|
|
110
|
-
return Stream.unwrap(requestEffect(input).pipe(Effect.map((request) => VideoClient.stream(request, options))));
|
|
111
|
-
}
|
|
69
|
+
/** One status read for a stored token. */
|
|
70
|
+
export const status = (model, token) => VideoClient.status(model, token);
|
|
71
|
+
/** The finished videos; fails while the job is still running, or with the provider's reason when it failed. */
|
|
72
|
+
export const result = (model, token) => VideoClient.result(model, token);
|
|
73
|
+
/** Ask the provider to stop the job; fails with `UnsupportedOperation` when the provider has no cancel call. */
|
|
74
|
+
export const cancel = (model, token) => VideoClient.cancel(model, token);
|
|
112
75
|
export const Video = {
|
|
113
76
|
request,
|
|
114
77
|
start,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
78
|
+
status,
|
|
79
|
+
result,
|
|
80
|
+
cancel,
|
|
118
81
|
};
|