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/index.js
CHANGED
|
@@ -19,13 +19,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
return cached;
|
|
20
20
|
}
|
|
21
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(mod))
|
|
25
|
+
if (!__hasOwnProp.call(to, key))
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
29
31
|
if (canCache)
|
|
30
32
|
cache.set(mod, to);
|
|
31
33
|
return to;
|
|
@@ -34,7 +36,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
34
36
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
35
37
|
|
|
36
38
|
// ../../node_modules/commander/lib/error.js
|
|
37
|
-
var require_error = __commonJS((exports)
|
|
39
|
+
var require_error = __commonJS(function(exports) {
|
|
38
40
|
class CommanderError extends Error {
|
|
39
41
|
constructor(exitCode, code, message) {
|
|
40
42
|
super(message);
|
|
@@ -58,7 +60,7 @@ var require_error = __commonJS((exports) => {
|
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
// ../../node_modules/commander/lib/argument.js
|
|
61
|
-
var require_argument = __commonJS((exports)
|
|
63
|
+
var require_argument = __commonJS(function(exports) {
|
|
62
64
|
var { InvalidArgumentError } = require_error();
|
|
63
65
|
|
|
64
66
|
class Argument {
|
|
@@ -137,7 +139,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
137
139
|
});
|
|
138
140
|
|
|
139
141
|
// ../../node_modules/commander/lib/help.js
|
|
140
|
-
var require_help = __commonJS((exports)
|
|
142
|
+
var require_help = __commonJS(function(exports) {
|
|
141
143
|
var { humanReadableArgName } = require_argument();
|
|
142
144
|
|
|
143
145
|
class Help {
|
|
@@ -148,7 +150,7 @@ var require_help = __commonJS((exports) => {
|
|
|
148
150
|
this.showGlobalOptions = false;
|
|
149
151
|
}
|
|
150
152
|
visibleCommands(cmd) {
|
|
151
|
-
const visibleCommands = cmd.commands.filter((
|
|
153
|
+
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
152
154
|
if (cmd._hasImplicitHelpCommand()) {
|
|
153
155
|
const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
|
|
154
156
|
const helpCommand = cmd.createCommand(helpName).helpOption(false);
|
|
@@ -341,8 +343,8 @@ var require_help = __commonJS((exports) => {
|
|
|
341
343
|
output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
|
|
342
344
|
}
|
|
343
345
|
}
|
|
344
|
-
const commandList = helper.visibleCommands(cmd).map((
|
|
345
|
-
return formatItem(helper.subcommandTerm(
|
|
346
|
+
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
|
347
|
+
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
|
346
348
|
});
|
|
347
349
|
if (commandList.length > 0) {
|
|
348
350
|
output = output.concat(["Commands:", formatList(commandList), ""]);
|
|
@@ -353,16 +355,16 @@ var require_help = __commonJS((exports) => {
|
|
|
353
355
|
padWidth(cmd, helper) {
|
|
354
356
|
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
355
357
|
}
|
|
356
|
-
wrap(
|
|
358
|
+
wrap(str, width, indent, minColumnWidth = 40) {
|
|
357
359
|
const indents = " \\f\\t\\v - \uFEFF";
|
|
358
360
|
const manualIndent = new RegExp(`[\\n][${indents}]+`);
|
|
359
|
-
if (
|
|
360
|
-
return
|
|
361
|
+
if (str.match(manualIndent))
|
|
362
|
+
return str;
|
|
361
363
|
const columnWidth = width - indent;
|
|
362
364
|
if (columnWidth < minColumnWidth)
|
|
363
|
-
return
|
|
364
|
-
const leadingStr =
|
|
365
|
-
const columnText =
|
|
365
|
+
return str;
|
|
366
|
+
const leadingStr = str.slice(0, indent);
|
|
367
|
+
const columnText = str.slice(indent).replace(`\r
|
|
366
368
|
`, `
|
|
367
369
|
`);
|
|
368
370
|
const indentString = " ".repeat(indent);
|
|
@@ -384,7 +386,7 @@ var require_help = __commonJS((exports) => {
|
|
|
384
386
|
});
|
|
385
387
|
|
|
386
388
|
// ../../node_modules/commander/lib/option.js
|
|
387
|
-
var require_option = __commonJS((exports)
|
|
389
|
+
var require_option = __commonJS(function(exports) {
|
|
388
390
|
var { InvalidArgumentError } = require_error();
|
|
389
391
|
|
|
390
392
|
class Option {
|
|
@@ -512,9 +514,9 @@ var require_option = __commonJS((exports) => {
|
|
|
512
514
|
return option.negate === (negativeValue === value);
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
|
-
function camelcase(
|
|
516
|
-
return
|
|
517
|
-
return
|
|
517
|
+
function camelcase(str) {
|
|
518
|
+
return str.split("-").reduce((str, word) => {
|
|
519
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
518
520
|
});
|
|
519
521
|
}
|
|
520
522
|
function splitOptionFlags(flags) {
|
|
@@ -536,9 +538,9 @@ var require_option = __commonJS((exports) => {
|
|
|
536
538
|
});
|
|
537
539
|
|
|
538
540
|
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
539
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
541
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
540
542
|
var maxDistance = 3;
|
|
541
|
-
function
|
|
543
|
+
function editDistance(a, b) {
|
|
542
544
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
543
545
|
return Math.max(a.length, b.length);
|
|
544
546
|
const d = [];
|
|
@@ -579,7 +581,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
579
581
|
candidates.forEach((candidate) => {
|
|
580
582
|
if (candidate.length <= 1)
|
|
581
583
|
return;
|
|
582
|
-
const distance =
|
|
584
|
+
const distance = editDistance(word, candidate);
|
|
583
585
|
const length = Math.max(word.length, candidate.length);
|
|
584
586
|
const similarity = (length - distance) / length;
|
|
585
587
|
if (similarity > minSimilarity) {
|
|
@@ -609,12 +611,12 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
609
611
|
});
|
|
610
612
|
|
|
611
613
|
// ../../node_modules/commander/lib/command.js
|
|
612
|
-
var require_command = __commonJS((exports)
|
|
614
|
+
var require_command = __commonJS(function(exports) {
|
|
613
615
|
var EventEmitter = __require("events").EventEmitter;
|
|
614
616
|
var childProcess = __require("child_process");
|
|
615
617
|
var path = __require("path");
|
|
616
618
|
var fs = __require("fs");
|
|
617
|
-
var
|
|
619
|
+
var process2 = __require("process");
|
|
618
620
|
var { Argument, humanReadableArgName } = require_argument();
|
|
619
621
|
var { CommanderError } = require_error();
|
|
620
622
|
var { Help } = require_help();
|
|
@@ -656,11 +658,11 @@ var require_command = __commonJS((exports) => {
|
|
|
656
658
|
this._showHelpAfterError = false;
|
|
657
659
|
this._showSuggestionAfterError = true;
|
|
658
660
|
this._outputConfiguration = {
|
|
659
|
-
writeOut: (
|
|
660
|
-
writeErr: (
|
|
661
|
-
getOutHelpWidth: () =>
|
|
662
|
-
getErrHelpWidth: () =>
|
|
663
|
-
outputError: (
|
|
661
|
+
writeOut: (str) => process2.stdout.write(str),
|
|
662
|
+
writeErr: (str) => process2.stderr.write(str),
|
|
663
|
+
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
|
|
664
|
+
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
|
|
665
|
+
outputError: (str, write) => write(str)
|
|
664
666
|
};
|
|
665
667
|
this._hidden = false;
|
|
666
668
|
this._hasHelpOption = true;
|
|
@@ -848,7 +850,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
848
850
|
if (this._exitCallback) {
|
|
849
851
|
this._exitCallback(new CommanderError(exitCode, code, message));
|
|
850
852
|
}
|
|
851
|
-
|
|
853
|
+
process2.exit(exitCode);
|
|
852
854
|
}
|
|
853
855
|
action(fn) {
|
|
854
856
|
const listener = (args) => {
|
|
@@ -1010,35 +1012,35 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1010
1012
|
});
|
|
1011
1013
|
return source;
|
|
1012
1014
|
}
|
|
1013
|
-
_prepareUserArgs(
|
|
1014
|
-
if (
|
|
1015
|
+
_prepareUserArgs(argv2, parseOptions) {
|
|
1016
|
+
if (argv2 !== undefined && !Array.isArray(argv2)) {
|
|
1015
1017
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1016
1018
|
}
|
|
1017
1019
|
parseOptions = parseOptions || {};
|
|
1018
|
-
if (
|
|
1019
|
-
|
|
1020
|
-
if (
|
|
1020
|
+
if (argv2 === undefined) {
|
|
1021
|
+
argv2 = process2.argv;
|
|
1022
|
+
if (process2.versions && process2.versions.electron) {
|
|
1021
1023
|
parseOptions.from = "electron";
|
|
1022
1024
|
}
|
|
1023
1025
|
}
|
|
1024
|
-
this.rawArgs =
|
|
1026
|
+
this.rawArgs = argv2.slice();
|
|
1025
1027
|
let userArgs;
|
|
1026
1028
|
switch (parseOptions.from) {
|
|
1027
1029
|
case undefined:
|
|
1028
1030
|
case "node":
|
|
1029
|
-
this._scriptPath =
|
|
1030
|
-
userArgs =
|
|
1031
|
+
this._scriptPath = argv2[1];
|
|
1032
|
+
userArgs = argv2.slice(2);
|
|
1031
1033
|
break;
|
|
1032
1034
|
case "electron":
|
|
1033
|
-
if (
|
|
1034
|
-
this._scriptPath =
|
|
1035
|
-
userArgs =
|
|
1035
|
+
if (process2.defaultApp) {
|
|
1036
|
+
this._scriptPath = argv2[1];
|
|
1037
|
+
userArgs = argv2.slice(2);
|
|
1036
1038
|
} else {
|
|
1037
|
-
userArgs =
|
|
1039
|
+
userArgs = argv2.slice(1);
|
|
1038
1040
|
}
|
|
1039
1041
|
break;
|
|
1040
1042
|
case "user":
|
|
1041
|
-
userArgs =
|
|
1043
|
+
userArgs = argv2.slice(0);
|
|
1042
1044
|
break;
|
|
1043
1045
|
default:
|
|
1044
1046
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1098,23 +1100,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1098
1100
|
}
|
|
1099
1101
|
launchWithNode = sourceExt.includes(path.extname(executableFile));
|
|
1100
1102
|
let proc;
|
|
1101
|
-
if (
|
|
1103
|
+
if (process2.platform !== "win32") {
|
|
1102
1104
|
if (launchWithNode) {
|
|
1103
1105
|
args.unshift(executableFile);
|
|
1104
|
-
args = incrementNodeInspectorPort(
|
|
1105
|
-
proc = childProcess.spawn(
|
|
1106
|
+
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1107
|
+
proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
|
|
1106
1108
|
} else {
|
|
1107
1109
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1108
1110
|
}
|
|
1109
1111
|
} else {
|
|
1110
1112
|
args.unshift(executableFile);
|
|
1111
|
-
args = incrementNodeInspectorPort(
|
|
1112
|
-
proc = childProcess.spawn(
|
|
1113
|
+
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1114
|
+
proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
|
|
1113
1115
|
}
|
|
1114
1116
|
if (!proc.killed) {
|
|
1115
1117
|
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1116
1118
|
signals.forEach((signal) => {
|
|
1117
|
-
|
|
1119
|
+
process2.on(signal, () => {
|
|
1118
1120
|
if (proc.killed === false && proc.exitCode === null) {
|
|
1119
1121
|
proc.kill(signal);
|
|
1120
1122
|
}
|
|
@@ -1123,10 +1125,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1123
1125
|
}
|
|
1124
1126
|
const exitCallback = this._exitCallback;
|
|
1125
1127
|
if (!exitCallback) {
|
|
1126
|
-
proc.on("close",
|
|
1128
|
+
proc.on("close", process2.exit.bind(process2));
|
|
1127
1129
|
} else {
|
|
1128
1130
|
proc.on("close", () => {
|
|
1129
|
-
exitCallback(new CommanderError(
|
|
1131
|
+
exitCallback(new CommanderError(process2.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
|
|
1130
1132
|
});
|
|
1131
1133
|
}
|
|
1132
1134
|
proc.on("error", (err) => {
|
|
@@ -1141,7 +1143,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1141
1143
|
throw new Error(`'${executableFile}' not executable`);
|
|
1142
1144
|
}
|
|
1143
1145
|
if (!exitCallback) {
|
|
1144
|
-
|
|
1146
|
+
process2.exit(1);
|
|
1145
1147
|
} else {
|
|
1146
1148
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
1147
1149
|
wrappedError.nestedError = err;
|
|
@@ -1491,11 +1493,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1491
1493
|
}
|
|
1492
1494
|
_parseOptionsEnv() {
|
|
1493
1495
|
this.options.forEach((option) => {
|
|
1494
|
-
if (option.envVar && option.envVar in
|
|
1496
|
+
if (option.envVar && option.envVar in process2.env) {
|
|
1495
1497
|
const optionKey = option.attributeName();
|
|
1496
1498
|
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1497
1499
|
if (option.required || option.optional) {
|
|
1498
|
-
this.emit(`optionEnv:${option.name()}`,
|
|
1500
|
+
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
1499
1501
|
} else {
|
|
1500
1502
|
this.emit(`optionEnv:${option.name()}`);
|
|
1501
1503
|
}
|
|
@@ -1527,18 +1529,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1527
1529
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1528
1530
|
}
|
|
1529
1531
|
_conflictingOption(option, conflictingOption) {
|
|
1530
|
-
const findBestOptionFromValue = (
|
|
1531
|
-
const optionKey =
|
|
1532
|
+
const findBestOptionFromValue = (option) => {
|
|
1533
|
+
const optionKey = option.attributeName();
|
|
1532
1534
|
const optionValue = this.getOptionValue(optionKey);
|
|
1533
1535
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1534
1536
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1535
1537
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1536
1538
|
return negativeOption;
|
|
1537
1539
|
}
|
|
1538
|
-
return positiveOption ||
|
|
1540
|
+
return positiveOption || option;
|
|
1539
1541
|
};
|
|
1540
|
-
const getErrorMessage = (
|
|
1541
|
-
const bestOption = findBestOptionFromValue(
|
|
1542
|
+
const getErrorMessage = (option) => {
|
|
1543
|
+
const bestOption = findBestOptionFromValue(option);
|
|
1542
1544
|
const optionKey = bestOption.attributeName();
|
|
1543
1545
|
const source = this.getOptionValueSource(optionKey);
|
|
1544
1546
|
if (source === "env") {
|
|
@@ -1590,35 +1592,35 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1590
1592
|
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
1591
1593
|
this.error(message, { code: "commander.unknownCommand" });
|
|
1592
1594
|
}
|
|
1593
|
-
version(
|
|
1594
|
-
if (
|
|
1595
|
+
version(str, flags, description) {
|
|
1596
|
+
if (str === undefined)
|
|
1595
1597
|
return this._version;
|
|
1596
|
-
this._version =
|
|
1598
|
+
this._version = str;
|
|
1597
1599
|
flags = flags || "-V, --version";
|
|
1598
1600
|
description = description || "output the version number";
|
|
1599
1601
|
const versionOption = this.createOption(flags, description);
|
|
1600
1602
|
this._versionOptionName = versionOption.attributeName();
|
|
1601
1603
|
this.options.push(versionOption);
|
|
1602
1604
|
this.on("option:" + versionOption.name(), () => {
|
|
1603
|
-
this._outputConfiguration.writeOut(`${
|
|
1605
|
+
this._outputConfiguration.writeOut(`${str}
|
|
1604
1606
|
`);
|
|
1605
|
-
this._exit(0, "commander.version",
|
|
1607
|
+
this._exit(0, "commander.version", str);
|
|
1606
1608
|
});
|
|
1607
1609
|
return this;
|
|
1608
1610
|
}
|
|
1609
|
-
description(
|
|
1610
|
-
if (
|
|
1611
|
+
description(str, argsDescription) {
|
|
1612
|
+
if (str === undefined && argsDescription === undefined)
|
|
1611
1613
|
return this._description;
|
|
1612
|
-
this._description =
|
|
1614
|
+
this._description = str;
|
|
1613
1615
|
if (argsDescription) {
|
|
1614
1616
|
this._argsDescription = argsDescription;
|
|
1615
1617
|
}
|
|
1616
1618
|
return this;
|
|
1617
1619
|
}
|
|
1618
|
-
summary(
|
|
1619
|
-
if (
|
|
1620
|
+
summary(str) {
|
|
1621
|
+
if (str === undefined)
|
|
1620
1622
|
return this._summary;
|
|
1621
|
-
this._summary =
|
|
1623
|
+
this._summary = str;
|
|
1622
1624
|
return this;
|
|
1623
1625
|
}
|
|
1624
1626
|
alias(alias) {
|
|
@@ -1639,8 +1641,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1639
1641
|
aliases.forEach((alias) => this.alias(alias));
|
|
1640
1642
|
return this;
|
|
1641
1643
|
}
|
|
1642
|
-
usage(
|
|
1643
|
-
if (
|
|
1644
|
+
usage(str) {
|
|
1645
|
+
if (str === undefined) {
|
|
1644
1646
|
if (this._usage)
|
|
1645
1647
|
return this._usage;
|
|
1646
1648
|
const args = this.registeredArguments.map((arg) => {
|
|
@@ -1648,23 +1650,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1648
1650
|
});
|
|
1649
1651
|
return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
|
|
1650
1652
|
}
|
|
1651
|
-
this._usage =
|
|
1653
|
+
this._usage = str;
|
|
1652
1654
|
return this;
|
|
1653
1655
|
}
|
|
1654
|
-
name(
|
|
1655
|
-
if (
|
|
1656
|
+
name(str) {
|
|
1657
|
+
if (str === undefined)
|
|
1656
1658
|
return this._name;
|
|
1657
|
-
this._name =
|
|
1659
|
+
this._name = str;
|
|
1658
1660
|
return this;
|
|
1659
1661
|
}
|
|
1660
1662
|
nameFromFilename(filename) {
|
|
1661
1663
|
this._name = path.basename(filename, path.extname(filename));
|
|
1662
1664
|
return this;
|
|
1663
1665
|
}
|
|
1664
|
-
executableDir(
|
|
1665
|
-
if (
|
|
1666
|
+
executableDir(path) {
|
|
1667
|
+
if (path === undefined)
|
|
1666
1668
|
return this._executableDir;
|
|
1667
|
-
this._executableDir =
|
|
1669
|
+
this._executableDir = path;
|
|
1668
1670
|
return this;
|
|
1669
1671
|
}
|
|
1670
1672
|
helpInformation(contextOptions) {
|
|
@@ -1724,13 +1726,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1724
1726
|
}
|
|
1725
1727
|
help(contextOptions) {
|
|
1726
1728
|
this.outputHelp(contextOptions);
|
|
1727
|
-
let
|
|
1728
|
-
if (
|
|
1729
|
-
|
|
1729
|
+
let exitCode2 = process2.exitCode || 0;
|
|
1730
|
+
if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
1731
|
+
exitCode2 = 1;
|
|
1730
1732
|
}
|
|
1731
|
-
this._exit(
|
|
1733
|
+
this._exit(exitCode2, "commander.help", "(outputHelp)");
|
|
1732
1734
|
}
|
|
1733
|
-
addHelpText(position,
|
|
1735
|
+
addHelpText(position, text) {
|
|
1734
1736
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
1735
1737
|
if (!allowedValues.includes(position)) {
|
|
1736
1738
|
throw new Error(`Unexpected value for position to addHelpText.
|
|
@@ -1739,10 +1741,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1739
1741
|
const helpEvent = `${position}Help`;
|
|
1740
1742
|
this.on(helpEvent, (context) => {
|
|
1741
1743
|
let helpStr;
|
|
1742
|
-
if (typeof
|
|
1743
|
-
helpStr =
|
|
1744
|
+
if (typeof text === "function") {
|
|
1745
|
+
helpStr = text({ error: context.error, command: context.command });
|
|
1744
1746
|
} else {
|
|
1745
|
-
helpStr =
|
|
1747
|
+
helpStr = text;
|
|
1746
1748
|
}
|
|
1747
1749
|
if (helpStr) {
|
|
1748
1750
|
context.write(`${helpStr}
|
|
@@ -1792,7 +1794,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1792
1794
|
});
|
|
1793
1795
|
|
|
1794
1796
|
// ../../node_modules/commander/index.js
|
|
1795
|
-
var require_commander = __commonJS((exports, module)
|
|
1797
|
+
var require_commander = __commonJS(function(exports, module) {
|
|
1796
1798
|
var { Argument } = require_argument();
|
|
1797
1799
|
var { Command } = require_command();
|
|
1798
1800
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -2314,6 +2316,14 @@ function setSoftExitCode(code) {
|
|
|
2314
2316
|
process.exitCode = code;
|
|
2315
2317
|
}
|
|
2316
2318
|
var embedStore = new AsyncLocalStorage;
|
|
2319
|
+
|
|
2320
|
+
class EmbeddedExit extends Error {
|
|
2321
|
+
code;
|
|
2322
|
+
constructor(code) {
|
|
2323
|
+
super(`CLI exited with code ${code}`);
|
|
2324
|
+
this.code = code;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2317
2327
|
function embeddedProfile() {
|
|
2318
2328
|
const ctx = embedStore.getStore();
|
|
2319
2329
|
if (!ctx)
|
|
@@ -2329,6 +2339,11 @@ function embeddedProfile() {
|
|
|
2329
2339
|
sources: { endpoint: "flag", apiKey: "flag", workspaceId: "flag", output: "flag" }
|
|
2330
2340
|
};
|
|
2331
2341
|
}
|
|
2342
|
+
function exitCli(code) {
|
|
2343
|
+
if (embedStore.getStore())
|
|
2344
|
+
throw new EmbeddedExit(code);
|
|
2345
|
+
return process.exit(code);
|
|
2346
|
+
}
|
|
2332
2347
|
|
|
2333
2348
|
// src/output/presentation.ts
|
|
2334
2349
|
var plain = new Chalk({ level: 0 });
|
|
@@ -2722,6 +2737,39 @@ function resolveProfile(overrides = {}) {
|
|
|
2722
2737
|
}
|
|
2723
2738
|
};
|
|
2724
2739
|
}
|
|
2740
|
+
// src/output/io.ts
|
|
2741
|
+
import { format } from "node:util";
|
|
2742
|
+
function printLine(...args) {
|
|
2743
|
+
const context = embedStore.getStore();
|
|
2744
|
+
if (context)
|
|
2745
|
+
context.stdout.write(`${format(...args)}
|
|
2746
|
+
`);
|
|
2747
|
+
else
|
|
2748
|
+
console.log(...args);
|
|
2749
|
+
}
|
|
2750
|
+
function printError(...args) {
|
|
2751
|
+
const context = embedStore.getStore();
|
|
2752
|
+
if (context)
|
|
2753
|
+
context.stderr.write(`${format(...args)}
|
|
2754
|
+
`);
|
|
2755
|
+
else
|
|
2756
|
+
console.error(...args);
|
|
2757
|
+
}
|
|
2758
|
+
function writeStdout(chunk) {
|
|
2759
|
+
const context = embedStore.getStore();
|
|
2760
|
+
if (!context)
|
|
2761
|
+
return process.stdout.write(chunk);
|
|
2762
|
+
context.stdout.write(chunk);
|
|
2763
|
+
return true;
|
|
2764
|
+
}
|
|
2765
|
+
function writeStderr(chunk) {
|
|
2766
|
+
const context = embedStore.getStore();
|
|
2767
|
+
if (!context)
|
|
2768
|
+
return process.stderr.write(chunk);
|
|
2769
|
+
context.stderr.write(chunk);
|
|
2770
|
+
return true;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2725
2773
|
// src/version.ts
|
|
2726
2774
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2727
2775
|
function readPackageVersion() {
|
|
@@ -2748,7 +2796,7 @@ function once(key, message) {
|
|
|
2748
2796
|
if (reported.has(key))
|
|
2749
2797
|
return;
|
|
2750
2798
|
reported.add(key);
|
|
2751
|
-
|
|
2799
|
+
writeStderr(`warning: ${message}
|
|
2752
2800
|
`);
|
|
2753
2801
|
}
|
|
2754
2802
|
var PROXY_VARIABLES = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
@@ -2763,11 +2811,11 @@ function runtimeCanProxy(version) {
|
|
|
2763
2811
|
return minor >= firstSupportedMinor;
|
|
2764
2812
|
return major > FIRST_SUPPORTED_MAJOR;
|
|
2765
2813
|
}
|
|
2766
|
-
function warnIfProxyIgnored(
|
|
2767
|
-
const variable = PROXY_VARIABLES.find((name) =>
|
|
2814
|
+
function warnIfProxyIgnored(env = process.env, version = process.version) {
|
|
2815
|
+
const variable = PROXY_VARIABLES.find((name) => env[name]);
|
|
2768
2816
|
if (!variable)
|
|
2769
2817
|
return;
|
|
2770
|
-
if (
|
|
2818
|
+
if (env.NODE_USE_ENV_PROXY && runtimeCanProxy(version))
|
|
2771
2819
|
return;
|
|
2772
2820
|
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.`);
|
|
2773
2821
|
}
|
|
@@ -2879,8 +2927,8 @@ var RAISE_TIMEOUT_HINT = "Raise SIM_TIMEOUT_SECONDS, or set it to 0 to wait inde
|
|
|
2879
2927
|
function isRequestTimeout(error) {
|
|
2880
2928
|
return error instanceof DOMException && error.name === "TimeoutError";
|
|
2881
2929
|
}
|
|
2882
|
-
function resolveTimeoutMs(
|
|
2883
|
-
const raw =
|
|
2930
|
+
function resolveTimeoutMs(env = process.env) {
|
|
2931
|
+
const raw = env.SIM_TIMEOUT_SECONDS;
|
|
2884
2932
|
if (raw === undefined || raw.trim() === "")
|
|
2885
2933
|
return DEFAULT_TIMEOUT_SECONDS * 1000;
|
|
2886
2934
|
const seconds = Number(raw);
|
|
@@ -2910,12 +2958,12 @@ function combineSignals(caller, timeout) {
|
|
|
2910
2958
|
}
|
|
2911
2959
|
return controller.signal;
|
|
2912
2960
|
}
|
|
2913
|
-
function debugEnabled(
|
|
2914
|
-
const raw =
|
|
2961
|
+
function debugEnabled(env = process.env) {
|
|
2962
|
+
const raw = env.SIM_DEBUG;
|
|
2915
2963
|
return raw !== undefined && raw !== "" && raw !== "0" && raw.toLowerCase() !== "false";
|
|
2916
2964
|
}
|
|
2917
2965
|
function traceRequest(method, url, status, startedAt) {
|
|
2918
|
-
|
|
2966
|
+
writeStderr(`${styles3().dim(`[sim] ${method} ${url} → ${status} ${Math.round(performance.now() - startedAt)}ms`)}
|
|
2919
2967
|
`);
|
|
2920
2968
|
}
|
|
2921
2969
|
function withoutLeadingLabel(message, label) {
|
|
@@ -3088,17 +3136,17 @@ function redirectEndpoint(endpoint, requestPath, target) {
|
|
|
3088
3136
|
return suggested === endpoint.replace(/\/+$/, "") ? null : suggested;
|
|
3089
3137
|
}
|
|
3090
3138
|
function pageProgress() {
|
|
3091
|
-
let
|
|
3139
|
+
let reported = false;
|
|
3092
3140
|
return {
|
|
3093
3141
|
advance: (fetched) => {
|
|
3094
3142
|
if (!hasProgressTerminal())
|
|
3095
3143
|
return;
|
|
3096
|
-
|
|
3097
|
-
|
|
3144
|
+
reported = true;
|
|
3145
|
+
writeStderr(`\r${styles3().dim(`fetched ${fetched}…`)}\x1B[K`);
|
|
3098
3146
|
},
|
|
3099
3147
|
finish: () => {
|
|
3100
|
-
if (
|
|
3101
|
-
|
|
3148
|
+
if (reported)
|
|
3149
|
+
writeStderr("\r\x1B[K");
|
|
3102
3150
|
}
|
|
3103
3151
|
};
|
|
3104
3152
|
}
|
|
@@ -5771,14 +5819,14 @@ function requireDumper() {
|
|
|
5771
5819
|
let hasFoldableLine = false;
|
|
5772
5820
|
const shouldTrackWidth = lineWidth !== -1;
|
|
5773
5821
|
let previousLineBreak = -1;
|
|
5774
|
-
let
|
|
5822
|
+
let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
5775
5823
|
if (singleLineOnly || forceQuotes) {
|
|
5776
5824
|
for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
5777
5825
|
char = codePointAt(string, i);
|
|
5778
5826
|
if (!isPrintable(char)) {
|
|
5779
5827
|
return STYLE_DOUBLE;
|
|
5780
5828
|
}
|
|
5781
|
-
|
|
5829
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
5782
5830
|
prevChar = char;
|
|
5783
5831
|
}
|
|
5784
5832
|
} else {
|
|
@@ -5793,13 +5841,13 @@ function requireDumper() {
|
|
|
5793
5841
|
} else if (!isPrintable(char)) {
|
|
5794
5842
|
return STYLE_DOUBLE;
|
|
5795
5843
|
}
|
|
5796
|
-
|
|
5844
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
5797
5845
|
prevChar = char;
|
|
5798
5846
|
}
|
|
5799
5847
|
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
5800
5848
|
}
|
|
5801
5849
|
if (!hasLineBreak && !hasFoldableLine) {
|
|
5802
|
-
if (
|
|
5850
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
5803
5851
|
return STYLE_PLAIN;
|
|
5804
5852
|
}
|
|
5805
5853
|
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
@@ -6361,8 +6409,8 @@ function visibleWidth(value) {
|
|
|
6361
6409
|
return displayWidth(value);
|
|
6362
6410
|
}
|
|
6363
6411
|
function stripAnsi(value) {
|
|
6364
|
-
const
|
|
6365
|
-
return
|
|
6412
|
+
const plain = value.replace(ANSI_PATTERN, "");
|
|
6413
|
+
return plain === EMPTY_GLYPH ? "" : plain;
|
|
6366
6414
|
}
|
|
6367
6415
|
function pad(value, width) {
|
|
6368
6416
|
return value + " ".repeat(Math.max(0, width - visibleWidth(value)));
|
|
@@ -6399,36 +6447,36 @@ function renderMachine(format, raw) {
|
|
|
6399
6447
|
function printList(format, rows, columns, raw = rows) {
|
|
6400
6448
|
const machine = renderMachine(format, raw);
|
|
6401
6449
|
if (machine !== null) {
|
|
6402
|
-
|
|
6450
|
+
printLine(machine);
|
|
6403
6451
|
return;
|
|
6404
6452
|
}
|
|
6405
6453
|
if (format === "text") {
|
|
6406
6454
|
for (const row of rows) {
|
|
6407
|
-
|
|
6455
|
+
printLine(columns.map((column) => oneLine(stripAnsi(column.value(row)))).join("\t"));
|
|
6408
6456
|
}
|
|
6409
6457
|
return;
|
|
6410
6458
|
}
|
|
6411
|
-
|
|
6459
|
+
printLine(renderTable(rows, columns));
|
|
6412
6460
|
}
|
|
6413
6461
|
function printDocument(format, raw) {
|
|
6414
|
-
|
|
6462
|
+
printLine(format === "yaml" ? renderMachine("yaml", raw) : JSON.stringify(raw, null, 2));
|
|
6415
6463
|
}
|
|
6416
6464
|
function printRecord(format, fields, raw) {
|
|
6417
6465
|
const machine = renderMachine(format, raw);
|
|
6418
6466
|
if (machine !== null) {
|
|
6419
|
-
|
|
6467
|
+
printLine(machine);
|
|
6420
6468
|
return;
|
|
6421
6469
|
}
|
|
6422
6470
|
const safeFields = fields.map(([label, value]) => [safeOneLine(label), value]);
|
|
6423
6471
|
if (format === "text") {
|
|
6424
6472
|
for (const [label, value] of safeFields) {
|
|
6425
|
-
|
|
6473
|
+
printLine(`${label} ${oneLine(stripAnsi(value))}`);
|
|
6426
6474
|
}
|
|
6427
6475
|
return;
|
|
6428
6476
|
}
|
|
6429
6477
|
const width = Math.max(...safeFields.map(([label]) => visibleWidth(label)));
|
|
6430
6478
|
for (const [label, value] of safeFields) {
|
|
6431
|
-
|
|
6479
|
+
printLine(`${styles3().dim(pad(`${label}:`, width + 1))} ${clamp(oneLine(value), MAX_RECORD_WIDTH)}`);
|
|
6432
6480
|
}
|
|
6433
6481
|
}
|
|
6434
6482
|
|
|
@@ -6457,7 +6505,7 @@ import { createHash, randomBytes, randomInt } from "node:crypto";
|
|
|
6457
6505
|
|
|
6458
6506
|
// src/helpers.ts
|
|
6459
6507
|
function sleep(ms) {
|
|
6460
|
-
return new Promise((
|
|
6508
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6461
6509
|
}
|
|
6462
6510
|
|
|
6463
6511
|
// src/auth/device-flow.ts
|
|
@@ -6535,7 +6583,7 @@ async function pollForKey(endpoint, auth, signal) {
|
|
|
6535
6583
|
consecutiveTransportFailures++;
|
|
6536
6584
|
if (!warnedAboutTransport && consecutiveTransportFailures >= TRANSPORT_FAILURES_BEFORE_WARNING) {
|
|
6537
6585
|
warnedAboutTransport = true;
|
|
6538
|
-
|
|
6586
|
+
writeStderr(`Still waiting: ${endpoint} is not answering the login poll (${cause.message}). Check the endpoint; retrying until you approve or the login times out.
|
|
6539
6587
|
`);
|
|
6540
6588
|
}
|
|
6541
6589
|
}
|
|
@@ -11705,10 +11753,10 @@ async function chooseWorkspace(client) {
|
|
|
11705
11753
|
if (workspaces.length > MAX_INTERACTIVE_WORKSPACES) {
|
|
11706
11754
|
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);
|
|
11707
11755
|
}
|
|
11708
|
-
|
|
11756
|
+
printLine(`
|
|
11709
11757
|
Available workspaces:`);
|
|
11710
11758
|
for (const [index, workspace] of workspaces.entries()) {
|
|
11711
|
-
|
|
11759
|
+
printLine(` ${index + 1}) ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
11712
11760
|
}
|
|
11713
11761
|
const prompt = createInterface({ input: process.stdin, output: process.stderr });
|
|
11714
11762
|
try {
|
|
@@ -11733,10 +11781,10 @@ function addProfileCommand() {
|
|
|
11733
11781
|
auth_profile: authProfile,
|
|
11734
11782
|
workspace: normalizeWorkspaceId(workspace.id, "the workspace response")
|
|
11735
11783
|
});
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11784
|
+
printLine(styles3().green(`✓ Added profile "${safeOneLine(profileName)}" in ${configPath()}`));
|
|
11785
|
+
printLine(` Workspace: ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
11786
|
+
printLine(` Authentication: ${safeOneLine(authProfile)}`);
|
|
11787
|
+
printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
|
|
11740
11788
|
});
|
|
11741
11789
|
}
|
|
11742
11790
|
function loginCommand() {
|
|
@@ -11753,21 +11801,21 @@ function loginCommand() {
|
|
|
11753
11801
|
if (readCredentialsProfile(profile.name).api_key && !options.yes) {
|
|
11754
11802
|
const confirmed = await confirmProfileOverwrite(profile.name);
|
|
11755
11803
|
if (!confirmed) {
|
|
11756
|
-
|
|
11804
|
+
printLine(styles3().dim("Login cancelled; the existing profile was not changed."));
|
|
11757
11805
|
return;
|
|
11758
11806
|
}
|
|
11759
11807
|
}
|
|
11760
11808
|
const auth = createAuthRequest();
|
|
11761
11809
|
const url = buildApprovalUrl(profile.endpoint, auth, scope, profile.workspaceId ?? undefined);
|
|
11762
|
-
|
|
11763
|
-
|
|
11810
|
+
printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
|
|
11811
|
+
printLine(`
|
|
11764
11812
|
Pairing code: ${styles3().bold(auth.pairing)}`);
|
|
11765
|
-
|
|
11813
|
+
printLine(styles3().dim(`Confirm this code matches what the browser shows before approving.
|
|
11766
11814
|
`));
|
|
11767
|
-
|
|
11815
|
+
printLine(url);
|
|
11768
11816
|
if (options.browser)
|
|
11769
11817
|
openBrowser(url);
|
|
11770
|
-
|
|
11818
|
+
printLine(styles3().dim(`
|
|
11771
11819
|
Waiting for approval…`));
|
|
11772
11820
|
const key = await pollForKey(profile.endpoint, auth);
|
|
11773
11821
|
if (key.scope !== scope) {
|
|
@@ -11780,14 +11828,14 @@ Waiting for approval…`));
|
|
|
11780
11828
|
requireStorableKey(key.apiKey);
|
|
11781
11829
|
writeConfigProfile(profile.name, settings);
|
|
11782
11830
|
writeCredentialsProfile(profile.name, key.apiKey);
|
|
11783
|
-
|
|
11831
|
+
printLine(styles3().green(`
|
|
11784
11832
|
✓ Logged in. Key stored in ${credentialsPath()}`));
|
|
11785
11833
|
if (key.workspaceBound && key.workspaceId) {
|
|
11786
|
-
|
|
11834
|
+
printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
|
|
11787
11835
|
} else if (key.workspaceId) {
|
|
11788
|
-
|
|
11836
|
+
printLine(styles3().dim(` Personal key, defaulting to ${key.workspaceId}. Override per command with --workspace.`));
|
|
11789
11837
|
} else {
|
|
11790
|
-
|
|
11838
|
+
printLine(styles3().dim(" Personal key with no default workspace. Set one with: sim configure --set-workspace <id>"));
|
|
11791
11839
|
}
|
|
11792
11840
|
});
|
|
11793
11841
|
}
|
|
@@ -11801,10 +11849,10 @@ function logoutCommand() {
|
|
|
11801
11849
|
}
|
|
11802
11850
|
const removed = deleteProfile(profileName);
|
|
11803
11851
|
if (!removed.config && !removed.credentials) {
|
|
11804
|
-
|
|
11852
|
+
printLine(styles3().dim(`Nothing stored for profile "${safeOneLine(profileName)}".`));
|
|
11805
11853
|
return;
|
|
11806
11854
|
}
|
|
11807
|
-
|
|
11855
|
+
printLine(styles3().green(`✓ Removed profile "${safeOneLine(profileName)}".`));
|
|
11808
11856
|
return;
|
|
11809
11857
|
}
|
|
11810
11858
|
const profile = profileFrom(command);
|
|
@@ -11813,12 +11861,12 @@ function logoutCommand() {
|
|
|
11813
11861
|
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);
|
|
11814
11862
|
}
|
|
11815
11863
|
if (!readCredentialsProfile(profile.name).api_key) {
|
|
11816
|
-
|
|
11864
|
+
printLine(styles3().dim(`No stored key for profile "${safeOneLine(profile.name)}".`));
|
|
11817
11865
|
return;
|
|
11818
11866
|
}
|
|
11819
11867
|
writeCredentialsProfile(profile.name, null);
|
|
11820
|
-
|
|
11821
|
-
|
|
11868
|
+
printLine(styles3().green(`✓ Removed the stored key for profile "${safeOneLine(profile.name)}".`));
|
|
11869
|
+
printLine(styles3().dim(" The key itself is still active — revoke it in Settings → Sim API keys."));
|
|
11822
11870
|
});
|
|
11823
11871
|
}
|
|
11824
11872
|
async function readKeyType(client) {
|
|
@@ -11998,7 +12046,7 @@ function profilesCommand() {
|
|
|
11998
12046
|
const rows = listProfiles().map((name) => buildProfileRow(name, name === activeName));
|
|
11999
12047
|
if (rows.length === 0) {
|
|
12000
12048
|
if (output === "table")
|
|
12001
|
-
|
|
12049
|
+
printLine(styles3().dim("No profiles yet. Run: sim login"));
|
|
12002
12050
|
else
|
|
12003
12051
|
printList(output, rows, PROFILE_COLUMNS);
|
|
12004
12052
|
return;
|
|
@@ -12078,21 +12126,21 @@ function configureCommand() {
|
|
|
12078
12126
|
if (Object.keys(updates).length === 0) {
|
|
12079
12127
|
const current = readConfigProfile(profile.name);
|
|
12080
12128
|
if (Object.keys(current).length === 0) {
|
|
12081
|
-
|
|
12129
|
+
printLine(styles3().dim(`No settings stored for profile "${profile.name}".`));
|
|
12082
12130
|
return;
|
|
12083
12131
|
}
|
|
12084
12132
|
for (const [key, value] of Object.entries(current)) {
|
|
12085
|
-
|
|
12133
|
+
printLine(`${styles3().dim(`${key}:`)} ${value}`);
|
|
12086
12134
|
}
|
|
12087
12135
|
return;
|
|
12088
12136
|
}
|
|
12089
12137
|
const removalOnly = Object.values(updates).every((value) => value === null);
|
|
12090
12138
|
if (removalOnly && Object.keys(readConfigProfile(profile.name)).length === 0) {
|
|
12091
|
-
|
|
12139
|
+
printLine(styles3().dim(`No settings stored for profile "${profile.name}".`));
|
|
12092
12140
|
return;
|
|
12093
12141
|
}
|
|
12094
12142
|
writeConfigProfile(profile.name, updates);
|
|
12095
|
-
|
|
12143
|
+
printLine(styles3().green(`✓ Updated profile "${profile.name}" in ${configPath()}`));
|
|
12096
12144
|
});
|
|
12097
12145
|
}
|
|
12098
12146
|
|
|
@@ -13341,13 +13389,13 @@ async function localFile(path, override) {
|
|
|
13341
13389
|
embedded.identity.signal?.throwIfAborted();
|
|
13342
13390
|
if (!embedded.openFile)
|
|
13343
13391
|
throw new SimApiError("This invocation has no machine to read from", 0);
|
|
13344
|
-
const { size
|
|
13392
|
+
const { size } = await embedded.openFile(embeddedFileKey(path));
|
|
13345
13393
|
embedded.identity.signal?.throwIfAborted();
|
|
13346
|
-
if (!Number.isSafeInteger(
|
|
13394
|
+
if (!Number.isSafeInteger(size) || size < 0)
|
|
13347
13395
|
throw new SimApiError("Invalid file size", 0);
|
|
13348
|
-
if (
|
|
13396
|
+
if (size === 0)
|
|
13349
13397
|
throw new SimApiError(`${path} is empty`, 0);
|
|
13350
|
-
return { name: override ?? basename(embeddedFileKey(path)), size
|
|
13398
|
+
return { name: override ?? basename(embeddedFileKey(path)), size };
|
|
13351
13399
|
}
|
|
13352
13400
|
let size;
|
|
13353
13401
|
try {
|
|
@@ -13647,20 +13695,20 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
13647
13695
|
const headerSlot = Object.keys(headers).length > 0 ? { headers } : {};
|
|
13648
13696
|
if (spec.opaqueBody) {
|
|
13649
13697
|
if (commandSpec.bodyVariants) {
|
|
13650
|
-
const provided = commandSpec.bodyVariants.filter((
|
|
13651
|
-
const names = commandSpec.bodyVariants.map((
|
|
13698
|
+
const provided = commandSpec.bodyVariants.filter((variant) => flags[camel(variant.name)] !== undefined);
|
|
13699
|
+
const names = commandSpec.bodyVariants.map((variant) => `--${variant.name}`).join(" or ");
|
|
13652
13700
|
if (provided.length !== 1) {
|
|
13653
13701
|
throw new SimApiError(`Pass exactly one of ${names}`, 0);
|
|
13654
13702
|
}
|
|
13655
13703
|
const variant = provided[0];
|
|
13656
|
-
const
|
|
13657
|
-
if (typeof
|
|
13704
|
+
const raw = flags[camel(variant.name)];
|
|
13705
|
+
if (typeof raw !== "string")
|
|
13658
13706
|
throw new SimApiError(`--${variant.name} is required`, 0);
|
|
13659
|
-
const
|
|
13660
|
-
if (variant.kind === "object" && (!
|
|
13707
|
+
const parsed = await coerce(raw, { kind: variant.kind }, { json: true }, variant.name);
|
|
13708
|
+
if (variant.kind === "object" && (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) || variant.kind === "array" && !Array.isArray(parsed)) {
|
|
13661
13709
|
throw new SimApiError(`--${variant.name} must be a JSON ${variant.kind}`, 0);
|
|
13662
13710
|
}
|
|
13663
|
-
return { path, query, body: { ...body, [variant.property]:
|
|
13711
|
+
return { path, query, body: { ...body, [variant.property]: parsed }, ...headerSlot };
|
|
13664
13712
|
}
|
|
13665
13713
|
const raw = flags.body;
|
|
13666
13714
|
if (typeof raw !== "string")
|
|
@@ -13789,7 +13837,7 @@ function warn(kind, from, to) {
|
|
|
13789
13837
|
if (warned.has(key))
|
|
13790
13838
|
return;
|
|
13791
13839
|
warned.add(key);
|
|
13792
|
-
|
|
13840
|
+
writeStderr(`warning: ${kind} "${from}" has been renamed to "${to}". The old name still works.
|
|
13793
13841
|
`);
|
|
13794
13842
|
}
|
|
13795
13843
|
function warnRenamedCommand(from, to) {
|
|
@@ -13857,13 +13905,13 @@ function renderSpan(value, depth) {
|
|
|
13857
13905
|
const indent = " ".repeat(depth);
|
|
13858
13906
|
const detailIndent = `${indent} `;
|
|
13859
13907
|
const name = requiredText(span, "name");
|
|
13860
|
-
const
|
|
13908
|
+
const type = requiredText(span, "type");
|
|
13861
13909
|
const status = optionalText(span, "status");
|
|
13862
13910
|
const elapsed = optionalNumber(span, "durationMs") ?? optionalNumber(span, "duration");
|
|
13863
13911
|
const totalCost = costTotal(span);
|
|
13864
13912
|
const summary = [
|
|
13865
13913
|
`${indent}- ${name}`,
|
|
13866
|
-
`[${
|
|
13914
|
+
`[${type}]`,
|
|
13867
13915
|
status,
|
|
13868
13916
|
elapsed === undefined ? undefined : duration(Math.round(elapsed)),
|
|
13869
13917
|
totalCost === undefined ? undefined : `$${totalCost.toFixed(4)}`
|
|
@@ -13901,13 +13949,13 @@ function renderSpan(value, depth) {
|
|
|
13901
13949
|
function printTraceSpans(format, traceSpans) {
|
|
13902
13950
|
if (format === "json" || format === "yaml")
|
|
13903
13951
|
return;
|
|
13904
|
-
|
|
13905
|
-
|
|
13952
|
+
printLine("");
|
|
13953
|
+
printLine(format === "table" ? styles3().dim("trace:") : "trace:");
|
|
13906
13954
|
if (traceSpans.length === 0) {
|
|
13907
|
-
|
|
13955
|
+
printLine(styles3().dim(" No trace spans."));
|
|
13908
13956
|
return;
|
|
13909
13957
|
}
|
|
13910
|
-
|
|
13958
|
+
printLine(traceSpans.flatMap((span) => renderSpan(span, 0)).join(`
|
|
13911
13959
|
`));
|
|
13912
13960
|
}
|
|
13913
13961
|
|
|
@@ -14072,7 +14120,7 @@ function writePageNote(spec, envelope) {
|
|
|
14072
14120
|
const value = at(envelope, spec.pageNote.path);
|
|
14073
14121
|
if (value === undefined || value === null)
|
|
14074
14122
|
return;
|
|
14075
|
-
|
|
14123
|
+
writeStderr(styles3().dim(`${spec.pageNote.label}: ${String(value)}
|
|
14076
14124
|
`));
|
|
14077
14125
|
}
|
|
14078
14126
|
var TRUNCATION_FLAG = /^truncated$|^[A-Za-z0-9]+Truncated$/;
|
|
@@ -14105,14 +14153,14 @@ function clippedSubject(flag) {
|
|
|
14105
14153
|
}
|
|
14106
14154
|
function writeEnvelopeTruncation(envelope) {
|
|
14107
14155
|
for (const flag of responseTruncationFlags(envelope)) {
|
|
14108
|
-
|
|
14156
|
+
writeStderr(styles3().dim(`${spellOut(flag)}: the server clipped ${clippedSubject(flag)}, so the answer is incomplete
|
|
14109
14157
|
`));
|
|
14110
14158
|
}
|
|
14111
14159
|
}
|
|
14112
14160
|
function writeCursorTruncation(count, truncated) {
|
|
14113
14161
|
if (!truncated)
|
|
14114
14162
|
return;
|
|
14115
|
-
|
|
14163
|
+
writeStderr(styles3().dim(`showing the first ${count}; more results exist — re-run with --limit 0 for all
|
|
14116
14164
|
`));
|
|
14117
14165
|
}
|
|
14118
14166
|
function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
@@ -14165,8 +14213,8 @@ function runFailureMessage(operation, payload) {
|
|
|
14165
14213
|
const fallback = FAILED_RUN_STATUS_MESSAGES[status];
|
|
14166
14214
|
if (!fallback)
|
|
14167
14215
|
return null;
|
|
14168
|
-
const
|
|
14169
|
-
return safeOneLine(typeof
|
|
14216
|
+
const reported = error?.message;
|
|
14217
|
+
return safeOneLine(typeof reported === "string" && reported ? reported : fallback);
|
|
14170
14218
|
}
|
|
14171
14219
|
var BULK_OUTCOME_CHECKS = {
|
|
14172
14220
|
bulkDeleteFiles: (payload, body) => {
|
|
@@ -14201,8 +14249,8 @@ var BULK_OUTCOME_CHECKS = {
|
|
|
14201
14249
|
const requested = lengthOf(body?.chunkIds);
|
|
14202
14250
|
if (requested === 0)
|
|
14203
14251
|
return null;
|
|
14204
|
-
const
|
|
14205
|
-
return typeof
|
|
14252
|
+
const reported = payload.errors?.[0];
|
|
14253
|
+
return typeof reported === "string" && reported ? safeOneLine(reported) : `Updated nothing: none of the ${requested} requested ${requested === 1 ? "chunk" : "chunks"} matched.`;
|
|
14206
14254
|
},
|
|
14207
14255
|
deleteTableRows: (payload) => {
|
|
14208
14256
|
if (countOf(payload.deletedCount) > 0)
|
|
@@ -14248,7 +14296,7 @@ function writeResultNote(operation, payload, body) {
|
|
|
14248
14296
|
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
14249
14297
|
const message = note(record, body);
|
|
14250
14298
|
if (message)
|
|
14251
|
-
|
|
14299
|
+
writeStderr(styles3().dim(`${message}
|
|
14252
14300
|
`));
|
|
14253
14301
|
}
|
|
14254
14302
|
function bulkFailureMessage(operation, payload, body) {
|
|
@@ -14263,8 +14311,8 @@ var EXCLUSIVE_CAP_FIELDS = {
|
|
|
14263
14311
|
deleteTableRows: { cap: "limit", ids: "rowIds" }
|
|
14264
14312
|
};
|
|
14265
14313
|
function readPagedLimit(raw) {
|
|
14266
|
-
const
|
|
14267
|
-
const value =
|
|
14314
|
+
const text = String(raw ?? DEFAULT_LIMIT).trim();
|
|
14315
|
+
const value = text === "" ? Number.NaN : Number(text);
|
|
14268
14316
|
if (!Number.isInteger(value) || value < 0) {
|
|
14269
14317
|
throw new SimApiError("--limit must be a whole number of 0 or more (0 for everything)", 0);
|
|
14270
14318
|
}
|
|
@@ -14439,7 +14487,7 @@ function retypeMessage(message, spellings) {
|
|
|
14439
14487
|
}
|
|
14440
14488
|
function retypeDetails(details, spellings) {
|
|
14441
14489
|
if (Array.isArray(details))
|
|
14442
|
-
return details.map((
|
|
14490
|
+
return details.map((issue) => retypeDetails(issue, spellings));
|
|
14443
14491
|
if (!details || typeof details !== "object")
|
|
14444
14492
|
return details;
|
|
14445
14493
|
const issue = details;
|
|
@@ -14501,8 +14549,8 @@ function commandPath(command) {
|
|
|
14501
14549
|
return names.join(" ");
|
|
14502
14550
|
}
|
|
14503
14551
|
var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
|
|
14504
|
-
function looksLikeAnId(
|
|
14505
|
-
return
|
|
14552
|
+
function looksLikeAnId(token) {
|
|
14553
|
+
return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
|
|
14506
14554
|
}
|
|
14507
14555
|
function addArgumentExamples(command) {
|
|
14508
14556
|
const outputError = command.configureOutput().outputError;
|
|
@@ -14520,10 +14568,10 @@ function addArgumentExamples(command) {
|
|
|
14520
14568
|
}
|
|
14521
14569
|
if (command.registeredArguments.length === 0)
|
|
14522
14570
|
return;
|
|
14523
|
-
const
|
|
14524
|
-
if (!
|
|
14571
|
+
const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
|
|
14572
|
+
if (!token || !looksLikeAnId(token))
|
|
14525
14573
|
return;
|
|
14526
|
-
write(`Example: ${commandPath(command)} -- ${
|
|
14574
|
+
write(`Example: ${commandPath(command)} -- ${token}
|
|
14527
14575
|
`);
|
|
14528
14576
|
}
|
|
14529
14577
|
});
|
|
@@ -14539,7 +14587,7 @@ function assertNoReservedFlags(command, operation) {
|
|
|
14539
14587
|
}
|
|
14540
14588
|
}
|
|
14541
14589
|
var RESERVED_FLAG_EXEMPTIONS = new Set(["profiles add"]);
|
|
14542
|
-
function assertNoReservedProgramFlags(
|
|
14590
|
+
function assertNoReservedProgramFlags(program) {
|
|
14543
14591
|
const walk = (command, prefix) => {
|
|
14544
14592
|
const path = [...prefix, command.name()];
|
|
14545
14593
|
const name = path.join(" ");
|
|
@@ -14555,10 +14603,10 @@ function assertNoReservedProgramFlags(program2) {
|
|
|
14555
14603
|
for (const child of command.commands)
|
|
14556
14604
|
walk(child, path);
|
|
14557
14605
|
};
|
|
14558
|
-
for (const child of
|
|
14606
|
+
for (const child of program.commands)
|
|
14559
14607
|
walk(child, []);
|
|
14560
14608
|
}
|
|
14561
|
-
function refuseHelpAfterUnknownCommand(
|
|
14609
|
+
function refuseHelpAfterUnknownCommand(program) {
|
|
14562
14610
|
const walk = (command) => {
|
|
14563
14611
|
const internals = command;
|
|
14564
14612
|
const dispatchesOnly = command.commands.length > 0 && !internals._actionHandler && command.registeredArguments.length === 0;
|
|
@@ -14579,7 +14627,7 @@ function refuseHelpAfterUnknownCommand(program2) {
|
|
|
14579
14627
|
for (const child of command.commands)
|
|
14580
14628
|
walk(child);
|
|
14581
14629
|
};
|
|
14582
|
-
walk(
|
|
14630
|
+
walk(program);
|
|
14583
14631
|
}
|
|
14584
14632
|
function configureOperation(command, operation, spec) {
|
|
14585
14633
|
const operationSpec = V2_OPERATIONS[operation];
|
|
@@ -14863,8 +14911,8 @@ function acceptNameOnUpdate(credentials) {
|
|
|
14863
14911
|
options.displayName = options.name;
|
|
14864
14912
|
});
|
|
14865
14913
|
}
|
|
14866
|
-
function attachCredentialCommands(
|
|
14867
|
-
const credentials =
|
|
14914
|
+
function attachCredentialCommands(program) {
|
|
14915
|
+
const credentials = program.commands.find((command) => command.name() === "credentials");
|
|
14868
14916
|
if (!credentials)
|
|
14869
14917
|
throw new Error("The generated credentials command group is missing");
|
|
14870
14918
|
acceptNameOnUpdate(credentials);
|
|
@@ -14958,8 +15006,8 @@ function ignoreBrokenPipe(stream) {
|
|
|
14958
15006
|
stream.off("error", onError);
|
|
14959
15007
|
};
|
|
14960
15008
|
}
|
|
14961
|
-
function attachChat(
|
|
14962
|
-
|
|
15009
|
+
function attachChat(program) {
|
|
15010
|
+
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", `
|
|
14963
15011
|
Each turn prints the reply on stdout and the conversation ID on stderr; pass
|
|
14964
15012
|
that ID back with -c to continue the same conversation. With --output json or
|
|
14965
15013
|
yaml the reply is not streamed — the finished result is printed as one
|
|
@@ -14992,19 +15040,19 @@ Examples:
|
|
|
14992
15040
|
const endStreamedLine = () => {
|
|
14993
15041
|
if (streamed.length > 0 && !streamed.endsWith(`
|
|
14994
15042
|
`)) {
|
|
14995
|
-
|
|
15043
|
+
writeStdout(`
|
|
14996
15044
|
`);
|
|
14997
15045
|
streamed += `
|
|
14998
15046
|
`;
|
|
14999
15047
|
}
|
|
15000
15048
|
};
|
|
15001
|
-
const restorePipeHandling = streaming ? ignoreBrokenPipe(process.stdout) : undefined;
|
|
15049
|
+
const restorePipeHandling = streaming && !embedStore.getStore() ? ignoreBrokenPipe(process.stdout) : undefined;
|
|
15002
15050
|
try {
|
|
15003
|
-
const result = await readChatStream(response, (
|
|
15051
|
+
const result = await readChatStream(response, (content) => {
|
|
15004
15052
|
if (!streaming)
|
|
15005
15053
|
return;
|
|
15006
|
-
streamed +=
|
|
15007
|
-
|
|
15054
|
+
streamed += content;
|
|
15055
|
+
writeStdout(content);
|
|
15008
15056
|
});
|
|
15009
15057
|
if (!streaming) {
|
|
15010
15058
|
printProtocolResult(profile.output, result);
|
|
@@ -15012,11 +15060,11 @@ Examples:
|
|
|
15012
15060
|
}
|
|
15013
15061
|
const content = sanitize(result.content ?? "");
|
|
15014
15062
|
if (content.startsWith(streamed) && content.length > streamed.length) {
|
|
15015
|
-
|
|
15063
|
+
writeStdout(content.slice(streamed.length));
|
|
15016
15064
|
streamed = content;
|
|
15017
15065
|
}
|
|
15018
15066
|
endStreamedLine();
|
|
15019
|
-
|
|
15067
|
+
writeStderr(`${styles3().dim(`conversation: ${result.conversationId}`)}
|
|
15020
15068
|
`);
|
|
15021
15069
|
} catch (error) {
|
|
15022
15070
|
endStreamedLine();
|
|
@@ -15163,15 +15211,19 @@ async function saveToFile(body, target, force) {
|
|
|
15163
15211
|
}
|
|
15164
15212
|
return saveStagedFile(body, target, force);
|
|
15165
15213
|
}
|
|
15166
|
-
async function streamToStdout(body, output
|
|
15214
|
+
async function streamToStdout(body, output) {
|
|
15167
15215
|
const reader = body.getReader();
|
|
15168
15216
|
try {
|
|
15169
15217
|
while (true) {
|
|
15170
15218
|
const { done, value } = await reader.read();
|
|
15171
15219
|
if (done)
|
|
15172
15220
|
return;
|
|
15173
|
-
if (
|
|
15174
|
-
|
|
15221
|
+
if (output) {
|
|
15222
|
+
if (!output.write(value))
|
|
15223
|
+
await once2(output, "drain");
|
|
15224
|
+
} else if (!writeStdout(value)) {
|
|
15225
|
+
await once2(process.stdout, "drain");
|
|
15226
|
+
}
|
|
15175
15227
|
}
|
|
15176
15228
|
} finally {
|
|
15177
15229
|
await reader.cancel().catch(() => {});
|
|
@@ -15574,11 +15626,11 @@ function createTableWriter() {
|
|
|
15574
15626
|
if (!widths) {
|
|
15575
15627
|
widths = COLUMNS.map((column, index) => Math.min(MAX_CELL_WIDTH2, Math.max(column.floor, visibleWidth(column.header), ...lines.map((line) => visibleWidth(line[index])))));
|
|
15576
15628
|
const header = widths;
|
|
15577
|
-
|
|
15629
|
+
printLine(styles3().dim(COLUMNS.map((column, index) => pad2(column.header.toUpperCase(), header[index])).join(" ").trimEnd()));
|
|
15578
15630
|
}
|
|
15579
15631
|
const locked = widths;
|
|
15580
15632
|
for (const line of lines) {
|
|
15581
|
-
|
|
15633
|
+
printLine(line.map((cell, index) => pad2(cell, locked[index])).join(" ").trimEnd());
|
|
15582
15634
|
}
|
|
15583
15635
|
};
|
|
15584
15636
|
}
|
|
@@ -15586,13 +15638,13 @@ function createWriter(format) {
|
|
|
15586
15638
|
if (format === "json") {
|
|
15587
15639
|
return (rows) => {
|
|
15588
15640
|
for (const row of rows)
|
|
15589
|
-
|
|
15641
|
+
printLine(JSON.stringify(row));
|
|
15590
15642
|
};
|
|
15591
15643
|
}
|
|
15592
15644
|
if (format === "yaml") {
|
|
15593
15645
|
return (rows) => {
|
|
15594
15646
|
for (const row of rows) {
|
|
15595
|
-
|
|
15647
|
+
printLine(`---
|
|
15596
15648
|
${dump(row, { lineWidth: 0, noRefs: true }).trimEnd()}`);
|
|
15597
15649
|
}
|
|
15598
15650
|
};
|
|
@@ -15606,27 +15658,27 @@ ${dump(row, { lineWidth: 0, noRefs: true }).trimEnd()}`);
|
|
|
15606
15658
|
return createTableWriter();
|
|
15607
15659
|
}
|
|
15608
15660
|
function followStatus() {
|
|
15609
|
-
let
|
|
15661
|
+
let reported = false;
|
|
15610
15662
|
return {
|
|
15611
15663
|
note: (message) => {
|
|
15612
15664
|
if (!hasProgressTerminal())
|
|
15613
15665
|
return;
|
|
15614
|
-
|
|
15615
|
-
|
|
15666
|
+
reported = true;
|
|
15667
|
+
writeStderr(`\r${styles3().dim(message)}${ERASE_LINE}`);
|
|
15616
15668
|
},
|
|
15617
15669
|
warn: (message) => {
|
|
15618
|
-
if (
|
|
15619
|
-
|
|
15620
|
-
|
|
15670
|
+
if (reported) {
|
|
15671
|
+
reported = false;
|
|
15672
|
+
writeStderr(`\r${ERASE_LINE}`);
|
|
15621
15673
|
}
|
|
15622
|
-
|
|
15674
|
+
writeStderr(`warning: ${message}
|
|
15623
15675
|
`);
|
|
15624
15676
|
},
|
|
15625
15677
|
clear: () => {
|
|
15626
|
-
if (!
|
|
15678
|
+
if (!reported)
|
|
15627
15679
|
return;
|
|
15628
|
-
|
|
15629
|
-
|
|
15680
|
+
reported = false;
|
|
15681
|
+
writeStderr(`\r${ERASE_LINE}`);
|
|
15630
15682
|
}
|
|
15631
15683
|
};
|
|
15632
15684
|
}
|
|
@@ -15913,19 +15965,19 @@ function progressLine(job) {
|
|
|
15913
15965
|
}
|
|
15914
15966
|
async function watchImport(client, workspaceId, job) {
|
|
15915
15967
|
let current = job;
|
|
15916
|
-
let
|
|
15968
|
+
let reported = null;
|
|
15917
15969
|
while (!IMPORT_SETTLED.has(current.status)) {
|
|
15918
15970
|
await sleep2(IMPORT_POLL_MS);
|
|
15919
15971
|
const next = await client.request(`/api/v2/tables/imports/${encodeURIComponent(current.id)}`, { query: { workspaceId } });
|
|
15920
15972
|
current = next.data;
|
|
15921
15973
|
const line = progressLine(current);
|
|
15922
|
-
if (hasProgressTerminal() && line !==
|
|
15923
|
-
|
|
15924
|
-
|
|
15974
|
+
if (hasProgressTerminal() && line !== reported) {
|
|
15975
|
+
reported = line;
|
|
15976
|
+
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
15925
15977
|
}
|
|
15926
15978
|
}
|
|
15927
|
-
if (hasProgressTerminal() &&
|
|
15928
|
-
|
|
15979
|
+
if (hasProgressTerminal() && reported !== null)
|
|
15980
|
+
writeStderr("\r\x1B[K");
|
|
15929
15981
|
return current;
|
|
15930
15982
|
}
|
|
15931
15983
|
function validateTargetOptions(options) {
|
|
@@ -16108,16 +16160,16 @@ class Commentary {
|
|
|
16108
16160
|
constructor(sink) {
|
|
16109
16161
|
this.sink = sink;
|
|
16110
16162
|
}
|
|
16111
|
-
inline(
|
|
16112
|
-
if (
|
|
16163
|
+
inline(text) {
|
|
16164
|
+
if (text.length === 0)
|
|
16113
16165
|
return;
|
|
16114
|
-
this.sink.write(
|
|
16115
|
-
this.atLineStart =
|
|
16166
|
+
this.sink.write(text);
|
|
16167
|
+
this.atLineStart = text.endsWith(`
|
|
16116
16168
|
`);
|
|
16117
16169
|
}
|
|
16118
|
-
line(
|
|
16170
|
+
line(text) {
|
|
16119
16171
|
this.sink.write(`${this.atLineStart ? "" : `
|
|
16120
|
-
`}${
|
|
16172
|
+
`}${text}
|
|
16121
16173
|
`);
|
|
16122
16174
|
this.atLineStart = true;
|
|
16123
16175
|
}
|
|
@@ -16225,7 +16277,7 @@ async function followRun(workflowId, command) {
|
|
|
16225
16277
|
const final = await renderRunStream(response.body, {
|
|
16226
16278
|
includeThinking,
|
|
16227
16279
|
includeToolCalls,
|
|
16228
|
-
stderr:
|
|
16280
|
+
stderr: { write: writeStderr }
|
|
16229
16281
|
});
|
|
16230
16282
|
renderResult("executeWorkflow", profile.output, final, CLI_CONTRACT.executeWorkflow ?? {});
|
|
16231
16283
|
if (final.success === false) {
|
|
@@ -16422,19 +16474,19 @@ function classify(snapshot) {
|
|
|
16422
16474
|
return snapshot.status === "completed" ? "completed" : snapshot.status === "cancelled" ? "cancelled" : "failed";
|
|
16423
16475
|
}
|
|
16424
16476
|
function waitProgress() {
|
|
16425
|
-
let
|
|
16477
|
+
let reported = false;
|
|
16426
16478
|
return {
|
|
16427
16479
|
advance: (status, elapsedMs) => {
|
|
16428
16480
|
if (!hasProgressTerminal())
|
|
16429
16481
|
return;
|
|
16430
|
-
|
|
16431
|
-
|
|
16482
|
+
reported = true;
|
|
16483
|
+
writeStderr(`\r${styles3().dim(`${status} — waiting ${Math.round(elapsedMs / 1000)}s…`)}\x1B[K`);
|
|
16432
16484
|
},
|
|
16433
16485
|
finish: () => {
|
|
16434
|
-
if (!
|
|
16486
|
+
if (!reported)
|
|
16435
16487
|
return;
|
|
16436
|
-
|
|
16437
|
-
|
|
16488
|
+
reported = false;
|
|
16489
|
+
writeStderr("\r\x1B[K");
|
|
16438
16490
|
}
|
|
16439
16491
|
};
|
|
16440
16492
|
}
|
|
@@ -16478,7 +16530,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16478
16530
|
renderResult("getWorkflowRun", profile.output, runData(raw), runSpec());
|
|
16479
16531
|
const message = explain(outcome, runId, options.workflow, snapshot);
|
|
16480
16532
|
if (message)
|
|
16481
|
-
|
|
16533
|
+
printError(styles3().red(message));
|
|
16482
16534
|
setSoftExitCode(WAIT_EXIT_CODES[outcome]);
|
|
16483
16535
|
return;
|
|
16484
16536
|
}
|
|
@@ -16486,7 +16538,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16486
16538
|
if (remainingMs <= 0) {
|
|
16487
16539
|
progress.finish();
|
|
16488
16540
|
renderResult("getWorkflowRun", profile.output, runData(raw), runSpec());
|
|
16489
|
-
|
|
16541
|
+
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.`));
|
|
16490
16542
|
setSoftExitCode(WAIT_EXIT_CODES.timeout);
|
|
16491
16543
|
return;
|
|
16492
16544
|
}
|
|
@@ -16501,16 +16553,16 @@ function attachWorkflowRunWait(runs) {
|
|
|
16501
16553
|
}
|
|
16502
16554
|
|
|
16503
16555
|
// src/commands/protocol/index.ts
|
|
16504
|
-
function group(
|
|
16505
|
-
const existing =
|
|
16556
|
+
function group(program, name) {
|
|
16557
|
+
const existing = program.commands.find((command) => command.name() === name);
|
|
16506
16558
|
if (existing)
|
|
16507
16559
|
return existing;
|
|
16508
16560
|
const created = new Command(name);
|
|
16509
|
-
|
|
16561
|
+
program.addCommand(created);
|
|
16510
16562
|
return created;
|
|
16511
16563
|
}
|
|
16512
|
-
function attachProtocolCommands(
|
|
16513
|
-
const files = group(
|
|
16564
|
+
function attachProtocolCommands(program) {
|
|
16565
|
+
const files = group(program, "files");
|
|
16514
16566
|
attachFileUpload(files);
|
|
16515
16567
|
attachFileGet(files);
|
|
16516
16568
|
attachResourceDirectoryCommands(files, {
|
|
@@ -16519,7 +16571,7 @@ function attachProtocolCommands(program2) {
|
|
|
16519
16571
|
folders: "listFileFolders",
|
|
16520
16572
|
createFolder: "createFileFolder"
|
|
16521
16573
|
});
|
|
16522
|
-
const knowledge = group(
|
|
16574
|
+
const knowledge = group(program, "knowledge");
|
|
16523
16575
|
attachKnowledgeDocumentUpload(group(knowledge, "documents"));
|
|
16524
16576
|
attachResourceDirectoryCommands(knowledge, {
|
|
16525
16577
|
kind: "knowledge",
|
|
@@ -16527,7 +16579,7 @@ function attachProtocolCommands(program2) {
|
|
|
16527
16579
|
folders: "listKnowledgeFolders",
|
|
16528
16580
|
createFolder: "createKnowledgeFolder"
|
|
16529
16581
|
});
|
|
16530
|
-
const tables = group(
|
|
16582
|
+
const tables = group(program, "tables");
|
|
16531
16583
|
attachTableImport(tables);
|
|
16532
16584
|
attachResourceDirectoryCommands(tables, {
|
|
16533
16585
|
kind: "table",
|
|
@@ -16535,7 +16587,7 @@ function attachProtocolCommands(program2) {
|
|
|
16535
16587
|
folders: "listTableFolders",
|
|
16536
16588
|
createFolder: "createTableFolder"
|
|
16537
16589
|
});
|
|
16538
|
-
const workflows = group(
|
|
16590
|
+
const workflows = group(program, "workflows");
|
|
16539
16591
|
attachResourceDirectoryCommands(workflows, {
|
|
16540
16592
|
kind: "workflow",
|
|
16541
16593
|
resources: "listWorkflows",
|
|
@@ -16546,8 +16598,8 @@ function attachProtocolCommands(program2) {
|
|
|
16546
16598
|
const runs = group(workflows, "runs");
|
|
16547
16599
|
attachWorkflowRunGet(runs);
|
|
16548
16600
|
attachWorkflowRunWait(runs);
|
|
16549
|
-
attachLogsFollow(group(
|
|
16550
|
-
attachChat(
|
|
16601
|
+
attachLogsFollow(group(program, "logs"));
|
|
16602
|
+
attachChat(program);
|
|
16551
16603
|
}
|
|
16552
16604
|
|
|
16553
16605
|
// src/terminal/secret-input.ts
|
|
@@ -16579,7 +16631,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16579
16631
|
emitKeypressEvents(input);
|
|
16580
16632
|
input.setRawMode(true);
|
|
16581
16633
|
input.resume();
|
|
16582
|
-
return new Promise((
|
|
16634
|
+
return new Promise((resolve, reject) => {
|
|
16583
16635
|
const cleanup = () => {
|
|
16584
16636
|
input.removeListener("keypress", onKeypress);
|
|
16585
16637
|
input.setRawMode(wasRaw);
|
|
@@ -16600,7 +16652,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16600
16652
|
};
|
|
16601
16653
|
const fail = (message) => finish(() => reject(new SimApiError(message, 0)));
|
|
16602
16654
|
const cancel = () => finish(() => reject(new SecretInputCancelledError));
|
|
16603
|
-
function onKeypress(
|
|
16655
|
+
function onKeypress(text, key) {
|
|
16604
16656
|
if (key.ctrl && (key.name === "c" || key.name === "d")) {
|
|
16605
16657
|
cancel();
|
|
16606
16658
|
return;
|
|
@@ -16609,7 +16661,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16609
16661
|
if (value.length === 0)
|
|
16610
16662
|
fail("Secret value cannot be empty.");
|
|
16611
16663
|
else
|
|
16612
|
-
finish(() =>
|
|
16664
|
+
finish(() => resolve(value));
|
|
16613
16665
|
return;
|
|
16614
16666
|
}
|
|
16615
16667
|
if (key.name === "backspace") {
|
|
@@ -16621,7 +16673,7 @@ function promptSecret(input = process.stdin, output = process.stderr) {
|
|
|
16621
16673
|
}
|
|
16622
16674
|
return;
|
|
16623
16675
|
}
|
|
16624
|
-
const entered =
|
|
16676
|
+
const entered = text || metaCharacter(key);
|
|
16625
16677
|
if (!entered || key.ctrl || key.name === "escape")
|
|
16626
16678
|
return;
|
|
16627
16679
|
if (value.length + entered.length > MAX_SECRET_LENGTH) {
|
|
@@ -16681,8 +16733,8 @@ async function readSecretValue(options) {
|
|
|
16681
16733
|
} catch (error) {
|
|
16682
16734
|
if (!(error instanceof SecretInputCancelledError))
|
|
16683
16735
|
throw error;
|
|
16684
|
-
|
|
16685
|
-
return
|
|
16736
|
+
printError(styles3().red(`Error: ${error.message}`));
|
|
16737
|
+
return exitCli(CANCELLED_EXIT_CODE);
|
|
16686
16738
|
}
|
|
16687
16739
|
}
|
|
16688
16740
|
async function setSecret(name, options, command, redactionSpellings) {
|
|
@@ -16706,8 +16758,8 @@ async function setSecret(name, options, command, redactionSpellings) {
|
|
|
16706
16758
|
});
|
|
16707
16759
|
renderResult("setSecret", profile.output, response.data, SECRET_RESULT);
|
|
16708
16760
|
}
|
|
16709
|
-
function attachSecretCommands(
|
|
16710
|
-
const secrets =
|
|
16761
|
+
function attachSecretCommands(program) {
|
|
16762
|
+
const secrets = program.commands.find((command) => command.name() === "secrets");
|
|
16711
16763
|
if (!secrets)
|
|
16712
16764
|
throw new Error("The generated secrets command group is missing");
|
|
16713
16765
|
const redactionSpellings = new Set;
|
|
@@ -16750,37 +16802,37 @@ var ROOT_VALUE_FLAGS = new Set([
|
|
|
16750
16802
|
function namesASubcommandFirst(rawArgs) {
|
|
16751
16803
|
const tokens = rawArgs.slice(2);
|
|
16752
16804
|
for (let index = 0;index < tokens.length; index += 1) {
|
|
16753
|
-
const
|
|
16754
|
-
if (
|
|
16805
|
+
const token = tokens[index];
|
|
16806
|
+
if (token === "--version" || token === "-V")
|
|
16755
16807
|
return false;
|
|
16756
|
-
if (ROOT_VALUE_FLAGS.has(
|
|
16808
|
+
if (ROOT_VALUE_FLAGS.has(token)) {
|
|
16757
16809
|
index += 1;
|
|
16758
16810
|
continue;
|
|
16759
16811
|
}
|
|
16760
|
-
if (
|
|
16812
|
+
if (token.startsWith("-"))
|
|
16761
16813
|
continue;
|
|
16762
16814
|
return true;
|
|
16763
16815
|
}
|
|
16764
16816
|
return false;
|
|
16765
16817
|
}
|
|
16766
|
-
function addVersionOption(
|
|
16767
|
-
|
|
16818
|
+
function addVersionOption(program) {
|
|
16819
|
+
program.on("option:version", (value) => {
|
|
16768
16820
|
if (value === null || value === undefined) {
|
|
16769
|
-
const { rawArgs } =
|
|
16821
|
+
const { rawArgs } = program;
|
|
16770
16822
|
if (!namesASubcommandFirst(rawArgs ?? []))
|
|
16771
16823
|
return;
|
|
16772
|
-
|
|
16824
|
+
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.");
|
|
16773
16825
|
}
|
|
16774
|
-
|
|
16826
|
+
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.");
|
|
16775
16827
|
});
|
|
16776
|
-
|
|
16828
|
+
program.version(cliVersion(), "-V, --version [none]", "output the version number (takes no value)");
|
|
16777
16829
|
}
|
|
16778
16830
|
function buildProgram(options = {}) {
|
|
16779
|
-
const
|
|
16780
|
-
|
|
16831
|
+
const program = options.program ?? new Command;
|
|
16832
|
+
program.name("sim").description(PROGRAM_DESCRIPTION);
|
|
16781
16833
|
if (options.version !== false)
|
|
16782
|
-
addVersionOption(
|
|
16783
|
-
|
|
16834
|
+
addVersionOption(program);
|
|
16835
|
+
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]));
|
|
16784
16836
|
for (const command of [
|
|
16785
16837
|
loginCommand,
|
|
16786
16838
|
logoutCommand,
|
|
@@ -16788,23 +16840,23 @@ function buildProgram(options = {}) {
|
|
|
16788
16840
|
profilesCommand,
|
|
16789
16841
|
configureCommand
|
|
16790
16842
|
])
|
|
16791
|
-
|
|
16843
|
+
program.addCommand(command());
|
|
16792
16844
|
for (const command of buildGeneratedCommands()) {
|
|
16793
|
-
|
|
16845
|
+
program.addCommand(command);
|
|
16794
16846
|
}
|
|
16795
|
-
attachCredentialCommands(
|
|
16796
|
-
attachProtocolCommands(
|
|
16797
|
-
attachSecretCommands(
|
|
16798
|
-
|
|
16799
|
-
refuseHelpAfterUnknownCommand(
|
|
16800
|
-
assertNoReservedProgramFlags(
|
|
16801
|
-
return
|
|
16847
|
+
attachCredentialCommands(program);
|
|
16848
|
+
attachProtocolCommands(program);
|
|
16849
|
+
attachSecretCommands(program);
|
|
16850
|
+
program.addHelpText("after", options.helpText ?? HELP_EPILOGUE);
|
|
16851
|
+
refuseHelpAfterUnknownCommand(program);
|
|
16852
|
+
assertNoReservedProgramFlags(program);
|
|
16853
|
+
return program;
|
|
16802
16854
|
}
|
|
16803
16855
|
|
|
16804
16856
|
// src/terminal.ts
|
|
16805
|
-
async function runTerminalCli(
|
|
16857
|
+
async function runTerminalCli(program = buildProgram()) {
|
|
16806
16858
|
try {
|
|
16807
|
-
await
|
|
16859
|
+
await program.parseAsync(process.argv);
|
|
16808
16860
|
} catch (error) {
|
|
16809
16861
|
if (error instanceof ProfileConfigError) {
|
|
16810
16862
|
console.error(styles3().red(`Error: ${sanitize(error.message)}`));
|