@genspark/cli 1.10.0 → 1.11.2

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.
Files changed (39) hide show
  1. package/README.md +24 -5
  2. package/dist/arrayArgs.d.ts +66 -0
  3. package/dist/arrayArgs.d.ts.map +1 -0
  4. package/dist/arrayArgs.js +144 -0
  5. package/dist/arrayArgs.js.map +1 -0
  6. package/dist/commands/aidrive-upload.d.ts +18 -0
  7. package/dist/commands/aidrive-upload.d.ts.map +1 -1
  8. package/dist/commands/aidrive-upload.js +21 -0
  9. package/dist/commands/aidrive-upload.js.map +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +66 -18
  12. package/dist/index.js.map +1 -1
  13. package/dist/runtime.d.ts +13 -9
  14. package/dist/runtime.d.ts.map +1 -1
  15. package/dist/runtime.js +15 -8
  16. package/dist/runtime.js.map +1 -1
  17. package/docs/skills.md +1 -1
  18. package/package.json +1 -1
  19. package/skills/gsk-aidrive/SKILL.md +11 -1
  20. package/skills/gsk-audio-transcribe/SKILL.md +1 -1
  21. package/skills/gsk-create-task/SKILL.md +5 -5
  22. package/skills/gsk-genteam/SKILL.md +5 -4
  23. package/skills/gsk-github/SKILL.md +0 -4
  24. package/skills/gsk-gmail/SKILL.md +6 -4
  25. package/skills/gsk-google-calendar/SKILL.md +4 -4
  26. package/skills/gsk-google-chat/SKILL.md +3 -3
  27. package/skills/gsk-google-docs/SKILL.md +0 -4
  28. package/skills/gsk-google-drive/SKILL.md +3 -3
  29. package/skills/gsk-google-sheets/SKILL.md +1 -5
  30. package/skills/gsk-google-slides/SKILL.md +0 -4
  31. package/skills/gsk-microsoft-teams/SKILL.md +17 -15
  32. package/skills/gsk-notion/SKILL.md +0 -4
  33. package/skills/gsk-onedrive/SKILL.md +3 -3
  34. package/skills/gsk-outlook-calendar/SKILL.md +3 -3
  35. package/skills/gsk-outlook-email/SKILL.md +8 -6
  36. package/skills/gsk-shared/SKILL.md +6 -4
  37. package/skills/gsk-sharepoint/SKILL.md +10 -13
  38. package/skills/gsk-slack/SKILL.md +3 -3
  39. package/skills/gsk-video-generation/SKILL.md +3 -3
package/README.md CHANGED
@@ -203,23 +203,42 @@ gsk me
203
203
 
204
204
  ### init-opencode
205
205
 
206
- Generate an `.opencode.json` config file for [OpenCode](https://opencode.ai), pre-configured to use Genspark's LLM proxy with your API key.
206
+ Generate an `opencode.json` config file for [OpenCode](https://opencode.ai), pre-configured to use Genspark's LLM proxy with your API key.
207
207
 
208
208
  ```bash
209
- # Generate with default model (claude-opus-4-6-1m)
209
+ # Generate with the server-selected default model
210
210
  gsk init-opencode
211
211
 
212
212
  # Specify a different default model
213
213
  gsk init-opencode --model claude-sonnet-4-6
214
214
 
215
215
  # Write to a custom path
216
- gsk init-opencode -o ./my-project/.opencode.json
216
+ gsk init-opencode -o ./my-project/opencode.json
217
217
  ```
218
218
 
219
219
  | Option | Default | Description |
220
220
  |--------|---------|-------------|
221
- | `--model <name>` | `claude-opus-4-6-1m` | Default model for OpenCode |
222
- | `-o, --out <path>` | `.opencode.json` (cwd) | Output file path |
221
+ | `--model <name>` | Server-selected | Default model for OpenCode |
222
+ | `-o, --out <path>` | `opencode.json` (cwd) | Output file path |
223
+
224
+ The generated models include per-model reasoning variants, selectable with OpenCode's variant selector:
225
+
226
+ | Models | Selectable levels |
227
+ |--------|-------------------|
228
+ | DeepSeek V4 Pro / Flash / Pro 0813 (text), including listed Baseten Pro | `none`, `low`, `high`, `max` |
229
+ | GLM-5.3 / GLM-5.3 Flash | `low`, `high`, `max` |
230
+ | GPT-5.2 / 5.4 (including mini/nano) / 5.5 | `none`, `low`, `medium`, `high`, `xhigh` |
231
+ | GPT-5.6 | `none`, `low`, `medium`, `high`, `xhigh`, `max` |
232
+ | GPT-6 Astra | `low`, `medium`, `high`, `xhigh`, `max` |
233
+ | Adaptive Claude | `low`, `medium`, `high`, `xhigh` |
234
+ | Legacy Claude / Grok 4.5 | `low`, `medium`, `high` |
235
+ | Gemini 3.1 Pro / 3.7 Flash / 3.8 Flash | `low`, `medium`, `high` |
236
+ | Gemini 3 Flash / 3.1 Flash Lite / 3.5 Flash / 3.6 Flash | `minimal`, `low`, `medium`, `high` |
237
+ | MiniMax M3 | `none` (off), `thinking` (always think); no selection keeps adaptive mode |
238
+
239
+ Model access gates still apply. Models without a verified end-to-end effort contract (including Kimi K3, GLM-5.2, Grok 4.6 and DeepSeek vision-exp) do not gain speculative levels. MiniMax modes are not reasoning-depth levels. Gemini uses native `thinkingConfig.thinkingLevel`, not `reasoning_effort`.
240
+
241
+ The server owns this catalog; regenerating overwrites the output file, so preserve custom settings first. No CLI package update is needed for catalog changes. For rollout, deploy the LiteLLM effort-forwarding hook before the backend catalog/validation change, then regenerate configs; this avoids advertising levels while an older proxy still pins or drops them. This command does not deploy either service.
223
242
 
224
243
  ### init-skills
225
244
 
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Schema-driven repair of JSON-array literals handed to array flags (#60410).
3
+ *
4
+ * Every schema `array` parameter is registered as a Commander variadic
5
+ * (`--name <values...>`, see addSchemaOption in index.ts) and nothing in the
6
+ * CLI JSON-parses flag values. So `--sheet_names '["A","B"]'` reaches the
7
+ * server as the ONE-element array `['["A","B"]']` — Google Sheets then created
8
+ * a sheet literally named `["A","B"]` and every later `B!A1:..` write 400'd.
9
+ * Agents write that shape because two sibling flags on the same command
10
+ * (`--values`, `--initial_data`) document exactly it, and the server-side
11
+ * repair from #47625 only covers those two.
12
+ *
13
+ * Contract:
14
+ * - Only a value that is a single string, or a one-element array holding a
15
+ * single string, whose trimmed text is a JSON array literal is touched.
16
+ * `--names a b`, real arrays from --args-file and per-element JSON
17
+ * objects (`--params '{"a":1}' '{"b":2}'`) are left alone.
18
+ * - Text that merely starts with `[` but is not valid JSON (`[Draft]`) is a
19
+ * legitimate value and passes through unchanged.
20
+ * - A literal that parses but whose elements do not match the schema's
21
+ * `items.type` is refused with an actionable error, and nothing is sent:
22
+ * the caller clearly meant a JSON array, so forwarding the text (or
23
+ * guessing a shape) would only move the failure server-side.
24
+ * - Escape hatch for a value that genuinely IS JSON-array-shaped text (a
25
+ * free-text answer such as `["yes","no"]`): put it in --args-file as a
26
+ * real JSON array, `{"answer": ["[\"yes\",\"no\"]"]}`. JSON has no
27
+ * shell ambiguity — an array there is an array and a string a string —
28
+ * so arrays that arrive from the file are forwarded verbatim; only a
29
+ * file STRING where the schema wants an array is repaired.
30
+ */
31
+ export interface ArrayParameterLike {
32
+ type: string | string[];
33
+ items?: {
34
+ type?: string | string[];
35
+ };
36
+ }
37
+ export type JsonArrayRepair = {
38
+ kind: 'unchanged';
39
+ } | {
40
+ kind: 'replaced';
41
+ value: unknown[];
42
+ } | {
43
+ kind: 'error';
44
+ message: string;
45
+ };
46
+ /**
47
+ * Decide what to do with one array parameter's value. Pure; never throws.
48
+ */
49
+ export declare function repairJsonArrayLiteral(name: string, value: unknown, param: ArrayParameterLike): JsonArrayRepair;
50
+ export interface RepairJsonArrayArgsOptions {
51
+ /**
52
+ * Parameters whose current value is a real JSON array from --args-file.
53
+ * Those arrays are forwarded verbatim (see the escape hatch above); a
54
+ * string value under one of these keys is still repaired.
55
+ */
56
+ literalArrayKeys?: ReadonlySet<string>;
57
+ }
58
+ /**
59
+ * Apply repairJsonArrayLiteral to every schema `array` parameter present in
60
+ * `args`, in place. A parameter counts as an array parameter when `array`
61
+ * appears anywhere in its `type` (a nullable `["null", "array"]` included).
62
+ * Returns the first refusal message, or null when every value was accepted
63
+ * (repaired or untouched).
64
+ */
65
+ export declare function repairJsonArrayArgs(args: Record<string, unknown>, props: Record<string, ArrayParameterLike>, options?: RepairJsonArrayArgsOptions): string | null;
66
+ //# sourceMappingURL=arrayArgs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrayArgs.d.ts","sourceRoot":"","sources":["../src/arrayArgs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACvB,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CACrC;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAqDtC;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,kBAAkB,GACxB,eAAe,CA0CjB;AAED,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACzC,OAAO,GAAE,0BAA+B,GACvC,MAAM,GAAG,IAAI,CAYf"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Schema-driven repair of JSON-array literals handed to array flags (#60410).
3
+ *
4
+ * Every schema `array` parameter is registered as a Commander variadic
5
+ * (`--name <values...>`, see addSchemaOption in index.ts) and nothing in the
6
+ * CLI JSON-parses flag values. So `--sheet_names '["A","B"]'` reaches the
7
+ * server as the ONE-element array `['["A","B"]']` — Google Sheets then created
8
+ * a sheet literally named `["A","B"]` and every later `B!A1:..` write 400'd.
9
+ * Agents write that shape because two sibling flags on the same command
10
+ * (`--values`, `--initial_data`) document exactly it, and the server-side
11
+ * repair from #47625 only covers those two.
12
+ *
13
+ * Contract:
14
+ * - Only a value that is a single string, or a one-element array holding a
15
+ * single string, whose trimmed text is a JSON array literal is touched.
16
+ * `--names a b`, real arrays from --args-file and per-element JSON
17
+ * objects (`--params '{"a":1}' '{"b":2}'`) are left alone.
18
+ * - Text that merely starts with `[` but is not valid JSON (`[Draft]`) is a
19
+ * legitimate value and passes through unchanged.
20
+ * - A literal that parses but whose elements do not match the schema's
21
+ * `items.type` is refused with an actionable error, and nothing is sent:
22
+ * the caller clearly meant a JSON array, so forwarding the text (or
23
+ * guessing a shape) would only move the failure server-side.
24
+ * - Escape hatch for a value that genuinely IS JSON-array-shaped text (a
25
+ * free-text answer such as `["yes","no"]`): put it in --args-file as a
26
+ * real JSON array, `{"answer": ["[\"yes\",\"no\"]"]}`. JSON has no
27
+ * shell ambiguity — an array there is an array and a string a string —
28
+ * so arrays that arrive from the file are forwarded verbatim; only a
29
+ * file STRING where the schema wants an array is repaired.
30
+ */
31
+ const PREVIEW_MAX = 80;
32
+ function literalText(value) {
33
+ if (typeof value === 'string')
34
+ return value;
35
+ if (Array.isArray(value) &&
36
+ value.length === 1 &&
37
+ typeof value[0] === 'string') {
38
+ return value[0];
39
+ }
40
+ return undefined;
41
+ }
42
+ function matchesItemType(element, expected) {
43
+ switch (expected) {
44
+ case 'string':
45
+ return typeof element === 'string';
46
+ case 'integer':
47
+ return typeof element === 'number' && Number.isInteger(element);
48
+ case 'number':
49
+ return typeof element === 'number';
50
+ case 'boolean':
51
+ return typeof element === 'boolean';
52
+ case 'array':
53
+ return Array.isArray(element);
54
+ case 'object':
55
+ return (typeof element === 'object' &&
56
+ element !== null &&
57
+ !Array.isArray(element));
58
+ case 'null':
59
+ return element === null;
60
+ default:
61
+ // Unknown item type: not ours to judge, the server validates.
62
+ return true;
63
+ }
64
+ }
65
+ function describeElement(element) {
66
+ if (element === null)
67
+ return 'null';
68
+ if (Array.isArray(element))
69
+ return 'an array';
70
+ if (typeof element === 'object')
71
+ return 'an object';
72
+ return `a ${typeof element}`;
73
+ }
74
+ function preview(text) {
75
+ return text.length > PREVIEW_MAX ? `${text.slice(0, PREVIEW_MAX)}…` : text;
76
+ }
77
+ /**
78
+ * Decide what to do with one array parameter's value. Pure; never throws.
79
+ */
80
+ export function repairJsonArrayLiteral(name, value, param) {
81
+ const text = literalText(value);
82
+ if (text === undefined)
83
+ return { kind: 'unchanged' };
84
+ const trimmed = text.trim();
85
+ if (!trimmed.startsWith('[') || !trimmed.endsWith(']')) {
86
+ return { kind: 'unchanged' };
87
+ }
88
+ let parsed;
89
+ try {
90
+ parsed = JSON.parse(trimmed);
91
+ }
92
+ catch {
93
+ // Not JSON: `[Draft]`-style text is a legitimate single value, so the
94
+ // caller's string goes through untouched (the server validates it).
95
+ return { kind: 'unchanged' };
96
+ }
97
+ if (!Array.isArray(parsed))
98
+ return { kind: 'unchanged' };
99
+ const rawItemType = param.items?.type;
100
+ const expected = rawItemType === undefined
101
+ ? []
102
+ : Array.isArray(rawItemType)
103
+ ? rawItemType
104
+ : [rawItemType];
105
+ if (expected.length > 0) {
106
+ const bad = parsed.findIndex(element => !expected.some(t => matchesItemType(element, t)));
107
+ if (bad !== -1) {
108
+ const want = expected.join(' or ');
109
+ return {
110
+ kind: 'error',
111
+ message: `--${name}: ${preview(trimmed)} parses as a JSON array, but element ` +
112
+ `${bad} is ${describeElement(parsed[bad])} where the schema wants ` +
113
+ `${want}. Pass one value per token (--${name} <v1> <v2>) or a JSON ` +
114
+ `array whose elements are all ${want}. The request was NOT sent ` +
115
+ '(nothing was billed).'
116
+ };
117
+ }
118
+ }
119
+ return { kind: 'replaced', value: parsed };
120
+ }
121
+ /**
122
+ * Apply repairJsonArrayLiteral to every schema `array` parameter present in
123
+ * `args`, in place. A parameter counts as an array parameter when `array`
124
+ * appears anywhere in its `type` (a nullable `["null", "array"]` included).
125
+ * Returns the first refusal message, or null when every value was accepted
126
+ * (repaired or untouched).
127
+ */
128
+ export function repairJsonArrayArgs(args, props, options = {}) {
129
+ for (const [name, param] of Object.entries(props)) {
130
+ const types = Array.isArray(param.type) ? param.type : [param.type];
131
+ if (!types.includes('array') || args[name] === undefined)
132
+ continue;
133
+ const fromFileAsArray = options.literalArrayKeys?.has(name) && Array.isArray(args[name]);
134
+ if (fromFileAsArray)
135
+ continue;
136
+ const repair = repairJsonArrayLiteral(name, args[name], param);
137
+ if (repair.kind === 'error')
138
+ return repair.message;
139
+ if (repair.kind === 'replaced')
140
+ args[name] = repair.value;
141
+ }
142
+ return null;
143
+ }
144
+ //# sourceMappingURL=arrayArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrayArgs.js","sourceRoot":"","sources":["../src/arrayArgs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAYH,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IACE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAC5B,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB,EAAE,QAAgB;IACzD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAA;QACpC,KAAK,SAAS;YACZ,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACjE,KAAK,QAAQ;YACX,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAA;QACpC,KAAK,SAAS;YACZ,OAAO,OAAO,OAAO,KAAK,SAAS,CAAA;QACrC,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA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,CAAA;AAC5C,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA6B,EAC7B,KAAyC,EACzC,UAAsC,EAAE;IAExC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,SAAQ;QAClE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAClE,IAAI,eAAe;YAAE,SAAQ;QAC7B,MAAM,MAAM,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QAC9D,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,MAAM,CAAC,OAAO,CAAA;QAClD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAA;IAC3D,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -12,4 +12,22 @@ export interface UploadFile {
12
12
  relativePath: string;
13
13
  }
14
14
  export declare function collectUploadFiles(root: string): UploadFile[];
15
+ /** Entry-id / URL addressing for the streaming upload lane (mirrors the
16
+ * server's --id/--owner/--url on the aidrive tool: a folder id is the
17
+ * destination base, upload_path is relative to it). */
18
+ export interface UploadLocator {
19
+ id?: string;
20
+ owner?: string;
21
+ url?: string;
22
+ }
23
+ /** Query string for POST /api/tool_cli/aidrive/upload — exported so the
24
+ * parameter contract is testable without streaming a file. */
25
+ export declare function buildAidriveUploadQuery(opts: {
26
+ uploadPath: string;
27
+ workspace: string;
28
+ override?: boolean;
29
+ onConflict?: string;
30
+ source?: string;
31
+ locator?: UploadLocator;
32
+ }): URLSearchParams;
15
33
  //# sourceMappingURL=aidrive-upload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aidrive-upload.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-upload.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,GAAG,SAAS,CAIpB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CA6B7D"}
1
+ {"version":3,"file":"aidrive-upload.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-upload.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,GAAG,SAAS,CAIpB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CA6B7D;AAED;;wDAEwD;AACxD,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;+DAC+D;AAC/D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,GAAG,eAAe,CAYlB"}
@@ -39,4 +39,25 @@ export function collectUploadFiles(root) {
39
39
  visit(normalizedRoot);
40
40
  return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
41
41
  }
42
+ /** Query string for POST /api/tool_cli/aidrive/upload — exported so the
43
+ * parameter contract is testable without streaming a file. */
44
+ export function buildAidriveUploadQuery(opts) {
45
+ const query = new URLSearchParams({
46
+ upload_path: opts.uploadPath,
47
+ workspace: opts.workspace,
48
+ });
49
+ if (opts.override)
50
+ query.set('override', 'true');
51
+ if (opts.onConflict)
52
+ query.set('on_conflict', opts.onConflict);
53
+ if (opts.source)
54
+ query.set('source', opts.source);
55
+ if (opts.locator?.id)
56
+ query.set('id', opts.locator.id);
57
+ if (opts.locator?.owner)
58
+ query.set('owner', opts.locator.owner);
59
+ if (opts.locator?.url)
60
+ query.set('url', opts.locator.url);
61
+ return query;
62
+ }
42
63
  //# sourceMappingURL=aidrive-upload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aidrive-upload.js","sourceRoot":"","sources":["../../src/commands/aidrive-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAExB;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAA2B;IAE3B,OAAO,QAAQ,CAAC,IAAI,CAClB,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CACjD,CAAA;AACH,CAAC;AAOD,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC9B,IA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"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AA2SH,KAAK,oBAAoB,GAAG,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEtE,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,kFAAkF;AAClF,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,GACb,mBAAmB,EAAE,CAqBvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AA8SH,KAAK,oBAAoB,GAAG,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEtE,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,kFAAkF;AAClF,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,GACb,mBAAmB,EAAE,CAqBvB"}
package/dist/index.js CHANGED
@@ -33,13 +33,14 @@ import { classifyFileArg, awaitLocalFileReady, decideAfterWait, localFileNotRead
33
33
  import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, progress, } from './logger.js';
34
34
  import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
35
35
  import { isPendingConfirmationEnvelope, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
36
+ import { repairJsonArrayArgs } from './arrayArgs.js';
36
37
  import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
37
38
  import { checkForUpdates } from './updater.js';
38
39
  import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
39
40
  import { shimLegacyTaskInvocation } from './task-shim.js';
40
41
  import { getSandboxRuntime } from './runtime.js';
41
42
  import { registerDesignCommand } from './commands/design.js';
42
- import { collectUploadFiles, pickExistingUploadOperand, } from './commands/aidrive-upload.js';
43
+ import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
43
44
  import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
44
45
  import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
45
46
  import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
@@ -368,7 +369,7 @@ async function uploadLocalFile(filePath, client) {
368
369
  *
369
370
  * This avoids the roundabout blob-upload + download_file two-step approach.
370
371
  */
371
- async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source, onConflict) {
372
+ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source, onConflict, locator) {
372
373
  const fileName = pathModule.basename(filePath);
373
374
  const ext = pathModule.extname(filePath).toLowerCase();
374
375
  const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
@@ -376,16 +377,14 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
376
377
  progress(`Uploading ${fileName} (${formatFileSize(fileSize)}, ${contentType}) directly to AI Drive...`);
377
378
  const globalOpts = getGlobalOptions();
378
379
  const baseUrl = globalOpts.baseUrl.replace(/\/$/, '');
379
- const uploadQuery = new URLSearchParams({
380
- upload_path: uploadPath,
380
+ const uploadQuery = buildAidriveUploadQuery({
381
+ uploadPath,
381
382
  workspace,
383
+ override,
384
+ onConflict,
385
+ source,
386
+ locator,
382
387
  });
383
- if (override)
384
- uploadQuery.set('override', 'true');
385
- if (onConflict)
386
- uploadQuery.set('on_conflict', onConflict);
387
- if (source)
388
- uploadQuery.set('source', source);
389
388
  const uploadUrl = `${baseUrl}/api/tool_cli/aidrive/upload?${uploadQuery.toString()}`;
390
389
  const headers = { 'Content-Type': contentType };
391
390
  if (globalOpts.apiKey)
@@ -1058,6 +1057,10 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1058
1057
  // deliberate rich payload, flags are the convenience layer (#46011).
1059
1058
  // It sits before the numeric coercion below so file-provided
1060
1059
  // numeric strings get the same schema-driven coercion flags do.
1060
+ // Array values that arrive from --args-file as real JSON arrays are
1061
+ // forwarded verbatim by the array-literal repair below (JSON has no
1062
+ // shell ambiguity); collected here because the merge erases origin.
1063
+ const fileProvidedArrays = new Set();
1061
1064
  if (argsFilePath) {
1062
1065
  let fileArgs;
1063
1066
  try {
@@ -1096,6 +1099,10 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1096
1099
  process.exit(1);
1097
1100
  }
1098
1101
  Object.assign(args, fileArgs);
1102
+ for (const [key, value] of Object.entries(fileArgs)) {
1103
+ if (Array.isArray(value))
1104
+ fileProvidedArrays.add(key);
1105
+ }
1099
1106
  // Required params were registered optional because the file may
1100
1107
  // carry them (Commander validates before the file is readable) —
1101
1108
  // re-validate the merged set now. CLI-populated params are
@@ -1130,6 +1137,23 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1130
1137
  }
1131
1138
  }
1132
1139
  }
1140
+ // Array flags are variadics that never JSON-parse, so a whole-array
1141
+ // literal (`--sheet_names '["A","B"]'`) arrives as ONE element and
1142
+ // the server acts on the text verbatim — Google Sheets created a
1143
+ // sheet literally named `["A","B"]` (#60410). Repair it here, after
1144
+ // the --args-file merge, so both input paths see one contract; an
1145
+ // element type that contradicts items.type is refused before any
1146
+ // server call, and a real array from the file is the literal escape
1147
+ // hatch (contract in arrayArgs.ts).
1148
+ {
1149
+ const arrayError = repairJsonArrayArgs(args, props, {
1150
+ literalArrayKeys: fileProvidedArrays,
1151
+ });
1152
+ if (arrayError) {
1153
+ logError(arrayError);
1154
+ process.exit(1);
1155
+ }
1156
+ }
1133
1157
  // Pre-call confirmation (confirm.ts): when the cached /tools
1134
1158
  // payload advertised interactive_confirm AND the schema marks this
1135
1159
  // tool/action confirmation-required, resolve [y/N] / --yes /
@@ -1280,7 +1304,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1280
1304
  ? invokedCmd.args.slice(1)
1281
1305
  : invokedCmd.args;
1282
1306
  const { drivePath: sourceOperand, localPath: operandDest } = resolveAidriveDownloadOperands(operandCandidates, typeof args.path === 'string' ? args.path : undefined);
1283
- if (!sourceOperand) {
1307
+ const hasDownloadLocator = !!(args.id || args.url);
1308
+ if (!sourceOperand && !hasDownloadLocator) {
1284
1309
  logError('download needs the AI-Drive path: gsk aidrive download ' +
1285
1310
  '<ai-drive-path> [local-path] (or --path/-p). To save an ' +
1286
1311
  'external url INTO AI Drive instead, use ' +
@@ -1289,8 +1314,16 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1289
1314
  }
1290
1315
  // Attachments arrive spelled `aidrive:///a/b.pdf`; take that as-is
1291
1316
  // rather than making the caller strip the scheme.
1292
- const drivePath = normalizeDrivePath(sourceOperand);
1317
+ const drivePath = sourceOperand ? normalizeDrivePath(sourceOperand) : undefined;
1318
+ // --id / --owner / --url resolve server-side inside get_readable_url;
1319
+ // with them the path operand is optional.
1320
+ const downloadLocator = {
1321
+ id: args.id,
1322
+ owner: args.owner,
1323
+ url: args.url,
1324
+ };
1293
1325
  const urlResult = await client.executeTool('aidrive', {
1326
+ ...downloadLocator,
1294
1327
  // Use the established wire spelling; both older backends and the
1295
1328
  // current canonical contract recognize it.
1296
1329
  action: 'get_readable_url',
@@ -1304,14 +1337,18 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1304
1337
  logError(`Failed to resolve AI-Drive path ${drivePath}: ${urlResult.message}`);
1305
1338
  process.exit(1);
1306
1339
  }
1340
+ // Addressed by id/url, the drive path comes back from the server:
1341
+ // get_readable_url reports "Readable URL for <path>: <url>".
1342
+ const reportedPath = /Readable URL for (.+?): https?:\/\//.exec(String(urlResult.data?.result ?? ''))?.[1];
1343
+ const resolvedDrivePath = drivePath ?? reportedPath ?? String(args.id ?? 'download');
1307
1344
  const destPath = (typeof opts.local_file === 'string' ? opts.local_file : '') ||
1308
1345
  operandDest ||
1309
- pathModule.basename(drivePath);
1346
+ pathModule.basename(resolvedDrivePath);
1310
1347
  const savedPath = await downloadToFile(readableUrl, destPath, client);
1311
1348
  output({
1312
1349
  status: 'ok',
1313
1350
  message: 'AI-Drive file downloaded to local disk',
1314
- data: { ai_drive_path: drivePath, local_path: savedPath },
1351
+ data: { ai_drive_path: resolvedDrivePath, local_path: savedPath },
1315
1352
  });
1316
1353
  return;
1317
1354
  }
@@ -1371,9 +1408,20 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1371
1408
  }
1372
1409
  // args.upload_path is safe here: args = { ...opts } at line above, and
1373
1410
  // only local_file/override were deleted from args — upload_path is intact.
1411
+ // --id / --owner / --url: the server resolves the folder and treats
1412
+ // upload_path as RELATIVE to it, so keep the caller's spelling and
1413
+ // default to the file name instead of forcing a leading slash.
1414
+ const locator = {
1415
+ id: args.id,
1416
+ owner: args.owner,
1417
+ url: args.url,
1418
+ };
1419
+ const addressedById = !!(locator.id || locator.url);
1374
1420
  const rawUploadPath = args.upload_path ||
1375
- `/${pathModule.basename(localFilePath)}`;
1376
- const uploadPath = rawUploadPath.startsWith('/')
1421
+ (addressedById
1422
+ ? pathModule.basename(localFilePath)
1423
+ : `/${pathModule.basename(localFilePath)}`);
1424
+ const uploadPath = addressedById || rawUploadPath.startsWith('/')
1377
1425
  ? rawUploadPath
1378
1426
  : `/${rawUploadPath}`;
1379
1427
  const localStat = fs.statSync(localFilePath);
@@ -1387,7 +1435,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1387
1435
  const uploaded = [];
1388
1436
  for (const file of files) {
1389
1437
  const destination = pathModule.posix.join(uploadPath, file.relativePath);
1390
- const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source, onConflict);
1438
+ const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source, onConflict, locator);
1391
1439
  if (result.status !== 'ok') {
1392
1440
  output(result);
1393
1441
  process.exit(1);
@@ -1407,7 +1455,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1407
1455
  }
1408
1456
  else {
1409
1457
  // Stream directly to AI Drive — single request, no blob middleman
1410
- const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source, onConflict);
1458
+ const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source, onConflict, locator);
1411
1459
  output(result);
1412
1460
  }
1413
1461
  return;