@opencode/ai 0.0.0-dev-1277 → 0.0.0-dev-1284
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 +75 -87
- package/dist/effect.d.ts +8 -7
- package/dist/effect.js +2 -1
- package/dist/experimental.d.ts +0 -4
- package/dist/experimental.js +0 -3
- package/dist/index.d.ts +11 -48
- package/dist/index.js +30 -13
- package/dist/media-model.d.ts +2 -0
- package/dist/media-model.js +3 -1
- package/dist/media.d.ts +8 -2
- package/dist/media.js +26 -6
- package/dist/protocols/xai-video.d.ts +8 -2
- package/dist/protocols/xai-video.js +20 -15
- package/dist/public.d.ts +2 -0
- package/dist/public.js +1 -0
- package/dist/route/media.d.ts +2 -0
- package/dist/route/media.js +9 -7
- package/dist/video-client.d.ts +16 -84
- package/dist/video-client.js +28 -9
- package/dist/video.d.ts +56 -1072
- package/dist/video.js +28 -65
- package/package.json +3 -3
package/dist/public.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
2
2
|
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, GENERATION_KEYS, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, SystemMessage, UserMessage, AssistantMessage, ToolMessage, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
3
3
|
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
4
|
+
export { VideoAspectRatio, VideoDuration, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
4
5
|
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
5
6
|
export { EmbeddingModel, EmbeddingModelSchema, EmbeddingResponse, EmbeddingUsage, EmbeddingValue } from "./embedding.js";
|
|
6
7
|
export { Media } from "./media.js";
|
package/dist/route/media.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface QueuedRoute<Request extends MediaRequest, Response> {
|
|
|
46
46
|
readonly start: (request: Request, execute: Execute) => Effect.Effect<Generation<Response>, AIError>;
|
|
47
47
|
/** Rebuild a handle from a persisted `Generation.token`; fails typed when the token is not this route's. */
|
|
48
48
|
readonly resume: (model: MediaRequest["model"], token: unknown, execute: Execute) => Effect.Effect<Generation<Response>, AIError>;
|
|
49
|
+
/** The status, result and cancel operations for a persisted token, without reading its status first. */
|
|
50
|
+
readonly attach: (model: MediaRequest["model"], token: unknown, execute: Execute) => Effect.Effect<Generation<Response>["route"], AIError>;
|
|
49
51
|
}
|
|
50
52
|
/** One request whose response parses into events; `generate` runs the same stream and collects it. */
|
|
51
53
|
export interface StreamRoute<Request extends MediaRequest, Event, Response> {
|
package/dist/route/media.js
CHANGED
|
@@ -74,17 +74,19 @@ export const queued = (input) => {
|
|
|
74
74
|
const route = generationRoute(started.token, submitted.exchange, execute);
|
|
75
75
|
return new Generation(route, encodeToken(started.token), started.snapshot);
|
|
76
76
|
});
|
|
77
|
+
const decode = (raw) => decodeToken(raw).pipe(Effect.mapError((cause) => new AIError({
|
|
78
|
+
reason: new InvalidRequestError({
|
|
79
|
+
message: `${protocol.id} cannot resume a generation from this token`,
|
|
80
|
+
cause,
|
|
81
|
+
}),
|
|
82
|
+
})));
|
|
83
|
+
const attach = (model, raw, execute) => decode(raw).pipe(Effect.map((token) => generationRoute(token, transport.exchange(model), execute)));
|
|
77
84
|
const resume = Effect.fn("MediaRoute.resume")(function* (model, raw, execute) {
|
|
78
|
-
const token = yield*
|
|
79
|
-
reason: new InvalidRequestError({
|
|
80
|
-
message: `${protocol.id} cannot resume a generation from this token`,
|
|
81
|
-
cause,
|
|
82
|
-
}),
|
|
83
|
-
})));
|
|
85
|
+
const token = yield* decode(raw);
|
|
84
86
|
const route = generationRoute(token, transport.exchange(model), execute);
|
|
85
87
|
return new Generation(route, encodeToken(token), yield* route.status);
|
|
86
88
|
});
|
|
87
|
-
return { kind: "queued", id: protocol.id, provider: protocol.provider, protocol: protocol.id, start, resume };
|
|
89
|
+
return { kind: "queued", id: protocol.id, provider: protocol.provider, protocol: protocol.id, start, resume, attach };
|
|
88
90
|
};
|
|
89
91
|
/** Compose a streaming media protocol; `generate` runs the same stream in `generate` mode and folds it with `collect`. */
|
|
90
92
|
export const stream = (input) => {
|
package/dist/video-client.d.ts
CHANGED
|
@@ -1,93 +1,25 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
3
|
+
import { AIError } from "./schema/index.js";
|
|
4
|
+
import type { VideoJob, VideoModel, VideoRequest, VideoResponse, VideoStatus } from "./video.js";
|
|
5
|
+
export interface Interface {
|
|
6
|
+
readonly start: (request: VideoRequest) => Effect.Effect<VideoJob, AIError>;
|
|
7
|
+
readonly status: (model: VideoModel, token: unknown) => Effect.Effect<VideoStatus, AIError>;
|
|
8
|
+
readonly result: (model: VideoModel, token: unknown) => Effect.Effect<VideoResponse, AIError>;
|
|
9
|
+
readonly cancel: (model: VideoModel, token: unknown) => Effect.Effect<void, AIError>;
|
|
10
|
+
}
|
|
5
11
|
declare const VideoClientService_base: Context.ServiceClass<VideoClientService, "@opencode/VideoClient", Interface>;
|
|
6
12
|
export declare class VideoClientService extends VideoClientService_base {
|
|
7
13
|
}
|
|
8
14
|
export declare const Service: typeof VideoClientService;
|
|
9
15
|
export type Service = VideoClientService;
|
|
16
|
+
export declare const layer: Layer.Layer<VideoClientService, never, RequestExecutor.RequestExecutorService>;
|
|
10
17
|
export declare const VideoClient: {
|
|
11
|
-
readonly responseEvents: (response: VideoResponse) => readonly ({
|
|
12
|
-
readonly type: "video";
|
|
13
|
-
readonly index: number;
|
|
14
|
-
readonly video: import("./media.js").Asset;
|
|
15
|
-
} | {
|
|
16
|
-
readonly type: "generation-queued";
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly position?: number | undefined;
|
|
19
|
-
} | {
|
|
20
|
-
readonly type: "generation-progress";
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly progress?: number | undefined;
|
|
23
|
-
} | {
|
|
24
|
-
readonly type: "finish";
|
|
25
|
-
readonly usage?: {
|
|
26
|
-
readonly type: "seconds";
|
|
27
|
-
readonly seconds: number;
|
|
28
|
-
} | {
|
|
29
|
-
readonly type: "characters";
|
|
30
|
-
readonly characters: number;
|
|
31
|
-
} | {
|
|
32
|
-
readonly type: "credits";
|
|
33
|
-
readonly credits: number;
|
|
34
|
-
} | {
|
|
35
|
-
readonly type: "compute";
|
|
36
|
-
readonly seconds: number;
|
|
37
|
-
} | {
|
|
38
|
-
readonly type: "tokens";
|
|
39
|
-
readonly input?: number | undefined;
|
|
40
|
-
readonly output?: number | undefined;
|
|
41
|
-
readonly total?: number | undefined;
|
|
42
|
-
readonly details?: {
|
|
43
|
-
readonly [x: string]: unknown;
|
|
44
|
-
} | undefined;
|
|
45
|
-
} | undefined;
|
|
46
|
-
readonly providerMetadata?: {
|
|
47
|
-
readonly [x: string]: {
|
|
48
|
-
readonly [x: string]: unknown;
|
|
49
|
-
};
|
|
50
|
-
} | undefined;
|
|
51
|
-
})[];
|
|
52
|
-
readonly layer: import("effect/Layer").Layer<VideoClientService, never, import("./route.js").RequestExecutorService>;
|
|
53
|
-
readonly generate: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./public.js").AIError, VideoClientService>;
|
|
54
|
-
readonly stream: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
55
|
-
readonly type: "video";
|
|
56
|
-
readonly index: number;
|
|
57
|
-
readonly video: import("./media.js").Asset;
|
|
58
|
-
} | {
|
|
59
|
-
readonly type: "finish";
|
|
60
|
-
readonly usage?: {
|
|
61
|
-
readonly type: "seconds";
|
|
62
|
-
readonly seconds: number;
|
|
63
|
-
} | {
|
|
64
|
-
readonly type: "characters";
|
|
65
|
-
readonly characters: number;
|
|
66
|
-
} | {
|
|
67
|
-
readonly type: "credits";
|
|
68
|
-
readonly credits: number;
|
|
69
|
-
} | {
|
|
70
|
-
readonly type: "compute";
|
|
71
|
-
readonly seconds: number;
|
|
72
|
-
} | {
|
|
73
|
-
readonly type: "tokens";
|
|
74
|
-
readonly input?: number | undefined;
|
|
75
|
-
readonly output?: number | undefined;
|
|
76
|
-
readonly total?: number | undefined;
|
|
77
|
-
readonly details?: {
|
|
78
|
-
readonly [x: string]: unknown;
|
|
79
|
-
} | undefined;
|
|
80
|
-
} | undefined;
|
|
81
|
-
readonly providerMetadata?: {
|
|
82
|
-
readonly [x: string]: {
|
|
83
|
-
readonly [x: string]: unknown;
|
|
84
|
-
};
|
|
85
|
-
} | undefined;
|
|
86
|
-
} | import("./generation.js").Observation, import("./public.js").AIError, VideoClientService>;
|
|
87
|
-
readonly start: (request: VideoRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
|
|
88
|
-
readonly resume: (model: import("./video.js").VideoModel<{
|
|
89
|
-
readonly [x: string]: unknown;
|
|
90
|
-
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
|
|
91
18
|
readonly Service: typeof VideoClientService;
|
|
19
|
+
readonly layer: Layer.Layer<VideoClientService, never, RequestExecutor.RequestExecutorService>;
|
|
20
|
+
readonly start: (request: VideoRequest) => Effect.Effect<VideoJob, AIError, VideoClientService>;
|
|
21
|
+
readonly status: (model: VideoModel, token: unknown) => Effect.Effect<VideoStatus, AIError, VideoClientService>;
|
|
22
|
+
readonly result: (model: VideoModel, token: unknown) => Effect.Effect<VideoResponse, AIError, VideoClientService>;
|
|
23
|
+
readonly cancel: (model: VideoModel, token: unknown) => Effect.Effect<void, AIError, VideoClientService>;
|
|
92
24
|
};
|
|
93
25
|
export {};
|
package/dist/video-client.js
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
2
|
-
import {
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
3
|
+
import { AIError, UnsupportedOperationError } from "./schema/index.js";
|
|
3
4
|
export class VideoClientService extends Context.Service()("@opencode/VideoClient") {
|
|
4
5
|
}
|
|
5
6
|
export const Service = VideoClientService;
|
|
7
|
+
export const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
8
|
+
const executor = yield* RequestExecutor.Service;
|
|
9
|
+
const attach = (model, token) => model.route.attach(model, token, executor.execute);
|
|
10
|
+
return Service.of({
|
|
11
|
+
start: (request) => request.model.route
|
|
12
|
+
.start(request, executor.execute)
|
|
13
|
+
.pipe(Effect.map((generation) => ({ id: generation.id, token: generation.token }))),
|
|
14
|
+
status: (model, token) => attach(model, token).pipe(Effect.flatMap((route) => route.status), Effect.map((snapshot) => ({ status: snapshot.status, progress: snapshot.progress }))),
|
|
15
|
+
result: (model, token) => attach(model, token).pipe(Effect.flatMap((route) => route.result)),
|
|
16
|
+
cancel: (model, token) => attach(model, token).pipe(Effect.flatMap((route) => route.cancel ??
|
|
17
|
+
Effect.fail(new AIError({
|
|
18
|
+
reason: new UnsupportedOperationError({
|
|
19
|
+
operation: "video.cancel",
|
|
20
|
+
provider: model.provider,
|
|
21
|
+
route: model.route.id,
|
|
22
|
+
message: `${model.provider}/${model.route.id} has no way to cancel a video generation`,
|
|
23
|
+
}),
|
|
24
|
+
})))),
|
|
25
|
+
});
|
|
26
|
+
}));
|
|
6
27
|
export const VideoClient = {
|
|
7
28
|
Service,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
],
|
|
14
|
-
}),
|
|
29
|
+
layer,
|
|
30
|
+
start: (request) => Service.use((client) => client.start(request)),
|
|
31
|
+
status: (model, token) => Service.use((client) => client.status(model, token)),
|
|
32
|
+
result: (model, token) => Service.use((client) => client.result(model, token)),
|
|
33
|
+
cancel: (model, token) => Service.use((client) => client.cancel(model, token)),
|
|
15
34
|
};
|