@genspark/cli 1.7.0 → 1.8.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/README.md +21 -9
- package/dist/commands/aidrive-download.d.ts +7 -0
- package/dist/commands/aidrive-download.d.ts.map +1 -1
- package/dist/commands/aidrive-download.js +17 -1
- package/dist/commands/aidrive-download.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -44
- package/dist/index.js.map +1 -1
- package/dist/pendingApproval.d.ts +98 -0
- package/dist/pendingApproval.d.ts.map +1 -0
- package/dist/pendingApproval.js +252 -0
- package/dist/pendingApproval.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/skills.md +4 -4
- package/package.json +1 -1
- package/skills/gsk-aidrive/SKILL.md +38 -24
- package/skills/gsk-batch-crawl-url-and-answer/SKILL.md +7 -7
- package/skills/gsk-genteam/SKILL.md +40 -23
- package/skills/gsk-github/SKILL.md +1 -1
- package/skills/gsk-gmail/SKILL.md +3 -2
- package/skills/gsk-google-calendar/SKILL.md +1 -1
- package/skills/gsk-google-chat/SKILL.md +4 -2
- package/skills/gsk-google-docs/SKILL.md +1 -1
- package/skills/gsk-google-drive/SKILL.md +2 -2
- package/skills/gsk-google-sheets/SKILL.md +1 -1
- package/skills/gsk-google-slides/SKILL.md +1 -1
- package/skills/gsk-hub/SKILL.md +1 -1
- package/skills/gsk-meeting/SKILL.md +8 -2
- package/skills/gsk-microsoft-teams/SKILL.md +6 -5
- package/skills/gsk-notion/SKILL.md +1 -1
- package/skills/gsk-onedrive/SKILL.md +2 -2
- package/skills/gsk-outlook-calendar/SKILL.md +1 -1
- package/skills/gsk-outlook-email/SKILL.md +4 -2
- package/skills/gsk-phone-call/SKILL.md +19 -11
- package/skills/gsk-sharepoint/SKILL.md +2 -2
- package/skills/gsk-slack/SKILL.md +4 -3
- package/skills/gsk-video-generation/SKILL.md +3 -3
- package/skills/gsk-youtube/SKILL.md +11 -4
package/README.md
CHANGED
|
@@ -394,12 +394,19 @@ gsk transcribe -i ./meeting.wav -m "whisper-large-v3"
|
|
|
394
394
|
|
|
395
395
|
### aidrive (alias: `drive`)
|
|
396
396
|
|
|
397
|
-
AI-Drive file storage and management.
|
|
397
|
+
AI-Drive file storage and management. Canonical workspaces are `my_drive`,
|
|
398
|
+
`shared_with_me`, and `shared_drive`. Run `ls` on a shared workspace first, then pass
|
|
399
|
+
the returned stable `source_id` to work inside one source. `shared_with_me` is
|
|
400
|
+
an ACL-filtered view and does not own bytes or quota.
|
|
398
401
|
|
|
399
402
|
```bash
|
|
400
403
|
# List files in root directory
|
|
401
|
-
gsk drive ls
|
|
402
|
-
gsk drive ls -p "/documents" -f file
|
|
404
|
+
gsk drive ls --workspace my_drive
|
|
405
|
+
gsk drive ls --workspace my_drive -p "/documents" -f file
|
|
406
|
+
|
|
407
|
+
# Discover and read a source shared with you
|
|
408
|
+
gsk drive ls --workspace shared_with_me
|
|
409
|
+
gsk drive ls --workspace shared_with_me --source "<source_id>"
|
|
403
410
|
|
|
404
411
|
# Create directory
|
|
405
412
|
gsk drive mkdir -p "/my-folder"
|
|
@@ -407,10 +414,13 @@ gsk drive mkdir -p "/my-folder"
|
|
|
407
414
|
# Move file
|
|
408
415
|
gsk drive move -p "/old-path/file.txt" --target_path "/new-path/file.txt"
|
|
409
416
|
|
|
410
|
-
# Download video/audio/file
|
|
417
|
+
# Download an external video/audio/file into AI-Drive (the "download for me" actions)
|
|
411
418
|
gsk drive download_video --video_url "https://example.com/video.mp4" --target_folder "/videos"
|
|
412
419
|
gsk drive download_file --file_url "https://example.com/doc.pdf" --target_folder "/docs"
|
|
413
420
|
|
|
421
|
+
# Download an AI-Drive file to the local machine
|
|
422
|
+
gsk drive download "/docs/report.pdf" ./report.pdf
|
|
423
|
+
|
|
414
424
|
# Upload inline text content to AI-Drive
|
|
415
425
|
gsk drive upload --file_content "Hello World" --upload_path "/notes/hello.txt"
|
|
416
426
|
|
|
@@ -427,15 +437,17 @@ gsk drive get_readable_url -p "/documents/report.pdf"
|
|
|
427
437
|
|
|
428
438
|
| Option | Default | Description |
|
|
429
439
|
|--------|---------|-------------|
|
|
440
|
+
| `--workspace <name>` | `my_drive` | `my_drive`, `shared_with_me`, or `shared_drive` |
|
|
441
|
+
| `--source <id>` | — | Stable source ID returned by listing a shared workspace |
|
|
430
442
|
| `-p, --path <path>` | — | File or directory path in AI-Drive |
|
|
431
443
|
| `-f, --filter_type <type>` | `all` | Filter: `all`, `file`, `directory` |
|
|
432
444
|
| `--file_type <type>` | `all` | File type filter: `all`, `audio`, `video`, `image` |
|
|
433
445
|
| `--target_path <path>` | — | Target path for move operations |
|
|
434
|
-
| `--target_folder <path>` | — | Target folder for
|
|
435
|
-
| `--video_url <url>` | — |
|
|
436
|
-
| `--audio_url <url>` | — |
|
|
437
|
-
| `--file_url <url>` | — |
|
|
438
|
-
| `--file_name <name>` | — | Custom
|
|
446
|
+
| `--target_folder <path>` | — | Target folder for `download_video`, `download_audio`, or `download_file` |
|
|
447
|
+
| `--video_url <url>` | — | External video URL for `download_video` |
|
|
448
|
+
| `--audio_url <url>` | — | External audio/video URL for `download_audio` |
|
|
449
|
+
| `--file_url <url>` | — | External file URL for `download_file` |
|
|
450
|
+
| `--file_name <name>` | — | Custom filename for `download_file` |
|
|
439
451
|
| `--file_content <text>` | — | Inline text content to upload |
|
|
440
452
|
| `--local_file <path>` | — | Local file path to upload directly to AI-Drive (streaming, no size limit) |
|
|
441
453
|
| `--upload_path <path>` | — | Destination path for upload (defaults to `/<filename>` for `--local_file`) |
|
|
@@ -20,4 +20,11 @@ export declare function normalizeDrivePath(pathOrUrl: string): string;
|
|
|
20
20
|
* be parsed; the structured value lives in `session_state.aidrive_result`.
|
|
21
21
|
*/
|
|
22
22
|
export declare function extractReadableUrl(response: Pick<ApiResponse, 'status' | 'session_state'>): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* A file-wrapper URL carrying its own access token is already the final,
|
|
25
|
+
* fetchable URL. Sending it through `/file/download` re-checks ownership and
|
|
26
|
+
* incorrectly rejects files the caller may read through a Drive share.
|
|
27
|
+
* Token-less wrapper URLs still need the resolver used by other CLI exports.
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldResolveFileWrapperUrl(url: string): boolean;
|
|
23
30
|
//# sourceMappingURL=aidrive-download.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aidrive-download.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACzB;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAQ5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,CAAC,GACtD,MAAM,GAAG,SAAS,CAMpB"}
|
|
1
|
+
{"version":3,"file":"aidrive-download.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACzB;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAQ5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,CAAC,GACtD,MAAM,GAAG,SAAS,CAMpB;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhE"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* `--path`/`-p`, the first operand is the destination instead.
|
|
5
5
|
*/
|
|
6
6
|
export function resolveAidriveDownloadOperands(operands, explicitDrivePath) {
|
|
7
|
-
const bareOperands = operands.filter(
|
|
7
|
+
const bareOperands = operands.filter(operand => operand.length > 0 && !operand.startsWith('-'));
|
|
8
8
|
if (explicitDrivePath) {
|
|
9
9
|
return { drivePath: explicitDrivePath, localPath: bareOperands[0] };
|
|
10
10
|
}
|
|
@@ -33,4 +33,20 @@ export function extractReadableUrl(response) {
|
|
|
33
33
|
const url = aidriveResult.readable_url;
|
|
34
34
|
return typeof url === 'string' && url ? url : undefined;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A file-wrapper URL carrying its own access token is already the final,
|
|
38
|
+
* fetchable URL. Sending it through `/file/download` re-checks ownership and
|
|
39
|
+
* incorrectly rejects files the caller may read through a Drive share.
|
|
40
|
+
* Token-less wrapper URLs still need the resolver used by other CLI exports.
|
|
41
|
+
*/
|
|
42
|
+
export function shouldResolveFileWrapperUrl(url) {
|
|
43
|
+
if (!url.includes('/api/files/'))
|
|
44
|
+
return false;
|
|
45
|
+
try {
|
|
46
|
+
return !new URL(url, 'https://local.invalid').searchParams.has('token');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
36
52
|
//# sourceMappingURL=aidrive-download.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aidrive-download.js","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA2B,EAC3B,iBAA0B;IAE1B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,
|
|
1
|
+
{"version":3,"file":"aidrive-download.js","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA2B,EAC3B,iBAA0B;IAE1B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAC1D,CAAA;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IACrE,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,kEAAkE;IAClE,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAuD;IAEvD,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC9C,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAA;IAC5D,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACzE,MAAM,GAAG,GAAI,aAAyC,CAAC,YAAY,CAAA;IACnE,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,GAAW;IACrD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,KAAK,CAAA;IAC9C,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AA6RH,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
|
@@ -31,6 +31,7 @@ import { pipeline } from 'stream/promises';
|
|
|
31
31
|
import { ApiClient, isAuthError, unauthenticatedRequest, } from './client.js';
|
|
32
32
|
import { classifyFileArg, awaitLocalFileReady, decideAfterWait, localFileNotReadyError, passthroughWarning, urlsParamItems, } from './localFiles.js';
|
|
33
33
|
import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, } from './logger.js';
|
|
34
|
+
import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
|
|
34
35
|
import { loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
|
|
35
36
|
import { checkForUpdates } from './updater.js';
|
|
36
37
|
import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
|
|
@@ -38,7 +39,7 @@ import { shimLegacyTaskInvocation } from './task-shim.js';
|
|
|
38
39
|
import { getSandboxRuntime } from './runtime.js';
|
|
39
40
|
import { registerDesignCommand } from './commands/design.js';
|
|
40
41
|
import { collectUploadFiles, pickExistingUploadOperand, } from './commands/aidrive-upload.js';
|
|
41
|
-
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, } from './commands/aidrive-download.js';
|
|
42
|
+
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
|
|
42
43
|
import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
|
|
43
44
|
import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
|
|
44
45
|
import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
|
|
@@ -99,6 +100,8 @@ program
|
|
|
99
100
|
.option('--debug', 'Enable debug output and request more details from server', false)
|
|
100
101
|
.option('--timeout <ms>', 'Request timeout in milliseconds', String(DEFAULT_TIMEOUT))
|
|
101
102
|
.option('--output <format>', 'Output format: json or text', 'json')
|
|
103
|
+
// Commander negation flag: parses into opts.input (default true).
|
|
104
|
+
.option('--no-input', 'Never prompt interactively (e.g. hosted approval y/n); print pending envelopes as-is')
|
|
102
105
|
.option('--refresh', 'Force refresh of cached tool schemas from server')
|
|
103
106
|
.option('--config <path>', 'Path to a custom config file (defaults to ~/.genspark-tool-cli/config.json, or set GSK_CONFIG env var). The tools cache lives in the same directory as the config file.');
|
|
104
107
|
/**
|
|
@@ -135,6 +138,8 @@ function getGlobalOptions() {
|
|
|
135
138
|
output: opts.output,
|
|
136
139
|
projectId,
|
|
137
140
|
refresh: opts.refresh || false,
|
|
141
|
+
// Commander stores the --no-input negation flag as opts.input=false.
|
|
142
|
+
noInput: opts.input === false,
|
|
138
143
|
};
|
|
139
144
|
}
|
|
140
145
|
function createClient() {
|
|
@@ -359,7 +364,7 @@ async function uploadLocalFile(filePath, client) {
|
|
|
359
364
|
*
|
|
360
365
|
* This avoids the roundabout blob-upload + download_file two-step approach.
|
|
361
366
|
*/
|
|
362
|
-
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = '
|
|
367
|
+
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source) {
|
|
363
368
|
const fileName = pathModule.basename(filePath);
|
|
364
369
|
const ext = pathModule.extname(filePath).toLowerCase();
|
|
365
370
|
const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
@@ -367,7 +372,15 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
367
372
|
info(`Uploading ${fileName} (${formatFileSize(fileSize)}, ${contentType}) directly to AI Drive...`);
|
|
368
373
|
const globalOpts = getGlobalOptions();
|
|
369
374
|
const baseUrl = globalOpts.baseUrl.replace(/\/$/, '');
|
|
370
|
-
const
|
|
375
|
+
const uploadQuery = new URLSearchParams({
|
|
376
|
+
upload_path: uploadPath,
|
|
377
|
+
workspace,
|
|
378
|
+
});
|
|
379
|
+
if (override)
|
|
380
|
+
uploadQuery.set('override', 'true');
|
|
381
|
+
if (source)
|
|
382
|
+
uploadQuery.set('source', source);
|
|
383
|
+
const uploadUrl = `${baseUrl}/api/tool_cli/aidrive/upload?${uploadQuery.toString()}`;
|
|
371
384
|
const headers = { 'Content-Type': contentType };
|
|
372
385
|
if (globalOpts.apiKey)
|
|
373
386
|
headers['X-Api-Key'] = globalOpts.apiKey;
|
|
@@ -385,8 +398,10 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
385
398
|
async function downloadToFile(url, savePath, client) {
|
|
386
399
|
info(`Downloading to ${savePath}...`);
|
|
387
400
|
let downloadUrl = url;
|
|
388
|
-
//
|
|
389
|
-
|
|
401
|
+
// Token-less file wrappers need `/file/download`; a signed wrapper is
|
|
402
|
+
// already fetchable and must keep its share token (important for Drive
|
|
403
|
+
// files whose storage owner is not the caller).
|
|
404
|
+
if (shouldResolveFileWrapperUrl(url)) {
|
|
390
405
|
const result = await client.getDownloadUrl({ file_wrapper_url: url });
|
|
391
406
|
if (result.status !== 'ok' || !result.data)
|
|
392
407
|
throw new Error(`Failed to get download URL: ${result.message}`);
|
|
@@ -831,7 +846,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
831
846
|
// upload and by `download`'s local destination.
|
|
832
847
|
if (tool.name === 'aidrive') {
|
|
833
848
|
if (!Object.hasOwn(props, 'workspace')) {
|
|
834
|
-
cmd.option('--workspace <value>', 'AI Drive workspace:
|
|
849
|
+
cmd.option('--workspace <value>', 'AI Drive workspace: my_drive, shared_with_me, or shared_drive');
|
|
835
850
|
}
|
|
836
851
|
cmd.option('--local_file <path>', 'upload: local file path to upload to AI Drive (supports files >5 MB; ' +
|
|
837
852
|
'alternative to --file_content). download: local destination path ' +
|
|
@@ -1224,9 +1239,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1224
1239
|
// rather than making the caller strip the scheme.
|
|
1225
1240
|
const drivePath = normalizeDrivePath(sourceOperand);
|
|
1226
1241
|
const urlResult = await client.executeTool('aidrive', {
|
|
1242
|
+
// Use the established wire spelling; both older backends and the
|
|
1243
|
+
// current canonical contract recognize it.
|
|
1227
1244
|
action: 'get_readable_url',
|
|
1228
1245
|
path: drivePath,
|
|
1229
1246
|
workspace: args.workspace,
|
|
1247
|
+
source: args.source,
|
|
1230
1248
|
share: args.share,
|
|
1231
1249
|
});
|
|
1232
1250
|
const readableUrl = extractReadableUrl(urlResult);
|
|
@@ -1280,7 +1298,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1280
1298
|
opts.local_file) {
|
|
1281
1299
|
const localFilePath = opts.local_file;
|
|
1282
1300
|
const override = !!opts.override;
|
|
1283
|
-
const workspace = args.workspace || '
|
|
1301
|
+
const workspace = args.workspace || 'my_drive';
|
|
1302
|
+
const source = args.source ||
|
|
1303
|
+
args.share;
|
|
1284
1304
|
if (!fs.existsSync(localFilePath)) {
|
|
1285
1305
|
logError(`File not found: ${localFilePath}`);
|
|
1286
1306
|
process.exit(1);
|
|
@@ -1303,7 +1323,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1303
1323
|
const uploaded = [];
|
|
1304
1324
|
for (const file of files) {
|
|
1305
1325
|
const destination = pathModule.posix.join(uploadPath, file.relativePath);
|
|
1306
|
-
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace);
|
|
1326
|
+
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source);
|
|
1307
1327
|
if (result.status !== 'ok') {
|
|
1308
1328
|
output(result);
|
|
1309
1329
|
process.exit(1);
|
|
@@ -1318,7 +1338,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1318
1338
|
}
|
|
1319
1339
|
else {
|
|
1320
1340
|
// Stream directly to AI Drive — single request, no blob middleman
|
|
1321
|
-
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace);
|
|
1341
|
+
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source);
|
|
1322
1342
|
output(result);
|
|
1323
1343
|
}
|
|
1324
1344
|
return;
|
|
@@ -1579,6 +1599,20 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1579
1599
|
}
|
|
1580
1600
|
}
|
|
1581
1601
|
}
|
|
1602
|
+
// Hosted destructive submissions pause on a pending approval
|
|
1603
|
+
// (data.code === 'pending_approval'). In an interactive terminal
|
|
1604
|
+
// offer approve/reject right here (prompt on stderr) instead of
|
|
1605
|
+
// only echoing the stub; non-TTY and --no-input keep today's
|
|
1606
|
+
// print-and-exit behavior. All three stdio streams must be TTYs:
|
|
1607
|
+
// the prompt lives on stderr, so `2>/dev/null` must not turn into
|
|
1608
|
+
// an invisible-prompt hang. Whatever branch runs, `result` becomes
|
|
1609
|
+
// the LAST transport envelope received, so stdout still carries
|
|
1610
|
+
// exactly one JSON document. See pendingApproval.ts.
|
|
1611
|
+
if (shouldPromptForApproval(result, process.stdin.isTTY === true &&
|
|
1612
|
+
process.stdout.isTTY === true &&
|
|
1613
|
+
process.stderr.isTTY === true, getGlobalOptions().noInput === true)) {
|
|
1614
|
+
result = await runInteractiveApprovalFlow(result, (name, toolArgs) => client.executeTool(name, toolArgs));
|
|
1615
|
+
}
|
|
1582
1616
|
// Media generation payloads print compact + a stderr field summary
|
|
1583
1617
|
// so agent-side `grep | head` filters can't lose the URLs/task_id
|
|
1584
1618
|
// (the fabricated-URL incident behind PR #41690) — see
|
|
@@ -1748,7 +1782,8 @@ program
|
|
|
1748
1782
|
program
|
|
1749
1783
|
.command('login')
|
|
1750
1784
|
.description('Log in to Genspark via browser to obtain an API key')
|
|
1751
|
-
.
|
|
1785
|
+
.option('--no-open', 'Print the login URL without opening a browser')
|
|
1786
|
+
.action(async (loginOpts) => {
|
|
1752
1787
|
const globalOpts = getGlobalOptions();
|
|
1753
1788
|
setDebugEnabled(globalOpts.debug);
|
|
1754
1789
|
setOutputFormat(globalOpts.output);
|
|
@@ -1758,44 +1793,52 @@ program
|
|
|
1758
1793
|
info('Requesting device code...');
|
|
1759
1794
|
const deviceResp = await unauthenticatedRequest(baseUrl, '/api/cli_auth/device_code', 'POST');
|
|
1760
1795
|
const { device_code, auth_url, poll_interval, expires_in } = deviceResp;
|
|
1761
|
-
// Step 2: Open browser
|
|
1762
|
-
|
|
1796
|
+
// Step 2: Open browser unless the caller explicitly opted out. Tests
|
|
1797
|
+
// and headless automation use --no-open so a mock URL never escapes
|
|
1798
|
+
// into the user's desktop session.
|
|
1799
|
+
if (loginOpts.open !== false)
|
|
1800
|
+
info('Opening browser for login...');
|
|
1763
1801
|
info(`Login URL: ${auth_url}`);
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
cmd
|
|
1779
|
-
args
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1802
|
+
if (loginOpts.open === false) {
|
|
1803
|
+
info('Browser opening disabled; open the URL above manually.');
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
// Validate auth_url is a same-origin HTTP(S) URL before passing to spawn
|
|
1807
|
+
try {
|
|
1808
|
+
const parsed = new URL(auth_url);
|
|
1809
|
+
const base = new URL(baseUrl);
|
|
1810
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
1811
|
+
throw new Error('auth_url is not http(s)');
|
|
1812
|
+
}
|
|
1813
|
+
if (parsed.host !== base.host) {
|
|
1814
|
+
throw new Error('auth_url host does not match baseUrl host');
|
|
1815
|
+
}
|
|
1816
|
+
let cmd;
|
|
1817
|
+
let args;
|
|
1818
|
+
if (process.platform === 'win32') {
|
|
1819
|
+
// Avoid cmd.exe which interprets & in URLs as command separators
|
|
1820
|
+
cmd = 'rundll32';
|
|
1821
|
+
args = ['url.dll,FileProtocolHandler', auth_url];
|
|
1822
|
+
}
|
|
1823
|
+
else if (process.platform === 'darwin') {
|
|
1824
|
+
cmd = 'open';
|
|
1825
|
+
args = [auth_url];
|
|
1826
|
+
}
|
|
1827
|
+
else {
|
|
1828
|
+
cmd = 'xdg-open';
|
|
1829
|
+
args = [auth_url];
|
|
1830
|
+
}
|
|
1831
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
1832
|
+
child.on('error', () => {
|
|
1833
|
+
info('Could not open browser automatically.');
|
|
1834
|
+
info('Please open the URL above manually.');
|
|
1835
|
+
});
|
|
1836
|
+
child.unref();
|
|
1788
1837
|
}
|
|
1789
|
-
|
|
1790
|
-
child.on('error', () => {
|
|
1838
|
+
catch {
|
|
1791
1839
|
info('Could not open browser automatically.');
|
|
1792
1840
|
info('Please open the URL above manually.');
|
|
1793
|
-
}
|
|
1794
|
-
child.unref();
|
|
1795
|
-
}
|
|
1796
|
-
catch {
|
|
1797
|
-
info('Could not open browser automatically.');
|
|
1798
|
-
info('Please open the URL above manually.');
|
|
1841
|
+
}
|
|
1799
1842
|
}
|
|
1800
1843
|
info(`Waiting for authorization (expires in ${expires_in}s, press Ctrl+C to cancel)...`);
|
|
1801
1844
|
// Step 3: Poll for token
|