@genspark/cli 1.15.4-beta.0 → 1.15.5

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 (65) hide show
  1. package/README.md +118 -12
  2. package/dist/acp-serve.d.ts +2 -2
  3. package/dist/acp-serve.d.ts.map +1 -1
  4. package/dist/acp-serve.js +7 -2
  5. package/dist/acp-serve.js.map +1 -1
  6. package/dist/client.d.ts +16 -0
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +52 -12
  9. package/dist/client.js.map +1 -1
  10. package/dist/commands/aidrive-contract.generated.d.ts.map +1 -1
  11. package/dist/commands/aidrive-contract.generated.js +62 -9
  12. package/dist/commands/aidrive-contract.generated.js.map +1 -1
  13. package/dist/commands/developer-input.d.ts +1 -1
  14. package/dist/commands/developer-input.d.ts.map +1 -1
  15. package/dist/commands/developer-input.js +14 -10
  16. package/dist/commands/developer-input.js.map +1 -1
  17. package/dist/commands/sb-box-session.d.ts +7 -6
  18. package/dist/commands/sb-box-session.d.ts.map +1 -1
  19. package/dist/commands/sb-box-session.js +21 -41
  20. package/dist/commands/sb-box-session.js.map +1 -1
  21. package/dist/commands/task-status-follow.d.ts +9 -0
  22. package/dist/commands/task-status-follow.d.ts.map +1 -1
  23. package/dist/commands/task-status-follow.js +24 -4
  24. package/dist/commands/task-status-follow.js.map +1 -1
  25. package/dist/commands/tts-stream.d.ts +68 -0
  26. package/dist/commands/tts-stream.d.ts.map +1 -0
  27. package/dist/commands/tts-stream.js +291 -0
  28. package/dist/commands/tts-stream.js.map +1 -0
  29. package/dist/confirm.d.ts.map +1 -1
  30. package/dist/confirm.js +18 -1
  31. package/dist/confirm.js.map +1 -1
  32. package/dist/humanApproval.d.ts +48 -0
  33. package/dist/humanApproval.d.ts.map +1 -0
  34. package/dist/humanApproval.js +86 -0
  35. package/dist/humanApproval.js.map +1 -0
  36. package/dist/index.js +169 -37
  37. package/dist/index.js.map +1 -1
  38. package/dist/mediaSummary.d.ts.map +1 -1
  39. package/dist/mediaSummary.js +4 -1
  40. package/dist/mediaSummary.js.map +1 -1
  41. package/dist/task-shim.d.ts +11 -2
  42. package/dist/task-shim.d.ts.map +1 -1
  43. package/dist/task-shim.js +21 -2
  44. package/dist/task-shim.js.map +1 -1
  45. package/docs/skills.md +5 -4
  46. package/gated-skills/gsk-issue/SKILL.md +50 -0
  47. package/gated-skills/gsk-m365-apps/SKILL.md +197 -0
  48. package/gated-skills/gsk-m365-apps/references/add-genspark-ai.md +399 -0
  49. package/gated-skills/gsk-m365-apps/scripts/install-genspark-connector.mjs +548 -0
  50. package/gated-skills/gsk-m365-apps/scripts/sync-microsoft-guidance.mjs +557 -0
  51. package/package.json +2 -1
  52. package/skills/gsk-aidrive/SKILL.md +52 -480
  53. package/skills/gsk-aidrive/command-reference.md +550 -0
  54. package/skills/gsk-connector/SKILL.md +5 -3
  55. package/skills/gsk-get-service-url/SKILL.md +1 -1
  56. package/skills/gsk-gmail/SKILL.md +17 -17
  57. package/skills/gsk-google-calendar/SKILL.md +3 -3
  58. package/skills/gsk-image-generation/SKILL.md +6 -3
  59. package/skills/gsk-outlook-calendar/SKILL.md +1 -1
  60. package/skills/gsk-phone-call/SKILL.md +33 -13
  61. package/skills/gsk-second-brain/SKILL.md +15 -16
  62. package/skills/gsk-shared/SKILL.md +1 -1
  63. package/skills/gsk-slack/SKILL.md +4 -1
  64. package/skills/gsk-team-brain/SKILL.md +208 -0
  65. package/skills/gsk-video-generation/SKILL.md +4 -4
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Waiting for the user's approval of an agent's outbound action (#66416).
3
+ *
4
+ * When an agent-held token (a Genspark sandbox, an OpenClaw VM) sends outside
5
+ * the user's organization, `--yes` does not count: the server parks the call
6
+ * and answers `status: "pending_human_approval"` with an `approval_id`. Only
7
+ * the user can decide, in Genspark (the CLI has no way to approve). This
8
+ * module waits a bounded time for that decision, polling the read-only
9
+ * `GET /agent_approvals/<id>`, and re-issues the identical call once the user
10
+ * has decided — the server then sends it (approved) or reports the decline.
11
+ * Out of budget, the original envelope is printed as-is: it tells the agent
12
+ * to re-run the same command after the user approves.
13
+ *
14
+ * Decisions are pure functions; the loop takes its I/O as parameters. All
15
+ * progress goes to stderr; the caller prints exactly one envelope.
16
+ */
17
+ import type { ApiResponse } from './types.js';
18
+ export declare const STATUS_PENDING_HUMAN_APPROVAL = "pending_human_approval";
19
+ export declare const DEFAULT_WAIT_SECONDS = 90;
20
+ export interface HumanApprovalInfo {
21
+ id: string;
22
+ expiresAt?: number;
23
+ }
24
+ /** The approval a parked call waits for, or null for any other envelope. */
25
+ export declare function extractHumanApproval(envelope: ApiResponse): HumanApprovalInfo | null;
26
+ /**
27
+ * Seconds to wait: `GSK_APPROVAL_WAIT_SECONDS` when it is a non-negative
28
+ * integer (0 = do not wait), else the default — short enough to fit an agent
29
+ * shell's command timeout.
30
+ */
31
+ export declare function approvalWaitSeconds(raw: string | undefined): number;
32
+ export type ApprovalState = 'pending' | 'approved' | 'rejected' | 'expired';
33
+ /** Whether to keep polling (`pending`) or re-issue the call (a decision). */
34
+ export declare function nextApprovalStep(state: unknown): 'poll' | 'rerun' | 'stop';
35
+ export interface HumanApprovalIo {
36
+ pollState: () => Promise<unknown>;
37
+ rerun: () => Promise<ApiResponse>;
38
+ notify: (line: string) => void;
39
+ sleep: (ms: number) => Promise<void>;
40
+ nowMs: () => number;
41
+ }
42
+ /**
43
+ * Wait for the user's decision on `approval`, then re-issue the call once.
44
+ * Returns the envelope to print: the re-issued call's, or `original` when
45
+ * the budget ran out, the request expired, or polling failed.
46
+ */
47
+ export declare function waitForHumanApproval(original: ApiResponse, approval: HumanApprovalInfo, budgetSeconds: number, io: HumanApprovalIo): Promise<ApiResponse>;
48
+ //# sourceMappingURL=humanApproval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"humanApproval.d.ts","sourceRoot":"","sources":["../src/humanApproval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,eAAO,MAAM,6BAA6B,2BAA2B,CAAA;AACrE,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAGtC,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,WAAW,GACpB,iBAAiB,GAAG,IAAI,CAY1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGnE;AAED,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAA;AAE3E,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAI1E;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IACjC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,KAAK,EAAE,MAAM,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,eAAe,GAClB,OAAO,CAAC,WAAW,CAAC,CA6BtB"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Waiting for the user's approval of an agent's outbound action (#66416).
3
+ *
4
+ * When an agent-held token (a Genspark sandbox, an OpenClaw VM) sends outside
5
+ * the user's organization, `--yes` does not count: the server parks the call
6
+ * and answers `status: "pending_human_approval"` with an `approval_id`. Only
7
+ * the user can decide, in Genspark (the CLI has no way to approve). This
8
+ * module waits a bounded time for that decision, polling the read-only
9
+ * `GET /agent_approvals/<id>`, and re-issues the identical call once the user
10
+ * has decided — the server then sends it (approved) or reports the decline.
11
+ * Out of budget, the original envelope is printed as-is: it tells the agent
12
+ * to re-run the same command after the user approves.
13
+ *
14
+ * Decisions are pure functions; the loop takes its I/O as parameters. All
15
+ * progress goes to stderr; the caller prints exactly one envelope.
16
+ */
17
+ export const STATUS_PENDING_HUMAN_APPROVAL = 'pending_human_approval';
18
+ export const DEFAULT_WAIT_SECONDS = 90;
19
+ const POLL_INTERVAL_MS = 3000;
20
+ /** The approval a parked call waits for, or null for any other envelope. */
21
+ export function extractHumanApproval(envelope) {
22
+ const data = envelope.data;
23
+ if (!data || typeof data !== 'object' || Array.isArray(data))
24
+ return null;
25
+ const record = data;
26
+ if (record.status !== STATUS_PENDING_HUMAN_APPROVAL)
27
+ return null;
28
+ const id = record.approval_id;
29
+ if (typeof id !== 'string' || id.length === 0)
30
+ return null;
31
+ return {
32
+ id,
33
+ expiresAt: typeof record.expires_at === 'number' ? record.expires_at : undefined,
34
+ };
35
+ }
36
+ /**
37
+ * Seconds to wait: `GSK_APPROVAL_WAIT_SECONDS` when it is a non-negative
38
+ * integer (0 = do not wait), else the default — short enough to fit an agent
39
+ * shell's command timeout.
40
+ */
41
+ export function approvalWaitSeconds(raw) {
42
+ if (raw !== undefined && /^\d+$/.test(raw.trim()))
43
+ return Number(raw.trim());
44
+ return DEFAULT_WAIT_SECONDS;
45
+ }
46
+ /** Whether to keep polling (`pending`) or re-issue the call (a decision). */
47
+ export function nextApprovalStep(state) {
48
+ if (state === 'pending')
49
+ return 'poll';
50
+ if (state === 'approved' || state === 'rejected')
51
+ return 'rerun';
52
+ return 'stop';
53
+ }
54
+ /**
55
+ * Wait for the user's decision on `approval`, then re-issue the call once.
56
+ * Returns the envelope to print: the re-issued call's, or `original` when
57
+ * the budget ran out, the request expired, or polling failed.
58
+ */
59
+ export async function waitForHumanApproval(original, approval, budgetSeconds, io) {
60
+ if (budgetSeconds <= 0)
61
+ return original;
62
+ io.notify('Waiting for the user to approve this action in Genspark (it reaches people outside their organization)...');
63
+ const deadline = io.nowMs() + budgetSeconds * 1000;
64
+ while (io.nowMs() < deadline) {
65
+ await io.sleep(Math.min(POLL_INTERVAL_MS, deadline - io.nowMs()));
66
+ let state;
67
+ try {
68
+ state = await io.pollState();
69
+ }
70
+ catch {
71
+ return original;
72
+ }
73
+ const step = nextApprovalStep(state);
74
+ if (step === 'rerun') {
75
+ io.notify(state === 'approved'
76
+ ? 'Approved in Genspark; sending.'
77
+ : 'Declined in Genspark.');
78
+ return io.rerun();
79
+ }
80
+ if (step === 'stop')
81
+ return original;
82
+ }
83
+ io.notify('No decision yet. Ask the user to approve it in Genspark, then run the identical command again.');
84
+ return original;
85
+ }
86
+ //# sourceMappingURL=humanApproval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"humanApproval.js","sourceRoot":"","sources":["../src/humanApproval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,MAAM,CAAC,MAAM,6BAA6B,GAAG,wBAAwB,CAAA;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AACtC,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAO7B,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,QAAqB;IAErB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;IAC1B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACzE,MAAM,MAAM,GAAG,IAA+B,CAAA;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,6BAA6B;QAAE,OAAO,IAAI,CAAA;IAChE,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAA;IAC7B,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC1D,OAAO;QACL,EAAE;QACF,SAAS,EACP,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACxE,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAuB;IACzD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5E,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAID,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IACtC,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,UAAU;QAAE,OAAO,OAAO,CAAA;IAChE,OAAO,MAAM,CAAA;AACf,CAAC;AAUD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAqB,EACrB,QAA2B,EAC3B,aAAqB,EACrB,EAAmB;IAEnB,IAAI,aAAa,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAA;IACvC,EAAE,CAAC,MAAM,CACP,2GAA2G,CAC5G,CAAA;IACD,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,aAAa,GAAG,IAAI,CAAA;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7B,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACjE,IAAI,KAAc,CAAA;QAClB,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,EAAE,CAAC,SAAS,EAAE,CAAA;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,EAAE,CAAC,MAAM,CACP,KAAK,KAAK,UAAU;gBAClB,CAAC,CAAC,gCAAgC;gBAClC,CAAC,CAAC,uBAAuB,CAC5B,CAAA;YACD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,IAAI,KAAK,MAAM;YAAE,OAAO,QAAQ,CAAA;IACtC,CAAC;IACD,EAAE,CAAC,MAAM,CACP,gGAAgG,CACjG,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import { resolveProjectSelection } from './project-binding.js';
24
24
  import { registerDeveloperCommands } from './commands/developer-project.js';
25
25
  import { addBrainEvidenceOptions, attachBrainEvidence, checkEvidenceDestination, saveBrainEvidence, } from './commands/brain-evidence.js';
26
26
  import { registerBrainEvidenceCommand } from './commands/brain-evidence-reader.js';
27
- import { followTaskStatus, parseWaitSeconds, } from './commands/task-status-follow.js';
27
+ import { followTaskStatus, parseWaitSeconds, settleTerminalState, } from './commands/task-status-follow.js';
28
28
  import { localCommandRoute } from './commands/local-command-routing.js';
29
29
  import { localServiceUrl, parseLocalPort } from './commands/local-preview.js';
30
30
  import { registerHostedLocalCommand } from './commands/hosted-local.js';
@@ -41,13 +41,14 @@ import { tokenPassHeaders } from './native-waf.js';
41
41
  import { classifyFileArg, awaitLocalFileReady, decideAfterWait, localFileNotReadyError, passthroughWarning, urlsParamItems, } from './localFiles.js';
42
42
  import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, progress, } from './logger.js';
43
43
  import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
44
+ import { approvalWaitSeconds, extractHumanApproval, waitForHumanApproval, } from './humanApproval.js';
44
45
  import { isPendingConfirmationEnvelope, LEGACY_SKIP_PARAMS, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
45
46
  import { repairJsonArrayArgs } from './arrayArgs.js';
46
47
  import { parseJsonObjectArgs } from './object-args.js';
47
48
  import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, resolveCredentialPair, resolveSbRuntimeCredential, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
48
49
  import { checkForUpdates } from './updater.js';
49
50
  import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
50
- import { shimLegacyTaskInvocation } from './task-shim.js';
51
+ import { legacyTaskInvokedAs, shimLegacyTaskInvocation } from './task-shim.js';
51
52
  import { getSandboxRuntime } from './runtime.js';
52
53
  import { registerDesignCommand } from './commands/design.js';
53
54
  import { collectUploadFiles, aidriveUploadHeaders, buildAidriveUploadQuery, mergeShareIntoUpload, normalizeUploadDestination, resolveAidriveUploadOperands, shareArgsFromUpload, uploadConflictFromCli, uploadConflictProblem, uploadPathForDestination, uploadShareRefusal, } from './commands/aidrive-upload.js';
@@ -56,12 +57,17 @@ import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl,
56
57
  import { fileNameFromContentDisposition, genteamAttachmentEndpoint, resolveGenteamDownloadDestination, saveBodyToFile, } from './commands/genteam-download.js';
57
58
  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';
58
59
  import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
60
+ import { registerTtsCommand } from './commands/tts-stream.js';
59
61
  import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJsonIfExists, resolvePiAgentDir, writeJsonFile, } from './commands/pi-config.js';
60
62
  import { mediaItemsKeyFor, mediaProgressLines, mediaSummaryLines, } from './mediaSummary.js';
61
63
  import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
62
64
  import { executeCloneUrl, normalizeCloneUrlForGit, } from './commands/sb-git-clone.js';
63
- import { afterSessionCall, bindSession, defaultTemplate, resolveSessionKey, SANDBOX_ACTIONS, SessionError, SessionStore, SESSION_ENV, } from './commands/sb-box-session.js';
65
+ import { afterSessionCall, bindSession, resolveSessionKey, SANDBOX_ACTIONS, SessionError, SessionStore, SESSION_ENV, } from './commands/sb-box-session.js';
64
66
  import { actionScopedDescription, serviceActionViews, } from './serviceActions.js';
67
+ // Set at startup when the pre-tree `gsk task <type>` shim rewrote argv:
68
+ // the label the caller's form maps to, sent as X-GSK-Invoked-As on the
69
+ // resulting task-create request so the server can count the shim path.
70
+ let legacyTaskInvocation;
65
71
  const require = createRequire(import.meta.url);
66
72
  const { version: VERSION } = require('../package.json');
67
73
  const DEFAULT_BASE_URL = 'https://www.genspark.ai';
@@ -599,7 +605,8 @@ async function downloadToFile(url, savePath, client) {
599
605
  downloadUrl = result.data.download_url;
600
606
  }
601
607
  const { developerInputDownload } = await import('./commands/developer-input.js');
602
- const download = developerInputDownload(downloadUrl, getGlobalOptions().baseUrl, getGlobalOptions().apiKey || '');
608
+ const { baseUrl, apiKey, projectId } = getGlobalOptions();
609
+ const download = developerInputDownload(downloadUrl, baseUrl, apiKey || '', projectId);
603
610
  const resp = await fetch(download.url, download.init);
604
611
  if (!resp.ok)
605
612
  throw new Error(`Download failed: HTTP ${resp.status}`);
@@ -1290,12 +1297,13 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1290
1297
  if (tool.name === 'create_task' && opts.acp) {
1291
1298
  const taskType = primaryArgValue;
1292
1299
  if (!taskType) {
1293
- logError('Task type is required for ACP mode. Usage: gsk task <type> --acp');
1300
+ logError('Task type is required for ACP mode. ' +
1301
+ 'Usage: gsk task create <type> --acp');
1294
1302
  process.exit(1);
1295
1303
  }
1296
1304
  delete opts.acp;
1297
1305
  const { startAcpBridge } = await import('./acp-serve.js');
1298
- await startAcpBridge(taskType, clientFactory().getOptions());
1306
+ await startAcpBridge(taskType, clientFactory().getOptions(), legacyTaskInvocation);
1299
1307
  return;
1300
1308
  }
1301
1309
  // For create_task (non-ACP): validate required params manually.
@@ -1323,11 +1331,17 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1323
1331
  client.setInvokedAs(`${legacyName} (legacy)`);
1324
1332
  }
1325
1333
  else {
1326
- client.setInvokedAs(tool.cli.path && tool.cli.path.length >= 2
1334
+ const canonicalForm = tool.cli.path && tool.cli.path.length >= 2
1327
1335
  ? tool.cli.path.join(' ')
1328
1336
  : tool.cli.group
1329
1337
  ? `${tool.cli.group} ${cmdName}`
1330
- : cmdName);
1338
+ : cmdName;
1339
+ // A `task create` the pre-tree shim produced is tagged with the
1340
+ // form the caller typed, so the deprecation telemetry counts the
1341
+ // shim path (#49618).
1342
+ client.setInvokedAs(canonicalForm === 'task create' && legacyTaskInvocation
1343
+ ? legacyTaskInvocation
1344
+ : canonicalForm);
1331
1345
  }
1332
1346
  // Extract and remove client-side-only options before sending to API
1333
1347
  const outputFilePath = opts.outputFile;
@@ -2204,20 +2218,13 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2204
2218
  else if (key && SANDBOX_ACTIONS.has(action) && !hasSandboxId) {
2205
2219
  sbBoxSession = key;
2206
2220
  }
2207
- // create without --template: newest ready public base (CLI-side).
2221
+ // create without --template: the server picks the public `base`
2222
+ // of the placement lever's region (gen-spark#79863) — never a
2223
+ // client-side "newest catalog row" that ignores the region.
2208
2224
  if (action === 'create' &&
2209
2225
  !(typeof args.template === 'string' && args.template.trim())) {
2210
- try {
2211
- args.template = await defaultTemplate(callArgs => client.executeTool('sb-box', callArgs));
2212
- info(`create: no --template given, using the public base ${args.template}`);
2213
- }
2214
- catch (err) {
2215
- if (err instanceof SessionError) {
2216
- sessionErrorEnvelope(err);
2217
- return;
2218
- }
2219
- throw err;
2220
- }
2226
+ delete args.template;
2227
+ info('create: no --template given, using the public base of the default region');
2221
2228
  }
2222
2229
  if (sbBoxSession) {
2223
2230
  sbBoxStore = SessionStore.forConfig(getConfigPath(), getGlobalOptions().baseUrl);
@@ -2289,6 +2296,11 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2289
2296
  return pollClient.executeTool(tool.name, resolvedArgs);
2290
2297
  }, Math.max(0, waitSeconds - (performance.now() - statusWaitStarted) / 1000), info);
2291
2298
  }
2299
+ else if (tool.name === 'task_status') {
2300
+ // One exit contract for both read shapes: a plain status read of
2301
+ // a canceled / failed run exits non-zero exactly like --follow.
2302
+ result = settleTerminalState(result);
2303
+ }
2292
2304
  if (saveEvidencePath) {
2293
2305
  result = await saveBrainEvidence(saveEvidencePath, result);
2294
2306
  }
@@ -2325,6 +2337,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
2325
2337
  },
2326
2338
  };
2327
2339
  }
2340
+ // An agent-held token's send outside the org waits for the user's
2341
+ // approval in Genspark (#66416): wait a bounded time, then re-issue
2342
+ // the identical call once they decided.
2343
+ const humanApproval = extractHumanApproval(result);
2344
+ if (humanApproval) {
2345
+ result = await waitForHumanApproval(result, humanApproval, approvalWaitSeconds(process.env.GSK_APPROVAL_WAIT_SECONDS), {
2346
+ pollState: () => client.getAgentApprovalState(humanApproval.id),
2347
+ rerun: () => client.executeTool(tool.name, resolvedArgs),
2348
+ notify: info,
2349
+ sleep: ms => new Promise(resolve => setTimeout(resolve, ms)),
2350
+ nowMs: () => Date.now(),
2351
+ });
2352
+ }
2328
2353
  // Fail-safe: with the interactive-confirm contract active the
2329
2354
  // server should never pend — a pending envelope means the cached
2330
2355
  // schema predates this action's confirmation flag, so no prompt
@@ -2708,7 +2733,8 @@ program
2708
2733
  // If save path specified, download using the already-fetched URL
2709
2734
  if (opts.save) {
2710
2735
  const { developerInputDownload } = await import('./commands/developer-input.js');
2711
- const download = developerInputDownload(result.data.download_url, getGlobalOptions().baseUrl, getGlobalOptions().apiKey || '');
2736
+ const { baseUrl, apiKey, projectId } = getGlobalOptions();
2737
+ const download = developerInputDownload(result.data.download_url, baseUrl, apiKey || '', projectId);
2712
2738
  let sizeBytes;
2713
2739
  try {
2714
2740
  const resp = await fetch(download.url, download.init);
@@ -3043,6 +3069,7 @@ program
3043
3069
  fs.copyFileSync(srcPath, destPath);
3044
3070
  }
3045
3071
  }
3072
+ await _syncGatedSkills(cliDir, destDir);
3046
3073
  const skillDirs = fs
3047
3074
  .readdirSync(destDir)
3048
3075
  .filter(d => fs.statSync(pathModule.join(destDir, d)).isDirectory());
@@ -3128,6 +3155,56 @@ program
3128
3155
  process.exit(1);
3129
3156
  }
3130
3157
  });
3158
+ /**
3159
+ * Skills for gatekeeper-gated command groups, keyed by the group the server
3160
+ * must list for the caller. They ship in `gated-skills/`, outside the
3161
+ * `skills/` tree that other installers (OpenClaw VM cron, sandbox mirrors)
3162
+ * copy wholesale, and only `init-skills` hands them out.
3163
+ */
3164
+ const GATED_SKILLS = {
3165
+ // GenDesk issues (gk_gendesk_issue_cli). The doc tells the agent that
3166
+ // "my issues" means GenDesk, which is wrong for anyone without it.
3167
+ 'gsk-issue': 'issue',
3168
+ // Microsoft 365 managed apps from GenCode (gk_m365_managed_apps): the
3169
+ // workflow, Microsoft's vendored plugin docs and the connector installer.
3170
+ 'gsk-m365-apps': 'm365',
3171
+ };
3172
+ /**
3173
+ * Copy each gated skill the caller may use and remove an earlier copy of one
3174
+ * they may not. The server omits gated tools from the manifest, so a group
3175
+ * is listed exactly when the gate admits the caller. Only a fresh manifest
3176
+ * decides either way: the tools cache can lag a gate flip by a day, so
3177
+ * without one (no API key, failed fetch) nothing is copied or removed.
3178
+ */
3179
+ async function _syncGatedSkills(cliDir, destDir) {
3180
+ const globalOpts = getGlobalOptions();
3181
+ if (!globalOpts.apiKey)
3182
+ return;
3183
+ let groups;
3184
+ try {
3185
+ const { tools } = await new ApiClient(globalOpts).listTools();
3186
+ groups = new Set(tools.map(tool => tool.cli?.group).filter((g) => !!g));
3187
+ }
3188
+ catch {
3189
+ debug('Could not fetch the tool list; gated skills left as they are');
3190
+ return;
3191
+ }
3192
+ const gatedDir = pathModule.join(cliDir, 'gated-skills');
3193
+ for (const [skill, group] of Object.entries(GATED_SKILLS)) {
3194
+ const srcPath = pathModule.join(gatedDir, skill);
3195
+ const destPath = pathModule.join(destDir, skill);
3196
+ if (groups.has(group)) {
3197
+ if (fs.existsSync(srcPath))
3198
+ _copyDirRecursive(srcPath, destPath);
3199
+ continue;
3200
+ }
3201
+ const skillMd = pathModule.join(destPath, 'SKILL.md');
3202
+ if (fs.existsSync(skillMd) &&
3203
+ fs.readFileSync(skillMd, 'utf-8').startsWith(`---\nname: ${skill}\n`)) {
3204
+ fs.rmSync(destPath, { recursive: true, force: true });
3205
+ }
3206
+ }
3207
+ }
3131
3208
  /** Recursively copy a directory */
3132
3209
  function _copyDirRecursive(src, dest) {
3133
3210
  fs.mkdirSync(dest, { recursive: true });
@@ -3269,7 +3346,33 @@ ${skillList}
3269
3346
  fs.writeFileSync(contextPath, content);
3270
3347
  return true;
3271
3348
  }
3349
+ const PHONE_CALL_CONTACT_FLAGS = ['phone_number', 'contact_ref', 'contact_info'];
3350
+ const PHONE_CALL_CONTACT_USAGE = 'pass exactly one contact: --phone_number <number with country code> or ' +
3351
+ '--contact_ref <calllog: contact_ref | self>';
3352
+ // The contact field to send, named as the server expects it. Exits before
3353
+ // any request on a conflict or an absent contact; the deprecated alias is
3354
+ // forwarded as-is (the server classifies it by shape) with a warning.
3355
+ function phoneCallContactField(opts) {
3356
+ const given = PHONE_CALL_CONTACT_FLAGS.filter(flag => typeof opts[flag] === 'string' && opts[flag] !== '');
3357
+ if (given.length === 0) {
3358
+ logError(`A contact is required: ${PHONE_CALL_CONTACT_USAGE}`);
3359
+ process.exit(1);
3360
+ }
3361
+ if (given.length > 1) {
3362
+ logError(`Conflicting contact flags (${given.map(flag => `--${flag}`).join(', ')}): ` +
3363
+ PHONE_CALL_CONTACT_USAGE);
3364
+ process.exit(1);
3365
+ }
3366
+ const flag = given[0];
3367
+ if (flag === 'contact_info') {
3368
+ console.error('[DEPRECATED] --contact_info still works but is deprecated — use ' +
3369
+ '--phone_number for a phone number, or --contact_ref for a calllog: ' +
3370
+ 'contact_ref / self.');
3371
+ }
3372
+ return { [flag]: opts[flag] };
3373
+ }
3272
3374
  async function phoneCallAction(recipient, opts, invokedAs) {
3375
+ const contact = phoneCallContactField(opts);
3273
3376
  try {
3274
3377
  const client = createClient();
3275
3378
  client.setInvokedAs(invokedAs);
@@ -3282,7 +3385,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3282
3385
  info('Dry run: validating prerequisites, contact and from_number...');
3283
3386
  const result = await client.requestStreaming('/phone_call/initiate', {
3284
3387
  recipient,
3285
- contact_info: opts.contact_info,
3388
+ ...contact,
3286
3389
  purpose: opts.purpose,
3287
3390
  mode: 'dry_run',
3288
3391
  from_number: opts.from_number,
@@ -3293,7 +3396,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3293
3396
  if (contact) {
3294
3397
  info('Contact resolved:');
3295
3398
  info(` Name: ${contact.title || recipient}`);
3296
- info(` Phone: ${contact.phone || '(from place_id)'}`);
3399
+ info(` Phone: ${contact.phone || '(unknown)'}`);
3297
3400
  if (contact.address)
3298
3401
  info(` Address: ${contact.address}`);
3299
3402
  }
@@ -3314,7 +3417,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3314
3417
  info('Dry run: validating prerequisites and resolving contact info...');
3315
3418
  const result = await client.executeTool('phone_call', {
3316
3419
  recipient,
3317
- contact_info: opts.contact_info,
3420
+ ...contact,
3318
3421
  purpose: opts.purpose,
3319
3422
  });
3320
3423
  if (result.status === 'ok' && result.session_state) {
@@ -3325,7 +3428,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3325
3428
  info('');
3326
3429
  info('=== Contact Resolved ===');
3327
3430
  info(` Name: ${c.title || recipient}`);
3328
- info(` Phone: ${c.phone || '(from place_id)'}`);
3431
+ info(` Phone: ${c.phone || '(unknown)'}`);
3329
3432
  if (c.address)
3330
3433
  info(` Address: ${c.address}`);
3331
3434
  if (c.rating)
@@ -3344,7 +3447,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3344
3447
  info('');
3345
3448
  const result = await client.requestStreaming('/phone_call/initiate', {
3346
3449
  recipient,
3347
- contact_info: opts.contact_info,
3450
+ ...contact,
3348
3451
  purpose: opts.purpose,
3349
3452
  mode: opts.async ? 'async' : 'sync',
3350
3453
  ...(opts.from_number ? { from_number: opts.from_number } : {}),
@@ -3356,7 +3459,7 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3356
3459
  if (contact) {
3357
3460
  info('Contact resolved:');
3358
3461
  info(` Name: ${contact.title || recipient}`);
3359
- info(` Phone: ${contact.phone || '(from place_id)'}`);
3462
+ info(` Phone: ${contact.phone || '(unknown)'}`);
3360
3463
  if (contact.address)
3361
3464
  info(` Address: ${contact.address}`);
3362
3465
  }
@@ -3393,8 +3496,9 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3393
3496
  info(isFailure ? '=== Call Failed ===' : '=== Call Complete ===');
3394
3497
  info(` Recipient: ${data.recipient || recipient}`);
3395
3498
  info(` Status: ${callStatus}`);
3396
- // duration_seconds is the real audio duration when the step recorded
3397
- // one (request wall-clock only as legacy fallback; see request_seconds).
3499
+ // duration_seconds is the real audio duration and is absent when no
3500
+ // call was placed (purpose rejected, pre-dial failure) — the request
3501
+ // wall-clock lives in request_seconds and is never printed as Duration.
3398
3502
  // 0.0 is a legitimate value (callee never reached) — check the type, or
3399
3503
  // JS falsiness hides the line exactly when the truthful zero matters.
3400
3504
  if (typeof data.duration_seconds === 'number')
@@ -3429,12 +3533,17 @@ async function phoneCallAction(recipient, opts, invokedAs) {
3429
3533
  function addPhoneCallOptions(cmd) {
3430
3534
  return cmd
3431
3535
  .argument('<recipient>', 'Name of the person or business to call')
3432
- .requiredOption('-c, --contact_info <value>', 'Phone number (e.g. +1-555-123-4567), calllog: contact_ref, or Google ' +
3433
- 'Maps place_id — the type is detected automatically')
3536
+ .option('-n, --phone_number <value>', 'Phone number in E.164 (+<country calling code><national number>; ' +
3537
+ 'a number without + and its country calling code is refused); ' +
3538
+ 'exactly one of --phone_number / --contact_ref')
3539
+ .option('-r, --contact_ref <value>', 'A calllog: contact_ref from `gsk telephony call log --view contacts`, ' +
3540
+ 'or `self` (your own verified number); exactly one of ' +
3541
+ '--phone_number / --contact_ref')
3542
+ .addOption(new Option('-c, --contact_info <value>', 'Deprecated: use --phone_number or --contact_ref').hideHelp())
3434
3543
  .requiredOption('-p, --purpose <value>', "Purpose of the call (e.g. 'Check reservation availability')")
3435
3544
  .option('--dry-run', 'Only validate and resolve contact info (and --from_number when ' +
3436
3545
  'given), do not initiate the call')
3437
- .option('--async', 'Return right after dialing starts; poll with `gsk telephony call status`, stop with `gsk telephony call hangup`')
3546
+ .option('--async', 'Return as soon as the call is dispatched, before the purpose review and the dial (call_status preparing); poll with `gsk telephony call status`, stop with `gsk telephony call hangup`')
3438
3547
  .option('--from_number <value>', 'Dial from this number (strict E.164, e.g. +14155550123) — one of ' +
3439
3548
  'your verified caller IDs or active purchased numbers');
3440
3549
  }
@@ -3449,9 +3558,9 @@ const telephonyCmd = program
3449
3558
  const telephonyCallCmd = telephonyCmd
3450
3559
  .command('call')
3451
3560
  .description('Make an AI phone call on your behalf, and inspect or control your calls (see subcommands).')
3452
- .addHelpText('after', '\nDialing is the default subcommand: `gsk telephony call <recipient> -c <number> -p <purpose>`.\n' +
3561
+ .addHelpText('after', '\nDialing is the default subcommand: `gsk telephony call <recipient> -n <number> -p <purpose>`.\n' +
3453
3562
  'If the recipient name collides with a subcommand word (status, log, ...), use the explicit form:\n' +
3454
- ' gsk telephony call dial <recipient> -c <number> -p <purpose>\n');
3563
+ ' gsk telephony call dial <recipient> -n <number> -p <purpose>\n');
3455
3564
  addPhoneCallOptions(telephonyCallCmd
3456
3565
  .command('dial', { isDefault: true })
3457
3566
  .description('Make an AI phone call on your behalf. Validates prerequisites, resolves contact info, and initiates the call. (default subcommand)')).action((recipient, opts) => phoneCallAction(recipient, opts, 'telephony call dial'));
@@ -3466,7 +3575,7 @@ const phoneCallCmd = program
3466
3575
  .alias('call-for-me')
3467
3576
  .description('[deprecated: use `gsk telephony call`] Make an AI phone call on your behalf, and inspect or control your calls (see subcommands).')
3468
3577
  .addHelpText('after', '\nDeprecated: use `gsk telephony call` instead.\n' +
3469
- 'Dialing is the default subcommand: `gsk phone-call <recipient> -c <number> -p <purpose>`.\n');
3578
+ 'Dialing is the default subcommand: `gsk phone-call <recipient> -n <number> -p <purpose>`.\n');
3470
3579
  addPhoneCallOptions(phoneCallCmd
3471
3580
  .command('dial', { isDefault: true })
3472
3581
  .description('[deprecated: use `gsk telephony call dial`] Make an AI phone call on your behalf. (default subcommand)')).action((recipient, opts) => {
@@ -3476,6 +3585,21 @@ addPhoneCallOptions(phoneCallCmd
3476
3585
  // Seed the dynamic-group map so server-registered phone-call tools become
3477
3586
  // subcommands of this static parent instead of a duplicate top-level group.
3478
3587
  _groupCommands.set('phone-call', phoneCallCmd);
3588
+ // Realtime streaming TTS (`gsk tts stream` / `gsk tts models`). Static: the
3589
+ // audio is raw bytes piped to stdout or a file as it is synthesized, which
3590
+ // the generic NDJSON tool handler cannot carry. Seeded into _groupCommands so
3591
+ // a future server-registered `tts` verb attaches here instead of colliding.
3592
+ _groupCommands.set('tts', registerTtsCommand(program, () => {
3593
+ const client = createClient();
3594
+ return {
3595
+ postStream: (endpoint, body) => client.postBinaryStream(endpoint, body),
3596
+ getModels: () => client.getJson('/tts/models'),
3597
+ output,
3598
+ progress,
3599
+ logError,
3600
+ exit: (code) => process.exit(code),
3601
+ };
3602
+ }));
3479
3603
  // The task command tree. Verbs are server-registered (create / status /
3480
3604
  // info / ask / answer / messages / wait / stop / delete / rename attach as
3481
3605
  // dynamic subcommands via the seeded group); this static parent gives the
@@ -3670,9 +3794,11 @@ async function main() {
3670
3794
  return;
3671
3795
  }
3672
3796
  // Pre-tree `gsk task <type>` compat (see shimLegacyTaskInvocation).
3797
+ const rawArgs = process.argv.slice(2);
3798
+ legacyTaskInvocation = legacyTaskInvokedAs(rawArgs);
3673
3799
  process.argv = [
3674
3800
  ...process.argv.slice(0, 2),
3675
- ...shimLegacyTaskInvocation(process.argv.slice(2)),
3801
+ ...shimLegacyTaskInvocation(rawArgs),
3676
3802
  ];
3677
3803
  // `gsk mesh ...` is a native-binary passthrough — intercept it before the
3678
3804
  // tool-fetch path and npm self-update gating (it needs neither). Handling it
@@ -3777,7 +3903,13 @@ async function main() {
3777
3903
  're-authenticate.');
3778
3904
  }
3779
3905
  else {
3780
- debug(`Failed to fetch tools: ${err.message}`);
3906
+ // Just as loud as the auth case: a script's log otherwise shows
3907
+ // only "unknown command" for every server-provided command.
3908
+ warn(`Could not load the server command list (${err.message}) — ` +
3909
+ (staleFallbackTools
3910
+ ? 'using the previously cached commands.'
3911
+ : 'server-provided commands were NOT loaded; only built-in ' +
3912
+ 'commands work. Retry, or run with --refresh --debug.'));
3781
3913
  }
3782
3914
  // Continue without dynamic commands - built-in commands still work
3783
3915
  }