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