@genspark/cli 1.14.1 → 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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/aidrive-contract.generated.d.ts +3 -0
  3. package/dist/commands/aidrive-contract.generated.d.ts.map +1 -0
  4. package/dist/commands/aidrive-contract.generated.js +555 -0
  5. package/dist/commands/aidrive-contract.generated.js.map +1 -0
  6. package/dist/commands/aidrive-operands.d.ts +2 -0
  7. package/dist/commands/aidrive-operands.d.ts.map +1 -1
  8. package/dist/commands/aidrive-operands.js +22 -26
  9. package/dist/commands/aidrive-operands.js.map +1 -1
  10. package/dist/commands/aidrive-upload.js +2 -1
  11. package/dist/commands/aidrive-upload.js.map +1 -1
  12. package/dist/commands/sb-box-session.d.ts +128 -0
  13. package/dist/commands/sb-box-session.d.ts.map +1 -0
  14. package/dist/commands/sb-box-session.js +463 -0
  15. package/dist/commands/sb-box-session.js.map +1 -0
  16. package/dist/config.d.ts +42 -1
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +43 -1
  19. package/dist/config.js.map +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +192 -51
  22. package/dist/index.js.map +1 -1
  23. package/dist/object-args.d.ts +4 -0
  24. package/dist/object-args.d.ts.map +1 -0
  25. package/dist/object-args.js +34 -0
  26. package/dist/object-args.js.map +1 -0
  27. package/dist/serviceActions.d.ts +2 -0
  28. package/dist/serviceActions.d.ts.map +1 -1
  29. package/dist/serviceActions.js +13 -1
  30. package/dist/serviceActions.js.map +1 -1
  31. package/dist/types.d.ts +3 -0
  32. package/dist/types.d.ts.map +1 -1
  33. package/docs/skills.md +10 -9
  34. package/package.json +1 -1
  35. package/skills/gsk-aidrive/SKILL.md +104 -16
  36. package/skills/gsk-audio-transcribe/SKILL.md +5 -2
  37. package/skills/gsk-calendar-source/SKILL.md +44 -0
  38. package/skills/gsk-connector/SKILL.md +23 -9
  39. package/skills/gsk-create-task/SKILL.md +1 -1
  40. package/skills/gsk-genteam/SKILL.md +3 -1
  41. package/skills/gsk-github/SKILL.md +4 -3
  42. package/skills/gsk-gmail/SKILL.md +1 -1
  43. package/skills/gsk-google-drive/SKILL.md +6 -5
  44. package/skills/gsk-google-sheets/SKILL.md +1 -1
  45. package/skills/gsk-image-generation/SKILL.md +2 -1
  46. package/skills/gsk-meeting/SKILL.md +1 -1
  47. package/skills/gsk-notion/SKILL.md +2 -2
  48. package/skills/gsk-onedrive/SKILL.md +6 -4
  49. package/skills/gsk-outlook-calendar/SKILL.md +1 -1
  50. package/skills/gsk-outlook-email/SKILL.md +1 -1
  51. package/skills/gsk-sb-brain/SKILL.md +32 -21
  52. package/skills/gsk-second-brain/SKILL.md +44 -16
  53. package/skills/gsk-shared/SKILL.md +7 -1
  54. package/skills/gsk-sharepoint/SKILL.md +5 -4
  55. package/skills/gsk-video-generation/SKILL.md +6 -2
@@ -0,0 +1,463 @@
1
+ /**
2
+ * `gsk sb-box … --session <key>` — a client-side session → sandbox binding.
3
+ *
4
+ * Why: an agent that drives sandboxes from its shell has to carry the
5
+ * `sbx-…` id from one command to the next itself, and a tool wrapper
6
+ * (the former opencode `python.ts`) had to keep its own id file to give a
7
+ * conversation one stateful interpreter. Both are the same bookkeeping, so
8
+ * it lives here once: a key names the session, the CLI remembers which
9
+ * sandbox belongs to it, checks the sandbox is still alive before reuse and
10
+ * creates a new one when it is not.
11
+ *
12
+ * Why client-side: the backend tool is stateless per call and shared by
13
+ * REST users and in-product agents; the binding is a convenience of THIS
14
+ * process (like `--args-file` or sb-git's `--execute`). Nothing is sent to
15
+ * the server that it does not already accept — the resolved id goes out as
16
+ * the ordinary `sandbox_id` parameter.
17
+ *
18
+ * Key resolution (first hit wins): `--session <key>`, then the
19
+ * `GSK_SB_BOX_SESSION` env var, then the session id a host agent exports
20
+ * (`CLAUDE_CODE_SESSION_ID`). An explicit `--sandbox_id` always wins over
21
+ * all of them and leaves the binding untouched.
22
+ *
23
+ * Bindings live in `<config dir>/sb-box-sessions.json`, scoped by the API
24
+ * host so a dev and a prod key never resolve to each other's sandboxes.
25
+ */
26
+ import * as crypto from 'crypto';
27
+ import * as fs from 'fs';
28
+ import * as path from 'path';
29
+ export const SESSION_ENV = 'GSK_SB_BOX_SESSION';
30
+ /** Session ids host agents export into the shells they spawn. */
31
+ export const HOST_SESSION_ENVS = ['CLAUDE_CODE_SESSION_ID'];
32
+ export const SESSIONS_FILE = 'sb-box-sessions.json';
33
+ /** Actions that address a sandbox (the server's "Required for" list). */
34
+ export const SANDBOX_ACTIONS = new Set([
35
+ 'get',
36
+ 'kill',
37
+ 'exec',
38
+ 'run-code',
39
+ 'write',
40
+ 'read',
41
+ 'ls',
42
+ 'freeze',
43
+ 'pause',
44
+ 'resume',
45
+ 'rollback',
46
+ 'clone',
47
+ 'versions',
48
+ 'timeout',
49
+ ]);
50
+ /**
51
+ * Actions that may START a session's sandbox when it has none (or its last
52
+ * one is gone): the ones that put work on a machine. Reads, lifecycle and
53
+ * inspection never create — a `kill`/`get`/`read` on an empty session is a
54
+ * mistake worth surfacing, not a reason to bill a new sandbox.
55
+ */
56
+ export const CREATING_ACTIONS = new Set(['exec', 'run-code', 'write']);
57
+ /**
58
+ * States in which the bound sandbox is reusable. frozen / paused are fine:
59
+ * the next data-plane call resumes it with its files and interpreter state.
60
+ */
61
+ export const ALIVE_STATES = new Set([
62
+ 'starting',
63
+ 'running',
64
+ 'freezing',
65
+ 'frozen',
66
+ 'pausing',
67
+ 'paused',
68
+ 'resuming',
69
+ ]);
70
+ /** The public base template line (`gsk sb-box templates`, namespace public). */
71
+ const PUBLIC_BASE_RE = /^sb-box-base-/;
72
+ export class SessionError extends Error {
73
+ }
74
+ /**
75
+ * Pick the session key for this invocation. `explicit` is the `--session`
76
+ * flag value; the env fallbacks make a host-spawned shell "just work"
77
+ * without the model ever handling an id.
78
+ */
79
+ export function resolveSessionKey(explicit, env = process.env) {
80
+ if (typeof explicit === 'string' && explicit.trim()) {
81
+ return { key: explicit.trim(), source: 'flag' };
82
+ }
83
+ const own = env[SESSION_ENV];
84
+ if (own && own.trim())
85
+ return { key: own.trim(), source: SESSION_ENV };
86
+ for (const name of HOST_SESSION_ENVS) {
87
+ const value = env[name];
88
+ if (value && value.trim())
89
+ return { key: value.trim(), source: name };
90
+ }
91
+ return undefined;
92
+ }
93
+ /**
94
+ * Cross-process lock for one session key (parallel first calls from an
95
+ * agent are common: two `write`s fired together must end up on ONE
96
+ * sandbox, not create two and overwrite each other's binding). mkdir is
97
+ * atomic on every platform; a lock older than STALE_MS is a crashed owner.
98
+ */
99
+ const LOCK_WAIT_MS = 90_000; // a create + interpreter start fits comfortably
100
+ // Only reached when the owner pid cannot be checked (foreign host, unreadable
101
+ // pid file): a live owner is never evicted, a dead one is evicted at once.
102
+ const LOCK_STALE_MS = LOCK_WAIT_MS;
103
+ const sleep = (ms) => new Promise(r => setTimeout(r, ms));
104
+ /** The pid recorded in a lock, if readable and plausible. */
105
+ function lockOwnerPid(dir) {
106
+ try {
107
+ const pid = fs.readFileSync(path.join(dir, 'pid'), 'utf8').trim();
108
+ return /^[1-9]\d*$/.test(pid) ? pid : undefined;
109
+ }
110
+ catch {
111
+ return undefined; // no pid yet (owner between mkdir and write) or unreadable
112
+ }
113
+ }
114
+ /** Is the process with this pid alive on this host? */
115
+ function lockOwnerPidAlive(pid) {
116
+ try {
117
+ process.kill(Number(pid), 0);
118
+ return true;
119
+ }
120
+ catch (err) {
121
+ return err.code === 'EPERM';
122
+ }
123
+ }
124
+ export class SessionStore {
125
+ filePath;
126
+ scope;
127
+ constructor(filePath, scope) {
128
+ this.filePath = filePath;
129
+ this.scope = scope;
130
+ }
131
+ lockDir(key) {
132
+ const h = crypto
133
+ .createHash('sha1')
134
+ .update(`${this.scope}\u0000${key}`)
135
+ .digest('hex')
136
+ .slice(0, 16);
137
+ return `${this.filePath}.${h}.lock`;
138
+ }
139
+ /**
140
+ * Run `fn` while holding this key's lock. `fn` receives `held()`, which
141
+ * re-reads the lock's owner: a holder about to commit something it must
142
+ * not do twice (bind a freshly created sandbox) checks it, because an
143
+ * eviction race can in theory move a live lock aside — see `evict`.
144
+ */
145
+ async withLock(key, fn) {
146
+ const dir = this.lockDir(key);
147
+ fs.mkdirSync(path.dirname(dir), { recursive: true, mode: 0o700 });
148
+ const deadline = Date.now() + LOCK_WAIT_MS;
149
+ // Only the owner removes the lock: a waiter that evicted and re-took it
150
+ // is a new owner, and this process must not pull the lock out from
151
+ // under it on its own exit path.
152
+ const release = () => {
153
+ try {
154
+ const pid = fs.readFileSync(path.join(dir, 'pid'), 'utf8').trim();
155
+ if (pid !== String(process.pid))
156
+ return;
157
+ fs.rmSync(dir, { recursive: true, force: true });
158
+ }
159
+ catch {
160
+ /* already gone or not ours */
161
+ }
162
+ };
163
+ const held = () => {
164
+ try {
165
+ return (fs.readFileSync(path.join(dir, 'pid'), 'utf8').trim() ===
166
+ String(process.pid));
167
+ }
168
+ catch {
169
+ return false;
170
+ }
171
+ };
172
+ // Eviction is an atomic rename, then a check: of several waiters that
173
+ // saw the same dead owner exactly one rename succeeds. If what it moved
174
+ // turns out to be a LIVE lock (a waiter that evicted and re-took it in
175
+ // between), it is put back; should even that fail — a third process
176
+ // took the slot in the same instant — the displaced holder notices via
177
+ // `held()` before it commits and reconciles instead of double-binding.
178
+ const evict = (deadPid) => {
179
+ const tomb = `${dir}.evicted.${process.pid}.${Date.now()}`;
180
+ try {
181
+ fs.renameSync(dir, tomb);
182
+ }
183
+ catch {
184
+ return false;
185
+ }
186
+ let movedPid;
187
+ try {
188
+ movedPid = fs.readFileSync(path.join(tomb, 'pid'), 'utf8').trim();
189
+ }
190
+ catch {
191
+ movedPid = undefined;
192
+ }
193
+ if (movedPid !== deadPid && movedPid && lockOwnerPidAlive(movedPid)) {
194
+ try {
195
+ fs.renameSync(tomb, dir);
196
+ }
197
+ catch {
198
+ fs.rmSync(tomb, { recursive: true, force: true });
199
+ }
200
+ return false;
201
+ }
202
+ fs.rmSync(tomb, { recursive: true, force: true });
203
+ return true;
204
+ };
205
+ for (;;) {
206
+ try {
207
+ fs.mkdirSync(dir);
208
+ // Owner pid inside the lock: a lock left by a process that died
209
+ // mid-create (Ctrl+C, SIGKILL, crash) is recognised and evicted by
210
+ // the next command instead of blocking it for the full wait.
211
+ fs.writeFileSync(path.join(dir, 'pid'), String(process.pid));
212
+ break;
213
+ }
214
+ catch (err) {
215
+ if (err.code !== 'EEXIST')
216
+ throw err;
217
+ try {
218
+ const ownerPid = lockOwnerPid(dir);
219
+ const alive = ownerPid === undefined ? undefined : lockOwnerPidAlive(ownerPid);
220
+ if (alive === false ||
221
+ (alive === undefined &&
222
+ Date.now() - fs.statSync(dir).mtimeMs > LOCK_STALE_MS)) {
223
+ evict(ownerPid);
224
+ continue;
225
+ }
226
+ }
227
+ catch {
228
+ continue; // vanished between the two calls: retry at once
229
+ }
230
+ if (Date.now() > deadline) {
231
+ throw new SessionError(`session ${key}: another gsk process has held the session lock ` +
232
+ `for over ${LOCK_WAIT_MS / 1000}s (${dir}); remove it if that ` +
233
+ 'process is gone.');
234
+ }
235
+ await sleep(50 + Math.floor(Math.random() * 50));
236
+ }
237
+ }
238
+ // Release on every exit path, including a signal that would otherwise
239
+ // skip `finally` (Node's default SIGINT/SIGTERM handling exits at once).
240
+ const onSignal = (signal) => {
241
+ release();
242
+ process.exit(signal === 'SIGINT' ? 130 : 143);
243
+ };
244
+ process.once('SIGINT', onSignal);
245
+ process.once('SIGTERM', onSignal);
246
+ process.once('exit', release);
247
+ try {
248
+ return await fn(held);
249
+ }
250
+ finally {
251
+ release();
252
+ process.removeListener('SIGINT', onSignal);
253
+ process.removeListener('SIGTERM', onSignal);
254
+ process.removeListener('exit', release);
255
+ }
256
+ }
257
+ static forConfig(configPath, baseUrl) {
258
+ return new SessionStore(path.join(path.dirname(configPath), SESSIONS_FILE), scopeOf(baseUrl));
259
+ }
260
+ readAll() {
261
+ try {
262
+ const parsed = JSON.parse(fs.readFileSync(this.filePath, 'utf8'));
263
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
264
+ ? parsed
265
+ : {};
266
+ }
267
+ catch {
268
+ return {};
269
+ }
270
+ }
271
+ writeAll(all) {
272
+ fs.mkdirSync(path.dirname(this.filePath), { recursive: true, mode: 0o700 });
273
+ const tmp = `${this.filePath}.${process.pid}.tmp`;
274
+ fs.writeFileSync(tmp, JSON.stringify(all, null, 2) + '\n', { mode: 0o600 });
275
+ fs.renameSync(tmp, this.filePath);
276
+ }
277
+ get(key) {
278
+ return this.readAll()[this.scope]?.[key];
279
+ }
280
+ set(key, binding) {
281
+ const all = this.readAll();
282
+ all[this.scope] = all[this.scope] ?? {};
283
+ all[this.scope][key] = { ...binding, updated_at: new Date().toISOString() };
284
+ this.writeAll(all);
285
+ }
286
+ delete(key) {
287
+ const all = this.readAll();
288
+ if (!all[this.scope]?.[key])
289
+ return;
290
+ delete all[this.scope][key];
291
+ if (Object.keys(all[this.scope]).length === 0)
292
+ delete all[this.scope];
293
+ this.writeAll(all);
294
+ }
295
+ }
296
+ /** Bindings are per API host: a dev and a prod key must never cross. */
297
+ export function scopeOf(baseUrl) {
298
+ try {
299
+ return new URL(baseUrl).host;
300
+ }
301
+ catch {
302
+ return baseUrl;
303
+ }
304
+ }
305
+ /** Newest ready public base template, the default when none is named. */
306
+ export function pickDefaultTemplate(templates) {
307
+ if (!Array.isArray(templates))
308
+ return undefined;
309
+ const base = templates.filter((t) => !!t &&
310
+ typeof t === 'object' &&
311
+ t.status === 'ready' &&
312
+ t.namespace === 'public' &&
313
+ typeof t.name === 'string' &&
314
+ PUBLIC_BASE_RE.test(t.name) &&
315
+ typeof t.id === 'string');
316
+ base.sort((a, b) => ((a.created_at ?? '') < (b.created_at ?? '') ? 1 : -1));
317
+ return base[0]?.id;
318
+ }
319
+ /**
320
+ * `gsk sb-box create` with no --template: the newest ready public base
321
+ * (CLI-side default; the server still requires a template — it just
322
+ * receives the one picked here). Throws when the catalog has none.
323
+ */
324
+ export async function defaultTemplate(call) {
325
+ const listed = await call({ action: 'templates' });
326
+ const template = pickDefaultTemplate(listed.data?.templates);
327
+ if (!template) {
328
+ throw new SessionError('no ready public base template to create from; pass ' +
329
+ '--template <name|tpl-id> (see `gsk sb-box templates`).');
330
+ }
331
+ return template;
332
+ }
333
+ /**
334
+ * Resolve the sandbox for a session before the real call: reuse the bound
335
+ * one if it is alive, otherwise create (for CREATING_ACTIONS) or fail with
336
+ * a message that says what to do. `args` is mutated: `sandbox_id` is set,
337
+ * and `template` (a create-only parameter) is consumed when a sandbox had
338
+ * to be created.
339
+ */
340
+ export async function bindSession(opts) {
341
+ // The whole lookup → verify → create → bind sequence runs under the
342
+ // key's lock, so concurrent first calls serialize: the second one finds
343
+ // the first one's sandbox instead of creating its own.
344
+ return opts.store.withLock(opts.key.key, held => bindSessionLocked(opts, held));
345
+ }
346
+ /** The `get` says the sandbox no longer exists (as opposed to "ask again"). */
347
+ function isGoneError(got) {
348
+ if (got.http_status === 404)
349
+ return true;
350
+ return /not found|no such sandbox|does not exist|unknown sandbox/i.test(got.message ?? '');
351
+ }
352
+ async function bindSessionLocked(opts, held) {
353
+ const { key, action, args, call, store } = opts;
354
+ const log = opts.log ?? (() => { });
355
+ const bound = store.get(key.key);
356
+ if (bound) {
357
+ const got = await call({ action: 'get', sandbox_id: bound.sandbox_id });
358
+ let state;
359
+ if (got.status === 'ok' && got.data && typeof got.data === 'object') {
360
+ state = String(got.data.state ?? '');
361
+ }
362
+ else if (!isGoneError(got)) {
363
+ // A rate limit, timeout or 5xx is not evidence the sandbox is gone:
364
+ // keep the binding and let the caller retry, rather than orphaning a
365
+ // live machine (and its interpreter state) behind a fresh one.
366
+ throw new SessionError(`session ${key.key}: could not check ${bound.sandbox_id} ` +
367
+ `(${got.message}); binding kept — retry, or pass --sandbox_id.`);
368
+ }
369
+ if (state && ALIVE_STATES.has(state)) {
370
+ args.sandbox_id = bound.sandbox_id;
371
+ delete args.template;
372
+ return { key, sandbox_id: bound.sandbox_id, created: false, state };
373
+ }
374
+ store.delete(key.key);
375
+ log(`session ${key.key}: ${bound.sandbox_id} is ${state ?? 'gone'}; ` +
376
+ (CREATING_ACTIONS.has(action) ? 'creating a new sandbox' : 'binding dropped'));
377
+ if (!CREATING_ACTIONS.has(action)) {
378
+ throw new SessionError(`session ${key.key} has no live sandbox (${bound.sandbox_id} is ` +
379
+ `${state ?? 'gone'}). Run exec, run-code or write on the session ` +
380
+ 'to start a new one, or pass --sandbox_id.');
381
+ }
382
+ }
383
+ else if (!CREATING_ACTIONS.has(action)) {
384
+ throw new SessionError(`session ${key.key} has no sandbox yet. Run exec, run-code or write ` +
385
+ 'on the session to start one, or pass --sandbox_id.');
386
+ }
387
+ let template = typeof args.template === 'string' && args.template.trim()
388
+ ? args.template.trim()
389
+ : undefined;
390
+ delete args.template;
391
+ if (!template)
392
+ template = await defaultTemplate(call);
393
+ // timeout 0 = no hard deadline: the sandbox lives across the whole
394
+ // session; the platform's idle freeze (nothing billed while frozen) and
395
+ // an explicit `kill --session` are the lifecycle.
396
+ const created = await call({ action: 'create', template, timeout: 0 });
397
+ const id = created.status === 'ok' && created.data && typeof created.data === 'object'
398
+ ? created.data.id
399
+ : undefined;
400
+ if (typeof id !== 'string' || !id) {
401
+ throw new SessionError(`session ${key.key}: could not create a sandbox: ${created.message}`);
402
+ }
403
+ if (!held()) {
404
+ // The lock was taken from us during the create (eviction race, see
405
+ // withLock). Re-acquire and reconcile: if another process bound a live
406
+ // sandbox meanwhile, use that one and give ours back — one sandbox per
407
+ // session is the contract, a wasted create is the lesser evil.
408
+ log(`session ${key.key}: lost the session lock during create; reconciling`);
409
+ return store.withLock(key.key, async () => {
410
+ const other = store.get(key.key);
411
+ if (other && other.sandbox_id !== id) {
412
+ const got = await call({ action: 'get', sandbox_id: other.sandbox_id });
413
+ const state = got.status === 'ok' && got.data && typeof got.data === 'object'
414
+ ? String(got.data.state ?? '')
415
+ : undefined;
416
+ if (state && ALIVE_STATES.has(state)) {
417
+ await call({ action: 'kill', sandbox_id: id });
418
+ log(`session ${key.key}: using ${other.sandbox_id}, killed ${id}`);
419
+ args.sandbox_id = other.sandbox_id;
420
+ return { key, sandbox_id: other.sandbox_id, created: false, state };
421
+ }
422
+ }
423
+ store.set(key.key, { sandbox_id: id, template });
424
+ log(`session ${key.key}: created ${id} from ${template}`);
425
+ args.sandbox_id = id;
426
+ return { key, sandbox_id: id, created: true };
427
+ });
428
+ }
429
+ store.set(key.key, { sandbox_id: id, template });
430
+ log(`session ${key.key}: created ${id} from ${template}`);
431
+ args.sandbox_id = id;
432
+ return { key, sandbox_id: id, created: true };
433
+ }
434
+ /**
435
+ * After the real call: keep the binding in step with explicit lifecycle
436
+ * actions (`create --session` binds the new sandbox, a successful `kill`
437
+ * drops it) and echo the binding on the envelope so a caller that never
438
+ * saw the id learns it once.
439
+ */
440
+ export function afterSessionCall(opts) {
441
+ const { key, action, bind, result, store } = opts;
442
+ const data = result.data && typeof result.data === 'object' && !Array.isArray(result.data)
443
+ ? result.data
444
+ : undefined;
445
+ if (result.status !== 'ok')
446
+ return;
447
+ let sandboxId = bind?.sandbox_id;
448
+ let created = bind?.created ?? false;
449
+ if (action === 'create' && data && typeof data.id === 'string') {
450
+ sandboxId = data.id;
451
+ created = true;
452
+ store.set(key.key, {
453
+ sandbox_id: data.id,
454
+ template: typeof data.templateId === 'string' ? data.templateId : undefined,
455
+ });
456
+ }
457
+ if (action === 'kill' && sandboxId)
458
+ store.delete(key.key);
459
+ if (data && sandboxId) {
460
+ data.session = { key: key.key, sandbox_id: sandboxId, created };
461
+ }
462
+ }
463
+ //# sourceMappingURL=sb-box-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sb-box-session.js","sourceRoot":"","sources":["../../src/commands/sb-box-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EA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L)
7
7
  * 3. Config file (~/.genspark-tool-cli/config.json)
8
+ *
9
+ * The credential and its base URL are one pair (see resolveCredentialPair):
10
+ * a key is only valid on the server that issued it (a `gsk-` key on www, an
11
+ * `sbx-` Sandbox Passport only on the sbx gateway), so the base URL follows
12
+ * the tier the key came from instead of being resolved independently.
13
+ *
14
+ * API key: --api-key > GSK_API_KEY > config api_key (unchanged)
15
+ * Base URL: 1. --base-url (explicit flag, always wins)
16
+ * 2. the key's own tier: GSK_BASE_URL for an env key,
17
+ * config base_url for a config key (the CLI tier has none)
18
+ * 3. the first other tier, in order env > config, that has a
19
+ * base URL and holds either no key or this same key
20
+ * 4. the default base URL
21
+ * With no key at all: --base-url > GSK_BASE_URL > config base_url > default.
22
+ *
23
+ * So an env key never borrows the config file's base URL when the config
24
+ * file holds a different key (and vice versa) — it gets the default instead.
25
+ * With only one tier populated, or all tiers holding the same key, the result
26
+ * is what plain "CLI > env > config > default" per field gives.
8
27
  */
9
28
  import type { ToolSchema } from './types.js';
10
29
  export interface ConfigFile {
@@ -23,7 +42,7 @@ export interface ConfigFile {
23
42
  */
24
43
  vd_project_id?: string;
25
44
  }
26
- export declare const GSK_CLI_CAPS = "cli-groups-v2,cli-paths-v3,cli-actions-v4,cli-confirm-v1,cli-yes-only-v1,cli-local-source-v1";
45
+ export declare const GSK_CLI_CAPS = "cli-groups-v2,cli-paths-v3,cli-actions-v4,cli-confirm-v1,cli-yes-only-v1,cli-local-source-v1,cli-drive-actions-v1";
27
46
  /**
28
47
  * Set (or clear) the custom config path. Call this before any other
29
48
  * function in this module so that subsequent reads/writes target the
@@ -87,4 +106,26 @@ export declare function saveToolsCache(baseUrl: string, tools: ToolSchema[], fea
87
106
  * key), so a stray value can never break the CLI.
88
107
  */
89
108
  export declare function resolveRequestCredential(apiKey: string | undefined, env?: NodeJS.ProcessEnv): string;
109
+ /** One configuration tier's view of the credential pair; empty = unset. */
110
+ export interface CredentialTier {
111
+ apiKey?: string;
112
+ baseUrl?: string;
113
+ }
114
+ export interface CredentialPairSources {
115
+ /** `--api-key`. */
116
+ cliApiKey?: string;
117
+ /** `--base-url`, only when the user passed the flag explicitly. */
118
+ cliBaseUrl?: string;
119
+ env: CredentialTier;
120
+ file: CredentialTier;
121
+ defaultBaseUrl: string;
122
+ }
123
+ /**
124
+ * Resolve the API key and the base URL as one pair — precedence documented
125
+ * in the header comment of this file.
126
+ */
127
+ export declare function resolveCredentialPair(sources: CredentialPairSources): {
128
+ apiKey: string | undefined;
129
+ baseUrl: string;
130
+ };
90
131
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAuBD,eAAO,MAAM,YAAY,iGACuE,CAAA;AAmChG;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEvE;AAYD;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAKtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAiC3C;AAmFD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAEvD;AAuBD;;GAEG;AACH,wBAAgB,gB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AAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG;IACrE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAoBA"}
package/dist/config.js CHANGED
@@ -5,6 +5,25 @@
5
5
  * 1. Command-line options
6
6
  * 2. Environment variables (GSK_API_KEY, GSK_BASE_URL)
7
7
  * 3. Config file (~/.genspark-tool-cli/config.json)
8
+ *
9
+ * The credential and its base URL are one pair (see resolveCredentialPair):
10
+ * a key is only valid on the server that issued it (a `gsk-` key on www, an
11
+ * `sbx-` Sandbox Passport only on the sbx gateway), so the base URL follows
12
+ * the tier the key came from instead of being resolved independently.
13
+ *
14
+ * API key: --api-key > GSK_API_KEY > config api_key (unchanged)
15
+ * Base URL: 1. --base-url (explicit flag, always wins)
16
+ * 2. the key's own tier: GSK_BASE_URL for an env key,
17
+ * config base_url for a config key (the CLI tier has none)
18
+ * 3. the first other tier, in order env > config, that has a
19
+ * base URL and holds either no key or this same key
20
+ * 4. the default base URL
21
+ * With no key at all: --base-url > GSK_BASE_URL > config base_url > default.
22
+ *
23
+ * So an env key never borrows the config file's base URL when the config
24
+ * file holds a different key (and vice versa) — it gets the default instead.
25
+ * With only one tier populated, or all tiers holding the same key, the result
26
+ * is what plain "CLI > env > config > default" per field gives.
8
27
  */
9
28
  import * as fs from 'fs';
10
29
  import * as path from 'path';
@@ -31,7 +50,7 @@ import { randomUUID } from 'crypto';
31
50
  // so their --skip_confirmation flags and args-file payloads keep parsing.
32
51
  // Because the caps string is part of the cache filename, their cache and
33
52
  // this binary's cache never mix.
34
- export const GSK_CLI_CAPS = 'cli-groups-v2,cli-paths-v3,cli-actions-v4,cli-confirm-v1,cli-yes-only-v1,cli-local-source-v1';
53
+ export const GSK_CLI_CAPS = 'cli-groups-v2,cli-paths-v3,cli-actions-v4,cli-confirm-v1,cli-yes-only-v1,cli-local-source-v1,cli-drive-actions-v1';
35
54
  const CONFIG_DIR = '.genspark-tool-cli';
36
55
  const CONFIG_FILE = 'config.json';
37
56
  // Pre-caps CLIs (e.g. the Genspark Desktop bundled binary) read this file
@@ -357,4 +376,27 @@ export function resolveRequestCredential(apiKey, env = process.env) {
357
376
  return turn;
358
377
  return apiKey || '';
359
378
  }
379
+ /**
380
+ * Resolve the API key and the base URL as one pair — precedence documented
381
+ * in the header comment of this file.
382
+ */
383
+ export function resolveCredentialPair(sources) {
384
+ const { cliApiKey, cliBaseUrl, env, file, defaultBaseUrl } = sources;
385
+ const apiKey = cliApiKey || env.apiKey || file.apiKey || undefined;
386
+ if (cliBaseUrl)
387
+ return { apiKey, baseUrl: normalizeBaseUrl(cliBaseUrl) };
388
+ const ownTier = cliApiKey
389
+ ? undefined
390
+ : env.apiKey
391
+ ? env
392
+ : file.apiKey
393
+ ? file
394
+ : undefined;
395
+ const compatible = (tier) => !!tier.baseUrl && (!apiKey || !tier.apiKey || tier.apiKey === apiKey);
396
+ const source = (ownTier?.baseUrl ? ownTier : undefined) ?? [env, file].find(compatible);
397
+ return {
398
+ apiKey,
399
+ baseUrl: normalizeBaseUrl(source?.baseUrl || defaultBaseUrl),
400
+ };
401
+ }
360
402
  //# sourceMappingURL=config.js.map