@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.
- package/README.md +80 -0
- package/dist/generation.d.ts +23 -13
- package/dist/generation.js +42 -24
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +7 -36
- package/dist/image.js +8 -38
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -0
- package/dist/media-model.d.ts +42 -0
- package/dist/media-model.js +39 -0
- package/dist/media.d.ts +10 -9
- package/dist/media.js +9 -10
- package/dist/promise.d.ts +126 -3
- package/dist/promise.js +18 -1
- package/dist/protocols/fal-video.d.ts +39 -0
- package/dist/protocols/fal-video.js +139 -0
- package/dist/protocols/google-video.d.ts +26 -0
- package/dist/protocols/google-video.js +158 -0
- package/dist/protocols/meta-images.js +2 -9
- package/dist/protocols/openai-images.js +1 -12
- package/dist/protocols/runway-video.d.ts +38 -0
- package/dist/protocols/runway-video.js +146 -0
- package/dist/protocols/shared.d.ts +10 -0
- package/dist/protocols/shared.js +17 -0
- package/dist/protocols/xai-images.js +1 -12
- package/dist/protocols/xai-video.d.ts +34 -0
- package/dist/protocols/xai-video.js +147 -0
- package/dist/protocols/zai-chat.d.ts +1 -1
- package/dist/providers/fal.d.ts +24 -0
- package/dist/providers/fal.js +29 -0
- package/dist/providers/google.d.ts +5 -0
- package/dist/providers/google.js +5 -2
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/runway.d.ts +24 -0
- package/dist/providers/runway.js +22 -0
- package/dist/providers/xai.d.ts +5 -0
- package/dist/providers/xai.js +5 -2
- package/dist/providers/zai-coding-plan.d.ts +1 -1
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/auth.d.ts +4 -1
- package/dist/route/auth.js +6 -0
- package/dist/route/media-protocol.d.ts +68 -2
- package/dist/route/media-protocol.js +32 -3
- package/dist/route/media.d.ts +28 -5
- package/dist/route/media.js +95 -14
- package/dist/schema/events.d.ts +0 -6
- package/dist/schema/messages.d.ts +0 -3
- package/dist/video-client.d.ts +28 -0
- package/dist/video-client.js +43 -0
- package/dist/video.d.ts +1373 -0
- package/dist/video.js +131 -0
- package/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
3
|
+
import { isObservation, responseEvents, } from "./video.js";
|
|
4
|
+
export class Service extends Context.Service()("@opencode/VideoClient") {
|
|
5
|
+
}
|
|
6
|
+
export const start = (request) => Effect.gen(function* () {
|
|
7
|
+
const client = yield* Service;
|
|
8
|
+
return yield* client.start(request);
|
|
9
|
+
});
|
|
10
|
+
export const resume = (model, token) => Effect.gen(function* () {
|
|
11
|
+
const client = yield* Service;
|
|
12
|
+
return yield* client.resume(model, token);
|
|
13
|
+
});
|
|
14
|
+
export const generate = (request, options) => Effect.gen(function* () {
|
|
15
|
+
const client = yield* Service;
|
|
16
|
+
return yield* client.generate(request, options);
|
|
17
|
+
});
|
|
18
|
+
export const stream = (request, options) => Stream.unwrap(Effect.gen(function* () {
|
|
19
|
+
const client = yield* Service;
|
|
20
|
+
return client.stream(request, options);
|
|
21
|
+
}));
|
|
22
|
+
/** Status observations until the first terminal one, then the fetched result expanded into events. */
|
|
23
|
+
const events = (generation, options) => generation
|
|
24
|
+
.events(options)
|
|
25
|
+
.pipe(Stream.filter(isObservation), Stream.concat(Stream.fromIterableEffect(Effect.map(generation.result(), responseEvents))));
|
|
26
|
+
export const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
27
|
+
const executor = yield* RequestExecutor.Service;
|
|
28
|
+
const start = (request) => request.model.route.start(request, executor.execute);
|
|
29
|
+
return Service.of({
|
|
30
|
+
start,
|
|
31
|
+
resume: (model, token) => model.route.resume(model, token, executor.execute),
|
|
32
|
+
generate: (request, options) => start(request).pipe(Effect.flatMap((generation) => generation.await(options))),
|
|
33
|
+
stream: (request, options) => Stream.unwrap(start(request).pipe(Effect.map((generation) => events(generation, options)))),
|
|
34
|
+
});
|
|
35
|
+
}));
|
|
36
|
+
export const VideoClient = {
|
|
37
|
+
Service,
|
|
38
|
+
layer,
|
|
39
|
+
start,
|
|
40
|
+
resume,
|
|
41
|
+
generate,
|
|
42
|
+
stream,
|
|
43
|
+
};
|