@mindstone/mcp-server-runway 0.6.0 → 0.8.0
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 +8 -4
- package/dist/client.d.ts +2 -1
- package/dist/client.js +50 -37
- package/dist/file-write-context.d.ts +73 -0
- package/dist/file-write-context.js +50 -0
- package/dist/server.js +2 -1
- package/dist/tools/audio.js +2 -2
- package/dist/tools/image.js +19 -15
- package/dist/tools/resold-models.d.ts +40 -32
- package/dist/tools/resold-models.js +185 -132
- package/dist/tools/resold-specs.generated.d.ts +24 -0
- package/dist/tools/resold-specs.generated.js +46 -0
- package/dist/tools/tasks.js +8 -5
- package/dist/tools/video.js +40 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Runway ML MCP server for Model Context Protocol hosts. Generate AI video, images
|
|
|
7
7
|
|
|
8
8
|
## Status
|
|
9
9
|
|
|
10
|
-
- **Version:** [0.
|
|
10
|
+
- **Version:** [0.8.0](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
|
|
11
11
|
- **Auth:** API key ([`RUNWAYML_API_SECRET`](./server.json))
|
|
12
12
|
- **Tools:** [23](./src/tools/) (video, image, audio, voices, tasks)
|
|
13
13
|
- **Surface:** cloud-api
|
|
@@ -130,11 +130,11 @@ node dist/index.js
|
|
|
130
130
|
- `character_performance` — Animate a character with facial expressions and body movements (Act-Two)
|
|
131
131
|
- `upscale_video` — Upscale a video up to 4K (Magnific Video Upscaler)
|
|
132
132
|
|
|
133
|
-
Video models: `generate_video_from_image` takes `gen4_turbo` (default), `gen4.5`, `veo3.1
|
|
133
|
+
Video models: `generate_video_from_image` takes `gen4_turbo` (default), `gen4.5`, `veo3.1` and `veo3.1_fast`; `generate_video_from_text` takes `gen4.5` (default), `veo3.1` and `veo3.1_fast`. Both also take the models Runway resells: `kling_4` and `kling_4_flash` (Kling 4.0), `seedance2_5` and `seedance2_5_flash` (Seedance 2.5), `gemini_omni_flash_1.2` (Gemini Omni Flash), `hailuo3` and `h3_max` (MiniMax), `wan3` and `wan3_prime` (Wan 3), `grok_imagine_1_5` and `grok_imagine_1_5_lite` (Grok Imagine), and `happyhorse_1_0`. Some of these take a `resolution` (`hailuo3`, `h3_max`, `grok_imagine_1_5`, and `happyhorse_1_0` from an image) instead of, or as well as, a `ratio`. `veo3` is no longer accepted by Runway and is refused before any request; use `veo3.1` or `veo3.1_fast` instead.
|
|
134
134
|
|
|
135
|
-
Image models: `gen4_image` (default), `gen4_image_turbo`, `gemini_2.5_flash`, `gemini_image3_pro` (Nano Banana Pro), `gpt_image_2_6_sunburst` and `gpt_image_2_6_flare` (GPT Image 2.6). Speech models: `eleven_multilingual_v2` (default), `eleven_v3` and `eleven_v4`.
|
|
135
|
+
Image models: `gen4_image` (default), `gen4_image_turbo`, `gemini_2.5_flash`, `gemini_image3_pro` (Nano Banana Pro), `gpt_image_2_6_sunburst` and `gpt_image_2_6_flare` (GPT Image 2.6), `gemini_image3.1_flash` and `gemini_image3.1_flash_lite`, `nano_banana_2.1`, `seedream5.5`, `minimax_h3_image`, `ideogram_4_5`, `grok_imagine_image_2`, `muse_image` and `bria_fibo_1_5`. Speech models: `eleven_multilingual_v2` (default), `eleven_v3` and `eleven_v4`.
|
|
136
136
|
|
|
137
|
-
Each model takes its own ratios, durations and options; anything a model does not take is refused before any request. The models Runway resells from other makers (
|
|
137
|
+
Each model takes its own ratios, durations and options; anything a model does not take is refused before any request. The models Runway resells from other makers (all of the above besides `gen4*`, `veo3.1*` and `gemini_2.5_flash`, plus ElevenLabs v4) were added from Runway's documentation and have not yet been tried against its live API, so a mistake fails for that model only. Their accepted fields and limits are generated from Runway's published API spec: `node scripts/generate-resold-specs.mjs <openapi.json>` rewrites `src/tools/resold-specs.generated.ts`, and `--check` compares it; defaults and prices are kept by hand in `src/tools/resold-models.ts`.
|
|
138
138
|
|
|
139
139
|
### Image
|
|
140
140
|
- `generate_image` — Generate an image from text, optionally with reference images
|
|
@@ -180,3 +180,7 @@ list, stops the read.
|
|
|
180
180
|
Clients that do not negotiate this extension keep the connector's existing
|
|
181
181
|
standalone file restrictions. This extension changes input-read permissions;
|
|
182
182
|
existing output destinations, upload formats, size limits and file checks apply.
|
|
183
|
+
|
|
184
|
+
### Host-authorised local saves
|
|
185
|
+
|
|
186
|
+
When a host negotiates experimental `files/writeModes` version 1, declared save destinations use the canonical file or parent folder authorised for that concrete argument in the call's `files/writeMode` metadata. The host's path permissions apply instead of the connector's standalone path policy. File type, size, identity, exclusive-create and overwrite mechanics still apply. Clients that do not negotiate this protocol, or select standalone mode, retain the existing sandbox.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FileWriteContext } from './file-write-context.js';
|
|
1
2
|
import { type FileReadContext } from './file-read-context.js';
|
|
2
3
|
/** Envelope source label for Runway-authored text (error bodies, task failures). */
|
|
3
4
|
export declare const RUNWAY_API_SOURCE = "runway-api";
|
|
@@ -27,7 +28,7 @@ export declare function assertPathInAllowedRoot(input: string): string;
|
|
|
27
28
|
* directory if missing so the default `~/Downloads/runway-mcp` works
|
|
28
29
|
* out-of-the-box.
|
|
29
30
|
*/
|
|
30
|
-
export declare function assertDownloadPathInRoot(outputPath: string): {
|
|
31
|
+
export declare function assertDownloadPathInRoot(outputPath: string, context?: FileWriteContext): {
|
|
31
32
|
resolved: string;
|
|
32
33
|
root: string;
|
|
33
34
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { centralWritePath, isAuthorisedWriteParent } from './file-write-context.js';
|
|
1
2
|
import { centralReadPath } from './file-read-context.js';
|
|
2
3
|
/**
|
|
3
4
|
* Runway API HTTP client.
|
|
@@ -190,44 +191,56 @@ function isPathInDenyList(resolvedAbs) {
|
|
|
190
191
|
* directory if missing so the default `~/Downloads/runway-mcp` works
|
|
191
192
|
* out-of-the-box.
|
|
192
193
|
*/
|
|
193
|
-
export function assertDownloadPathInRoot(outputPath) {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
194
|
+
export function assertDownloadPathInRoot(outputPath, context) {
|
|
195
|
+
const allowed = centralWritePath(context, outputPath, ['output_path']);
|
|
196
|
+
let resolved;
|
|
197
|
+
let realRoot;
|
|
198
|
+
if (allowed === undefined) {
|
|
199
|
+
const lexicalRoot = getDownloadRoot();
|
|
200
|
+
// Auto-create the configured root so the default just works. Tolerate
|
|
201
|
+
// failures here — they'll surface later when we try to canonicalise it.
|
|
202
|
+
try {
|
|
203
|
+
fs.mkdirSync(lexicalRoot, { recursive: true });
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
/* tolerate; realpath below will fail with a clear error */
|
|
207
|
+
}
|
|
208
|
+
realRoot = fs.realpathSync(lexicalRoot);
|
|
209
|
+
const lexical = path.resolve(outputPath);
|
|
210
|
+
const lexicalParent = path.dirname(lexical);
|
|
211
|
+
const denyMessage = `Output path is outside the RUNWAY_DOWNLOAD_ROOT sandbox: ${outputPath}`;
|
|
212
|
+
const denyResolution = `Set ${RUNWAY_DOWNLOAD_ROOT_ENV} to a directory that contains the target file, ` +
|
|
213
|
+
`or pick an output_path inside ${realRoot}.`;
|
|
214
|
+
const isUnder = (p, root) => p === root || p.startsWith(root + path.sep);
|
|
215
|
+
// (1) Lexical check — catches `..` traversal and "completely outside"
|
|
216
|
+
// paths regardless of filesystem state.
|
|
217
|
+
if (!isUnder(lexicalParent, lexicalRoot) && !isUnder(lexicalParent, realRoot)) {
|
|
218
|
+
throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
|
|
219
|
+
}
|
|
220
|
+
// (2) Realpath check on the parent dir — catches symlink-escape.
|
|
221
|
+
let realParent;
|
|
222
|
+
try {
|
|
223
|
+
realParent = fs.realpathSync(lexicalParent);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
throw new RunwayError(`Parent directory does not exist or is not accessible: ${lexicalParent}`, 'OUTPUT_PARENT_NOT_FOUND', `Create ${lexicalParent} first, or pick an output_path inside ${realRoot}.`);
|
|
227
|
+
}
|
|
228
|
+
if (!isUnder(realParent, realRoot)) {
|
|
229
|
+
throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
|
|
230
|
+
}
|
|
231
|
+
resolved = path.join(realParent, path.basename(lexical));
|
|
232
|
+
// (3) Static deny-list — applies even when nominally inside the root.
|
|
233
|
+
const denied = isPathInDenyList(resolved);
|
|
234
|
+
if (denied.hit) {
|
|
235
|
+
throw new RunwayError(`Output path matches the sensitive deny-list and is refused: ${outputPath}`, 'OUTPUT_PATH_DENY_LISTED', `Refused: ${denied.reason}. Paths under ~/.ssh, ~/.aws, /etc, and shell rc files (~/.bashrc, ~/.zshrc) cannot be overwritten by Runway downloads even when ${RUNWAY_DOWNLOAD_ROOT_ENV} would otherwise permit it.`);
|
|
236
|
+
}
|
|
225
237
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
else {
|
|
239
|
+
resolved = allowed;
|
|
240
|
+
realRoot = path.dirname(allowed);
|
|
241
|
+
if (!isAuthorisedWriteParent(realRoot)) {
|
|
242
|
+
throw new RunwayError(`Authorised parent directory is missing, inaccessible or changed: ${realRoot}`, 'OUTPUT_PARENT_NOT_FOUND', 'Create the destination folder if needed, then retry the call to authorise it again.');
|
|
243
|
+
}
|
|
231
244
|
}
|
|
232
245
|
// (4) Refuse to write through a non-regular-file existing target.
|
|
233
246
|
//
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Negotiation is connection-scoped; authority belongs to one SDK request. */
|
|
3
|
+
export declare const FILE_WRITE_CAPABILITIES: {
|
|
4
|
+
experimental: {
|
|
5
|
+
'files/writeModes': {
|
|
6
|
+
version: number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function fileReadWriteCapabilities(readCapabilities: {
|
|
11
|
+
experimental: Record<string, unknown>;
|
|
12
|
+
}, experimental?: Record<string, unknown>): {
|
|
13
|
+
experimental: {
|
|
14
|
+
'files/writeModes': {
|
|
15
|
+
version: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/** A missing or redirected parent is mapped to the connector's own error. */
|
|
20
|
+
export declare function isAuthorisedWriteParent(parent: string): boolean;
|
|
21
|
+
export declare const writeModeSchema: z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
|
|
22
|
+
version: z.ZodLiteral<1>;
|
|
23
|
+
mode: z.ZodLiteral<"central">;
|
|
24
|
+
writes: z.ZodArray<z.ZodObject<{
|
|
25
|
+
location: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
|
|
26
|
+
rawPath: z.ZodString;
|
|
27
|
+
canonicalPath: z.ZodEffects<z.ZodString, string, string>;
|
|
28
|
+
target: z.ZodEnum<["file", "parent"]>;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
location: (string | number)[];
|
|
31
|
+
rawPath: string;
|
|
32
|
+
canonicalPath: string;
|
|
33
|
+
target: "parent" | "file";
|
|
34
|
+
}, {
|
|
35
|
+
location: (string | number)[];
|
|
36
|
+
rawPath: string;
|
|
37
|
+
canonicalPath: string;
|
|
38
|
+
target: "parent" | "file";
|
|
39
|
+
}>, "many">;
|
|
40
|
+
}, "strict", z.ZodTypeAny, {
|
|
41
|
+
version: 1;
|
|
42
|
+
mode: "central";
|
|
43
|
+
writes: {
|
|
44
|
+
location: (string | number)[];
|
|
45
|
+
rawPath: string;
|
|
46
|
+
canonicalPath: string;
|
|
47
|
+
target: "parent" | "file";
|
|
48
|
+
}[];
|
|
49
|
+
}, {
|
|
50
|
+
version: 1;
|
|
51
|
+
mode: "central";
|
|
52
|
+
writes: {
|
|
53
|
+
location: (string | number)[];
|
|
54
|
+
rawPath: string;
|
|
55
|
+
canonicalPath: string;
|
|
56
|
+
target: "parent" | "file";
|
|
57
|
+
}[];
|
|
58
|
+
}>, z.ZodObject<{
|
|
59
|
+
version: z.ZodLiteral<1>;
|
|
60
|
+
mode: z.ZodLiteral<"standalone">;
|
|
61
|
+
}, "strict", z.ZodTypeAny, {
|
|
62
|
+
version: 1;
|
|
63
|
+
mode: "standalone";
|
|
64
|
+
}, {
|
|
65
|
+
version: 1;
|
|
66
|
+
mode: "standalone";
|
|
67
|
+
}>]>;
|
|
68
|
+
export type FileWriteContext = z.infer<typeof writeModeSchema>;
|
|
69
|
+
/** Pass SDK extra here, never model arguments or arguments._meta. */
|
|
70
|
+
export declare function fileWriteContext(capabilities: unknown, extra: unknown): FileWriteContext;
|
|
71
|
+
/** For parent outputs the canonical path is the authorised folder itself. */
|
|
72
|
+
export declare function centralWritePath(context: FileWriteContext | undefined, rawPath: string, location: (string | number)[], target?: 'file' | 'parent'): string | undefined;
|
|
73
|
+
//# sourceMappingURL=file-write-context.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { isAbsolute } from 'node:path';
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
4
|
+
/** Negotiation is connection-scoped; authority belongs to one SDK request. */
|
|
5
|
+
export const FILE_WRITE_CAPABILITIES = { experimental: { 'files/writeModes': { version: 1 } } };
|
|
6
|
+
export function fileReadWriteCapabilities(readCapabilities, experimental = {}) {
|
|
7
|
+
return { experimental: { ...readCapabilities.experimental, ...FILE_WRITE_CAPABILITIES.experimental, ...experimental } };
|
|
8
|
+
}
|
|
9
|
+
/** A missing or redirected parent is mapped to the connector's own error. */
|
|
10
|
+
export function isAuthorisedWriteParent(parent) {
|
|
11
|
+
try {
|
|
12
|
+
return realpathSync(parent) === parent;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const locationSchema = z.array(z.union([z.string(), z.number().int().nonnegative()]));
|
|
19
|
+
const allowedWriteSchema = z.object({
|
|
20
|
+
location: locationSchema, rawPath: z.string(), canonicalPath: z.string().refine(isAbsolute),
|
|
21
|
+
target: z.enum(['file', 'parent']),
|
|
22
|
+
}).strict();
|
|
23
|
+
export const writeModeSchema = z.discriminatedUnion('mode', [
|
|
24
|
+
z.object({ version: z.literal(1), mode: z.literal('central'), writes: z.array(allowedWriteSchema) }).strict(),
|
|
25
|
+
z.object({ version: z.literal(1), mode: z.literal('standalone') }).strict(),
|
|
26
|
+
]);
|
|
27
|
+
const capabilitiesSchema = z.object({ experimental: z.object({
|
|
28
|
+
'files/writeModes': z.object({ version: z.literal(1) }).passthrough(),
|
|
29
|
+
}).passthrough() }).passthrough();
|
|
30
|
+
const extraSchema = z.object({ _meta: z.object({ 'files/writeMode': writeModeSchema }).passthrough() }).passthrough();
|
|
31
|
+
/** Pass SDK extra here, never model arguments or arguments._meta. */
|
|
32
|
+
export function fileWriteContext(capabilities, extra) {
|
|
33
|
+
if (!capabilitiesSchema.safeParse(capabilities).success)
|
|
34
|
+
return { version: 1, mode: 'standalone' };
|
|
35
|
+
const parsed = extraSchema.safeParse(extra);
|
|
36
|
+
if (!parsed.success)
|
|
37
|
+
throw new Error('Negotiated file writes require valid request files/writeMode metadata.');
|
|
38
|
+
return parsed.data._meta['files/writeMode'];
|
|
39
|
+
}
|
|
40
|
+
/** For parent outputs the canonical path is the authorised folder itself. */
|
|
41
|
+
export function centralWritePath(context, rawPath, location, target = 'file') {
|
|
42
|
+
if (!context || context.mode === 'standalone')
|
|
43
|
+
return undefined;
|
|
44
|
+
const matches = context.writes.filter(write => write.rawPath === rawPath && write.target === target &&
|
|
45
|
+
write.location.length === location.length && write.location.every((part, index) => part === location[index]));
|
|
46
|
+
if (matches.length !== 1)
|
|
47
|
+
throw new Error('Central file write requires exactly one allowed concrete operand.');
|
|
48
|
+
return matches[0].canonicalPath;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=file-write-context.js.map
|
package/dist/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileReadWriteCapabilities } from './file-write-context.js';
|
|
1
2
|
import { FILE_READ_CAPABILITIES } from './file-read-context.js';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
@@ -19,7 +20,7 @@ export function createServer() {
|
|
|
19
20
|
const server = new RunwayMcpServer({
|
|
20
21
|
name: 'runway-mcp-server',
|
|
21
22
|
version: pkg.version,
|
|
22
|
-
}, { capabilities: FILE_READ_CAPABILITIES });
|
|
23
|
+
}, { capabilities: fileReadWriteCapabilities(FILE_READ_CAPABILITIES) });
|
|
23
24
|
registerConfigureTools(server);
|
|
24
25
|
registerVideoTools(server);
|
|
25
26
|
registerImageTools(server);
|
package/dist/tools/audio.js
CHANGED
|
@@ -69,7 +69,7 @@ export function registerAudioTools(server) {
|
|
|
69
69
|
// ── Sound Effect ──────────────────────────────────────────────────────
|
|
70
70
|
server.registerTool('generate_sound_effect', {
|
|
71
71
|
description: 'Generate sound effects from a text description. ' +
|
|
72
|
-
'COST: 1 credit per
|
|
72
|
+
'COST: 1 credit per second of audio, or 2 credits when the duration is left out. WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
|
|
73
73
|
inputSchema: z.object({
|
|
74
74
|
prompt_text: z.string().max(3000).describe('Describe the sound effect. Max 3000 chars.'),
|
|
75
75
|
duration: z.number().optional().describe('Duration in seconds (0.5-30). Auto-determined if omitted.'),
|
|
@@ -85,7 +85,7 @@ export function registerAudioTools(server) {
|
|
|
85
85
|
const result = await runwayFetch('/sound_effect', { method: 'POST', body: JSON.stringify(body) });
|
|
86
86
|
return JSON.stringify({
|
|
87
87
|
ok: true, task_id: result.id, status: 'PENDING',
|
|
88
|
-
cost_rate: '1 credit per
|
|
88
|
+
cost_rate: args.duration !== undefined ? '1 credit per second of audio' : '2 credits',
|
|
89
89
|
message: `Sound effect generation started. Poll with check_runway_task("${result.id}") every 10s, or use wait_for_runway_task.`,
|
|
90
90
|
});
|
|
91
91
|
}));
|
package/dist/tools/image.js
CHANGED
|
@@ -3,33 +3,35 @@ import { z } from 'zod';
|
|
|
3
3
|
import { runwayFetch, resolveMediaInput, addContentModeration } from '../client.js';
|
|
4
4
|
import { RunwayError } from '../types.js';
|
|
5
5
|
import { withErrorHandling } from '../utils.js';
|
|
6
|
-
import {
|
|
7
|
-
// Runway's own and Gemini 2.5 models keep the ratios they always took;
|
|
8
|
-
//
|
|
6
|
+
import { RESOLD_IMAGE_MODELS, isResoldImageModel, resoldImageFields } from './resold-models.js';
|
|
7
|
+
// Runway's own and Gemini 2.5 models keep the ratios they always took; each
|
|
8
|
+
// resold model's ratios are checked against its own spec in resold-models.ts.
|
|
9
9
|
const RUNWAY_IMAGE_RATIOS = [
|
|
10
10
|
'1024:1024', '1080:1080', '1168:880', '1360:768', '1440:1080',
|
|
11
11
|
'1080:1440', '1808:768', '1920:1080', '1080:1920', '2112:912',
|
|
12
12
|
'1280:720', '720:1280', '720:720', '960:720', '720:960', '1680:720',
|
|
13
13
|
];
|
|
14
|
-
const IMAGE_RATIOS = [...new Set([
|
|
15
|
-
...RUNWAY_IMAGE_RATIOS, ...IMAGE_SPECS.gemini_image3_pro.ratios, ...IMAGE_SPECS.gpt_image_2_6_sunburst.ratios,
|
|
16
|
-
])];
|
|
17
14
|
export function registerImageTools(server) {
|
|
18
15
|
server.registerTool('generate_image', {
|
|
19
16
|
description: 'Generate an image from text, optionally with reference images for style/content guidance. ' +
|
|
20
17
|
'MODELS: gen4_image (high quality), gen4_image_turbo (fast/cheap), gemini_2.5_flash (Google Gemini), ' +
|
|
21
|
-
'gemini_image3_pro (Nano Banana Pro, up to 4K), gpt_image_2_6_sunburst and gpt_image_2_6_flare (OpenAI GPT Image 2.6, up to 4K)
|
|
22
|
-
'
|
|
18
|
+
'gemini_image3_pro (Nano Banana Pro, up to 4K), gpt_image_2_6_sunburst and gpt_image_2_6_flare (OpenAI GPT Image 2.6, up to 4K), ' +
|
|
19
|
+
'gemini_image3.1_flash (512px to 4K), gemini_image3.1_flash_lite (1K, cheap), nano_banana_2.1 (1K to 4K), seedream5.5 (ByteDance, 1K to 2K), ' +
|
|
20
|
+
'minimax_h3_image (1K to 4K, up to 16 references), ideogram_4_5 (strong at text in images), grok_imagine_image_2 (xAI, 1K/2K), ' +
|
|
21
|
+
'muse_image (cheapest, 1 credit), bria_fibo_1_5 (1MP/4MP, takes a seed). ' +
|
|
22
|
+
'Models made by others take only their own options; a wrong one is refused with the reason, nothing is charged. Their prices are estimated from Runway\'s published rates. ' +
|
|
23
|
+
'REFERENCE IMAGES: Tag with short label (e.g., "cat"), use @tag in prompt. Tags work with gen4, gemini and nano_banana models. ' +
|
|
24
|
+
'gpt_image_2_6 takes tags but ignores them, and the other models made by others refuse them: with those, refer to references by order ("the first image"). ' +
|
|
23
25
|
'WORKFLOW: Returns task_id → poll with check_runway_task or use wait_for_runway_task.',
|
|
24
26
|
_meta: { 'files/readInputs': { version: 1, inputs: [{ selector: ['reference_images', '*', 'uri'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }] } },
|
|
25
27
|
inputSchema: z.object({
|
|
26
28
|
prompt_text: z.string().describe('Text description. Use @tag to reference images (gpt_image_2_6: "the first image", "the second image").'),
|
|
27
|
-
model: z.enum(['gen4_image', 'gen4_image_turbo', 'gemini_2.5_flash',
|
|
28
|
-
ratio: z.
|
|
29
|
+
model: z.enum(['gen4_image', 'gen4_image_turbo', 'gemini_2.5_flash', ...RESOLD_IMAGE_MODELS]).optional().describe('Default: gen4_image.'),
|
|
30
|
+
ratio: z.string().optional().describe('Output size as W:H. Each model takes its own set; an unsupported one is refused with the list. Default: 1920:1080 for Runway models; about 16:9 at 1K for the others (gpt_image_2_6: 1920:1088). gpt_image_2_6, ideogram_4_5 and muse_image also take auto; ideogram_4_5 with reference images takes 1024:576 in place of 1280:720 (likewise 576:1024, 1408:704, 704:1408).'),
|
|
29
31
|
reference_images: z.array(z.object({
|
|
30
32
|
uri: z.string().describe('HTTPS URL, Runway URI, or local file path.'),
|
|
31
33
|
tag: z.string().optional().describe('Tag for @mention in prompt. 3-16 lowercase chars.'),
|
|
32
|
-
})).min(1).max(16).optional().describe('Optional reference images: 1-3
|
|
34
|
+
})).min(1).max(16).optional().describe('Optional reference images: 1-3 for Runway models; up to 16 for gpt_image_2_6 and minimax_h3_image, 14 for gemini models, 10 for seedream5.5 and muse_image, 5 ideogram_4_5, 3 grok_imagine_image_2, 1 bria_fibo_1_5.'),
|
|
33
35
|
content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
|
|
34
36
|
seed: z.number().int().optional().describe('Random seed (0-4294967295).'),
|
|
35
37
|
}),
|
|
@@ -50,7 +52,7 @@ export function registerImageTools(server) {
|
|
|
50
52
|
throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${RUNWAY_IMAGE_RATIOS.join(', ')}.`);
|
|
51
53
|
}
|
|
52
54
|
const seed = args.seed;
|
|
53
|
-
const body = { model, promptText: args.prompt_text, ratio };
|
|
55
|
+
const body = { model, promptText: args.prompt_text, ratio, ...resold?.fields };
|
|
54
56
|
if (refs && refs.length > 0) {
|
|
55
57
|
const resolvedRefs = [];
|
|
56
58
|
for (const [index, r] of refs.entries()) {
|
|
@@ -58,9 +60,11 @@ export function registerImageTools(server) {
|
|
|
58
60
|
}
|
|
59
61
|
body.referenceImages = resolvedRefs;
|
|
60
62
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (!resold) {
|
|
64
|
+
if (seed !== undefined)
|
|
65
|
+
body.seed = seed;
|
|
66
|
+
addContentModeration(body, args.content_moderation);
|
|
67
|
+
}
|
|
64
68
|
const result = await runwayFetch('/text_to_image', { method: 'POST', body: JSON.stringify(body) });
|
|
65
69
|
const is1080p = ['1920:1080', '1080:1920', '1440:1080', '1080:1440'].includes(ratio);
|
|
66
70
|
const credits = resold ? resold.credits : model === 'gen4_image_turbo' ? 2 : model === 'gemini_2.5_flash' ? 5 : (is1080p ? 8 : 5);
|
|
@@ -1,53 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ResoldFieldSpec } from './resold-specs.generated.js';
|
|
2
|
+
export declare const RESOLD_VIDEO_MODELS: readonly ["kling_4", "kling_4_flash", "seedance2_5", "seedance2_5_flash", "gemini_omni_flash_1.2", "hailuo3", "h3_max", "wan3", "wan3_prime", "grok_imagine_1_5", "grok_imagine_1_5_lite", "happyhorse_1_0"];
|
|
2
3
|
export type ResoldVideoModel = (typeof RESOLD_VIDEO_MODELS)[number];
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
label: string;
|
|
6
|
-
imageRatios: readonly string[];
|
|
7
|
-
textRatios: readonly string[];
|
|
8
|
-
defaultImageRatio: string;
|
|
9
|
-
defaultTextRatio: string;
|
|
10
|
-
minDuration: number;
|
|
11
|
-
maxDuration: number;
|
|
12
|
-
defaultDuration: number;
|
|
13
|
-
options: readonly VideoOption[];
|
|
14
|
-
maxPromptChars: number;
|
|
15
|
-
creditsPerSecond: (ratio: string) => number;
|
|
16
|
-
minimumCredits: number;
|
|
17
|
-
}
|
|
18
|
-
export declare const VIDEO_SPECS: Record<ResoldVideoModel, VideoSpec>;
|
|
4
|
+
export declare const RESOLD_IMAGE_MODELS: readonly ["gemini_image3_pro", "gpt_image_2_6_sunburst", "gpt_image_2_6_flare", "gemini_image3.1_flash", "gemini_image3.1_flash_lite", "nano_banana_2.1", "seedream5.5", "minimax_h3_image", "ideogram_4_5", "grok_imagine_image_2", "muse_image", "bria_fibo_1_5"];
|
|
5
|
+
export type ResoldImageModel = (typeof RESOLD_IMAGE_MODELS)[number];
|
|
19
6
|
export declare function isResoldVideoModel(model: string): model is ResoldVideoModel;
|
|
7
|
+
export declare function isResoldImageModel(model: string): model is ResoldImageModel;
|
|
8
|
+
export declare function videoSpec(model: ResoldVideoModel, kind: 'image' | 'text'): ResoldFieldSpec;
|
|
9
|
+
export declare function tierOf(ratio: string, tiers: readonly string[], pixels: Record<string, number>, overrides?: Record<string, string>): string;
|
|
10
|
+
interface VideoPricing {
|
|
11
|
+
/** Sent when the caller gives none, so the estimate matches what Runway bills. */
|
|
12
|
+
image: {
|
|
13
|
+
ratio?: string;
|
|
14
|
+
resolution?: string;
|
|
15
|
+
};
|
|
16
|
+
text: {
|
|
17
|
+
ratio?: string;
|
|
18
|
+
resolution?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Credits per second of output, by tier. */
|
|
21
|
+
rates: Record<string, number>;
|
|
22
|
+
minimum?: number;
|
|
23
|
+
/** Credits for each input frame (first and last). */
|
|
24
|
+
perFrame?: number;
|
|
25
|
+
tierOverrides?: Record<string, string>;
|
|
26
|
+
/** Ratios allowed from an image, where Runway's spec narrows its list in prose. */
|
|
27
|
+
imageRatios?: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export declare const VIDEO_PRICING: Record<ResoldVideoModel, VideoPricing>;
|
|
20
30
|
/**
|
|
21
|
-
* Check a resold model's prompt, ratio, duration and options,
|
|
22
|
-
* fields to send
|
|
23
|
-
*
|
|
31
|
+
* Check a resold model's prompt, ratio, resolution, duration, frames and options,
|
|
32
|
+
* and return the body fields to send (besides model, promptImage and promptText)
|
|
33
|
+
* with the estimated credits. Throws INVALID_INPUT, naming the model, for
|
|
34
|
+
* anything its spec does not allow, before any request is made.
|
|
24
35
|
*/
|
|
25
36
|
export declare function resoldVideoFields(model: ResoldVideoModel, kind: 'image' | 'text', args: {
|
|
26
37
|
prompt_text?: string;
|
|
27
38
|
ratio?: string;
|
|
39
|
+
resolution?: string;
|
|
28
40
|
duration?: number;
|
|
41
|
+
last_frame_image?: string;
|
|
29
42
|
audio?: boolean;
|
|
30
43
|
seed?: number;
|
|
31
44
|
negative_prompt?: string;
|
|
32
45
|
content_moderation?: string;
|
|
33
46
|
}): {
|
|
34
|
-
|
|
47
|
+
fields: Record<string, unknown>;
|
|
35
48
|
duration: number;
|
|
36
|
-
extra: Record<string, unknown>;
|
|
37
49
|
credits: number;
|
|
38
50
|
};
|
|
39
|
-
|
|
40
|
-
export type ResoldImageModel = (typeof RESOLD_IMAGE_MODELS)[number];
|
|
41
|
-
interface ImageSpec {
|
|
42
|
-
ratios: readonly string[];
|
|
51
|
+
interface ImagePricing {
|
|
43
52
|
defaultRatio: string;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
credits: (ratio: string) => number;
|
|
53
|
+
credits: (ratio: string, references: number) => number;
|
|
54
|
+
/** Sizes Runway swaps for others when reference images are given (each listed size is used only in its own mode). */
|
|
55
|
+
withReferences?: Record<string, string>;
|
|
48
56
|
}
|
|
49
|
-
export declare const
|
|
50
|
-
export declare function isResoldImageModel(model: string): model is ResoldImageModel;
|
|
57
|
+
export declare const IMAGE_PRICING: Record<ResoldImageModel, ImagePricing>;
|
|
51
58
|
/** Check a resold image model's prompt, ratio, references and options; throws INVALID_INPUT naming the model. */
|
|
52
59
|
export declare function resoldImageFields(model: ResoldImageModel, args: {
|
|
53
60
|
prompt_text: string;
|
|
@@ -59,6 +66,7 @@ export declare function resoldImageFields(model: ResoldImageModel, args: {
|
|
|
59
66
|
}>;
|
|
60
67
|
}): {
|
|
61
68
|
ratio: string;
|
|
69
|
+
fields: Record<string, unknown>;
|
|
62
70
|
credits: number;
|
|
63
71
|
};
|
|
64
72
|
export {};
|
|
@@ -1,178 +1,231 @@
|
|
|
1
1
|
import { RunwayError } from '../types.js';
|
|
2
|
-
|
|
3
|
-
//
|
|
2
|
+
import { IMAGE_TO_VIDEO, TEXT_TO_VIDEO, TEXT_TO_IMAGE } from './resold-specs.generated.js';
|
|
3
|
+
// Models Runway resells from other makers. Most of their API schemas reject
|
|
4
|
+
// request fields they do not list (additionalProperties: false), so the
|
|
4
5
|
// connector sends a resold model only the fields its own spec allows, and
|
|
5
|
-
// refuses any other option with a plain message naming the model
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// refuses any other option with a plain message naming the model, before any
|
|
7
|
+
// upload or request. The fields and limits come from Runway's published API
|
|
8
|
+
// spec (resold-specs.generated.ts); the defaults and prices below are typed by
|
|
9
|
+
// hand from Runway's pricing guide (docs.dev.runwayml.com/guides/pricing).
|
|
10
|
+
// These models were added from the documentation and never called (FOX-12868),
|
|
11
|
+
// so a mistake here fails for that one model only.
|
|
12
|
+
export const RESOLD_VIDEO_MODELS = [
|
|
13
|
+
'kling_4', 'kling_4_flash', 'seedance2_5', 'seedance2_5_flash', 'gemini_omni_flash_1.2', 'hailuo3', 'h3_max',
|
|
14
|
+
'wan3', 'wan3_prime', 'grok_imagine_1_5', 'grok_imagine_1_5_lite', 'happyhorse_1_0',
|
|
15
|
+
];
|
|
16
|
+
export const RESOLD_IMAGE_MODELS = [
|
|
17
|
+
'gemini_image3_pro', 'gpt_image_2_6_sunburst', 'gpt_image_2_6_flare', 'gemini_image3.1_flash', 'gemini_image3.1_flash_lite',
|
|
18
|
+
'nano_banana_2.1', 'seedream5.5', 'minimax_h3_image', 'ideogram_4_5', 'grok_imagine_image_2', 'muse_image', 'bria_fibo_1_5',
|
|
14
19
|
];
|
|
15
|
-
const SEEDANCE_RATIOS = SEEDANCE_TIERS.flatMap(([, ratios]) => ratios);
|
|
16
|
-
export const VIDEO_SPECS = {
|
|
17
|
-
kling_4: {
|
|
18
|
-
label: 'Kling 4.0',
|
|
19
|
-
imageRatios: ['auto_720p', 'auto_1080p'],
|
|
20
|
-
textRatios: ['1280:720', '720:1280', '940:940', '1460:624', '1920:1080', '1080:1920', '1440:1440', '2200:940', 'auto_720p', 'auto_1080p'],
|
|
21
|
-
defaultImageRatio: 'auto_720p',
|
|
22
|
-
defaultTextRatio: '1280:720',
|
|
23
|
-
minDuration: 3,
|
|
24
|
-
maxDuration: 30,
|
|
25
|
-
defaultDuration: 5,
|
|
26
|
-
options: [],
|
|
27
|
-
maxPromptChars: 26000,
|
|
28
|
-
// List price; Runway charges 20% less until 30 Nov 2026.
|
|
29
|
-
creditsPerSecond: (ratio) => (KLING_4_1080P.has(ratio) ? 23.5 : 15.7),
|
|
30
|
-
minimumCredits: 0,
|
|
31
|
-
},
|
|
32
|
-
seedance2_5: {
|
|
33
|
-
label: 'Seedance 2.5',
|
|
34
|
-
imageRatios: SEEDANCE_RATIOS,
|
|
35
|
-
textRatios: SEEDANCE_RATIOS,
|
|
36
|
-
defaultImageRatio: '1280:720',
|
|
37
|
-
defaultTextRatio: '1280:720',
|
|
38
|
-
minDuration: 4,
|
|
39
|
-
maxDuration: 30,
|
|
40
|
-
defaultDuration: 5,
|
|
41
|
-
options: ['audio', 'seed'],
|
|
42
|
-
maxPromptChars: 15000,
|
|
43
|
-
creditsPerSecond: (ratio) => SEEDANCE_TIERS.find(([, ratios]) => ratios.includes(ratio))?.[0] ?? 30,
|
|
44
|
-
minimumCredits: 80,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
20
|
export function isResoldVideoModel(model) {
|
|
48
21
|
return RESOLD_VIDEO_MODELS.includes(model);
|
|
49
22
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
export function isResoldImageModel(model) {
|
|
24
|
+
return RESOLD_IMAGE_MODELS.includes(model);
|
|
25
|
+
}
|
|
26
|
+
export function videoSpec(model, kind) {
|
|
27
|
+
return (kind === 'image' ? IMAGE_TO_VIDEO : TEXT_TO_VIDEO)[model];
|
|
28
|
+
}
|
|
29
|
+
// ── Price tiers ────────────────────────────────────────────────────────
|
|
30
|
+
// Runway prices a ratio by the resolution it belongs to. A ratio named auto_<tier>
|
|
31
|
+
// is that tier; any other W:H is the tier nearest its pixel count (checked
|
|
32
|
+
// against every listed ratio in resold-models.test.ts), unless overridden.
|
|
33
|
+
const VIDEO_TIER_PIXELS = {
|
|
34
|
+
'360p': 640 * 360, '480p': 854 * 480, '720p': 1280 * 720, '768p': 1366 * 768, '1080p': 1920 * 1080, '2k': 2560 * 1440, '4k': 3840 * 2160,
|
|
35
|
+
};
|
|
36
|
+
const IMAGE_TIER_PIXELS = {
|
|
37
|
+
'512': 512 * 512, '1k': 1024 * 1024, '1.5k': 1536 * 1536, '2k': 2048 * 2048, '4k': 4096 * 4096,
|
|
38
|
+
};
|
|
39
|
+
export function tierOf(ratio, tiers, pixels, overrides = {}) {
|
|
40
|
+
if (overrides[ratio])
|
|
41
|
+
return overrides[ratio];
|
|
42
|
+
if (tiers.length === 1)
|
|
43
|
+
return tiers[0];
|
|
44
|
+
const named = ratio.match(/^auto_(.+)$/)?.[1];
|
|
45
|
+
if (named && tiers.includes(named))
|
|
46
|
+
return named;
|
|
47
|
+
const [w, h] = ratio.split(':').map(Number);
|
|
48
|
+
const distance = (tier) => Math.abs(Math.log((w * h) / pixels[tier]));
|
|
49
|
+
return tiers.reduce((best, tier) => (distance(tier) < distance(best) ? tier : best));
|
|
50
|
+
}
|
|
51
|
+
const WIDE = { image: { ratio: 'auto_720p' }, text: { ratio: '1280:720' } };
|
|
52
|
+
export const VIDEO_PRICING = {
|
|
53
|
+
// List price; Runway charges 20% less until 30 Nov 2026.
|
|
54
|
+
kling_4: { ...WIDE, rates: { '720p': 15.7, '1080p': 23.5 } },
|
|
55
|
+
kling_4_flash: { ...WIDE, rates: { '720p': 9.4 }, minimum: 29 },
|
|
56
|
+
seedance2_5: { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '480p': 20, '720p': 30, '1080p': 68, '4k': 110 }, minimum: 80 },
|
|
57
|
+
seedance2_5_flash: { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '480p': 13, '720p': 20 }, minimum: 52 },
|
|
58
|
+
'gemini_omni_flash_1.2': { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '360p': 2, '720p': 7, '1080p': 10, '4k': 21 }, minimum: 6, perFrame: 1 },
|
|
59
|
+
hailuo3: { image: { ratio: 'adaptive', resolution: '768p' }, text: { ratio: '16:9', resolution: '768p' }, rates: { '768p': 10, '2k': 15 }, perFrame: 2 },
|
|
60
|
+
h3_max: { image: { resolution: '768p' }, text: { resolution: '768p' }, rates: { '480p': 5, '768p': 8 } },
|
|
61
|
+
// Runway: keyframe image-to-video requests must use an auto_ ratio, which follows the first frame.
|
|
62
|
+
wan3: { ...WIDE, rates: { '480p': 5, '720p': 10, '1080p': 20 }, imageRatios: ['auto_480p', 'auto_720p', 'auto_1080p'] },
|
|
63
|
+
wan3_prime: { ...WIDE, rates: { '480p': 6.8, '720p': 14, '1080p': 28 }, imageRatios: ['auto_480p', 'auto_720p', 'auto_1080p'] },
|
|
64
|
+
grok_imagine_1_5: { image: { resolution: '720p' }, text: { ratio: '16:9', resolution: '720p' }, rates: { '480p': 10, '720p': 16, '1080p': 29 }, perFrame: 1 },
|
|
65
|
+
// Runway lists 720:720 with the 720p sizes.
|
|
66
|
+
grok_imagine_1_5_lite: { ...WIDE, rates: { '480p': 2, '720p': 3, '1080p': 14 }, perFrame: 1, tierOverrides: { '720:720': '720p' } },
|
|
67
|
+
happyhorse_1_0: { image: { resolution: '720p' }, text: { ratio: '1280:720' }, rates: { '720p': 15, '1080p': 30 } },
|
|
68
|
+
};
|
|
69
|
+
const VIDEO_OPTIONS = { audio: 'audio', seed: 'seed', negative_prompt: 'negativePrompt', content_moderation: 'contentModeration' };
|
|
70
|
+
function refuse(message, hint) {
|
|
71
|
+
throw new RunwayError(message, 'INVALID_INPUT', hint);
|
|
72
|
+
}
|
|
73
|
+
function checkPrompt(model, spec, prompt) {
|
|
74
|
+
if (prompt === undefined) {
|
|
75
|
+
if (spec.promptRequired)
|
|
76
|
+
refuse(`${model} needs a prompt here.`, 'Pass prompt_text describing the video or image.');
|
|
53
77
|
return;
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
}
|
|
79
|
+
const max = spec.maxPrompt ?? Infinity;
|
|
80
|
+
if (prompt.length < spec.minPrompt || prompt.length > max) {
|
|
81
|
+
refuse(`Prompt is ${prompt.length} characters; ${model} takes ${spec.minPrompt} to ${max}.`, prompt.length > max ? `Shorten the prompt to ${max} characters or fewer.` : `Write a prompt of at least ${spec.minPrompt} characters.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function pick(model, name, given, fallback, allowed) {
|
|
85
|
+
if (allowed.length === 0) {
|
|
86
|
+
if (given !== undefined)
|
|
87
|
+
refuse(`${model} does not take a ${name} here.`, `Leave ${name} out when using ${model}.`);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const value = given ?? fallback;
|
|
91
|
+
if (value === undefined || !allowed.includes(value)) {
|
|
92
|
+
refuse(`${model} does not support ${name} ${value} here.`, `Use one of: ${allowed.join(', ')}.`);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
function checkSeed(model, spec, seed) {
|
|
97
|
+
const max = spec.seedMax ?? 4294967295;
|
|
98
|
+
if (typeof seed !== 'number' || !Number.isInteger(seed) || seed < 0 || seed > max) {
|
|
99
|
+
refuse(`${model} takes a seed from 0 to ${max}; got ${seed}.`, `Pick a seed from 0 to ${max}, or leave it out.`);
|
|
56
100
|
}
|
|
57
101
|
}
|
|
58
|
-
const OPTION_BODY_KEYS = {
|
|
59
|
-
audio: 'audio',
|
|
60
|
-
seed: 'seed',
|
|
61
|
-
negative_prompt: 'negativePrompt',
|
|
62
|
-
content_moderation: 'contentModeration',
|
|
63
|
-
};
|
|
64
102
|
/**
|
|
65
|
-
* Check a resold model's prompt, ratio, duration and options,
|
|
66
|
-
* fields to send
|
|
67
|
-
*
|
|
103
|
+
* Check a resold model's prompt, ratio, resolution, duration, frames and options,
|
|
104
|
+
* and return the body fields to send (besides model, promptImage and promptText)
|
|
105
|
+
* with the estimated credits. Throws INVALID_INPUT, naming the model, for
|
|
106
|
+
* anything its spec does not allow, before any request is made.
|
|
68
107
|
*/
|
|
69
108
|
export function resoldVideoFields(model, kind, args) {
|
|
70
|
-
const spec =
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
109
|
+
const spec = videoSpec(model, kind);
|
|
110
|
+
const pricing = VIDEO_PRICING[model];
|
|
111
|
+
const defaults = pricing[kind];
|
|
112
|
+
checkPrompt(model, spec, args.prompt_text);
|
|
113
|
+
if (kind === 'text' && args.ratio === 'adaptive') {
|
|
114
|
+
refuse(`${model} takes ratio adaptive only from an image.`, `Pick a fixed ratio: ${spec.ratios.filter((r) => r !== 'adaptive').join(', ')}.`);
|
|
76
115
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
116
|
+
const ratio = pick(model, 'ratio', args.ratio, defaults.ratio, (kind === 'image' && pricing.imageRatios) || spec.ratios);
|
|
117
|
+
const resolution = pick(model, 'resolution', args.resolution, defaults.resolution, spec.resolutions);
|
|
118
|
+
const duration = args.duration ?? 5;
|
|
119
|
+
const range = spec.duration ?? { min: 5, max: 5 };
|
|
120
|
+
if (!Number.isInteger(duration) || duration < range.min || duration > range.max) {
|
|
121
|
+
refuse(`${model} takes a whole number of seconds from ${range.min} to ${range.max}; got ${duration}.`, `Pick a duration from ${range.min} to ${range.max} seconds.`);
|
|
80
122
|
}
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
if (args.last_frame_image !== undefined && !spec.lastFrame) {
|
|
124
|
+
refuse(`${model} takes only a first frame, not a last frame.`, `Leave last_frame_image out when using ${model}.`);
|
|
125
|
+
}
|
|
126
|
+
const fields = { duration };
|
|
127
|
+
if (ratio !== undefined)
|
|
128
|
+
fields.ratio = ratio;
|
|
129
|
+
if (resolution !== undefined)
|
|
130
|
+
fields.resolution = resolution;
|
|
131
|
+
for (const option of Object.keys(VIDEO_OPTIONS)) {
|
|
83
132
|
const value = args[option];
|
|
84
133
|
if (value === undefined || (option === 'content_moderation' && value === 'auto'))
|
|
85
134
|
continue;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (option === 'seed'
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
extra[OPTION_BODY_KEYS[option]] = value;
|
|
135
|
+
const key = VIDEO_OPTIONS[option];
|
|
136
|
+
if (!spec.fields.includes(key))
|
|
137
|
+
refuse(`${model} does not accept ${option}.`, `Leave ${option} out when using ${model}.`);
|
|
138
|
+
if (option === 'seed')
|
|
139
|
+
checkSeed(model, spec, value);
|
|
140
|
+
fields[key] = option === 'content_moderation' ? { publicFigureThreshold: value } : value;
|
|
93
141
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
142
|
+
const tier = resolution ?? tierOf(ratio ?? '', Object.keys(pricing.rates), VIDEO_TIER_PIXELS, pricing.tierOverrides);
|
|
143
|
+
const frames = kind === 'image' ? (args.last_frame_image !== undefined ? 2 : 1) : 0;
|
|
144
|
+
const credits = Math.max(pricing.minimum ?? 0, Math.ceil(pricing.rates[tier] * duration + frames * (pricing.perFrame ?? 0)));
|
|
145
|
+
return { fields, duration, credits };
|
|
96
146
|
}
|
|
97
147
|
// ── Images ─────────────────────────────────────────────────────────────
|
|
98
|
-
export const RESOLD_IMAGE_MODELS = ['gemini_image3_pro', 'gpt_image_2_6_sunburst', 'gpt_image_2_6_flare'];
|
|
99
|
-
const GPT_IMAGE_2_6_RATIOS = [
|
|
100
|
-
'2048:880', '1920:1088', '1920:1280', '1920:1440', '1920:1536', '1920:1920', '1536:1920', '1440:1920', '1280:1920', '1088:1920',
|
|
101
|
-
'2912:1248', '2560:1440', '2560:1712', '2560:1920', '2560:2048', '2560:2560', '2048:2560', '1920:2560', '1712:2560', '1440:2560',
|
|
102
|
-
'3840:1648', '3840:2160', '3504:2336', '3264:2448', '3200:2560', '2880:2880', '2560:3200', '2448:3264', '2336:3504', '2160:3840',
|
|
103
|
-
];
|
|
104
|
-
const GEMINI_IMAGE_3_PRO_RATIOS = [
|
|
105
|
-
'1344:768', '768:1344', '1024:1024', '1184:864', '864:1184', '1536:672', '832:1248', '1248:832', '896:1152', '1152:896',
|
|
106
|
-
'2048:2048', '1696:2528', '2528:1696', '1792:2400', '2400:1792', '1856:2304', '2304:1856', '1536:2752', '2752:1536', '3168:1344',
|
|
107
|
-
'4096:4096', '3392:5056', '5056:3392', '3584:4800', '4800:3584', '3712:4608', '4608:3712', '3072:5504', '5504:3072', '6336:2688',
|
|
108
|
-
];
|
|
109
148
|
// GPT Image 2.6 at the default high quality, by tier and shape (Runway's
|
|
110
|
-
// pricing guide). Each tier
|
|
149
|
+
// pricing guide). Each tier lists its ten ratios in this shape order.
|
|
111
150
|
const GPT_IMAGE_2_6_SHAPES = ['21:9', '16:9', '3:2', '4:3', '5:4', '1:1', '5:4', '4:3', '3:2', '16:9'];
|
|
112
151
|
const GPT_IMAGE_2_6_HIGH = [
|
|
113
152
|
{ '1:1': 11, '5:4': 8, '4:3': 7, '3:2': 6, '16:9': 5, '21:9': 4 },
|
|
114
153
|
{ '1:1': 16, '5:4': 11, '4:3': 10, '3:2': 8, '16:9': 6, '21:9': 5 },
|
|
115
154
|
{ '1:1': 19, '5:4': 15, '4:3': 14, '3:2': 13, '16:9': 11, '21:9': 7 },
|
|
116
155
|
];
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
return GPT_IMAGE_2_6_AUTO_CREDITS;
|
|
123
|
-
return GPT_IMAGE_2_6_HIGH[Math.floor(index / 10)][GPT_IMAGE_2_6_SHAPES[index % 10]];
|
|
156
|
+
function gptImage26Credits(ratio, references) {
|
|
157
|
+
const index = TEXT_TO_IMAGE.gpt_image_2_6_flare.ratios.indexOf(ratio);
|
|
158
|
+
// With ratio "auto", Runway charges 19 credits up front at high quality.
|
|
159
|
+
const perImage = ratio === 'auto' || index < 0 ? 19 : GPT_IMAGE_2_6_HIGH[Math.floor(index / 10)][GPT_IMAGE_2_6_SHAPES[index % 10]];
|
|
160
|
+
return perImage + references;
|
|
124
161
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
gemini_image3_pro: {
|
|
135
|
-
ratios: GEMINI_IMAGE_3_PRO_RATIOS,
|
|
136
|
-
defaultRatio: '1344:768',
|
|
137
|
-
minPromptChars: 3,
|
|
138
|
-
maxPromptChars: 45000,
|
|
139
|
-
maxReferences: 14,
|
|
140
|
-
// 20 credits at 1K or 2K, 40 at 4K (the last ten ratios).
|
|
141
|
-
credits: (ratio) => (GEMINI_IMAGE_3_PRO_RATIOS.indexOf(ratio) >= 20 ? 40 : 20),
|
|
142
|
-
},
|
|
162
|
+
// MiniMax H3 Image at the default (not highspeed): credits by reference count (row) and 1K, 2K, 4K.
|
|
163
|
+
const MINIMAX_H3_IMAGE = [
|
|
164
|
+
[3, 3, 7], [3, 3, 8], [4, 4, 8], [4, 5, 8], [5, 5, 9], [6, 6, 10], [6, 7, 11], [7, 8, 11], [8, 8, 12],
|
|
165
|
+
[9, 9, 13], [9, 10, 14], [10, 11, 14], [11, 12, 15], [12, 12, 16], [12, 13, 17], [13, 14, 18], [14, 15, 18],
|
|
166
|
+
];
|
|
167
|
+
/** Credits per image by tier, from the ratio's pixel count. */
|
|
168
|
+
const byTier = (table) => (ratio) => table[tierOf(ratio, Object.keys(table), IMAGE_TIER_PIXELS)];
|
|
169
|
+
export const IMAGE_PRICING = {
|
|
170
|
+
gemini_image3_pro: { defaultRatio: '1344:768', credits: byTier({ '1k': 20, '2k': 20, '4k': 40 }) },
|
|
143
171
|
// Runway lists both 2.6 variants with one description and one price table.
|
|
144
|
-
gpt_image_2_6_sunburst:
|
|
145
|
-
gpt_image_2_6_flare:
|
|
172
|
+
gpt_image_2_6_sunburst: { defaultRatio: '1920:1088', credits: gptImage26Credits },
|
|
173
|
+
gpt_image_2_6_flare: { defaultRatio: '1920:1088', credits: gptImage26Credits },
|
|
174
|
+
'gemini_image3.1_flash': { defaultRatio: '1344:768', credits: byTier({ '512': 5, '1k': 7, '2k': 11, '4k': 16 }) },
|
|
175
|
+
'gemini_image3.1_flash_lite': { defaultRatio: '1376:768', credits: () => 4 },
|
|
176
|
+
'nano_banana_2.1': { defaultRatio: '1376:768', credits: byTier({ '1k': 4, '2k': 6, '4k': 12 }) },
|
|
177
|
+
'seedream5.5': { defaultRatio: '1424:800', credits: (ratio, refs) => Math.ceil(byTier({ '1k': 2, '1.5k': 2, '2k': 4 })(ratio) + refs * 0.8) },
|
|
178
|
+
minimax_h3_image: { defaultRatio: '1376:768', credits: (ratio, refs) => MINIMAX_H3_IMAGE[refs][['1k', '2k', '4k'].indexOf(tierOf(ratio, ['1k', '2k', '4k'], IMAGE_TIER_PIXELS))] },
|
|
179
|
+
// Runway's default quality: medium with reference images, high without.
|
|
180
|
+
ideogram_4_5: {
|
|
181
|
+
defaultRatio: '1280:720',
|
|
182
|
+
credits: (_ratio, refs) => (refs > 0 ? 8 : 25),
|
|
183
|
+
withReferences: { '1280:720': '1024:576', '720:1280': '576:1024', '1440:720': '1408:704', '720:1440': '704:1408' },
|
|
184
|
+
},
|
|
185
|
+
// Default quality medium; 1 credit per reference image.
|
|
186
|
+
grok_imagine_image_2: { defaultRatio: '1280:720', credits: (ratio, refs) => byTier({ '1k': 6, '2k': 8 })(ratio) + refs },
|
|
187
|
+
muse_image: { defaultRatio: '2016:1152', credits: () => 1 },
|
|
188
|
+
// 1MP and 4MP sizes.
|
|
189
|
+
bria_fibo_1_5: { defaultRatio: '1024:576', credits: byTier({ '1k': 5, '2k': 10 }) },
|
|
146
190
|
};
|
|
147
|
-
export function isResoldImageModel(model) {
|
|
148
|
-
return RESOLD_IMAGE_MODELS.includes(model);
|
|
149
|
-
}
|
|
150
191
|
const REFERENCE_TAG = /^[a-z][a-z0-9_]{2,15}$/;
|
|
151
192
|
/** Check a resold image model's prompt, ratio, references and options; throws INVALID_INPUT naming the model. */
|
|
152
193
|
export function resoldImageFields(model, args) {
|
|
153
|
-
const spec =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
194
|
+
const spec = TEXT_TO_IMAGE[model];
|
|
195
|
+
const pricing = IMAGE_PRICING[model];
|
|
196
|
+
checkPrompt(model, spec, args.prompt_text);
|
|
197
|
+
const max = spec.maxReferences ?? 0;
|
|
198
|
+
if (args.references.length > max) {
|
|
199
|
+
refuse(`${model} takes at most ${max} reference images; got ${args.references.length}.`, `Pass ${max} reference images or fewer.`);
|
|
157
200
|
}
|
|
158
201
|
const tags = args.references.flatMap((r) => (r.tag === undefined ? [] : [r.tag]));
|
|
202
|
+
if (tags.length > 0 && !spec.referenceTags) {
|
|
203
|
+
refuse(`${model} does not take reference tags.`, 'Leave the tags out and refer to reference images by order ("the first image").');
|
|
204
|
+
}
|
|
159
205
|
const badTag = tags.find((tag) => !REFERENCE_TAG.test(tag));
|
|
160
206
|
if (badTag !== undefined) {
|
|
161
|
-
|
|
207
|
+
refuse(`${model} does not accept the reference tag "${badTag}".`, 'A tag is 3-16 characters: a lowercase letter, then lowercase letters, digits or underscores.');
|
|
162
208
|
}
|
|
163
209
|
if (new Set(tags).size !== tags.length) {
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
const ratio = args.ratio ?? spec.defaultRatio;
|
|
167
|
-
if (!spec.ratios.includes(ratio)) {
|
|
168
|
-
throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${spec.ratios.join(', ')}.`);
|
|
210
|
+
refuse(`${model} needs a different tag on each reference image.`, 'Give each reference image its own tag, or leave tags out.');
|
|
169
211
|
}
|
|
212
|
+
const swap = pricing.withReferences ?? {};
|
|
213
|
+
const withRefs = args.references.length > 0;
|
|
214
|
+
const allowed = spec.ratios.filter((r) => !(withRefs ? r in swap : Object.values(swap).includes(r)));
|
|
215
|
+
const fallback = withRefs ? (swap[pricing.defaultRatio] ?? pricing.defaultRatio) : pricing.defaultRatio;
|
|
216
|
+
const ratio = pick(model, 'ratio', args.ratio, fallback, allowed);
|
|
217
|
+
const fields = {};
|
|
170
218
|
if (args.seed !== undefined) {
|
|
171
|
-
|
|
219
|
+
if (!spec.fields.includes('seed'))
|
|
220
|
+
refuse(`${model} does not accept seed.`, `Leave seed out when using ${model}.`);
|
|
221
|
+
checkSeed(model, spec, args.seed);
|
|
222
|
+
fields.seed = args.seed;
|
|
172
223
|
}
|
|
173
224
|
if (args.content_moderation !== undefined && args.content_moderation !== 'auto') {
|
|
174
|
-
|
|
225
|
+
if (!spec.fields.includes('contentModeration'))
|
|
226
|
+
refuse(`${model} does not accept content_moderation.`, `Leave content_moderation out when using ${model}.`);
|
|
227
|
+
fields.contentModeration = { publicFigureThreshold: args.content_moderation };
|
|
175
228
|
}
|
|
176
|
-
return { ratio, credits:
|
|
229
|
+
return { ratio, fields, credits: pricing.credits(ratio, args.references.length) };
|
|
177
230
|
}
|
|
178
231
|
//# sourceMappingURL=resold-models.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ResoldFieldSpec {
|
|
2
|
+
/** Request fields the model accepts, besides model. Anything else is refused by Runway. */
|
|
3
|
+
fields: readonly string[];
|
|
4
|
+
promptRequired: boolean;
|
|
5
|
+
minPrompt: number;
|
|
6
|
+
maxPrompt: number | null;
|
|
7
|
+
/** Allowed ratios; empty when the model takes no ratio here. */
|
|
8
|
+
ratios: readonly string[];
|
|
9
|
+
/** Allowed resolutions, lowercased; empty when the model takes none. */
|
|
10
|
+
resolutions: readonly string[];
|
|
11
|
+
duration?: {
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
};
|
|
15
|
+
seedMax?: number;
|
|
16
|
+
/** Image-to-video: whether promptImage may carry a last frame as well as the first. */
|
|
17
|
+
lastFrame?: boolean;
|
|
18
|
+
maxReferences?: number;
|
|
19
|
+
referenceTags?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const IMAGE_TO_VIDEO: Record<string, ResoldFieldSpec>;
|
|
22
|
+
export declare const TEXT_TO_VIDEO: Record<string, ResoldFieldSpec>;
|
|
23
|
+
export declare const TEXT_TO_IMAGE: Record<string, ResoldFieldSpec>;
|
|
24
|
+
//# sourceMappingURL=resold-specs.generated.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Generated by scripts/generate-resold-specs.mjs from Runway's published API spec. Do not edit by hand.
|
|
2
|
+
// Source: https://docs.dev.runwayml.com/openapi.json, version 2024-11-06, sha256 a617495a5ebb91c0bb0d1a4476115d9cd1f3c262100859c00eda15b856465221.
|
|
3
|
+
// The models were read from the documentation, never called (FOX-12868).
|
|
4
|
+
export const IMAGE_TO_VIDEO = {
|
|
5
|
+
"kling_4": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 3, "max": 30 }, "lastFrame": true },
|
|
6
|
+
"kling_4_flash": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["auto_720p"], "resolutions": [], "duration": { "min": 3, "max": 20 }, "lastFrame": false },
|
|
7
|
+
"seedance2_5": { "fields": ["audio", "draft", "duration", "outputFormat", "promptImage", "promptText", "ratio", "referenceAudio", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280", "2206:946", "1920:1080", "1664:1248", "1440:1440", "1248:1664", "1080:1920", "3840:1646", "3840:2160", "3840:2880", "3840:3840", "2880:3840", "2160:3840"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295, "lastFrame": true },
|
|
8
|
+
"seedance2_5_flash": { "fields": ["audio", "duration", "outputFormat", "promptImage", "promptText", "ratio", "referenceAudio", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295, "lastFrame": true },
|
|
9
|
+
"gemini_omni_flash_1.2": { "fields": ["duration", "promptImage", "promptText", "ratio"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["640:360", "360:640", "1280:720", "720:1280", "1920:1080", "1080:1920", "3840:2160", "2160:3840"], "resolutions": [], "duration": { "min": 3, "max": 15 }, "lastFrame": true },
|
|
10
|
+
"hailuo3": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceAudio", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"], "resolutions": ["768p", "2k"], "duration": { "min": 5, "max": 15 }, "lastFrame": true },
|
|
11
|
+
"h3_max": { "fields": ["duration", "promptExpansionMode", "promptImage", "promptText", "resolution", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": [], "resolutions": ["480p", "768p"], "duration": { "min": 5, "max": 15 }, "seedMax": 4294967295, "lastFrame": true },
|
|
12
|
+
"wan3": { "fields": ["audio", "duration", "promptImage", "promptText", "ratio", "referenceAudio", "referenceVideos"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 }, "lastFrame": true },
|
|
13
|
+
"wan3_prime": { "fields": ["audio", "duration", "promptImage", "promptText", "ratio", "referenceAudio", "referenceVideos"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 }, "lastFrame": true },
|
|
14
|
+
"grok_imagine_1_5": { "fields": ["duration", "promptImage", "promptText", "resolution"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 2500, "ratios": [], "resolutions": ["480p", "720p", "1080p"], "duration": { "min": 1, "max": 15 }, "lastFrame": false },
|
|
15
|
+
"grok_imagine_1_5_lite": { "fields": ["duration", "promptImage", "promptText", "ratio"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 1, "max": 15 }, "lastFrame": false },
|
|
16
|
+
"happyhorse_1_0": { "fields": ["duration", "promptImage", "promptText", "resolution"], "promptRequired": false, "minPrompt": 2, "maxPrompt": 2500, "ratios": [], "resolutions": ["720p", "1080p"], "duration": { "min": 3, "max": 15 }, "lastFrame": false },
|
|
17
|
+
};
|
|
18
|
+
export const TEXT_TO_VIDEO = {
|
|
19
|
+
"kling_4": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["1280:720", "720:1280", "940:940", "1460:624", "1920:1080", "1080:1920", "1440:1440", "2200:940", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 3, "max": 30 } },
|
|
20
|
+
"kling_4_flash": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["1280:720", "720:1280", "960:960", "1464:628", "auto_720p", "940:940", "1460:624"], "resolutions": [], "duration": { "min": 3, "max": 20 } },
|
|
21
|
+
"seedance2_5": { "fields": ["audio", "draft", "draftTaskId", "duration", "outputFormat", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280", "2206:946", "1920:1080", "1664:1248", "1440:1440", "1248:1664", "1080:1920", "3840:1646", "3840:2160", "3840:2880", "3840:3840", "2880:3840", "2160:3840"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295 },
|
|
22
|
+
"seedance2_5_flash": { "fields": ["audio", "duration", "outputFormat", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295 },
|
|
23
|
+
"gemini_omni_flash_1.2": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["640:360", "360:640", "1280:720", "720:1280", "1920:1080", "1080:1920", "3840:2160", "2160:3840"], "resolutions": [], "duration": { "min": 3, "max": 15 } },
|
|
24
|
+
"hailuo3": { "fields": ["duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"], "resolutions": ["768p", "2k"], "duration": { "min": 5, "max": 15 } },
|
|
25
|
+
"h3_max": { "fields": ["duration", "promptExpansionMode", "promptText", "resolution", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": [], "resolutions": ["480p", "768p"], "duration": { "min": 5, "max": 15 }, "seedMax": 4294967295 },
|
|
26
|
+
"wan3": { "fields": ["audio", "duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 } },
|
|
27
|
+
"wan3_prime": { "fields": ["audio", "duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 } },
|
|
28
|
+
"grok_imagine_1_5": { "fields": ["duration", "promptText", "ratio", "referenceAudio", "references", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"], "resolutions": ["480p", "720p", "1080p"], "duration": { "min": 1, "max": 15 } },
|
|
29
|
+
"grok_imagine_1_5_lite": { "fields": ["duration", "promptText", "ratio"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["848:480", "480:848", "480:480", "640:480", "480:640", "720:480", "480:720", "1280:720", "720:1280", "720:720", "960:720", "720:960", "1088:720", "720:1088", "1904:1072", "1072:1904", "1424:1424", "1648:1232", "1232:1648", "1744:1152", "1152:1744"], "resolutions": [], "duration": { "min": 1, "max": 15 } },
|
|
30
|
+
"happyhorse_1_0": { "fields": ["duration", "promptText", "ratio"], "promptRequired": true, "minPrompt": 2, "maxPrompt": 2500, "ratios": ["1280:720", "720:1280", "960:960", "1108:832", "832:1108", "1920:1080", "1080:1920", "1440:1440", "1662:1248", "1248:1662"], "resolutions": [], "duration": { "min": 3, "max": 15 } },
|
|
31
|
+
};
|
|
32
|
+
export const TEXT_TO_IMAGE = {
|
|
33
|
+
"gemini_image3_pro": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 3, "maxPrompt": 45000, "ratios": ["1344:768", "768:1344", "1024:1024", "1184:864", "864:1184", "1536:672", "832:1248", "1248:832", "896:1152", "1152:896", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
|
|
34
|
+
"gpt_image_2_6_sunburst": { "fields": ["background", "frameCount", "frameDurationMs", "outputCount", "outputFormat", "promptText", "quality", "ratio", "reasoningEffort", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["2048:880", "1920:1088", "1920:1280", "1920:1440", "1920:1536", "1920:1920", "1536:1920", "1440:1920", "1280:1920", "1088:1920", "2912:1248", "2560:1440", "2560:1712", "2560:1920", "2560:2048", "2560:2560", "2048:2560", "1920:2560", "1712:2560", "1440:2560", "3840:1648", "3840:2160", "3504:2336", "3264:2448", "3200:2560", "2880:2880", "2560:3200", "2448:3264", "2336:3504", "2160:3840", "auto"], "resolutions": [], "maxReferences": 16, "referenceTags": true },
|
|
35
|
+
"gpt_image_2_6_flare": { "fields": ["background", "frameCount", "frameDurationMs", "outputCount", "outputFormat", "promptText", "quality", "ratio", "reasoningEffort", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["2048:880", "1920:1088", "1920:1280", "1920:1440", "1920:1536", "1920:1920", "1536:1920", "1440:1920", "1280:1920", "1088:1920", "2912:1248", "2560:1440", "2560:1712", "2560:1920", "2560:2048", "2560:2560", "2048:2560", "1920:2560", "1712:2560", "1440:2560", "3840:1648", "3840:2160", "3504:2336", "3264:2448", "3200:2560", "2880:2880", "2560:3200", "2448:3264", "2336:3504", "2160:3840", "auto"], "resolutions": [], "maxReferences": 16, "referenceTags": true },
|
|
36
|
+
"gemini_image3.1_flash": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["512:512", "416:624", "624:416", "432:592", "592:432", "448:576", "576:448", "384:672", "672:384", "768:336", "256:1024", "1024:256", "176:1408", "1408:176", "1024:1024", "832:1248", "1248:832", "864:1184", "1184:864", "896:1152", "1152:896", "768:1344", "1344:768", "1536:672", "512:2048", "2048:512", "352:2816", "2816:352", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "1024:4096", "4096:1024", "704:5632", "5632:704", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688", "2048:8192", "8192:2048", "1408:11264", "11264:1408"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
|
|
37
|
+
"gemini_image3.1_flash_lite": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["1024:1024", "848:1264", "1264:848", "896:1200", "1200:896", "928:1152", "1152:928", "768:1376", "1376:768", "1584:672"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
|
|
38
|
+
"nano_banana_2.1": { "fields": ["outputCount", "promptText", "ratio", "referenceImages", "thinkingLevel"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["1024:1024", "848:1264", "1264:848", "896:1200", "1200:896", "928:1152", "1152:928", "768:1376", "1376:768", "1584:672", "512:2064", "2064:512", "352:2928", "2928:352", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "1024:4128", "4128:1024", "704:5856", "5856:704", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688", "2048:8256", "8256:2048", "1408:11712", "11712:1408"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
|
|
39
|
+
"seedream5.5": { "fields": ["background", "outputCount", "outputFormat", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["1024:1024", "1152:864", "864:1152", "1424:800", "800:1424", "1248:832", "832:1248", "1568:672", "1536:1536", "1792:1344", "1344:1792", "2048:1152", "1152:2048", "1872:1248", "1248:1872", "2352:1008", "2048:2048", "2368:1776", "1776:2368", "2816:1584", "1584:2816", "2496:1664", "1664:2496", "3136:1344", "auto_1k", "auto_1.5k", "auto_2k"], "resolutions": [], "maxReferences": 10, "referenceTags": false },
|
|
40
|
+
"minimax_h3_image": { "fields": ["highspeed", "outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["1024:1024", "1152:928", "928:1152", "1184:896", "896:1184", "1248:832", "832:1248", "1376:768", "768:1376", "1440:736", "736:1440", "1568:672", "672:1568", "1760:576", "576:1760", "2048:2048", "2304:1824", "1824:2304", "2368:1760", "1760:2368", "2496:1664", "1664:2496", "2720:1536", "1536:2720", "2912:1440", "1440:2912", "3136:1344", "1344:3136", "3552:1184", "1184:3552", "4096:4096", "4576:3648", "3648:4576", "4736:3552", "3552:4736", "5024:3360", "3360:5024", "5472:3072", "3072:5472", "5792:2912", "2912:5792", "6272:2688", "2688:6272", "7104:2368", "2368:7104", "auto_1k", "auto_2k", "auto_4k"], "resolutions": [], "maxReferences": 16, "referenceTags": false },
|
|
41
|
+
"ideogram_4_5": { "fields": ["contextWindow", "maskUri", "outputCount", "preciseEdit", "promptText", "quality", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 10000, "ratios": ["1024:1024", "1280:720", "720:1280", "1152:864", "864:1152", "1248:832", "832:1248", "1120:896", "896:1120", "1440:720", "720:1440", "2048:2048", "2560:1440", "1440:2560", "2304:1728", "1728:2304", "2496:1664", "1664:2496", "2240:1792", "1792:2240", "2880:1440", "1440:2880", "1024:576", "576:1024", "1408:704", "704:1408", "auto"], "resolutions": [], "maxReferences": 5, "referenceTags": false },
|
|
42
|
+
"grok_imagine_image_2": { "fields": ["edit", "outputCount", "promptText", "quality", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["1024:1024", "1280:720", "720:1280", "1152:864", "864:1152", "1248:832", "832:1248", "1248:576", "576:1248", "1280:576", "576:1280", "1408:704", "704:1408", "2048:2048", "2816:1584", "1584:2816", "2368:1776", "1776:2368", "2496:1664", "1664:2496", "2912:1344", "1344:2912", "3200:1440", "1440:3200", "2912:1456", "1456:2912", "auto_1k", "auto_2k"], "resolutions": [], "maxReferences": 3, "referenceTags": false },
|
|
43
|
+
"muse_image": { "fields": ["outputCount", "outputFormat", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["2352:1008", "2016:1152", "1920:1280", "1792:1344", "1600:1600", "1344:1792", "1280:1920", "1152:2016", "auto"], "resolutions": [], "maxReferences": 10, "referenceTags": false },
|
|
44
|
+
"bria_fibo_1_5": { "fields": ["outputFormat", "promptText", "ratio", "referenceImages", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 10000, "ratios": ["1024:1024", "768:1152", "1152:768", "768:1024", "1024:768", "768:960", "960:768", "576:1024", "1024:576", "2048:2048", "1536:2304", "2304:1536", "1536:2048", "2048:1536", "1536:1920", "1920:1536", "1152:2048", "2048:1152"], "resolutions": [], "seedMax": 2147483647, "maxReferences": 1, "referenceTags": false },
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=resold-specs.generated.js.map
|
package/dist/tools/tasks.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileWriteContext } from '../file-write-context.js';
|
|
1
2
|
import { randomUUID } from 'crypto';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import { centralReadPath, fileReadContext } from '../file-read-context.js';
|
|
@@ -117,19 +118,21 @@ export function registerTaskTools(server) {
|
|
|
117
118
|
}));
|
|
118
119
|
// ── Download Output ───────────────────────────────────────────────────
|
|
119
120
|
server.registerTool('download_runway_output', {
|
|
121
|
+
_meta: { 'files/writeOutputs': { version: 1, outputs: [{ selector: ['output_path'], target: 'file', expandTilde: false }] } },
|
|
120
122
|
description: 'Download a Runway output (video, image, audio) to a local file. ' +
|
|
121
123
|
'Use after a task succeeds to save the output locally. ' +
|
|
122
|
-
'output_path MUST live inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). ' +
|
|
123
|
-
'
|
|
124
|
+
'When connected to a host that authorizes file writes, its path permission decision applies to output_path. For standalone clients, output_path MUST live inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). ' +
|
|
125
|
+
'For standalone clients, sensitive paths (~/.ssh, ~/.aws, /etc, ~/.bashrc, ~/.zshrc) are refused even when the root would otherwise permit them. ' +
|
|
124
126
|
'By default, refuses to overwrite an existing file (atomic flags: "wx") — pass overwrite: true to replace it. ' +
|
|
125
127
|
'An overwrite is staged to a temporary file and moved into place only after the download succeeds, so a failed download leaves the existing file untouched.',
|
|
126
128
|
inputSchema: z.object({
|
|
127
129
|
url: z.string().describe('Output URL from a completed task.'),
|
|
128
|
-
output_path: z.string().describe('Local file path to save to.
|
|
130
|
+
output_path: z.string().describe('Local file path to save to. When connected to a host that authorizes file writes, its path permission decision applies. For standalone clients, must be inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). Parent directory must exist.'),
|
|
129
131
|
overwrite: z.boolean().optional().describe('If true, replace an existing file at output_path once the download succeeds; a failed download keeps the existing file. Defaults to false (refuses to clobber).'),
|
|
130
132
|
}),
|
|
131
133
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
132
|
-
}, withErrorHandling(async (args) => {
|
|
134
|
+
}, withErrorHandling(async (args, extra) => {
|
|
135
|
+
const writes = fileWriteContext(server.server.getClientCapabilities(), extra);
|
|
133
136
|
const url = args.url;
|
|
134
137
|
const outputPath = args.output_path;
|
|
135
138
|
const overwrite = args.overwrite === true;
|
|
@@ -147,7 +150,7 @@ export function registerTaskTools(server) {
|
|
|
147
150
|
const fs = await import('fs');
|
|
148
151
|
let safe;
|
|
149
152
|
try {
|
|
150
|
-
safe = assertDownloadPathInRoot(outputPath);
|
|
153
|
+
safe = assertDownloadPathInRoot(outputPath, writes);
|
|
151
154
|
}
|
|
152
155
|
catch (err) {
|
|
153
156
|
if (err instanceof RunwayError) {
|
package/dist/tools/video.js
CHANGED
|
@@ -3,34 +3,47 @@ import { z } from 'zod';
|
|
|
3
3
|
import { runwayFetch, resolveMediaInput, costEstimate, addContentModeration } from '../client.js';
|
|
4
4
|
import { RunwayError } from '../types.js';
|
|
5
5
|
import { withErrorHandling } from '../utils.js';
|
|
6
|
-
import {
|
|
7
|
-
// Runway's own and Veo models keep the ratios they always took;
|
|
8
|
-
//
|
|
6
|
+
import { RESOLD_VIDEO_MODELS, isResoldVideoModel, resoldVideoFields } from './resold-models.js';
|
|
7
|
+
// Runway's own and Veo models keep the ratios they always took; each resold
|
|
8
|
+
// model's ratios are checked against its own spec in resold-models.ts.
|
|
9
9
|
const RUNWAY_IMAGE_RATIOS = ['1280:720', '720:1280', '960:960', '1104:832', '832:1104', '1584:672'];
|
|
10
10
|
const RUNWAY_TEXT_RATIOS = ['1280:720', '720:1280'];
|
|
11
|
-
|
|
12
|
-
const TEXT_RATIOS = [...new Set([...RUNWAY_TEXT_RATIOS, ...VIDEO_SPECS.kling_4.textRatios, ...VIDEO_SPECS.seedance2_5.textRatios])];
|
|
13
|
-
function checkRunwayRatio(model, ratio, allowed) {
|
|
11
|
+
function checkRunwayModel(model, ratio, allowed, resolution) {
|
|
14
12
|
if (!allowed.includes(ratio)) {
|
|
15
13
|
throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${allowed.join(', ')}.`);
|
|
16
14
|
}
|
|
15
|
+
if (resolution !== undefined) {
|
|
16
|
+
throw new RunwayError(`${model} does not take a resolution; its ratio sets the size.`, 'INVALID_INPUT', `Leave resolution out when using ${model}.`);
|
|
17
|
+
}
|
|
17
18
|
}
|
|
19
|
+
// Shown to the model choosing; every detail is checked in code before any request.
|
|
20
|
+
const RESOLD_VIDEO_GUIDE = 'kling_4 (Kling 4.0, 3-30s, up to 1080p), kling_4_flash (Kling 4.0 Flash, 720p, 3-20s, cheapest Kling), ' +
|
|
21
|
+
'seedance2_5 (Seedance 2.5, 4-30s, 480p to 4K, audio), seedance2_5_flash (480p/720p, audio), ' +
|
|
22
|
+
'gemini_omni_flash_1.2 (Google, 3-15s, 360p to 4K, needs a prompt), hailuo3 (MiniMax Hailuo 3, 5-15s, resolution 768p or 2k), ' +
|
|
23
|
+
'h3_max (MiniMax H3 Max, 5-15s, resolution 480p or 768p, no ratio), wan3 and wan3_prime (Wan 3, 2-30s, 480p to 1080p, audio), ' +
|
|
24
|
+
'grok_imagine_1_5 (xAI, 1-15s, resolution 480p to 1080p), grok_imagine_1_5_lite (1-15s, cheap), happyhorse_1_0 (3-15s, 720p/1080p). ' +
|
|
25
|
+
'Models made by others take only their own options; a wrong one is refused with the reason, nothing is charged. ' +
|
|
26
|
+
'Their prices are estimated from Runway\'s published rates.';
|
|
27
|
+
const RATIO_GUIDE = 'Output size or shape. Runway models default to 1280:720. Models made by others each take their own list ' +
|
|
28
|
+
'(e.g. auto_720p to follow the image, W:H sizes, or shapes like 16:9) and default to a 720p size; an unsupported one is refused with the list.';
|
|
29
|
+
const RESOLUTION_GUIDE = 'Only for hailuo3 (768p, 2k), h3_max (480p, 768p), grok_imagine_1_5 (480p, 720p, 1080p) and happyhorse_1_0 from an image (720p, 1080p). Defaults to 720p or 768p.';
|
|
18
30
|
export function registerVideoTools(server) {
|
|
19
31
|
// ── Image-to-Video ────────────────────────────────────────────────────
|
|
20
32
|
server.registerTool('generate_video_from_image', {
|
|
21
33
|
description: 'Animate a still image into a video. Supports first-frame (and optionally last-frame) keyframe control. ' +
|
|
22
34
|
'MODELS: gen4.5 (flagship), gen4_turbo (fast/cheap), veo3.1 (best quality + audio), veo3.1_fast, ' +
|
|
23
|
-
|
|
35
|
+
RESOLD_VIDEO_GUIDE + ' Last frame: gen4/veo, kling_4, seedance2_5(_flash), gemini_omni_flash_1.2, hailuo3, h3_max, wan3(_prime). ' +
|
|
24
36
|
'WORKFLOW: Returns task_id → poll with check_runway_task or use wait_for_runway_task.',
|
|
25
37
|
_meta: { 'files/readInputs': { version: 1, inputs: [{ selector: ['prompt_image'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }, { selector: ['last_frame_image'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }] } },
|
|
26
38
|
inputSchema: z.object({
|
|
27
39
|
prompt_image: z.string().describe('First frame image. HTTPS URL, Runway URI, or local file path.'),
|
|
28
40
|
last_frame_image: z.string().optional().describe('Optional last frame image for transition.'),
|
|
29
|
-
prompt_text: z.string().optional().describe('Describe the desired motion. kling_4 takes up to 26000 characters,
|
|
30
|
-
model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast',
|
|
31
|
-
ratio: z.
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
prompt_text: z.string().optional().describe('Describe the desired motion. Required for gemini_omni_flash_1.2, hailuo3, h3_max, wan3 and wan3_prime. kling_4 takes up to 26000 characters, wan3 20000, seedance2_5 15000.'),
|
|
42
|
+
model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast', ...RESOLD_VIDEO_MODELS]).optional().describe('Default: gen4_turbo.'),
|
|
43
|
+
ratio: z.string().optional().describe(`${RATIO_GUIDE} gen4/veo: 1280:720, 720:1280, 960:960, 1104:832, 832:1104, 1584:672.`),
|
|
44
|
+
resolution: z.enum(['480p', '720p', '768p', '1080p', '2k']).optional().describe(RESOLUTION_GUIDE),
|
|
45
|
+
duration: z.number().optional().describe('Seconds. gen4: 2-10 (default 5). veo: 4,6,8 (default 8). Models made by others: their own range (default 5).'),
|
|
46
|
+
audio: z.boolean().optional().describe('Generate audio (veo, seedance2_5(_flash), wan3(_prime)). Default: true.'),
|
|
34
47
|
negative_prompt: z.string().max(1000).optional().describe('What should NOT appear in the output (veo models only, max 1000 chars). Omit to use the default negative prompt.'),
|
|
35
48
|
content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
|
|
36
49
|
seed: z.number().int().optional().describe('Random seed (0-4294967295) for reproducibility.'),
|
|
@@ -40,11 +53,13 @@ export function registerVideoTools(server) {
|
|
|
40
53
|
const reads = fileReadContext(server.server.getClientCapabilities(), extra);
|
|
41
54
|
const model = args.model || 'gen4_turbo';
|
|
42
55
|
// Checked before any upload or request, so a wrong option fails for this model only.
|
|
43
|
-
const resold = isResoldVideoModel(model)
|
|
56
|
+
const resold = isResoldVideoModel(model)
|
|
57
|
+
? resoldVideoFields(model, 'image', { ...args, prompt_text: args.prompt_text || undefined, last_frame_image: args.last_frame_image || undefined })
|
|
58
|
+
: undefined;
|
|
44
59
|
const isRunwayModel = ['gen4.5', 'gen4_turbo'].includes(model);
|
|
45
60
|
const ratio = args.ratio || '1280:720';
|
|
46
61
|
if (!resold)
|
|
47
|
-
|
|
62
|
+
checkRunwayModel(model, ratio, RUNWAY_IMAGE_RATIOS, args.resolution);
|
|
48
63
|
const duration = args.duration || (isRunwayModel ? 5 : 8);
|
|
49
64
|
const audio = args.audio;
|
|
50
65
|
const seed = args.seed;
|
|
@@ -61,7 +76,7 @@ export function registerVideoTools(server) {
|
|
|
61
76
|
promptImage = firstImage;
|
|
62
77
|
}
|
|
63
78
|
if (resold) {
|
|
64
|
-
const body = { model, promptImage,
|
|
79
|
+
const body = { model, promptImage, ...resold.fields };
|
|
65
80
|
if (args.prompt_text)
|
|
66
81
|
body.promptText = args.prompt_text;
|
|
67
82
|
const result = await runwayFetch('/image_to_video', { method: 'POST', body: JSON.stringify(body) });
|
|
@@ -94,14 +109,15 @@ export function registerVideoTools(server) {
|
|
|
94
109
|
// ── Text-to-Video ─────────────────────────────────────────────────────
|
|
95
110
|
server.registerTool('generate_video_from_text', {
|
|
96
111
|
description: 'Create a video entirely from a text description. ' +
|
|
97
|
-
'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast,
|
|
112
|
+
'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast, ' + RESOLD_VIDEO_GUIDE + ' ' +
|
|
98
113
|
'WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
|
|
99
114
|
inputSchema: z.object({
|
|
100
|
-
prompt_text: z.string().max(26000).describe('Detailed video description. Max 1000 chars
|
|
101
|
-
model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast',
|
|
102
|
-
ratio: z.
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
prompt_text: z.string().max(26000).describe('Detailed video description. Max 1000 chars for gen4.5/veo; models made by others take more (kling_4 26000, wan3 20000, seedance2_5 15000).'),
|
|
116
|
+
model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast', ...RESOLD_VIDEO_MODELS]).optional().describe('Default: gen4.5.'),
|
|
117
|
+
ratio: z.string().optional().describe(`${RATIO_GUIDE} gen4.5/veo: 1280:720 or 720:1280.`),
|
|
118
|
+
resolution: z.enum(['480p', '720p', '768p', '1080p', '2k']).optional().describe(RESOLUTION_GUIDE),
|
|
119
|
+
duration: z.number().optional().describe('Seconds. gen4.5: 2-10 (default 5). veo: 4,6,8 (default 8). Models made by others: their own range (default 5).'),
|
|
120
|
+
audio: z.boolean().optional().describe('Generate audio (veo, seedance2_5(_flash), wan3(_prime)). Default: true.'),
|
|
105
121
|
negative_prompt: z.string().max(1000).optional().describe('What should NOT appear in the output (veo models only, max 1000 chars). Omit to use the default negative prompt.'),
|
|
106
122
|
content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
|
|
107
123
|
seed: z.number().int().optional().describe('Random seed (0-4294967295).'),
|
|
@@ -111,7 +127,7 @@ export function registerVideoTools(server) {
|
|
|
111
127
|
const model = args.model || 'gen4.5';
|
|
112
128
|
if (isResoldVideoModel(model)) {
|
|
113
129
|
const resold = resoldVideoFields(model, 'text', args);
|
|
114
|
-
const body = { model, promptText: args.prompt_text,
|
|
130
|
+
const body = { model, promptText: args.prompt_text, ...resold.fields };
|
|
115
131
|
const result = await runwayFetch('/text_to_video', { method: 'POST', body: JSON.stringify(body) });
|
|
116
132
|
return JSON.stringify({
|
|
117
133
|
ok: true, task_id: result.id, status: 'PENDING', model, duration: resold.duration,
|
|
@@ -120,11 +136,11 @@ export function registerVideoTools(server) {
|
|
|
120
136
|
});
|
|
121
137
|
}
|
|
122
138
|
if (args.prompt_text.length > 1000) {
|
|
123
|
-
throw new RunwayError(`Prompt is ${args.prompt_text.length} characters; ${model} supports at most 1000.`, 'INVALID_INPUT', 'Shorten the prompt to 1000 characters, or use kling_4 (up to 26000) or seedance2_5 (up to 15000).');
|
|
139
|
+
throw new RunwayError(`Prompt is ${args.prompt_text.length} characters; ${model} supports at most 1000.`, 'INVALID_INPUT', 'Shorten the prompt to 1000 characters, or use a model that takes more, such as kling_4 (up to 26000) or seedance2_5 (up to 15000).');
|
|
124
140
|
}
|
|
125
141
|
const isGen45 = model === 'gen4.5';
|
|
126
142
|
const ratio = args.ratio || '1280:720';
|
|
127
|
-
|
|
143
|
+
checkRunwayModel(model, ratio, RUNWAY_TEXT_RATIOS, args.resolution);
|
|
128
144
|
const duration = args.duration || (isGen45 ? 5 : 8);
|
|
129
145
|
const audio = args.audio !== false;
|
|
130
146
|
const seed = args.seed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindstone/mcp-server-runway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"mcpName": "io.github.mindstone/mcp-server-runway",
|
|
5
5
|
"description": "Runway ML MCP server for Model Context Protocol hosts — AI video, image, audio generation, custom voices, task management",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|