@opencode/ai 0.0.0-dev-1296 → 0.0.0-dev-1298
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 +4 -3
- package/dist/generation.d.ts +10 -10
- package/dist/generation.js +8 -14
- package/dist/image-client.d.ts +5 -1
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +10 -89
- package/dist/image.js +2 -9
- package/dist/index.d.ts +0 -12
- package/dist/media-client.d.ts +5 -1
- 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-interactions-video.js +3 -3
- package/dist/protocols/google-speech.d.ts +0 -8
- package/dist/protocols/google-transcription.d.ts +0 -8
- package/dist/protocols/minimax-video.js +11 -11
- package/dist/protocols/openai-images.d.ts +0 -8
- package/dist/protocols/openai-speech.d.ts +0 -8
- package/dist/protocols/openai-transcription.d.ts +0 -8
- package/dist/protocols/openrouter-video.js +5 -5
- package/dist/protocols/seedance-video.js +5 -5
- package/dist/protocols/xai-video.js +6 -3
- package/dist/public.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +8 -4
- package/dist/route/media-protocol.js +11 -4
- package/dist/speech-client.d.ts +5 -5
- package/dist/speech.d.ts +7 -88
- package/dist/speech.js +1 -3
- package/dist/transcription-client.d.ts +5 -5
- package/dist/transcription.d.ts +7 -88
- package/dist/transcription.js +1 -3
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +3 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1077,7 +1077,8 @@ const program = Effect.gen(function* () {
|
|
|
1077
1077
|
job.id // the provider's job ID: store it with the provider and model ID
|
|
1078
1078
|
|
|
1079
1079
|
const status = yield* ai.video.status(model, job.id)
|
|
1080
|
-
status.status // "
|
|
1080
|
+
status.status // "running" | "completed" | "error"
|
|
1081
|
+
status.reason // "failed" | "cancelled" | "expired", only when status is "error"
|
|
1081
1082
|
status.progress // 0..1, only when the provider reports it
|
|
1082
1083
|
|
|
1083
1084
|
const response = yield* ai.video.result(model, job.id)
|
|
@@ -1328,8 +1329,8 @@ const program = Effect.gen(function* () {
|
|
|
1328
1329
|
})
|
|
1329
1330
|
```
|
|
1330
1331
|
|
|
1331
|
-
Inline routes emit only `finish` from `stream` (no faked deltas); queued routes emit `generation-
|
|
1332
|
-
|
|
1332
|
+
Inline routes emit only `finish` from `stream` (no faked deltas); queued routes emit `generation-progress`
|
|
1333
|
+
before it.
|
|
1333
1334
|
|
|
1334
1335
|
Provider notes:
|
|
1335
1336
|
|
package/dist/generation.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Duration, Effect, Schema, Stream } from "effect";
|
|
2
2
|
import { AIError } from "./schema/errors.js";
|
|
3
|
-
export declare const Status: Schema.Literals<readonly ["
|
|
3
|
+
export declare const Status: Schema.Literals<readonly ["running", "completed", "error"]>;
|
|
4
4
|
export type Status = Schema.Schema.Type<typeof Status>;
|
|
5
|
+
/** Why a generation ended in `error`. */
|
|
6
|
+
export declare const Reason: Schema.Literals<readonly ["failed", "cancelled", "expired"]>;
|
|
7
|
+
export type Reason = Schema.Schema.Type<typeof Reason>;
|
|
5
8
|
/** Provider-neutral view of one generation observation. */
|
|
6
9
|
export interface Snapshot {
|
|
7
10
|
readonly id: string;
|
|
8
11
|
readonly status: Status;
|
|
12
|
+
/** Set when `status` is `error`. */
|
|
13
|
+
readonly reason?: Reason;
|
|
9
14
|
/** Normalized 0..1 when the provider reports progress. */
|
|
10
15
|
readonly progress?: number;
|
|
11
|
-
readonly position?: number;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
18
|
* Route-owned generation operations for one generation. The media route decodes its serializable token once (from the
|
|
@@ -26,31 +30,27 @@ export interface Poll {
|
|
|
26
30
|
export interface AwaitOptions {
|
|
27
31
|
readonly poll?: Poll;
|
|
28
32
|
}
|
|
29
|
-
export declare const QueuedEvent: Schema.Struct<{
|
|
30
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
31
|
-
readonly id: Schema.String;
|
|
32
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
33
|
-
}>;
|
|
34
33
|
export declare const ProgressEvent: Schema.Struct<{
|
|
35
34
|
readonly type: Schema.tag<"generation-progress">;
|
|
36
35
|
readonly id: Schema.String;
|
|
37
36
|
readonly progress: Schema.optional<Schema.Number>;
|
|
38
37
|
}>;
|
|
39
|
-
export type Observation = Schema.Schema.Type<typeof
|
|
38
|
+
export type Observation = Schema.Schema.Type<typeof ProgressEvent>;
|
|
40
39
|
export type Event = Observation | {
|
|
41
40
|
readonly type: "generation-finished";
|
|
42
41
|
readonly id: string;
|
|
43
42
|
readonly status: Status;
|
|
43
|
+
readonly reason?: Reason;
|
|
44
44
|
};
|
|
45
|
-
export declare const isTerminal: (status: Status) =>
|
|
45
|
+
export declare const isTerminal: (status: Status) => status is "completed" | "error";
|
|
46
46
|
export declare class Generation<Response> {
|
|
47
47
|
readonly route: Route<Response>;
|
|
48
48
|
/** Route-owned serializable JSON; pass it to the modality's `resume` from another process. */
|
|
49
49
|
readonly token: unknown;
|
|
50
50
|
readonly id: string;
|
|
51
51
|
readonly status: Status;
|
|
52
|
+
readonly reason?: Reason;
|
|
52
53
|
readonly progress?: number;
|
|
53
|
-
readonly position?: number;
|
|
54
54
|
constructor(route: Route<Response>,
|
|
55
55
|
/** Route-owned serializable JSON; pass it to the modality's `resume` from another process. */
|
|
56
56
|
token: unknown, snapshot: Snapshot);
|
package/dist/generation.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { Clock, Duration, Effect, Schedule, Schema, Stream } from "effect";
|
|
2
2
|
import { AIError, TimeoutError } from "./schema/errors.js";
|
|
3
|
-
export const Status = Schema.Literals(["
|
|
3
|
+
export const Status = Schema.Literals(["running", "completed", "error"]);
|
|
4
|
+
/** Why a generation ended in `error`. */
|
|
5
|
+
export const Reason = Schema.Literals(["failed", "cancelled", "expired"]);
|
|
4
6
|
const DEFAULT_POLL_INTERVAL = Duration.seconds(5);
|
|
5
7
|
const DEFAULT_POLL_TIMEOUT = Duration.minutes(10);
|
|
6
|
-
export const QueuedEvent = Schema.Struct({
|
|
7
|
-
type: Schema.tag("generation-queued"),
|
|
8
|
-
id: Schema.String,
|
|
9
|
-
position: Schema.optional(Schema.Number),
|
|
10
|
-
}).annotate({ identifier: "Generation.Event.Queued" });
|
|
11
8
|
export const ProgressEvent = Schema.Struct({
|
|
12
9
|
type: Schema.tag("generation-progress"),
|
|
13
10
|
id: Schema.String,
|
|
14
11
|
progress: Schema.optional(Schema.Number),
|
|
15
12
|
}).annotate({ identifier: "Generation.Event.Progress" });
|
|
16
|
-
const
|
|
17
|
-
export const isTerminal = (status) => TERMINAL.has(status);
|
|
13
|
+
export const isTerminal = (status) => status !== "running";
|
|
18
14
|
export class Generation {
|
|
19
15
|
route;
|
|
20
16
|
token;
|
|
21
17
|
id;
|
|
22
18
|
status;
|
|
19
|
+
reason;
|
|
23
20
|
progress;
|
|
24
|
-
position;
|
|
25
21
|
constructor(route,
|
|
26
22
|
/** Route-owned serializable JSON; pass it to the modality's `resume` from another process. */
|
|
27
23
|
token, snapshot) {
|
|
@@ -29,15 +25,15 @@ export class Generation {
|
|
|
29
25
|
this.token = token;
|
|
30
26
|
this.id = snapshot.id;
|
|
31
27
|
this.status = snapshot.status;
|
|
28
|
+
this.reason = snapshot.reason;
|
|
32
29
|
this.progress = snapshot.progress;
|
|
33
|
-
this.position = snapshot.position;
|
|
34
30
|
}
|
|
35
31
|
get snapshot() {
|
|
36
32
|
return {
|
|
37
33
|
id: this.id,
|
|
38
34
|
status: this.status,
|
|
35
|
+
reason: this.reason,
|
|
39
36
|
progress: this.progress,
|
|
40
|
-
position: this.position,
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
39
|
get terminal() {
|
|
@@ -80,9 +76,7 @@ export class Generation {
|
|
|
80
76
|
}
|
|
81
77
|
event() {
|
|
82
78
|
if (this.terminal)
|
|
83
|
-
return { type: "generation-finished", id: this.id, status: this.status };
|
|
84
|
-
if (this.status === "queued")
|
|
85
|
-
return { type: "generation-queued", id: this.id, position: this.position };
|
|
79
|
+
return { type: "generation-finished", id: this.id, status: this.status, reason: this.reason };
|
|
86
80
|
return { type: "generation-progress", id: this.id, progress: this.progress };
|
|
87
81
|
}
|
|
88
82
|
poll(poll) {
|
package/dist/image-client.d.ts
CHANGED
|
@@ -63,6 +63,10 @@ export declare const ImageClient: {
|
|
|
63
63
|
readonly type: "image";
|
|
64
64
|
readonly index: number;
|
|
65
65
|
readonly image: import("./media.js").Asset;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "generation-progress";
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly progress?: number | undefined;
|
|
66
70
|
} | {
|
|
67
71
|
readonly type: "finish";
|
|
68
72
|
readonly usage?: {
|
|
@@ -91,7 +95,7 @@ export declare const ImageClient: {
|
|
|
91
95
|
readonly [x: string]: unknown;
|
|
92
96
|
};
|
|
93
97
|
} | undefined;
|
|
94
|
-
}
|
|
98
|
+
}, AIError, ImageClientService>;
|
|
95
99
|
readonly start: (request: ImageRequest) => Effect.Effect<ImageJob, AIError, ImageClientService>;
|
|
96
100
|
readonly status: (model: ImageModel, id: string) => Effect.Effect<ImageStatus, AIError, ImageClientService>;
|
|
97
101
|
readonly result: (model: ImageModel, id: string) => Effect.Effect<ImageResponse, AIError, ImageClientService>;
|
package/dist/image-client.js
CHANGED
|
@@ -28,7 +28,7 @@ export const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
|
28
28
|
start: (request) => media.start(request).pipe(
|
|
29
29
|
// The token, not the snapshot id, is what `status` and `result` decode; `ImageModel.fromRoute` makes it a string.
|
|
30
30
|
Effect.flatMap((generation) => decodeID(generation.token)), Effect.map((id) => ({ id }))),
|
|
31
|
-
status: (model, id) => attach(model, id, "status").pipe(Effect.flatMap((route) => route.status), Effect.map((snapshot) => ({ status: snapshot.status, progress: snapshot.progress }))),
|
|
31
|
+
status: (model, id) => attach(model, id, "status").pipe(Effect.flatMap((route) => route.status), Effect.map((snapshot) => ({ status: snapshot.status, reason: snapshot.reason, progress: snapshot.progress }))),
|
|
32
32
|
result: (model, id) => attach(model, id, "result").pipe(Effect.flatMap((route) => route.result)),
|
|
33
33
|
cancel: (model, id) => attach(model, id, "cancel").pipe(Effect.flatMap((route) => route.cancel ??
|
|
34
34
|
Effect.fail(new AIError({
|
package/dist/image.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema, Stream } from "effect";
|
|
2
|
-
import { type AwaitOptions, type Status } from "./generation.js";
|
|
2
|
+
import { type AwaitOptions, type Reason, type Status } from "./generation.js";
|
|
3
3
|
import { Media } from "./media.js";
|
|
4
4
|
import { MediaModel } from "./media-model.js";
|
|
5
5
|
import { MediaRoute } from "./route/media.js";
|
|
@@ -49,6 +49,8 @@ export interface ImageJob {
|
|
|
49
49
|
}
|
|
50
50
|
export interface ImageStatus {
|
|
51
51
|
readonly status: Status;
|
|
52
|
+
/** Set when `status` is `error`. */
|
|
53
|
+
readonly reason?: Reason;
|
|
52
54
|
/** 0..1, only when the provider reports progress. */
|
|
53
55
|
readonly progress?: number;
|
|
54
56
|
}
|
|
@@ -202,10 +204,6 @@ export declare const ImageFinishEvent: Schema.Struct<{
|
|
|
202
204
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
203
205
|
}>;
|
|
204
206
|
declare const imageEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
|
|
205
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
206
|
-
readonly id: Schema.String;
|
|
207
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
208
|
-
}>, Schema.Struct<{
|
|
209
207
|
readonly type: Schema.tag<"generation-progress">;
|
|
210
208
|
readonly id: Schema.String;
|
|
211
209
|
readonly progress: Schema.optional<Schema.Number>;
|
|
@@ -301,10 +299,6 @@ declare const imageEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.St
|
|
|
301
299
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
302
300
|
}>]>;
|
|
303
301
|
export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
304
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
305
|
-
readonly id: Schema.String;
|
|
306
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
307
|
-
}>, Schema.Struct<{
|
|
308
302
|
readonly type: Schema.tag<"generation-progress">;
|
|
309
303
|
readonly id: Schema.String;
|
|
310
304
|
readonly progress: Schema.optional<Schema.Number>;
|
|
@@ -400,7 +394,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
400
394
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
401
395
|
}>]> & {
|
|
402
396
|
readonly tag: "type";
|
|
403
|
-
readonly discriminants: readonly ["generation-
|
|
397
|
+
readonly discriminants: readonly ["generation-progress", "image-partial", "image", "finish"];
|
|
404
398
|
readonly cases: {
|
|
405
399
|
finish: Schema.Struct<{
|
|
406
400
|
readonly type: Schema.tag<"finish">;
|
|
@@ -430,11 +424,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
430
424
|
readonly id: Schema.String;
|
|
431
425
|
readonly progress: Schema.optional<Schema.Number>;
|
|
432
426
|
}>;
|
|
433
|
-
"generation-queued": Schema.Struct<{
|
|
434
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
435
|
-
readonly id: Schema.String;
|
|
436
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
437
|
-
}>;
|
|
438
427
|
image: Schema.Struct<{
|
|
439
428
|
readonly type: Schema.tag<"image">;
|
|
440
429
|
readonly index: Schema.Number;
|
|
@@ -514,10 +503,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
514
503
|
readonly type: "image";
|
|
515
504
|
readonly index: number;
|
|
516
505
|
readonly image: Media.Asset;
|
|
517
|
-
} | {
|
|
518
|
-
readonly type: "generation-queued";
|
|
519
|
-
readonly id: string;
|
|
520
|
-
readonly position?: number | undefined;
|
|
521
506
|
} | {
|
|
522
507
|
readonly type: "generation-progress";
|
|
523
508
|
readonly id: string;
|
|
@@ -562,12 +547,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
562
547
|
readonly image: Media.Asset;
|
|
563
548
|
}, {
|
|
564
549
|
readonly type: Keys;
|
|
565
|
-
}> | Extract<{
|
|
566
|
-
readonly type: "generation-queued";
|
|
567
|
-
readonly id: string;
|
|
568
|
-
readonly position?: number | undefined;
|
|
569
|
-
}, {
|
|
570
|
-
readonly type: Keys;
|
|
571
550
|
}> | Extract<{
|
|
572
551
|
readonly type: "generation-progress";
|
|
573
552
|
readonly id: string;
|
|
@@ -640,11 +619,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
640
619
|
readonly id: string;
|
|
641
620
|
readonly progress?: number | undefined;
|
|
642
621
|
};
|
|
643
|
-
"generation-queued": (u: unknown) => u is {
|
|
644
|
-
readonly type: "generation-queued";
|
|
645
|
-
readonly id: string;
|
|
646
|
-
readonly position?: number | undefined;
|
|
647
|
-
};
|
|
648
622
|
image: (u: unknown) => u is {
|
|
649
623
|
readonly type: "image";
|
|
650
624
|
readonly index: number;
|
|
@@ -657,7 +631,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
657
631
|
};
|
|
658
632
|
};
|
|
659
633
|
readonly match: {
|
|
660
|
-
<Handlers extends { [K in "finish" | "generation-progress" | "
|
|
634
|
+
<Handlers extends { [K in "finish" | "generation-progress" | "image" | "image-partial"]: (value: {
|
|
661
635
|
readonly finish: Schema.Struct<{
|
|
662
636
|
readonly type: Schema.tag<"finish">;
|
|
663
637
|
readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -686,11 +660,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
686
660
|
readonly id: Schema.String;
|
|
687
661
|
readonly progress: Schema.optional<Schema.Number>;
|
|
688
662
|
}>;
|
|
689
|
-
readonly "generation-queued": Schema.Struct<{
|
|
690
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
691
|
-
readonly id: Schema.String;
|
|
692
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
693
|
-
}>;
|
|
694
663
|
readonly image: Schema.Struct<{
|
|
695
664
|
readonly type: Schema.tag<"image">;
|
|
696
665
|
readonly index: Schema.Number;
|
|
@@ -769,10 +738,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
769
738
|
readonly type: "image";
|
|
770
739
|
readonly index: number;
|
|
771
740
|
readonly image: Media.Asset;
|
|
772
|
-
} | {
|
|
773
|
-
readonly type: "generation-queued";
|
|
774
|
-
readonly id: string;
|
|
775
|
-
readonly position?: number | undefined;
|
|
776
741
|
} | {
|
|
777
742
|
readonly type: "generation-progress";
|
|
778
743
|
readonly id: string;
|
|
@@ -805,8 +770,8 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
805
770
|
readonly [x: string]: unknown;
|
|
806
771
|
};
|
|
807
772
|
} | undefined;
|
|
808
|
-
}, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "
|
|
809
|
-
<Handlers extends { [K in "finish" | "generation-progress" | "
|
|
773
|
+
}, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "image" | "image-partial"]>>;
|
|
774
|
+
<Handlers extends { [K in "finish" | "generation-progress" | "image" | "image-partial"]: (value: {
|
|
810
775
|
readonly finish: Schema.Struct<{
|
|
811
776
|
readonly type: Schema.tag<"finish">;
|
|
812
777
|
readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -835,11 +800,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
835
800
|
readonly id: Schema.String;
|
|
836
801
|
readonly progress: Schema.optional<Schema.Number>;
|
|
837
802
|
}>;
|
|
838
|
-
readonly "generation-queued": Schema.Struct<{
|
|
839
|
-
readonly type: Schema.tag<"generation-queued">;
|
|
840
|
-
readonly id: Schema.String;
|
|
841
|
-
readonly position: Schema.optional<Schema.Number>;
|
|
842
|
-
}>;
|
|
843
803
|
readonly image: Schema.Struct<{
|
|
844
804
|
readonly type: Schema.tag<"image">;
|
|
845
805
|
readonly index: Schema.Number;
|
|
@@ -918,10 +878,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
918
878
|
readonly type: "image";
|
|
919
879
|
readonly index: number;
|
|
920
880
|
readonly image: Media.Asset;
|
|
921
|
-
} | {
|
|
922
|
-
readonly type: "generation-queued";
|
|
923
|
-
readonly id: string;
|
|
924
|
-
readonly position?: number | undefined;
|
|
925
881
|
} | {
|
|
926
882
|
readonly type: "generation-progress";
|
|
927
883
|
readonly id: string;
|
|
@@ -954,7 +910,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
954
910
|
readonly [x: string]: unknown;
|
|
955
911
|
};
|
|
956
912
|
} | undefined;
|
|
957
|
-
}) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "
|
|
913
|
+
}) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "image" | "image-partial"]>>;
|
|
958
914
|
};
|
|
959
915
|
readonly matchOrElse: {
|
|
960
916
|
<Handlers, OrElse>(value: {
|
|
@@ -965,10 +921,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
965
921
|
readonly type: "image";
|
|
966
922
|
readonly index: number;
|
|
967
923
|
readonly image: Media.Asset;
|
|
968
|
-
} | {
|
|
969
|
-
readonly type: "generation-queued";
|
|
970
|
-
readonly id: string;
|
|
971
|
-
readonly position?: number | undefined;
|
|
972
924
|
} | {
|
|
973
925
|
readonly type: "generation-progress";
|
|
974
926
|
readonly id: string;
|
|
@@ -1036,11 +988,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1036
988
|
readonly id: string;
|
|
1037
989
|
readonly progress?: number | undefined;
|
|
1038
990
|
}) => any) | undefined;
|
|
1039
|
-
readonly "generation-queued"?: ((value: {
|
|
1040
|
-
readonly type: "generation-queued";
|
|
1041
|
-
readonly id: string;
|
|
1042
|
-
readonly position?: number | undefined;
|
|
1043
|
-
}) => any) | undefined;
|
|
1044
991
|
readonly image?: ((value: {
|
|
1045
992
|
readonly type: "image";
|
|
1046
993
|
readonly index: number;
|
|
@@ -1051,7 +998,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1051
998
|
readonly index: number;
|
|
1052
999
|
readonly image: Media.Asset;
|
|
1053
1000
|
}) => any) | undefined;
|
|
1054
|
-
} & (Exclude<keyof Handlers, "finish" | "generation-progress" | "
|
|
1001
|
+
} & (Exclude<keyof Handlers, "finish" | "generation-progress" | "image" | "image-partial"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
|
|
1055
1002
|
readonly type: "image-partial";
|
|
1056
1003
|
readonly index: number;
|
|
1057
1004
|
readonly image: Media.Asset;
|
|
@@ -1063,12 +1010,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1063
1010
|
readonly image: Media.Asset;
|
|
1064
1011
|
}, {
|
|
1065
1012
|
readonly type: keyof Handlers;
|
|
1066
|
-
}> | Exclude<{
|
|
1067
|
-
readonly type: "generation-queued";
|
|
1068
|
-
readonly id: string;
|
|
1069
|
-
readonly position?: number | undefined;
|
|
1070
|
-
}, {
|
|
1071
|
-
readonly type: keyof Handlers;
|
|
1072
1013
|
}> | Exclude<{
|
|
1073
1014
|
readonly type: "generation-progress";
|
|
1074
1015
|
readonly id: string;
|
|
@@ -1141,11 +1082,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1141
1082
|
readonly id: string;
|
|
1142
1083
|
readonly progress?: number | undefined;
|
|
1143
1084
|
}) => any) | undefined;
|
|
1144
|
-
readonly "generation-queued"?: ((value: {
|
|
1145
|
-
readonly type: "generation-queued";
|
|
1146
|
-
readonly id: string;
|
|
1147
|
-
readonly position?: number | undefined;
|
|
1148
|
-
}) => any) | undefined;
|
|
1149
1085
|
readonly image?: ((value: {
|
|
1150
1086
|
readonly type: "image";
|
|
1151
1087
|
readonly index: number;
|
|
@@ -1156,7 +1092,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1156
1092
|
readonly index: number;
|
|
1157
1093
|
readonly image: Media.Asset;
|
|
1158
1094
|
}) => any) | undefined;
|
|
1159
|
-
} & (Exclude<keyof Handlers, "finish" | "generation-progress" | "
|
|
1095
|
+
} & (Exclude<keyof Handlers, "finish" | "generation-progress" | "image" | "image-partial"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
|
|
1160
1096
|
readonly type: "image-partial";
|
|
1161
1097
|
readonly index: number;
|
|
1162
1098
|
readonly image: Media.Asset;
|
|
@@ -1168,12 +1104,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1168
1104
|
readonly image: Media.Asset;
|
|
1169
1105
|
}, {
|
|
1170
1106
|
readonly type: keyof Handlers;
|
|
1171
|
-
}> | Exclude<{
|
|
1172
|
-
readonly type: "generation-queued";
|
|
1173
|
-
readonly id: string;
|
|
1174
|
-
readonly position?: number | undefined;
|
|
1175
|
-
}, {
|
|
1176
|
-
readonly type: keyof Handlers;
|
|
1177
1107
|
}> | Exclude<{
|
|
1178
1108
|
readonly type: "generation-progress";
|
|
1179
1109
|
readonly id: string;
|
|
@@ -1218,10 +1148,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1218
1148
|
readonly type: "image";
|
|
1219
1149
|
readonly index: number;
|
|
1220
1150
|
readonly image: Media.Asset;
|
|
1221
|
-
} | {
|
|
1222
|
-
readonly type: "generation-queued";
|
|
1223
|
-
readonly id: string;
|
|
1224
|
-
readonly position?: number | undefined;
|
|
1225
1151
|
} | {
|
|
1226
1152
|
readonly type: "generation-progress";
|
|
1227
1153
|
readonly id: string;
|
|
@@ -1258,11 +1184,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1258
1184
|
};
|
|
1259
1185
|
} & {
|
|
1260
1186
|
is: {
|
|
1261
|
-
generationQueued: (u: unknown) => u is {
|
|
1262
|
-
readonly type: "generation-queued";
|
|
1263
|
-
readonly id: string;
|
|
1264
|
-
readonly position?: number | undefined;
|
|
1265
|
-
};
|
|
1266
1187
|
generationProgress: (u: unknown) => u is {
|
|
1267
1188
|
readonly type: "generation-progress";
|
|
1268
1189
|
readonly id: string;
|
package/dist/image.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema, Stream } from "effect";
|
|
2
|
-
import { ProgressEvent
|
|
2
|
+
import { ProgressEvent } from "./generation.js";
|
|
3
3
|
import { Media } from "./media.js";
|
|
4
4
|
import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
|
|
5
5
|
import { MediaRoute } from "./route/media.js";
|
|
@@ -51,16 +51,9 @@ export const ImageFinishEvent = Schema.Struct({
|
|
|
51
51
|
usage: Schema.optional(MediaUsage),
|
|
52
52
|
providerMetadata: Schema.optional(ProviderMetadata),
|
|
53
53
|
}).annotate({ identifier: "Image.Event.Finish" });
|
|
54
|
-
const imageEventTagged = Schema.Union([
|
|
55
|
-
QueuedEvent,
|
|
56
|
-
ProgressEvent,
|
|
57
|
-
ImagePartialEvent,
|
|
58
|
-
ImageOutputEvent,
|
|
59
|
-
ImageFinishEvent,
|
|
60
|
-
]).pipe(Schema.toTaggedUnion("type"));
|
|
54
|
+
const imageEventTagged = Schema.Union([ProgressEvent, ImagePartialEvent, ImageOutputEvent, ImageFinishEvent]).pipe(Schema.toTaggedUnion("type"));
|
|
61
55
|
export const ImageEvent = Object.assign(imageEventTagged, {
|
|
62
56
|
is: {
|
|
63
|
-
generationQueued: imageEventTagged.guards["generation-queued"],
|
|
64
57
|
generationProgress: imageEventTagged.guards["generation-progress"],
|
|
65
58
|
imagePartial: imageEventTagged.guards["image-partial"],
|
|
66
59
|
image: imageEventTagged.guards.image,
|
package/dist/index.d.ts
CHANGED
|
@@ -93,10 +93,6 @@ export declare const make: (options?: Options) => {
|
|
|
93
93
|
readonly type: "image";
|
|
94
94
|
readonly index: number;
|
|
95
95
|
readonly image: Media.Asset;
|
|
96
|
-
} | {
|
|
97
|
-
readonly type: "generation-queued";
|
|
98
|
-
readonly id: string;
|
|
99
|
-
readonly position?: number | undefined;
|
|
100
96
|
} | {
|
|
101
97
|
readonly type: "generation-progress";
|
|
102
98
|
readonly id: string;
|
|
@@ -171,10 +167,6 @@ export declare const make: (options?: Options) => {
|
|
|
171
167
|
readonly startSeconds: number;
|
|
172
168
|
readonly endSeconds: number;
|
|
173
169
|
}[];
|
|
174
|
-
} | {
|
|
175
|
-
readonly type: "generation-queued";
|
|
176
|
-
readonly id: string;
|
|
177
|
-
readonly position?: number | undefined;
|
|
178
170
|
} | {
|
|
179
171
|
readonly type: "generation-progress";
|
|
180
172
|
readonly id: string;
|
|
@@ -224,10 +216,6 @@ export declare const make: (options?: Options) => {
|
|
|
224
216
|
readonly endSeconds: number;
|
|
225
217
|
readonly speaker?: string | undefined;
|
|
226
218
|
};
|
|
227
|
-
} | {
|
|
228
|
-
readonly type: "generation-queued";
|
|
229
|
-
readonly id: string;
|
|
230
|
-
readonly position?: number | undefined;
|
|
231
219
|
} | {
|
|
232
220
|
readonly type: "generation-progress";
|
|
233
221
|
readonly id: string;
|
package/dist/media-client.d.ts
CHANGED
|
@@ -33,7 +33,11 @@ export declare const make: <Self, Req extends RoutedRequest<Req, Event, Response
|
|
|
33
33
|
responseEvents: (response: Response) => readonly Event[];
|
|
34
34
|
layer: Layer.Layer<Self, never, RequestExecutor.RequestExecutorService>;
|
|
35
35
|
generate: (request: Req, options?: AwaitOptions) => Effect.Effect<Response, AIError, Self>;
|
|
36
|
-
stream: (request: Req, options?: AwaitOptions) => Stream.Stream<Event |
|
|
36
|
+
stream: (request: Req, options?: AwaitOptions) => Stream.Stream<Event | {
|
|
37
|
+
readonly type: "generation-progress";
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly progress?: number | undefined;
|
|
40
|
+
}, AIError, Exclude<Self, import("effect/Scope").Scope>>;
|
|
37
41
|
start: (request: Req) => Effect.Effect<Generation<Response>, AIError, Self>;
|
|
38
42
|
resume: (model: Req["model"], token: unknown) => Effect.Effect<Generation<Response>, AIError, Self>;
|
|
39
43
|
};
|
|
@@ -39,7 +39,7 @@ const Transcript = Schema.Struct({
|
|
|
39
39
|
error: optionalNull(Schema.String),
|
|
40
40
|
});
|
|
41
41
|
const STATUS = {
|
|
42
|
-
queued: "
|
|
42
|
+
queued: "running",
|
|
43
43
|
processing: "running",
|
|
44
44
|
completed: "completed",
|
|
45
45
|
error: "failed",
|
|
@@ -77,19 +77,20 @@ const fromRequest = Effect.fn("AssemblyAITranscription.fromRequest")(function* (
|
|
|
77
77
|
const decodeTranscript = route.decodeJson(Transcript);
|
|
78
78
|
const decodeStart = Effect.fn("AssemblyAITranscription.decodeStart")(function* (response) {
|
|
79
79
|
const output = yield* decodeTranscript(response);
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
return {
|
|
81
|
+
token: { transcriptID: output.value.id },
|
|
82
|
+
snapshot: { id: output.value.id, ...MediaProtocol.status(STATUS, output.value.status) },
|
|
83
|
+
};
|
|
82
84
|
});
|
|
83
85
|
const decodeStatus = Effect.fn("AssemblyAITranscription.decodeStatus")(function* (response, context) {
|
|
84
86
|
const output = yield* decodeTranscript(response);
|
|
85
|
-
|
|
86
|
-
return { id: context.token.transcriptID, status };
|
|
87
|
+
return { id: context.token.transcriptID, ...MediaProtocol.status(STATUS, output.value.status) };
|
|
87
88
|
});
|
|
88
89
|
const seconds = (milliseconds) => milliseconds / 1000;
|
|
89
90
|
const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function* (response, context) {
|
|
90
91
|
const output = yield* decodeTranscript(response);
|
|
91
92
|
const transcript = output.value;
|
|
92
|
-
const status = MediaProtocol.
|
|
93
|
+
const status = MediaProtocol.state(STATUS, transcript.status);
|
|
93
94
|
const error = transcript.error ?? undefined;
|
|
94
95
|
if (status === "failed")
|
|
95
96
|
return yield* output.ended("failed", `${route.name} transcription failed${error === undefined ? "" : `: ${error}`}`);
|
|
@@ -32,10 +32,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
32
32
|
readonly startSeconds: number;
|
|
33
33
|
readonly endSeconds: number;
|
|
34
34
|
}[];
|
|
35
|
-
} | {
|
|
36
|
-
readonly type: "generation-queued";
|
|
37
|
-
readonly id: string;
|
|
38
|
-
readonly position?: number | undefined;
|
|
39
35
|
} | {
|
|
40
36
|
readonly type: "generation-progress";
|
|
41
37
|
readonly id: string;
|
|
@@ -82,10 +78,6 @@ export declare const CartesiaSpeech: {
|
|
|
82
78
|
readonly startSeconds: number;
|
|
83
79
|
readonly endSeconds: number;
|
|
84
80
|
}[];
|
|
85
|
-
} | {
|
|
86
|
-
readonly type: "generation-queued";
|
|
87
|
-
readonly id: string;
|
|
88
|
-
readonly position?: number | undefined;
|
|
89
81
|
} | {
|
|
90
82
|
readonly type: "generation-progress";
|
|
91
83
|
readonly id: string;
|
|
@@ -25,10 +25,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
25
25
|
readonly startSeconds: number;
|
|
26
26
|
readonly endSeconds: number;
|
|
27
27
|
}[];
|
|
28
|
-
} | {
|
|
29
|
-
readonly type: "generation-queued";
|
|
30
|
-
readonly id: string;
|
|
31
|
-
readonly position?: number | undefined;
|
|
32
28
|
} | {
|
|
33
29
|
readonly type: "generation-progress";
|
|
34
30
|
readonly id: string;
|
|
@@ -75,10 +71,6 @@ export declare const DeepgramSpeech: {
|
|
|
75
71
|
readonly startSeconds: number;
|
|
76
72
|
readonly endSeconds: number;
|
|
77
73
|
}[];
|
|
78
|
-
} | {
|
|
79
|
-
readonly type: "generation-queued";
|
|
80
|
-
readonly id: string;
|
|
81
|
-
readonly position?: number | undefined;
|
|
82
74
|
} | {
|
|
83
75
|
readonly type: "generation-progress";
|
|
84
76
|
readonly id: string;
|
|
@@ -28,10 +28,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
28
28
|
readonly startSeconds: number;
|
|
29
29
|
readonly endSeconds: number;
|
|
30
30
|
}[];
|
|
31
|
-
} | {
|
|
32
|
-
readonly type: "generation-queued";
|
|
33
|
-
readonly id: string;
|
|
34
|
-
readonly position?: number | undefined;
|
|
35
31
|
} | {
|
|
36
32
|
readonly type: "generation-progress";
|
|
37
33
|
readonly id: string;
|
|
@@ -78,10 +74,6 @@ export declare const ElevenLabsSpeech: {
|
|
|
78
74
|
readonly startSeconds: number;
|
|
79
75
|
readonly endSeconds: number;
|
|
80
76
|
}[];
|
|
81
|
-
} | {
|
|
82
|
-
readonly type: "generation-queued";
|
|
83
|
-
readonly id: string;
|
|
84
|
-
readonly position?: number | undefined;
|
|
85
77
|
} | {
|
|
86
78
|
readonly type: "generation-progress";
|
|
87
79
|
readonly id: string;
|
|
@@ -104,17 +104,17 @@ const fromRequest = Effect.fn("GoogleInteractionsVideo.fromRequest")(function* (
|
|
|
104
104
|
// ---------------------------------------------------------------------------
|
|
105
105
|
const decodeStart = route.decodeStarted(Interaction, (value) => ({
|
|
106
106
|
token: value.id,
|
|
107
|
-
snapshot: { id: value.id,
|
|
107
|
+
snapshot: { id: value.id, ...MediaProtocol.status(STATUS, value.status) },
|
|
108
108
|
}));
|
|
109
109
|
const decodeInteraction = route.decodeJson(Interaction);
|
|
110
110
|
const decodeStatus = Effect.fn("GoogleInteractionsVideo.decodeStatus")(function* (response, context) {
|
|
111
111
|
const output = yield* decodeInteraction(response);
|
|
112
|
-
return { id: context.token,
|
|
112
|
+
return { id: context.token, ...MediaProtocol.status(STATUS, output.value.status) };
|
|
113
113
|
});
|
|
114
114
|
const decodeResult = Effect.fn("GoogleInteractionsVideo.decodeResult")(function* (response, context) {
|
|
115
115
|
const output = yield* decodeInteraction(response);
|
|
116
116
|
const decoded = output.value;
|
|
117
|
-
const status = MediaProtocol.
|
|
117
|
+
const status = MediaProtocol.state(STATUS, decoded.status);
|
|
118
118
|
if (status === "running")
|
|
119
119
|
return yield* output.pending(context.token);
|
|
120
120
|
const errors = decoded.errors ?? [];
|
|
@@ -35,10 +35,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
35
35
|
readonly startSeconds: number;
|
|
36
36
|
readonly endSeconds: number;
|
|
37
37
|
}[];
|
|
38
|
-
} | {
|
|
39
|
-
readonly type: "generation-queued";
|
|
40
|
-
readonly id: string;
|
|
41
|
-
readonly position?: number | undefined;
|
|
42
38
|
} | {
|
|
43
39
|
readonly type: "generation-progress";
|
|
44
40
|
readonly id: string;
|
|
@@ -85,10 +81,6 @@ export declare const GoogleSpeech: {
|
|
|
85
81
|
readonly startSeconds: number;
|
|
86
82
|
readonly endSeconds: number;
|
|
87
83
|
}[];
|
|
88
|
-
} | {
|
|
89
|
-
readonly type: "generation-queued";
|
|
90
|
-
readonly id: string;
|
|
91
|
-
readonly position?: number | undefined;
|
|
92
84
|
} | {
|
|
93
85
|
readonly type: "generation-progress";
|
|
94
86
|
readonly id: string;
|