@opencode/ai 0.0.0-dev-1266 → 0.0.0-dev-1274
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 +17 -26
- package/dist/media.d.ts +1 -1
- package/dist/media.js +1 -1
- package/dist/providers/google.d.ts +0 -4
- package/dist/providers/google.js +0 -3
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.js +0 -1
- package/dist/route/media-protocol.d.ts +2 -11
- package/dist/route/media.js +6 -13
- package/package.json +3 -7
- 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/README.md
CHANGED
|
@@ -1071,73 +1071,64 @@ part of the same experimental surface.
|
|
|
1071
1071
|
### Video generation
|
|
1072
1072
|
|
|
1073
1073
|
Video mirrors `Image` with one difference: every provider is asynchronous, so the route is a submit-then-poll
|
|
1074
|
-
`Generation`. Models come from `.video(...)` selectors on the `
|
|
1074
|
+
`Generation`. Models come from `.video(...)` selectors on the `XAI` facade.
|
|
1075
1075
|
Common fields (`frames`, `references`, `video`, `durationSeconds`, `aspect`, `resolution`, `audio`, `n`, `seed`,
|
|
1076
1076
|
`negativePrompt`) lower natively or fail with a typed `AIError` before any network call; provider-native controls live
|
|
1077
1077
|
under `providerOptions`, inferred from the selected model.
|
|
1078
1078
|
|
|
1079
1079
|
```ts
|
|
1080
1080
|
import { Video } from "@opencode/ai/experimental"
|
|
1081
|
-
import {
|
|
1081
|
+
import { XAI } from "@opencode/ai/providers"
|
|
1082
1082
|
|
|
1083
|
-
const
|
|
1083
|
+
const xai = XAI.configure({ apiKey: process.env.XAI_API_KEY })
|
|
1084
1084
|
|
|
1085
1085
|
// Simple: submit and wait.
|
|
1086
1086
|
const program = Effect.gen(function* () {
|
|
1087
1087
|
const response = yield* Video.generate(
|
|
1088
1088
|
{
|
|
1089
|
-
model:
|
|
1089
|
+
model: xai.video("grok-imagine-video-1.5"),
|
|
1090
1090
|
prompt: "Panning wide shot of a calico kitten sleeping in the sunshine",
|
|
1091
1091
|
aspect: "16:9",
|
|
1092
|
-
resolution: "
|
|
1093
|
-
durationSeconds:
|
|
1094
|
-
providerOptions: { personGeneration: "allow_adult" },
|
|
1092
|
+
resolution: "720p",
|
|
1093
|
+
durationSeconds: 10,
|
|
1095
1094
|
},
|
|
1096
1095
|
{ poll: { interval: "10 seconds", timeout: "10 minutes" } },
|
|
1097
1096
|
)
|
|
1098
|
-
//
|
|
1099
|
-
// download credentials only on the live instance (`asset.headers`), never in `source` or JSON: materialize
|
|
1100
|
-
// before persisting, or the persisted URL cannot be fetched again.
|
|
1097
|
+
// xAI returns a temporary URL: materialize before persisting, or the persisted URL may stop working.
|
|
1101
1098
|
return yield* response.video.materialize()
|
|
1102
1099
|
})
|
|
1103
1100
|
|
|
1104
1101
|
// Explicit control: keep the handle, persist the token, resume elsewhere.
|
|
1105
1102
|
const controlled = Effect.gen(function* () {
|
|
1106
|
-
const generation = yield* Video.start({ model:
|
|
1107
|
-
generation.id // provider
|
|
1103
|
+
const generation = yield* Video.start({ model: xai.video("grok-imagine-video-1.5"), prompt })
|
|
1104
|
+
generation.id // provider request id
|
|
1108
1105
|
generation.status // "queued" | "running" | "completed" | "failed" | "cancelled" | "expired"
|
|
1109
|
-
generation.token // route-owned JSON
|
|
1106
|
+
generation.token // route-owned JSON, `{ requestID }` for xAI
|
|
1110
1107
|
// The token carries no route identity: persist the provider and model ID alongside it, since `resume` needs the model.
|
|
1111
1108
|
const saved = JSON.stringify(generation.token)
|
|
1112
1109
|
|
|
1113
|
-
const resumed = yield* Video.resume(
|
|
1110
|
+
const resumed = yield* Video.resume(xai.video("grok-imagine-video-1.5"), JSON.parse(saved))
|
|
1114
1111
|
return yield* resumed.await({ poll: { interval: "10 seconds" } })
|
|
1115
1112
|
})
|
|
1116
1113
|
|
|
1117
1114
|
// Progress as a stream: generation-queued | generation-progress | video | finish.
|
|
1118
|
-
const events = Video.stream({ model:
|
|
1115
|
+
const events = Video.stream({ model: xai.video("grok-imagine-video-1.5"), prompt }, { poll })
|
|
1119
1116
|
```
|
|
1120
1117
|
|
|
1121
|
-
Status polls, result fetches,
|
|
1118
|
+
Status polls, result fetches, and cancels all run through the same request executor with the route's
|
|
1122
1119
|
auth. `Generation.await` and `Generation.events` fail with a
|
|
1123
1120
|
`Timeout` reason when `poll.timeout` (default 10 minutes) elapses. Status polls and result fetches retry transient
|
|
1124
1121
|
failures (rate limits, provider 5xx, network errors) with backoff that honors `retry-after`, always within
|
|
1125
1122
|
`poll.timeout`; submits and cancels never retry. Interrupting a wait (or aborting its `signal`) does not cancel the
|
|
1126
|
-
provider job, which keeps running and billing: call `cancel()` to stop it
|
|
1127
|
-
cancelled, and expired generations fail typed with the provider's
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
`providerMetadata`.
|
|
1123
|
+
provider job, which keeps running and billing: call `cancel()` to stop it on providers with a cancel endpoint (xAI has
|
|
1124
|
+
none, so `cancel()` sends nothing there). Failed, cancelled, and expired generations fail typed with the provider's
|
|
1125
|
+
terminal document on `reason.body`; moderation outcomes (xAI `respect_moderation`) fail with a `ContentPolicy` reason
|
|
1126
|
+
when no video comes back; when one still does, the raw outcome stays in `providerMetadata`.
|
|
1131
1127
|
|
|
1132
1128
|
Provider notes:
|
|
1133
1129
|
|
|
1134
|
-
- **Google Veo** takes inline bytes only (materialize `url` assets first); `frames.last` requires `frames.first`;
|
|
1135
|
-
audio is always on, so `audio: false` fails typed; one video per request. Output URLs need the API key to
|
|
1136
|
-
download, which the returned asset holds transiently (see above).
|
|
1137
1130
|
- **xAI** sends a `video` input to `/videos/edits`, or `/videos/extensions` with `providerOptions.mode: "extend"`.
|
|
1138
1131
|
`seed` and `negativePrompt` are not supported.
|
|
1139
|
-
- **Runway** expects pixel ratios in `aspect` for most models (`"1280:720"`), pins `X-Runway-Version`, reports
|
|
1140
|
-
`usage: { type: "credits" }`, and its output URLs expire after 24–48 hours.
|
|
1141
1132
|
|
|
1142
1133
|
The promise client exposes the same surface: `ai.experimental.video.start(...)` resolves to a handle with `await`, `events`,
|
|
1143
1134
|
`result`, `refresh`, `cancel`, and `token`; `ai.experimental.video.generate`, `ai.experimental.video.resume(model, token)`, and
|
package/dist/media.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ export declare namespace Asset {
|
|
|
115
115
|
readonly info?: Info;
|
|
116
116
|
readonly providerMetadata?: ProviderMetadata;
|
|
117
117
|
/**
|
|
118
|
-
* Headers required to download a `url` source, such as
|
|
118
|
+
* Headers required to download a `url` source, such as a provider API key.
|
|
119
119
|
* They are runtime-only: never part of `source`, `toJSON()`, or `AssetSchema`, so a persisted asset cannot leak
|
|
120
120
|
* credentials and cannot be downloaded again after a round-trip. Call `materialize()` before persisting.
|
|
121
121
|
*/
|
package/dist/media.js
CHANGED
|
@@ -29,7 +29,7 @@ const UrlSource = Schema.Struct({
|
|
|
29
29
|
/** Epoch milliseconds after which the provider no longer serves the URL. */
|
|
30
30
|
expiresAt: Schema.optional(Schema.Number),
|
|
31
31
|
});
|
|
32
|
-
/** A provider-side handle: OpenAI `file_id`, Gemini file URI, `gs://`,
|
|
32
|
+
/** A provider-side handle: OpenAI `file_id`, Gemini file URI, `gs://`, or a prior generation id. */
|
|
33
33
|
const RefSource = Schema.Struct({
|
|
34
34
|
type: Schema.Literal("ref"),
|
|
35
35
|
provider: ProviderID,
|
|
@@ -9,7 +9,6 @@ export type { OptionsInput as GoogleEmbeddingOptions } from "../protocols/google
|
|
|
9
9
|
export type { GoogleImageOptions } from "../protocols/google-images.js";
|
|
10
10
|
export type { GoogleSpeechOptions } from "../protocols/google-speech.js";
|
|
11
11
|
export type { GoogleTranscriptionOptions } from "../protocols/google-transcription.js";
|
|
12
|
-
export type { GoogleVideoOptions } from "../protocols/google-video.js";
|
|
13
12
|
export type GeminiOptionsInput = Gemini.OptionsInput;
|
|
14
13
|
export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput;
|
|
15
14
|
export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput;
|
|
@@ -182,7 +181,6 @@ export declare const configure: (input?: Config) => {
|
|
|
182
181
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
183
182
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
184
183
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
185
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
186
184
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
187
185
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
188
186
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
@@ -201,7 +199,6 @@ export declare const provider: {
|
|
|
201
199
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
202
200
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
203
201
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
204
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
205
202
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
206
203
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
207
204
|
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<GoogleEmbeddingOptionsInput>;
|
|
@@ -222,7 +219,6 @@ export declare const interactions: (modelID: string | ModelID) => import("../sch
|
|
|
222
219
|
readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
|
|
223
220
|
readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
|
|
224
221
|
}, import("../route.js").CompactionOperations | undefined>;
|
|
225
|
-
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/google-video.js").GoogleVideoOptions>;
|
|
226
222
|
export declare const speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
|
|
227
223
|
export declare const transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
|
|
228
224
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<GoogleDecisions.OptionsInput>;
|
package/dist/providers/google.js
CHANGED
|
@@ -9,7 +9,6 @@ import { GoogleInteractions } from "../protocols/google-interactions.js";
|
|
|
9
9
|
import { GoogleImages } from "../protocols/google-images.js";
|
|
10
10
|
import { GoogleSpeech } from "../protocols/google-speech.js";
|
|
11
11
|
import { GoogleTranscription } from "../protocols/google-transcription.js";
|
|
12
|
-
import { GoogleVideo } from "../protocols/google-video.js";
|
|
13
12
|
import { toConfig } from "./settings.js";
|
|
14
13
|
export const id = ProviderID.make("google");
|
|
15
14
|
export const routes = [Gemini.route, GoogleInteractions.route];
|
|
@@ -39,7 +38,6 @@ export const configure = (input = {}) => {
|
|
|
39
38
|
gemini,
|
|
40
39
|
interactions: (modelID) => interactionsRoute(input).model({ id: modelID }),
|
|
41
40
|
image: (modelID, providerOptions) => GoogleImages.model({ ...media, id: modelID, providerOptions }),
|
|
42
|
-
video: (modelID) => GoogleVideo.model({ ...media, id: modelID }),
|
|
43
41
|
speech: (modelID) => GoogleSpeech.model({ ...media, id: modelID }),
|
|
44
42
|
transcription: (modelID) => GoogleTranscription.model({ ...media, id: modelID }),
|
|
45
43
|
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
@@ -67,7 +65,6 @@ export const image = provider.image;
|
|
|
67
65
|
export const embedding = provider.embedding;
|
|
68
66
|
export const gemini = provider.gemini;
|
|
69
67
|
export const interactions = provider.interactions;
|
|
70
|
-
export const video = provider.video;
|
|
71
68
|
export const speech = provider.speech;
|
|
72
69
|
export const transcription = provider.transcription;
|
|
73
70
|
export const decision = provider.decision;
|
|
@@ -34,7 +34,6 @@ export * as OpenAICompatible from "./openai-compatible.js";
|
|
|
34
34
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
35
35
|
export * as OpenCode from "./opencode.js";
|
|
36
36
|
export * as OpenRouter from "./openrouter.js";
|
|
37
|
-
export * as Runway from "./runway.js";
|
|
38
37
|
export * as TogetherAI from "./togetherai.js";
|
|
39
38
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
40
39
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
package/dist/providers/index.js
CHANGED
|
@@ -34,7 +34,6 @@ export * as OpenAICompatible from "./openai-compatible.js";
|
|
|
34
34
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
35
35
|
export * as OpenCode from "./opencode.js";
|
|
36
36
|
export * as OpenRouter from "./openrouter.js";
|
|
37
|
-
export * as Runway from "./runway.js";
|
|
38
37
|
export * as TogetherAI from "./togetherai.js";
|
|
39
38
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
40
39
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
@@ -50,19 +50,15 @@ export interface Started<Token> {
|
|
|
50
50
|
readonly token: Token;
|
|
51
51
|
readonly snapshot: Snapshot;
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* A follow-up call's inputs: the decoded token and the auth headers the route sent, so a protocol can attach them
|
|
55
|
-
* to output URLs that require the same credentials to download (Veo).
|
|
56
|
-
*/
|
|
53
|
+
/** A follow-up call's inputs: the decoded token. */
|
|
57
54
|
export interface PollContext<Token> {
|
|
58
55
|
readonly token: Token;
|
|
59
|
-
readonly auth: Record<string, string>;
|
|
60
56
|
}
|
|
61
57
|
/**
|
|
62
58
|
* Submit, then poll. `start` posts the body to the route endpoint; `status`, `result`, and `cancel` are follow-up
|
|
63
59
|
* calls addressed by the token. Paths are relative to the route base URL unless the provider hands back absolute
|
|
64
60
|
* URLs, in which case they are used verbatim. `result` is always its own GET: providers that
|
|
65
|
-
* return the output inside the status body (
|
|
61
|
+
* return the output inside the status body (xAI) point `result.path` at the status path and decode the
|
|
66
62
|
* same document, so `Generation.await` and `Video.resume(...).await()` behave identically everywhere.
|
|
67
63
|
*/
|
|
68
64
|
export interface Queued<Request, Response, Token> {
|
|
@@ -91,11 +87,6 @@ export interface Queued<Request, Response, Token> {
|
|
|
91
87
|
readonly cancel?: {
|
|
92
88
|
readonly method: AuthInput["method"];
|
|
93
89
|
readonly path: (token: Token) => string;
|
|
94
|
-
/**
|
|
95
|
-
* Fetch a fresh status first and skip the call for terminal generations, for providers whose cancel endpoint
|
|
96
|
-
* destroys finished work (Runway's `DELETE /v1/tasks/{id}` deletes completed tasks and their outputs).
|
|
97
|
-
*/
|
|
98
|
-
readonly activeOnly?: boolean;
|
|
99
90
|
};
|
|
100
91
|
}
|
|
101
92
|
export declare const queued: <Request, Response, Token>(route: Identity, input: Omit<Queued<Request, Response, Token>, "kind" | "id" | "provider">) => Queued<Request, Response, Token>;
|
package/dist/route/media.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Auth } from "./auth.js";
|
|
|
4
4
|
import { Endpoint } from "./endpoint.js";
|
|
5
5
|
import { RequestExecutor } from "./executor.js";
|
|
6
6
|
import { MediaProtocol } from "./media-protocol.js";
|
|
7
|
-
import { Generation
|
|
7
|
+
import { Generation } from "../generation.js";
|
|
8
8
|
import { isRetryable } from "../provider-error.js";
|
|
9
9
|
import { AIError, AIErrorReason, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeProviderOptions, mergeTransport, } from "../schema/index.js";
|
|
10
10
|
import { encodeJson } from "../utils/json.js";
|
|
@@ -57,18 +57,15 @@ export const queued = (input) => {
|
|
|
57
57
|
const generationRoute = (token, exchange, execute) => {
|
|
58
58
|
// Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
|
|
59
59
|
// re-reading it would spin until the caller's deadline.
|
|
60
|
-
const poll = (operation) => transport.call("GET", operation.path(token), exchange, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token
|
|
60
|
+
const poll = (operation) => transport.call("GET", operation.path(token), exchange, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token })));
|
|
61
61
|
const status = poll(protocol.status);
|
|
62
62
|
const cancel = protocol.cancel;
|
|
63
|
-
const send = cancel === undefined
|
|
64
|
-
? undefined
|
|
65
|
-
: transport.call(cancel.method, cancel.path(token), exchange, execute).pipe(Effect.asVoid);
|
|
66
63
|
return {
|
|
67
64
|
status,
|
|
68
65
|
result: poll(protocol.result),
|
|
69
|
-
cancel:
|
|
70
|
-
?
|
|
71
|
-
:
|
|
66
|
+
cancel: cancel === undefined
|
|
67
|
+
? undefined
|
|
68
|
+
: transport.call(cancel.method, cancel.path(token), exchange, execute).pipe(Effect.asVoid),
|
|
72
69
|
};
|
|
73
70
|
};
|
|
74
71
|
const start = Effect.fn("MediaRoute.start")(function* (request, execute) {
|
|
@@ -129,7 +126,6 @@ export const stream = (input) => {
|
|
|
129
126
|
const makeTransport = (input) => {
|
|
130
127
|
const authorize = Auth.toEffect(input.auth);
|
|
131
128
|
const baseURL = (path) => new URL(`${Endpoint.trimBaseUrl(input.endpoint.baseURL ?? "")}${path}`);
|
|
132
|
-
/** `auth` is only what `Auth` added or changed, never untouched deployment headers. */
|
|
133
129
|
const send = Effect.fn("MediaRoute.send")(function* (call, fetch, execute) {
|
|
134
130
|
const encoded = encode(call.body, call.headers);
|
|
135
131
|
const url = call.url.toString();
|
|
@@ -141,10 +137,7 @@ const makeTransport = (input) => {
|
|
|
141
137
|
headers: encoded.headers,
|
|
142
138
|
});
|
|
143
139
|
const response = yield* execute(encoded.apply(HttpClientRequest.make(call.method)(url).pipe(HttpClientRequest.setHeaders(headers))), RequestExecutor.withFetch(fetch));
|
|
144
|
-
return {
|
|
145
|
-
response,
|
|
146
|
-
auth: Object.fromEntries(Object.entries(headers).filter(([key, value]) => encoded.headers[key] !== value)),
|
|
147
|
-
};
|
|
140
|
+
return { response };
|
|
148
141
|
});
|
|
149
142
|
return {
|
|
150
143
|
/** Route and model overlays; `start` additionally merges the request's own. */
|
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-
|
|
3
|
+
"version": "0.0.0-dev-1274",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -412,10 +412,6 @@
|
|
|
412
412
|
"types": "./dist/providers/openrouter/responses.d.ts",
|
|
413
413
|
"import": "./dist/providers/openrouter/responses.js"
|
|
414
414
|
},
|
|
415
|
-
"./providers/runway": {
|
|
416
|
-
"types": "./dist/providers/runway.d.ts",
|
|
417
|
-
"import": "./dist/providers/runway.js"
|
|
418
|
-
},
|
|
419
415
|
"./providers/togetherai": {
|
|
420
416
|
"types": "./dist/providers/togetherai.d.ts",
|
|
421
417
|
"import": "./dist/providers/togetherai.js"
|
|
@@ -584,7 +580,7 @@
|
|
|
584
580
|
"devDependencies": {
|
|
585
581
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
586
582
|
"@effect/platform-node": "4.1.0",
|
|
587
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
583
|
+
"@opencode/http-recorder": "0.0.0-dev-1274",
|
|
588
584
|
"@tsconfig/bun": "1.0.9",
|
|
589
585
|
"@types/bun": "1.4.3",
|
|
590
586
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -594,7 +590,7 @@
|
|
|
594
590
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
595
591
|
"@smithy/eventstream-codec": "4.2.14",
|
|
596
592
|
"@smithy/util-utf8": "4.2.2",
|
|
597
|
-
"@opencode/schema": "0.0.0-dev-
|
|
593
|
+
"@opencode/schema": "0.0.0-dev-1274",
|
|
598
594
|
"aws4fetch": "1.0.20",
|
|
599
595
|
"effect": "4.1.0",
|
|
600
596
|
"google-auth-library": "10.5.0"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
3
|
-
import { MediaRoute } from "../route/media.js";
|
|
4
|
-
import { type OpenString } from "../schema/index.js";
|
|
5
|
-
import { VideoModel, VideoResponse, type VideoRequest } from "../video.js";
|
|
6
|
-
export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
7
|
-
/** Provider-native `parameters`. Common fields (`aspect`, `resolution`, `durationSeconds`, `seed`) live on the request. */
|
|
8
|
-
export type GoogleVideoOptions = {
|
|
9
|
-
readonly personGeneration?: OpenString<"allow_all" | "allow_adult" | "dont_allow">;
|
|
10
|
-
} & Record<string, unknown>;
|
|
11
|
-
export type Request = VideoRequest<VideoModel<GoogleVideoOptions>>;
|
|
12
|
-
/** The long-running operation name, e.g. `models/veo-3.1-generate-preview/operations/abc123`. */
|
|
13
|
-
export declare const Token: Schema.Struct<{
|
|
14
|
-
readonly operation: Schema.String;
|
|
15
|
-
}>;
|
|
16
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
17
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
18
|
-
readonly operation: string;
|
|
19
|
-
}>;
|
|
20
|
-
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<GoogleVideoOptions>;
|
|
21
|
-
export declare const GoogleVideo: {
|
|
22
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
23
|
-
readonly operation: string;
|
|
24
|
-
}>;
|
|
25
|
-
readonly model: typeof model;
|
|
26
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Duration, Effect, Schema } from "effect";
|
|
2
|
-
import { Media } from "../media.js";
|
|
3
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
|
-
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
-
import { VideoModel, VideoResponse } from "../video.js";
|
|
7
|
-
import { ProviderShared, optionalArray } from "./shared.js";
|
|
8
|
-
const route = MediaProtocol.identity({ id: "google-video", name: "Google Veo", provider: "google" });
|
|
9
|
-
export const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
10
|
-
/** Veo keeps generated files for two days; the asset carries that deadline so callers materialize in time. */
|
|
11
|
-
const FILE_RETENTION = Duration.days(2);
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// 2. Token and response schemas
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
/** The long-running operation name, e.g. `models/veo-3.1-generate-preview/operations/abc123`. */
|
|
16
|
-
export const Token = Schema.Struct({ operation: Schema.String });
|
|
17
|
-
const StartResponse = Schema.Struct({ name: Schema.String });
|
|
18
|
-
const Operation = Schema.Struct({
|
|
19
|
-
done: Schema.optional(Schema.Boolean),
|
|
20
|
-
error: Schema.optional(Schema.Struct({ code: Schema.optional(Schema.Number), message: Schema.optional(Schema.String) })),
|
|
21
|
-
response: Schema.optional(Schema.Struct({
|
|
22
|
-
generateVideoResponse: Schema.optional(Schema.Struct({
|
|
23
|
-
generatedSamples: optionalArray(Schema.Struct({
|
|
24
|
-
video: Schema.optional(Schema.Struct({
|
|
25
|
-
uri: Schema.optional(Schema.String),
|
|
26
|
-
mimeType: Schema.optional(Schema.String),
|
|
27
|
-
})),
|
|
28
|
-
})),
|
|
29
|
-
raiMediaFilteredCount: Schema.optional(Schema.Number),
|
|
30
|
-
raiMediaFilteredReasons: optionalArray(Schema.String),
|
|
31
|
-
})),
|
|
32
|
-
})),
|
|
33
|
-
metadata: Schema.optional(Schema.Unknown),
|
|
34
|
-
});
|
|
35
|
-
// Operation errors are `google.rpc.Status`; unlisted codes (INTERNAL, UNAVAILABLE, ...) are provider-side.
|
|
36
|
-
const FAILURE = {
|
|
37
|
-
3: "InvalidRequest", // INVALID_ARGUMENT
|
|
38
|
-
7: "Authentication", // PERMISSION_DENIED
|
|
39
|
-
8: "RateLimit", // RESOURCE_EXHAUSTED
|
|
40
|
-
9: "InvalidRequest", // FAILED_PRECONDITION
|
|
41
|
-
11: "InvalidRequest", // OUT_OF_RANGE
|
|
42
|
-
16: "Authentication", // UNAUTHENTICATED
|
|
43
|
-
};
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
// 5. Request body construction
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Veo takes inline media only; a prior Veo output is `Media.url` with transient auth, so materialize it first.
|
|
48
|
-
const inlineMedia = (asset) => ProviderShared.requireInlineMedia(route.name, asset).pipe(Effect.map((inline) => ({ inlineData: { mimeType: inline.mime, data: inline.base64 } })));
|
|
49
|
-
const fromRequest = Effect.fn("GoogleVideo.fromRequest")(function* (request) {
|
|
50
|
-
if (request.n !== undefined && request.n > 1)
|
|
51
|
-
return yield* route.unsupported("video.n", `${route.name} generates one video per request; call it once per video instead of n=${request.n}`);
|
|
52
|
-
if (request.audio === false)
|
|
53
|
-
return yield* route.unsupported("video.audio", `${route.name} always generates audio; audio: false cannot be honored`);
|
|
54
|
-
if (request.frames?.last !== undefined && request.frames.first === undefined)
|
|
55
|
-
return yield* ProviderShared.invalidRequest(`${route.name} requires frames.first when frames.last is set`);
|
|
56
|
-
const image = request.frames?.first === undefined ? undefined : yield* inlineMedia(request.frames.first);
|
|
57
|
-
const lastFrame = request.frames?.last === undefined ? undefined : yield* inlineMedia(request.frames.last);
|
|
58
|
-
const video = request.video === undefined ? undefined : yield* inlineMedia(request.video);
|
|
59
|
-
const referenceImages = yield* Effect.forEach(request.references ?? [], (asset) => inlineMedia(asset).pipe(Effect.map((image) => ({ image, referenceType: "asset" }))));
|
|
60
|
-
return MediaProtocol.json(mergeJsonRecords({
|
|
61
|
-
instances: [
|
|
62
|
-
{
|
|
63
|
-
prompt: request.prompt,
|
|
64
|
-
image,
|
|
65
|
-
lastFrame,
|
|
66
|
-
referenceImages: referenceImages.length === 0 ? undefined : referenceImages,
|
|
67
|
-
video,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
parameters: mergeJsonRecords({
|
|
71
|
-
aspectRatio: request.aspect,
|
|
72
|
-
resolution: request.resolution,
|
|
73
|
-
durationSeconds: request.durationSeconds,
|
|
74
|
-
negativePrompt: request.negativePrompt,
|
|
75
|
-
seed: request.seed,
|
|
76
|
-
}, request.providerOptions),
|
|
77
|
-
}, request.http?.body) ?? {});
|
|
78
|
-
});
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// 6. Response decoding
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
83
|
-
token: { operation: value.name },
|
|
84
|
-
snapshot: { id: value.name, status: "running" },
|
|
85
|
-
}));
|
|
86
|
-
// Operations carry no status string: not done is running, done with `error` failed, otherwise completed.
|
|
87
|
-
const statusOf = (operation) => {
|
|
88
|
-
if (operation.done !== true)
|
|
89
|
-
return "running";
|
|
90
|
-
return operation.error === undefined ? "completed" : "failed";
|
|
91
|
-
};
|
|
92
|
-
const decodeOperation = route.decodeJson(Operation);
|
|
93
|
-
const decodeStatus = Effect.fn("GoogleVideo.decodeStatus")(function* (response, context) {
|
|
94
|
-
const output = yield* decodeOperation(response);
|
|
95
|
-
return { id: context.token.operation, status: statusOf(output.value) };
|
|
96
|
-
});
|
|
97
|
-
const decodeResult = Effect.fn("GoogleVideo.decodeResult")(function* (response, context) {
|
|
98
|
-
const output = yield* decodeOperation(response);
|
|
99
|
-
const operation = output.value;
|
|
100
|
-
const status = statusOf(operation);
|
|
101
|
-
if (status === "running")
|
|
102
|
-
return yield* output.pending(context.token.operation);
|
|
103
|
-
if (status === "failed")
|
|
104
|
-
return yield* output.ended("failed", `${route.name} operation failed${operation.error?.message === undefined ? "" : `: ${operation.error.message}`}`, MediaProtocol.failure(FAILURE, operation.error?.code));
|
|
105
|
-
const generated = operation.response?.generateVideoResponse;
|
|
106
|
-
// Downloads require the same API key as the poll; the asset carries it transiently and follows the redirect.
|
|
107
|
-
const videos = yield* Effect.forEach((generated?.generatedSamples ?? []).flatMap((sample) => sample.video?.uri === undefined ? [] : [{ uri: sample.video.uri, mimeType: sample.video.mimeType }]), (video) => MediaProtocol.expiringUrl(video.uri, FILE_RETENTION, {
|
|
108
|
-
mediaType: video.mimeType ?? "video/mp4",
|
|
109
|
-
headers: context.auth,
|
|
110
|
-
}));
|
|
111
|
-
const reasons = generated?.raiMediaFilteredReasons ?? [];
|
|
112
|
-
if (videos.length === 0 && (reasons.length > 0 || (generated?.raiMediaFilteredCount ?? 0) > 0))
|
|
113
|
-
return yield* output.contentPolicy(`${route.name} filtered every video${reasons.length === 0 ? "" : `: ${reasons.join("; ")}`}`);
|
|
114
|
-
if (videos.length === 0)
|
|
115
|
-
return yield* output.invalid(`${route.name} operation completed without any video`);
|
|
116
|
-
return new VideoResponse({
|
|
117
|
-
videos,
|
|
118
|
-
providerMetadata: {
|
|
119
|
-
google: {
|
|
120
|
-
operation: context.token.operation,
|
|
121
|
-
raiMediaFilteredCount: generated?.raiMediaFilteredCount,
|
|
122
|
-
raiMediaFilteredReasons: generated?.raiMediaFilteredReasons,
|
|
123
|
-
metadata: operation.metadata,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
// 7. Protocol and route
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
const operationPath = (token) => `/${token.operation}`;
|
|
132
|
-
export const protocol = MediaProtocol.queued(route, {
|
|
133
|
-
token: Token,
|
|
134
|
-
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
135
|
-
status: { path: operationPath, decode: decodeStatus },
|
|
136
|
-
result: { path: operationPath, decode: decodeResult },
|
|
137
|
-
});
|
|
138
|
-
export const model = (input) => VideoModel.fromRoute({
|
|
139
|
-
protocol,
|
|
140
|
-
baseURL: DEFAULT_BASE_URL,
|
|
141
|
-
path: ({ request }) => `/models/${request.model.id}:predictLongRunning`,
|
|
142
|
-
}, input);
|
|
143
|
-
export const GoogleVideo = {
|
|
144
|
-
protocol,
|
|
145
|
-
model,
|
|
146
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
3
|
-
import { MediaRoute } from "../route/media.js";
|
|
4
|
-
import { type OpenString } from "../schema/index.js";
|
|
5
|
-
import { VideoModel, VideoResponse, type VideoRequest } from "../video.js";
|
|
6
|
-
export declare const DEFAULT_BASE_URL = "https://api.dev.runwayml.com/v1";
|
|
7
|
-
/** Every Runway request must pin the API version. */
|
|
8
|
-
export declare const API_VERSION = "2024-11-06";
|
|
9
|
-
export declare const TEXT_TO_VIDEO_PATH = "/text_to_video";
|
|
10
|
-
export declare const IMAGE_TO_VIDEO_PATH = "/image_to_video";
|
|
11
|
-
export declare const VIDEO_TO_VIDEO_PATH = "/video_to_video";
|
|
12
|
-
export declare const TASKS_PATH = "/tasks";
|
|
13
|
-
/**
|
|
14
|
-
* Provider-native options. Common fields lower to Runway's names: `aspect` → `ratio` (Runway expects pixel
|
|
15
|
-
* ratios such as `1280:720` for most models), `durationSeconds` → `duration`, `audio`, `negativePrompt`,
|
|
16
|
-
* `resolution`, `references`, and `frames` → `promptImage`.
|
|
17
|
-
*/
|
|
18
|
-
export type RunwayVideoOptions = {
|
|
19
|
-
readonly contentModeration?: {
|
|
20
|
-
readonly publicFigureThreshold?: OpenString<"auto" | "low">;
|
|
21
|
-
};
|
|
22
|
-
readonly outputFormat?: OpenString<"mp4" | "prores" | "png_sequence">;
|
|
23
|
-
} & Record<string, unknown>;
|
|
24
|
-
export type Request = VideoRequest<VideoModel<RunwayVideoOptions>>;
|
|
25
|
-
export declare const Token: Schema.Struct<{
|
|
26
|
-
readonly taskID: Schema.String;
|
|
27
|
-
}>;
|
|
28
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
29
|
-
export declare const protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
30
|
-
readonly taskID: string;
|
|
31
|
-
}>;
|
|
32
|
-
export declare const model: (input: MediaRoute.ModelInput) => VideoModel<RunwayVideoOptions>;
|
|
33
|
-
export declare const RunwayVideo: {
|
|
34
|
-
readonly protocol: MediaProtocol.Queued<Request, VideoResponse, {
|
|
35
|
-
readonly taskID: string;
|
|
36
|
-
}>;
|
|
37
|
-
readonly model: typeof model;
|
|
38
|
-
};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Duration, Effect, Schema } from "effect";
|
|
2
|
-
import { Media } from "../media.js";
|
|
3
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
|
-
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
-
import { VideoModel, VideoResponse } from "../video.js";
|
|
7
|
-
import { ProviderShared, optionalArray, optionalNull } from "./shared.js";
|
|
8
|
-
const route = MediaProtocol.identity({ id: "runway-video", name: "Runway", provider: "runway" });
|
|
9
|
-
export const DEFAULT_BASE_URL = "https://api.dev.runwayml.com/v1";
|
|
10
|
-
/** Every Runway request must pin the API version. */
|
|
11
|
-
export const API_VERSION = "2024-11-06";
|
|
12
|
-
export const TEXT_TO_VIDEO_PATH = "/text_to_video";
|
|
13
|
-
export const IMAGE_TO_VIDEO_PATH = "/image_to_video";
|
|
14
|
-
export const VIDEO_TO_VIDEO_PATH = "/video_to_video";
|
|
15
|
-
export const TASKS_PATH = "/tasks";
|
|
16
|
-
/** Output URLs are valid for 24–48 hours; the asset carries the conservative bound. */
|
|
17
|
-
const OUTPUT_RETENTION = Duration.hours(24);
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
// 2. Token and response schemas
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
export const Token = Schema.Struct({ taskID: Schema.String });
|
|
22
|
-
const Cost = Schema.Struct({ credits: Schema.Number });
|
|
23
|
-
const StartResponse = Schema.Struct({ id: Schema.String });
|
|
24
|
-
const Task = Schema.Struct({
|
|
25
|
-
status: Schema.String,
|
|
26
|
-
progress: optionalNull(Schema.Number),
|
|
27
|
-
output: optionalArray(Schema.String),
|
|
28
|
-
failure: optionalNull(Schema.String),
|
|
29
|
-
failureCode: optionalNull(Schema.String),
|
|
30
|
-
cost: Schema.optional(Cost),
|
|
31
|
-
estimatedCost: Schema.optional(Cost),
|
|
32
|
-
});
|
|
33
|
-
const STATUS = {
|
|
34
|
-
PENDING: "queued",
|
|
35
|
-
THROTTLED: "queued",
|
|
36
|
-
RUNNING: "running",
|
|
37
|
-
SUCCEEDED: "completed",
|
|
38
|
-
FAILED: "failed",
|
|
39
|
-
CANCELLED: "cancelled",
|
|
40
|
-
};
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
// 5. Request body construction
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// Runway accepts HTTPS URLs, `runway://` upload URIs, and data URIs, all as one string.
|
|
45
|
-
const mediaUri = (asset) => ProviderShared.mediaReference(asset, route.provider, route.name).pipe(Effect.map((reference) => reference.value));
|
|
46
|
-
const fromRequest = Effect.fn("RunwayVideo.fromRequest")(function* (request) {
|
|
47
|
-
const first = request.frames?.first === undefined ? undefined : yield* mediaUri(request.frames.first);
|
|
48
|
-
const last = request.frames?.last === undefined ? undefined : yield* mediaUri(request.frames.last);
|
|
49
|
-
const promptImage = [
|
|
50
|
-
...(first === undefined ? [] : [{ uri: first, position: "first" }]),
|
|
51
|
-
...(last === undefined ? [] : [{ uri: last, position: "last" }]),
|
|
52
|
-
];
|
|
53
|
-
const videoUri = request.video === undefined ? undefined : yield* mediaUri(request.video);
|
|
54
|
-
const references = yield* Effect.forEach(request.references ?? [], (asset) => mediaUri(asset).pipe(Effect.map((uri) => ({ uri }))));
|
|
55
|
-
return MediaProtocol.json(mergeJsonRecords({
|
|
56
|
-
model: request.model.id,
|
|
57
|
-
promptText: request.prompt,
|
|
58
|
-
promptImage: promptImage.length === 0 ? undefined : promptImage,
|
|
59
|
-
videoUri,
|
|
60
|
-
references: references.length === 0 ? undefined : references,
|
|
61
|
-
ratio: request.aspect,
|
|
62
|
-
duration: request.durationSeconds,
|
|
63
|
-
resolution: request.resolution,
|
|
64
|
-
audio: request.audio,
|
|
65
|
-
negativePrompt: request.negativePrompt,
|
|
66
|
-
seed: request.seed,
|
|
67
|
-
}, request.providerOptions, request.http?.body) ?? {});
|
|
68
|
-
});
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// 6. Response decoding
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
73
|
-
token: { taskID: value.id },
|
|
74
|
-
snapshot: { id: value.id, status: "queued" },
|
|
75
|
-
}));
|
|
76
|
-
const decodeTask = route.decodeJson(Task);
|
|
77
|
-
const decodeStatus = Effect.fn("RunwayVideo.decodeStatus")(function* (response, context) {
|
|
78
|
-
const output = yield* decodeTask(response);
|
|
79
|
-
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
80
|
-
return { id: context.token.taskID, status, progress: output.value.progress ?? undefined };
|
|
81
|
-
});
|
|
82
|
-
const decodeResult = Effect.fn("RunwayVideo.decodeResult")(function* (response, context) {
|
|
83
|
-
const output = yield* decodeTask(response);
|
|
84
|
-
const task = output.value;
|
|
85
|
-
const status = MediaProtocol.status(STATUS, task.status);
|
|
86
|
-
if (status === "failed") {
|
|
87
|
-
const code = task.failureCode ?? undefined;
|
|
88
|
-
const message = `${route.name} task failed${code === undefined ? "" : ` (${code})`}${task.failure ? `: ${task.failure}` : ""}`;
|
|
89
|
-
// Runway failure codes are dotted paths; every moderation outcome carries a SAFETY segment.
|
|
90
|
-
if (code !== undefined && /(^|\.)SAFETY(\.|$)/.test(code))
|
|
91
|
-
return yield* output.contentPolicy(message);
|
|
92
|
-
// ASSET.INVALID rejects the caller's input media; Runway documents it as not retryable.
|
|
93
|
-
return yield* output.ended("failed", message, code !== undefined && /^ASSET\.INVALID(\.|$)/.test(code) ? "InvalidRequest" : "ProviderInternal");
|
|
94
|
-
}
|
|
95
|
-
if (status === "cancelled")
|
|
96
|
-
return yield* output.ended("cancelled", `${route.name} task ${context.token.taskID} was cancelled`);
|
|
97
|
-
if (status !== "completed")
|
|
98
|
-
return yield* output.pending(context.token.taskID);
|
|
99
|
-
const urls = task.output ?? [];
|
|
100
|
-
if (urls.length === 0)
|
|
101
|
-
return yield* output.invalid(`${route.name} task succeeded without any output`);
|
|
102
|
-
return new VideoResponse({
|
|
103
|
-
videos: yield* Effect.forEach(urls, (url) => MediaProtocol.expiringUrl(url, OUTPUT_RETENTION, { mediaType: "video/mp4" })),
|
|
104
|
-
usage: task.cost === undefined ? undefined : { type: "credits", credits: task.cost.credits },
|
|
105
|
-
providerMetadata: {
|
|
106
|
-
runway: {
|
|
107
|
-
taskId: context.token.taskID,
|
|
108
|
-
estimatedCredits: task.estimatedCost?.credits,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
// 7. Protocol and route
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
const taskPath = (token) => `${TASKS_PATH}/${token.taskID}`;
|
|
117
|
-
export const protocol = MediaProtocol.queued(route, {
|
|
118
|
-
token: Token,
|
|
119
|
-
unsupported: ["n"],
|
|
120
|
-
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
121
|
-
status: { path: taskPath, decode: decodeStatus },
|
|
122
|
-
result: { path: taskPath, decode: decodeResult },
|
|
123
|
-
cancel: { method: "DELETE", path: taskPath, activeOnly: true },
|
|
124
|
-
});
|
|
125
|
-
const startPath = (request) => {
|
|
126
|
-
if (request.video !== undefined)
|
|
127
|
-
return VIDEO_TO_VIDEO_PATH;
|
|
128
|
-
if (request.frames?.first !== undefined || request.frames?.last !== undefined)
|
|
129
|
-
return IMAGE_TO_VIDEO_PATH;
|
|
130
|
-
return TEXT_TO_VIDEO_PATH;
|
|
131
|
-
};
|
|
132
|
-
export const model = (input) => VideoModel.fromRoute({
|
|
133
|
-
protocol,
|
|
134
|
-
baseURL: DEFAULT_BASE_URL,
|
|
135
|
-
headers: { "X-Runway-Version": API_VERSION },
|
|
136
|
-
path: ({ request }) => startPath(request),
|
|
137
|
-
}, input);
|
|
138
|
-
export const RunwayVideo = {
|
|
139
|
-
protocol,
|
|
140
|
-
model,
|
|
141
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
|
-
export type { RunwayVideoOptions } from "../protocols/runway-video.js";
|
|
4
|
-
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
-
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
-
readonly baseURL?: string;
|
|
7
|
-
readonly headers?: Record<string, string>;
|
|
8
|
-
readonly http?: HttpOptions;
|
|
9
|
-
};
|
|
10
|
-
export declare const configure: (input?: Config) => {
|
|
11
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
12
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
|
|
13
|
-
configure: typeof configure;
|
|
14
|
-
};
|
|
15
|
-
export declare const provider: {
|
|
16
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
17
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
|
|
18
|
-
configure: typeof configure;
|
|
19
|
-
};
|
|
20
|
-
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
|
package/dist/providers/runway.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
2
|
-
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import { ProviderID } from "../schema/index.js";
|
|
4
|
-
import { RunwayVideo } from "../protocols/runway-video.js";
|
|
5
|
-
export const id = ProviderID.make("runway");
|
|
6
|
-
const auth = (options) => AuthOptions.bearer(options, "RUNWAYML_API_SECRET");
|
|
7
|
-
export const configure = (input = {}) => {
|
|
8
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
9
|
-
const video = (modelID) => RunwayVideo.model({ ...media, id: modelID });
|
|
10
|
-
return {
|
|
11
|
-
id,
|
|
12
|
-
video,
|
|
13
|
-
configure,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export const provider = configure();
|
|
17
|
-
export const video = provider.video;
|