@genspark/cli 1.13.1 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -339,4 +339,22 @@ export function saveToolsCache(baseUrl, tools, features) {
339
339
  _cachedFeatures = validatedFeatures;
340
340
  fs.writeFileSync(cachePath, JSON.stringify(cache, null, 2), 'utf-8');
341
341
  }
342
+ /**
343
+ * The credential the CLI sends on its own HTTP requests.
344
+ *
345
+ * GenTeam sandboxes export a per-turn credential (`dtk-…`, minted by the
346
+ * backend for the running turn — see
347
+ * `backend/digital_employee/runtime/turn_credential.py`) as
348
+ * `GSK_TURN_TOKEN` into each bash exec. It is preferred over the
349
+ * per-agent `GSK_API_KEY` for gsk requests only: `GSK_API_KEY` itself is
350
+ * untouched because sb-git clone URLs and other tooling still need the
351
+ * plain key. Anything else in the variable is ignored (fail back to the
352
+ * key), so a stray value can never break the CLI.
353
+ */
354
+ export function resolveRequestCredential(apiKey, env = process.env) {
355
+ const turn = env.GSK_TURN_TOKEN;
356
+ if (typeof turn === 'string' && turn.startsWith('dtk-'))
357
+ return turn;
358
+ return apiKey || '';
359
+ }
342
360
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAoBnC,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,mEAAmE;AACnE,6EAA6E;AAC7E,4EAA4E;AAC5E,0BAA0B;AAC1B,EAAE;AACF,+DAA+D;AAC/D,0EAA0E;A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AAC,GAAG;IAEpC,MAAM,IAAI,GAAG,GAAG,CAAC,cAAc,CAAA;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACpE,OAAO,MAAM,IAAI,EAAE,CAAA;AACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AA4fH,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;AAqgBH,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
@@ -45,7 +45,8 @@ import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken
45
45
  import { shimLegacyTaskInvocation } from './task-shim.js';
46
46
  import { getSandboxRuntime } from './runtime.js';
47
47
  import { registerDesignCommand } from './commands/design.js';
48
- import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
48
+ import { collectUploadFiles, aidriveUploadHeaders, buildAidriveUploadQuery, mergeShareIntoUpload, normalizeUploadDestination, resolveAidriveUploadOperands, shareArgsFromUpload, uploadConflictFromCli, uploadConflictProblem, uploadPathForDestination, uploadShareRefusal, } from './commands/aidrive-upload.js';
49
+ import { aidriveOperandArgs } from './commands/aidrive-operands.js';
49
50
  import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
50
51
  import { fileNameFromContentDisposition, genteamAttachmentEndpoint, resolveGenteamDownloadDestination, saveBodyToFile, } from './commands/genteam-download.js';
51
52
  import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
@@ -549,7 +550,7 @@ async function uploadLocalFile(filePath, client) {
549
550
  *
550
551
  * This avoids the roundabout blob-upload + download_file two-step approach.
551
552
  */
552
- async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source, onConflict, locator) {
553
+ async function uploadToAiDrive(filePath, uploadPath, workspace = 'my_drive', source, onConflict, locator) {
553
554
  const fileName = pathModule.basename(filePath);
554
555
  const ext = pathModule.extname(filePath).toLowerCase();
555
556
  const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
@@ -560,17 +561,16 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
560
561
  const uploadQuery = buildAidriveUploadQuery({
561
562
  uploadPath,
562
563
  workspace,
563
- override,
564
564
  onConflict,
565
565
  source,
566
566
  locator,
567
567
  });
568
568
  const uploadUrl = `${baseUrl}/api/tool_cli/aidrive/upload?${uploadQuery.toString()}`;
569
- const headers = { 'Content-Type': contentType };
570
- if (globalOpts.apiKey)
571
- headers['X-Api-Key'] = globalOpts.apiKey;
572
- if (globalOpts.projectId)
573
- headers['X-Project-ID'] = globalOpts.projectId;
569
+ const headers = aidriveUploadHeaders({
570
+ apiKey: globalOpts.apiKey,
571
+ projectId: globalOpts.projectId,
572
+ contentType,
573
+ });
574
574
  debug(`AI Drive upload URL: ${uploadUrl}`);
575
575
  const responseBody = await streamFileUpload(filePath, uploadUrl, headers, fileSize, 'POST');
576
576
  try {
@@ -678,9 +678,12 @@ function encodeAttachmentInline(filePath) {
678
678
  * the bytes only exist for the duration of the email-send request. Hosted
679
679
  * URLs in the same array are passed through unchanged.
680
680
  */
681
- async function resolveLocalFiles(args, client) {
681
+ async function resolveLocalFiles(args, client, locatorKeys = new Set()) {
682
682
  const resolved = { ...args };
683
683
  for (const [key, value] of Object.entries(resolved)) {
684
+ // A locator names an entry on the server, never a local file to upload.
685
+ if (locatorKeys.has(key))
686
+ continue;
684
687
  // Email `attachments` — inline base64, no blob round-trip.
685
688
  if (key === 'attachments' && Array.isArray(value)) {
686
689
  const out = [];
@@ -1116,9 +1119,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1116
1119
  cmd.option('--workspace <value>', 'AI Drive workspace: my_drive, shared_with_me, or shared_drive');
1117
1120
  }
1118
1121
  cmd.option('--local_file <path>', 'upload: local file path to upload to AI Drive (supports files >5 MB; ' +
1119
- 'alternative to --file_content). download: local destination path ' +
1122
+ 'alternative to --file_content; same as the first operand of ' +
1123
+ '`upload <local> <drive folder>/`). download: local destination path ' +
1120
1124
  '(same as the second operand; default ./<basename of the drive path>)');
1121
- cmd.option('--override', 'Overwrite an existing file at the destination path (used with --local_file)', false);
1125
+ // An optional value, as schema booleans take: presence-only, the
1126
+ // `false` in `--override false` was left over and the upload overwrote.
1127
+ cmd.option('--override [value]', 'Overwrite an existing file at the destination path (used with --local_file)', parseBooleanFlagValue);
1122
1128
  cmd.option('--on-conflict <mode>', 'upload: what to do when the destination name is taken — ' +
1123
1129
  'error | rename | overwrite (default: rename, which lands ' +
1124
1130
  'name(1).ext and reports the path actually written). Use error for ' +
@@ -1452,6 +1458,41 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1452
1458
  process.exit(1);
1453
1459
  }
1454
1460
  }
1461
+ // aidrive: a drive path written as an operand (`gsk drive ls
1462
+ // /Reports`, `gsk drive move /q3.pdf /Archive`) fills the action's
1463
+ // parameters. Commander keeps such operands but maps none of them,
1464
+ // so the server used to answer "Missing required parameter: path".
1465
+ // Upload and download read their operands in their own lanes below.
1466
+ // The operands after the action: a per-action subcommand's are all
1467
+ // bare; the union command's first is the action, unless --args-file
1468
+ // carried it and Commander bound a bare path to the action slot.
1469
+ let aidriveOperands = [];
1470
+ if (tool.name === 'aidrive' && typeof args.action === 'string') {
1471
+ const actionNames = props.action?.enum;
1472
+ if (invokedCmd === cmd &&
1473
+ primaryArgValue !== undefined &&
1474
+ primaryArgValue !== args.action &&
1475
+ Array.isArray(actionNames) &&
1476
+ actionNames.includes(primaryArgValue)) {
1477
+ // Read as an operand, `drive ls --args-file` with a file saying
1478
+ // "rm" would have removed a path named "ls".
1479
+ logError(`The command line names the action ${primaryArgValue} and ` +
1480
+ `--args-file names ${args.action}; pass one. Nothing was sent.`);
1481
+ process.exit(1);
1482
+ }
1483
+ aidriveOperands =
1484
+ invokedCmd !== cmd
1485
+ ? invokedCmd.args
1486
+ : primaryArgValue !== undefined && primaryArgValue === args.action
1487
+ ? invokedCmd.args.slice(1)
1488
+ : invokedCmd.args;
1489
+ const mapped = aidriveOperandArgs(args.action, aidriveOperands, args);
1490
+ if (mapped.error) {
1491
+ logError(mapped.error);
1492
+ process.exit(1);
1493
+ }
1494
+ Object.assign(args, mapped.filled);
1495
+ }
1455
1496
  // Pre-call confirmation (confirm.ts): when the cached /tools
1456
1497
  // payload advertised interactive_confirm AND the schema marks this
1457
1498
  // tool/action confirmation-required, resolve [y/N] / --yes /
@@ -1560,40 +1601,86 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1560
1601
  // only, not CLI-populated ones).
1561
1602
  args.files = collected.files;
1562
1603
  }
1563
- // aidrive upload ergonomics: `gsk aidrive upload <path>` is the natural
1564
- // invocation and the dominant fumble — the bare path is an excess
1565
- // operand that Commander tolerates but never maps to an option, so the
1566
- // request otherwise reaches the API with no content and fails with a
1567
- // misleading "Missing file_content". When no explicit content source was
1568
- // given, adopt a path-like operand as --local_file (cmd.args[0] is the
1569
- // 'upload' action; later operands are candidate paths, directories
1570
- // skipped) so the streaming upload below handles it; if there is still
1571
- // no usable source, fail with an actionable message that names
1572
- // --local_file rather than the opaque backend error.
1573
- if (tool.name === 'aidrive' &&
1574
- // args.action, not the positional: the action may arrive via
1575
- // --args-file (sb-git's clone-url gate uses the same pattern).
1576
- args.action === 'upload' &&
1577
- !opts.local_file &&
1604
+ // aidrive upload operands: `gsk drive upload <local> [<drive
1605
+ // destination>]`. A bare local path is an operand Commander tolerates
1606
+ // but never maps, so the request used to reach the API with no
1607
+ // content ("Missing file_content"), and a destination operand or
1608
+ // `-p` was dropped, landing the file at the drive root. The local
1609
+ // source is --local_file or the first operand that exists on disk;
1610
+ // the destination is `-p` or the operand left over, read by the
1611
+ // lanes below. With no usable source, fail with an actionable
1612
+ // message that names --local_file rather than the opaque backend
1613
+ // error.
1614
+ let uploadDestination;
1615
+ if (tool.name === 'aidrive' && args.action === 'upload') {
1578
1616
  // args, not opts: file_content is a server param and may have
1579
1617
  // arrived via --args-file (merged into args above).
1580
- !args.file_content) {
1581
- // Skip the first operand only when it really is the action: with
1582
- // the action arriving via --args-file, Commander binds a bare
1583
- // path to the [action] positional slot, so cmd.args[0] is itself
1584
- // a path candidate.
1585
- const operandCandidates = primaryArgValue !== undefined && primaryArgValue === args.action
1586
- ? invokedCmd.args.slice(1)
1587
- : invokedCmd.args;
1588
- const pathOperand = pickExistingUploadOperand(operandCandidates);
1589
- if (pathOperand) {
1590
- opts.local_file = pathOperand;
1618
+ const inline = !!args.file_content && !opts.local_file;
1619
+ const resolved = resolveAidriveUploadOperands({
1620
+ operands: aidriveOperands,
1621
+ localFile: typeof opts.local_file === 'string' ? opts.local_file : undefined,
1622
+ inline,
1623
+ path: typeof args.path === 'string' ? args.path : undefined,
1624
+ uploadPath: typeof args.upload_path === 'string'
1625
+ ? args.upload_path
1626
+ : undefined,
1627
+ });
1628
+ if (resolved.error) {
1629
+ logError(resolved.error);
1630
+ process.exit(1);
1631
+ }
1632
+ // `-p` was the destination; upload has no `path` of its own.
1633
+ delete args.path;
1634
+ for (const key of ['destination', 'upload_path']) {
1635
+ const value = key === 'destination' ? resolved.destination : args.upload_path;
1636
+ if (typeof value !== 'string' || !value)
1637
+ continue;
1638
+ const normalized = normalizeUploadDestination(value);
1639
+ if (normalized.error) {
1640
+ logError(normalized.error);
1641
+ process.exit(1);
1642
+ }
1643
+ if (key === 'destination')
1644
+ uploadDestination = normalized.path;
1645
+ else
1646
+ args.upload_path = normalized.path;
1647
+ }
1648
+ if (inline) {
1649
+ // Inline content has no file name of its own, so its
1650
+ // destination is the file's full path as written.
1651
+ if (uploadDestination !== undefined) {
1652
+ if (uploadDestination.endsWith('/')) {
1653
+ logError(`--file_content needs the file's full path; ${uploadDestination} ` +
1654
+ 'names a folder: add the file name. Nothing was sent.');
1655
+ process.exit(1);
1656
+ }
1657
+ // Relative to a folder --id/--url names; otherwise from the
1658
+ // drive root, which the tool lane requires spelled out.
1659
+ args.upload_path =
1660
+ args.id || args.url || uploadDestination.startsWith('/')
1661
+ ? uploadDestination
1662
+ : `/${uploadDestination}`;
1663
+ }
1664
+ // The tool lane knows `overwrite` only; --on-conflict and
1665
+ // --override are the CLI's spellings, so map them here rather
1666
+ // than let them vanish with the other CLI-only flags.
1667
+ const conflict = uploadConflictFromCli(opts, args);
1668
+ const problem = uploadConflictProblem(conflict, args, true);
1669
+ if (problem) {
1670
+ logError(`${problem}. Nothing was sent.`);
1671
+ process.exit(1);
1672
+ }
1673
+ if (conflict.onConflict === 'overwrite')
1674
+ args.overwrite = true;
1675
+ }
1676
+ else if (resolved.localFile) {
1677
+ opts.local_file = resolved.localFile;
1591
1678
  }
1592
1679
  else {
1593
1680
  logError('upload needs a file source: use `--local_file <path>` for a ' +
1594
1681
  'local file (any size, binaries OK) or `--file_content <text>` ' +
1595
- 'for inline text. Example: gsk aidrive upload --local_file ' +
1596
- './report.pdf --upload_path /report.pdf');
1682
+ 'for inline text. Example: gsk drive upload ./report.pdf ' +
1683
+ '/Reports/');
1597
1684
  process.exit(1);
1598
1685
  }
1599
1686
  }
@@ -1745,19 +1832,29 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1745
1832
  args.action === 'upload' &&
1746
1833
  opts.local_file) {
1747
1834
  const localFilePath = opts.local_file;
1748
- const override = !!opts.override;
1749
1835
  // --on-conflict error|rename|overwrite (#54379). Default (unset) is
1750
1836
  // rename server-side: nobody is here to answer a prompt, and
1751
1837
  // dead-ending an agent mid-task is worse than landing a copy.
1752
1838
  // `error` is kept for idempotent scripts that read a failure as
1753
1839
  // "nothing was written" — with rename they would accumulate a copy
1754
- // per retry.
1755
- // Commander camelCases `--on-conflict` to `onConflict`; the other
1756
- // spellings are only for a caller that passed the raw arg through.
1757
- const onConflict = (opts.onConflict ??
1758
- opts['on-conflict'] ??
1759
- opts.on_conflict ??
1760
- args.on_conflict);
1840
+ // per retry. `--overwrite true` (the tool schema's spelling) and
1841
+ // `--override` both mean overwrite here. Commander camelCases
1842
+ // `--on-conflict` to `onConflict`; the other spellings are only
1843
+ // for a caller that passed the raw arg through.
1844
+ const conflict = uploadConflictFromCli(opts, args);
1845
+ const problem = uploadConflictProblem(conflict, args, false);
1846
+ if (problem) {
1847
+ logError(`${problem}. Nothing was sent.`);
1848
+ process.exit(1);
1849
+ }
1850
+ const onConflict = conflict.onConflict;
1851
+ // `upload --to <who>` / `--general_access <audience>`: share the
1852
+ // file the moment it lands, and answer with the link that opens
1853
+ // for them — the share verb the caller would run next, addressed
1854
+ // by the uploaded entry's id. My Drive only, as on the server:
1855
+ // a shared source's sharing has its own verb and admin gate.
1856
+ const shareAfterUpload = shareArgsFromUpload(args);
1857
+ const sharesAfterUpload = Object.keys(shareAfterUpload).length > 0;
1761
1858
  const workspace = args.workspace || 'my_drive';
1762
1859
  const source = args.source ||
1763
1860
  args.share;
@@ -1766,7 +1863,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1766
1863
  process.exit(1);
1767
1864
  }
1768
1865
  // args.upload_path is safe here: args = { ...opts } at line above, and
1769
- // only local_file/override were deleted from args — upload_path is intact.
1866
+ // only the CLI-only flags (local_file, override, onConflict) were
1867
+ // deleted from args — upload_path is intact.
1770
1868
  // --id / --owner / --url: the server resolves the folder and treats
1771
1869
  // upload_path as RELATIVE to it, so keep the caller's spelling and
1772
1870
  // default to the file name instead of forcing a leading slash.
@@ -1776,15 +1874,42 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1776
1874
  url: args.url,
1777
1875
  };
1778
1876
  const addressedById = !!(locator.id || locator.url);
1877
+ const localStat = fs.statSync(localFilePath);
1878
+ // --upload_path is the exact path; an operand or `-p` destination
1879
+ // is a folder unless it names the upload itself.
1880
+ let destinationPath;
1881
+ if (!args.upload_path && uploadDestination !== undefined) {
1882
+ const placed = uploadPathForDestination(uploadDestination, localFilePath, localStat.isDirectory());
1883
+ if (placed.error) {
1884
+ logError(placed.error);
1885
+ process.exit(1);
1886
+ }
1887
+ destinationPath = placed.uploadPath;
1888
+ }
1779
1889
  const rawUploadPath = args.upload_path ||
1890
+ destinationPath ||
1891
+ // Named after the resolved path, as with a destination: `.`
1892
+ // spread its files over the drive root.
1780
1893
  (addressedById
1781
- ? pathModule.basename(localFilePath)
1782
- : `/${pathModule.basename(localFilePath)}`);
1894
+ ? pathModule.basename(pathModule.resolve(localFilePath))
1895
+ : `/${pathModule.basename(pathModule.resolve(localFilePath))}`);
1783
1896
  const uploadPath = addressedById || rawUploadPath.startsWith('/')
1784
1897
  ? rawUploadPath
1785
1898
  : `/${rawUploadPath}`;
1786
- const localStat = fs.statSync(localFilePath);
1787
1899
  const files = collectUploadFiles(localFilePath);
1900
+ if (sharesAfterUpload) {
1901
+ const refusal = uploadShareRefusal({
1902
+ workspace,
1903
+ source,
1904
+ addressedById: Boolean(args.id || args.url),
1905
+ isDirectory: localStat.isDirectory(),
1906
+ uploadPath,
1907
+ });
1908
+ if (refusal) {
1909
+ logError(refusal);
1910
+ process.exit(1);
1911
+ }
1912
+ }
1788
1913
  if (localStat.isDirectory()) {
1789
1914
  if (files.length === 0) {
1790
1915
  logError(`Folder has no files to upload: ${localFilePath}`);
@@ -1794,7 +1919,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1794
1919
  const uploaded = [];
1795
1920
  for (const file of files) {
1796
1921
  const destination = pathModule.posix.join(uploadPath, file.relativePath);
1797
- const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source, onConflict, locator);
1922
+ const result = await uploadToAiDrive(file.absolutePath, destination, workspace, source, onConflict, locator);
1798
1923
  if (result.status !== 'ok') {
1799
1924
  output(result);
1800
1925
  process.exit(1);
@@ -1815,8 +1940,37 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1815
1940
  }
1816
1941
  else {
1817
1942
  // Stream directly to AI Drive — single request, no blob middleman
1818
- const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source, onConflict, locator);
1819
- output(result);
1943
+ const result = await uploadToAiDrive(localFilePath, uploadPath, workspace, source, onConflict, locator);
1944
+ const uploadedData = result.data;
1945
+ const uploadedId = uploadedData?.entry_id || uploadedData?.id;
1946
+ if (result.status !== 'ok' || !sharesAfterUpload || !uploadedId) {
1947
+ if (result.status === 'ok' && sharesAfterUpload && !uploadedId) {
1948
+ result.message +=
1949
+ ' (the server did not return the file id, so it was not shared; run `gsk drive share` on it)';
1950
+ }
1951
+ output(result);
1952
+ return;
1953
+ }
1954
+ // A share that throws (network, parse) must not read as a
1955
+ // failed upload: the file is written, and a retry would land a
1956
+ // second copy.
1957
+ let shared;
1958
+ try {
1959
+ shared = await client.executeTool('aidrive', {
1960
+ action: 'share',
1961
+ workspace,
1962
+ id: uploadedId,
1963
+ ...shareAfterUpload,
1964
+ });
1965
+ }
1966
+ catch (error) {
1967
+ shared = {
1968
+ status: 'error',
1969
+ message: error instanceof Error ? error.message : String(error),
1970
+ data: null,
1971
+ };
1972
+ }
1973
+ output(mergeShareIntoUpload(result, shared));
1820
1974
  }
1821
1975
  return;
1822
1976
  }
@@ -1868,7 +2022,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1868
2022
  delete args.file; // CLI-only option, not a server parameter
1869
2023
  }
1870
2024
  // Resolve local file paths to uploaded URLs
1871
- const resolvedArgs = await resolveLocalFiles(args, client);
2025
+ // The drive's --url is the Drive link an entry is addressed by.
2026
+ const resolvedArgs = await resolveLocalFiles(args, client, tool.name === 'aidrive' ? new Set(['url']) : undefined);
1872
2027
  // The server owns the async-first default: create_task /
1873
2028
  // task_continue return a submit stub ({status: "submitted",
1874
2029
  // run_id, stream_url}) unless `--wait true` was passed. --attach