@genspark/cli 1.14.2 → 1.15.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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/aidrive-contract.generated.d.ts.map +1 -1
  3. package/dist/commands/aidrive-contract.generated.js +23 -4
  4. package/dist/commands/aidrive-contract.generated.js.map +1 -1
  5. package/dist/commands/aidrive-upload.js +2 -1
  6. package/dist/commands/aidrive-upload.js.map +1 -1
  7. package/dist/commands/sb-box-session.d.ts +128 -0
  8. package/dist/commands/sb-box-session.d.ts.map +1 -0
  9. package/dist/commands/sb-box-session.js +463 -0
  10. package/dist/commands/sb-box-session.js.map +1 -0
  11. package/dist/config.d.ts +41 -0
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +42 -0
  14. package/dist/config.js.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +128 -19
  17. package/dist/index.js.map +1 -1
  18. package/dist/object-args.d.ts +4 -0
  19. package/dist/object-args.d.ts.map +1 -0
  20. package/dist/object-args.js +34 -0
  21. package/dist/object-args.js.map +1 -0
  22. package/docs/skills.md +8 -7
  23. package/package.json +1 -1
  24. package/skills/gsk-aidrive/SKILL.md +89 -7
  25. package/skills/gsk-audio-transcribe/SKILL.md +5 -2
  26. package/skills/gsk-calendar-source/SKILL.md +44 -0
  27. package/skills/gsk-create-task/SKILL.md +1 -1
  28. package/skills/gsk-genteam/SKILL.md +3 -1
  29. package/skills/gsk-github/SKILL.md +4 -3
  30. package/skills/gsk-google-drive/SKILL.md +6 -5
  31. package/skills/gsk-google-sheets/SKILL.md +1 -1
  32. package/skills/gsk-image-generation/SKILL.md +2 -1
  33. package/skills/gsk-meeting/SKILL.md +1 -1
  34. package/skills/gsk-notion/SKILL.md +2 -2
  35. package/skills/gsk-onedrive/SKILL.md +6 -4
  36. package/skills/gsk-second-brain/SKILL.md +2 -2
  37. package/skills/gsk-sharepoint/SKILL.md +5 -4
  38. package/skills/gsk-video-generation/SKILL.md +1 -1
package/dist/index.js CHANGED
@@ -40,7 +40,8 @@ import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError,
40
40
  import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
41
41
  import { isPendingConfirmationEnvelope, LEGACY_SKIP_PARAMS, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
42
42
  import { repairJsonArrayArgs } from './arrayArgs.js';
43
- import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
43
+ import { parseJsonObjectArgs } from './object-args.js';
44
+ import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, resolveCredentialPair, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
44
45
  import { checkForUpdates } from './updater.js';
45
46
  import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
46
47
  import { shimLegacyTaskInvocation } from './task-shim.js';
@@ -56,11 +57,23 @@ import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJson
56
57
  import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
57
58
  import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
58
59
  import { executeCloneUrl, normalizeCloneUrlForGit, } from './commands/sb-git-clone.js';
60
+ import { afterSessionCall, bindSession, defaultTemplate, resolveSessionKey, SANDBOX_ACTIONS, SessionError, SessionStore, SESSION_ENV, } from './commands/sb-box-session.js';
59
61
  import { actionScopedDescription, serviceActionViews, } from './serviceActions.js';
60
62
  const require = createRequire(import.meta.url);
61
63
  const { version: VERSION } = require('../package.json');
62
64
  const DEFAULT_BASE_URL = 'https://www.genspark.ai';
63
65
  const DEFAULT_TIMEOUT = 1800000; // 30 minutes (slides/video generation can be slow)
66
+ // `gsk sb-box --session` help (commands/sb-box-session.ts). Env fallbacks
67
+ // are named so a host-spawned shell knows why a bare `run-code` just worked.
68
+ const SB_BOX_SESSION_HELP = 'Bind this session key to a sandbox instead of passing --sandbox_id: the ' +
69
+ 'CLI reuses the sandbox it remembers for the key while it is alive ' +
70
+ '(frozen is fine — it resumes) and starts a new one on exec / run-code / ' +
71
+ 'write when there is none (--template picks the image; default newest ' +
72
+ 'public base; no hard deadline, idle-frozen when quiet). get / read / ls / ' +
73
+ 'kill / freeze / … only use an existing binding; `kill` drops it; ' +
74
+ '`create --session` binds the new sandbox. Without the flag the key comes ' +
75
+ `from $${SESSION_ENV}, then CLAUDE_CODE_SESSION_ID (create binds only with the flag). An explicit ` +
76
+ '--sandbox_id always wins. Bindings: <config dir>/sb-box-sessions.json, per API host.';
64
77
  const GENTEAM_DOWNLOAD_LOCAL_FILE_HELP = 'download: local destination path (same as a bare operand; a directory ' +
65
78
  'receives the server-reported file name; default ./<file_name>)';
66
79
  /**
@@ -294,16 +307,20 @@ function finalizeGlobalPassthrough() {
294
307
  }
295
308
  function getGlobalOptions() {
296
309
  const opts = { ...program.opts(), ...activePassthroughOpts };
297
- // API key priority: CLI > env > config file
298
- const apiKey = opts.apiKey || process.env.GSK_API_KEY || fileConfig.api_key;
299
- // Base URL priority: CLI > env > config file > default
300
- const explicitBaseUrl = program.getOptionValueSource('baseUrl') === 'cli'
301
- ? opts.baseUrl
302
- : undefined;
303
- const baseUrl = normalizeBaseUrl(explicitBaseUrl ||
304
- process.env.GSK_BASE_URL ||
305
- fileConfig.base_url ||
306
- DEFAULT_BASE_URL);
310
+ // API key and base URL resolve as one pair (#70209) — see the precedence
311
+ // table in config.ts.
312
+ const { apiKey, baseUrl } = resolveCredentialPair({
313
+ cliApiKey: opts.apiKey,
314
+ cliBaseUrl: program.getOptionValueSource('baseUrl') === 'cli'
315
+ ? opts.baseUrl
316
+ : undefined,
317
+ env: {
318
+ apiKey: process.env.GSK_API_KEY,
319
+ baseUrl: process.env.GSK_BASE_URL,
320
+ },
321
+ file: { apiKey: fileConfig.api_key, baseUrl: fileConfig.base_url },
322
+ defaultBaseUrl: DEFAULT_BASE_URL,
323
+ });
307
324
  // Timeout priority: CLI > config file > default
308
325
  const timeout = opts.timeout !== String(DEFAULT_TIMEOUT)
309
326
  ? parseInt(opts.timeout, 10)
@@ -383,7 +400,12 @@ const CONTENT_TYPE_MAP = {
383
400
  '.csv': 'text/csv',
384
401
  '.zip': 'application/zip',
385
402
  '.mp3': 'audio/mpeg',
403
+ '.m4a': 'audio/mp4',
404
+ '.aac': 'audio/aac',
405
+ '.ogg': 'audio/ogg',
406
+ '.flac': 'audio/flac',
386
407
  '.mp4': 'video/mp4',
408
+ '.mov': 'video/quicktime',
387
409
  '.wav': 'audio/wav',
388
410
  '.webm': 'video/webm',
389
411
  };
@@ -552,7 +574,7 @@ async function uploadLocalFile(filePath, client) {
552
574
  *
553
575
  * This avoids the roundabout blob-upload + download_file two-step approach.
554
576
  */
555
- async function uploadToAiDrive(filePath, uploadPath, workspace = 'my_drive', source, onConflict, locator) {
577
+ async function uploadToAiDrive(filePath, uploadPath, workspace = '', source, onConflict, locator) {
556
578
  const fileName = pathModule.basename(filePath);
557
579
  const ext = pathModule.extname(filePath).toLowerCase();
558
580
  const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
@@ -794,10 +816,8 @@ function parseBooleanFlagValue(value) {
794
816
  return false;
795
817
  throw new InvalidArgumentError(`expected true/false. If '${value}' was meant as an argument, place it before the flag or pass an explicit value (--flag true ${value}).`);
796
818
  }
797
- function addAidriveLocalOptions(cmd, props, action) {
798
- if (!Object.hasOwn(props, 'workspace')) {
799
- cmd.option('--workspace <value>', 'AI Drive workspace: my_drive, shared_with_me, or shared_drive');
800
- }
819
+ function addAidriveLocalOptions(cmd, action) {
820
+ cmd.addOption(new Option('--workspace [type]', 'Drive location: my_drive (ls default), sb_workspace (bare flag), team_drive, shared_drive (all managed), shared_with_me').preset('sb_workspace'));
801
821
  cmd.option('--local_file <path>', action === 'download'
802
822
  ? 'Local destination path; use --local_file with --id or --url. ' +
803
823
  'Otherwise the second operand is the destination.'
@@ -1050,6 +1070,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1050
1070
  break;
1051
1071
  if (name === tool.cli.primary_arg)
1052
1072
  continue;
1073
+ if (tool.name === 'aidrive' && name === 'workspace')
1074
+ continue;
1053
1075
  // For create_task, make params optional so --acp mode works without them.
1054
1076
  // Validation of required params happens in the action handler. Likewise
1055
1077
  // skills_save's `files` is server-required but CLI-populated (from the
@@ -1140,7 +1162,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1140
1162
  // For the aidrive tool, add client-side options used by the --local_file
1141
1163
  // upload and by `download`'s local destination.
1142
1164
  if (tool.name === 'aidrive')
1143
- addAidriveLocalOptions(cmd, props);
1165
+ addAidriveLocalOptions(cmd);
1144
1166
  // genteam download saves the attachment to local disk (client-side: only
1145
1167
  // this process can write the local filesystem). The union view takes the
1146
1168
  // flag here; the per-action `download` subcommand registers it below.
@@ -1162,6 +1184,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1162
1184
  if (tool.name === 'sb-git') {
1163
1185
  cmd.option('--execute [dest]', 'For action=clone-url: run `git clone` locally to [dest] (default: ./<repo>) instead of just printing the snippet');
1164
1186
  }
1187
+ // For sb-box: `--session <key>` binds a session to a sandbox client-side
1188
+ // (commands/sb-box-session.ts): the CLI remembers which sandbox the key
1189
+ // owns, reuses it while alive and starts a new one on exec / run-code /
1190
+ // write when it is gone. CLI-only; the server sees the resolved sandbox_id.
1191
+ if (tool.name === 'sb-box')
1192
+ cmd.option('--session <key>', SB_BOX_SESSION_HELP);
1165
1193
  // For skills pull: `--out [dir]` writes the returned skill files to disk.
1166
1194
  // Client-side because an HTTP/JSON tool can't materialise a tree on the
1167
1195
  // user's machine — same shape as sb-git's `--execute`. Default dest is
@@ -1448,6 +1476,11 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1448
1476
  }
1449
1477
  }
1450
1478
  }
1479
+ const objectError = parseJsonObjectArgs(args, props);
1480
+ if (objectError) {
1481
+ logError(objectError);
1482
+ process.exit(1);
1483
+ }
1451
1484
  // Coerce numeric strings to numbers based on schema
1452
1485
  for (const [name, param] of Object.entries(props)) {
1453
1486
  if (args[name] !== undefined) {
@@ -1936,7 +1969,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1936
1969
  // a shared source's sharing has its own verb and admin gate.
1937
1970
  const shareAfterUpload = shareArgsFromUpload(args);
1938
1971
  const sharesAfterUpload = Object.keys(shareAfterUpload).length > 0;
1939
- const workspace = args.workspace || 'my_drive';
1972
+ const workspace = args.workspace || (sharesAfterUpload ? 'my_drive' : '');
1940
1973
  const source = args.source ||
1941
1974
  args.share;
1942
1975
  if (!fs.existsSync(localFilePath)) {
@@ -2102,6 +2135,68 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2102
2135
  args.file_urls = [...existing, ...fileUrls];
2103
2136
  delete args.file; // CLI-only option, not a server parameter
2104
2137
  }
2138
+ // sb-box --session: resolve the session's sandbox before the call
2139
+ // (reuse / create), never forward the flag. An explicit sandbox_id
2140
+ // wins and leaves the binding alone; with neither flag the env
2141
+ // fallbacks (GSK_SB_BOX_SESSION, a host agent's session id) apply
2142
+ // to the actions that address a sandbox.
2143
+ let sbBoxSession;
2144
+ let sbBoxBind;
2145
+ let sbBoxStore;
2146
+ if (tool.name === 'sb-box') {
2147
+ const explicitSession = args.session;
2148
+ delete args.session;
2149
+ const action = typeof args.action === 'string' ? args.action : '';
2150
+ const hasSandboxId = typeof args.sandbox_id === 'string' && args.sandbox_id.trim() !== '';
2151
+ const key = resolveSessionKey(explicitSession);
2152
+ // `create` binds only on an EXPLICIT --session: a bare create
2153
+ // inside Claude Code must not silently rebind the conversation's
2154
+ // sandbox (the env fallbacks are for the actions that address one).
2155
+ if (key && action === 'create' && !hasSandboxId) {
2156
+ if (key.source === 'flag')
2157
+ sbBoxSession = key;
2158
+ }
2159
+ else if (key && SANDBOX_ACTIONS.has(action) && !hasSandboxId) {
2160
+ sbBoxSession = key;
2161
+ }
2162
+ // create without --template: newest ready public base (CLI-side).
2163
+ if (action === 'create' &&
2164
+ !(typeof args.template === 'string' && args.template.trim())) {
2165
+ try {
2166
+ args.template = await defaultTemplate(callArgs => client.executeTool('sb-box', callArgs));
2167
+ info(`create: no --template given, using the public base ${args.template}`);
2168
+ }
2169
+ catch (err) {
2170
+ if (err instanceof SessionError) {
2171
+ logError(err.message);
2172
+ process.exit(1);
2173
+ }
2174
+ throw err;
2175
+ }
2176
+ }
2177
+ if (sbBoxSession) {
2178
+ sbBoxStore = SessionStore.forConfig(getConfigPath(), getGlobalOptions().baseUrl);
2179
+ if (action !== 'create') {
2180
+ try {
2181
+ sbBoxBind = await bindSession({
2182
+ key: sbBoxSession,
2183
+ action,
2184
+ args,
2185
+ call: callArgs => client.executeTool('sb-box', callArgs),
2186
+ store: sbBoxStore,
2187
+ log: info,
2188
+ });
2189
+ }
2190
+ catch (err) {
2191
+ if (err instanceof SessionError) {
2192
+ logError(err.message);
2193
+ process.exit(1);
2194
+ }
2195
+ throw err;
2196
+ }
2197
+ }
2198
+ }
2199
+ }
2105
2200
  // Resolve local file paths to uploaded URLs
2106
2201
  // The drive's --url is the Drive link an entry is addressed by.
2107
2202
  const uploadArgs = await resolveUploadFilePaths(args, tool.parameters.properties, source => resolveFileArg(source, client));
@@ -2112,6 +2207,15 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2112
2207
  // upgrades the stub into a live SSE follow that exits with the
2113
2208
  // run's terminal result — the work still executes server-side.
2114
2209
  let result = await client.executeTool(tool.name, resolvedArgs);
2210
+ if (sbBoxSession && sbBoxStore) {
2211
+ afterSessionCall({
2212
+ key: sbBoxSession,
2213
+ action: String(resolvedArgs.action ?? ''),
2214
+ bind: sbBoxBind,
2215
+ result,
2216
+ store: sbBoxStore,
2217
+ });
2218
+ }
2115
2219
  const stubData = result.data;
2116
2220
  if (attachTask &&
2117
2221
  result.status === 'ok' &&
@@ -2374,6 +2478,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2374
2478
  const parameterNames = tool.name === 'aidrive'
2375
2479
  ? Object.keys(props).filter(name => name !== tool.cli.primary_arg) : view.parameters;
2376
2480
  for (const paramName of parameterNames) {
2481
+ if (tool.name === 'aidrive' && paramName === 'workspace')
2482
+ continue;
2377
2483
  addSchemaOption(sub, paramName, props[paramName], {
2378
2484
  // Same relaxation as the union path: with --args-file on the
2379
2485
  // command line, required params may live in the file, which
@@ -2389,7 +2495,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2389
2495
  });
2390
2496
  }
2391
2497
  if (tool.name === 'aidrive') {
2392
- addAidriveLocalOptions(sub, props, view.name);
2498
+ addAidriveLocalOptions(sub, view.name);
2393
2499
  const localFlags = view.name === 'upload'
2394
2500
  ? ['local_file', 'override', 'on-conflict']
2395
2501
  : view.name === 'download' ? ['local_file'] : [];
@@ -2418,6 +2524,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2418
2524
  if (tool.name === 'genteam' && view.name === 'download') {
2419
2525
  sub.option('--local_file <path>', GENTEAM_DOWNLOAD_LOCAL_FILE_HELP);
2420
2526
  }
2527
+ if (tool.name === 'sb-box' && (SANDBOX_ACTIONS.has(view.name) || view.name === 'create')) {
2528
+ sub.option('--session <key>', SB_BOX_SESSION_HELP);
2529
+ }
2421
2530
  addGlobalPassthroughOptions(sub, props);
2422
2531
  sub.action((opts) => runToolInvocation(view.name, opts, sub));
2423
2532
  }