@opencode/ai 0.0.0-dev-20035 → 0.0.0-dev-20038

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.
Files changed (53) hide show
  1. package/README.md +80 -0
  2. package/dist/generation.d.ts +23 -13
  3. package/dist/generation.js +42 -24
  4. package/dist/image-client.js +1 -1
  5. package/dist/image.d.ts +7 -36
  6. package/dist/image.js +8 -38
  7. package/dist/index.d.ts +5 -1
  8. package/dist/index.js +3 -0
  9. package/dist/media-model.d.ts +42 -0
  10. package/dist/media-model.js +39 -0
  11. package/dist/media.d.ts +10 -9
  12. package/dist/media.js +9 -10
  13. package/dist/promise.d.ts +126 -3
  14. package/dist/promise.js +18 -1
  15. package/dist/protocols/fal-video.d.ts +39 -0
  16. package/dist/protocols/fal-video.js +139 -0
  17. package/dist/protocols/google-video.d.ts +26 -0
  18. package/dist/protocols/google-video.js +158 -0
  19. package/dist/protocols/meta-images.js +2 -9
  20. package/dist/protocols/openai-images.js +1 -12
  21. package/dist/protocols/runway-video.d.ts +38 -0
  22. package/dist/protocols/runway-video.js +146 -0
  23. package/dist/protocols/shared.d.ts +10 -0
  24. package/dist/protocols/shared.js +17 -0
  25. package/dist/protocols/xai-images.js +1 -12
  26. package/dist/protocols/xai-video.d.ts +34 -0
  27. package/dist/protocols/xai-video.js +147 -0
  28. package/dist/protocols/zai-chat.d.ts +1 -1
  29. package/dist/providers/fal.d.ts +24 -0
  30. package/dist/providers/fal.js +29 -0
  31. package/dist/providers/google.d.ts +5 -0
  32. package/dist/providers/google.js +5 -2
  33. package/dist/providers/index.d.ts +2 -0
  34. package/dist/providers/index.js +2 -0
  35. package/dist/providers/runway.d.ts +24 -0
  36. package/dist/providers/runway.js +22 -0
  37. package/dist/providers/xai.d.ts +5 -0
  38. package/dist/providers/xai.js +5 -2
  39. package/dist/providers/zai-coding-plan.d.ts +1 -1
  40. package/dist/providers/zai.d.ts +1 -1
  41. package/dist/route/auth.d.ts +4 -1
  42. package/dist/route/auth.js +6 -0
  43. package/dist/route/media-protocol.d.ts +68 -2
  44. package/dist/route/media-protocol.js +32 -3
  45. package/dist/route/media.d.ts +28 -5
  46. package/dist/route/media.js +95 -14
  47. package/dist/schema/events.d.ts +0 -6
  48. package/dist/schema/messages.d.ts +0 -3
  49. package/dist/video-client.d.ts +28 -0
  50. package/dist/video-client.js +43 -0
  51. package/dist/video.d.ts +1373 -0
  52. package/dist/video.js +131 -0
  53. package/package.json +3 -3
package/dist/video.js ADDED
@@ -0,0 +1,131 @@
1
+ import { Effect, Schema, Stream } from "effect";
2
+ import { Generation } from "./generation.js";
3
+ import { Media } from "./media.js";
4
+ import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
+ import { MediaRoute } from "./route/media.js";
6
+ import { AIError, HttpOptions, MediaUsage, ProviderMetadata } from "./schema/index.js";
7
+ import { VideoClient, Service } from "./video-client.js";
8
+ export class VideoModel extends MediaModel {
9
+ static make(input) {
10
+ return new VideoModel(input);
11
+ }
12
+ /** Compose a queued video protocol with its canonical start path into a model for one deployment. */
13
+ static fromRoute(route, input) {
14
+ return new VideoModel({
15
+ id: input.id,
16
+ provider: route.provider,
17
+ http: input.http,
18
+ route: composeRoute(MediaRoute.queued, route, input),
19
+ });
20
+ }
21
+ }
22
+ export const VideoModelSchema = Schema.declare((value) => value instanceof VideoModel, {
23
+ expected: "Video.Model",
24
+ });
25
+ export const VideoAspectRatio = Media.AspectRatio;
26
+ /** Pinned frames. Routes that accept only a first frame fail typed when `last` is present. */
27
+ export const VideoFrames = Schema.Struct({
28
+ first: Schema.optional(Media.AssetSchema),
29
+ last: Schema.optional(Media.AssetSchema),
30
+ }).annotate({ identifier: "Video.Frames" });
31
+ export class VideoRequest extends Schema.Class("Video.Request")({
32
+ model: VideoModelSchema,
33
+ prompt: Schema.String,
34
+ frames: Schema.optional(VideoFrames),
35
+ /** Style or subject references that guide the output without pinning a frame. */
36
+ references: Schema.optional(Schema.Array(Media.AssetSchema)),
37
+ /** Source video for edit or extension routes. */
38
+ video: Schema.optional(Media.AssetSchema),
39
+ durationSeconds: Schema.optional(Schema.Number),
40
+ aspectRatio: Schema.optional(VideoAspectRatio),
41
+ resolution: Schema.optional(Schema.String),
42
+ /** Whether to generate an audio track; routes whose audio is always on fail typed on `false`. */
43
+ audio: Schema.optional(Schema.Boolean),
44
+ n: Schema.optional(Schema.Int),
45
+ seed: Schema.optional(Schema.Number),
46
+ negativePrompt: Schema.optional(Schema.String),
47
+ providerOptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
48
+ http: Schema.optional(HttpOptions),
49
+ }) {
50
+ }
51
+ // ---------------------------------------------------------------------------
52
+ // Response and events
53
+ // ---------------------------------------------------------------------------
54
+ export class VideoResponse extends Schema.Class("Video.Response")({
55
+ videos: Schema.Array(Media.AssetSchema),
56
+ usage: Schema.optional(MediaUsage),
57
+ notices: Schema.optional(Schema.Array(Media.Notice)),
58
+ providerMetadata: Schema.optional(ProviderMetadata),
59
+ }) {
60
+ get video() {
61
+ return this.videos[0];
62
+ }
63
+ }
64
+ export const VideoQueuedEvent = Schema.Struct({
65
+ type: Schema.tag("generation-queued"),
66
+ id: Schema.String,
67
+ position: Schema.optional(Schema.Number),
68
+ }).annotate({ identifier: "Video.Event.Queued" });
69
+ export const VideoProgressEvent = Schema.Struct({
70
+ type: Schema.tag("generation-progress"),
71
+ id: Schema.String,
72
+ progress: Schema.optional(Schema.Number),
73
+ }).annotate({ identifier: "Video.Event.Progress" });
74
+ export const VideoOutputEvent = Schema.Struct({
75
+ type: Schema.tag("video"),
76
+ index: Schema.Number,
77
+ video: Media.AssetSchema,
78
+ }).annotate({ identifier: "Video.Event.Video" });
79
+ export const VideoFinishEvent = Schema.Struct({
80
+ type: Schema.tag("finish"),
81
+ usage: Schema.optional(MediaUsage),
82
+ notices: Schema.optional(Schema.Array(Media.Notice)),
83
+ providerMetadata: Schema.optional(ProviderMetadata),
84
+ }).annotate({ identifier: "Video.Event.Finish" });
85
+ const videoEventTagged = Schema.Union([VideoQueuedEvent, VideoProgressEvent, VideoOutputEvent, VideoFinishEvent]).pipe(Schema.toTaggedUnion("type"));
86
+ export const VideoEvent = Object.assign(videoEventTagged, {
87
+ is: {
88
+ generationQueued: videoEventTagged.guards["generation-queued"],
89
+ generationProgress: videoEventTagged.guards["generation-progress"],
90
+ video: videoEventTagged.guards.video,
91
+ finish: videoEventTagged.guards.finish,
92
+ },
93
+ });
94
+ /** A completed response expanded into the streaming event shape. */
95
+ export const responseEvents = (response) => [
96
+ ...response.videos.map((video, index) => VideoOutputEvent.make({ index, video })),
97
+ VideoFinishEvent.make({
98
+ usage: response.usage,
99
+ notices: response.notices,
100
+ providerMetadata: response.providerMetadata,
101
+ }),
102
+ ];
103
+ /** A status observation as a video event; the terminal observation is replaced by the result events, so `none`. */
104
+ export const isObservation = (event) => event.type !== "generation-finished";
105
+ export function request(input) {
106
+ if (input instanceof VideoRequest)
107
+ return input;
108
+ return new VideoRequest({
109
+ ...input,
110
+ http: input.http === undefined ? undefined : HttpOptions.make(input.http),
111
+ });
112
+ }
113
+ const requestEffect = (input) => tryRequest(() => request(input));
114
+ export function start(input) {
115
+ return requestEffect(input).pipe(Effect.flatMap((request) => VideoClient.start(request)));
116
+ }
117
+ export function generate(input, options) {
118
+ return requestEffect(input).pipe(Effect.flatMap((request) => VideoClient.generate(request, options)));
119
+ }
120
+ /** Rebuild a generation handle from a persisted `Generation.token`, refreshing its status once. */
121
+ export const resume = (model, token) => VideoClient.resume(model, token);
122
+ export function stream(input, options) {
123
+ return Stream.unwrap(requestEffect(input).pipe(Effect.map((request) => VideoClient.stream(request, options))));
124
+ }
125
+ export const Video = {
126
+ request,
127
+ start,
128
+ generate,
129
+ resume,
130
+ stream,
131
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-20035",
3
+ "version": "0.0.0-dev-20038",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.112",
37
- "@opencode/http-recorder": "0.0.0-dev-20035",
37
+ "@opencode/http-recorder": "0.0.0-dev-20038",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-20035",
47
+ "@opencode/schema": "0.0.0-dev-20038",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"