sim 2.1.8-dev.94.1 → 2.1.8-dev.95.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/dist/embed-context.d.ts +2 -8
- package/dist/http/environment.d.ts +0 -8
- package/dist/index.js +329 -277
- package/dist/output/io.d.ts +5 -0
- package/dist/runtime/renamed.d.ts +0 -14
- package/dist/runtime.js +309 -255
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -18,13 +18,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
return cached;
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
if (canCache)
|
|
29
31
|
cache.set(mod, to);
|
|
30
32
|
return to;
|
|
@@ -33,7 +35,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
33
35
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
34
36
|
|
|
35
37
|
// ../../node_modules/commander/lib/error.js
|
|
36
|
-
var require_error = __commonJS((exports)
|
|
38
|
+
var require_error = __commonJS(function(exports) {
|
|
37
39
|
class CommanderError extends Error {
|
|
38
40
|
constructor(exitCode, code, message) {
|
|
39
41
|
super(message);
|
|
@@ -57,7 +59,7 @@ var require_error = __commonJS((exports) => {
|
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
// ../../node_modules/commander/lib/argument.js
|
|
60
|
-
var require_argument = __commonJS((exports)
|
|
62
|
+
var require_argument = __commonJS(function(exports) {
|
|
61
63
|
var { InvalidArgumentError } = require_error();
|
|
62
64
|
|
|
63
65
|
class Argument {
|
|
@@ -136,7 +138,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
136
138
|
});
|
|
137
139
|
|
|
138
140
|
// ../../node_modules/commander/lib/help.js
|
|
139
|
-
var require_help = __commonJS((exports)
|
|
141
|
+
var require_help = __commonJS(function(exports) {
|
|
140
142
|
var { humanReadableArgName } = require_argument();
|
|
141
143
|
|
|
142
144
|
class Help {
|
|
@@ -147,7 +149,7 @@ var require_help = __commonJS((exports) => {
|
|
|
147
149
|
this.showGlobalOptions = false;
|
|
148
150
|
}
|
|
149
151
|
visibleCommands(cmd) {
|
|
150
|
-
const visibleCommands = cmd.commands.filter((
|
|
152
|
+
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
151
153
|
if (cmd._hasImplicitHelpCommand()) {
|
|
152
154
|
const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
|
|
153
155
|
const helpCommand = cmd.createCommand(helpName).helpOption(false);
|
|
@@ -340,8 +342,8 @@ var require_help = __commonJS((exports) => {
|
|
|
340
342
|
output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
|
|
341
343
|
}
|
|
342
344
|
}
|
|
343
|
-
const commandList = helper.visibleCommands(cmd).map((
|
|
344
|
-
return formatItem(helper.subcommandTerm(
|
|
345
|
+
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
|
346
|
+
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
|
345
347
|
});
|
|
346
348
|
if (commandList.length > 0) {
|
|
347
349
|
output = output.concat(["Commands:", formatList(commandList), ""]);
|
|
@@ -383,7 +385,7 @@ var require_help = __commonJS((exports) => {
|
|
|
383
385
|
});
|
|
384
386
|
|
|
385
387
|
// ../../node_modules/commander/lib/option.js
|
|
386
|
-
var require_option = __commonJS((exports)
|
|
388
|
+
var require_option = __commonJS(function(exports) {
|
|
387
389
|
var { InvalidArgumentError } = require_error();
|
|
388
390
|
|
|
389
391
|
class Option {
|
|
@@ -512,8 +514,8 @@ var require_option = __commonJS((exports) => {
|
|
|
512
514
|
}
|
|
513
515
|
}
|
|
514
516
|
function camelcase(str) {
|
|
515
|
-
return str.split("-").reduce((
|
|
516
|
-
return
|
|
517
|
+
return str.split("-").reduce((str, word) => {
|
|
518
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
517
519
|
});
|
|
518
520
|
}
|
|
519
521
|
function splitOptionFlags(flags) {
|
|
@@ -535,7 +537,7 @@ var require_option = __commonJS((exports) => {
|
|
|
535
537
|
});
|
|
536
538
|
|
|
537
539
|
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
538
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
540
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
539
541
|
var maxDistance = 3;
|
|
540
542
|
function editDistance(a, b) {
|
|
541
543
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -608,7 +610,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
608
610
|
});
|
|
609
611
|
|
|
610
612
|
// ../../node_modules/commander/lib/command.js
|
|
611
|
-
var require_command = __commonJS((exports)
|
|
613
|
+
var require_command = __commonJS(function(exports) {
|
|
612
614
|
var EventEmitter = __require("events").EventEmitter;
|
|
613
615
|
var childProcess = __require("child_process");
|
|
614
616
|
var path = __require("path");
|
|
@@ -1009,35 +1011,35 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1009
1011
|
});
|
|
1010
1012
|
return source;
|
|
1011
1013
|
}
|
|
1012
|
-
_prepareUserArgs(
|
|
1013
|
-
if (
|
|
1014
|
+
_prepareUserArgs(argv2, parseOptions) {
|
|
1015
|
+
if (argv2 !== undefined && !Array.isArray(argv2)) {
|
|
1014
1016
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1015
1017
|
}
|
|
1016
1018
|
parseOptions = parseOptions || {};
|
|
1017
|
-
if (
|
|
1018
|
-
|
|
1019
|
+
if (argv2 === undefined) {
|
|
1020
|
+
argv2 = process2.argv;
|
|
1019
1021
|
if (process2.versions && process2.versions.electron) {
|
|
1020
1022
|
parseOptions.from = "electron";
|
|
1021
1023
|
}
|
|
1022
1024
|
}
|
|
1023
|
-
this.rawArgs =
|
|
1025
|
+
this.rawArgs = argv2.slice();
|
|
1024
1026
|
let userArgs;
|
|
1025
1027
|
switch (parseOptions.from) {
|
|
1026
1028
|
case undefined:
|
|
1027
1029
|
case "node":
|
|
1028
|
-
this._scriptPath =
|
|
1029
|
-
userArgs =
|
|
1030
|
+
this._scriptPath = argv2[1];
|
|
1031
|
+
userArgs = argv2.slice(2);
|
|
1030
1032
|
break;
|
|
1031
1033
|
case "electron":
|
|
1032
1034
|
if (process2.defaultApp) {
|
|
1033
|
-
this._scriptPath =
|
|
1034
|
-
userArgs =
|
|
1035
|
+
this._scriptPath = argv2[1];
|
|
1036
|
+
userArgs = argv2.slice(2);
|
|
1035
1037
|
} else {
|
|
1036
|
-
userArgs =
|
|
1038
|
+
userArgs = argv2.slice(1);
|
|
1037
1039
|
}
|
|
1038
1040
|
break;
|
|
1039
1041
|
case "user":
|
|
1040
|
-
userArgs =
|
|
1042
|
+
userArgs = argv2.slice(0);
|
|
1041
1043
|
break;
|
|
1042
1044
|
default:
|
|
1043
1045
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1526,18 +1528,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1526
1528
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1527
1529
|
}
|
|
1528
1530
|
_conflictingOption(option, conflictingOption) {
|
|
1529
|
-
const findBestOptionFromValue = (
|
|
1530
|
-
const optionKey =
|
|
1531
|
+
const findBestOptionFromValue = (option) => {
|
|
1532
|
+
const optionKey = option.attributeName();
|
|
1531
1533
|
const optionValue = this.getOptionValue(optionKey);
|
|
1532
1534
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1533
1535
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1534
1536
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1535
1537
|
return negativeOption;
|
|
1536
1538
|
}
|
|
1537
|
-
return positiveOption ||
|
|
1539
|
+
return positiveOption || option;
|
|
1538
1540
|
};
|
|
1539
|
-
const getErrorMessage = (
|
|
1540
|
-
const bestOption = findBestOptionFromValue(
|
|
1541
|
+
const getErrorMessage = (option) => {
|
|
1542
|
+
const bestOption = findBestOptionFromValue(option);
|
|
1541
1543
|
const optionKey = bestOption.attributeName();
|
|
1542
1544
|
const source = this.getOptionValueSource(optionKey);
|
|
1543
1545
|
if (source === "env") {
|
|
@@ -1660,10 +1662,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1660
1662
|
this._name = path.basename(filename, path.extname(filename));
|
|
1661
1663
|
return this;
|
|
1662
1664
|
}
|
|
1663
|
-
executableDir(
|
|
1664
|
-
if (
|
|
1665
|
+
executableDir(path) {
|
|
1666
|
+
if (path === undefined)
|
|
1665
1667
|
return this._executableDir;
|
|
1666
|
-
this._executableDir =
|
|
1668
|
+
this._executableDir = path;
|
|
1667
1669
|
return this;
|
|
1668
1670
|
}
|
|
1669
1671
|
helpInformation(contextOptions) {
|
|
@@ -1723,11 +1725,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1723
1725
|
}
|
|
1724
1726
|
help(contextOptions) {
|
|
1725
1727
|
this.outputHelp(contextOptions);
|
|
1726
|
-
let
|
|
1727
|
-
if (
|
|
1728
|
-
|
|
1728
|
+
let exitCode2 = process2.exitCode || 0;
|
|
1729
|
+
if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
1730
|
+
exitCode2 = 1;
|
|
1729
1731
|
}
|
|
1730
|
-
this._exit(
|
|
1732
|
+
this._exit(exitCode2, "commander.help", "(outputHelp)");
|
|
1731
1733
|
}
|
|
1732
1734
|
addHelpText(position, text) {
|
|
1733
1735
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
@@ -1791,7 +1793,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1791
1793
|
});
|
|
1792
1794
|
|
|
1793
1795
|
// ../../node_modules/commander/index.js
|
|
1794
|
-
var require_commander = __commonJS((exports, module)
|
|
1796
|
+
var require_commander = __commonJS(function(exports, module) {
|
|
1795
1797
|
var { Argument } = require_argument();
|
|
1796
1798
|
var { Command } = require_command();
|
|
1797
1799
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -1823,6 +1825,80 @@ var {
|
|
|
1823
1825
|
Option,
|
|
1824
1826
|
Help
|
|
1825
1827
|
} = import__.default;
|
|
1828
|
+
// src/output/io.ts
|
|
1829
|
+
import { format } from "node:util";
|
|
1830
|
+
|
|
1831
|
+
// src/embed-context.ts
|
|
1832
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1833
|
+
function setSoftExitCode(code) {
|
|
1834
|
+
const ctx = embedStore.getStore();
|
|
1835
|
+
if (ctx)
|
|
1836
|
+
ctx.softExitCode = code;
|
|
1837
|
+
else
|
|
1838
|
+
process.exitCode = code;
|
|
1839
|
+
}
|
|
1840
|
+
var embedStore = new AsyncLocalStorage;
|
|
1841
|
+
|
|
1842
|
+
class EmbeddedExit extends Error {
|
|
1843
|
+
code;
|
|
1844
|
+
constructor(code) {
|
|
1845
|
+
super(`CLI exited with code ${code}`);
|
|
1846
|
+
this.code = code;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function embeddedProfile() {
|
|
1850
|
+
const ctx = embedStore.getStore();
|
|
1851
|
+
if (!ctx)
|
|
1852
|
+
return null;
|
|
1853
|
+
return {
|
|
1854
|
+
name: "embedded",
|
|
1855
|
+
endpoint: ctx.identity.endpoint,
|
|
1856
|
+
apiKey: ctx.identity.apiKey,
|
|
1857
|
+
workspaceId: ctx.identity.workspaceId ?? null,
|
|
1858
|
+
output: "json",
|
|
1859
|
+
...ctx.identity.transport ? { transport: ctx.identity.transport } : {},
|
|
1860
|
+
...ctx.identity.signal ? { signal: ctx.identity.signal } : {},
|
|
1861
|
+
sources: { endpoint: "flag", apiKey: "flag", workspaceId: "flag", output: "flag" }
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
function exitCli(code) {
|
|
1865
|
+
if (embedStore.getStore())
|
|
1866
|
+
throw new EmbeddedExit(code);
|
|
1867
|
+
return process.exit(code);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
// src/output/io.ts
|
|
1871
|
+
function printLine(...args) {
|
|
1872
|
+
const context = embedStore.getStore();
|
|
1873
|
+
if (context)
|
|
1874
|
+
context.stdout.write(`${format(...args)}
|
|
1875
|
+
`);
|
|
1876
|
+
else
|
|
1877
|
+
console.log(...args);
|
|
1878
|
+
}
|
|
1879
|
+
function printError(...args) {
|
|
1880
|
+
const context = embedStore.getStore();
|
|
1881
|
+
if (context)
|
|
1882
|
+
context.stderr.write(`${format(...args)}
|
|
1883
|
+
`);
|
|
1884
|
+
else
|
|
1885
|
+
console.error(...args);
|
|
1886
|
+
}
|
|
1887
|
+
function writeStdout(chunk) {
|
|
1888
|
+
const context = embedStore.getStore();
|
|
1889
|
+
if (!context)
|
|
1890
|
+
return process.stdout.write(chunk);
|
|
1891
|
+
context.stdout.write(chunk);
|
|
1892
|
+
return true;
|
|
1893
|
+
}
|
|
1894
|
+
function writeStderr(chunk) {
|
|
1895
|
+
const context = embedStore.getStore();
|
|
1896
|
+
if (!context)
|
|
1897
|
+
return process.stderr.write(chunk);
|
|
1898
|
+
context.stderr.write(chunk);
|
|
1899
|
+
return true;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1826
1902
|
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
1827
1903
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
1828
1904
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
@@ -2318,32 +2394,6 @@ var chalk = createChalk();
|
|
|
2318
2394
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2319
2395
|
var source_default = chalk;
|
|
2320
2396
|
|
|
2321
|
-
// src/embed-context.ts
|
|
2322
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2323
|
-
function setSoftExitCode(code) {
|
|
2324
|
-
const ctx = embedStore.getStore();
|
|
2325
|
-
if (ctx)
|
|
2326
|
-
ctx.softExitCode = code;
|
|
2327
|
-
else
|
|
2328
|
-
process.exitCode = code;
|
|
2329
|
-
}
|
|
2330
|
-
var embedStore = new AsyncLocalStorage;
|
|
2331
|
-
function embeddedProfile() {
|
|
2332
|
-
const ctx = embedStore.getStore();
|
|
2333
|
-
if (!ctx)
|
|
2334
|
-
return null;
|
|
2335
|
-
return {
|
|
2336
|
-
name: "embedded",
|
|
2337
|
-
endpoint: ctx.identity.endpoint,
|
|
2338
|
-
apiKey: ctx.identity.apiKey,
|
|
2339
|
-
workspaceId: ctx.identity.workspaceId ?? null,
|
|
2340
|
-
output: "json",
|
|
2341
|
-
...ctx.identity.transport ? { transport: ctx.identity.transport } : {},
|
|
2342
|
-
...ctx.identity.signal ? { signal: ctx.identity.signal } : {},
|
|
2343
|
-
sources: { endpoint: "flag", apiKey: "flag", workspaceId: "flag", output: "flag" }
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
2397
|
// src/output/presentation.ts
|
|
2348
2398
|
var plain = new Chalk({ level: 0 });
|
|
2349
2399
|
function styles3() {
|
|
@@ -2379,7 +2429,7 @@ function once(key, message) {
|
|
|
2379
2429
|
if (reported.has(key))
|
|
2380
2430
|
return;
|
|
2381
2431
|
reported.add(key);
|
|
2382
|
-
|
|
2432
|
+
writeStderr(`warning: ${message}
|
|
2383
2433
|
`);
|
|
2384
2434
|
}
|
|
2385
2435
|
var PROXY_VARIABLES = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
@@ -2394,11 +2444,11 @@ function runtimeCanProxy(version) {
|
|
|
2394
2444
|
return minor >= firstSupportedMinor;
|
|
2395
2445
|
return major > FIRST_SUPPORTED_MAJOR;
|
|
2396
2446
|
}
|
|
2397
|
-
function warnIfProxyIgnored(
|
|
2398
|
-
const variable = PROXY_VARIABLES.find((name) =>
|
|
2447
|
+
function warnIfProxyIgnored(env = process.env, version = process.version) {
|
|
2448
|
+
const variable = PROXY_VARIABLES.find((name) => env[name]);
|
|
2399
2449
|
if (!variable)
|
|
2400
2450
|
return;
|
|
2401
|
-
if (
|
|
2451
|
+
if (env.NODE_USE_ENV_PROXY && runtimeCanProxy(version))
|
|
2402
2452
|
return;
|
|
2403
2453
|
once("proxy", runtimeCanProxy(version) ? `${variable} is set but Node only uses it when NODE_USE_ENV_PROXY=1. Re-run with NODE_USE_ENV_PROXY=1 to route through the proxy.` : `${variable} is set but Node ${version} cannot use it. Upgrade to Node 22.21 or 24.5 and set NODE_USE_ENV_PROXY=1 to route through the proxy.`);
|
|
2404
2454
|
}
|
|
@@ -2510,8 +2560,8 @@ var RAISE_TIMEOUT_HINT = "Raise SIM_TIMEOUT_SECONDS, or set it to 0 to wait inde
|
|
|
2510
2560
|
function isRequestTimeout(error) {
|
|
2511
2561
|
return error instanceof DOMException && error.name === "TimeoutError";
|
|
2512
2562
|
}
|
|
2513
|
-
function resolveTimeoutMs(
|
|
2514
|
-
const raw =
|
|
2563
|
+
function resolveTimeoutMs(env = process.env) {
|
|
2564
|
+
const raw = env.SIM_TIMEOUT_SECONDS;
|
|
2515
2565
|
if (raw === undefined || raw.trim() === "")
|
|
2516
2566
|
return DEFAULT_TIMEOUT_SECONDS * 1000;
|
|
2517
2567
|
const seconds = Number(raw);
|
|
@@ -2541,12 +2591,12 @@ function combineSignals(caller, timeout) {
|
|
|
2541
2591
|
}
|
|
2542
2592
|
return controller.signal;
|
|
2543
2593
|
}
|
|
2544
|
-
function debugEnabled(
|
|
2545
|
-
const raw =
|
|
2594
|
+
function debugEnabled(env = process.env) {
|
|
2595
|
+
const raw = env.SIM_DEBUG;
|
|
2546
2596
|
return raw !== undefined && raw !== "" && raw !== "0" && raw.toLowerCase() !== "false";
|
|
2547
2597
|
}
|
|
2548
2598
|
function traceRequest(method, url, status, startedAt) {
|
|
2549
|
-
|
|
2599
|
+
writeStderr(`${styles3().dim(`[sim] ${method} ${url} → ${status} ${Math.round(performance.now() - startedAt)}ms`)}
|
|
2550
2600
|
`);
|
|
2551
2601
|
}
|
|
2552
2602
|
function withoutLeadingLabel(message, label) {
|
|
@@ -2719,17 +2769,17 @@ function redirectEndpoint(endpoint, requestPath, target) {
|
|
|
2719
2769
|
return suggested === endpoint.replace(/\/+$/, "") ? null : suggested;
|
|
2720
2770
|
}
|
|
2721
2771
|
function pageProgress() {
|
|
2722
|
-
let
|
|
2772
|
+
let reported = false;
|
|
2723
2773
|
return {
|
|
2724
2774
|
advance: (fetched) => {
|
|
2725
2775
|
if (!hasProgressTerminal())
|
|
2726
2776
|
return;
|
|
2727
|
-
|
|
2728
|
-
|
|
2777
|
+
reported = true;
|
|
2778
|
+
writeStderr(`\r${styles3().dim(`fetched ${fetched}…`)}\x1B[K`);
|
|
2729
2779
|
},
|
|
2730
2780
|
finish: () => {
|
|
2731
|
-
if (
|
|
2732
|
-
|
|
2781
|
+
if (reported)
|
|
2782
|
+
writeStderr("\r\x1B[K");
|
|
2733
2783
|
}
|
|
2734
2784
|
};
|
|
2735
2785
|
}
|
|
@@ -2860,7 +2910,7 @@ async function pollForKey(endpoint, auth, signal) {
|
|
|
2860
2910
|
consecutiveTransportFailures++;
|
|
2861
2911
|
if (!warnedAboutTransport && consecutiveTransportFailures >= TRANSPORT_FAILURES_BEFORE_WARNING) {
|
|
2862
2912
|
warnedAboutTransport = true;
|
|
2863
|
-
|
|
2913
|
+
writeStderr(`Still waiting: ${endpoint} is not answering the login poll (${cause.message}). Check the endpoint; retrying until you approve or the login times out.
|
|
2864
2914
|
`);
|
|
2865
2915
|
}
|
|
2866
2916
|
}
|
|
@@ -10957,14 +11007,14 @@ function requireDumper() {
|
|
|
10957
11007
|
let hasFoldableLine = false;
|
|
10958
11008
|
const shouldTrackWidth = lineWidth !== -1;
|
|
10959
11009
|
let previousLineBreak = -1;
|
|
10960
|
-
let
|
|
11010
|
+
let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
10961
11011
|
if (singleLineOnly || forceQuotes) {
|
|
10962
11012
|
for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
10963
11013
|
char = codePointAt(string, i);
|
|
10964
11014
|
if (!isPrintable(char)) {
|
|
10965
11015
|
return STYLE_DOUBLE;
|
|
10966
11016
|
}
|
|
10967
|
-
|
|
11017
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
10968
11018
|
prevChar = char;
|
|
10969
11019
|
}
|
|
10970
11020
|
} else {
|
|
@@ -10979,13 +11029,13 @@ function requireDumper() {
|
|
|
10979
11029
|
} else if (!isPrintable(char)) {
|
|
10980
11030
|
return STYLE_DOUBLE;
|
|
10981
11031
|
}
|
|
10982
|
-
|
|
11032
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
10983
11033
|
prevChar = char;
|
|
10984
11034
|
}
|
|
10985
11035
|
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
10986
11036
|
}
|
|
10987
11037
|
if (!hasLineBreak && !hasFoldableLine) {
|
|
10988
|
-
if (
|
|
11038
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
10989
11039
|
return STYLE_PLAIN;
|
|
10990
11040
|
}
|
|
10991
11041
|
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
@@ -11547,8 +11597,8 @@ function visibleWidth(value) {
|
|
|
11547
11597
|
return displayWidth(value);
|
|
11548
11598
|
}
|
|
11549
11599
|
function stripAnsi(value) {
|
|
11550
|
-
const
|
|
11551
|
-
return
|
|
11600
|
+
const plain = value.replace(ANSI_PATTERN, "");
|
|
11601
|
+
return plain === EMPTY_GLYPH ? "" : plain;
|
|
11552
11602
|
}
|
|
11553
11603
|
function pad(value, width) {
|
|
11554
11604
|
return value + " ".repeat(Math.max(0, width - visibleWidth(value)));
|
|
@@ -11585,36 +11635,36 @@ function renderMachine(format, raw) {
|
|
|
11585
11635
|
function printList(format, rows, columns, raw = rows) {
|
|
11586
11636
|
const machine = renderMachine(format, raw);
|
|
11587
11637
|
if (machine !== null) {
|
|
11588
|
-
|
|
11638
|
+
printLine(machine);
|
|
11589
11639
|
return;
|
|
11590
11640
|
}
|
|
11591
11641
|
if (format === "text") {
|
|
11592
11642
|
for (const row of rows) {
|
|
11593
|
-
|
|
11643
|
+
printLine(columns.map((column) => oneLine(stripAnsi(column.value(row)))).join("\t"));
|
|
11594
11644
|
}
|
|
11595
11645
|
return;
|
|
11596
11646
|
}
|
|
11597
|
-
|
|
11647
|
+
printLine(renderTable(rows, columns));
|
|
11598
11648
|
}
|
|
11599
11649
|
function printDocument(format, raw) {
|
|
11600
|
-
|
|
11650
|
+
printLine(format === "yaml" ? renderMachine("yaml", raw) : JSON.stringify(raw, null, 2));
|
|
11601
11651
|
}
|
|
11602
11652
|
function printRecord(format, fields, raw) {
|
|
11603
11653
|
const machine = renderMachine(format, raw);
|
|
11604
11654
|
if (machine !== null) {
|
|
11605
|
-
|
|
11655
|
+
printLine(machine);
|
|
11606
11656
|
return;
|
|
11607
11657
|
}
|
|
11608
11658
|
const safeFields = fields.map(([label, value]) => [safeOneLine(label), value]);
|
|
11609
11659
|
if (format === "text") {
|
|
11610
11660
|
for (const [label, value] of safeFields) {
|
|
11611
|
-
|
|
11661
|
+
printLine(`${label} ${oneLine(stripAnsi(value))}`);
|
|
11612
11662
|
}
|
|
11613
11663
|
return;
|
|
11614
11664
|
}
|
|
11615
11665
|
const width = Math.max(...safeFields.map(([label]) => visibleWidth(label)));
|
|
11616
11666
|
for (const [label, value] of safeFields) {
|
|
11617
|
-
|
|
11667
|
+
printLine(`${styles3().dim(pad(`${label}:`, width + 1))} ${clamp(oneLine(value), MAX_RECORD_WIDTH)}`);
|
|
11618
11668
|
}
|
|
11619
11669
|
}
|
|
11620
11670
|
|
|
@@ -11702,10 +11752,10 @@ async function chooseWorkspace(client) {
|
|
|
11702
11752
|
if (workspaces.length > MAX_INTERACTIVE_WORKSPACES) {
|
|
11703
11753
|
throw new SimApiError(`The active API key can access more than ${MAX_INTERACTIVE_WORKSPACES} workspaces, which is too many to show interactively. Pass --workspace <id> instead.`, 0);
|
|
11704
11754
|
}
|
|
11705
|
-
|
|
11755
|
+
printLine(`
|
|
11706
11756
|
Available workspaces:`);
|
|
11707
11757
|
for (const [index, workspace] of workspaces.entries()) {
|
|
11708
|
-
|
|
11758
|
+
printLine(` ${index + 1}) ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
11709
11759
|
}
|
|
11710
11760
|
const prompt = createInterface({ input: process.stdin, output: process.stderr });
|
|
11711
11761
|
try {
|
|
@@ -11730,10 +11780,10 @@ function addProfileCommand() {
|
|
|
11730
11780
|
auth_profile: authProfile,
|
|
11731
11781
|
workspace: normalizeWorkspaceId(workspace.id, "the workspace response")
|
|
11732
11782
|
});
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11783
|
+
printLine(styles3().green(`✓ Added profile "${safeOneLine(profileName)}" in ${configPath()}`));
|
|
11784
|
+
printLine(` Workspace: ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
11785
|
+
printLine(` Authentication: ${safeOneLine(authProfile)}`);
|
|
11786
|
+
printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
|
|
11737
11787
|
});
|
|
11738
11788
|
}
|
|
11739
11789
|
function loginCommand() {
|
|
@@ -11750,21 +11800,21 @@ function loginCommand() {
|
|
|
11750
11800
|
if (readCredentialsProfile(profile.name).api_key && !options.yes) {
|
|
11751
11801
|
const confirmed = await confirmProfileOverwrite(profile.name);
|
|
11752
11802
|
if (!confirmed) {
|
|
11753
|
-
|
|
11803
|
+
printLine(styles3().dim("Login cancelled; the existing profile was not changed."));
|
|
11754
11804
|
return;
|
|
11755
11805
|
}
|
|
11756
11806
|
}
|
|
11757
11807
|
const auth = createAuthRequest();
|
|
11758
11808
|
const url = buildApprovalUrl(profile.endpoint, auth, scope, profile.workspaceId ?? undefined);
|
|
11759
|
-
|
|
11760
|
-
|
|
11809
|
+
printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
|
|
11810
|
+
printLine(`
|
|
11761
11811
|
Pairing code: ${styles3().bold(auth.pairing)}`);
|
|
11762
|
-
|
|
11812
|
+
printLine(styles3().dim(`Confirm this code matches what the browser shows before approving.
|
|
11763
11813
|
`));
|
|
11764
|
-
|
|
11814
|
+
printLine(url);
|
|
11765
11815
|
if (options.browser)
|
|
11766
11816
|
openBrowser(url);
|
|
11767
|
-
|
|
11817
|
+
printLine(styles3().dim(`
|
|
11768
11818
|
Waiting for approval…`));
|
|
11769
11819
|
const key = await pollForKey(profile.endpoint, auth);
|
|
11770
11820
|
if (key.scope !== scope) {
|
|
@@ -11777,14 +11827,14 @@ Waiting for approval…`));
|
|
|
11777
11827
|
requireStorableKey(key.apiKey);
|
|
11778
11828
|
writeConfigProfile(profile.name, settings);
|
|
11779
11829
|
writeCredentialsProfile(profile.name, key.apiKey);
|
|
11780
|
-
|
|
11830
|
+
printLine(styles3().green(`
|
|
11781
11831
|
✓ Logged in. Key stored in ${credentialsPath()}`));
|
|
11782
11832
|
if (key.workspaceBound && key.workspaceId) {
|
|
11783
|
-
|
|
11833
|
+
printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
|
|
11784
11834
|
} else if (key.workspaceId) {
|
|
11785
|
-
|
|
11835
|
+
printLine(styles3().dim(` Personal key, defaulting to ${key.workspaceId}. Override per command with --workspace.`));
|
|
11786
11836
|
} else {
|
|
11787
|
-
|
|
11837
|
+
printLine(styles3().dim(" Personal key with no default workspace. Set one with: sim configure --set-workspace <id>"));
|
|
11788
11838
|
}
|
|
11789
11839
|
});
|
|
11790
11840
|
}
|
|
@@ -11798,10 +11848,10 @@ function logoutCommand() {
|
|
|
11798
11848
|
}
|
|
11799
11849
|
const removed = deleteProfile(profileName);
|
|
11800
11850
|
if (!removed.config && !removed.credentials) {
|
|
11801
|
-
|
|
11851
|
+
printLine(styles3().dim(`Nothing stored for profile "${safeOneLine(profileName)}".`));
|
|
11802
11852
|
return;
|
|
11803
11853
|
}
|
|
11804
|
-
|
|
11854
|
+
printLine(styles3().green(`✓ Removed profile "${safeOneLine(profileName)}".`));
|
|
11805
11855
|
return;
|
|
11806
11856
|
}
|
|
11807
11857
|
const profile = profileFrom(command);
|
|
@@ -11810,12 +11860,12 @@ function logoutCommand() {
|
|
|
11810
11860
|
throw new SimApiError(`Profile "${redact(profile.name)}" shares authentication with "${redact(authProfile)}". Log out of the authentication profile instead: sim logout --profile ${redact(authProfile)}`, 0);
|
|
11811
11861
|
}
|
|
11812
11862
|
if (!readCredentialsProfile(profile.name).api_key) {
|
|
11813
|
-
|
|
11863
|
+
printLine(styles3().dim(`No stored key for profile "${safeOneLine(profile.name)}".`));
|
|
11814
11864
|
return;
|
|
11815
11865
|
}
|
|
11816
11866
|
writeCredentialsProfile(profile.name, null);
|
|
11817
|
-
|
|
11818
|
-
|
|
11867
|
+
printLine(styles3().green(`✓ Removed the stored key for profile "${safeOneLine(profile.name)}".`));
|
|
11868
|
+
printLine(styles3().dim(" The key itself is still active — revoke it in Settings → Sim API keys."));
|
|
11819
11869
|
});
|
|
11820
11870
|
}
|
|
11821
11871
|
async function readKeyType(client) {
|
|
@@ -11995,7 +12045,7 @@ function profilesCommand() {
|
|
|
11995
12045
|
const rows = listProfiles().map((name) => buildProfileRow(name, name === activeName));
|
|
11996
12046
|
if (rows.length === 0) {
|
|
11997
12047
|
if (output === "table")
|
|
11998
|
-
|
|
12048
|
+
printLine(styles3().dim("No profiles yet. Run: sim login"));
|
|
11999
12049
|
else
|
|
12000
12050
|
printList(output, rows, PROFILE_COLUMNS);
|
|
12001
12051
|
return;
|
|
@@ -12075,21 +12125,21 @@ function configureCommand() {
|
|
|
12075
12125
|
if (Object.keys(updates).length === 0) {
|
|
12076
12126
|
const current = readConfigProfile(profile.name);
|
|
12077
12127
|
if (Object.keys(current).length === 0) {
|
|
12078
|
-
|
|
12128
|
+
printLine(styles3().dim(`No settings stored for profile "${profile.name}".`));
|
|
12079
12129
|
return;
|
|
12080
12130
|
}
|
|
12081
12131
|
for (const [key, value] of Object.entries(current)) {
|
|
12082
|
-
|
|
12132
|
+
printLine(`${styles3().dim(`${key}:`)} ${value}`);
|
|
12083
12133
|
}
|
|
12084
12134
|
return;
|
|
12085
12135
|
}
|
|
12086
12136
|
const removalOnly = Object.values(updates).every((value) => value === null);
|
|
12087
12137
|
if (removalOnly && Object.keys(readConfigProfile(profile.name)).length === 0) {
|
|
12088
|
-
|
|
12138
|
+
printLine(styles3().dim(`No settings stored for profile "${profile.name}".`));
|
|
12089
12139
|
return;
|
|
12090
12140
|
}
|
|
12091
12141
|
writeConfigProfile(profile.name, updates);
|
|
12092
|
-
|
|
12142
|
+
printLine(styles3().green(`✓ Updated profile "${profile.name}" in ${configPath()}`));
|
|
12093
12143
|
});
|
|
12094
12144
|
}
|
|
12095
12145
|
|
|
@@ -13338,13 +13388,13 @@ async function localFile(path, override) {
|
|
|
13338
13388
|
embedded.identity.signal?.throwIfAborted();
|
|
13339
13389
|
if (!embedded.openFile)
|
|
13340
13390
|
throw new SimApiError("This invocation has no machine to read from", 0);
|
|
13341
|
-
const { size
|
|
13391
|
+
const { size } = await embedded.openFile(embeddedFileKey(path));
|
|
13342
13392
|
embedded.identity.signal?.throwIfAborted();
|
|
13343
|
-
if (!Number.isSafeInteger(
|
|
13393
|
+
if (!Number.isSafeInteger(size) || size < 0)
|
|
13344
13394
|
throw new SimApiError("Invalid file size", 0);
|
|
13345
|
-
if (
|
|
13395
|
+
if (size === 0)
|
|
13346
13396
|
throw new SimApiError(`${path} is empty`, 0);
|
|
13347
|
-
return { name: override ?? basename(embeddedFileKey(path)), size
|
|
13397
|
+
return { name: override ?? basename(embeddedFileKey(path)), size };
|
|
13348
13398
|
}
|
|
13349
13399
|
let size;
|
|
13350
13400
|
try {
|
|
@@ -13644,20 +13694,20 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
13644
13694
|
const headerSlot = Object.keys(headers).length > 0 ? { headers } : {};
|
|
13645
13695
|
if (spec.opaqueBody) {
|
|
13646
13696
|
if (commandSpec.bodyVariants) {
|
|
13647
|
-
const provided = commandSpec.bodyVariants.filter((
|
|
13648
|
-
const names = commandSpec.bodyVariants.map((
|
|
13697
|
+
const provided = commandSpec.bodyVariants.filter((variant) => flags[camel(variant.name)] !== undefined);
|
|
13698
|
+
const names = commandSpec.bodyVariants.map((variant) => `--${variant.name}`).join(" or ");
|
|
13649
13699
|
if (provided.length !== 1) {
|
|
13650
13700
|
throw new SimApiError(`Pass exactly one of ${names}`, 0);
|
|
13651
13701
|
}
|
|
13652
13702
|
const variant = provided[0];
|
|
13653
|
-
const
|
|
13654
|
-
if (typeof
|
|
13703
|
+
const raw = flags[camel(variant.name)];
|
|
13704
|
+
if (typeof raw !== "string")
|
|
13655
13705
|
throw new SimApiError(`--${variant.name} is required`, 0);
|
|
13656
|
-
const
|
|
13657
|
-
if (variant.kind === "object" && (!
|
|
13706
|
+
const parsed = await coerce(raw, { kind: variant.kind }, { json: true }, variant.name);
|
|
13707
|
+
if (variant.kind === "object" && (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) || variant.kind === "array" && !Array.isArray(parsed)) {
|
|
13658
13708
|
throw new SimApiError(`--${variant.name} must be a JSON ${variant.kind}`, 0);
|
|
13659
13709
|
}
|
|
13660
|
-
return { path, query, body: { ...body, [variant.property]:
|
|
13710
|
+
return { path, query, body: { ...body, [variant.property]: parsed }, ...headerSlot };
|
|
13661
13711
|
}
|
|
13662
13712
|
const raw = flags.body;
|
|
13663
13713
|
if (typeof raw !== "string")
|
|
@@ -13786,7 +13836,7 @@ function warn(kind, from, to) {
|
|
|
13786
13836
|
if (warned.has(key))
|
|
13787
13837
|
return;
|
|
13788
13838
|
warned.add(key);
|
|
13789
|
-
|
|
13839
|
+
writeStderr(`warning: ${kind} "${from}" has been renamed to "${to}". The old name still works.
|
|
13790
13840
|
`);
|
|
13791
13841
|
}
|
|
13792
13842
|
function warnRenamedCommand(from, to) {
|
|
@@ -13854,13 +13904,13 @@ function renderSpan(value, depth) {
|
|
|
13854
13904
|
const indent = " ".repeat(depth);
|
|
13855
13905
|
const detailIndent = `${indent} `;
|
|
13856
13906
|
const name = requiredText(span, "name");
|
|
13857
|
-
const
|
|
13907
|
+
const type = requiredText(span, "type");
|
|
13858
13908
|
const status = optionalText(span, "status");
|
|
13859
13909
|
const elapsed = optionalNumber(span, "durationMs") ?? optionalNumber(span, "duration");
|
|
13860
13910
|
const totalCost = costTotal(span);
|
|
13861
13911
|
const summary = [
|
|
13862
13912
|
`${indent}- ${name}`,
|
|
13863
|
-
`[${
|
|
13913
|
+
`[${type}]`,
|
|
13864
13914
|
status,
|
|
13865
13915
|
elapsed === undefined ? undefined : duration(Math.round(elapsed)),
|
|
13866
13916
|
totalCost === undefined ? undefined : `$${totalCost.toFixed(4)}`
|
|
@@ -13898,13 +13948,13 @@ function renderSpan(value, depth) {
|
|
|
13898
13948
|
function printTraceSpans(format, traceSpans) {
|
|
13899
13949
|
if (format === "json" || format === "yaml")
|
|
13900
13950
|
return;
|
|
13901
|
-
|
|
13902
|
-
|
|
13951
|
+
printLine("");
|
|
13952
|
+
printLine(format === "table" ? styles3().dim("trace:") : "trace:");
|
|
13903
13953
|
if (traceSpans.length === 0) {
|
|
13904
|
-
|
|
13954
|
+
printLine(styles3().dim(" No trace spans."));
|
|
13905
13955
|
return;
|
|
13906
13956
|
}
|
|
13907
|
-
|
|
13957
|
+
printLine(traceSpans.flatMap((span) => renderSpan(span, 0)).join(`
|
|
13908
13958
|
`));
|
|
13909
13959
|
}
|
|
13910
13960
|
|
|
@@ -14069,7 +14119,7 @@ function writePageNote(spec, envelope) {
|
|
|
14069
14119
|
const value = at(envelope, spec.pageNote.path);
|
|
14070
14120
|
if (value === undefined || value === null)
|
|
14071
14121
|
return;
|
|
14072
|
-
|
|
14122
|
+
writeStderr(styles3().dim(`${spec.pageNote.label}: ${String(value)}
|
|
14073
14123
|
`));
|
|
14074
14124
|
}
|
|
14075
14125
|
var TRUNCATION_FLAG = /^truncated$|^[A-Za-z0-9]+Truncated$/;
|
|
@@ -14102,14 +14152,14 @@ function clippedSubject(flag) {
|
|
|
14102
14152
|
}
|
|
14103
14153
|
function writeEnvelopeTruncation(envelope) {
|
|
14104
14154
|
for (const flag of responseTruncationFlags(envelope)) {
|
|
14105
|
-
|
|
14155
|
+
writeStderr(styles3().dim(`${spellOut(flag)}: the server clipped ${clippedSubject(flag)}, so the answer is incomplete
|
|
14106
14156
|
`));
|
|
14107
14157
|
}
|
|
14108
14158
|
}
|
|
14109
14159
|
function writeCursorTruncation(count, truncated) {
|
|
14110
14160
|
if (!truncated)
|
|
14111
14161
|
return;
|
|
14112
|
-
|
|
14162
|
+
writeStderr(styles3().dim(`showing the first ${count}; more results exist — re-run with --limit 0 for all
|
|
14113
14163
|
`));
|
|
14114
14164
|
}
|
|
14115
14165
|
function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
@@ -14162,8 +14212,8 @@ function runFailureMessage(operation, payload) {
|
|
|
14162
14212
|
const fallback = FAILED_RUN_STATUS_MESSAGES[status];
|
|
14163
14213
|
if (!fallback)
|
|
14164
14214
|
return null;
|
|
14165
|
-
const
|
|
14166
|
-
return safeOneLine(typeof
|
|
14215
|
+
const reported = error?.message;
|
|
14216
|
+
return safeOneLine(typeof reported === "string" && reported ? reported : fallback);
|
|
14167
14217
|
}
|
|
14168
14218
|
var BULK_OUTCOME_CHECKS = {
|
|
14169
14219
|
bulkDeleteFiles: (payload, body) => {
|
|
@@ -14198,8 +14248,8 @@ var BULK_OUTCOME_CHECKS = {
|
|
|
14198
14248
|
const requested = lengthOf(body?.chunkIds);
|
|
14199
14249
|
if (requested === 0)
|
|
14200
14250
|
return null;
|
|
14201
|
-
const
|
|
14202
|
-
return typeof
|
|
14251
|
+
const reported = payload.errors?.[0];
|
|
14252
|
+
return typeof reported === "string" && reported ? safeOneLine(reported) : `Updated nothing: none of the ${requested} requested ${requested === 1 ? "chunk" : "chunks"} matched.`;
|
|
14203
14253
|
},
|
|
14204
14254
|
deleteTableRows: (payload) => {
|
|
14205
14255
|
if (countOf(payload.deletedCount) > 0)
|
|
@@ -14245,7 +14295,7 @@ function writeResultNote(operation, payload, body) {
|
|
|
14245
14295
|
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
14246
14296
|
const message = note(record, body);
|
|
14247
14297
|
if (message)
|
|
14248
|
-
|
|
14298
|
+
writeStderr(styles3().dim(`${message}
|
|
14249
14299
|
`));
|
|
14250
14300
|
}
|
|
14251
14301
|
function bulkFailureMessage(operation, payload, body) {
|
|
@@ -14260,8 +14310,8 @@ var EXCLUSIVE_CAP_FIELDS = {
|
|
|
14260
14310
|
deleteTableRows: { cap: "limit", ids: "rowIds" }
|
|
14261
14311
|
};
|
|
14262
14312
|
function readPagedLimit(raw) {
|
|
14263
|
-
const
|
|
14264
|
-
const value =
|
|
14313
|
+
const text = String(raw ?? DEFAULT_LIMIT).trim();
|
|
14314
|
+
const value = text === "" ? Number.NaN : Number(text);
|
|
14265
14315
|
if (!Number.isInteger(value) || value < 0) {
|
|
14266
14316
|
throw new SimApiError("--limit must be a whole number of 0 or more (0 for everything)", 0);
|
|
14267
14317
|
}
|
|
@@ -14436,7 +14486,7 @@ function retypeMessage(message, spellings) {
|
|
|
14436
14486
|
}
|
|
14437
14487
|
function retypeDetails(details, spellings) {
|
|
14438
14488
|
if (Array.isArray(details))
|
|
14439
|
-
return details.map((
|
|
14489
|
+
return details.map((issue) => retypeDetails(issue, spellings));
|
|
14440
14490
|
if (!details || typeof details !== "object")
|
|
14441
14491
|
return details;
|
|
14442
14492
|
const issue = details;
|
|
@@ -14498,8 +14548,8 @@ function commandPath(command) {
|
|
|
14498
14548
|
return names.join(" ");
|
|
14499
14549
|
}
|
|
14500
14550
|
var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
|
|
14501
|
-
function looksLikeAnId(
|
|
14502
|
-
return
|
|
14551
|
+
function looksLikeAnId(token) {
|
|
14552
|
+
return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
|
|
14503
14553
|
}
|
|
14504
14554
|
function addArgumentExamples(command) {
|
|
14505
14555
|
const outputError = command.configureOutput().outputError;
|
|
@@ -14517,10 +14567,10 @@ function addArgumentExamples(command) {
|
|
|
14517
14567
|
}
|
|
14518
14568
|
if (command.registeredArguments.length === 0)
|
|
14519
14569
|
return;
|
|
14520
|
-
const
|
|
14521
|
-
if (!
|
|
14570
|
+
const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
|
|
14571
|
+
if (!token || !looksLikeAnId(token))
|
|
14522
14572
|
return;
|
|
14523
|
-
write(`Example: ${commandPath(command)} -- ${
|
|
14573
|
+
write(`Example: ${commandPath(command)} -- ${token}
|
|
14524
14574
|
`);
|
|
14525
14575
|
}
|
|
14526
14576
|
});
|
|
@@ -14536,7 +14586,7 @@ function assertNoReservedFlags(command, operation) {
|
|
|
14536
14586
|
}
|
|
14537
14587
|
}
|
|
14538
14588
|
var RESERVED_FLAG_EXEMPTIONS = new Set(["profiles add"]);
|
|
14539
|
-
function assertNoReservedProgramFlags(
|
|
14589
|
+
function assertNoReservedProgramFlags(program) {
|
|
14540
14590
|
const walk = (command, prefix) => {
|
|
14541
14591
|
const path = [...prefix, command.name()];
|
|
14542
14592
|
const name = path.join(" ");
|
|
@@ -14552,10 +14602,10 @@ function assertNoReservedProgramFlags(program2) {
|
|
|
14552
14602
|
for (const child of command.commands)
|
|
14553
14603
|
walk(child, path);
|
|
14554
14604
|
};
|
|
14555
|
-
for (const child of
|
|
14605
|
+
for (const child of program.commands)
|
|
14556
14606
|
walk(child, []);
|
|
14557
14607
|
}
|
|
14558
|
-
function refuseHelpAfterUnknownCommand(
|
|
14608
|
+
function refuseHelpAfterUnknownCommand(program) {
|
|
14559
14609
|
const walk = (command) => {
|
|
14560
14610
|
const internals = command;
|
|
14561
14611
|
const dispatchesOnly = command.commands.length > 0 && !internals._actionHandler && command.registeredArguments.length === 0;
|
|
@@ -14576,7 +14626,7 @@ function refuseHelpAfterUnknownCommand(program2) {
|
|
|
14576
14626
|
for (const child of command.commands)
|
|
14577
14627
|
walk(child);
|
|
14578
14628
|
};
|
|
14579
|
-
walk(
|
|
14629
|
+
walk(program);
|
|
14580
14630
|
}
|
|
14581
14631
|
function configureOperation(command, operation, spec) {
|
|
14582
14632
|
const operationSpec = V2_OPERATIONS[operation];
|
|
@@ -14860,8 +14910,8 @@ function acceptNameOnUpdate(credentials) {
|
|
|
14860
14910
|
options.displayName = options.name;
|
|
14861
14911
|
});
|
|
14862
14912
|
}
|
|
14863
|
-
function attachCredentialCommands(
|
|
14864
|
-
const credentials =
|
|
14913
|
+
function attachCredentialCommands(program) {
|
|
14914
|
+
const credentials = program.commands.find((command) => command.name() === "credentials");
|
|
14865
14915
|
if (!credentials)
|
|
14866
14916
|
throw new Error("The generated credentials command group is missing");
|
|
14867
14917
|
acceptNameOnUpdate(credentials);
|
|
@@ -14955,8 +15005,8 @@ function ignoreBrokenPipe(stream) {
|
|
|
14955
15005
|
stream.off("error", onError);
|
|
14956
15006
|
};
|
|
14957
15007
|
}
|
|
14958
|
-
function attachChat(
|
|
14959
|
-
|
|
15008
|
+
function attachChat(program) {
|
|
15009
|
+
program.command("chat").description("Ask Sim and print the reply").argument("<message>", "What to ask Sim").allowExcessArguments(false).option("-c, --conversation <id>", "Continue the conversation with this ID").addHelpText("after", `
|
|
14960
15010
|
Each turn prints the reply on stdout and the conversation ID on stderr; pass
|
|
14961
15011
|
that ID back with -c to continue the same conversation. With --output json or
|
|
14962
15012
|
yaml the reply is not streamed — the finished result is printed as one
|
|
@@ -14989,19 +15039,19 @@ Examples:
|
|
|
14989
15039
|
const endStreamedLine = () => {
|
|
14990
15040
|
if (streamed.length > 0 && !streamed.endsWith(`
|
|
14991
15041
|
`)) {
|
|
14992
|
-
|
|
15042
|
+
writeStdout(`
|
|
14993
15043
|
`);
|
|
14994
15044
|
streamed += `
|
|
14995
15045
|
`;
|
|
14996
15046
|
}
|
|
14997
15047
|
};
|
|
14998
|
-
const restorePipeHandling = streaming ? ignoreBrokenPipe(process.stdout) : undefined;
|
|
15048
|
+
const restorePipeHandling = streaming && !embedStore.getStore() ? ignoreBrokenPipe(process.stdout) : undefined;
|
|
14999
15049
|
try {
|
|
15000
|
-
const result = await readChatStream(response, (
|
|
15050
|
+
const result = await readChatStream(response, (content) => {
|
|
15001
15051
|
if (!streaming)
|
|
15002
15052
|
return;
|
|
15003
|
-
streamed +=
|
|
15004
|
-
|
|
15053
|
+
streamed += content;
|
|
15054
|
+
writeStdout(content);
|
|
15005
15055
|
});
|
|
15006
15056
|
if (!streaming) {
|
|
15007
15057
|
printProtocolResult(profile.output, result);
|
|
@@ -15009,11 +15059,11 @@ Examples:
|
|
|
15009
15059
|
}
|
|
15010
15060
|
const content = sanitize(result.content ?? "");
|
|
15011
15061
|
if (content.startsWith(streamed) && content.length > streamed.length) {
|
|
15012
|
-
|
|
15062
|
+
writeStdout(content.slice(streamed.length));
|
|
15013
15063
|
streamed = content;
|
|
15014
15064
|
}
|
|
15015
15065
|
endStreamedLine();
|
|
15016
|
-
|
|
15066
|
+
writeStderr(`${styles3().dim(`conversation: ${result.conversationId}`)}
|
|
15017
15067
|
`);
|
|
15018
15068
|
} catch (error) {
|
|
15019
15069
|
endStreamedLine();
|
|
@@ -15160,15 +15210,19 @@ async function saveToFile(body, target, force) {
|
|
|
15160
15210
|
}
|
|
15161
15211
|
return saveStagedFile(body, target, force);
|
|
15162
15212
|
}
|
|
15163
|
-
async function streamToStdout(body, output
|
|
15213
|
+
async function streamToStdout(body, output) {
|
|
15164
15214
|
const reader = body.getReader();
|
|
15165
15215
|
try {
|
|
15166
15216
|
while (true) {
|
|
15167
15217
|
const { done, value } = await reader.read();
|
|
15168
15218
|
if (done)
|
|
15169
15219
|
return;
|
|
15170
|
-
if (
|
|
15171
|
-
|
|
15220
|
+
if (output) {
|
|
15221
|
+
if (!output.write(value))
|
|
15222
|
+
await once2(output, "drain");
|
|
15223
|
+
} else if (!writeStdout(value)) {
|
|
15224
|
+
await once2(process.stdout, "drain");
|
|
15225
|
+
}
|
|
15172
15226
|
}
|
|
15173
15227
|
} finally {
|
|
15174
15228
|
await reader.cancel().catch(() => {});
|
|
@@ -15571,11 +15625,11 @@ function createTableWriter() {
|
|
|
15571
15625
|
if (!widths) {
|
|
15572
15626
|
widths = COLUMNS.map((column, index) => Math.min(MAX_CELL_WIDTH2, Math.max(column.floor, visibleWidth(column.header), ...lines.map((line) => visibleWidth(line[index])))));
|
|
15573
15627
|
const header = widths;
|
|
15574
|
-
|
|
15628
|
+
printLine(styles3().dim(COLUMNS.map((column, index) => pad2(column.header.toUpperCase(), header[index])).join(" ").trimEnd()));
|
|
15575
15629
|
}
|
|
15576
15630
|
const locked = widths;
|
|
15577
15631
|
for (const line of lines) {
|
|
15578
|
-
|
|
15632
|
+
printLine(line.map((cell, index) => pad2(cell, locked[index])).join(" ").trimEnd());
|
|
15579
15633
|
}
|
|
15580
15634
|
};
|
|
15581
15635
|
}
|
|
@@ -15583,13 +15637,13 @@ function createWriter(format) {
|
|
|
15583
15637
|
if (format === "json") {
|
|
15584
15638
|
return (rows) => {
|
|
15585
15639
|
for (const row of rows)
|
|
15586
|
-
|
|
15640
|
+
printLine(JSON.stringify(row));
|
|
15587
15641
|
};
|
|
15588
15642
|
}
|
|
15589
15643
|
if (format === "yaml") {
|
|
15590
15644
|
return (rows) => {
|
|
15591
15645
|
for (const row of rows) {
|
|
15592
|
-
|
|
15646
|
+
printLine(`---
|
|
15593
15647
|
${dump(row, { lineWidth: 0, noRefs: true }).trimEnd()}`);
|
|
15594
15648
|
}
|
|
15595
15649
|
};
|
|
@@ -15603,27 +15657,27 @@ ${dump(row, { lineWidth: 0, noRefs: true }).trimEnd()}`);
|
|
|
15603
15657
|
return createTableWriter();
|
|
15604
15658
|
}
|
|
15605
15659
|
function followStatus() {
|
|
15606
|
-
let
|
|
15660
|
+
let reported = false;
|
|
15607
15661
|
return {
|
|
15608
15662
|
note: (message) => {
|
|
15609
15663
|
if (!hasProgressTerminal())
|
|
15610
15664
|
return;
|
|
15611
|
-
|
|
15612
|
-
|
|
15665
|
+
reported = true;
|
|
15666
|
+
writeStderr(`\r${styles3().dim(message)}${ERASE_LINE}`);
|
|
15613
15667
|
},
|
|
15614
15668
|
warn: (message) => {
|
|
15615
|
-
if (
|
|
15616
|
-
|
|
15617
|
-
|
|
15669
|
+
if (reported) {
|
|
15670
|
+
reported = false;
|
|
15671
|
+
writeStderr(`\r${ERASE_LINE}`);
|
|
15618
15672
|
}
|
|
15619
|
-
|
|
15673
|
+
writeStderr(`warning: ${message}
|
|
15620
15674
|
`);
|
|
15621
15675
|
},
|
|
15622
15676
|
clear: () => {
|
|
15623
|
-
if (!
|
|
15677
|
+
if (!reported)
|
|
15624
15678
|
return;
|
|
15625
|
-
|
|
15626
|
-
|
|
15679
|
+
reported = false;
|
|
15680
|
+
writeStderr(`\r${ERASE_LINE}`);
|
|
15627
15681
|
}
|
|
15628
15682
|
};
|
|
15629
15683
|
}
|
|
@@ -15910,19 +15964,19 @@ function progressLine(job) {
|
|
|
15910
15964
|
}
|
|
15911
15965
|
async function watchImport(client, workspaceId, job) {
|
|
15912
15966
|
let current = job;
|
|
15913
|
-
let
|
|
15967
|
+
let reported = null;
|
|
15914
15968
|
while (!IMPORT_SETTLED.has(current.status)) {
|
|
15915
15969
|
await sleep2(IMPORT_POLL_MS);
|
|
15916
15970
|
const next = await client.request(`/api/v2/tables/imports/${encodeURIComponent(current.id)}`, { query: { workspaceId } });
|
|
15917
15971
|
current = next.data;
|
|
15918
15972
|
const line = progressLine(current);
|
|
15919
|
-
if (hasProgressTerminal() && line !==
|
|
15920
|
-
|
|
15921
|
-
|
|
15973
|
+
if (hasProgressTerminal() && line !== reported) {
|
|
15974
|
+
reported = line;
|
|
15975
|
+
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
15922
15976
|
}
|
|
15923
15977
|
}
|
|
15924
|
-
if (hasProgressTerminal() &&
|
|
15925
|
-
|
|
15978
|
+
if (hasProgressTerminal() && reported !== null)
|
|
15979
|
+
writeStderr("\r\x1B[K");
|
|
15926
15980
|
return current;
|
|
15927
15981
|
}
|
|
15928
15982
|
function validateTargetOptions(options) {
|
|
@@ -16105,16 +16159,16 @@ class Commentary {
|
|
|
16105
16159
|
constructor(sink) {
|
|
16106
16160
|
this.sink = sink;
|
|
16107
16161
|
}
|
|
16108
|
-
inline(
|
|
16109
|
-
if (
|
|
16162
|
+
inline(text) {
|
|
16163
|
+
if (text.length === 0)
|
|
16110
16164
|
return;
|
|
16111
|
-
this.sink.write(
|
|
16112
|
-
this.atLineStart =
|
|
16165
|
+
this.sink.write(text);
|
|
16166
|
+
this.atLineStart = text.endsWith(`
|
|
16113
16167
|
`);
|
|
16114
16168
|
}
|
|
16115
|
-
line(
|
|
16169
|
+
line(text) {
|
|
16116
16170
|
this.sink.write(`${this.atLineStart ? "" : `
|
|
16117
|
-
`}${
|
|
16171
|
+
`}${text}
|
|
16118
16172
|
`);
|
|
16119
16173
|
this.atLineStart = true;
|
|
16120
16174
|
}
|
|
@@ -16222,7 +16276,7 @@ async function followRun(workflowId, command) {
|
|
|
16222
16276
|
const final = await renderRunStream(response.body, {
|
|
16223
16277
|
includeThinking,
|
|
16224
16278
|
includeToolCalls,
|
|
16225
|
-
stderr:
|
|
16279
|
+
stderr: { write: writeStderr }
|
|
16226
16280
|
});
|
|
16227
16281
|
renderResult("executeWorkflow", profile.output, final, CLI_CONTRACT.executeWorkflow ?? {});
|
|
16228
16282
|
if (final.success === false) {
|
|
@@ -16419,19 +16473,19 @@ function classify(snapshot) {
|
|
|
16419
16473
|
return snapshot.status === "completed" ? "completed" : snapshot.status === "cancelled" ? "cancelled" : "failed";
|
|
16420
16474
|
}
|
|
16421
16475
|
function waitProgress() {
|
|
16422
|
-
let
|
|
16476
|
+
let reported = false;
|
|
16423
16477
|
return {
|
|
16424
16478
|
advance: (status, elapsedMs) => {
|
|
16425
16479
|
if (!hasProgressTerminal())
|
|
16426
16480
|
return;
|
|
16427
|
-
|
|
16428
|
-
|
|
16481
|
+
reported = true;
|
|
16482
|
+
writeStderr(`\r${styles3().dim(`${status} — waiting ${Math.round(elapsedMs / 1000)}s…`)}\x1B[K`);
|
|
16429
16483
|
},
|
|
16430
16484
|
finish: () => {
|
|
16431
|
-
if (!
|
|
16485
|
+
if (!reported)
|
|
16432
16486
|
return;
|
|
16433
|
-
|
|
16434
|
-
|
|
16487
|
+
reported = false;
|
|
16488
|
+
writeStderr("\r\x1B[K");
|
|
16435
16489
|
}
|
|
16436
16490
|
};
|
|
16437
16491
|
}
|
|
@@ -16475,7 +16529,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16475
16529
|
renderResult("getWorkflowRun", profile.output, runData(raw), runSpec());
|
|
16476
16530
|
const message = explain(outcome, runId, options.workflow, snapshot);
|
|
16477
16531
|
if (message)
|
|
16478
|
-
|
|
16532
|
+
printError(styles3().red(message));
|
|
16479
16533
|
setSoftExitCode(WAIT_EXIT_CODES[outcome]);
|
|
16480
16534
|
return;
|
|
16481
16535
|
}
|
|
@@ -16483,7 +16537,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16483
16537
|
if (remainingMs <= 0) {
|
|
16484
16538
|
progress.finish();
|
|
16485
16539
|
renderResult("getWorkflowRun", profile.output, runData(raw), runSpec());
|
|
16486
|
-
|
|
16540
|
+
printError(styles3().red(`Timed out after ${timeoutSeconds}s waiting for run ${runId} (status: ${snapshot.status}${snapshot.resumeAt ? `, resuming at ${snapshot.resumeAt}` : ""}). Raise ${WAIT_TIMEOUT_FLAG}, or set it to 0 to wait indefinitely.`));
|
|
16487
16541
|
setSoftExitCode(WAIT_EXIT_CODES.timeout);
|
|
16488
16542
|
return;
|
|
16489
16543
|
}
|
|
@@ -16498,16 +16552,16 @@ function attachWorkflowRunWait(runs) {
|
|
|
16498
16552
|
}
|
|
16499
16553
|
|
|
16500
16554
|
// src/commands/protocol/index.ts
|
|
16501
|
-
function group(
|
|
16502
|
-
const existing =
|
|
16555
|
+
function group(program, name) {
|
|
16556
|
+
const existing = program.commands.find((command) => command.name() === name);
|
|
16503
16557
|
if (existing)
|
|
16504
16558
|
return existing;
|
|
16505
16559
|
const created = new Command(name);
|
|
16506
|
-
|
|
16560
|
+
program.addCommand(created);
|
|
16507
16561
|
return created;
|
|
16508
16562
|
}
|
|
16509
|
-
function attachProtocolCommands(
|
|
16510
|
-
const files = group(
|
|
16563
|
+
function attachProtocolCommands(program) {
|
|
16564
|
+
const files = group(program, "files");
|
|
16511
16565
|
attachFileUpload(files);
|
|
16512
16566
|
attachFileGet(files);
|
|
16513
16567
|
attachResourceDirectoryCommands(files, {
|
|
@@ -16516,7 +16570,7 @@ function attachProtocolCommands(program2) {
|
|
|
16516
16570
|
folders: "listFileFolders",
|
|
16517
16571
|
createFolder: "createFileFolder"
|
|
16518
16572
|
});
|
|
16519
|
-
const knowledge = group(
|
|
16573
|
+
const knowledge = group(program, "knowledge");
|
|
16520
16574
|
attachKnowledgeDocumentUpload(group(knowledge, "documents"));
|
|
16521
16575
|
attachResourceDirectoryCommands(knowledge, {
|
|
16522
16576
|
kind: "knowledge",
|
|
@@ -16524,7 +16578,7 @@ function attachProtocolCommands(program2) {
|
|
|
16524
16578
|
folders: "listKnowledgeFolders",
|
|
16525
16579
|
createFolder: "createKnowledgeFolder"
|
|
16526
16580
|
});
|
|
16527
|
-
const tables = group(
|
|
16581
|
+
const tables = group(program, "tables");
|
|
16528
16582
|
attachTableImport(tables);
|
|
16529
16583
|
attachResourceDirectoryCommands(tables, {
|
|
16530
16584
|
kind: "table",
|
|
@@ -16532,7 +16586,7 @@ function attachProtocolCommands(program2) {
|
|
|
16532
16586
|
folders: "listTableFolders",
|
|
16533
16587
|
createFolder: "createTableFolder"
|
|
16534
16588
|
});
|
|
16535
|
-
const workflows = group(
|
|
16589
|
+
const workflows = group(program, "workflows");
|
|
16536
16590
|
attachResourceDirectoryCommands(workflows, {
|
|
16537
16591
|
kind: "workflow",
|
|
16538
16592
|
resources: "listWorkflows",
|
|
@@ -16543,8 +16597,8 @@ function attachProtocolCommands(program2) {
|
|
|
16543
16597
|
const runs = group(workflows, "runs");
|
|
16544
16598
|
attachWorkflowRunGet(runs);
|
|
16545
16599
|
attachWorkflowRunWait(runs);
|
|
16546
|
-
attachLogsFollow(group(
|
|
16547
|
-
attachChat(
|
|
16600
|
+
attachLogsFollow(group(program, "logs"));
|
|
16601
|
+
attachChat(program);
|
|
16548
16602
|
}
|
|
16549
16603
|
|
|
16550
16604
|
// src/terminal/secret-input.ts
|
|
@@ -16576,7 +16630,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16576
16630
|
emitKeypressEvents(input);
|
|
16577
16631
|
input.setRawMode(true);
|
|
16578
16632
|
input.resume();
|
|
16579
|
-
return new Promise((
|
|
16633
|
+
return new Promise((resolve, reject) => {
|
|
16580
16634
|
const cleanup = () => {
|
|
16581
16635
|
input.removeListener("keypress", onKeypress);
|
|
16582
16636
|
input.setRawMode(wasRaw);
|
|
@@ -16597,7 +16651,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16597
16651
|
};
|
|
16598
16652
|
const fail = (message) => finish(() => reject(new SimApiError(message, 0)));
|
|
16599
16653
|
const cancel = () => finish(() => reject(new SecretInputCancelledError));
|
|
16600
|
-
function onKeypress(
|
|
16654
|
+
function onKeypress(text, key) {
|
|
16601
16655
|
if (key.ctrl && (key.name === "c" || key.name === "d")) {
|
|
16602
16656
|
cancel();
|
|
16603
16657
|
return;
|
|
@@ -16606,7 +16660,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16606
16660
|
if (value.length === 0)
|
|
16607
16661
|
fail("Secret value cannot be empty.");
|
|
16608
16662
|
else
|
|
16609
|
-
finish(() =>
|
|
16663
|
+
finish(() => resolve(value));
|
|
16610
16664
|
return;
|
|
16611
16665
|
}
|
|
16612
16666
|
if (key.name === "backspace") {
|
|
@@ -16618,7 +16672,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16618
16672
|
}
|
|
16619
16673
|
return;
|
|
16620
16674
|
}
|
|
16621
|
-
const entered =
|
|
16675
|
+
const entered = text || metaCharacter(key);
|
|
16622
16676
|
if (!entered || key.ctrl || key.name === "escape")
|
|
16623
16677
|
return;
|
|
16624
16678
|
if (value.length + entered.length > MAX_SECRET_LENGTH) {
|
|
@@ -16678,8 +16732,8 @@ async function readSecretValue(options) {
|
|
|
16678
16732
|
} catch (error) {
|
|
16679
16733
|
if (!(error instanceof SecretInputCancelledError))
|
|
16680
16734
|
throw error;
|
|
16681
|
-
|
|
16682
|
-
return
|
|
16735
|
+
printError(styles3().red(`Error: ${error.message}`));
|
|
16736
|
+
return exitCli(CANCELLED_EXIT_CODE);
|
|
16683
16737
|
}
|
|
16684
16738
|
}
|
|
16685
16739
|
async function setSecret(name, options, command, redactionSpellings) {
|
|
@@ -16703,8 +16757,8 @@ async function setSecret(name, options, command, redactionSpellings) {
|
|
|
16703
16757
|
});
|
|
16704
16758
|
renderResult("setSecret", profile.output, response.data, SECRET_RESULT);
|
|
16705
16759
|
}
|
|
16706
|
-
function attachSecretCommands(
|
|
16707
|
-
const secrets =
|
|
16760
|
+
function attachSecretCommands(program) {
|
|
16761
|
+
const secrets = program.commands.find((command) => command.name() === "secrets");
|
|
16708
16762
|
if (!secrets)
|
|
16709
16763
|
throw new Error("The generated secrets command group is missing");
|
|
16710
16764
|
const redactionSpellings = new Set;
|
|
@@ -16747,37 +16801,37 @@ var ROOT_VALUE_FLAGS = new Set([
|
|
|
16747
16801
|
function namesASubcommandFirst(rawArgs) {
|
|
16748
16802
|
const tokens = rawArgs.slice(2);
|
|
16749
16803
|
for (let index = 0;index < tokens.length; index += 1) {
|
|
16750
|
-
const
|
|
16751
|
-
if (
|
|
16804
|
+
const token = tokens[index];
|
|
16805
|
+
if (token === "--version" || token === "-V")
|
|
16752
16806
|
return false;
|
|
16753
|
-
if (ROOT_VALUE_FLAGS.has(
|
|
16807
|
+
if (ROOT_VALUE_FLAGS.has(token)) {
|
|
16754
16808
|
index += 1;
|
|
16755
16809
|
continue;
|
|
16756
16810
|
}
|
|
16757
|
-
if (
|
|
16811
|
+
if (token.startsWith("-"))
|
|
16758
16812
|
continue;
|
|
16759
16813
|
return true;
|
|
16760
16814
|
}
|
|
16761
16815
|
return false;
|
|
16762
16816
|
}
|
|
16763
|
-
function addVersionOption(
|
|
16764
|
-
|
|
16817
|
+
function addVersionOption(program) {
|
|
16818
|
+
program.on("option:version", (value) => {
|
|
16765
16819
|
if (value === null || value === undefined) {
|
|
16766
|
-
const { rawArgs } =
|
|
16820
|
+
const { rawArgs } = program;
|
|
16767
16821
|
if (!namesASubcommandFirst(rawArgs ?? []))
|
|
16768
16822
|
return;
|
|
16769
|
-
|
|
16823
|
+
program.error("error: --version reports the Sim CLI version and is not a command flag. A command that acts on a deployment version reads it from --to-version.");
|
|
16770
16824
|
}
|
|
16771
|
-
|
|
16825
|
+
program.error("error: --version reports the Sim CLI version and takes no value. A command that acts on a deployment version reads it from --to-version.");
|
|
16772
16826
|
});
|
|
16773
|
-
|
|
16827
|
+
program.version(cliVersion(), "-V, --version [none]", "output the version number (takes no value)");
|
|
16774
16828
|
}
|
|
16775
16829
|
function buildProgram(options = {}) {
|
|
16776
|
-
const
|
|
16777
|
-
|
|
16830
|
+
const program = options.program ?? new Command;
|
|
16831
|
+
program.name("sim").description(PROGRAM_DESCRIPTION);
|
|
16778
16832
|
if (options.version !== false)
|
|
16779
|
-
addVersionOption(
|
|
16780
|
-
|
|
16833
|
+
addVersionOption(program);
|
|
16834
|
+
program.option("-P, --profile <name>", "Profile to use (env: SIM_PROFILE)").option("--endpoint <url>", "Sim deployment to talk to (env: SIM_ENDPOINT)").option("-w, --workspace <id>", "Workspace to target (env: SIM_WORKSPACE)").addOption(new Option("--output <format>", "Output format for this command").choices([...OUTPUT_FORMATS]));
|
|
16781
16835
|
for (const command of [
|
|
16782
16836
|
loginCommand,
|
|
16783
16837
|
logoutCommand,
|
|
@@ -16785,22 +16839,22 @@ function buildProgram(options = {}) {
|
|
|
16785
16839
|
profilesCommand,
|
|
16786
16840
|
configureCommand
|
|
16787
16841
|
])
|
|
16788
|
-
|
|
16842
|
+
program.addCommand(command());
|
|
16789
16843
|
for (const command of buildGeneratedCommands()) {
|
|
16790
|
-
|
|
16844
|
+
program.addCommand(command);
|
|
16791
16845
|
}
|
|
16792
|
-
attachCredentialCommands(
|
|
16793
|
-
attachProtocolCommands(
|
|
16794
|
-
attachSecretCommands(
|
|
16795
|
-
|
|
16796
|
-
refuseHelpAfterUnknownCommand(
|
|
16797
|
-
assertNoReservedProgramFlags(
|
|
16798
|
-
return
|
|
16846
|
+
attachCredentialCommands(program);
|
|
16847
|
+
attachProtocolCommands(program);
|
|
16848
|
+
attachSecretCommands(program);
|
|
16849
|
+
program.addHelpText("after", options.helpText ?? HELP_EPILOGUE);
|
|
16850
|
+
refuseHelpAfterUnknownCommand(program);
|
|
16851
|
+
assertNoReservedProgramFlags(program);
|
|
16852
|
+
return program;
|
|
16799
16853
|
}
|
|
16800
16854
|
// src/terminal.ts
|
|
16801
|
-
async function runTerminalCli(
|
|
16855
|
+
async function runTerminalCli(program = buildProgram()) {
|
|
16802
16856
|
try {
|
|
16803
|
-
await
|
|
16857
|
+
await program.parseAsync(process.argv);
|
|
16804
16858
|
} catch (error) {
|
|
16805
16859
|
if (error instanceof ProfileConfigError) {
|
|
16806
16860
|
console.error(styles3().red(`Error: ${sanitize(error.message)}`));
|
|
@@ -16825,8 +16879,8 @@ async function runTerminalCli(program2 = buildProgram()) {
|
|
|
16825
16879
|
}
|
|
16826
16880
|
}
|
|
16827
16881
|
export {
|
|
16828
|
-
|
|
16829
|
-
buildProgram,
|
|
16882
|
+
Command,
|
|
16830
16883
|
SimApiError,
|
|
16831
|
-
|
|
16884
|
+
buildProgram,
|
|
16885
|
+
runTerminalCli
|
|
16832
16886
|
};
|