@genspark/cli 1.8.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/client.js +3 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +14 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +46 -3
- package/dist/config.js.map +1 -1
- package/dist/confirm.d.ts +121 -0
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +207 -0
- package/dist/confirm.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +75 -19
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/confirmation.md +49 -0
- package/docs/skills.md +2 -2
- package/package.json +1 -1
- package/skills/gsk-aidrive/SKILL.md +9 -5
- package/skills/gsk-gmail/SKILL.md +12 -8
- package/skills/gsk-outlook-email/SKILL.md +18 -11
- package/skills/gsk-shared/SKILL.md +2 -0
- package/skills/gsk-slack/SKILL.md +7 -9
- package/skills/gsk-task-status/SKILL.md +1 -0
- package/skills/gsk-youtube/SKILL.md +3 -3
package/dist/confirm.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-call confirmation for confirmation-required tool actions.
|
|
3
|
+
*
|
|
4
|
+
* The server annotates confirmation-required tools/actions in the /tools
|
|
5
|
+
* schema (`requires_confirmation`, plus `interactive_only` for actions whose
|
|
6
|
+
* skip parameters are schema-locked, e.g. slack send) and advertises
|
|
7
|
+
* `features.interactive_confirm` when the caller's caps AND the server-side
|
|
8
|
+
* gatekeeper agree. When both hold, the CLI resolves the confirmation
|
|
9
|
+
* BEFORE the single server call — `[y/N]` on stdin/stderr or `--yes` — and
|
|
10
|
+
* injects `cli_confirmed: true`, which the server translates into direct
|
|
11
|
+
* execution. A decline means ZERO server calls. No replay, no second call:
|
|
12
|
+
* the old pending/double-call contract only remains as the server-side
|
|
13
|
+
* fail-safe for a stale schema cache (see isPendingConfirmationEnvelope).
|
|
14
|
+
*
|
|
15
|
+
* Like pendingApproval.ts, every decision is a pure, unit-testable
|
|
16
|
+
* function; the readline shell at the bottom is the only impure part. The
|
|
17
|
+
* prompt reads stdin (NOT /dev/tty) so `echo y | gsk ...` and agents
|
|
18
|
+
* feeding a background process work; EOF defaults to decline.
|
|
19
|
+
*/
|
|
20
|
+
export const STALE_SCHEMA_CACHE_MESSAGE = "schema cache stale, run 'gsk --refresh ls' and retry";
|
|
21
|
+
const INTERACTIVE_ONLY_WARNING = 'This action requires interactive confirmation (marketplace policy) — ' +
|
|
22
|
+
'--yes / skip_confirmation are ignored.';
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the static confirmation annotation for one invocation: service
|
|
25
|
+
* tools carry it per action (`tool.actions[args.action]`), single-action
|
|
26
|
+
* tools on `tool.cli`. Reads the merged args (not the positional) because
|
|
27
|
+
* the action may arrive via --args-file.
|
|
28
|
+
*/
|
|
29
|
+
export function confirmationFlagsFor(tool, args) {
|
|
30
|
+
const action = typeof args.action === 'string' ? args.action : undefined;
|
|
31
|
+
const actionInfo = action && tool.actions ? tool.actions[action] : undefined;
|
|
32
|
+
const source = actionInfo ?? tool.cli;
|
|
33
|
+
const requiresConfirmation = source?.requires_confirmation === true;
|
|
34
|
+
return {
|
|
35
|
+
requiresConfirmation,
|
|
36
|
+
interactiveOnly: requiresConfirmation && source?.interactive_only === true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The confirmation state machine, pre-prompt half:
|
|
41
|
+
*
|
|
42
|
+
* - feature off (old server / GK off) or action not annotated → call as
|
|
43
|
+
* today, no cli_confirmed;
|
|
44
|
+
* - explicit skip_confirmation/auto_skip_confirmation arg on a normal
|
|
45
|
+
* action → call as today, no prompt, no cli_confirmed (the server
|
|
46
|
+
* honors the skip param directly for CLI callers — existing unattended
|
|
47
|
+
* scripts keep working);
|
|
48
|
+
* - --yes on a normal action → call with cli_confirmed, no prompt;
|
|
49
|
+
* - --yes or a skip param on an interactive-only action → warn, fall into
|
|
50
|
+
* the prompt (the server strips locked skip params anyway);
|
|
51
|
+
* - no usable stdin (--no-input, or --args-file -) → exit 2, zero calls;
|
|
52
|
+
* - otherwise → prompt.
|
|
53
|
+
*/
|
|
54
|
+
export function decideConfirmation(flags, ctx) {
|
|
55
|
+
if (!ctx.featureOn || !flags.requiresConfirmation) {
|
|
56
|
+
return { kind: 'proceed', confirmed: false };
|
|
57
|
+
}
|
|
58
|
+
if (ctx.skipRequested && !flags.interactiveOnly) {
|
|
59
|
+
return { kind: 'proceed', confirmed: false };
|
|
60
|
+
}
|
|
61
|
+
if (ctx.yes && !flags.interactiveOnly) {
|
|
62
|
+
return { kind: 'proceed', confirmed: true };
|
|
63
|
+
}
|
|
64
|
+
if (ctx.noInput || ctx.stdinConsumed) {
|
|
65
|
+
const stdinReason = ctx.stdinConsumed
|
|
66
|
+
? '`--args-file -` consumes stdin, so the confirmation prompt cannot run'
|
|
67
|
+
: '--no-input disables the confirmation prompt';
|
|
68
|
+
const message = flags.interactiveOnly
|
|
69
|
+
? `This action requires interactive confirmation (marketplace ` +
|
|
70
|
+
`policy), but ${stdinReason}. Nothing was sent.`
|
|
71
|
+
: `Confirmation required, but ${stdinReason} — re-run with --yes. ` +
|
|
72
|
+
`Nothing was sent.`;
|
|
73
|
+
return { kind: 'refuse', exitCode: 2, message };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
kind: 'prompt',
|
|
77
|
+
warning: (ctx.yes || ctx.skipRequested === true) && flags.interactiveOnly
|
|
78
|
+
? INTERACTIVE_ONLY_WARNING
|
|
79
|
+
: undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Truthiness intentionally mirrors the server (Python bool()): the params
|
|
84
|
+
* carry booleans from the CLI flag parser, but --args-file JSON may hold
|
|
85
|
+
* strings/numbers — for those payload shapes JS Boolean() agrees with
|
|
86
|
+
* Python, so the CLI skips the prompt exactly when the server would honor
|
|
87
|
+
* the skip.
|
|
88
|
+
*/
|
|
89
|
+
function skipParamsRequested(args) {
|
|
90
|
+
return Boolean(args.skip_confirmation) || Boolean(args.auto_skip_confirmation);
|
|
91
|
+
}
|
|
92
|
+
// The preview embeds request-controlled text (--args-file payloads) that
|
|
93
|
+
// reaches the terminal verbatim at the consent prompt: strip C0 controls +
|
|
94
|
+
// DEL (keep TAB) so injected escapes can't rewrite what the human confirms.
|
|
95
|
+
// Same rule as pendingApproval.ts.
|
|
96
|
+
const CONTROL_CHARS = /[\u0000-\u0008\u000a-\u001f\u007f]/g;
|
|
97
|
+
function sanitize(text) {
|
|
98
|
+
return text.replace(CONTROL_CHARS, '');
|
|
99
|
+
}
|
|
100
|
+
function renderValue(key, value) {
|
|
101
|
+
// Attachments are file paths/URLs about to be uploaded — list names only,
|
|
102
|
+
// never resolve or read the files at preview time.
|
|
103
|
+
if (key === 'attachments' && Array.isArray(value)) {
|
|
104
|
+
return value
|
|
105
|
+
.map(item => typeof item === 'string' ? item.split('/').pop() || item : '(file)')
|
|
106
|
+
.join(', ');
|
|
107
|
+
}
|
|
108
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* stderr preview of exactly what the user typed (the server has not
|
|
112
|
+
* normalized anything yet — you confirm what you sent). The action is part
|
|
113
|
+
* of the prompt question, so it is skipped here.
|
|
114
|
+
*/
|
|
115
|
+
export function previewLines(args) {
|
|
116
|
+
const lines = [''];
|
|
117
|
+
for (const [key, value] of Object.entries(args)) {
|
|
118
|
+
if (value === undefined || value === null || key === 'action')
|
|
119
|
+
continue;
|
|
120
|
+
lines.push(sanitize(` ${key}: ${renderValue(key, value)}`));
|
|
121
|
+
}
|
|
122
|
+
return lines;
|
|
123
|
+
}
|
|
124
|
+
/** Prompt question naming the exact tool + action being confirmed. */
|
|
125
|
+
export function promptQuestion(tool, args) {
|
|
126
|
+
const action = typeof args.action === 'string' ? args.action : undefined;
|
|
127
|
+
const label = action ? `${tool.name} ${action}` : tool.name;
|
|
128
|
+
return `About to execute ${sanitize(label)}. Proceed? [y/N] `;
|
|
129
|
+
}
|
|
130
|
+
/** y/yes (case-insensitive) confirms; anything else — including EOF — declines. */
|
|
131
|
+
export function isConfirmedAnswer(raw) {
|
|
132
|
+
const answer = raw.trim().toLowerCase();
|
|
133
|
+
return answer === 'y' || answer === 'yes';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Full pre-call flow. Returns either "call (optionally with cli_confirmed
|
|
137
|
+
* injected)" or "abort with this exit code" — the caller must not touch the
|
|
138
|
+
* server on abort.
|
|
139
|
+
*/
|
|
140
|
+
export async function resolvePreCallConfirmation(tool, args, ctx, io) {
|
|
141
|
+
const decision = decideConfirmation(confirmationFlagsFor(tool, args), {
|
|
142
|
+
...ctx,
|
|
143
|
+
skipRequested: skipParamsRequested(args),
|
|
144
|
+
});
|
|
145
|
+
if (decision.kind === 'proceed') {
|
|
146
|
+
return { action: 'call', injectConfirmed: decision.confirmed };
|
|
147
|
+
}
|
|
148
|
+
if (decision.kind === 'refuse') {
|
|
149
|
+
return {
|
|
150
|
+
action: 'abort',
|
|
151
|
+
exitCode: decision.exitCode,
|
|
152
|
+
message: decision.message,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (decision.warning)
|
|
156
|
+
io.notify(decision.warning);
|
|
157
|
+
for (const line of previewLines(args))
|
|
158
|
+
io.notify(line);
|
|
159
|
+
const answer = await io.ask(promptQuestion(tool, args));
|
|
160
|
+
if (isConfirmedAnswer(answer)) {
|
|
161
|
+
return { action: 'call', injectConfirmed: true };
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
action: 'abort',
|
|
165
|
+
exitCode: 1,
|
|
166
|
+
message: 'Aborted, nothing was sent.',
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Fail-safe detector: with the interactive contract active the server never
|
|
171
|
+
* pends — a pending envelope means the cached schema predates this action's
|
|
172
|
+
* confirmation flag, so the CLI neither prompted nor sent cli_confirmed.
|
|
173
|
+
* The caller reports STALE_SCHEMA_CACHE_MESSAGE; there is no replay.
|
|
174
|
+
*/
|
|
175
|
+
export function isPendingConfirmationEnvelope(envelope) {
|
|
176
|
+
const data = envelope.data;
|
|
177
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
178
|
+
return false;
|
|
179
|
+
return data.status === 'pending_confirmation';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Thin readline shell around resolvePreCallConfirmation: stdin in,
|
|
183
|
+
* stderr out (NEVER stdout — it must stay one machine-parseable JSON
|
|
184
|
+
* document). EOF (stdin closed / Ctrl+D) resolves the question with '',
|
|
185
|
+
* which declines — same close-race pattern as pendingApproval.ts.
|
|
186
|
+
*/
|
|
187
|
+
export async function runPreCallConfirmation(tool, args, ctx) {
|
|
188
|
+
const io = {
|
|
189
|
+
ask: async (question) => {
|
|
190
|
+
const readline = await import('node:readline/promises');
|
|
191
|
+
const rl = readline.createInterface({
|
|
192
|
+
input: process.stdin,
|
|
193
|
+
output: process.stderr,
|
|
194
|
+
});
|
|
195
|
+
const closedAsDecline = new Promise(resolve => rl.once('close', () => resolve('')));
|
|
196
|
+
try {
|
|
197
|
+
return await Promise.race([rl.question(question), closedAsDecline]);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
rl.close();
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
notify: line => console.error(line),
|
|
204
|
+
};
|
|
205
|
+
return resolvePreCallConfirmation(tool, args, ctx, io);
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,MAAM,CAAC,M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E,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;AACxD,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;AA0SH,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
|
@@ -32,7 +32,8 @@ 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
34
|
import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
|
|
35
|
-
import {
|
|
35
|
+
import { isPendingConfirmationEnvelope, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
|
|
36
|
+
import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
|
|
36
37
|
import { checkForUpdates } from './updater.js';
|
|
37
38
|
import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
|
|
38
39
|
import { shimLegacyTaskInvocation } from './task-shim.js';
|
|
@@ -102,6 +103,8 @@ program
|
|
|
102
103
|
.option('--output <format>', 'Output format: json or text', 'json')
|
|
103
104
|
// Commander negation flag: parses into opts.input (default true).
|
|
104
105
|
.option('--no-input', 'Never prompt interactively (e.g. hosted approval y/n); print pending envelopes as-is')
|
|
106
|
+
.option('-y, --yes', 'Assume "yes" at confirmation prompts for confirmation-required ' +
|
|
107
|
+
'actions (interactive-only actions, e.g. slack send, still prompt)')
|
|
105
108
|
.option('--refresh', 'Force refresh of cached tool schemas from server')
|
|
106
109
|
.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.');
|
|
107
110
|
/**
|
|
@@ -140,6 +143,7 @@ function getGlobalOptions() {
|
|
|
140
143
|
refresh: opts.refresh || false,
|
|
141
144
|
// Commander stores the --no-input negation flag as opts.input=false.
|
|
142
145
|
noInput: opts.input === false,
|
|
146
|
+
yes: opts.yes === true,
|
|
143
147
|
};
|
|
144
148
|
}
|
|
145
149
|
function createClient() {
|
|
@@ -1058,17 +1062,32 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1058
1062
|
logError(err.message);
|
|
1059
1063
|
process.exit(1);
|
|
1060
1064
|
}
|
|
1061
|
-
// The file carries SERVER parameters only.
|
|
1062
|
-
//
|
|
1063
|
-
// client-side blocks below that never see the file —
|
|
1064
|
-
// them here would silently do nothing,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1065
|
+
// The file carries SERVER parameters only. An unknown key is a
|
|
1066
|
+
// typo, a CLI-only option (--out, --local_file, ... are processed
|
|
1067
|
+
// from flags by client-side blocks below that never see the file —
|
|
1068
|
+
// honoring them here would silently do nothing), or a parameter
|
|
1069
|
+
// this binary's cached schema doesn't know. Dropping it and
|
|
1070
|
+
// sending anyway silently alters a billable request (a dropped
|
|
1071
|
+
// video_time_range turned a "20-second clip" youtube download
|
|
1072
|
+
// into a full-video download billed per MB), so refuse the whole
|
|
1073
|
+
// invocation. The manifest cache (24h, gatekeeper-tailored per
|
|
1074
|
+
// user) may merely be stale, so bust it and let the rerun fetch a
|
|
1075
|
+
// fresh schema — an in-process refetch is deliberately not
|
|
1076
|
+
// attempted here; the retry is authoritative (the #51775 shape).
|
|
1077
|
+
const unknownKeys = Object.keys(fileArgs).filter(key => !(key in props));
|
|
1078
|
+
if (unknownKeys.length > 0) {
|
|
1079
|
+
clearToolsCache();
|
|
1080
|
+
const listed = unknownKeys.map(key => `"${key}"`).join(', ');
|
|
1081
|
+
const isAre = unknownKeys.length > 1
|
|
1082
|
+
? 'are not parameters'
|
|
1083
|
+
: 'is not a parameter';
|
|
1084
|
+
logError(`--args-file: ${listed} ${isAre} of ${tool.name}. The ` +
|
|
1085
|
+
'request was NOT sent (nothing was billed). If the ' +
|
|
1086
|
+
'parameter was recently enabled server-side, rerun the ' +
|
|
1087
|
+
'command (the tool schema cache has been refreshed); ' +
|
|
1088
|
+
'CLI-only options (--out, --local_file, ...) must be ' +
|
|
1089
|
+
'passed as flags.');
|
|
1090
|
+
process.exit(1);
|
|
1072
1091
|
}
|
|
1073
1092
|
Object.assign(args, fileArgs);
|
|
1074
1093
|
// Required params were registered optional because the file may
|
|
@@ -1105,6 +1124,31 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1105
1124
|
}
|
|
1106
1125
|
}
|
|
1107
1126
|
}
|
|
1127
|
+
// Pre-call confirmation (confirm.ts): when the cached /tools
|
|
1128
|
+
// payload advertised interactive_confirm AND the schema marks this
|
|
1129
|
+
// tool/action confirmation-required, resolve [y/N] / --yes /
|
|
1130
|
+
// --no-input right here — after the args are final (file merge +
|
|
1131
|
+
// coercion above) and BEFORE any server side effect (attachment
|
|
1132
|
+
// uploads included): a decline must leave zero server calls.
|
|
1133
|
+
// ACP mode never reaches this point (its branch returned above).
|
|
1134
|
+
const confirmFeatureOn = getCachedFeatures()?.interactive_confirm === true;
|
|
1135
|
+
{
|
|
1136
|
+
const globalOpts = getGlobalOptions();
|
|
1137
|
+
const confirmation = await runPreCallConfirmation(tool, args, {
|
|
1138
|
+
featureOn: confirmFeatureOn,
|
|
1139
|
+
yes: globalOpts.yes === true,
|
|
1140
|
+
noInput: globalOpts.noInput === true,
|
|
1141
|
+
stdinConsumed: argsFilePath === '-',
|
|
1142
|
+
});
|
|
1143
|
+
if (confirmation.action === 'abort') {
|
|
1144
|
+
logError(confirmation.message);
|
|
1145
|
+
process.exit(confirmation.exitCode);
|
|
1146
|
+
}
|
|
1147
|
+
// The server pops cli_confirmed and executes directly (it means
|
|
1148
|
+
// "the confirmation interaction happened client-side").
|
|
1149
|
+
if (confirmation.injectConfirmed)
|
|
1150
|
+
args.cli_confirmed = true;
|
|
1151
|
+
}
|
|
1108
1152
|
// aidrive: strip client-side-only options before sending to API.
|
|
1109
1153
|
// --local_file and --override are only meaningful to the CLI and must
|
|
1110
1154
|
// never be forwarded to the server (other aidrive actions like ls,
|
|
@@ -1422,6 +1466,15 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1422
1466
|
},
|
|
1423
1467
|
};
|
|
1424
1468
|
}
|
|
1469
|
+
// Fail-safe: with the interactive-confirm contract active the
|
|
1470
|
+
// server should never pend — a pending envelope means the cached
|
|
1471
|
+
// schema predates this action's confirmation flag, so no prompt
|
|
1472
|
+
// ran and no cli_confirmed was sent. No replay; the envelope is
|
|
1473
|
+
// still printed below, plus a refresh hint and a non-zero exit.
|
|
1474
|
+
if (confirmFeatureOn && isPendingConfirmationEnvelope(result)) {
|
|
1475
|
+
logError(STALE_SCHEMA_CACHE_MESSAGE);
|
|
1476
|
+
process.exitCode = 1;
|
|
1477
|
+
}
|
|
1425
1478
|
const isSbGitCloneUrl = tool.name === 'sb-git' &&
|
|
1426
1479
|
resolvedArgs.action === 'clone-url';
|
|
1427
1480
|
if (isSbGitCloneUrl &&
|
|
@@ -1750,26 +1803,29 @@ program
|
|
|
1750
1803
|
}
|
|
1751
1804
|
// If save path specified, download using the already-fetched URL
|
|
1752
1805
|
if (opts.save) {
|
|
1753
|
-
info(`Downloading to ${opts.save}...`);
|
|
1754
1806
|
const resp = await fetch(result.data.download_url);
|
|
1755
1807
|
if (!resp.ok)
|
|
1756
1808
|
throw new Error(`Download failed: HTTP ${resp.status}`);
|
|
1757
1809
|
const buffer = Buffer.from(await resp.arrayBuffer());
|
|
1758
1810
|
fs.writeFileSync(opts.save, buffer);
|
|
1759
|
-
|
|
1760
|
-
|
|
1811
|
+
// Report only what the save produced: `download_url` is the CLI's
|
|
1812
|
+
// own fetch handle (a ~400-char signed URL) and `original_url` is
|
|
1813
|
+
// the argument the caller just passed. Agents re-read every echoed
|
|
1814
|
+
// byte on every later turn, so neither is repeated here.
|
|
1761
1815
|
output({
|
|
1762
1816
|
status: 'ok',
|
|
1763
1817
|
message: 'File downloaded successfully',
|
|
1764
1818
|
data: {
|
|
1765
|
-
|
|
1766
|
-
|
|
1819
|
+
file_name: result.data.file_name,
|
|
1820
|
+
content_type: result.data.content_type,
|
|
1821
|
+
local_path: pathModule.resolve(opts.save),
|
|
1767
1822
|
size_bytes: buffer.length,
|
|
1768
1823
|
},
|
|
1769
1824
|
});
|
|
1770
1825
|
}
|
|
1771
1826
|
else {
|
|
1772
|
-
//
|
|
1827
|
+
// URL-only form: resolving a wrapper to a fetchable URL is the
|
|
1828
|
+
// purpose here, so `download_url` stays.
|
|
1773
1829
|
output(result);
|
|
1774
1830
|
}
|
|
1775
1831
|
}
|
|
@@ -2610,7 +2666,7 @@ async function main() {
|
|
|
2610
2666
|
const client = new ApiClient(globalOpts);
|
|
2611
2667
|
const result = await client.listTools();
|
|
2612
2668
|
tools = result.tools;
|
|
2613
|
-
saveToolsCache(baseUrl, tools);
|
|
2669
|
+
saveToolsCache(baseUrl, tools, result.features);
|
|
2614
2670
|
debug(`Fetched and cached ${tools.length} tools from server`);
|
|
2615
2671
|
}
|
|
2616
2672
|
catch (err) {
|