@wavespeed/cli 0.4.3 → 0.4.4

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 CHANGED
@@ -195,3 +195,8 @@ Stack: TypeScript, Commander, Inquirer, Chalk, Ora, the official `wavespeed` SDK
195
195
  ## License
196
196
 
197
197
  MIT — see [LICENSE](LICENSE).
198
+
199
+ ---
200
+
201
+ **[WaveSpeed AI](https://wavespeed.ai/)** — AI image & video generation platform.
202
+ Try it in the browser: **[Image generator](https://wavespeed.ai/image-generator)** · **[Video generator](https://wavespeed.ai/video-generator)**
@@ -3,7 +3,7 @@ import ora from 'ora';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import { requireClient } from '../lib/client.js';
6
- import { parseInputs } from '../lib/inputs.js';
6
+ import { parseInputs, withInputSyntaxHint } from '../lib/inputs.js';
7
7
  import { resolveLocalFiles } from '../lib/local-files.js';
8
8
  import { submitPrediction, waitForPrediction } from '../lib/api.js';
9
9
  import { uploadWithCache } from '../lib/upload-cache.js';
@@ -137,7 +137,7 @@ export function registerRun(program) {
137
137
  submitted = await submitPrediction(model, input, { sync: !!opts.sync });
138
138
  }
139
139
  catch (err) {
140
- const message = err.message ?? String(err);
140
+ const message = withInputSyntaxHint(err.message ?? String(err), opts.input);
141
141
  spinner.fail(message);
142
142
  if (isJsonMode())
143
143
  emitJsonError(message);
@@ -2,8 +2,9 @@
2
2
  // - bare strings stay strings
3
3
  // - "123" / "1.5" parsed as number
4
4
  // - "true" / "false" parsed as boolean
5
- // - "[a,b,c]" parsed as array of strings
6
- // - JSON values (starting with { or [) parsed as JSON
5
+ // - values starting with { or [ are parsed as JSON, and stay strings if that
6
+ // fails — so an array has to be written as valid JSON: '["a","b"]'.
7
+ // A bare "[a,b,c]" is not JSON and reaches the API as a string.
7
8
  // - keys with dots like "size.width" become nested
8
9
  function coerce(raw) {
9
10
  if (raw === 'true')
@@ -50,3 +51,16 @@ function setPath(obj, dotted, value) {
50
51
  }
51
52
  cur[parts[parts.length - 1]] = value;
52
53
  }
54
+ /**
55
+ * The API rejects a scalar sent to an array field. The message says what is
56
+ * wrong but not how to write it, and `-i key=value` gives no hint that an
57
+ * array needs JSON — so point at the fix rather than mutating the input.
58
+ */
59
+ export function withInputSyntaxHint(message, pairs = []) {
60
+ const field = /field "([^"]+)" must be an array/.exec(message)?.[1];
61
+ if (!field)
62
+ return message;
63
+ const given = pairs.find((p) => p.slice(0, p.indexOf('=')).trim() === field);
64
+ const sample = given ? given.slice(given.indexOf('=') + 1) : 'value';
65
+ return `${message}\nWrite arrays as JSON: -i '${field}=["${sample}"]'`;
66
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wavespeed/cli",
3
- "version": "0.4.3",
4
- "description": "WaveSpeed CLI \u2014 one command to run any WaveSpeed AI model from your terminal.",
3
+ "version": "0.4.4",
4
+ "description": "WaveSpeed CLI — one command to run any WaveSpeed AI model from your terminal.",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },