@genspark/cli 1.13.1 → 1.14.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.
Files changed (98) hide show
  1. package/README.md +8 -5
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +4 -2
  4. package/dist/client.js.map +1 -1
  5. package/dist/commands/aidrive-operands.d.ts +29 -0
  6. package/dist/commands/aidrive-operands.d.ts.map +1 -0
  7. package/dist/commands/aidrive-operands.js +178 -0
  8. package/dist/commands/aidrive-operands.js.map +1 -0
  9. package/dist/commands/aidrive-upload.d.ts +149 -0
  10. package/dist/commands/aidrive-upload.d.ts.map +1 -1
  11. package/dist/commands/aidrive-upload.js +344 -0
  12. package/dist/commands/aidrive-upload.js.map +1 -1
  13. package/dist/commands/design.d.ts +9 -0
  14. package/dist/commands/design.d.ts.map +1 -1
  15. package/dist/commands/design.js +12 -2
  16. package/dist/commands/design.js.map +1 -1
  17. package/dist/commands/genteam-download.d.ts +3 -1
  18. package/dist/commands/genteam-download.d.ts.map +1 -1
  19. package/dist/commands/genteam-download.js +4 -1
  20. package/dist/commands/genteam-download.js.map +1 -1
  21. package/dist/commands/telephony-recording.d.ts +34 -0
  22. package/dist/commands/telephony-recording.d.ts.map +1 -0
  23. package/dist/commands/telephony-recording.js +75 -0
  24. package/dist/commands/telephony-recording.js.map +1 -0
  25. package/dist/config.d.ts +13 -0
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/config.js +18 -0
  28. package/dist/config.js.map +1 -1
  29. package/dist/file-path-uploads.d.ts +4 -0
  30. package/dist/file-path-uploads.d.ts.map +1 -0
  31. package/dist/file-path-uploads.js +34 -0
  32. package/dist/file-path-uploads.js.map +1 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +278 -55
  35. package/dist/index.js.map +1 -1
  36. package/dist/types.d.ts +2 -0
  37. package/dist/types.d.ts.map +1 -1
  38. package/docs/skills.md +3 -3
  39. package/package.json +1 -1
  40. package/skills/gsk-aidrive/SKILL.md +175 -85
  41. package/skills/gsk-analyze-media/SKILL.md +1 -0
  42. package/skills/gsk-audio-generation/SKILL.md +2 -1
  43. package/skills/gsk-audio-processing/SKILL.md +1 -0
  44. package/skills/gsk-audio-transcribe/SKILL.md +1 -0
  45. package/skills/gsk-batch-crawl-url-and-answer/SKILL.md +1 -0
  46. package/skills/gsk-batch-understand-videos/SKILL.md +1 -0
  47. package/skills/gsk-claw-share-link/SKILL.md +1 -0
  48. package/skills/gsk-crawler/SKILL.md +1 -0
  49. package/skills/gsk-create-task/SKILL.md +6 -1
  50. package/skills/gsk-genteam/SKILL.md +4 -3
  51. package/skills/gsk-get-model-info/SKILL.md +1 -0
  52. package/skills/gsk-get-service-url/SKILL.md +1 -0
  53. package/skills/gsk-github/SKILL.md +1 -0
  54. package/skills/gsk-gmail/SKILL.md +4 -2
  55. package/skills/gsk-google-calendar/SKILL.md +1 -0
  56. package/skills/gsk-google-chat/SKILL.md +2 -1
  57. package/skills/gsk-google-contacts/SKILL.md +1 -0
  58. package/skills/gsk-google-docs/SKILL.md +1 -0
  59. package/skills/gsk-google-drive/SKILL.md +27 -7
  60. package/skills/gsk-google-sheets/SKILL.md +2 -1
  61. package/skills/gsk-google-slides/SKILL.md +1 -0
  62. package/skills/gsk-hub/SKILL.md +1 -0
  63. package/skills/gsk-image-generation/SKILL.md +1 -0
  64. package/skills/gsk-image-search/SKILL.md +1 -0
  65. package/skills/gsk-inbox-contacts/SKILL.md +1 -0
  66. package/skills/gsk-maps-search/SKILL.md +1 -0
  67. package/skills/gsk-meeting/SKILL.md +1 -0
  68. package/skills/gsk-microsoft-teams/SKILL.md +2 -1
  69. package/skills/gsk-notion/SKILL.md +1 -0
  70. package/skills/gsk-onedrive/SKILL.md +2 -1
  71. package/skills/gsk-outlook-calendar/SKILL.md +1 -0
  72. package/skills/gsk-outlook-contacts/SKILL.md +1 -0
  73. package/skills/gsk-outlook-email/SKILL.md +4 -2
  74. package/skills/gsk-phone-call/SKILL.md +138 -0
  75. package/skills/gsk-salesforce/SKILL.md +1 -0
  76. package/skills/gsk-sb-brain/SKILL.md +1 -0
  77. package/skills/gsk-scholar-search/SKILL.md +1 -0
  78. package/skills/gsk-second-brain/SKILL.md +54 -8
  79. package/skills/gsk-shared/SKILL.md +4 -2
  80. package/skills/gsk-sharepoint/SKILL.md +2 -1
  81. package/skills/gsk-sharepoint-upload/SKILL.md +2 -1
  82. package/skills/gsk-slack/SKILL.md +4 -2
  83. package/skills/gsk-social-instagram/SKILL.md +1 -0
  84. package/skills/gsk-social-reddit/SKILL.md +1 -0
  85. package/skills/gsk-social-twitter/SKILL.md +1 -0
  86. package/skills/gsk-stock-price/SKILL.md +1 -0
  87. package/skills/gsk-summarize-large-document/SKILL.md +1 -0
  88. package/skills/gsk-task-artifacts/SKILL.md +1 -0
  89. package/skills/gsk-task-continue/SKILL.md +1 -0
  90. package/skills/gsk-task-info/SKILL.md +1 -0
  91. package/skills/gsk-task-status/SKILL.md +1 -0
  92. package/skills/gsk-task-stop/SKILL.md +1 -0
  93. package/skills/gsk-understand-images/SKILL.md +1 -0
  94. package/skills/gsk-video-generation/SKILL.md +4 -1
  95. package/skills/gsk-vm-email-send/SKILL.md +1 -0
  96. package/skills/gsk-voice-cloning/SKILL.md +5 -4
  97. package/skills/gsk-web-search/SKILL.md +1 -0
  98. package/skills/gsk-youtube/SKILL.md +1 -0
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@
18
18
  * Tool name: "web_search" -> Command: `gsk web_search`, Alias: `gsk search`
19
19
  * Tool name: "crawler" -> Command: `gsk crawler`, Alias: `gsk crawl`
20
20
  */
21
+ import { resolveUploadFilePaths } from './file-path-uploads.js';
21
22
  import { Command, CommanderError, InvalidArgumentError, Option, } from 'commander';
22
23
  import { resolveProjectSelection } from './project-binding.js';
23
24
  import { registerDeveloperCommands } from './commands/developer-project.js';
@@ -45,9 +46,11 @@ import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken
45
46
  import { shimLegacyTaskInvocation } from './task-shim.js';
46
47
  import { getSandboxRuntime } from './runtime.js';
47
48
  import { registerDesignCommand } from './commands/design.js';
48
- import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
49
+ import { collectUploadFiles, aidriveUploadHeaders, buildAidriveUploadQuery, mergeShareIntoUpload, normalizeUploadDestination, resolveAidriveUploadOperands, shareArgsFromUpload, uploadConflictFromCli, uploadConflictProblem, uploadPathForDestination, uploadShareRefusal, } from './commands/aidrive-upload.js';
50
+ import { aidriveOperandArgs } from './commands/aidrive-operands.js';
49
51
  import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
50
52
  import { fileNameFromContentDisposition, genteamAttachmentEndpoint, resolveGenteamDownloadDestination, saveBodyToFile, } from './commands/genteam-download.js';
53
+ import { CALL_RECORDING_INFO_HELP, CALL_RECORDING_LOCAL_FILE_HELP, callRecordingEndpoint, defaultRecordingFileName, formatBytes, normalizeRecordingChannels, progressThrottle, RECORDING_CHANNEL_MODES, recordingDestinationOperands, recordingProgressLine, } from './commands/telephony-recording.js';
51
54
  import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
52
55
  import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJsonIfExists, resolvePiAgentDir, writeJsonFile, } from './commands/pi-config.js';
53
56
  import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
@@ -549,7 +552,7 @@ async function uploadLocalFile(filePath, client) {
549
552
  *
550
553
  * This avoids the roundabout blob-upload + download_file two-step approach.
551
554
  */
552
- async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source, onConflict, locator) {
555
+ async function uploadToAiDrive(filePath, uploadPath, workspace = 'my_drive', source, onConflict, locator) {
553
556
  const fileName = pathModule.basename(filePath);
554
557
  const ext = pathModule.extname(filePath).toLowerCase();
555
558
  const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
@@ -560,17 +563,16 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
560
563
  const uploadQuery = buildAidriveUploadQuery({
561
564
  uploadPath,
562
565
  workspace,
563
- override,
564
566
  onConflict,
565
567
  source,
566
568
  locator,
567
569
  });
568
570
  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;
571
+ const headers = aidriveUploadHeaders({
572
+ apiKey: globalOpts.apiKey,
573
+ projectId: globalOpts.projectId,
574
+ contentType,
575
+ });
574
576
  debug(`AI Drive upload URL: ${uploadUrl}`);
575
577
  const responseBody = await streamFileUpload(filePath, uploadUrl, headers, fileSize, 'POST');
576
578
  try {
@@ -678,9 +680,12 @@ function encodeAttachmentInline(filePath) {
678
680
  * the bytes only exist for the duration of the email-send request. Hosted
679
681
  * URLs in the same array are passed through unchanged.
680
682
  */
681
- async function resolveLocalFiles(args, client) {
683
+ async function resolveLocalFiles(args, client, locatorKeys = new Set()) {
682
684
  const resolved = { ...args };
683
685
  for (const [key, value] of Object.entries(resolved)) {
686
+ // A locator names an entry on the server, never a local file to upload.
687
+ if (locatorKeys.has(key))
688
+ continue;
684
689
  // Email `attachments` — inline base64, no blob round-trip.
685
690
  if (key === 'attachments' && Array.isArray(value)) {
686
691
  const out = [];
@@ -1116,9 +1121,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1116
1121
  cmd.option('--workspace <value>', 'AI Drive workspace: my_drive, shared_with_me, or shared_drive');
1117
1122
  }
1118
1123
  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 ' +
1124
+ 'alternative to --file_content; same as the first operand of ' +
1125
+ '`upload <local> <drive folder>/`). download: local destination path ' +
1120
1126
  '(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);
1127
+ // An optional value, as schema booleans take: presence-only, the
1128
+ // `false` in `--override false` was left over and the upload overwrote.
1129
+ cmd.option('--override [value]', 'Overwrite an existing file at the destination path (used with --local_file)', parseBooleanFlagValue);
1122
1130
  cmd.option('--on-conflict <mode>', 'upload: what to do when the destination name is taken — ' +
1123
1131
  'error | rename | overwrite (default: rename, which lands ' +
1124
1132
  'name(1).ext and reports the path actually written). Use error for ' +
@@ -1130,6 +1138,13 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1130
1138
  if (tool.name === 'genteam' && !actionViews) {
1131
1139
  cmd.option('--local_file <path>', GENTEAM_DOWNLOAD_LOCAL_FILE_HELP);
1132
1140
  }
1141
+ // telephony call recording (#66245): the WAV streams straight to local
1142
+ // disk, so the destination and the metadata-only switch are CLI-side;
1143
+ // `--channels` comes from the server schema like any other parameter.
1144
+ if (tool.name === 'call_recording') {
1145
+ cmd.option('--local_file <path>', CALL_RECORDING_LOCAL_FILE_HELP);
1146
+ cmd.option('--info', CALL_RECORDING_INFO_HELP, false);
1147
+ }
1133
1148
  // For sb-git: `--execute [dest]` turns `clone-url` from a snippet-print
1134
1149
  // into an actual `git clone`. Client-side because the backend `clone-url`
1135
1150
  // adaptor returns shell placeholders rather than embedding secrets in
@@ -1452,6 +1467,41 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1452
1467
  process.exit(1);
1453
1468
  }
1454
1469
  }
1470
+ // aidrive: a drive path written as an operand (`gsk drive ls
1471
+ // /Reports`, `gsk drive move /q3.pdf /Archive`) fills the action's
1472
+ // parameters. Commander keeps such operands but maps none of them,
1473
+ // so the server used to answer "Missing required parameter: path".
1474
+ // Upload and download read their operands in their own lanes below.
1475
+ // The operands after the action: a per-action subcommand's are all
1476
+ // bare; the union command's first is the action, unless --args-file
1477
+ // carried it and Commander bound a bare path to the action slot.
1478
+ let aidriveOperands = [];
1479
+ if (tool.name === 'aidrive' && typeof args.action === 'string') {
1480
+ const actionNames = props.action?.enum;
1481
+ if (invokedCmd === cmd &&
1482
+ primaryArgValue !== undefined &&
1483
+ primaryArgValue !== args.action &&
1484
+ Array.isArray(actionNames) &&
1485
+ actionNames.includes(primaryArgValue)) {
1486
+ // Read as an operand, `drive ls --args-file` with a file saying
1487
+ // "rm" would have removed a path named "ls".
1488
+ logError(`The command line names the action ${primaryArgValue} and ` +
1489
+ `--args-file names ${args.action}; pass one. Nothing was sent.`);
1490
+ process.exit(1);
1491
+ }
1492
+ aidriveOperands =
1493
+ invokedCmd !== cmd
1494
+ ? invokedCmd.args
1495
+ : primaryArgValue !== undefined && primaryArgValue === args.action
1496
+ ? invokedCmd.args.slice(1)
1497
+ : invokedCmd.args;
1498
+ const mapped = aidriveOperandArgs(args.action, aidriveOperands, args);
1499
+ if (mapped.error) {
1500
+ logError(mapped.error);
1501
+ process.exit(1);
1502
+ }
1503
+ Object.assign(args, mapped.filled);
1504
+ }
1455
1505
  // Pre-call confirmation (confirm.ts): when the cached /tools
1456
1506
  // payload advertised interactive_confirm AND the schema marks this
1457
1507
  // tool/action confirmation-required, resolve [y/N] / --yes /
@@ -1492,6 +1542,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1492
1542
  if (tool.name === 'genteam') {
1493
1543
  delete args.local_file;
1494
1544
  }
1545
+ // call_recording: --local_file / --info steer the client-side
1546
+ // download below; the server tool knows neither.
1547
+ if (tool.name === 'call_recording') {
1548
+ delete args.local_file;
1549
+ delete args.info;
1550
+ }
1495
1551
  // sb-git --execute is client-side only; never forward.
1496
1552
  let sbGitExecuteDest;
1497
1553
  let sbGitExecuteRequested = false;
@@ -1560,40 +1616,86 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1560
1616
  // only, not CLI-populated ones).
1561
1617
  args.files = collected.files;
1562
1618
  }
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 &&
1619
+ // aidrive upload operands: `gsk drive upload <local> [<drive
1620
+ // destination>]`. A bare local path is an operand Commander tolerates
1621
+ // but never maps, so the request used to reach the API with no
1622
+ // content ("Missing file_content"), and a destination operand or
1623
+ // `-p` was dropped, landing the file at the drive root. The local
1624
+ // source is --local_file or the first operand that exists on disk;
1625
+ // the destination is `-p` or the operand left over, read by the
1626
+ // lanes below. With no usable source, fail with an actionable
1627
+ // message that names --local_file rather than the opaque backend
1628
+ // error.
1629
+ let uploadDestination;
1630
+ if (tool.name === 'aidrive' && args.action === 'upload') {
1578
1631
  // args, not opts: file_content is a server param and may have
1579
1632
  // 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;
1633
+ const inline = !!args.file_content && !opts.local_file;
1634
+ const resolved = resolveAidriveUploadOperands({
1635
+ operands: aidriveOperands,
1636
+ localFile: typeof opts.local_file === 'string' ? opts.local_file : undefined,
1637
+ inline,
1638
+ path: typeof args.path === 'string' ? args.path : undefined,
1639
+ uploadPath: typeof args.upload_path === 'string'
1640
+ ? args.upload_path
1641
+ : undefined,
1642
+ });
1643
+ if (resolved.error) {
1644
+ logError(resolved.error);
1645
+ process.exit(1);
1646
+ }
1647
+ // `-p` was the destination; upload has no `path` of its own.
1648
+ delete args.path;
1649
+ for (const key of ['destination', 'upload_path']) {
1650
+ const value = key === 'destination' ? resolved.destination : args.upload_path;
1651
+ if (typeof value !== 'string' || !value)
1652
+ continue;
1653
+ const normalized = normalizeUploadDestination(value);
1654
+ if (normalized.error) {
1655
+ logError(normalized.error);
1656
+ process.exit(1);
1657
+ }
1658
+ if (key === 'destination')
1659
+ uploadDestination = normalized.path;
1660
+ else
1661
+ args.upload_path = normalized.path;
1662
+ }
1663
+ if (inline) {
1664
+ // Inline content has no file name of its own, so its
1665
+ // destination is the file's full path as written.
1666
+ if (uploadDestination !== undefined) {
1667
+ if (uploadDestination.endsWith('/')) {
1668
+ logError(`--file_content needs the file's full path; ${uploadDestination} ` +
1669
+ 'names a folder: add the file name. Nothing was sent.');
1670
+ process.exit(1);
1671
+ }
1672
+ // Relative to a folder --id/--url names; otherwise from the
1673
+ // drive root, which the tool lane requires spelled out.
1674
+ args.upload_path =
1675
+ args.id || args.url || uploadDestination.startsWith('/')
1676
+ ? uploadDestination
1677
+ : `/${uploadDestination}`;
1678
+ }
1679
+ // The tool lane knows `overwrite` only; --on-conflict and
1680
+ // --override are the CLI's spellings, so map them here rather
1681
+ // than let them vanish with the other CLI-only flags.
1682
+ const conflict = uploadConflictFromCli(opts, args);
1683
+ const problem = uploadConflictProblem(conflict, args, true);
1684
+ if (problem) {
1685
+ logError(`${problem}. Nothing was sent.`);
1686
+ process.exit(1);
1687
+ }
1688
+ if (conflict.onConflict === 'overwrite')
1689
+ args.overwrite = true;
1690
+ }
1691
+ else if (resolved.localFile) {
1692
+ opts.local_file = resolved.localFile;
1591
1693
  }
1592
1694
  else {
1593
1695
  logError('upload needs a file source: use `--local_file <path>` for a ' +
1594
1696
  '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');
1697
+ 'for inline text. Example: gsk drive upload ./report.pdf ' +
1698
+ '/Reports/');
1597
1699
  process.exit(1);
1598
1700
  }
1599
1701
  }
@@ -1711,6 +1813,58 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1711
1813
  });
1712
1814
  return;
1713
1815
  }
1816
+ // Save a Call-For-Me recording to local disk (#66245). Client-side
1817
+ // for the same reason as genteam download: only this process can
1818
+ // write the local filesystem, so the CLI streams the gsk-token
1819
+ // recording route straight into the file. `--info` keeps the
1820
+ // metadata-only server tool call (falls through below).
1821
+ if (tool.name === 'call_recording' && opts.info !== true) {
1822
+ const projectId = typeof args.project_id === 'string' ? args.project_id.trim() : '';
1823
+ if (!projectId) {
1824
+ logError('recording needs <project_id> (from a `dial` result or a ' +
1825
+ '`gsk telephony call log` entry)');
1826
+ process.exit(1);
1827
+ }
1828
+ const channels = normalizeRecordingChannels(args.channels);
1829
+ if (args.channels !== undefined && channels === undefined) {
1830
+ logError(`--channels must be one of: ${RECORDING_CHANNEL_MODES.join(', ')}`);
1831
+ process.exit(1);
1832
+ }
1833
+ const operands = recordingDestinationOperands(invokedCmd.args, primaryArgValue);
1834
+ let response;
1835
+ try {
1836
+ response = await client.fetchBinary(callRecordingEndpoint(projectId, channels));
1837
+ }
1838
+ catch (err) {
1839
+ const reason = err instanceof Error ? err.message : String(err);
1840
+ logError(`call recording download failed: ${reason}`);
1841
+ process.exit(1);
1842
+ }
1843
+ if (!response.body) {
1844
+ logError('call recording download failed: empty response body');
1845
+ process.exit(1);
1846
+ }
1847
+ const fileName = fileNameFromContentDisposition(response.headers.get('content-disposition')) ?? defaultRecordingFileName(projectId, channels);
1848
+ const destPath = resolveGenteamDownloadDestination(operands, typeof opts.local_file === 'string' ? opts.local_file : undefined, fileName);
1849
+ const totalBytes = Number(response.headers.get('content-length')) || undefined;
1850
+ // Progress goes to stderr only while a human watches a terminal
1851
+ // (logger.progress); in a sandbox stdout stays exactly one JSON.
1852
+ const saved = await saveBodyToFile(response.body, destPath, progressThrottle(500, received => progress(recordingProgressLine(fileName, received, totalBytes))));
1853
+ progress(`Downloaded ${formatBytes(saved.size_bytes)} → ${saved.local_path}`);
1854
+ output({
1855
+ status: 'ok',
1856
+ message: 'Call recording downloaded to local disk',
1857
+ data: {
1858
+ project_id: projectId,
1859
+ channels: channels ?? 'stereo',
1860
+ channel_map: response.headers.get('x-audio-channel-map') ?? null,
1861
+ file_name: fileName,
1862
+ content_type: response.headers.get('content-type') ?? 'audio/wav',
1863
+ ...saved,
1864
+ },
1865
+ });
1866
+ return;
1867
+ }
1714
1868
  // `download_file` saves an external URL INTO the drive and cannot copy
1715
1869
  // one out, yet it is the obvious spelling for "download a drive file"
1716
1870
  // and both attempts used to fail silently: its handler never consumes
@@ -1745,19 +1899,29 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1745
1899
  args.action === 'upload' &&
1746
1900
  opts.local_file) {
1747
1901
  const localFilePath = opts.local_file;
1748
- const override = !!opts.override;
1749
1902
  // --on-conflict error|rename|overwrite (#54379). Default (unset) is
1750
1903
  // rename server-side: nobody is here to answer a prompt, and
1751
1904
  // dead-ending an agent mid-task is worse than landing a copy.
1752
1905
  // `error` is kept for idempotent scripts that read a failure as
1753
1906
  // "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);
1907
+ // per retry. `--overwrite true` (the tool schema's spelling) and
1908
+ // `--override` both mean overwrite here. Commander camelCases
1909
+ // `--on-conflict` to `onConflict`; the other spellings are only
1910
+ // for a caller that passed the raw arg through.
1911
+ const conflict = uploadConflictFromCli(opts, args);
1912
+ const problem = uploadConflictProblem(conflict, args, false);
1913
+ if (problem) {
1914
+ logError(`${problem}. Nothing was sent.`);
1915
+ process.exit(1);
1916
+ }
1917
+ const onConflict = conflict.onConflict;
1918
+ // `upload --to <who>` / `--general_access <audience>`: share the
1919
+ // file the moment it lands, and answer with the link that opens
1920
+ // for them — the share verb the caller would run next, addressed
1921
+ // by the uploaded entry's id. My Drive only, as on the server:
1922
+ // a shared source's sharing has its own verb and admin gate.
1923
+ const shareAfterUpload = shareArgsFromUpload(args);
1924
+ const sharesAfterUpload = Object.keys(shareAfterUpload).length > 0;
1761
1925
  const workspace = args.workspace || 'my_drive';
1762
1926
  const source = args.source ||
1763
1927
  args.share;
@@ -1766,7 +1930,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1766
1930
  process.exit(1);
1767
1931
  }
1768
1932
  // 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.
1933
+ // only the CLI-only flags (local_file, override, onConflict) were
1934
+ // deleted from args — upload_path is intact.
1770
1935
  // --id / --owner / --url: the server resolves the folder and treats
1771
1936
  // upload_path as RELATIVE to it, so keep the caller's spelling and
1772
1937
  // default to the file name instead of forcing a leading slash.
@@ -1776,15 +1941,42 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1776
1941
  url: args.url,
1777
1942
  };
1778
1943
  const addressedById = !!(locator.id || locator.url);
1944
+ const localStat = fs.statSync(localFilePath);
1945
+ // --upload_path is the exact path; an operand or `-p` destination
1946
+ // is a folder unless it names the upload itself.
1947
+ let destinationPath;
1948
+ if (!args.upload_path && uploadDestination !== undefined) {
1949
+ const placed = uploadPathForDestination(uploadDestination, localFilePath, localStat.isDirectory());
1950
+ if (placed.error) {
1951
+ logError(placed.error);
1952
+ process.exit(1);
1953
+ }
1954
+ destinationPath = placed.uploadPath;
1955
+ }
1779
1956
  const rawUploadPath = args.upload_path ||
1957
+ destinationPath ||
1958
+ // Named after the resolved path, as with a destination: `.`
1959
+ // spread its files over the drive root.
1780
1960
  (addressedById
1781
- ? pathModule.basename(localFilePath)
1782
- : `/${pathModule.basename(localFilePath)}`);
1961
+ ? pathModule.basename(pathModule.resolve(localFilePath))
1962
+ : `/${pathModule.basename(pathModule.resolve(localFilePath))}`);
1783
1963
  const uploadPath = addressedById || rawUploadPath.startsWith('/')
1784
1964
  ? rawUploadPath
1785
1965
  : `/${rawUploadPath}`;
1786
- const localStat = fs.statSync(localFilePath);
1787
1966
  const files = collectUploadFiles(localFilePath);
1967
+ if (sharesAfterUpload) {
1968
+ const refusal = uploadShareRefusal({
1969
+ workspace,
1970
+ source,
1971
+ addressedById: Boolean(args.id || args.url),
1972
+ isDirectory: localStat.isDirectory(),
1973
+ uploadPath,
1974
+ });
1975
+ if (refusal) {
1976
+ logError(refusal);
1977
+ process.exit(1);
1978
+ }
1979
+ }
1788
1980
  if (localStat.isDirectory()) {
1789
1981
  if (files.length === 0) {
1790
1982
  logError(`Folder has no files to upload: ${localFilePath}`);
@@ -1794,7 +1986,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1794
1986
  const uploaded = [];
1795
1987
  for (const file of files) {
1796
1988
  const destination = pathModule.posix.join(uploadPath, file.relativePath);
1797
- const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source, onConflict, locator);
1989
+ const result = await uploadToAiDrive(file.absolutePath, destination, workspace, source, onConflict, locator);
1798
1990
  if (result.status !== 'ok') {
1799
1991
  output(result);
1800
1992
  process.exit(1);
@@ -1815,8 +2007,37 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1815
2007
  }
1816
2008
  else {
1817
2009
  // 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);
2010
+ const result = await uploadToAiDrive(localFilePath, uploadPath, workspace, source, onConflict, locator);
2011
+ const uploadedData = result.data;
2012
+ const uploadedId = uploadedData?.entry_id || uploadedData?.id;
2013
+ if (result.status !== 'ok' || !sharesAfterUpload || !uploadedId) {
2014
+ if (result.status === 'ok' && sharesAfterUpload && !uploadedId) {
2015
+ result.message +=
2016
+ ' (the server did not return the file id, so it was not shared; run `gsk drive share` on it)';
2017
+ }
2018
+ output(result);
2019
+ return;
2020
+ }
2021
+ // A share that throws (network, parse) must not read as a
2022
+ // failed upload: the file is written, and a retry would land a
2023
+ // second copy.
2024
+ let shared;
2025
+ try {
2026
+ shared = await client.executeTool('aidrive', {
2027
+ action: 'share',
2028
+ workspace,
2029
+ id: uploadedId,
2030
+ ...shareAfterUpload,
2031
+ });
2032
+ }
2033
+ catch (error) {
2034
+ shared = {
2035
+ status: 'error',
2036
+ message: error instanceof Error ? error.message : String(error),
2037
+ data: null,
2038
+ };
2039
+ }
2040
+ output(mergeShareIntoUpload(result, shared));
1820
2041
  }
1821
2042
  return;
1822
2043
  }
@@ -1868,7 +2089,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1868
2089
  delete args.file; // CLI-only option, not a server parameter
1869
2090
  }
1870
2091
  // Resolve local file paths to uploaded URLs
1871
- const resolvedArgs = await resolveLocalFiles(args, client);
2092
+ // The drive's --url is the Drive link an entry is addressed by.
2093
+ const uploadArgs = await resolveUploadFilePaths(args, tool.parameters.properties, source => resolveFileArg(source, client));
2094
+ const resolvedArgs = await resolveLocalFiles(uploadArgs, client, tool.name === 'aidrive' ? new Set(['url']) : undefined);
1872
2095
  // The server owns the async-first default: create_task /
1873
2096
  // task_continue return a submit stub ({status: "submitted",
1874
2097
  // run_id, stream_url}) unless `--wait true` was passed. --attach