@genspark/cli 1.8.1 → 1.10.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 +39 -0
- package/dist/client.js +3 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +4 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +28 -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 +92 -27
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +12 -3
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +17 -4
- package/dist/logger.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/package.json +1 -1
- package/skills/gsk-shared/SKILL.md +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,MAAM,CAAC,MAAM,0BAA0B,GACrC,sDAAsD,CAAA;AAExD,MAAM,wBAAwB,GAC5B,uEAAuE;IACvE,wCAAwC,CAAA;AAO1C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAgB,EAChB,IAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACxE,MAAM,UAAU,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC5E,MAAM,MAAM,GAAG,UAAU,IAAI,IAAI,CAAC,GAA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GAAG,EAAE,KAAK,EAAC,QAAQ,EAAC,EAAE;YACpB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAA;YACvD,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;gBAClC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAA;YACF,MAAM,eAAe,GAAG,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE,CACpD,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CACpC,CAAA;YACD,IAAI,CAAC;gBACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC,CAAA;YACrE,CAAC;oBAAS,CAAC;gBACT,EAAE,CAAC,KAAK,EAAE,CAAA;YACZ,CAAC;QACH,CAAC;QACD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;KACpC,CAAA;IACD,OAAO,0BAA0B,CAAC,IAAI,EAAE,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;AA2SH,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
|
@@ -30,9 +30,10 @@ import { Readable } from 'stream';
|
|
|
30
30
|
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
|
-
import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, } from './logger.js';
|
|
33
|
+
import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, progress, } 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() {
|
|
@@ -340,7 +344,7 @@ async function uploadLocalFile(filePath, client) {
|
|
|
340
344
|
const ext = pathModule.extname(filePath).toLowerCase();
|
|
341
345
|
const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
342
346
|
const fileSize = fs.statSync(filePath).size;
|
|
343
|
-
|
|
347
|
+
progress(`Uploading ${fileName} (${formatFileSize(fileSize)}, ${contentType})...`);
|
|
344
348
|
const globalOpts = getGlobalOptions();
|
|
345
349
|
const uploadUrlResult = await client.getUploadUrl({
|
|
346
350
|
content_type: contentType,
|
|
@@ -354,7 +358,7 @@ async function uploadLocalFile(filePath, client) {
|
|
|
354
358
|
debug(`Upload URL: ${upload_url.substring(0, 80)}...`);
|
|
355
359
|
// Stream the file directly to Azure Blob Storage — no full-file buffering
|
|
356
360
|
await streamFileUpload(filePath, upload_url, { 'Content-Type': contentType, 'x-ms-blob-type': 'BlockBlob' }, fileSize);
|
|
357
|
-
|
|
361
|
+
progress(`Uploaded → ${file_wrapper_url}`);
|
|
358
362
|
return file_wrapper_url;
|
|
359
363
|
}
|
|
360
364
|
/**
|
|
@@ -364,12 +368,12 @@ async function uploadLocalFile(filePath, client) {
|
|
|
364
368
|
*
|
|
365
369
|
* This avoids the roundabout blob-upload + download_file two-step approach.
|
|
366
370
|
*/
|
|
367
|
-
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source) {
|
|
371
|
+
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source, onConflict) {
|
|
368
372
|
const fileName = pathModule.basename(filePath);
|
|
369
373
|
const ext = pathModule.extname(filePath).toLowerCase();
|
|
370
374
|
const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
371
375
|
const fileSize = fs.statSync(filePath).size;
|
|
372
|
-
|
|
376
|
+
progress(`Uploading ${fileName} (${formatFileSize(fileSize)}, ${contentType}) directly to AI Drive...`);
|
|
373
377
|
const globalOpts = getGlobalOptions();
|
|
374
378
|
const baseUrl = globalOpts.baseUrl.replace(/\/$/, '');
|
|
375
379
|
const uploadQuery = new URLSearchParams({
|
|
@@ -378,6 +382,8 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
378
382
|
});
|
|
379
383
|
if (override)
|
|
380
384
|
uploadQuery.set('override', 'true');
|
|
385
|
+
if (onConflict)
|
|
386
|
+
uploadQuery.set('on_conflict', onConflict);
|
|
381
387
|
if (source)
|
|
382
388
|
uploadQuery.set('source', source);
|
|
383
389
|
const uploadUrl = `${baseUrl}/api/tool_cli/aidrive/upload?${uploadQuery.toString()}`;
|
|
@@ -396,7 +402,7 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
396
402
|
}
|
|
397
403
|
}
|
|
398
404
|
async function downloadToFile(url, savePath, client) {
|
|
399
|
-
|
|
405
|
+
progress(`Downloading to ${savePath}...`);
|
|
400
406
|
let downloadUrl = url;
|
|
401
407
|
// Token-less file wrappers need `/file/download`; a signed wrapper is
|
|
402
408
|
// already fetchable and must keep its share token (important for Drive
|
|
@@ -416,7 +422,7 @@ async function downloadToFile(url, savePath, client) {
|
|
|
416
422
|
// swap-less RAM tolerates as a single buffer.
|
|
417
423
|
await pipeline(Readable.fromWeb(resp.body), fs.createWriteStream(savePath));
|
|
418
424
|
const sizeBytes = fs.statSync(savePath).size;
|
|
419
|
-
|
|
425
|
+
progress(`Downloaded ${formatFileSize(sizeBytes)} → ${savePath}`);
|
|
420
426
|
return pathModule.resolve(savePath);
|
|
421
427
|
}
|
|
422
428
|
function isLocalFilePath(value) {
|
|
@@ -476,7 +482,7 @@ function encodeAttachmentInline(filePath) {
|
|
|
476
482
|
const fileName = pathModule.basename(filePath);
|
|
477
483
|
const ext = pathModule.extname(filePath).toLowerCase();
|
|
478
484
|
const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
479
|
-
|
|
485
|
+
progress(`Attaching ${fileName} (${formatFileSize(fileSize)}, ${contentType}) inline...`);
|
|
480
486
|
return {
|
|
481
487
|
name: fileName,
|
|
482
488
|
content_type: contentType,
|
|
@@ -852,6 +858,10 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
852
858
|
'alternative to --file_content). download: local destination path ' +
|
|
853
859
|
'(same as the second operand; default ./<basename of the drive path>)');
|
|
854
860
|
cmd.option('--override', 'Overwrite an existing file at the destination path (used with --local_file)', false);
|
|
861
|
+
cmd.option('--on-conflict <mode>', 'upload: what to do when the destination name is taken — ' +
|
|
862
|
+
'error | rename | overwrite (default: rename, which lands ' +
|
|
863
|
+
'name(1).ext and reports the path actually written). Use error for ' +
|
|
864
|
+
'idempotent scripts that retry on failure.');
|
|
855
865
|
}
|
|
856
866
|
// For sb-git: `--execute [dest]` turns `clone-url` from a snippet-print
|
|
857
867
|
// into an actual `git clone`. Client-side because the backend `clone-url`
|
|
@@ -1120,13 +1130,40 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1120
1130
|
}
|
|
1121
1131
|
}
|
|
1122
1132
|
}
|
|
1133
|
+
// Pre-call confirmation (confirm.ts): when the cached /tools
|
|
1134
|
+
// payload advertised interactive_confirm AND the schema marks this
|
|
1135
|
+
// tool/action confirmation-required, resolve [y/N] / --yes /
|
|
1136
|
+
// --no-input right here — after the args are final (file merge +
|
|
1137
|
+
// coercion above) and BEFORE any server side effect (attachment
|
|
1138
|
+
// uploads included): a decline must leave zero server calls.
|
|
1139
|
+
// ACP mode never reaches this point (its branch returned above).
|
|
1140
|
+
const confirmFeatureOn = getCachedFeatures()?.interactive_confirm === true;
|
|
1141
|
+
{
|
|
1142
|
+
const globalOpts = getGlobalOptions();
|
|
1143
|
+
const confirmation = await runPreCallConfirmation(tool, args, {
|
|
1144
|
+
featureOn: confirmFeatureOn,
|
|
1145
|
+
yes: globalOpts.yes === true,
|
|
1146
|
+
noInput: globalOpts.noInput === true,
|
|
1147
|
+
stdinConsumed: argsFilePath === '-',
|
|
1148
|
+
});
|
|
1149
|
+
if (confirmation.action === 'abort') {
|
|
1150
|
+
logError(confirmation.message);
|
|
1151
|
+
process.exit(confirmation.exitCode);
|
|
1152
|
+
}
|
|
1153
|
+
// The server pops cli_confirmed and executes directly (it means
|
|
1154
|
+
// "the confirmation interaction happened client-side").
|
|
1155
|
+
if (confirmation.injectConfirmed)
|
|
1156
|
+
args.cli_confirmed = true;
|
|
1157
|
+
}
|
|
1123
1158
|
// aidrive: strip client-side-only options before sending to API.
|
|
1124
|
-
// --local_file and --
|
|
1125
|
-
//
|
|
1126
|
-
//
|
|
1159
|
+
// --local_file, --override and --on-conflict are only meaningful to
|
|
1160
|
+
// the CLI's own upload lane (which puts on_conflict on the query
|
|
1161
|
+
// string itself) and must never be forwarded to the server as tool
|
|
1162
|
+
// args — other aidrive actions like ls, mkdir, move don't know them.
|
|
1127
1163
|
if (tool.name === 'aidrive') {
|
|
1128
1164
|
delete args.local_file;
|
|
1129
1165
|
delete args.override;
|
|
1166
|
+
delete args.onConflict;
|
|
1130
1167
|
}
|
|
1131
1168
|
// sb-git --execute is client-side only; never forward.
|
|
1132
1169
|
let sbGitExecuteDest;
|
|
@@ -1313,6 +1350,18 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1313
1350
|
opts.local_file) {
|
|
1314
1351
|
const localFilePath = opts.local_file;
|
|
1315
1352
|
const override = !!opts.override;
|
|
1353
|
+
// --on-conflict error|rename|overwrite (#54379). Default (unset) is
|
|
1354
|
+
// rename server-side: nobody is here to answer a prompt, and
|
|
1355
|
+
// dead-ending an agent mid-task is worse than landing a copy.
|
|
1356
|
+
// `error` is kept for idempotent scripts that read a failure as
|
|
1357
|
+
// "nothing was written" — with rename they would accumulate a copy
|
|
1358
|
+
// per retry.
|
|
1359
|
+
// Commander camelCases `--on-conflict` to `onConflict`; the other
|
|
1360
|
+
// spellings are only for a caller that passed the raw arg through.
|
|
1361
|
+
const onConflict = (opts.onConflict ??
|
|
1362
|
+
opts['on-conflict'] ??
|
|
1363
|
+
opts.on_conflict ??
|
|
1364
|
+
args.on_conflict);
|
|
1316
1365
|
const workspace = args.workspace || 'my_drive';
|
|
1317
1366
|
const source = args.source ||
|
|
1318
1367
|
args.share;
|
|
@@ -1338,12 +1387,17 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1338
1387
|
const uploaded = [];
|
|
1339
1388
|
for (const file of files) {
|
|
1340
1389
|
const destination = pathModule.posix.join(uploadPath, file.relativePath);
|
|
1341
|
-
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source);
|
|
1390
|
+
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source, onConflict);
|
|
1342
1391
|
if (result.status !== 'ok') {
|
|
1343
1392
|
output(result);
|
|
1344
1393
|
process.exit(1);
|
|
1345
1394
|
}
|
|
1346
|
-
|
|
1395
|
+
// Report where the bytes ACTUALLY landed: under the rename
|
|
1396
|
+
// default the server may have moved this file aside, and
|
|
1397
|
+
// echoing the requested destination would tell the caller it
|
|
1398
|
+
// wrote a file that does not exist.
|
|
1399
|
+
const landed = result.data?.path;
|
|
1400
|
+
uploaded.push(landed || destination);
|
|
1347
1401
|
}
|
|
1348
1402
|
output({
|
|
1349
1403
|
status: 'ok',
|
|
@@ -1353,7 +1407,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1353
1407
|
}
|
|
1354
1408
|
else {
|
|
1355
1409
|
// Stream directly to AI Drive — single request, no blob middleman
|
|
1356
|
-
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source);
|
|
1410
|
+
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source, onConflict);
|
|
1357
1411
|
output(result);
|
|
1358
1412
|
}
|
|
1359
1413
|
return;
|
|
@@ -1437,6 +1491,15 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1437
1491
|
},
|
|
1438
1492
|
};
|
|
1439
1493
|
}
|
|
1494
|
+
// Fail-safe: with the interactive-confirm contract active the
|
|
1495
|
+
// server should never pend — a pending envelope means the cached
|
|
1496
|
+
// schema predates this action's confirmation flag, so no prompt
|
|
1497
|
+
// ran and no cli_confirmed was sent. No replay; the envelope is
|
|
1498
|
+
// still printed below, plus a refresh hint and a non-zero exit.
|
|
1499
|
+
if (confirmFeatureOn && isPendingConfirmationEnvelope(result)) {
|
|
1500
|
+
logError(STALE_SCHEMA_CACHE_MESSAGE);
|
|
1501
|
+
process.exitCode = 1;
|
|
1502
|
+
}
|
|
1440
1503
|
const isSbGitCloneUrl = tool.name === 'sb-git' &&
|
|
1441
1504
|
resolvedArgs.action === 'clone-url';
|
|
1442
1505
|
if (isSbGitCloneUrl &&
|
|
@@ -1635,11 +1698,10 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1635
1698
|
for (const line of mediaSummaryLines(tool.name, result)) {
|
|
1636
1699
|
info(line);
|
|
1637
1700
|
}
|
|
1638
|
-
//
|
|
1639
|
-
//
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
});
|
|
1701
|
+
// One line whenever stdout is a pipe (see logger.output); media
|
|
1702
|
+
// payloads stay one line even on a terminal so a `grep | head` can
|
|
1703
|
+
// never split the URL list (PR #41690).
|
|
1704
|
+
output(result, { compact: Boolean(mediaItemsKeyFor(tool.name)) });
|
|
1643
1705
|
}
|
|
1644
1706
|
catch (err) {
|
|
1645
1707
|
logError(err.message);
|
|
@@ -1765,26 +1827,29 @@ program
|
|
|
1765
1827
|
}
|
|
1766
1828
|
// If save path specified, download using the already-fetched URL
|
|
1767
1829
|
if (opts.save) {
|
|
1768
|
-
info(`Downloading to ${opts.save}...`);
|
|
1769
1830
|
const resp = await fetch(result.data.download_url);
|
|
1770
1831
|
if (!resp.ok)
|
|
1771
1832
|
throw new Error(`Download failed: HTTP ${resp.status}`);
|
|
1772
1833
|
const buffer = Buffer.from(await resp.arrayBuffer());
|
|
1773
1834
|
fs.writeFileSync(opts.save, buffer);
|
|
1774
|
-
|
|
1775
|
-
|
|
1835
|
+
// Report only what the save produced: `download_url` is the CLI's
|
|
1836
|
+
// own fetch handle (a ~400-char signed URL) and `original_url` is
|
|
1837
|
+
// the argument the caller just passed. Agents re-read every echoed
|
|
1838
|
+
// byte on every later turn, so neither is repeated here.
|
|
1776
1839
|
output({
|
|
1777
1840
|
status: 'ok',
|
|
1778
1841
|
message: 'File downloaded successfully',
|
|
1779
1842
|
data: {
|
|
1780
|
-
|
|
1781
|
-
|
|
1843
|
+
file_name: result.data.file_name,
|
|
1844
|
+
content_type: result.data.content_type,
|
|
1845
|
+
local_path: pathModule.resolve(opts.save),
|
|
1782
1846
|
size_bytes: buffer.length,
|
|
1783
1847
|
},
|
|
1784
1848
|
});
|
|
1785
1849
|
}
|
|
1786
1850
|
else {
|
|
1787
|
-
//
|
|
1851
|
+
// URL-only form: resolving a wrapper to a fetchable URL is the
|
|
1852
|
+
// purpose here, so `download_url` stays.
|
|
1788
1853
|
output(result);
|
|
1789
1854
|
}
|
|
1790
1855
|
}
|
|
@@ -2625,7 +2690,7 @@ async function main() {
|
|
|
2625
2690
|
const client = new ApiClient(globalOpts);
|
|
2626
2691
|
const result = await client.listTools();
|
|
2627
2692
|
tools = result.tools;
|
|
2628
|
-
saveToolsCache(baseUrl, tools);
|
|
2693
|
+
saveToolsCache(baseUrl, tools, result.features);
|
|
2629
2694
|
debug(`Fetched and cached ${tools.length} tools from server`);
|
|
2630
2695
|
}
|
|
2631
2696
|
catch (err) {
|