upres-cli 0.1.1 → 0.3.1
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 +79 -37
- package/dist/cli.cjs +381 -251
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +383 -251
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +27 -13
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +5 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +25 -12
- package/dist/client.js.map +1 -1
- package/dist/mcp.cjs +310 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +6 -0
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.js +283 -0
- package/dist/mcp.js.map +1 -0
- package/dist/models.cjs +51 -214
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +5 -3
- package/dist/models.d.ts +5 -3
- package/dist/models.js +49 -214
- package/dist/models.js.map +1 -1
- package/dist/types.cjs +0 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +0 -0
- package/package.json +54 -12
- package/scripts/check-mcp-registry.sh +51 -0
- package/scripts/ensure-dist.mjs +15 -0
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,316 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res, err) => function __init() {
|
|
5
|
+
if (err) throw err[0];
|
|
6
|
+
try {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw err = [e], e;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/models.ts
|
|
18
|
+
function scaleParam(maxScale) {
|
|
19
|
+
if (maxScale <= 1) return [];
|
|
20
|
+
const options = [];
|
|
21
|
+
for (let step = 2; step <= maxScale; step *= 2) options.push(step);
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "scale",
|
|
25
|
+
type: "integer",
|
|
26
|
+
required: false,
|
|
27
|
+
default: 4,
|
|
28
|
+
options,
|
|
29
|
+
description: "Scale multiplier. Ignored when the alias does not enlarge."
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
function model(id, name, description, category, inputTypes, maxScale) {
|
|
34
|
+
const fileParam = category.startsWith("video") ? { name: "video", type: "string", required: true, description: "Video URL or file" } : category.startsWith("audio") ? { name: "audio", type: "string", required: true, description: "Audio URL or file" } : { name: "image", type: "string", required: true, description: "Image URL or file" };
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
name,
|
|
38
|
+
description,
|
|
39
|
+
category,
|
|
40
|
+
price: "One credit per stage that runs",
|
|
41
|
+
inputTypes,
|
|
42
|
+
params: [fileParam, ...scaleParam(maxScale)]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var MODELS, IMAGE_MODELS, VIDEO_MODELS, AUDIO_MODELS, DEFAULT_IMAGE_MODEL, DEFAULT_VIDEO_MODEL, DEFAULT_AUDIO_MODEL;
|
|
46
|
+
var init_models = __esm({
|
|
47
|
+
"src/models.ts"() {
|
|
48
|
+
"use strict";
|
|
49
|
+
MODELS = [
|
|
50
|
+
model("flare", "Flare", "Everyday photos, 2x-4x. Fastest and cheapest. Does not invent detail.", "image-upscale", ["image/*"], 4),
|
|
51
|
+
model("prism", "Prism", "Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.", "image-upscale", ["image/*"], 4),
|
|
52
|
+
model("lumen", "Lumen", "Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.", "image-upscale", ["image/*"], 8),
|
|
53
|
+
model("mirage", "Mirage", "Invents plausible new detail rather than recovering what was there. Good for art, wrong for documents.", "image-upscale", ["image/*"], 8),
|
|
54
|
+
model("hush", "Hush", "Faithful denoise. Same size as the source, nothing invented.", "image-clean", ["image/*"], 1),
|
|
55
|
+
model("keen", "Keen", "Deblur and sharpen. Same size as the source, does not invent texture.", "image-restore", ["image/*"], 1),
|
|
56
|
+
model("visage", "Visage", "Restores faces and leaves the rest of the frame alone. Does not enlarge.", "image-restore", ["image/*"], 1),
|
|
57
|
+
model("atelier", "Atelier", "Hush, then Visage if the photo looks like a portrait, then Lumen. A skipped face stage is free.", "image-studio", ["image/*"], 8),
|
|
58
|
+
model("motion", "Motion", "Fast 4K finish for AI-generated video. Frame-consistent, does not invent faces.", "video-upscale", ["video/*"], 4),
|
|
59
|
+
model("motion-x", "Motion X", "Cinema-grade video upscale. Noticeably slower and dearer per second than Motion.", "video-upscale", ["video/*"], 4),
|
|
60
|
+
model("still", "Still", "Temporal video denoise. Resolution stays put.", "video-clean", ["video/*"], 1),
|
|
61
|
+
model("cadence", "Cadence", "Frame interpolation. Does not enlarge the picture.", "video-restore", ["video/*"], 1),
|
|
62
|
+
model("atelier-x", "Atelier X", "Still, then Motion X. Two credits.", "video-studio", ["video/*"], 4),
|
|
63
|
+
model("voice", "Voice", "Speech denoise and bandwidth extension to 48 kHz. Not for music.", "audio-clean", ["audio/*"], 1)
|
|
64
|
+
];
|
|
65
|
+
IMAGE_MODELS = MODELS.filter((m) => m.category.startsWith("image"));
|
|
66
|
+
VIDEO_MODELS = MODELS.filter((m) => m.category.startsWith("video"));
|
|
67
|
+
AUDIO_MODELS = MODELS.filter((m) => m.category.startsWith("audio"));
|
|
68
|
+
DEFAULT_IMAGE_MODEL = "flare";
|
|
69
|
+
DEFAULT_VIDEO_MODEL = "motion";
|
|
70
|
+
DEFAULT_AUDIO_MODEL = "voice";
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// src/mcp.ts
|
|
75
|
+
var mcp_exports = {};
|
|
76
|
+
__export(mcp_exports, {
|
|
77
|
+
handleMessage: () => handleMessage,
|
|
78
|
+
startStdio: () => startStdio
|
|
79
|
+
});
|
|
80
|
+
function apiKey() {
|
|
81
|
+
return process.env.UPRES_API_KEY ?? "";
|
|
82
|
+
}
|
|
83
|
+
function baseUrl() {
|
|
84
|
+
return process.env.UPRES_BASE_URL ?? DEFAULT_BASE_URL2;
|
|
85
|
+
}
|
|
86
|
+
async function api(method, endpoint, body) {
|
|
87
|
+
const key = apiKey();
|
|
88
|
+
if (!key) {
|
|
89
|
+
throw new Error("UPRES_API_KEY is not set. Get a key at https://upres.ai/account/api-keys");
|
|
90
|
+
}
|
|
91
|
+
const res = await fetch(`${baseUrl()}${endpoint}`, {
|
|
92
|
+
method,
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: `Bearer ${key}`,
|
|
95
|
+
...body ? { "Content-Type": "application/json" } : {}
|
|
96
|
+
},
|
|
97
|
+
body: body ? JSON.stringify(body) : void 0
|
|
98
|
+
});
|
|
99
|
+
const data = await res.json().catch(() => ({}));
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
throw new Error(data.error ?? `HTTP ${res.status}`);
|
|
102
|
+
}
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
function ok(id, result) {
|
|
106
|
+
return { jsonrpc: "2.0", id, result };
|
|
107
|
+
}
|
|
108
|
+
function fail(id, code, message) {
|
|
109
|
+
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
110
|
+
}
|
|
111
|
+
function text(obj) {
|
|
112
|
+
return { content: [{ type: "text", text: JSON.stringify(obj, null, 2) }] };
|
|
113
|
+
}
|
|
114
|
+
async function callTool(name, args) {
|
|
115
|
+
switch (name) {
|
|
116
|
+
case "upres_list_models":
|
|
117
|
+
return text(
|
|
118
|
+
MODELS.map((m) => ({
|
|
119
|
+
id: m.id,
|
|
120
|
+
name: m.name,
|
|
121
|
+
category: m.category,
|
|
122
|
+
description: m.description
|
|
123
|
+
}))
|
|
124
|
+
);
|
|
125
|
+
case "upres_get_credits": {
|
|
126
|
+
const jobs = await api("GET", "/jobs?limit=100");
|
|
127
|
+
const data = jobs.data ?? [];
|
|
128
|
+
return text({
|
|
129
|
+
recent_jobs: data.length,
|
|
130
|
+
completed: data.filter((j) => j.status === "completed").length,
|
|
131
|
+
pricing: "https://upres.ai/pricing"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
case "upres_upscale_image": {
|
|
135
|
+
const image_url = String(args.image_url ?? "");
|
|
136
|
+
if (!image_url) throw new Error("image_url is required");
|
|
137
|
+
const job = await api("POST", "/jobs", {
|
|
138
|
+
image_url,
|
|
139
|
+
model: args.model ?? "flare",
|
|
140
|
+
scale: args.scale ?? 4
|
|
141
|
+
});
|
|
142
|
+
return text(job);
|
|
143
|
+
}
|
|
144
|
+
case "upres_upscale_video": {
|
|
145
|
+
const video_url = String(args.video_url ?? "");
|
|
146
|
+
if (!video_url) throw new Error("video_url is required");
|
|
147
|
+
const job = await api("POST", "/jobs", {
|
|
148
|
+
image_url: video_url,
|
|
149
|
+
model: args.model ?? "motion",
|
|
150
|
+
scale: args.scale ?? 4
|
|
151
|
+
});
|
|
152
|
+
return text(job);
|
|
153
|
+
}
|
|
154
|
+
case "upres_enhance_audio": {
|
|
155
|
+
const audio_url = String(args.audio_url ?? "");
|
|
156
|
+
if (!audio_url) throw new Error("audio_url is required");
|
|
157
|
+
const job = await api("POST", "/jobs", {
|
|
158
|
+
image_url: audio_url,
|
|
159
|
+
model: args.model ?? "voice"
|
|
160
|
+
});
|
|
161
|
+
return text(job);
|
|
162
|
+
}
|
|
163
|
+
case "upres_get_job": {
|
|
164
|
+
const job_id = String(args.job_id ?? "");
|
|
165
|
+
if (!job_id) throw new Error("job_id is required");
|
|
166
|
+
const job = await api("GET", `/jobs/${job_id}`);
|
|
167
|
+
return text(job);
|
|
168
|
+
}
|
|
169
|
+
default:
|
|
170
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function handle(msg) {
|
|
174
|
+
const id = msg.id;
|
|
175
|
+
const method = String(msg.method ?? "");
|
|
176
|
+
if (msg.jsonrpc !== "2.0") return fail(id, -32600, "Invalid Request");
|
|
177
|
+
if (method === "initialize") {
|
|
178
|
+
return ok(id, {
|
|
179
|
+
protocolVersion: "2024-11-05",
|
|
180
|
+
capabilities: { tools: {} },
|
|
181
|
+
serverInfo: { name: "upres", version: VERSION }
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (method === "notifications/initialized" || method === "initialized") return null;
|
|
185
|
+
if (method === "ping") return ok(id, {});
|
|
186
|
+
if (method === "tools/list") return ok(id, { tools: TOOLS });
|
|
187
|
+
if (method === "tools/call") {
|
|
188
|
+
const params = msg.params ?? {};
|
|
189
|
+
const name = String(params.name ?? "");
|
|
190
|
+
const args = params.arguments ?? {};
|
|
191
|
+
try {
|
|
192
|
+
return ok(id, await callTool(name, args));
|
|
193
|
+
} catch (e) {
|
|
194
|
+
return ok(id, {
|
|
195
|
+
isError: true,
|
|
196
|
+
content: [{ type: "text", text: e.message }]
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (id === void 0) return null;
|
|
201
|
+
return fail(id, -32601, `Method not found: ${method}`);
|
|
202
|
+
}
|
|
203
|
+
async function handleMessage(msg) {
|
|
204
|
+
return handle(msg);
|
|
205
|
+
}
|
|
206
|
+
function startStdio() {
|
|
207
|
+
let buf = "";
|
|
208
|
+
process.stdin.setEncoding("utf8");
|
|
209
|
+
process.stdin.on("data", async (chunk) => {
|
|
210
|
+
buf += chunk;
|
|
211
|
+
while (true) {
|
|
212
|
+
const nl = buf.indexOf("\n");
|
|
213
|
+
if (nl < 0) break;
|
|
214
|
+
const line = buf.slice(0, nl).trim();
|
|
215
|
+
buf = buf.slice(nl + 1);
|
|
216
|
+
if (!line) continue;
|
|
217
|
+
let msg;
|
|
218
|
+
try {
|
|
219
|
+
msg = JSON.parse(line);
|
|
220
|
+
} catch {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const reply = await handle(msg);
|
|
224
|
+
if (reply) process.stdout.write(JSON.stringify(reply) + "\n");
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
var VERSION, DEFAULT_BASE_URL2, TOOLS;
|
|
229
|
+
var init_mcp = __esm({
|
|
230
|
+
"src/mcp.ts"() {
|
|
231
|
+
"use strict";
|
|
232
|
+
init_models();
|
|
233
|
+
VERSION = "0.3.0";
|
|
234
|
+
DEFAULT_BASE_URL2 = "https://api.upres.ai/v1";
|
|
235
|
+
TOOLS = [
|
|
236
|
+
{
|
|
237
|
+
name: "upres_list_models",
|
|
238
|
+
description: "List the 14 public UpRes aliases for image, video, and speech.",
|
|
239
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "upres_get_credits",
|
|
243
|
+
description: "Show recent job count for the authenticated UpRes API key as a quota proxy.",
|
|
244
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "upres_upscale_image",
|
|
248
|
+
description: "Submit an image job from a public URL. Upscale: flare, prism, lumen, mirage. Restore: hush, keen, visage, atelier. Scale is ignored when the alias does not enlarge.",
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
image_url: { type: "string", description: "Public HTTPS URL of the image" },
|
|
253
|
+
model: {
|
|
254
|
+
type: "string",
|
|
255
|
+
enum: IMAGE_MODELS.map((m) => m.id),
|
|
256
|
+
description: "Image alias. Default flare."
|
|
257
|
+
},
|
|
258
|
+
scale: { type: "integer", enum: [2, 4, 8], description: "Scale multiplier. Default 4. Ignored for hush, keen, and visage." }
|
|
259
|
+
},
|
|
260
|
+
required: ["image_url"],
|
|
261
|
+
additionalProperties: false
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "upres_upscale_video",
|
|
266
|
+
description: "Submit a video job from a public URL. motion and motion-x upscale. still denoises, cadence interpolates frames, atelier-x runs still then motion-x.",
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: "object",
|
|
269
|
+
properties: {
|
|
270
|
+
video_url: { type: "string", description: "Public HTTPS URL of the video" },
|
|
271
|
+
model: {
|
|
272
|
+
type: "string",
|
|
273
|
+
enum: VIDEO_MODELS.map((m) => m.id),
|
|
274
|
+
description: "Video alias. Default motion."
|
|
275
|
+
},
|
|
276
|
+
scale: { type: "integer", enum: [2, 4], description: "Scale multiplier. Default 4. Ignored for still and cadence." }
|
|
277
|
+
},
|
|
278
|
+
required: ["video_url"],
|
|
279
|
+
additionalProperties: false
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "upres_enhance_audio",
|
|
284
|
+
description: "Submit a speech job from a public URL. voice denoises speech and extends it to 48 kHz. Music is not supported.",
|
|
285
|
+
inputSchema: {
|
|
286
|
+
type: "object",
|
|
287
|
+
properties: {
|
|
288
|
+
audio_url: { type: "string", description: "Public HTTPS URL of wav, mp3, m4a, or flac speech" },
|
|
289
|
+
model: {
|
|
290
|
+
type: "string",
|
|
291
|
+
enum: AUDIO_MODELS.map((m) => m.id),
|
|
292
|
+
description: "Audio alias. Default voice."
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
required: ["audio_url"],
|
|
296
|
+
additionalProperties: false
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "upres_get_job",
|
|
301
|
+
description: "Get status and result_url of an UpRes job by id.",
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: "object",
|
|
304
|
+
properties: {
|
|
305
|
+
job_id: { type: "string", description: "Job UUID returned by an upscale tool" }
|
|
306
|
+
},
|
|
307
|
+
required: ["job_id"],
|
|
308
|
+
additionalProperties: false
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
});
|
|
2
314
|
|
|
3
315
|
// src/cli.ts
|
|
4
316
|
import fs2 from "fs";
|
|
@@ -24,13 +336,20 @@ function loadConfigFile() {
|
|
|
24
336
|
function resolveApiKey(override) {
|
|
25
337
|
const key = override ?? process.env.UPRES_API_KEY ?? loadConfigFile().apiKey;
|
|
26
338
|
if (!key) {
|
|
27
|
-
|
|
28
|
-
"
|
|
339
|
+
throw new Error(
|
|
340
|
+
"No API key found.\n Set UPRES_API_KEY env var, pass --api-key, or save to ~/.config/upres/config.json\n Get a key at https://upres.ai/account/api-keys"
|
|
29
341
|
);
|
|
30
|
-
process.exit(1);
|
|
31
342
|
}
|
|
32
343
|
return key;
|
|
33
344
|
}
|
|
345
|
+
var UpresError = class extends Error {
|
|
346
|
+
constructor(message, status) {
|
|
347
|
+
super(message);
|
|
348
|
+
this.status = status;
|
|
349
|
+
this.name = "UpresError";
|
|
350
|
+
}
|
|
351
|
+
status;
|
|
352
|
+
};
|
|
34
353
|
var UpresClient = class {
|
|
35
354
|
apiKey;
|
|
36
355
|
baseUrl;
|
|
@@ -51,19 +370,24 @@ var UpresClient = class {
|
|
|
51
370
|
if (!res.ok) {
|
|
52
371
|
const err = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
53
372
|
if (res.status === 401) {
|
|
54
|
-
|
|
55
|
-
process.exit(1);
|
|
373
|
+
throw new UpresError(`Invalid API key. Get a new key at https://upres.ai/account/api-keys`, res.status);
|
|
56
374
|
}
|
|
57
375
|
if (res.status === 402) {
|
|
58
|
-
|
|
59
|
-
`
|
|
60
|
-
Upgrade
|
|
376
|
+
throw new UpresError(
|
|
377
|
+
`Monthly quota exceeded (used ${err.used ?? "?"}/${err.quota ?? "?"}).
|
|
378
|
+
Upgrade your plan at https://upres.ai/pricing`,
|
|
379
|
+
res.status
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
if (res.status === 403) {
|
|
383
|
+
throw new UpresError(
|
|
384
|
+
`${err.error ?? "API access requires the Business plan."}
|
|
385
|
+
Your key is kept and works again on Business: https://upres.ai/pricing`,
|
|
386
|
+
res.status
|
|
61
387
|
);
|
|
62
|
-
process.exit(1);
|
|
63
388
|
}
|
|
64
389
|
if (res.status === 429) {
|
|
65
|
-
|
|
66
|
-
process.exit(1);
|
|
390
|
+
throw new UpresError(`Rate limit exceeded (60 req/min). Wait a moment and retry.`, res.status);
|
|
67
391
|
}
|
|
68
392
|
throw new Error(err.error ?? `HTTP ${res.status}`);
|
|
69
393
|
}
|
|
@@ -164,226 +488,9 @@ var UpresClient = class {
|
|
|
164
488
|
}
|
|
165
489
|
};
|
|
166
490
|
|
|
167
|
-
// src/models.ts
|
|
168
|
-
var MODELS = [
|
|
169
|
-
{
|
|
170
|
-
id: "wavespeed-ai/real-esrgan",
|
|
171
|
-
name: "Real-ESRGAN",
|
|
172
|
-
description: "Fast image super-resolution with artifact removal. Best value.",
|
|
173
|
-
category: "image-upscale",
|
|
174
|
-
price: "$0.0024/image",
|
|
175
|
-
inputTypes: ["image/*"],
|
|
176
|
-
params: [
|
|
177
|
-
{ name: "image", type: "string", required: true, description: "Image URL" }
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: "wavespeed-ai/image-upscaler",
|
|
182
|
-
name: "Image Upscaler",
|
|
183
|
-
description: "AI upscaler to 2K/4K/8K with detail preservation.",
|
|
184
|
-
category: "image-upscale",
|
|
185
|
-
price: "$0.01/image",
|
|
186
|
-
inputTypes: ["image/*"],
|
|
187
|
-
params: [
|
|
188
|
-
{ name: "image", type: "string", required: true, description: "Image URL" },
|
|
189
|
-
{ name: "target_resolution", type: "string", required: false, default: "4k", options: ["2k", "4k", "8k"], description: "Target output resolution" },
|
|
190
|
-
{ name: "output_format", type: "string", required: false, default: "jpeg", options: ["jpeg", "png", "webp"], description: "Output format" }
|
|
191
|
-
]
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: "wavespeed-ai/ultimate-image-upscaler",
|
|
195
|
-
name: "Ultimate Image Upscaler",
|
|
196
|
-
description: "Most advanced AI enhancer. Reimagines fine detail at 2K/4K/8K.",
|
|
197
|
-
category: "image-upscale",
|
|
198
|
-
price: "$0.01/image",
|
|
199
|
-
inputTypes: ["image/*"],
|
|
200
|
-
params: [
|
|
201
|
-
{ name: "image", type: "string", required: true, description: "Image URL" },
|
|
202
|
-
{ name: "target_resolution", type: "string", required: false, default: "4k", options: ["2k", "4k", "8k"], description: "Target output resolution" },
|
|
203
|
-
{ name: "output_format", type: "string", required: false, default: "jpeg", options: ["jpeg", "png", "webp"], description: "Output format" }
|
|
204
|
-
]
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
id: "wavespeed-ai/seedvr2/image",
|
|
208
|
-
name: "SeedVR2 Image",
|
|
209
|
-
description: "ByteDance SeedVR2 architecture for sharp, detailed upscaling.",
|
|
210
|
-
category: "image-upscale",
|
|
211
|
-
price: "$0.01/image",
|
|
212
|
-
inputTypes: ["image/*"],
|
|
213
|
-
params: [
|
|
214
|
-
{ name: "image", type: "string", required: true, description: "Image URL" },
|
|
215
|
-
{ name: "target_resolution", type: "string", required: false, default: "4k", options: ["2k", "4k", "8k"], description: "Target output resolution" },
|
|
216
|
-
{ name: "output_format", type: "string", required: false, default: "jpeg", options: ["jpeg", "png", "webp"], description: "Output format" }
|
|
217
|
-
]
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
id: "bria/increase-resolution",
|
|
221
|
-
name: "Bria Increase Resolution",
|
|
222
|
-
description: "Preservation-first 2x/4x upscale. No content drift.",
|
|
223
|
-
category: "image-upscale",
|
|
224
|
-
price: "$0.04/image",
|
|
225
|
-
inputTypes: ["image/*"],
|
|
226
|
-
params: [
|
|
227
|
-
{ name: "image", type: "string", required: true, description: "Image URL. Max output 8192x8192" },
|
|
228
|
-
{ name: "desired_increase", type: "integer", required: false, default: 2, options: [2, 4], description: "Resolution multiplier" }
|
|
229
|
-
]
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
id: "clarity-ai/crystal-upscaler",
|
|
233
|
-
name: "Crystal Upscaler",
|
|
234
|
-
description: "Upscale to target megapixels with creativity control.",
|
|
235
|
-
category: "image-upscale",
|
|
236
|
-
price: "Pay per use",
|
|
237
|
-
inputTypes: ["image/*"],
|
|
238
|
-
params: [
|
|
239
|
-
{ name: "image", type: "string", required: true, description: "Image URL" },
|
|
240
|
-
{ name: "target_megapixels", type: "number", required: false, default: 2, range: "1-200", description: "Target size in megapixels" },
|
|
241
|
-
{ name: "creativity", type: "number", required: false, default: 0, range: "0-10", description: "Quality improvement strength" }
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: "recraft-ai/recraft-crisp-upscale",
|
|
246
|
-
name: "Recraft Crisp Upscale",
|
|
247
|
-
description: "Enhances textures and facial features. Ideal for portraits.",
|
|
248
|
-
category: "image-enhance",
|
|
249
|
-
price: "Pay per use",
|
|
250
|
-
inputTypes: ["image/*"],
|
|
251
|
-
params: [
|
|
252
|
-
{ name: "image", type: "string", required: true, description: "Image URL or base64" }
|
|
253
|
-
]
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
id: "recraft-ai/recraft-creative-upscale",
|
|
257
|
-
name: "Recraft Creative Upscale",
|
|
258
|
-
description: "Generative enhancement adding depth and polish to complex elements.",
|
|
259
|
-
category: "image-enhance",
|
|
260
|
-
price: "$0.25/image",
|
|
261
|
-
inputTypes: ["image/*"],
|
|
262
|
-
params: [
|
|
263
|
-
{ name: "image", type: "string", required: true, description: "Image URL or base64" }
|
|
264
|
-
]
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
id: "wavespeed-ai/phota/enhance",
|
|
268
|
-
name: "Phota Enhance",
|
|
269
|
-
description: "Batch enhancement up to 4 images per run with optional 4K output.",
|
|
270
|
-
category: "image-enhance",
|
|
271
|
-
price: "$0.09/image",
|
|
272
|
-
inputTypes: ["image/*"],
|
|
273
|
-
params: [
|
|
274
|
-
{ name: "image", type: "string", required: true, description: "Image URL or base64 data URI" },
|
|
275
|
-
{ name: "num_images", type: "integer", required: false, default: 1, range: "1-4", description: "Enhanced variations to generate" },
|
|
276
|
-
{ name: "output_format", type: "string", required: false, default: "jpeg", options: ["jpeg", "png", "webp"], description: "Output format" }
|
|
277
|
-
]
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
id: "wavespeed-ai/z-image-turbo/image-to-image",
|
|
281
|
-
name: "Z-Image Turbo",
|
|
282
|
-
description: "Fast enhance with strength control. Low strength = subtle upscale.",
|
|
283
|
-
category: "image-enhance",
|
|
284
|
-
price: "$0.01/image",
|
|
285
|
-
inputTypes: ["image/*"],
|
|
286
|
-
params: [
|
|
287
|
-
{ name: "image", type: "string", required: true, description: "Reference image URL" },
|
|
288
|
-
{ name: "prompt", type: "string", required: true, description: "Enhancement prompt", default: "enhance image quality, sharp details" },
|
|
289
|
-
{ name: "strength", type: "number", required: false, default: 0.2, range: "0.00-1.00", description: "0-0.3 subtle enhance, 0.3-0.6 moderate, 0.6+ creative" },
|
|
290
|
-
{ name: "size", type: "string", required: false, default: "1024*1024", description: "Output size (width*height)" },
|
|
291
|
-
{ name: "seed", type: "integer", required: false, default: -1, range: "-1-2147483647", description: "Random seed. -1 = random" },
|
|
292
|
-
{ name: "output_format", type: "string", required: false, default: "jpeg", options: ["jpeg", "png", "webp"], description: "Output format" }
|
|
293
|
-
]
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
id: "wavespeed-ai/video-upscaler",
|
|
297
|
-
name: "Video Upscaler",
|
|
298
|
-
description: "Fast AI video upscaling to 720p-4K. Best value for video.",
|
|
299
|
-
category: "video-upscale",
|
|
300
|
-
price: "$0.005-0.02/sec",
|
|
301
|
-
inputTypes: ["video/*"],
|
|
302
|
-
params: [
|
|
303
|
-
{ name: "video", type: "string", required: true, description: "Video URL. Max 10 minutes" },
|
|
304
|
-
{ name: "target_resolution", type: "string", required: false, default: "1080p", options: ["720p", "1080p", "2k", "4k"], description: "Target resolution" }
|
|
305
|
-
]
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
id: "wavespeed-ai/video-upscaler-pro",
|
|
309
|
-
name: "Video Upscaler Pro",
|
|
310
|
-
description: "Motion-aware processing with artifact cleanup for pro results.",
|
|
311
|
-
category: "video-upscale",
|
|
312
|
-
price: "$0.03-0.05/sec",
|
|
313
|
-
inputTypes: ["video/*"],
|
|
314
|
-
params: [
|
|
315
|
-
{ name: "video", type: "string", required: true, description: "Video URL. Max 10 minutes" },
|
|
316
|
-
{ name: "target_resolution", type: "string", required: false, default: "1080p", options: ["720p", "1080p", "2k", "4k"], description: "Target resolution" }
|
|
317
|
-
]
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
id: "wavespeed-ai/ultimate-video-upscaler",
|
|
321
|
-
name: "Ultimate Video Upscaler",
|
|
322
|
-
description: "Deep learning detail reconstruction for highest quality 4K video.",
|
|
323
|
-
category: "video-upscale",
|
|
324
|
-
price: "$0.02-0.08/sec",
|
|
325
|
-
inputTypes: ["video/*"],
|
|
326
|
-
params: [
|
|
327
|
-
{ name: "video", type: "string", required: true, description: "Video URL. Max 10 minutes" },
|
|
328
|
-
{ name: "target_resolution", type: "string", required: false, default: "1080p", options: ["720p", "1080p", "2k", "4k"], description: "Target resolution" }
|
|
329
|
-
]
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: "wavespeed-ai/seedvr2/video",
|
|
333
|
-
name: "SeedVR2 Video",
|
|
334
|
-
description: "16B param ByteDance model. Highest fidelity with frame consistency.",
|
|
335
|
-
category: "video-upscale",
|
|
336
|
-
price: "$0.02-0.05/sec",
|
|
337
|
-
inputTypes: ["video/*"],
|
|
338
|
-
params: [
|
|
339
|
-
{ name: "video", type: "string", required: true, description: "Video URL. Max 10 minutes" },
|
|
340
|
-
{ name: "target_resolution", type: "string", required: false, default: "1080p", options: ["720p", "1080p", "2k", "4k"], description: "Target resolution" }
|
|
341
|
-
]
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
id: "bytedance/video-upscaler",
|
|
345
|
-
name: "ByteDance Video Upscaler",
|
|
346
|
-
description: "ByteDance super-resolution recovering fine detail to 4K.",
|
|
347
|
-
category: "video-upscale",
|
|
348
|
-
price: "$0.007-0.029/sec",
|
|
349
|
-
inputTypes: ["video/*"],
|
|
350
|
-
params: [
|
|
351
|
-
{ name: "video", type: "string", required: true, description: "Video URL" },
|
|
352
|
-
{ name: "target_resolution", type: "string", required: false, default: "1080p", options: ["1080p", "2k", "4k"], description: "Target resolution" }
|
|
353
|
-
]
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
id: "bria/fibo/video-upscaler",
|
|
357
|
-
name: "Bria Video Upscaler",
|
|
358
|
-
description: "Temporal consistency with multiple output codec options.",
|
|
359
|
-
category: "video-upscale",
|
|
360
|
-
price: "$0.14/sec",
|
|
361
|
-
inputTypes: ["video/*"],
|
|
362
|
-
params: [
|
|
363
|
-
{ name: "video", type: "string", required: true, description: "Video URL" },
|
|
364
|
-
{ name: "target_resolution", type: "string", required: false, default: "2k", options: ["2k", "4k"], description: "Target resolution" },
|
|
365
|
-
{ name: "output_container_and_codec", type: "string", required: false, default: "mp4_h264", options: ["webm_vp9", "mp4_h264", "mp4_h265", "mov_h265", "mov_prores4s", "mkv_h264", "mkv_h265", "mkv_vp9", "gif"], description: "Output container and codec" }
|
|
366
|
-
]
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
id: "runwayml/upscale-v1",
|
|
370
|
-
name: "RunwayML Upscale",
|
|
371
|
-
description: "Simple one-click video upscale to 4K by RunwayML.",
|
|
372
|
-
category: "video-upscale",
|
|
373
|
-
price: "$0.02/sec",
|
|
374
|
-
inputTypes: ["video/*"],
|
|
375
|
-
params: [
|
|
376
|
-
{ name: "video", type: "string", required: true, description: "Video URL. Max 10 minutes" }
|
|
377
|
-
]
|
|
378
|
-
}
|
|
379
|
-
];
|
|
380
|
-
var IMAGE_MODELS = MODELS.filter((m) => m.category !== "video-upscale");
|
|
381
|
-
var VIDEO_MODELS = MODELS.filter((m) => m.category === "video-upscale");
|
|
382
|
-
var DEFAULT_IMAGE_MODEL = "wavespeed-ai/image-upscaler";
|
|
383
|
-
var DEFAULT_VIDEO_MODEL = "wavespeed-ai/video-upscaler";
|
|
384
|
-
|
|
385
491
|
// src/cli.ts
|
|
386
|
-
|
|
492
|
+
init_models();
|
|
493
|
+
var VERSION2 = "0.3.0";
|
|
387
494
|
function parseArgs(argv) {
|
|
388
495
|
const args = [];
|
|
389
496
|
const flags = {};
|
|
@@ -409,7 +516,7 @@ function parseArgs(argv) {
|
|
|
409
516
|
}
|
|
410
517
|
function printHelp() {
|
|
411
518
|
console.log(`
|
|
412
|
-
upres-cli v${
|
|
519
|
+
upres-cli v${VERSION2} \u2014 AI image & video upscaling
|
|
413
520
|
|
|
414
521
|
USAGE
|
|
415
522
|
upres <command> [options]
|
|
@@ -420,12 +527,12 @@ COMMANDS
|
|
|
420
527
|
models List available models
|
|
421
528
|
jobs List recent jobs
|
|
422
529
|
account Show quota and plan info
|
|
530
|
+
mcp Speak MCP over stdin/stdout for Claude, Cursor, Hermes
|
|
423
531
|
version Print version
|
|
424
532
|
|
|
425
533
|
OPTIONS
|
|
426
|
-
--model <id>
|
|
427
|
-
--scale <n> Scale factor 2-8 (
|
|
428
|
-
--resolution <res> Target resolution: 2k, 4k, 8k, 720p, 1080p (default: 4k)
|
|
534
|
+
--model <id> Public alias (default: flare, motion for video, voice for speech)
|
|
535
|
+
--scale <n> Scale factor 2-8 (default: 4)
|
|
429
536
|
--output <path> Output file or directory
|
|
430
537
|
--api-key <key> API key (or set UPRES_API_KEY env var)
|
|
431
538
|
--wait Wait for job to complete (default: true)
|
|
@@ -436,22 +543,25 @@ OPTIONS
|
|
|
436
543
|
--help Show help
|
|
437
544
|
|
|
438
545
|
EXAMPLES
|
|
439
|
-
upres upscale photo.jpg --model
|
|
440
|
-
upres upscale photo.jpg --model
|
|
441
|
-
upres
|
|
546
|
+
upres upscale photo.jpg --model flare --scale 4
|
|
547
|
+
upres upscale photo.jpg --model lumen --scale 8 --output out.jpg
|
|
548
|
+
upres upscale clip.mp4 --model motion
|
|
549
|
+
upres batch ./photos/ --model flare --output ./upscaled/
|
|
442
550
|
upres models
|
|
443
551
|
upres jobs --limit 10 --status completed
|
|
444
552
|
upres account
|
|
445
553
|
|
|
446
554
|
API KEY
|
|
447
|
-
1. Get a
|
|
555
|
+
1. Get a key on the Business plan at https://upres.ai/account/api-keys
|
|
448
556
|
2. Export: UPRES_API_KEY=upres_yourkey
|
|
449
557
|
3. Or save: echo '{"apiKey":"upres_yourkey"}' > ~/.config/upres/config.json
|
|
450
558
|
|
|
451
559
|
PRICING
|
|
452
|
-
Free:
|
|
453
|
-
|
|
454
|
-
|
|
560
|
+
Free: 5 upscales/month
|
|
561
|
+
Creator: $9/month \u2014 50 upscales + 20 videos up to 8K
|
|
562
|
+
Pro: $19/month \u2014 100 upscales + 30 videos up to 8K
|
|
563
|
+
Studio: $39/month \u2014 250 upscales + 90 videos up to 8K
|
|
564
|
+
Business: $49/month \u2014 500 upscales + 150 videos up to 8K + API
|
|
455
565
|
|
|
456
566
|
https://upres.ai/pricing
|
|
457
567
|
`);
|
|
@@ -465,6 +575,8 @@ function resolveModel(modelArg, filePath) {
|
|
|
465
575
|
}
|
|
466
576
|
const ext = path2.extname(filePath).toLowerCase();
|
|
467
577
|
const videoExts = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".gif"];
|
|
578
|
+
const audioExts = [".wav", ".mp3", ".m4a", ".flac"];
|
|
579
|
+
if (audioExts.includes(ext)) return DEFAULT_AUDIO_MODEL;
|
|
468
580
|
return videoExts.includes(ext) ? DEFAULT_VIDEO_MODEL : DEFAULT_IMAGE_MODEL;
|
|
469
581
|
}
|
|
470
582
|
function resolveOutputPath(input, outputDir) {
|
|
@@ -485,7 +597,7 @@ async function cmdUpscale(args, flags) {
|
|
|
485
597
|
process.exit(1);
|
|
486
598
|
}
|
|
487
599
|
const client = new UpresClient({ apiKey: flags["api-key"] });
|
|
488
|
-
const
|
|
600
|
+
const model2 = resolveModel(flags.model, input);
|
|
489
601
|
const scale = flags.scale ? Number(flags.scale) : 4;
|
|
490
602
|
const resolution = flags.resolution ?? "4k";
|
|
491
603
|
const outputPath = flags.output;
|
|
@@ -496,9 +608,9 @@ async function cmdUpscale(args, flags) {
|
|
|
496
608
|
console.error(`Error: File not found: ${input}`);
|
|
497
609
|
process.exit(1);
|
|
498
610
|
}
|
|
499
|
-
process.stdout.write(`Submitting job... model=${
|
|
611
|
+
process.stdout.write(`Submitting job... model=${model2}
|
|
500
612
|
`);
|
|
501
|
-
let job = isFile ? await client.createJobFromFile(input, { model, scale }) : await client.createJobFromUrl(input, { model, scale });
|
|
613
|
+
let job = isFile ? await client.createJobFromFile(input, { model: model2, scale }) : await client.createJobFromUrl(input, { model: model2, scale });
|
|
502
614
|
console.log(`Job created: ${job.id} (status: ${job.status})`);
|
|
503
615
|
if (noWait) {
|
|
504
616
|
console.log(`Run "upres jobs" to check status.`);
|
|
@@ -537,17 +649,18 @@ async function cmdBatch(args, flags) {
|
|
|
537
649
|
process.exit(1);
|
|
538
650
|
}
|
|
539
651
|
const outputDir = flags.output ?? path2.join(dir, "upscaled");
|
|
540
|
-
const
|
|
652
|
+
const model2 = resolveModel(flags.model, files[0]);
|
|
541
653
|
const scale = flags.scale ? Number(flags.scale) : 4;
|
|
542
654
|
const concurrency = flags.concurrency ? Number(flags.concurrency) : 3;
|
|
543
|
-
console.log(`Batch upscaling ${files.length} images with ${
|
|
655
|
+
console.log(`Batch upscaling ${files.length} images with ${model2} (concurrency: ${concurrency})`);
|
|
544
656
|
const client = new UpresClient({ apiKey: flags["api-key"] });
|
|
545
657
|
let done = 0;
|
|
546
658
|
let failed = 0;
|
|
659
|
+
let accountError = false;
|
|
547
660
|
async function processFile(filePath) {
|
|
548
661
|
const filename = path2.basename(filePath);
|
|
549
662
|
try {
|
|
550
|
-
const job = await client.createJobFromFile(filePath, { model, scale });
|
|
663
|
+
const job = await client.createJobFromFile(filePath, { model: model2, scale });
|
|
551
664
|
const completed = await client.waitForJob(job.id);
|
|
552
665
|
if (completed.status === "failed") {
|
|
553
666
|
console.error(` FAILED ${filename}: ${completed.error}`);
|
|
@@ -561,21 +674,34 @@ async function cmdBatch(args, flags) {
|
|
|
561
674
|
} catch (e) {
|
|
562
675
|
console.error(` ERROR ${filename}: ${e.message}`);
|
|
563
676
|
failed++;
|
|
677
|
+
if (e instanceof UpresError) accountError = true;
|
|
564
678
|
}
|
|
565
679
|
}
|
|
566
680
|
for (let i = 0; i < files.length; i += concurrency) {
|
|
567
681
|
const chunk = files.slice(i, i + concurrency);
|
|
568
682
|
await Promise.all(chunk.map(processFile));
|
|
683
|
+
if (accountError) break;
|
|
569
684
|
}
|
|
570
685
|
console.log(`
|
|
571
686
|
Done: ${done} succeeded, ${failed} failed. Output: ${outputDir}`);
|
|
687
|
+
if (failed > 0) process.exitCode = 1;
|
|
572
688
|
}
|
|
689
|
+
var CATEGORY_LABEL = {
|
|
690
|
+
"image-upscale": "Image Upscale",
|
|
691
|
+
"image-clean": "Image Clean",
|
|
692
|
+
"image-restore": "Image Restore",
|
|
693
|
+
"image-studio": "Image Studio",
|
|
694
|
+
"video-upscale": "Video Upscale",
|
|
695
|
+
"video-clean": "Video Clean",
|
|
696
|
+
"video-restore": "Video Restore",
|
|
697
|
+
"video-studio": "Video Studio",
|
|
698
|
+
"audio-clean": "Speech"
|
|
699
|
+
};
|
|
573
700
|
function cmdModels() {
|
|
574
|
-
const categories = [
|
|
701
|
+
const categories = [...new Set(MODELS.map((m) => m.category))];
|
|
575
702
|
for (const cat of categories) {
|
|
576
|
-
const label = { "image-upscale": "Image Upscale", "image-enhance": "Image Enhance", "video-upscale": "Video Upscale" }[cat];
|
|
577
703
|
console.log(`
|
|
578
|
-
${
|
|
704
|
+
${CATEGORY_LABEL[cat] ?? cat}`);
|
|
579
705
|
console.log("\u2500".repeat(60));
|
|
580
706
|
for (const m of MODELS.filter((x) => x.category === cat)) {
|
|
581
707
|
console.log(` ${m.id.padEnd(44)} ${m.price}`);
|
|
@@ -622,6 +748,7 @@ Account info (based on recent jobs)`);
|
|
|
622
748
|
console.log(` API keys: https://upres.ai/account/api-keys`);
|
|
623
749
|
} catch (e) {
|
|
624
750
|
console.error(e.message);
|
|
751
|
+
process.exitCode = 1;
|
|
625
752
|
}
|
|
626
753
|
}
|
|
627
754
|
async function main() {
|
|
@@ -632,7 +759,7 @@ async function main() {
|
|
|
632
759
|
process.exit(0);
|
|
633
760
|
}
|
|
634
761
|
if (command === "version" || command === "--version" || command === "-v") {
|
|
635
|
-
console.log(`upres-cli v${
|
|
762
|
+
console.log(`upres-cli v${VERSION2}`);
|
|
636
763
|
process.exit(0);
|
|
637
764
|
}
|
|
638
765
|
switch (command) {
|
|
@@ -651,6 +778,11 @@ async function main() {
|
|
|
651
778
|
case "account":
|
|
652
779
|
await cmdAccount(flags);
|
|
653
780
|
break;
|
|
781
|
+
case "mcp": {
|
|
782
|
+
const { startStdio: startStdio2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
|
|
783
|
+
startStdio2();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
654
786
|
default:
|
|
655
787
|
console.error(`Unknown command: ${command}
|
|
656
788
|
Run "upres --help" for usage.`);
|