sim 2.1.18-dev.132.1 → 2.1.18-preview.134.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/index.js +354 -824
- package/package.json +2 -12
- package/dist/auth/device-flow.d.ts +0 -39
- package/dist/auth/oauth-flow.d.ts +0 -119
- package/dist/auth/refresh.d.ts +0 -16
- package/dist/commands/auth.d.ts +0 -5
- package/dist/commands/configure.d.ts +0 -2
- package/dist/commands/credentials.d.ts +0 -3
- package/dist/commands/protocol/chat.d.ts +0 -11
- package/dist/commands/protocol/files-get.d.ts +0 -25
- package/dist/commands/protocol/files-upload.d.ts +0 -2
- package/dist/commands/protocol/index.d.ts +0 -3
- package/dist/commands/protocol/knowledge-document-upload.d.ts +0 -2
- package/dist/commands/protocol/knowledge-export.d.ts +0 -14
- package/dist/commands/protocol/logs-follow.d.ts +0 -39
- package/dist/commands/protocol/resource-directory.d.ts +0 -24
- package/dist/commands/protocol/result.d.ts +0 -2
- package/dist/commands/protocol/tables-import.d.ts +0 -2
- package/dist/commands/protocol/workflow-run-follow.d.ts +0 -56
- package/dist/commands/protocol/workflow-run-get.d.ts +0 -15
- package/dist/commands/protocol/workflow-run-wait.d.ts +0 -3
- package/dist/commands/protocol/workspace-operation-wait.d.ts +0 -14
- package/dist/commands/secrets.d.ts +0 -3
- package/dist/commands/telemetry.d.ts +0 -2
- package/dist/commands/update.d.ts +0 -2
- package/dist/config/index.d.ts +0 -2
- package/dist/config/ini.d.ts +0 -111
- package/dist/config/json-file.d.ts +0 -18
- package/dist/config/paths.d.ts +0 -29
- package/dist/config/profile.d.ts +0 -210
- package/dist/context.d.ts +0 -21
- package/dist/contract/commands.d.ts +0 -14
- package/dist/contract/types.d.ts +0 -306
- package/dist/embed-context.d.ts +0 -79
- package/dist/embed-output.d.ts +0 -15
- package/dist/embed.d.ts +0 -40
- package/dist/environment.d.ts +0 -22
- package/dist/generated/v2-api.d.ts +0 -15057
- package/dist/helpers.d.ts +0 -9
- package/dist/http/client.d.ts +0 -173
- package/dist/http/environment.d.ts +0 -24
- package/dist/http/ndjson.d.ts +0 -5
- package/dist/output/io.d.ts +0 -5
- package/dist/output/presentation.d.ts +0 -4
- package/dist/output/render.d.ts +0 -60
- package/dist/output/terminal-text.d.ts +0 -17
- package/dist/output/trace.d.ts +0 -3
- package/dist/output/truncation.d.ts +0 -3
- package/dist/program.d.ts +0 -21
- package/dist/runtime/build.d.ts +0 -38
- package/dist/runtime/derive.d.ts +0 -20
- package/dist/runtime/execute.d.ts +0 -32
- package/dist/runtime/naming.d.ts +0 -25
- package/dist/runtime/options.d.ts +0 -9
- package/dist/runtime/renamed.d.ts +0 -6
- package/dist/runtime/request.d.ts +0 -110
- package/dist/runtime/result.d.ts +0 -41
- package/dist/runtime/types.d.ts +0 -23
- package/dist/runtime.d.ts +0 -5
- package/dist/runtime.js +0 -21861
- package/dist/telemetry/client-info.d.ts +0 -20
- package/dist/telemetry/coding-agent.d.ts +0 -31
- package/dist/telemetry/index.d.ts +0 -4
- package/dist/telemetry/invocation.d.ts +0 -98
- package/dist/telemetry/policy.d.ts +0 -38
- package/dist/telemetry/state.d.ts +0 -47
- package/dist/telemetry/transport.d.ts +0 -47
- package/dist/terminal/secret-input.d.ts +0 -15
- package/dist/terminal.d.ts +0 -7
- package/dist/transfer/local-file.d.ts +0 -16
- package/dist/transfer/streaming-upload.d.ts +0 -16
- package/dist/transfer/upload-session.d.ts +0 -18
- package/dist/update/check.d.ts +0 -53
- package/dist/update/install.d.ts +0 -20
- package/dist/version.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -3692,12 +3692,6 @@ var applyOptions = (object, options = {}) => {
|
|
|
3692
3692
|
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
3693
3693
|
object.level = options.level === undefined ? colorLevel : options.level;
|
|
3694
3694
|
};
|
|
3695
|
-
|
|
3696
|
-
class Chalk {
|
|
3697
|
-
constructor(options) {
|
|
3698
|
-
return chalkFactory(options);
|
|
3699
|
-
}
|
|
3700
|
-
}
|
|
3701
3695
|
var chalkFactory = (options) => {
|
|
3702
3696
|
const chalk = (...strings) => strings.join(" ");
|
|
3703
3697
|
applyOptions(chalk, options);
|
|
@@ -3826,56 +3820,6 @@ var chalk = createChalk();
|
|
|
3826
3820
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
3827
3821
|
var source_default = chalk;
|
|
3828
3822
|
|
|
3829
|
-
// src/embed-context.ts
|
|
3830
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3831
|
-
function setSoftExitCode(code) {
|
|
3832
|
-
const ctx = embedStore.getStore();
|
|
3833
|
-
if (ctx)
|
|
3834
|
-
ctx.softExitCode = code;
|
|
3835
|
-
else
|
|
3836
|
-
process.exitCode = code;
|
|
3837
|
-
}
|
|
3838
|
-
var embedStore = new AsyncLocalStorage;
|
|
3839
|
-
|
|
3840
|
-
class EmbeddedExit extends Error {
|
|
3841
|
-
code;
|
|
3842
|
-
constructor(code) {
|
|
3843
|
-
super(`CLI exited with code ${code}`);
|
|
3844
|
-
this.code = code;
|
|
3845
|
-
}
|
|
3846
|
-
}
|
|
3847
|
-
function embeddedProfile() {
|
|
3848
|
-
const ctx = embedStore.getStore();
|
|
3849
|
-
if (!ctx)
|
|
3850
|
-
return null;
|
|
3851
|
-
return {
|
|
3852
|
-
name: "embedded",
|
|
3853
|
-
authProfile: "embedded",
|
|
3854
|
-
oauth: null,
|
|
3855
|
-
endpoint: ctx.identity.endpoint,
|
|
3856
|
-
apiKey: ctx.identity.apiKey,
|
|
3857
|
-
workspaceId: ctx.identity.workspaceId ?? null,
|
|
3858
|
-
output: "json",
|
|
3859
|
-
...ctx.identity.transport ? { transport: ctx.identity.transport } : {},
|
|
3860
|
-
...ctx.identity.signal ? { signal: ctx.identity.signal } : {},
|
|
3861
|
-
sources: { endpoint: "flag", credential: "flag", workspaceId: "flag", output: "flag" }
|
|
3862
|
-
};
|
|
3863
|
-
}
|
|
3864
|
-
function exitCli(code) {
|
|
3865
|
-
if (embedStore.getStore())
|
|
3866
|
-
throw new EmbeddedExit(code);
|
|
3867
|
-
return process.exit(code);
|
|
3868
|
-
}
|
|
3869
|
-
|
|
3870
|
-
// src/output/presentation.ts
|
|
3871
|
-
var plain = new Chalk({ level: 0 });
|
|
3872
|
-
function styles3() {
|
|
3873
|
-
return embedStore.getStore() ? plain : source_default;
|
|
3874
|
-
}
|
|
3875
|
-
function hasProgressTerminal() {
|
|
3876
|
-
return !embedStore.getStore() && Boolean(process.stderr.isTTY);
|
|
3877
|
-
}
|
|
3878
|
-
|
|
3879
3823
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
3880
3824
|
function getDefaultExportFromCjs(x) {
|
|
3881
3825
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -7018,6 +6962,15 @@ function getErrorMessage(value, fallback) {
|
|
|
7018
6962
|
return fallback ?? String(value);
|
|
7019
6963
|
}
|
|
7020
6964
|
|
|
6965
|
+
// ../utils/src/object.ts
|
|
6966
|
+
function omit(obj, keys) {
|
|
6967
|
+
const result = { ...obj };
|
|
6968
|
+
for (const key of keys) {
|
|
6969
|
+
delete result[key];
|
|
6970
|
+
}
|
|
6971
|
+
return result;
|
|
6972
|
+
}
|
|
6973
|
+
|
|
7021
6974
|
// src/update/install.ts
|
|
7022
6975
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
7023
6976
|
|
|
@@ -7150,22 +7103,14 @@ function childProcessEnv(strip, extra = {}) {
|
|
|
7150
7103
|
// src/version.ts
|
|
7151
7104
|
import { readFileSync } from "node:fs";
|
|
7152
7105
|
function readPackageVersion() {
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
} catch {}
|
|
7159
|
-
return "0.0.0-embedded";
|
|
7160
|
-
}
|
|
7161
|
-
var cachedVersion = null;
|
|
7162
|
-
function cliVersion() {
|
|
7163
|
-
cachedVersion ??= readPackageVersion();
|
|
7164
|
-
return cachedVersion;
|
|
7165
|
-
}
|
|
7166
|
-
function userAgent() {
|
|
7167
|
-
return `sim-cli/${cliVersion()} node/${process.versions.node} (${process.platform}; ${process.arch})`;
|
|
7106
|
+
const metadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
7107
|
+
if (typeof metadata !== "object" || metadata === null || !("version" in metadata) || typeof metadata.version !== "string") {
|
|
7108
|
+
throw new Error("CLI package metadata is missing a valid version");
|
|
7109
|
+
}
|
|
7110
|
+
return metadata.version;
|
|
7168
7111
|
}
|
|
7112
|
+
var CLI_VERSION = readPackageVersion();
|
|
7113
|
+
var USER_AGENT = `sim-cli/${CLI_VERSION} node/${process.versions.node} (${process.platform}; ${process.arch})`;
|
|
7169
7114
|
|
|
7170
7115
|
// src/update/check.ts
|
|
7171
7116
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -7298,7 +7243,7 @@ async function fetchDistTags(env, request) {
|
|
|
7298
7243
|
if (!url)
|
|
7299
7244
|
return null;
|
|
7300
7245
|
const text = await request(url, {
|
|
7301
|
-
headers: { accept: "application/json", "user-agent": `${PACKAGE_NAME}-cli/${
|
|
7246
|
+
headers: { accept: "application/json", "user-agent": `${PACKAGE_NAME}-cli/${CLI_VERSION}` },
|
|
7302
7247
|
maxResponseBytes: MAX_RESPONSE_BYTES,
|
|
7303
7248
|
timeoutMs: REGISTRY_TIMEOUT_MS
|
|
7304
7249
|
});
|
|
@@ -7370,7 +7315,7 @@ async function announceUpdateIfAvailable(options = {}) {
|
|
|
7370
7315
|
return;
|
|
7371
7316
|
if (isUnadvisableInstall(modulePath, env, cwd))
|
|
7372
7317
|
return;
|
|
7373
|
-
const currentVersion = options.currentVersion ??
|
|
7318
|
+
const currentVersion = options.currentVersion ?? CLI_VERSION;
|
|
7374
7319
|
const current = parseStableVersion(currentVersion);
|
|
7375
7320
|
if (!current)
|
|
7376
7321
|
return;
|
|
@@ -7493,7 +7438,7 @@ function parseRegistryVersion(output, manager) {
|
|
|
7493
7438
|
}
|
|
7494
7439
|
async function installUpdate(options = {}) {
|
|
7495
7440
|
const modulePath = resolveInstallationPath(options.modulePath ?? fileURLToPath2(import.meta.url));
|
|
7496
|
-
const env =
|
|
7441
|
+
const env = omit(options.env ?? process.env, ["SIM_API_KEY"]);
|
|
7497
7442
|
const normalized = modulePath.replaceAll("\\", "/").toLowerCase();
|
|
7498
7443
|
if (env.npm_command === "exec" || normalized.includes("/_npx/") || normalized.includes("/bunx-") || !normalized.endsWith("/node_modules/sim/dist/index.js")) {
|
|
7499
7444
|
throw new CliUpdateError("sim update requires a global installation. Update project dependencies with their package manager, or use sim@latest with your package runner.");
|
|
@@ -7504,7 +7449,7 @@ async function installUpdate(options = {}) {
|
|
|
7504
7449
|
}
|
|
7505
7450
|
const packageManager = manager;
|
|
7506
7451
|
const run = options.run ?? runPackageManager;
|
|
7507
|
-
const currentVersion = options.currentVersion ??
|
|
7452
|
+
const currentVersion = options.currentVersion ?? CLI_VERSION;
|
|
7508
7453
|
const current = parseReleaseVersion(currentVersion);
|
|
7509
7454
|
const target = current.channel;
|
|
7510
7455
|
const write = options.write ?? ((message) => void process.stderr.write(message));
|
|
@@ -7571,7 +7516,7 @@ async function installUpdate(options = {}) {
|
|
|
7571
7516
|
}
|
|
7572
7517
|
// src/config/profile.ts
|
|
7573
7518
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
7574
|
-
import { AsyncLocalStorage
|
|
7519
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7575
7520
|
import { createHash } from "node:crypto";
|
|
7576
7521
|
import {
|
|
7577
7522
|
chmodSync,
|
|
@@ -7905,7 +7850,7 @@ function readStoredCredential(profile) {
|
|
|
7905
7850
|
var CREDENTIALS_LOCK_STALE_MS = 30000;
|
|
7906
7851
|
var CREDENTIALS_LOCK_WAIT_MS = 20000;
|
|
7907
7852
|
var CREDENTIALS_LOCK_POLL_MS = 50;
|
|
7908
|
-
var heldLock = new
|
|
7853
|
+
var heldLock = new AsyncLocalStorage;
|
|
7909
7854
|
async function withProfileLoginLease(profile, work) {
|
|
7910
7855
|
const digest = createHash("sha256").update(profile, "utf8").digest("hex");
|
|
7911
7856
|
const path = `${credentialsPath()}.login-${digest}`;
|
|
@@ -8019,9 +7964,6 @@ function refuseBlankOverrides(overrides) {
|
|
|
8019
7964
|
}
|
|
8020
7965
|
}
|
|
8021
7966
|
function resolveProfile(overrides = {}) {
|
|
8022
|
-
const embedded = embeddedProfile();
|
|
8023
|
-
if (embedded)
|
|
8024
|
-
return embedded;
|
|
8025
7967
|
refuseBlankOverrides(overrides);
|
|
8026
7968
|
const named = overrides.profile || process.env.SIM_PROFILE;
|
|
8027
7969
|
const name = named || DEFAULT_PROFILE;
|
|
@@ -8079,39 +8021,6 @@ function resolveProfile(overrides = {}) {
|
|
|
8079
8021
|
}
|
|
8080
8022
|
};
|
|
8081
8023
|
}
|
|
8082
|
-
// src/output/io.ts
|
|
8083
|
-
import { format } from "node:util";
|
|
8084
|
-
function printLine(...args) {
|
|
8085
|
-
const context = embedStore.getStore();
|
|
8086
|
-
if (context)
|
|
8087
|
-
context.stdout.write(`${format(...args)}
|
|
8088
|
-
`);
|
|
8089
|
-
else
|
|
8090
|
-
console.log(...args);
|
|
8091
|
-
}
|
|
8092
|
-
function printError(...args) {
|
|
8093
|
-
const context = embedStore.getStore();
|
|
8094
|
-
if (context)
|
|
8095
|
-
context.stderr.write(`${format(...args)}
|
|
8096
|
-
`);
|
|
8097
|
-
else
|
|
8098
|
-
console.error(...args);
|
|
8099
|
-
}
|
|
8100
|
-
function writeStdout(chunk) {
|
|
8101
|
-
const context = embedStore.getStore();
|
|
8102
|
-
if (!context)
|
|
8103
|
-
return process.stdout.write(chunk);
|
|
8104
|
-
context.stdout.write(chunk);
|
|
8105
|
-
return true;
|
|
8106
|
-
}
|
|
8107
|
-
function writeStderr(chunk) {
|
|
8108
|
-
const context = embedStore.getStore();
|
|
8109
|
-
if (!context)
|
|
8110
|
-
return process.stderr.write(chunk);
|
|
8111
|
-
context.stderr.write(chunk);
|
|
8112
|
-
return true;
|
|
8113
|
-
}
|
|
8114
|
-
|
|
8115
8024
|
// ../utils/src/client-info.ts
|
|
8116
8025
|
var CLIENT_INFO_HEADER = "x-sim-client-info";
|
|
8117
8026
|
var SIM_SURFACES = ["web", "desktop", "cli", "sdk-js", "sdk-python"];
|
|
@@ -8283,12 +8192,12 @@ function clientInfoHeader(env = process.env) {
|
|
|
8283
8192
|
return cached;
|
|
8284
8193
|
}
|
|
8285
8194
|
function identityHeaders() {
|
|
8286
|
-
return { "user-agent":
|
|
8195
|
+
return { "user-agent": USER_AGENT, [CLIENT_INFO_HEADER]: clientInfoHeader() };
|
|
8287
8196
|
}
|
|
8288
8197
|
function buildClientInfoHeader(env) {
|
|
8289
8198
|
return formatClientInfo({
|
|
8290
8199
|
surface: "cli",
|
|
8291
|
-
version:
|
|
8200
|
+
version: CLI_VERSION,
|
|
8292
8201
|
runtime: { name: "node", version: process.versions.node },
|
|
8293
8202
|
os: process.platform,
|
|
8294
8203
|
arch: process.arch,
|
|
@@ -8305,7 +8214,7 @@ function once(key, message) {
|
|
|
8305
8214
|
if (reported.has(key))
|
|
8306
8215
|
return;
|
|
8307
8216
|
reported.add(key);
|
|
8308
|
-
|
|
8217
|
+
process.stderr.write(`warning: ${message}
|
|
8309
8218
|
`);
|
|
8310
8219
|
}
|
|
8311
8220
|
var PROXY_VARIABLES = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
@@ -8497,7 +8406,7 @@ function debugEnabled(env = process.env) {
|
|
|
8497
8406
|
return raw !== undefined && raw !== "" && raw !== "0" && raw.toLowerCase() !== "false";
|
|
8498
8407
|
}
|
|
8499
8408
|
function traceRequest(method, url, status, startedAt) {
|
|
8500
|
-
|
|
8409
|
+
process.stderr.write(`${source_default.dim(`[sim] ${method} ${url} → ${status} ${Math.round(performance.now() - startedAt)}ms`)}
|
|
8501
8410
|
`);
|
|
8502
8411
|
}
|
|
8503
8412
|
function withoutLeadingLabel(message, label) {
|
|
@@ -8625,15 +8534,12 @@ class SimClient {
|
|
|
8625
8534
|
warnIfCredentialOverCleartext(this.profile.endpoint, Boolean(credential));
|
|
8626
8535
|
const timeoutMs = resolveTimeoutMs();
|
|
8627
8536
|
const timeout = timeoutMs > 0 ? AbortSignal.timeout(timeoutMs) : undefined;
|
|
8628
|
-
const
|
|
8629
|
-
if (caller?.aborted)
|
|
8630
|
-
throw new SimApiError("Request cancelled.", 0);
|
|
8631
|
-
const signal = combineSignals(caller, timeout);
|
|
8537
|
+
const signal = combineSignals(options.signal, timeout);
|
|
8632
8538
|
const trace = debugEnabled();
|
|
8633
8539
|
const startedAt = performance.now();
|
|
8634
8540
|
let response;
|
|
8635
8541
|
try {
|
|
8636
|
-
response = await
|
|
8542
|
+
response = await fetch(url, {
|
|
8637
8543
|
method,
|
|
8638
8544
|
headers: {
|
|
8639
8545
|
...credential?.kind === "api_key" ? { "x-api-key": credential.apiKey } : {},
|
|
@@ -8650,7 +8556,7 @@ class SimClient {
|
|
|
8650
8556
|
} catch (cause) {
|
|
8651
8557
|
if (trace)
|
|
8652
8558
|
traceRequest(method, url, "failed", startedAt);
|
|
8653
|
-
if (
|
|
8559
|
+
if (options.signal?.aborted) {
|
|
8654
8560
|
throw new SimApiError("Request cancelled.", 0);
|
|
8655
8561
|
}
|
|
8656
8562
|
if (timeout?.aborted) {
|
|
@@ -8709,14 +8615,14 @@ function pageProgress() {
|
|
|
8709
8615
|
let reported = false;
|
|
8710
8616
|
return {
|
|
8711
8617
|
advance: (fetched) => {
|
|
8712
|
-
if (!
|
|
8618
|
+
if (!process.stderr.isTTY)
|
|
8713
8619
|
return;
|
|
8714
8620
|
reported = true;
|
|
8715
|
-
|
|
8621
|
+
process.stderr.write(`\r${source_default.dim(`fetched ${fetched}…`)}\x1B[K`);
|
|
8716
8622
|
},
|
|
8717
8623
|
finish: () => {
|
|
8718
8624
|
if (reported)
|
|
8719
|
-
|
|
8625
|
+
process.stderr.write("\r\x1B[K");
|
|
8720
8626
|
}
|
|
8721
8627
|
};
|
|
8722
8628
|
}
|
|
@@ -9140,6 +9046,7 @@ function isWideCodePoint(codePoint) {
|
|
|
9140
9046
|
|
|
9141
9047
|
// src/output/render.ts
|
|
9142
9048
|
var EMPTY_GLYPH = "—";
|
|
9049
|
+
var EMPTY = source_default.dim(EMPTY_GLYPH);
|
|
9143
9050
|
var ESC = String.fromCharCode(27);
|
|
9144
9051
|
var CONTROL_PATTERN = new RegExp([
|
|
9145
9052
|
`${ESC}\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\)?`,
|
|
@@ -9158,12 +9065,12 @@ function safeOneLine(value) {
|
|
|
9158
9065
|
}
|
|
9159
9066
|
function text(value) {
|
|
9160
9067
|
if (value === null || value === undefined || value === "")
|
|
9161
|
-
return
|
|
9068
|
+
return EMPTY;
|
|
9162
9069
|
return sanitize(String(value));
|
|
9163
9070
|
}
|
|
9164
9071
|
function timestamp2(value) {
|
|
9165
9072
|
if (!value)
|
|
9166
|
-
return
|
|
9073
|
+
return EMPTY;
|
|
9167
9074
|
const date = new Date(value);
|
|
9168
9075
|
if (Number.isNaN(date.getTime()))
|
|
9169
9076
|
return sanitize(String(value));
|
|
@@ -9171,12 +9078,12 @@ function timestamp2(value) {
|
|
|
9171
9078
|
}
|
|
9172
9079
|
function bool2(value) {
|
|
9173
9080
|
if (value === null || value === undefined)
|
|
9174
|
-
return
|
|
9175
|
-
return value ?
|
|
9081
|
+
return EMPTY;
|
|
9082
|
+
return value ? source_default.green("yes") : source_default.dim("no");
|
|
9176
9083
|
}
|
|
9177
9084
|
function bytes(value) {
|
|
9178
9085
|
if (value === null || value === undefined)
|
|
9179
|
-
return
|
|
9086
|
+
return EMPTY;
|
|
9180
9087
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
9181
9088
|
let size = value;
|
|
9182
9089
|
let unit = 0;
|
|
@@ -9188,7 +9095,7 @@ function bytes(value) {
|
|
|
9188
9095
|
}
|
|
9189
9096
|
function duration(ms) {
|
|
9190
9097
|
if (ms === null || ms === undefined)
|
|
9191
|
-
return
|
|
9098
|
+
return EMPTY;
|
|
9192
9099
|
if (ms < 1000)
|
|
9193
9100
|
return `${Math.round(ms)}ms`;
|
|
9194
9101
|
if (ms < 60000)
|
|
@@ -9219,11 +9126,11 @@ function clamp(value, width) {
|
|
|
9219
9126
|
}
|
|
9220
9127
|
function renderTable(rows, columns) {
|
|
9221
9128
|
if (rows.length === 0)
|
|
9222
|
-
return
|
|
9129
|
+
return source_default.dim("No results.");
|
|
9223
9130
|
const headers = columns.map((column) => sanitize(column.header));
|
|
9224
9131
|
const cells = rows.map((row) => columns.map((column) => clamp(oneLine(column.value(row)), MAX_CELL_WIDTH)));
|
|
9225
9132
|
const widths = columns.map((_column, index) => Math.max(visibleWidth(headers[index]), ...cells.map((line) => visibleWidth(line[index]))));
|
|
9226
|
-
const header = headers.map((label, index) =>
|
|
9133
|
+
const header = headers.map((label, index) => source_default.dim(pad(label.toUpperCase(), widths[index]))).join(" ").trimEnd();
|
|
9227
9134
|
const body = cells.map((line) => line.map((cell, index) => pad(cell, widths[index])).join(" ").trimEnd());
|
|
9228
9135
|
return [header, ...body].join(`
|
|
9229
9136
|
`);
|
|
@@ -9238,36 +9145,36 @@ function renderMachine(format, raw) {
|
|
|
9238
9145
|
function printList(format, rows, columns, raw = rows) {
|
|
9239
9146
|
const machine = renderMachine(format, raw);
|
|
9240
9147
|
if (machine !== null) {
|
|
9241
|
-
|
|
9148
|
+
console.log(machine);
|
|
9242
9149
|
return;
|
|
9243
9150
|
}
|
|
9244
9151
|
if (format === "text") {
|
|
9245
9152
|
for (const row of rows) {
|
|
9246
|
-
|
|
9153
|
+
console.log(columns.map((column) => oneLine(stripAnsi(column.value(row)))).join("\t"));
|
|
9247
9154
|
}
|
|
9248
9155
|
return;
|
|
9249
9156
|
}
|
|
9250
|
-
|
|
9157
|
+
console.log(renderTable(rows, columns));
|
|
9251
9158
|
}
|
|
9252
9159
|
function printDocument(format, raw) {
|
|
9253
|
-
|
|
9160
|
+
console.log(format === "yaml" ? renderMachine("yaml", raw) : JSON.stringify(raw, null, 2));
|
|
9254
9161
|
}
|
|
9255
9162
|
function printRecord(format, fields, raw) {
|
|
9256
9163
|
const machine = renderMachine(format, raw);
|
|
9257
9164
|
if (machine !== null) {
|
|
9258
|
-
|
|
9165
|
+
console.log(machine);
|
|
9259
9166
|
return;
|
|
9260
9167
|
}
|
|
9261
9168
|
const safeFields = fields.map(([label, value]) => [safeOneLine(label), value]);
|
|
9262
9169
|
if (format === "text") {
|
|
9263
9170
|
for (const [label, value] of safeFields) {
|
|
9264
|
-
|
|
9171
|
+
console.log(`${label} ${oneLine(stripAnsi(value))}`);
|
|
9265
9172
|
}
|
|
9266
9173
|
return;
|
|
9267
9174
|
}
|
|
9268
9175
|
const width = Math.max(...safeFields.map(([label]) => visibleWidth(label)));
|
|
9269
9176
|
for (const [label, value] of safeFields) {
|
|
9270
|
-
|
|
9177
|
+
console.log(`${source_default.dim(pad(`${label}:`, width + 1))} ${clamp(oneLine(value), MAX_RECORD_WIDTH)}`);
|
|
9271
9178
|
}
|
|
9272
9179
|
}
|
|
9273
9180
|
|
|
@@ -9382,7 +9289,7 @@ async function pollForKey(endpoint, auth, signal) {
|
|
|
9382
9289
|
consecutiveTransportFailures++;
|
|
9383
9290
|
if (!warnedAboutTransport && consecutiveTransportFailures >= TRANSPORT_FAILURES_BEFORE_WARNING) {
|
|
9384
9291
|
warnedAboutTransport = true;
|
|
9385
|
-
|
|
9292
|
+
process.stderr.write(`Still waiting: ${endpoint} is not answering the login poll (${cause.message}). Check the endpoint; retrying until you approve or the login times out.
|
|
9386
9293
|
`);
|
|
9387
9294
|
}
|
|
9388
9295
|
}
|
|
@@ -9513,8 +9420,8 @@ var V2_OPERATIONS = {
|
|
|
9513
9420
|
},
|
|
9514
9421
|
outputColumns: {
|
|
9515
9422
|
kind: "array",
|
|
9516
|
-
|
|
9517
|
-
describe: "Columns
|
|
9423
|
+
required: true,
|
|
9424
|
+
describe: "Columns created for producer outputs."
|
|
9518
9425
|
},
|
|
9519
9426
|
autoRun: {
|
|
9520
9427
|
kind: "boolean",
|
|
@@ -9555,7 +9462,7 @@ var V2_OPERATIONS = {
|
|
|
9555
9462
|
query: {
|
|
9556
9463
|
dryRun: {
|
|
9557
9464
|
kind: "boolean",
|
|
9558
|
-
describe: "Validate and lint without
|
|
9465
|
+
describe: "Validate and lint without persisting. The response is identical to the committed write of the same body, so a caller can inspect `lint` and then re-send the request for real. Nothing is written, no audit entry is recorded, and collaborators are not notified."
|
|
9559
9466
|
}
|
|
9560
9467
|
},
|
|
9561
9468
|
body: {
|
|
@@ -9600,7 +9507,7 @@ var V2_OPERATIONS = {
|
|
|
9600
9507
|
summary: "Delete Files",
|
|
9601
9508
|
body: {
|
|
9602
9509
|
workspaceId: { kind: "string", required: true, describe: "Workspace containing the files." },
|
|
9603
|
-
fileIds: { kind: "array", required: true, describe: "File identifiers to
|
|
9510
|
+
fileIds: { kind: "array", required: true, describe: "File identifiers to update." }
|
|
9604
9511
|
}
|
|
9605
9512
|
},
|
|
9606
9513
|
bulkDeleteTables: {
|
|
@@ -9818,7 +9725,7 @@ var V2_OPERATIONS = {
|
|
|
9818
9725
|
rowId: { kind: "string", describe: "Row whose runs should be canceled for row scope." },
|
|
9819
9726
|
filter: {
|
|
9820
9727
|
kind: "unknown",
|
|
9821
|
-
describe: "
|
|
9728
|
+
describe: "Recursive non-empty `all`/`any` groups containing groups or conditions; the root cannot be a condition. Limits: 100 members per group, 10 levels, and 500 nodes. The negating operators include nulls and absent cells, multi-select included; combine with `isNotNull` or `isNotEmpty` to exclude them. Pattern operators use `*` as the only wildcard; `%`, `_`, and backslash are literal. Select operators: single-select uses `eq`/`ne`/`in`/`nin`; multi-select uses `contains`/`ncontains`; option names resolve to IDs. Full operand rules are documented on `op`."
|
|
9822
9729
|
},
|
|
9823
9730
|
excludeRowIds: { kind: "array", describe: "Rows excluded from an all-scope cancellation." }
|
|
9824
9731
|
}
|
|
@@ -9849,11 +9756,6 @@ var V2_OPERATIONS = {
|
|
|
9849
9756
|
conversationId: {
|
|
9850
9757
|
kind: "string",
|
|
9851
9758
|
describe: "Conversation to continue; a new one starts when omitted."
|
|
9852
|
-
},
|
|
9853
|
-
effort: {
|
|
9854
|
-
kind: "enum",
|
|
9855
|
-
values: ["low", "medium", "high", "xhigh", "max"],
|
|
9856
|
-
describe: "Model effort for this turn; defaults to the deployment default (high)."
|
|
9857
9759
|
}
|
|
9858
9760
|
}
|
|
9859
9761
|
},
|
|
@@ -10416,7 +10318,7 @@ var V2_OPERATIONS = {
|
|
|
10416
10318
|
description: { kind: "string", describe: "Optional credential description." },
|
|
10417
10319
|
id: {
|
|
10418
10320
|
kind: "string",
|
|
10419
|
-
describe: "
|
|
10321
|
+
describe: "Required only when provider discovery requests a client-generated ID."
|
|
10420
10322
|
},
|
|
10421
10323
|
credentials: {
|
|
10422
10324
|
kind: "string",
|
|
@@ -10492,7 +10394,7 @@ var V2_OPERATIONS = {
|
|
|
10492
10394
|
rowIds: { kind: "array", describe: "Explicit row subset to run." },
|
|
10493
10395
|
filter: {
|
|
10494
10396
|
kind: "unknown",
|
|
10495
|
-
describe: "
|
|
10397
|
+
describe: "Recursive non-empty `all`/`any` groups containing groups or conditions; the root cannot be a condition. Limits: 100 members per group, 10 levels, and 500 nodes. The negating operators include nulls and absent cells, multi-select included; combine with `isNotNull` or `isNotEmpty` to exclude them. Pattern operators use `*` as the only wildcard; `%`, `_`, and backslash are literal. Select operators: single-select uses `eq`/`ne`/`in`/`nin`; multi-select uses `contains`/`ncontains`; option names resolve to IDs. Full operand rules are documented on `op`."
|
|
10496
10398
|
},
|
|
10497
10399
|
excludeRowIds: { kind: "array", describe: "Rows excluded from a select-all run scope." },
|
|
10498
10400
|
limit: { kind: "object", describe: "Optional cap on eligible rows to run." }
|
|
@@ -11026,7 +10928,7 @@ var V2_OPERATIONS = {
|
|
|
11026
10928
|
workspaceId: { kind: "string", required: true, describe: "Unique workspace identifier." },
|
|
11027
10929
|
filter: {
|
|
11028
10930
|
kind: "unknown",
|
|
11029
|
-
describe: "
|
|
10931
|
+
describe: "Recursive non-empty `all`/`any` groups containing groups or conditions; the root cannot be a condition. Limits: 100 members per group, 10 levels, and 500 nodes. The negating operators include nulls and absent cells, multi-select included; combine with `isNotNull` or `isNotEmpty` to exclude them. Pattern operators use `*` as the only wildcard; `%`, `_`, and backslash are literal. Select operators: single-select uses `eq`/`ne`/`in`/`nin`; multi-select uses `contains`/`ncontains`; option names resolve to IDs. Full operand rules are documented on `op`."
|
|
11030
10932
|
},
|
|
11031
10933
|
limit: { kind: "integer", describe: "Maximum matching rows to delete." },
|
|
11032
10934
|
rowIds: { kind: "array", describe: "Explicit row identifiers to delete." }
|
|
@@ -11275,7 +11177,7 @@ var V2_OPERATIONS = {
|
|
|
11275
11177
|
},
|
|
11276
11178
|
selectedOutputs: {
|
|
11277
11179
|
kind: "array",
|
|
11278
|
-
describe: "
|
|
11180
|
+
describe: "Output references for streaming: `<blockName>.<outputPath>` or `<childWorkflowId>.<blockName>.<outputPath>`, using normalized block names. Child references apply to every invocation. Requires `stream: true` and rejects synchronous or async requests. Use `selectedOutputs` with Get Workflow Run to narrow an existing run."
|
|
11279
11181
|
},
|
|
11280
11182
|
includeThinking: {
|
|
11281
11183
|
kind: "boolean",
|
|
@@ -11337,10 +11239,6 @@ var V2_OPERATIONS = {
|
|
|
11337
11239
|
includeReferences: {
|
|
11338
11240
|
kind: "boolean",
|
|
11339
11241
|
describe: "Include non-secret resource identifiers and source field occurrences for mapped imports."
|
|
11340
|
-
},
|
|
11341
|
-
includeWorkspaceBindings: {
|
|
11342
|
-
kind: "boolean",
|
|
11343
|
-
describe: "Whether to keep workspace-scoped bindings — table, knowledge base, document, folder, channel, and other resource selectors — in the exported state. Defaults to false, the sharing-safe export in which those ids are cleared because they resolve nowhere else. Send true for a same-workspace round trip so the re-imported workflow can run without re-selecting them. Credentials, passwords, and table sub-block values are cleared either way."
|
|
11344
11242
|
}
|
|
11345
11243
|
}
|
|
11346
11244
|
},
|
|
@@ -11589,10 +11487,6 @@ var V2_OPERATIONS = {
|
|
|
11589
11487
|
values: ["info", "error"],
|
|
11590
11488
|
describe: "Severity level to include."
|
|
11591
11489
|
},
|
|
11592
|
-
includeHandledErrors: {
|
|
11593
|
-
kind: "boolean",
|
|
11594
|
-
describe: "Whether runs with a handled block error are counted as `handledErrorRuns`, and whether `level=error` also selects them. Off by default: counting them scans each run’s stored trace."
|
|
11595
|
-
},
|
|
11596
11490
|
startDate: {
|
|
11597
11491
|
kind: "string",
|
|
11598
11492
|
describe: "Only include runs started at or after this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant."
|
|
@@ -11604,26 +11498,7 @@ var V2_OPERATIONS = {
|
|
|
11604
11498
|
segmentCount: {
|
|
11605
11499
|
kind: "integer",
|
|
11606
11500
|
default: 72,
|
|
11607
|
-
describe: "Number of
|
|
11608
|
-
},
|
|
11609
|
-
includeEmpty: {
|
|
11610
|
-
kind: "enum",
|
|
11611
|
-
values: [
|
|
11612
|
-
"true",
|
|
11613
|
-
"1",
|
|
11614
|
-
"yes",
|
|
11615
|
-
"on",
|
|
11616
|
-
"y",
|
|
11617
|
-
"enabled",
|
|
11618
|
-
"false",
|
|
11619
|
-
"0",
|
|
11620
|
-
"no",
|
|
11621
|
-
"off",
|
|
11622
|
-
"n",
|
|
11623
|
-
"disabled"
|
|
11624
|
-
],
|
|
11625
|
-
default: false,
|
|
11626
|
-
describe: "Whether buckets with no runs are included in every series. Off by default, so each series carries only the buckets that hold at least one run; set it to publish exactly `segmentCount` buckets per series, empty ones included. The listed spellings are the whole accepted vocabulary and are case-sensitive; any other value is rejected."
|
|
11501
|
+
describe: "Number of time buckets, up to 500. Exactly this many are returned, each at least one minute wide. Short windows extend past the requested end and include empty trailing buckets."
|
|
11627
11502
|
}
|
|
11628
11503
|
}
|
|
11629
11504
|
},
|
|
@@ -11681,7 +11556,7 @@ var V2_OPERATIONS = {
|
|
|
11681
11556
|
groupId: "Workflow or enrichment group to run."
|
|
11682
11557
|
},
|
|
11683
11558
|
responseMode: "json",
|
|
11684
|
-
summary: "Get
|
|
11559
|
+
summary: "Get Enrichment Run Detail",
|
|
11685
11560
|
query: {
|
|
11686
11561
|
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the table." }
|
|
11687
11562
|
}
|
|
@@ -11729,6 +11604,15 @@ var V2_OPERATIONS = {
|
|
|
11729
11604
|
"clickup.spaces",
|
|
11730
11605
|
"clickup.folders",
|
|
11731
11606
|
"clickup.lists",
|
|
11607
|
+
"coda.docs",
|
|
11608
|
+
"coda.pages",
|
|
11609
|
+
"coda.tables",
|
|
11610
|
+
"coda.columns",
|
|
11611
|
+
"coda.rows",
|
|
11612
|
+
"coda.formulas",
|
|
11613
|
+
"coda.controls",
|
|
11614
|
+
"coda.folders",
|
|
11615
|
+
"coda.permissions",
|
|
11732
11616
|
"confluence.spaces",
|
|
11733
11617
|
"confluence.spacesById",
|
|
11734
11618
|
"confluence.pages",
|
|
@@ -12291,11 +12175,7 @@ var V2_OPERATIONS = {
|
|
|
12291
12175
|
source: {
|
|
12292
12176
|
kind: "enum",
|
|
12293
12177
|
values: ["builtin", "custom"],
|
|
12294
|
-
describe: "Restrict to
|
|
12295
|
-
},
|
|
12296
|
-
includeSunset: {
|
|
12297
|
-
kind: "boolean",
|
|
12298
|
-
describe: "Include `legacy` and `deprecated` blocks. Off by default: a sunset block keeps executing where it is already placed, but it is not offered for new authoring. Each returned entry carries `sunset.replacedBy`, the block to build with instead."
|
|
12178
|
+
describe: "Restrict to built-in blocks or this workspace's deployed custom blocks."
|
|
12299
12179
|
},
|
|
12300
12180
|
sortBy: {
|
|
12301
12181
|
kind: "enum",
|
|
@@ -12372,21 +12252,6 @@ var V2_OPERATIONS = {
|
|
|
12372
12252
|
search: {
|
|
12373
12253
|
kind: "string",
|
|
12374
12254
|
describe: "Case-insensitive substring match against the connector name."
|
|
12375
|
-
},
|
|
12376
|
-
detail: {
|
|
12377
|
-
kind: "enum",
|
|
12378
|
-
values: ["summary", "full"],
|
|
12379
|
-
default: "summary",
|
|
12380
|
-
describe: "Projection of each item. `summary` (the default) carries the identifier, name, description, and auth mode; `full` adds the version, the complete auth settings, the `sourceConfig` field schema, incremental-sync support, and tag definitions."
|
|
12381
|
-
},
|
|
12382
|
-
limit: {
|
|
12383
|
-
kind: "integer",
|
|
12384
|
-
default: 25,
|
|
12385
|
-
describe: "Maximum connector types to return per page. Must be a whole number from 1 to 100. Defaults to 25."
|
|
12386
|
-
},
|
|
12387
|
-
cursor: {
|
|
12388
|
-
kind: "string",
|
|
12389
|
-
describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
|
|
12390
12255
|
}
|
|
12391
12256
|
}
|
|
12392
12257
|
},
|
|
@@ -12988,10 +12853,6 @@ var V2_OPERATIONS = {
|
|
|
12988
12853
|
kind: "string",
|
|
12989
12854
|
describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
|
|
12990
12855
|
},
|
|
12991
|
-
includeHandledErrors: {
|
|
12992
|
-
kind: "boolean",
|
|
12993
|
-
describe: "Whether `level=error` also selects runs that finished at `info` after a block error was recovered by an error path. Off by default: such a run succeeded, so it is an error only to a caller auditing error handling. Every row reports `hasHandledErrors` whether or not this is set. Job runs carry no block trace, so the flag never widens that branch."
|
|
12994
|
-
},
|
|
12995
12856
|
status: {
|
|
12996
12857
|
kind: "string",
|
|
12997
12858
|
describe: "Comma-separated execution statuses to include, from `pending` | `running` | `paused` | `redacting` | `completed` | `failed` | `cancelled`. An empty entry is rejected. ANDed with `level`, which reports severity rather than lifecycle."
|
|
@@ -13194,6 +13055,15 @@ var V2_OPERATIONS = {
|
|
|
13194
13055
|
"clickup.spaces",
|
|
13195
13056
|
"clickup.folders",
|
|
13196
13057
|
"clickup.lists",
|
|
13058
|
+
"coda.docs",
|
|
13059
|
+
"coda.pages",
|
|
13060
|
+
"coda.tables",
|
|
13061
|
+
"coda.columns",
|
|
13062
|
+
"coda.rows",
|
|
13063
|
+
"coda.formulas",
|
|
13064
|
+
"coda.controls",
|
|
13065
|
+
"coda.folders",
|
|
13066
|
+
"coda.permissions",
|
|
13197
13067
|
"confluence.spaces",
|
|
13198
13068
|
"confluence.spacesById",
|
|
13199
13069
|
"confluence.pages",
|
|
@@ -13366,7 +13236,7 @@ var V2_OPERATIONS = {
|
|
|
13366
13236
|
pathParams: ["tableId"],
|
|
13367
13237
|
pathParamDocs: { tableId: "Unique table identifier." },
|
|
13368
13238
|
responseMode: "json",
|
|
13369
|
-
summary: "List Run Dispatches",
|
|
13239
|
+
summary: "List Active Run Dispatches",
|
|
13370
13240
|
query: {
|
|
13371
13241
|
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the table." }
|
|
13372
13242
|
}
|
|
@@ -13879,8 +13749,8 @@ var V2_OPERATIONS = {
|
|
|
13879
13749
|
},
|
|
13880
13750
|
limit: {
|
|
13881
13751
|
kind: "integer",
|
|
13882
|
-
default:
|
|
13883
|
-
describe: "Maximum workspaces to return per page. Must be a whole number from 1 to 100. Defaults to
|
|
13752
|
+
default: 50,
|
|
13753
|
+
describe: "Maximum workspaces to return per page. Must be a whole number from 1 to 100. Defaults to 50."
|
|
13884
13754
|
},
|
|
13885
13755
|
cursor: {
|
|
13886
13756
|
kind: "string",
|
|
@@ -14219,9 +14089,7 @@ var V2_OPERATIONS = {
|
|
|
14219
14089
|
method: "GET",
|
|
14220
14090
|
path: "/api/v2/files/[fileId]/text",
|
|
14221
14091
|
pathParams: ["fileId"],
|
|
14222
|
-
pathParamDocs: {
|
|
14223
|
-
fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`, or `uploads/<name>` for a Chat upload."
|
|
14224
|
-
},
|
|
14092
|
+
pathParamDocs: { fileId: "File identifier." },
|
|
14225
14093
|
responseMode: "json",
|
|
14226
14094
|
summary: "Read File Text",
|
|
14227
14095
|
query: {
|
|
@@ -14252,7 +14120,7 @@ var V2_OPERATIONS = {
|
|
|
14252
14120
|
destinationPath: {
|
|
14253
14121
|
kind: "string",
|
|
14254
14122
|
required: true,
|
|
14255
|
-
describe: "
|
|
14123
|
+
describe: "New full path for the folder and its descendants."
|
|
14256
14124
|
}
|
|
14257
14125
|
}
|
|
14258
14126
|
},
|
|
@@ -14268,7 +14136,7 @@ var V2_OPERATIONS = {
|
|
|
14268
14136
|
destinationPath: {
|
|
14269
14137
|
kind: "string",
|
|
14270
14138
|
required: true,
|
|
14271
|
-
describe: "
|
|
14139
|
+
describe: "New full path for the folder and its descendants."
|
|
14272
14140
|
}
|
|
14273
14141
|
}
|
|
14274
14142
|
},
|
|
@@ -14284,7 +14152,7 @@ var V2_OPERATIONS = {
|
|
|
14284
14152
|
destinationPath: {
|
|
14285
14153
|
kind: "string",
|
|
14286
14154
|
required: true,
|
|
14287
|
-
describe: "
|
|
14155
|
+
describe: "New full path for the folder and its descendants."
|
|
14288
14156
|
}
|
|
14289
14157
|
}
|
|
14290
14158
|
},
|
|
@@ -14300,7 +14168,7 @@ var V2_OPERATIONS = {
|
|
|
14300
14168
|
destinationPath: {
|
|
14301
14169
|
kind: "string",
|
|
14302
14170
|
required: true,
|
|
14303
|
-
describe: "
|
|
14171
|
+
describe: "New full path for the folder and its descendants."
|
|
14304
14172
|
}
|
|
14305
14173
|
}
|
|
14306
14174
|
},
|
|
@@ -14380,7 +14248,7 @@ var V2_OPERATIONS = {
|
|
|
14380
14248
|
query: {
|
|
14381
14249
|
dryRun: {
|
|
14382
14250
|
kind: "boolean",
|
|
14383
|
-
describe: "Validate and lint without
|
|
14251
|
+
describe: "Validate and lint without persisting. The response is identical to the committed write of the same body, so a caller can inspect `lint` and then re-send the request for real. Nothing is written, no audit entry is recorded, and collaborators are not notified."
|
|
14384
14252
|
}
|
|
14385
14253
|
},
|
|
14386
14254
|
body: {
|
|
@@ -14689,7 +14557,7 @@ var V2_OPERATIONS = {
|
|
|
14689
14557
|
q: { kind: "string", required: true, describe: "Case-insensitive cell substring to find." },
|
|
14690
14558
|
predicate: {
|
|
14691
14559
|
kind: "unknown",
|
|
14692
|
-
describe: "
|
|
14560
|
+
describe: "Recursive non-empty `all`/`any` groups containing groups or conditions; the root cannot be a condition. Limits: 100 members per group, 10 levels, and 500 nodes. The negating operators include nulls and absent cells, multi-select included; combine with `isNotNull` or `isNotEmpty` to exclude them. Pattern operators use `*` as the only wildcard; `%`, `_`, and backslash are literal. Select operators: single-select uses `eq`/`ne`/`in`/`nin`; multi-select uses `contains`/`ncontains`; option names resolve to IDs. Full operand rules are documented on `op`."
|
|
14693
14561
|
},
|
|
14694
14562
|
sort: { kind: "array", describe: "Ordered table-row sort specification." }
|
|
14695
14563
|
}
|
|
@@ -15152,7 +15020,7 @@ var V2_OPERATIONS = {
|
|
|
15152
15020
|
filter: {
|
|
15153
15021
|
kind: "unknown",
|
|
15154
15022
|
required: true,
|
|
15155
|
-
describe: "
|
|
15023
|
+
describe: "Recursive non-empty `all`/`any` groups containing groups or conditions; the root cannot be a condition. Limits: 100 members per group, 10 levels, and 500 nodes. The negating operators include nulls and absent cells, multi-select included; combine with `isNotNull` or `isNotEmpty` to exclude them. Pattern operators use `*` as the only wildcard; `%`, `_`, and backslash are literal. Select operators: single-select uses `eq`/`ne`/`in`/`nin`; multi-select uses `contains`/`ncontains`; option names resolve to IDs. Full operand rules are documented on `op`."
|
|
15156
15024
|
},
|
|
15157
15025
|
data: {
|
|
15158
15026
|
kind: "object",
|
|
@@ -15616,10 +15484,10 @@ async function chooseWorkspace(client) {
|
|
|
15616
15484
|
if (workspaces.length > MAX_INTERACTIVE_WORKSPACES) {
|
|
15617
15485
|
throw new SimApiError(`The active credential can access more than ${MAX_INTERACTIVE_WORKSPACES} workspaces, which is too many to show interactively. Pass --workspace <id> instead.`, 0);
|
|
15618
15486
|
}
|
|
15619
|
-
|
|
15487
|
+
console.log(`
|
|
15620
15488
|
Available workspaces:`);
|
|
15621
15489
|
for (const [index, workspace] of workspaces.entries()) {
|
|
15622
|
-
|
|
15490
|
+
console.log(` ${index + 1}) ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
15623
15491
|
}
|
|
15624
15492
|
const prompt = createInterface({ input: process.stdin, output: process.stderr });
|
|
15625
15493
|
try {
|
|
@@ -15654,10 +15522,10 @@ function addProfileCommand() {
|
|
|
15654
15522
|
workspace: normalizedWorkspaceId
|
|
15655
15523
|
});
|
|
15656
15524
|
});
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15525
|
+
console.log(source_default.green(`✓ Added profile "${safeOneLine(profileName)}" in ${configPath()}`));
|
|
15526
|
+
console.log(` Workspace: ${safeOneLine(workspace.name)} (${workspace.id})`);
|
|
15527
|
+
console.log(` Authentication: ${safeOneLine(authProfile)}`);
|
|
15528
|
+
console.log(source_default.dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
|
|
15661
15529
|
});
|
|
15662
15530
|
}
|
|
15663
15531
|
async function chooseLoginFlow(profile, options) {
|
|
@@ -15665,7 +15533,7 @@ async function chooseLoginFlow(profile, options) {
|
|
|
15665
15533
|
if (options.method === "api-key")
|
|
15666
15534
|
return "handoff";
|
|
15667
15535
|
if (options.method === undefined && isLikelyRemoteSession() && options.callbackPort === undefined) {
|
|
15668
|
-
|
|
15536
|
+
console.log(source_default.dim(`This looks like a remote session; using the pairing code to create a personal API key. To use OAuth, forward a port and pass --method oauth --callback-port <port>.
|
|
15669
15537
|
`));
|
|
15670
15538
|
return "handoff";
|
|
15671
15539
|
}
|
|
@@ -15677,7 +15545,7 @@ async function chooseLoginFlow(profile, options) {
|
|
|
15677
15545
|
if (options.method === "oauth") {
|
|
15678
15546
|
throw new SimApiError(`${profile.endpoint} does not offer OAuth sign-in. Enable OAuth on the server or explicitly choose sim login --method api-key.`, 0);
|
|
15679
15547
|
}
|
|
15680
|
-
|
|
15548
|
+
console.log(source_default.dim(`${profile.endpoint} does not offer OAuth sign-in; using the pairing code to create a personal API key.
|
|
15681
15549
|
`));
|
|
15682
15550
|
return "handoff";
|
|
15683
15551
|
}
|
|
@@ -15693,16 +15561,16 @@ function parseCallbackPort(value) {
|
|
|
15693
15561
|
return port;
|
|
15694
15562
|
}
|
|
15695
15563
|
async function loginWithOAuth(profile, options, callbackPort, expected) {
|
|
15696
|
-
|
|
15564
|
+
console.log(`Signing in to ${source_default.bold(profile.endpoint)} as profile ${source_default.bold(safeOneLine(profile.name))}`);
|
|
15697
15565
|
const tokens = await loginWithBrowser(profile.endpoint, {
|
|
15698
15566
|
scopes: options.readOnly ? OAUTH_SCOPES_READ_ONLY : OAUTH_SCOPES_FULL,
|
|
15699
15567
|
callbackPort,
|
|
15700
15568
|
onAuthorizeUrl: (url) => {
|
|
15701
|
-
|
|
15569
|
+
console.log(`
|
|
15702
15570
|
${url}`);
|
|
15703
15571
|
if (options.browser)
|
|
15704
15572
|
openBrowser(url);
|
|
15705
|
-
|
|
15573
|
+
console.log(source_default.dim(`
|
|
15706
15574
|
Waiting for you to approve in the browser…`));
|
|
15707
15575
|
}
|
|
15708
15576
|
});
|
|
@@ -15734,7 +15602,7 @@ Waiting for you to approve in the browser…`));
|
|
|
15734
15602
|
try {
|
|
15735
15603
|
writeCredentialsProfile(profile.name, null);
|
|
15736
15604
|
} catch {}
|
|
15737
|
-
|
|
15605
|
+
console.log(source_default.yellow(`Could not restore the previous profile safely (${safeOneLine(getErrorMessage(rollbackError))}). Its local login was cleared to avoid using it against the wrong endpoint. The new server login will still be revoked.`));
|
|
15738
15606
|
}
|
|
15739
15607
|
throw error;
|
|
15740
15608
|
}
|
|
@@ -15743,15 +15611,15 @@ Waiting for you to approve in the browser…`));
|
|
|
15743
15611
|
try {
|
|
15744
15612
|
await revokeToken(profile.endpoint, tokens.refreshToken);
|
|
15745
15613
|
} catch (revocationError) {
|
|
15746
|
-
|
|
15614
|
+
console.log(source_default.yellow(`Could not revoke the uncommitted login (${safeOneLine(getErrorMessage(revocationError))}). Revoke Sim CLI in Settings → General → Authorized apps.`));
|
|
15747
15615
|
}
|
|
15748
15616
|
throw error;
|
|
15749
15617
|
}
|
|
15750
|
-
|
|
15618
|
+
console.log(source_default.green(`
|
|
15751
15619
|
✓ Logged in. Login stored in ${credentialsPath()}`));
|
|
15752
|
-
|
|
15620
|
+
console.log(source_default.dim(grantsWriteAccess(tokens.scope) ? " Renews itself; revoke it any time in Settings → General → Authorized apps, or with: sim logout" : " Read-only login — commands that change anything will be refused."));
|
|
15753
15621
|
if (!profile.workspaceId) {
|
|
15754
|
-
|
|
15622
|
+
console.log(source_default.dim(" No default workspace. Set one with: sim configure --set-workspace <id>"));
|
|
15755
15623
|
}
|
|
15756
15624
|
}
|
|
15757
15625
|
function loginCommand() {
|
|
@@ -15769,7 +15637,7 @@ function loginCommand() {
|
|
|
15769
15637
|
if (storedCredential && !options.yes) {
|
|
15770
15638
|
const confirmed = await confirmProfileOverwrite(profile.name);
|
|
15771
15639
|
if (!confirmed) {
|
|
15772
|
-
|
|
15640
|
+
console.log(source_default.dim("Login cancelled; the existing profile was not changed."));
|
|
15773
15641
|
return;
|
|
15774
15642
|
}
|
|
15775
15643
|
}
|
|
@@ -15796,15 +15664,15 @@ function loginCommand() {
|
|
|
15796
15664
|
async function loginWithHandoff(profile, options, expected) {
|
|
15797
15665
|
const auth = createAuthRequest();
|
|
15798
15666
|
const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined);
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
Pairing code: ${
|
|
15802
|
-
|
|
15667
|
+
console.log(`Signing in to ${source_default.bold(profile.endpoint)} as profile ${source_default.bold(safeOneLine(profile.name))}`);
|
|
15668
|
+
console.log(`
|
|
15669
|
+
Pairing code: ${source_default.bold(auth.pairing)}`);
|
|
15670
|
+
console.log(source_default.dim(`Confirm this code matches what the browser shows before approving.
|
|
15803
15671
|
`));
|
|
15804
|
-
|
|
15672
|
+
console.log(url);
|
|
15805
15673
|
if (options.browser)
|
|
15806
15674
|
openBrowser(url);
|
|
15807
|
-
|
|
15675
|
+
console.log(source_default.dim(`
|
|
15808
15676
|
Waiting for approval…`));
|
|
15809
15677
|
const key = await pollForKey(profile.endpoint, auth);
|
|
15810
15678
|
try {
|
|
@@ -15833,24 +15701,24 @@ Waiting for approval…`));
|
|
|
15833
15701
|
try {
|
|
15834
15702
|
writeCredentialsProfile(profile.name, null);
|
|
15835
15703
|
} catch {}
|
|
15836
|
-
|
|
15704
|
+
console.log(source_default.yellow(`Could not restore the previous profile safely (${safeOneLine(getErrorMessage(rollbackError))}). Its local login was cleared to avoid using it against the wrong endpoint.`));
|
|
15837
15705
|
}
|
|
15838
15706
|
throw error;
|
|
15839
15707
|
}
|
|
15840
15708
|
});
|
|
15841
15709
|
} catch (error) {
|
|
15842
15710
|
const keyId = typeof key.id === "string" && key.id ? safeOneLine(key.id) : "unknown";
|
|
15843
|
-
|
|
15711
|
+
console.log(source_default.yellow(`API key ${keyId} was created but could not be stored safely. Revoke it in Settings → API keys.`));
|
|
15844
15712
|
throw error;
|
|
15845
15713
|
}
|
|
15846
|
-
|
|
15714
|
+
console.log(source_default.green(`
|
|
15847
15715
|
✓ Logged in. Key stored in ${credentialsPath()}`));
|
|
15848
15716
|
if (key.workspaceBound && key.workspaceId) {
|
|
15849
|
-
|
|
15717
|
+
console.log(source_default.dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
|
|
15850
15718
|
} else if (key.workspaceId) {
|
|
15851
|
-
|
|
15719
|
+
console.log(source_default.dim(` Personal key, defaulting to ${key.workspaceId}. Override per command with --workspace.`));
|
|
15852
15720
|
} else {
|
|
15853
|
-
|
|
15721
|
+
console.log(source_default.dim(" Personal key with no default workspace. Set one with: sim configure --set-workspace <id>"));
|
|
15854
15722
|
}
|
|
15855
15723
|
}
|
|
15856
15724
|
async function revokeStoredOAuth(credential) {
|
|
@@ -15868,9 +15736,9 @@ async function revokeStoredOAuth(credential) {
|
|
|
15868
15736
|
const endpoint = issuer.toString().replace(/\/$/, "");
|
|
15869
15737
|
displayEndpoint = safeOneLine(endpoint);
|
|
15870
15738
|
await revokeToken(endpoint, credential.refreshToken);
|
|
15871
|
-
|
|
15739
|
+
console.log(source_default.dim(" Signed out of Sim; every token from this login was revoked."));
|
|
15872
15740
|
} catch (error) {
|
|
15873
|
-
|
|
15741
|
+
console.log(source_default.yellow(` Could not revoke the login on ${displayEndpoint} (${safeOneLine(getErrorMessage(error))}). Revoke it in Settings → General → Authorized apps.`));
|
|
15874
15742
|
}
|
|
15875
15743
|
}
|
|
15876
15744
|
function logoutCommand() {
|
|
@@ -15889,12 +15757,12 @@ function logoutCommand() {
|
|
|
15889
15757
|
return { removed: deleteProfile(profileName), credential };
|
|
15890
15758
|
});
|
|
15891
15759
|
if (!removed.config && !removed.credentials) {
|
|
15892
|
-
|
|
15760
|
+
console.log(source_default.dim(`Nothing stored for profile "${safeOneLine(profileName)}".`));
|
|
15893
15761
|
return;
|
|
15894
15762
|
}
|
|
15895
|
-
|
|
15763
|
+
console.log(source_default.green(`✓ Removed profile "${safeOneLine(profileName)}".`));
|
|
15896
15764
|
if (credential?.kind === "api_key") {
|
|
15897
|
-
|
|
15765
|
+
console.log(source_default.dim(" The key itself is still active — revoke it in Settings → API keys."));
|
|
15898
15766
|
}
|
|
15899
15767
|
return;
|
|
15900
15768
|
}
|
|
@@ -15914,12 +15782,12 @@ function logoutCommand() {
|
|
|
15914
15782
|
return credential;
|
|
15915
15783
|
});
|
|
15916
15784
|
if (!credential) {
|
|
15917
|
-
|
|
15785
|
+
console.log(source_default.dim(`No stored login for profile "${safeOneLine(profileName)}".`));
|
|
15918
15786
|
return;
|
|
15919
15787
|
}
|
|
15920
|
-
|
|
15788
|
+
console.log(source_default.green(`✓ Removed the stored login for profile "${safeOneLine(profileName)}".`));
|
|
15921
15789
|
if (credential.kind === "api_key") {
|
|
15922
|
-
|
|
15790
|
+
console.log(source_default.dim(" The key itself is still active — revoke it in Settings → API keys."));
|
|
15923
15791
|
}
|
|
15924
15792
|
});
|
|
15925
15793
|
}
|
|
@@ -15981,18 +15849,18 @@ function presentVerification(verification) {
|
|
|
15981
15849
|
if (verification.status === "verified") {
|
|
15982
15850
|
const { name, memberCount } = verification.workspace;
|
|
15983
15851
|
const members = `${memberCount} ${memberCount === 1 ? "member" : "members"}`;
|
|
15984
|
-
return `${
|
|
15852
|
+
return `${source_default.green("✓")} ${safeOneLine(name)} · ${members}`;
|
|
15985
15853
|
}
|
|
15986
15854
|
const detail = safeOneLine(verification.detail);
|
|
15987
15855
|
switch (verification.status) {
|
|
15988
15856
|
case "rejected":
|
|
15989
|
-
return `${
|
|
15857
|
+
return `${source_default.red("✗")} ${detail}`;
|
|
15990
15858
|
case "unauthenticated":
|
|
15991
|
-
return
|
|
15859
|
+
return source_default.yellow(`not logged in — ${detail}`);
|
|
15992
15860
|
case "disabled":
|
|
15993
|
-
return
|
|
15861
|
+
return source_default.dim(detail);
|
|
15994
15862
|
default:
|
|
15995
|
-
return
|
|
15863
|
+
return source_default.yellow(`could not check — ${detail}`);
|
|
15996
15864
|
}
|
|
15997
15865
|
}
|
|
15998
15866
|
function whoamiCommand() {
|
|
@@ -16006,17 +15874,17 @@ function whoamiCommand() {
|
|
|
16006
15874
|
keyType: null,
|
|
16007
15875
|
detail: "not checked (--no-verify)"
|
|
16008
15876
|
};
|
|
16009
|
-
const annotate = (value, source) => source === "unset" ?
|
|
15877
|
+
const annotate = (value, source) => source === "unset" ? source_default.dim("not set") : `${value} ${source_default.dim(`(${source})`)}`;
|
|
16010
15878
|
printRecord(profile.output, [
|
|
16011
15879
|
["Profile", profile.name],
|
|
16012
15880
|
["Endpoint", annotate(profile.endpoint, sources.endpoint)],
|
|
16013
15881
|
[
|
|
16014
15882
|
"Login",
|
|
16015
|
-
authentication.authenticated ? annotate(profile.oauth ? "OAuth" : "API key", authentication.source) :
|
|
15883
|
+
authentication.authenticated ? annotate(profile.oauth ? "OAuth" : "API key", authentication.source) : source_default.yellow("not logged in")
|
|
16016
15884
|
],
|
|
16017
15885
|
[
|
|
16018
15886
|
"Key type",
|
|
16019
|
-
verification.keyType ??
|
|
15887
|
+
verification.keyType ?? source_default.dim(options.verify ? "unknown" : "not checked (--no-verify)")
|
|
16020
15888
|
],
|
|
16021
15889
|
["Workspace", annotate(profile.workspaceId ?? "", sources.workspaceId)],
|
|
16022
15890
|
["Output", annotate(profile.output, sources.output)],
|
|
@@ -16042,15 +15910,15 @@ function whoamiCommand() {
|
|
|
16042
15910
|
});
|
|
16043
15911
|
const exitCode = WHOAMI_EXIT_CODES[verification.status];
|
|
16044
15912
|
if (exitCode !== 0)
|
|
16045
|
-
|
|
15913
|
+
process.exitCode = exitCode;
|
|
16046
15914
|
});
|
|
16047
15915
|
}
|
|
16048
15916
|
var PROFILE_COLUMNS = [
|
|
16049
|
-
{ header: "", value: (row) => row.active ?
|
|
15917
|
+
{ header: "", value: (row) => row.active ? source_default.green("*") : " " },
|
|
16050
15918
|
{ header: "profile", value: (row) => safeOneLine(row.name) },
|
|
16051
15919
|
{ header: "key", value: (row) => row.error ? text(null) : row.hasKey ? "yes" : "no" },
|
|
16052
15920
|
{ header: "auth", value: (row) => row.authProfile ? safeOneLine(row.authProfile) : text(null) },
|
|
16053
|
-
{ header: "error", value: (row) => row.error ?
|
|
15921
|
+
{ header: "error", value: (row) => row.error ? source_default.red(safeOneLine(row.error)) : text(null) }
|
|
16054
15922
|
];
|
|
16055
15923
|
function buildProfileRow(name, active) {
|
|
16056
15924
|
try {
|
|
@@ -16097,7 +15965,7 @@ function profilesCommand() {
|
|
|
16097
15965
|
const rows = listProfiles().map((name) => buildProfileRow(name, name === activeName));
|
|
16098
15966
|
if (rows.length === 0) {
|
|
16099
15967
|
if (output === "table")
|
|
16100
|
-
|
|
15968
|
+
console.log(source_default.dim("No profiles yet. Run: sim login"));
|
|
16101
15969
|
else
|
|
16102
15970
|
printList(output, rows, PROFILE_COLUMNS);
|
|
16103
15971
|
return;
|
|
@@ -16170,11 +16038,11 @@ function configureCommand() {
|
|
|
16170
16038
|
if (Object.keys(updates).length === 0) {
|
|
16171
16039
|
const current = readConfigProfile(profile.name);
|
|
16172
16040
|
if (Object.keys(current).length === 0) {
|
|
16173
|
-
|
|
16041
|
+
console.log(source_default.dim(`No settings stored for profile "${profile.name}".`));
|
|
16174
16042
|
return;
|
|
16175
16043
|
}
|
|
16176
16044
|
for (const [key, value] of Object.entries(current)) {
|
|
16177
|
-
|
|
16045
|
+
console.log(`${source_default.dim(`${key}:`)} ${value}`);
|
|
16178
16046
|
}
|
|
16179
16047
|
return;
|
|
16180
16048
|
}
|
|
@@ -16199,10 +16067,10 @@ function configureCommand() {
|
|
|
16199
16067
|
return true;
|
|
16200
16068
|
});
|
|
16201
16069
|
if (!changed) {
|
|
16202
|
-
|
|
16070
|
+
console.log(source_default.dim(`No settings stored for profile "${profile.name}".`));
|
|
16203
16071
|
return;
|
|
16204
16072
|
}
|
|
16205
|
-
|
|
16073
|
+
console.log(source_default.green(`✓ Updated profile "${profile.name}" in ${configPath()}`));
|
|
16206
16074
|
});
|
|
16207
16075
|
}
|
|
16208
16076
|
|
|
@@ -16426,7 +16294,7 @@ var CLI_CONTRACT = {
|
|
|
16426
16294
|
},
|
|
16427
16295
|
deleteTableView: { confirm: "This deletes the saved view and its filters." },
|
|
16428
16296
|
deleteWorkflowGroup: {
|
|
16429
|
-
confirm: "This deletes the group
|
|
16297
|
+
confirm: "This deletes the group, every column it fed, and the values in them.",
|
|
16430
16298
|
fields: [
|
|
16431
16299
|
{ header: "id" },
|
|
16432
16300
|
{ header: "deleted", format: "bool" },
|
|
@@ -16546,7 +16414,7 @@ var CLI_CONTRACT = {
|
|
|
16546
16414
|
},
|
|
16547
16415
|
applyWorkflowOperations: {
|
|
16548
16416
|
command: "workflows operations apply",
|
|
16549
|
-
confirm: "This edits the draft graph
|
|
16417
|
+
confirm: "This edits the draft graph, and a delete operation removes blocks and their edges.",
|
|
16550
16418
|
flags: {
|
|
16551
16419
|
operations: { json: true, describe: WORKFLOW_OPERATIONS_HELP },
|
|
16552
16420
|
setBlockEnabled: { json: true, describe: WORKFLOW_SET_BLOCK_ENABLED_HELP }
|
|
@@ -17398,7 +17266,7 @@ var CLI_CONTRACT = {
|
|
|
17398
17266
|
selectedOutputs: {
|
|
17399
17267
|
name: "select-output",
|
|
17400
17268
|
list: true,
|
|
17401
|
-
describe: "Return
|
|
17269
|
+
describe: "Return streamed outputs as blockName.path or childWorkflowId.blockName.path; selecting a child workflow applies to every invocation, requires --follow"
|
|
17402
17270
|
},
|
|
17403
17271
|
stream: { omit: true },
|
|
17404
17272
|
includeThinking: { omit: true },
|
|
@@ -17422,7 +17290,7 @@ var CLI_CONTRACT = {
|
|
|
17422
17290
|
selectedOutputs: {
|
|
17423
17291
|
name: "select-output",
|
|
17424
17292
|
list: true,
|
|
17425
|
-
describe: "Include
|
|
17293
|
+
describe: "Include blockId or blockId.path values in JSON or YAML output; block names are not resolved on a finished run"
|
|
17426
17294
|
}
|
|
17427
17295
|
},
|
|
17428
17296
|
fields: [
|
|
@@ -17528,22 +17396,6 @@ function camel(flag) {
|
|
|
17528
17396
|
return flag.replace(/-([a-z])/g, (_match, character) => character.toUpperCase());
|
|
17529
17397
|
}
|
|
17530
17398
|
|
|
17531
|
-
// src/output/truncation.ts
|
|
17532
|
-
var TRUNCATION_FLAG = /^truncated$|^[A-Za-z0-9]+Truncated$/;
|
|
17533
|
-
var NEGATED_TRUNCATION_FLAG = /^(?:not|un|non|never)Truncated$|(?:Not|Un|Non|Never)Truncated$/;
|
|
17534
|
-
function isTruncationField(key) {
|
|
17535
|
-
return TRUNCATION_FLAG.test(key) && !NEGATED_TRUNCATION_FLAG.test(key);
|
|
17536
|
-
}
|
|
17537
|
-
function truncationMetadata(container) {
|
|
17538
|
-
if (!container || typeof container !== "object" || Array.isArray(container))
|
|
17539
|
-
return {};
|
|
17540
|
-
const metadata = {};
|
|
17541
|
-
for (const [key, value] of Object.entries(container))
|
|
17542
|
-
if (typeof value === "boolean" && isTruncationField(key))
|
|
17543
|
-
metadata[key] = value;
|
|
17544
|
-
return metadata;
|
|
17545
|
-
}
|
|
17546
|
-
|
|
17547
17399
|
// src/output/trace.ts
|
|
17548
17400
|
function traceSpan(value) {
|
|
17549
17401
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -17646,13 +17498,13 @@ function renderSpan(value, depth) {
|
|
|
17646
17498
|
function printTraceSpans(format, traceSpans) {
|
|
17647
17499
|
if (format === "json" || format === "yaml")
|
|
17648
17500
|
return;
|
|
17649
|
-
|
|
17650
|
-
|
|
17501
|
+
console.log("");
|
|
17502
|
+
console.log(format === "table" ? source_default.dim("trace:") : "trace:");
|
|
17651
17503
|
if (traceSpans.length === 0) {
|
|
17652
|
-
|
|
17504
|
+
console.log(source_default.dim(" No trace spans."));
|
|
17653
17505
|
return;
|
|
17654
17506
|
}
|
|
17655
|
-
|
|
17507
|
+
console.log(traceSpans.flatMap((span) => renderSpan(span, 0)).join(`
|
|
17656
17508
|
`));
|
|
17657
17509
|
}
|
|
17658
17510
|
|
|
@@ -17816,9 +17668,20 @@ function writePageNote(spec, envelope) {
|
|
|
17816
17668
|
const value = at(envelope, spec.pageNote.path);
|
|
17817
17669
|
if (value === undefined || value === null)
|
|
17818
17670
|
return;
|
|
17819
|
-
|
|
17671
|
+
process.stderr.write(source_default.dim(`${spec.pageNote.label}: ${String(value)}
|
|
17820
17672
|
`));
|
|
17821
17673
|
}
|
|
17674
|
+
var TRUNCATION_FLAG = /^truncated$|^[A-Za-z0-9]+Truncated$/;
|
|
17675
|
+
var NEGATED_TRUNCATION_FLAG = /^(?:not|un|non|never)Truncated$|(?:Not|Un|Non|Never)Truncated$/;
|
|
17676
|
+
function truncationMetadata(container) {
|
|
17677
|
+
if (!container || typeof container !== "object" || Array.isArray(container))
|
|
17678
|
+
return {};
|
|
17679
|
+
const metadata = {};
|
|
17680
|
+
for (const [key, value] of Object.entries(container))
|
|
17681
|
+
if (typeof value === "boolean" && TRUNCATION_FLAG.test(key) && !NEGATED_TRUNCATION_FLAG.test(key))
|
|
17682
|
+
metadata[key] = value;
|
|
17683
|
+
return metadata;
|
|
17684
|
+
}
|
|
17822
17685
|
function truncationFlags(container) {
|
|
17823
17686
|
return Object.entries(truncationMetadata(container)).filter(([, value]) => value).map(([key]) => key);
|
|
17824
17687
|
}
|
|
@@ -17844,7 +17707,7 @@ function clippedSubject(flag) {
|
|
|
17844
17707
|
}
|
|
17845
17708
|
function writeEnvelopeTruncation(envelope) {
|
|
17846
17709
|
for (const flag of responseTruncationFlags(envelope)) {
|
|
17847
|
-
|
|
17710
|
+
process.stderr.write(source_default.dim(`${spellOut(flag)}: the server clipped ${clippedSubject(flag)}, so the answer is incomplete
|
|
17848
17711
|
`));
|
|
17849
17712
|
}
|
|
17850
17713
|
}
|
|
@@ -17854,7 +17717,7 @@ function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
|
17854
17717
|
printDocument(format, raw);
|
|
17855
17718
|
return;
|
|
17856
17719
|
}
|
|
17857
|
-
const data =
|
|
17720
|
+
const data = unwrapResource(raw);
|
|
17858
17721
|
if (spec.itemsPath) {
|
|
17859
17722
|
const items = at(data, spec.itemsPath);
|
|
17860
17723
|
if (!Array.isArray(items)) {
|
|
@@ -17976,87 +17839,6 @@ function attachWorkspaceOperationWait(operations) {
|
|
|
17976
17839
|
|
|
17977
17840
|
// src/runtime/request.ts
|
|
17978
17841
|
import { closeSync as closeSync2, existsSync as existsSync2, fstatSync as fstatSync2, openSync as openSync2, readSync as readSync2 } from "node:fs";
|
|
17979
|
-
|
|
17980
|
-
// src/transfer/local-file.ts
|
|
17981
|
-
import { constants as constants2 } from "node:fs";
|
|
17982
|
-
import { access, stat } from "node:fs/promises";
|
|
17983
|
-
import { basename } from "node:path";
|
|
17984
|
-
function embeddedFileKey(path) {
|
|
17985
|
-
return path.startsWith("@") ? path.slice(1) : path;
|
|
17986
|
-
}
|
|
17987
|
-
async function embeddedFileContent(embedded, path) {
|
|
17988
|
-
const key = embeddedFileKey(path);
|
|
17989
|
-
embedded.identity.signal?.throwIfAborted();
|
|
17990
|
-
if (!embedded.readFile)
|
|
17991
|
-
throw new SimApiError("This invocation has no machine to read from", 0);
|
|
17992
|
-
const content = await embedded.readFile(key);
|
|
17993
|
-
embedded.identity.signal?.throwIfAborted();
|
|
17994
|
-
return typeof content === "string" ? content : new Uint8Array(content);
|
|
17995
|
-
}
|
|
17996
|
-
var CONTENT_TYPES = {
|
|
17997
|
-
css: "text/css",
|
|
17998
|
-
csv: "text/csv",
|
|
17999
|
-
doc: "application/msword",
|
|
18000
|
-
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18001
|
-
gif: "image/gif",
|
|
18002
|
-
html: "text/html",
|
|
18003
|
-
htm: "text/html",
|
|
18004
|
-
jpeg: "image/jpeg",
|
|
18005
|
-
jpg: "image/jpeg",
|
|
18006
|
-
js: "text/javascript",
|
|
18007
|
-
json: "application/json",
|
|
18008
|
-
jsonl: "application/jsonl",
|
|
18009
|
-
md: "text/markdown",
|
|
18010
|
-
pdf: "application/pdf",
|
|
18011
|
-
ppt: "application/vnd.ms-powerpoint",
|
|
18012
|
-
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
18013
|
-
png: "image/png",
|
|
18014
|
-
svg: "image/svg+xml",
|
|
18015
|
-
txt: "text/plain",
|
|
18016
|
-
webp: "image/webp",
|
|
18017
|
-
yaml: "application/yaml",
|
|
18018
|
-
yml: "application/yaml",
|
|
18019
|
-
xls: "application/vnd.ms-excel",
|
|
18020
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
18021
|
-
zip: "application/zip"
|
|
18022
|
-
};
|
|
18023
|
-
function contentTypeFor(name) {
|
|
18024
|
-
const dot = name.lastIndexOf(".");
|
|
18025
|
-
const extension = dot === -1 ? "" : name.slice(dot + 1).toLowerCase();
|
|
18026
|
-
return CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
18027
|
-
}
|
|
18028
|
-
async function localFile(path, override) {
|
|
18029
|
-
const embedded = embedStore.getStore();
|
|
18030
|
-
if (embedded) {
|
|
18031
|
-
embedded.identity.signal?.throwIfAborted();
|
|
18032
|
-
if (!embedded.openFile)
|
|
18033
|
-
throw new SimApiError("This invocation has no machine to read from", 0);
|
|
18034
|
-
const { size } = await embedded.openFile(embeddedFileKey(path));
|
|
18035
|
-
embedded.identity.signal?.throwIfAborted();
|
|
18036
|
-
if (!Number.isSafeInteger(size) || size < 0)
|
|
18037
|
-
throw new SimApiError("Invalid file size", 0);
|
|
18038
|
-
if (size === 0)
|
|
18039
|
-
throw new SimApiError(`${path} is empty`, 0);
|
|
18040
|
-
return { name: override ?? basename(embeddedFileKey(path)), size };
|
|
18041
|
-
}
|
|
18042
|
-
let size;
|
|
18043
|
-
try {
|
|
18044
|
-
const stats = await stat(path);
|
|
18045
|
-
if (!stats.isFile())
|
|
18046
|
-
throw new SimApiError(`${path} is not a regular file`, 0);
|
|
18047
|
-
await access(path, constants2.R_OK);
|
|
18048
|
-
size = stats.size;
|
|
18049
|
-
} catch (error) {
|
|
18050
|
-
if (error instanceof SimApiError)
|
|
18051
|
-
throw error;
|
|
18052
|
-
throw new SimApiError(`Cannot read ${path}: ${error.message}`, 0);
|
|
18053
|
-
}
|
|
18054
|
-
if (size === 0)
|
|
18055
|
-
throw new SimApiError(`${path} is empty`, 0);
|
|
18056
|
-
return { name: override ?? basename(path), size };
|
|
18057
|
-
}
|
|
18058
|
-
|
|
18059
|
-
// src/runtime/request.ts
|
|
18060
17842
|
var PROFILE_INJECTED_FIELD = "workspaceId";
|
|
18061
17843
|
function isProfileWorkspacePath(commandSpec, param) {
|
|
18062
17844
|
return commandSpec.profileWorkspacePath === true && param === PROFILE_INJECTED_FIELD;
|
|
@@ -18143,25 +17925,13 @@ function readArgumentDescriptor(descriptor) {
|
|
|
18143
17925
|
function literalAtHint(error, path) {
|
|
18144
17926
|
return error?.code === "ENOENT" ? `. To pass the literal value @${path}, write @@${path}` : "";
|
|
18145
17927
|
}
|
|
18146
|
-
|
|
17928
|
+
function readArgumentSource(raw, flagName) {
|
|
18147
17929
|
if (Buffer.byteLength(raw, "utf8") > MAX_JSON_ARGUMENT_BYTES)
|
|
18148
17930
|
throw new SimApiError(`--${flagName} exceeds the 10 MiB JSON input limit`, 0);
|
|
18149
17931
|
if (raw.startsWith("@@"))
|
|
18150
17932
|
return { text: raw.slice(1), from: "" };
|
|
18151
17933
|
if (!raw.startsWith("@"))
|
|
18152
17934
|
return { text: raw, from: "" };
|
|
18153
|
-
const embedded = embedStore.getStore();
|
|
18154
|
-
if (embedded) {
|
|
18155
|
-
if (raw === "@-")
|
|
18156
|
-
throw new SimApiError(`--${flagName}: this invocation has no stdin; use @path or an inline value`, 0);
|
|
18157
|
-
const content = await embeddedFileContent(embedded, raw);
|
|
18158
|
-
if (Buffer.byteLength(content) > MAX_JSON_ARGUMENT_BYTES)
|
|
18159
|
-
throw new SimApiError(`--${flagName} exceeds the 10 MiB JSON input limit`, 0);
|
|
18160
|
-
return {
|
|
18161
|
-
text: typeof content === "string" ? content : new TextDecoder("utf-8", { fatal: true }).decode(content),
|
|
18162
|
-
from: " (read from your machine)"
|
|
18163
|
-
};
|
|
18164
|
-
}
|
|
18165
17935
|
const path = raw.slice(1);
|
|
18166
17936
|
if (path === "-") {
|
|
18167
17937
|
if (process.stdin.isTTY) {
|
|
@@ -18190,18 +17960,15 @@ function isManifestNoise(line) {
|
|
|
18190
17960
|
const trimmed = line.trim();
|
|
18191
17961
|
return trimmed === "" || trimmed.startsWith("#");
|
|
18192
17962
|
}
|
|
18193
|
-
|
|
17963
|
+
function readListValues(raw, flagName, manifest = false) {
|
|
18194
17964
|
const arguments_ = Array.isArray(raw) ? raw : [raw];
|
|
18195
|
-
const values =
|
|
18196
|
-
for (const argument of arguments_) {
|
|
17965
|
+
const values = arguments_.flatMap((argument) => {
|
|
18197
17966
|
if (typeof argument !== "string") {
|
|
18198
17967
|
throw new SimApiError(`--${flagName} values must be strings`, 0);
|
|
18199
17968
|
}
|
|
18200
|
-
if (!argument.startsWith("@"))
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
}
|
|
18204
|
-
const source = await readArgumentSource(argument, flagName);
|
|
17969
|
+
if (!argument.startsWith("@"))
|
|
17970
|
+
return [argument];
|
|
17971
|
+
const source = readArgumentSource(argument, flagName);
|
|
18205
17972
|
const lines = source.text.split(/\r?\n/);
|
|
18206
17973
|
if (lines.at(-1) === "")
|
|
18207
17974
|
lines.pop();
|
|
@@ -18209,14 +17976,14 @@ async function readListValues(raw, flagName, manifest = false) {
|
|
|
18209
17976
|
if (kept.length === 0) {
|
|
18210
17977
|
throw new SimApiError(`--${flagName}${source.from} contains no values`, 0);
|
|
18211
17978
|
}
|
|
18212
|
-
|
|
17979
|
+
return kept.map((line, index) => {
|
|
18213
17980
|
const value = line.trim();
|
|
18214
17981
|
if (!value) {
|
|
18215
17982
|
throw new SimApiError(`--${flagName}${source.from} has an empty value on line ${index + 1}`, 0);
|
|
18216
17983
|
}
|
|
18217
17984
|
return value;
|
|
18218
|
-
})
|
|
18219
|
-
}
|
|
17985
|
+
});
|
|
17986
|
+
});
|
|
18220
17987
|
return values.map((value) => {
|
|
18221
17988
|
const trimmed = value.trim();
|
|
18222
17989
|
if (!trimmed)
|
|
@@ -18248,13 +18015,13 @@ var FRACTIONAL_DIGITS = /\.\d*[1-9]/;
|
|
|
18248
18015
|
function pathHint(raw) {
|
|
18249
18016
|
if (raw.startsWith("@") || /^\s*[[{"\-\d]|^\s*(true|false|null)/.test(raw))
|
|
18250
18017
|
return "";
|
|
18251
|
-
return
|
|
18018
|
+
return existsSync2(raw) ? `. ${raw} is a file — pass it as @${raw}` : ". To read a file, pass @path (or @- for stdin)";
|
|
18252
18019
|
}
|
|
18253
|
-
|
|
18020
|
+
function coerce(raw, field, flag, flagName) {
|
|
18254
18021
|
if (raw === undefined)
|
|
18255
18022
|
return;
|
|
18256
18023
|
if (flag.list) {
|
|
18257
|
-
const values =
|
|
18024
|
+
const values = readListValues(raw, flagName, flag.manifest === true).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
|
|
18258
18025
|
return field.kind === "string" ? values.join(",") : values;
|
|
18259
18026
|
}
|
|
18260
18027
|
if (flag.rowCap)
|
|
@@ -18262,7 +18029,7 @@ async function coerce(raw, field, flag, flagName) {
|
|
|
18262
18029
|
if (takesJson(field, flag)) {
|
|
18263
18030
|
if (typeof raw !== "string")
|
|
18264
18031
|
return raw;
|
|
18265
|
-
const source =
|
|
18032
|
+
const source = readArgumentSource(raw, flagName);
|
|
18266
18033
|
try {
|
|
18267
18034
|
return JSON.parse(source.text);
|
|
18268
18035
|
} catch (error) {
|
|
@@ -18304,7 +18071,7 @@ function boundedRequest(request) {
|
|
|
18304
18071
|
throw new SimApiError("Aggregate JSON request body exceeds 10 MiB", 0);
|
|
18305
18072
|
return request;
|
|
18306
18073
|
}
|
|
18307
|
-
|
|
18074
|
+
function buildRequest(operation, positional, flags, workspaceId) {
|
|
18308
18075
|
const commandSpec = CLI_CONTRACT[operation] ?? {};
|
|
18309
18076
|
const spec = V2_OPERATIONS[operation];
|
|
18310
18077
|
let path = spec.path;
|
|
@@ -18342,7 +18109,7 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
18342
18109
|
if ((slot === "query" || NUMERIC_KINDS.has(descriptor.kind)) && typeof raw === "string" && raw.trim() === "" && !(field === "limit" && paginatedLimit)) {
|
|
18343
18110
|
throw new SimApiError(`--${flagName} cannot be empty`, 0);
|
|
18344
18111
|
}
|
|
18345
|
-
const value =
|
|
18112
|
+
const value = coerce(raw ?? undefined, descriptor, flag, flagName);
|
|
18346
18113
|
if (field === "limit" && !paginatedLimit && NUMERIC_KINDS.has(descriptor.kind) && typeof value === "number" && value < 1) {
|
|
18347
18114
|
throw new SimApiError(`--${flagName} must be 1 or more`, 0);
|
|
18348
18115
|
}
|
|
@@ -18372,7 +18139,7 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
18372
18139
|
const raw = flags[camel(variant.name)];
|
|
18373
18140
|
if (typeof raw !== "string")
|
|
18374
18141
|
throw new SimApiError(`--${variant.name} is required`, 0);
|
|
18375
|
-
const parsed =
|
|
18142
|
+
const parsed = coerce(raw, { kind: variant.kind }, { json: true }, variant.name);
|
|
18376
18143
|
if (variant.kind === "object" && (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) || variant.kind === "array" && !Array.isArray(parsed)) {
|
|
18377
18144
|
throw new SimApiError(`--${variant.name} must be a JSON ${variant.kind}`, 0);
|
|
18378
18145
|
}
|
|
@@ -18386,7 +18153,7 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
18386
18153
|
const raw = flags.body;
|
|
18387
18154
|
if (typeof raw !== "string")
|
|
18388
18155
|
throw new SimApiError("--body is required", 0);
|
|
18389
|
-
const parsed =
|
|
18156
|
+
const parsed = coerce(raw, { kind: "object" }, { json: true }, "body");
|
|
18390
18157
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
18391
18158
|
throw new SimApiError("--body must be a JSON object", 0);
|
|
18392
18159
|
}
|
|
@@ -18549,7 +18316,7 @@ function warn(kind, from, to) {
|
|
|
18549
18316
|
if (warned.has(key))
|
|
18550
18317
|
return;
|
|
18551
18318
|
warned.add(key);
|
|
18552
|
-
|
|
18319
|
+
process.stderr.write(`warning: ${kind} "${from}" has been renamed to "${to}". The old name still works.
|
|
18553
18320
|
`);
|
|
18554
18321
|
}
|
|
18555
18322
|
function warnRenamedCommand(from, to) {
|
|
@@ -18657,22 +18424,6 @@ function countOf(value) {
|
|
|
18657
18424
|
function lengthOf(value) {
|
|
18658
18425
|
return Array.isArray(value) ? value.length : 0;
|
|
18659
18426
|
}
|
|
18660
|
-
var RESULT_NOTES = {
|
|
18661
|
-
replaceWorkflowChatDeployment: (payload, body) => {
|
|
18662
|
-
const authType = payload.authType ?? body?.authType ?? "public";
|
|
18663
|
-
return authType === "public" ? "note: auth type is public — anyone with the link can chat; pass --auth-type password|email to restrict it." : null;
|
|
18664
|
-
}
|
|
18665
|
-
};
|
|
18666
|
-
function writeResultNote(operation, payload, body) {
|
|
18667
|
-
const note = RESULT_NOTES[operation];
|
|
18668
|
-
if (!note)
|
|
18669
|
-
return;
|
|
18670
|
-
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
18671
|
-
const message = note(record, body);
|
|
18672
|
-
if (message)
|
|
18673
|
-
writeStderr(styles3().dim(`${message}
|
|
18674
|
-
`));
|
|
18675
|
-
}
|
|
18676
18427
|
function bulkFailureMessage(operation, payload, body) {
|
|
18677
18428
|
const check = BULK_OUTCOME_CHECKS[operation];
|
|
18678
18429
|
if (!check)
|
|
@@ -18762,7 +18513,7 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
|
|
|
18762
18513
|
const paging = cursorSlot(operationSpec);
|
|
18763
18514
|
const pagedLimit = paging ? readPagedLimit(requestFlags.limit, operation) : 0;
|
|
18764
18515
|
const requestWorkspaceId = needsWorkspace ? client.requireWorkspace() : profile.workspaceId;
|
|
18765
|
-
const request =
|
|
18516
|
+
const request = buildRequest(operation, positional, requestFlags, requestWorkspaceId);
|
|
18766
18517
|
if (commandSpec.workspaceOperation) {
|
|
18767
18518
|
if (!WORKSPACE_OPERATION_KINDS[operation])
|
|
18768
18519
|
throw new SimApiError("This command has no workspace operation identity configured", 0);
|
|
@@ -18852,7 +18603,6 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
|
|
|
18852
18603
|
return;
|
|
18853
18604
|
}
|
|
18854
18605
|
renderResult(operation, profile.output, payload, commandSpec, { expandedTrace: requestFlags.trace === true }, result);
|
|
18855
|
-
writeResultNote(operation, payload, request.body);
|
|
18856
18606
|
const failure = runFailureMessage(operation, payload) ?? bulkFailureMessage(operation, payload, request.body);
|
|
18857
18607
|
if (failure)
|
|
18858
18608
|
throw new SimApiError(failure, 0);
|
|
@@ -19260,8 +19010,8 @@ function serviceAccountProvider(providers, providerId) {
|
|
|
19260
19010
|
}
|
|
19261
19011
|
return provider;
|
|
19262
19012
|
}
|
|
19263
|
-
|
|
19264
|
-
const parsed =
|
|
19013
|
+
function credentialValues(provider, raw) {
|
|
19014
|
+
const parsed = coerce(raw, { kind: "object" }, { json: true }, "credentials");
|
|
19265
19015
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19266
19016
|
throw new SimApiError("--credentials must be a JSON object", 0);
|
|
19267
19017
|
}
|
|
@@ -19298,7 +19048,7 @@ async function createServiceAccount(command, providerId, options) {
|
|
|
19298
19048
|
if (provider.requiresClientGeneratedCredentialId && !options.id) {
|
|
19299
19049
|
throw new SimApiError(`--id is required for ${providerId}.`, 0);
|
|
19300
19050
|
}
|
|
19301
|
-
const credentialFields =
|
|
19051
|
+
const credentialFields = credentialValues(provider, options.credentials);
|
|
19302
19052
|
const operation = V2_OPERATIONS.createServiceAccountCredential;
|
|
19303
19053
|
const response = await client.request(operation.path, {
|
|
19304
19054
|
method: operation.method,
|
|
@@ -19466,19 +19216,19 @@ Examples:
|
|
|
19466
19216
|
const endStreamedLine = () => {
|
|
19467
19217
|
if (streamed.length > 0 && !streamed.endsWith(`
|
|
19468
19218
|
`)) {
|
|
19469
|
-
|
|
19219
|
+
process.stdout.write(`
|
|
19470
19220
|
`);
|
|
19471
19221
|
streamed += `
|
|
19472
19222
|
`;
|
|
19473
19223
|
}
|
|
19474
19224
|
};
|
|
19475
|
-
const restorePipeHandling = streaming
|
|
19225
|
+
const restorePipeHandling = streaming ? ignoreBrokenPipe(process.stdout) : undefined;
|
|
19476
19226
|
try {
|
|
19477
19227
|
const result = await readChatStream(response, (content) => {
|
|
19478
19228
|
if (!streaming)
|
|
19479
19229
|
return;
|
|
19480
19230
|
streamed += content;
|
|
19481
|
-
|
|
19231
|
+
process.stdout.write(content);
|
|
19482
19232
|
});
|
|
19483
19233
|
if (!streaming) {
|
|
19484
19234
|
printProtocolResult(profile.output, result);
|
|
@@ -19486,11 +19236,11 @@ Examples:
|
|
|
19486
19236
|
}
|
|
19487
19237
|
const content = sanitize(result.content ?? "");
|
|
19488
19238
|
if (content.startsWith(streamed) && content.length > streamed.length) {
|
|
19489
|
-
|
|
19239
|
+
process.stdout.write(content.slice(streamed.length));
|
|
19490
19240
|
streamed = content;
|
|
19491
19241
|
}
|
|
19492
19242
|
endStreamedLine();
|
|
19493
|
-
|
|
19243
|
+
process.stderr.write(`${source_default.dim(`conversation: ${result.conversationId}`)}
|
|
19494
19244
|
`);
|
|
19495
19245
|
} catch (error) {
|
|
19496
19246
|
endStreamedLine();
|
|
@@ -19505,7 +19255,7 @@ Examples:
|
|
|
19505
19255
|
import { once as once2 } from "node:events";
|
|
19506
19256
|
import { createWriteStream, rmSync as rmSync2 } from "node:fs";
|
|
19507
19257
|
import { link, lstat, mkdtemp, readlink, rename, rm } from "node:fs/promises";
|
|
19508
|
-
import { dirname as dirname4, join as join3,
|
|
19258
|
+
import { dirname as dirname4, join as join3, resolve as resolve2 } from "node:path";
|
|
19509
19259
|
import { Readable } from "node:stream";
|
|
19510
19260
|
import { pipeline } from "node:stream/promises";
|
|
19511
19261
|
function writeFailure(path, error) {
|
|
@@ -19621,45 +19371,19 @@ async function saveStagedFile(body, target, force) {
|
|
|
19621
19371
|
}
|
|
19622
19372
|
}
|
|
19623
19373
|
async function saveToFile(body, target, force) {
|
|
19624
|
-
|
|
19625
|
-
if (embedded) {
|
|
19626
|
-
try {
|
|
19627
|
-
if (embedded.workingDirectory) {
|
|
19628
|
-
if (!posix.isAbsolute(embedded.workingDirectory))
|
|
19629
|
-
throw new SimApiError("The caller working directory must be absolute.", 0);
|
|
19630
|
-
target = posix.resolve(embedded.workingDirectory, target);
|
|
19631
|
-
}
|
|
19632
|
-
embedded.identity.signal?.throwIfAborted();
|
|
19633
|
-
if (!embedded.writeFile) {
|
|
19634
|
-
throw new SimApiError(`--output-file cannot save ${target} here: this surface has no machine to write to. Read the file instead, or use a client with filesystem access to download it.`, 0);
|
|
19635
|
-
}
|
|
19636
|
-
await embedded.writeFile(target, body, { overwrite: force });
|
|
19637
|
-
embedded.identity.signal?.throwIfAborted();
|
|
19638
|
-
} finally {
|
|
19639
|
-
await body.cancel().catch(() => {});
|
|
19640
|
-
}
|
|
19641
|
-
return target;
|
|
19642
|
-
}
|
|
19643
|
-
target = resolve2(target);
|
|
19644
|
-
await saveStagedFile(body, target, force);
|
|
19645
|
-
return target;
|
|
19374
|
+
return saveStagedFile(body, target, force);
|
|
19646
19375
|
}
|
|
19647
|
-
async function streamToStdout(body, output) {
|
|
19376
|
+
async function streamToStdout(body, output = process.stdout) {
|
|
19648
19377
|
const reader = body.getReader();
|
|
19649
19378
|
try {
|
|
19650
19379
|
while (true) {
|
|
19651
19380
|
const { done, value } = await reader.read();
|
|
19652
19381
|
if (done)
|
|
19653
19382
|
return;
|
|
19654
|
-
if (output)
|
|
19655
|
-
|
|
19656
|
-
await once2(output, "drain");
|
|
19657
|
-
} else if (!writeStdout(value)) {
|
|
19658
|
-
await once2(process.stdout, "drain");
|
|
19659
|
-
}
|
|
19383
|
+
if (!output.write(value))
|
|
19384
|
+
await once2(output, "drain");
|
|
19660
19385
|
}
|
|
19661
19386
|
} finally {
|
|
19662
|
-
await reader.cancel().catch(() => {});
|
|
19663
19387
|
reader.releaseLock();
|
|
19664
19388
|
}
|
|
19665
19389
|
}
|
|
@@ -19697,15 +19421,15 @@ function attachFileGet(files) {
|
|
|
19697
19421
|
}
|
|
19698
19422
|
if (options.outputFile === undefined || options.outputFile === "-") {
|
|
19699
19423
|
const contentType = response.headers.get("content-type");
|
|
19700
|
-
|
|
19701
|
-
if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
|
|
19424
|
+
if (process.stdout.isTTY && !isTerminalSafeContentType(contentType)) {
|
|
19702
19425
|
await response.body.cancel();
|
|
19703
|
-
throw new SimApiError(
|
|
19426
|
+
throw new SimApiError(`Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
|
|
19704
19427
|
}
|
|
19705
19428
|
await streamToStdout(response.body);
|
|
19706
19429
|
return;
|
|
19707
19430
|
}
|
|
19708
|
-
const target =
|
|
19431
|
+
const target = options.outputFile;
|
|
19432
|
+
await saveToFile(response.body, target, Boolean(options.force));
|
|
19709
19433
|
printProtocolResult(profile.output, {
|
|
19710
19434
|
id: fileId,
|
|
19711
19435
|
path: target,
|
|
@@ -19714,120 +19438,74 @@ function attachFileGet(files) {
|
|
|
19714
19438
|
});
|
|
19715
19439
|
}
|
|
19716
19440
|
|
|
19717
|
-
// src/transfer/
|
|
19718
|
-
import {
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19722
|
-
|
|
19723
|
-
|
|
19724
|
-
|
|
19725
|
-
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19735
|
-
|
|
19736
|
-
|
|
19737
|
-
|
|
19738
|
-
|
|
19739
|
-
|
|
19740
|
-
|
|
19741
|
-
|
|
19742
|
-
|
|
19743
|
-
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
|
|
19749
|
-
|
|
19750
|
-
|
|
19751
|
-
|
|
19752
|
-
|
|
19753
|
-
|
|
19754
|
-
|
|
19755
|
-
|
|
19756
|
-
|
|
19757
|
-
|
|
19758
|
-
|
|
19759
|
-
|
|
19760
|
-
|
|
19761
|
-
|
|
19762
|
-
|
|
19763
|
-
|
|
19764
|
-
|
|
19765
|
-
}
|
|
19766
|
-
},
|
|
19767
|
-
cancel: (reason) => this.reader.cancel(reason)
|
|
19768
|
-
}, { highWaterMark: 0 });
|
|
19769
|
-
}
|
|
19770
|
-
assertConsumed(end) {
|
|
19771
|
-
this.signal.throwIfAborted();
|
|
19772
|
-
if (this.position !== end) {
|
|
19773
|
-
throw new SimApiError("Upload was acknowledged before its complete body was consumed", 0);
|
|
19774
|
-
}
|
|
19775
|
-
}
|
|
19776
|
-
async verifyComplete() {
|
|
19777
|
-
this.assertConsumed(this.size);
|
|
19778
|
-
if (this.pending.byteLength > 0) {
|
|
19779
|
-
throw new SimApiError("Upload file exceeds its declared size", 0);
|
|
19780
|
-
}
|
|
19781
|
-
while (true) {
|
|
19782
|
-
const next = await this.reader.read();
|
|
19783
|
-
this.signal.throwIfAborted();
|
|
19784
|
-
if (next.done)
|
|
19785
|
-
return;
|
|
19786
|
-
if (next.value.byteLength > 0)
|
|
19787
|
-
throw new SimApiError("Upload file exceeds its declared size", 0);
|
|
19788
|
-
}
|
|
19789
|
-
}
|
|
19790
|
-
async close() {
|
|
19791
|
-
if (this.closed)
|
|
19792
|
-
return;
|
|
19793
|
-
this.closed = true;
|
|
19794
|
-
this.stopped.abort();
|
|
19795
|
-
this.signal.removeEventListener("abort", this.onAbort);
|
|
19796
|
-
try {
|
|
19797
|
-
await this.reader.cancel().catch(() => {});
|
|
19798
|
-
} finally {
|
|
19799
|
-
this.reader.releaseLock();
|
|
19800
|
-
}
|
|
19441
|
+
// src/transfer/local-file.ts
|
|
19442
|
+
import { constants as constants2 } from "node:fs";
|
|
19443
|
+
import { access, stat } from "node:fs/promises";
|
|
19444
|
+
import { basename } from "node:path";
|
|
19445
|
+
var CONTENT_TYPES = {
|
|
19446
|
+
css: "text/css",
|
|
19447
|
+
csv: "text/csv",
|
|
19448
|
+
doc: "application/msword",
|
|
19449
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
19450
|
+
gif: "image/gif",
|
|
19451
|
+
html: "text/html",
|
|
19452
|
+
htm: "text/html",
|
|
19453
|
+
jpeg: "image/jpeg",
|
|
19454
|
+
jpg: "image/jpeg",
|
|
19455
|
+
js: "text/javascript",
|
|
19456
|
+
json: "application/json",
|
|
19457
|
+
jsonl: "application/jsonl",
|
|
19458
|
+
md: "text/markdown",
|
|
19459
|
+
pdf: "application/pdf",
|
|
19460
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
19461
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
19462
|
+
png: "image/png",
|
|
19463
|
+
svg: "image/svg+xml",
|
|
19464
|
+
txt: "text/plain",
|
|
19465
|
+
webp: "image/webp",
|
|
19466
|
+
yaml: "application/yaml",
|
|
19467
|
+
yml: "application/yaml",
|
|
19468
|
+
xls: "application/vnd.ms-excel",
|
|
19469
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
19470
|
+
zip: "application/zip"
|
|
19471
|
+
};
|
|
19472
|
+
function contentTypeFor(name) {
|
|
19473
|
+
const dot = name.lastIndexOf(".");
|
|
19474
|
+
const extension = dot === -1 ? "" : name.slice(dot + 1).toLowerCase();
|
|
19475
|
+
return CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
19476
|
+
}
|
|
19477
|
+
async function localFile(path, override) {
|
|
19478
|
+
let size;
|
|
19479
|
+
try {
|
|
19480
|
+
const stats = await stat(path);
|
|
19481
|
+
if (!stats.isFile())
|
|
19482
|
+
throw new SimApiError(`${path} is not a regular file`, 0);
|
|
19483
|
+
await access(path, constants2.R_OK);
|
|
19484
|
+
size = stats.size;
|
|
19485
|
+
} catch (error) {
|
|
19486
|
+
if (error instanceof SimApiError)
|
|
19487
|
+
throw error;
|
|
19488
|
+
throw new SimApiError(`Cannot read ${path}: ${error.message}`, 0);
|
|
19801
19489
|
}
|
|
19490
|
+
if (size === 0)
|
|
19491
|
+
throw new SimApiError(`${path} is empty`, 0);
|
|
19492
|
+
return { name: override ?? basename(path), size };
|
|
19802
19493
|
}
|
|
19803
19494
|
|
|
19804
19495
|
// src/transfer/upload-session.ts
|
|
19496
|
+
import { openAsBlob } from "node:fs";
|
|
19805
19497
|
var PART_URL_BATCH = 100;
|
|
19806
|
-
async function
|
|
19807
|
-
const
|
|
19808
|
-
const options = {
|
|
19498
|
+
async function uploadPut(transfer, blob) {
|
|
19499
|
+
const response = await fetch(transfer.url, {
|
|
19809
19500
|
method: "PUT",
|
|
19810
|
-
headers,
|
|
19811
|
-
body
|
|
19812
|
-
|
|
19813
|
-
};
|
|
19814
|
-
if (file instanceof StreamingUpload) {
|
|
19815
|
-
const streamedHeaders = new Headers(headers);
|
|
19816
|
-
streamedHeaders.set("content-length", String(end - start));
|
|
19817
|
-
options.headers = streamedHeaders;
|
|
19818
|
-
options.duplex = "half";
|
|
19819
|
-
}
|
|
19820
|
-
const response = await fetch(url, options);
|
|
19501
|
+
headers: transfer.headers,
|
|
19502
|
+
body: blob
|
|
19503
|
+
});
|
|
19821
19504
|
if (!response.ok) {
|
|
19822
|
-
throw new SimApiError(
|
|
19505
|
+
throw new SimApiError(`Upload failed with status ${response.status}`, response.status);
|
|
19823
19506
|
}
|
|
19824
|
-
if (file instanceof StreamingUpload)
|
|
19825
|
-
file.assertConsumed(end);
|
|
19826
19507
|
}
|
|
19827
|
-
async function uploadParts(client, workspaceId, session, transfer,
|
|
19828
|
-
if (file instanceof StreamingUpload && (!Number.isSafeInteger(transfer.partSize) || transfer.partSize <= 0)) {
|
|
19829
|
-
throw new SimApiError("Invalid upload part size", 0);
|
|
19830
|
-
}
|
|
19508
|
+
async function uploadParts(client, workspaceId, session, transfer, blob) {
|
|
19831
19509
|
const expectedPartCount = Math.ceil(session.size / transfer.partSize);
|
|
19832
19510
|
if (expectedPartCount !== transfer.partCount) {
|
|
19833
19511
|
throw new Error(`Upload session expected ${transfer.partCount} parts, but file requires ${expectedPartCount}`);
|
|
@@ -19843,49 +19521,28 @@ async function uploadParts(client, workspaceId, session, transfer, file) {
|
|
|
19843
19521
|
headers: { "upload-token": session.uploadToken },
|
|
19844
19522
|
body: { partNumbers }
|
|
19845
19523
|
});
|
|
19846
|
-
|
|
19847
|
-
if (file instanceof StreamingUpload) {
|
|
19848
|
-
const numbers = new Set(parts.map((part) => part.partNumber));
|
|
19849
|
-
if (parts.length !== partNumbers.length || partNumbers.some((n) => !numbers.has(n))) {
|
|
19850
|
-
throw new SimApiError("Upload part URLs do not match the requested parts", 0);
|
|
19851
|
-
}
|
|
19852
|
-
parts = [...parts].sort((a, b) => a.partNumber - b.partNumber);
|
|
19853
|
-
}
|
|
19854
|
-
for (const part of parts) {
|
|
19524
|
+
for (const part of signed.data.parts) {
|
|
19855
19525
|
const start = (part.partNumber - 1) * transfer.partSize;
|
|
19856
|
-
|
|
19526
|
+
const chunk = blob.slice(start, Math.min(start + transfer.partSize, session.size));
|
|
19527
|
+
const response = await fetch(part.url, {
|
|
19528
|
+
method: "PUT",
|
|
19529
|
+
headers: part.headers,
|
|
19530
|
+
body: chunk
|
|
19531
|
+
});
|
|
19532
|
+
if (!response.ok) {
|
|
19533
|
+
throw new SimApiError(`Part ${part.partNumber} failed with status ${response.status}`, response.status);
|
|
19534
|
+
}
|
|
19857
19535
|
}
|
|
19858
19536
|
}
|
|
19859
19537
|
}
|
|
19860
19538
|
async function finishUploadSession(client, workspaceId, session, path) {
|
|
19861
|
-
let snapshot;
|
|
19862
|
-
let streamed;
|
|
19863
19539
|
try {
|
|
19864
|
-
const
|
|
19865
|
-
let file;
|
|
19866
|
-
if (embedded) {
|
|
19867
|
-
embedded.identity.signal?.throwIfAborted();
|
|
19868
|
-
if (!embedded.openFile)
|
|
19869
|
-
throw new SimApiError("This invocation has no machine to read from", 0);
|
|
19870
|
-
snapshot = await embedded.openFile(embeddedFileKey(path));
|
|
19871
|
-
if (snapshot.size !== session.size)
|
|
19872
|
-
throw new SimApiError("Upload snapshot size changed", 0);
|
|
19873
|
-
streamed = new StreamingUpload(await snapshot.stream(), snapshot.size, AbortSignal.any([
|
|
19874
|
-
...embedded.identity.signal ? [embedded.identity.signal] : [],
|
|
19875
|
-
...snapshot.signal ? [snapshot.signal] : []
|
|
19876
|
-
]));
|
|
19877
|
-
file = streamed;
|
|
19878
|
-
} else {
|
|
19879
|
-
file = await openAsBlob(path);
|
|
19880
|
-
}
|
|
19540
|
+
const blob = await openAsBlob(path);
|
|
19881
19541
|
if (session.transfer.method === "put") {
|
|
19882
|
-
await
|
|
19542
|
+
await uploadPut(session.transfer, blob);
|
|
19883
19543
|
} else {
|
|
19884
|
-
await uploadParts(client, workspaceId, session, session.transfer,
|
|
19544
|
+
await uploadParts(client, workspaceId, session, session.transfer, blob);
|
|
19885
19545
|
}
|
|
19886
|
-
await streamed?.verifyComplete();
|
|
19887
|
-
await streamed?.close();
|
|
19888
|
-
await snapshot?.dispose().catch(() => {});
|
|
19889
19546
|
const completed = await client.request(`${session.basePath}/complete`, {
|
|
19890
19547
|
method: "POST",
|
|
19891
19548
|
query: { workspaceId },
|
|
@@ -19893,10 +19550,7 @@ async function finishUploadSession(client, workspaceId, session, path) {
|
|
|
19893
19550
|
});
|
|
19894
19551
|
return completed.data;
|
|
19895
19552
|
} catch (error) {
|
|
19896
|
-
await
|
|
19897
|
-
const profile = embeddedProfile();
|
|
19898
|
-
const cleanupClient = profile ? new SimClient({ ...profile, signal: AbortSignal.timeout(5000) }) : client;
|
|
19899
|
-
await cleanupClient.request(session.basePath, {
|
|
19553
|
+
await client.request(session.basePath, {
|
|
19900
19554
|
method: "DELETE",
|
|
19901
19555
|
query: { workspaceId },
|
|
19902
19556
|
headers: { "upload-token": session.uploadToken }
|
|
@@ -19904,9 +19558,6 @@ async function finishUploadSession(client, workspaceId, session, path) {
|
|
|
19904
19558
|
return;
|
|
19905
19559
|
});
|
|
19906
19560
|
throw error;
|
|
19907
|
-
} finally {
|
|
19908
|
-
await streamed?.close();
|
|
19909
|
-
await snapshot?.dispose().catch(() => {});
|
|
19910
19561
|
}
|
|
19911
19562
|
}
|
|
19912
19563
|
|
|
@@ -19992,17 +19643,15 @@ function attachKnowledgeDocumentUpload(documents) {
|
|
|
19992
19643
|
printProtocolResult(profile.output, {
|
|
19993
19644
|
id: completed.document.id,
|
|
19994
19645
|
knowledgeBaseId: completed.document.knowledgeBaseId,
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
processingStatus: completed.document.processingStatus,
|
|
19999
|
-
chunkCount: completed.document.chunkCount
|
|
19646
|
+
name: completed.document.filename,
|
|
19647
|
+
size: completed.document.fileSize,
|
|
19648
|
+
status: completed.document.processingStatus
|
|
20000
19649
|
});
|
|
20001
19650
|
});
|
|
20002
19651
|
}
|
|
20003
19652
|
|
|
20004
19653
|
// src/commands/protocol/knowledge-export.ts
|
|
20005
|
-
import { basename as basename2 } from "node:path";
|
|
19654
|
+
import { basename as basename2, join as join4 } from "node:path";
|
|
20006
19655
|
function attachmentFileName(contentDisposition) {
|
|
20007
19656
|
if (!contentDisposition)
|
|
20008
19657
|
return null;
|
|
@@ -20037,15 +19686,15 @@ function attachKnowledgeExport(knowledge) {
|
|
|
20037
19686
|
}
|
|
20038
19687
|
if (writesToStdout) {
|
|
20039
19688
|
const contentType = response.headers.get("content-type");
|
|
20040
|
-
|
|
20041
|
-
if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
|
|
19689
|
+
if (process.stdout.isTTY && !isTerminalSafeContentType(contentType)) {
|
|
20042
19690
|
await response.body.cancel();
|
|
20043
|
-
throw new SimApiError(
|
|
19691
|
+
throw new SimApiError(`Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
|
|
20044
19692
|
}
|
|
20045
19693
|
await streamToStdout(response.body);
|
|
20046
19694
|
return;
|
|
20047
19695
|
}
|
|
20048
|
-
const target =
|
|
19696
|
+
const target = options.outputFile ?? join4(process.cwd(), attachmentFileName(response.headers.get("content-disposition")) ?? `${knowledgeBaseId}.simkb.zip`);
|
|
19697
|
+
await saveToFile(response.body, target, Boolean(options.force));
|
|
20049
19698
|
printProtocolResult(profile.output, {
|
|
20050
19699
|
id: knowledgeBaseId,
|
|
20051
19700
|
path: target,
|
|
@@ -20112,11 +19761,11 @@ function createTableWriter() {
|
|
|
20112
19761
|
if (!widths) {
|
|
20113
19762
|
widths = COLUMNS.map((column, index) => Math.min(MAX_CELL_WIDTH2, Math.max(column.floor, visibleWidth(column.header), ...lines.map((line) => visibleWidth(line[index])))));
|
|
20114
19763
|
const header = widths;
|
|
20115
|
-
|
|
19764
|
+
console.log(source_default.dim(COLUMNS.map((column, index) => pad2(column.header.toUpperCase(), header[index])).join(" ").trimEnd()));
|
|
20116
19765
|
}
|
|
20117
19766
|
const locked = widths;
|
|
20118
19767
|
for (const line of lines) {
|
|
20119
|
-
|
|
19768
|
+
console.log(line.map((cell, index) => pad2(cell, locked[index])).join(" ").trimEnd());
|
|
20120
19769
|
}
|
|
20121
19770
|
};
|
|
20122
19771
|
}
|
|
@@ -20124,13 +19773,13 @@ function createWriter(format) {
|
|
|
20124
19773
|
if (format === "json") {
|
|
20125
19774
|
return (rows) => {
|
|
20126
19775
|
for (const row of rows)
|
|
20127
|
-
|
|
19776
|
+
console.log(JSON.stringify(row));
|
|
20128
19777
|
};
|
|
20129
19778
|
}
|
|
20130
19779
|
if (format === "yaml") {
|
|
20131
19780
|
return (rows) => {
|
|
20132
19781
|
for (const row of rows) {
|
|
20133
|
-
|
|
19782
|
+
console.log(`---
|
|
20134
19783
|
${dump(row, { lineWidth: 0, noRefs: true }).trimEnd()}`);
|
|
20135
19784
|
}
|
|
20136
19785
|
};
|
|
@@ -20147,24 +19796,24 @@ function followStatus() {
|
|
|
20147
19796
|
let reported = false;
|
|
20148
19797
|
return {
|
|
20149
19798
|
note: (message) => {
|
|
20150
|
-
if (!
|
|
19799
|
+
if (!process.stderr.isTTY)
|
|
20151
19800
|
return;
|
|
20152
19801
|
reported = true;
|
|
20153
|
-
|
|
19802
|
+
process.stderr.write(`\r${source_default.dim(message)}${ERASE_LINE}`);
|
|
20154
19803
|
},
|
|
20155
19804
|
warn: (message) => {
|
|
20156
19805
|
if (reported) {
|
|
20157
19806
|
reported = false;
|
|
20158
|
-
|
|
19807
|
+
process.stderr.write(`\r${ERASE_LINE}`);
|
|
20159
19808
|
}
|
|
20160
|
-
|
|
19809
|
+
process.stderr.write(`warning: ${message}
|
|
20161
19810
|
`);
|
|
20162
19811
|
},
|
|
20163
19812
|
clear: () => {
|
|
20164
19813
|
if (!reported)
|
|
20165
19814
|
return;
|
|
20166
19815
|
reported = false;
|
|
20167
|
-
|
|
19816
|
+
process.stderr.write(`\r${ERASE_LINE}`);
|
|
20168
19817
|
}
|
|
20169
19818
|
};
|
|
20170
19819
|
}
|
|
@@ -20456,13 +20105,13 @@ async function watchImport(client, workspaceId, job) {
|
|
|
20456
20105
|
const next = await client.request(`/api/v2/tables/imports/${encodeURIComponent(current.id)}`, { query: { workspaceId } });
|
|
20457
20106
|
current = next.data;
|
|
20458
20107
|
const line = progressLine(current);
|
|
20459
|
-
if (
|
|
20108
|
+
if (process.stderr.isTTY && line !== reported) {
|
|
20460
20109
|
reported = line;
|
|
20461
|
-
|
|
20110
|
+
process.stderr.write(`\r${source_default.dim(line)}\x1B[K`);
|
|
20462
20111
|
}
|
|
20463
20112
|
}
|
|
20464
|
-
if (
|
|
20465
|
-
|
|
20113
|
+
if (process.stderr.isTTY && reported !== null)
|
|
20114
|
+
process.stderr.write("\r\x1B[K");
|
|
20466
20115
|
return current;
|
|
20467
20116
|
}
|
|
20468
20117
|
function validateTargetOptions(options) {
|
|
@@ -20520,8 +20169,8 @@ function attachTableImport(tables) {
|
|
|
20520
20169
|
workspaceId,
|
|
20521
20170
|
source,
|
|
20522
20171
|
target,
|
|
20523
|
-
...options.mapping ? { mapping:
|
|
20524
|
-
...options.createColumns ? { createColumns:
|
|
20172
|
+
...options.mapping ? { mapping: jsonFlag(options.mapping, "mapping", "object") } : {},
|
|
20173
|
+
...options.createColumns ? { createColumns: jsonFlag(options.createColumns, "create-columns", "array") } : {},
|
|
20525
20174
|
...options.timezone ? { timezone: options.timezone } : {}
|
|
20526
20175
|
}
|
|
20527
20176
|
});
|
|
@@ -20567,11 +20216,14 @@ var AGENT_STREAM_PROTOCOL_V1 = "agent-events-v1";
|
|
|
20567
20216
|
var WORKFLOW_RESULT_STREAM_CONTENT_TYPE = "application/x-ndjson";
|
|
20568
20217
|
var DONE_SENTINEL = "[DONE]";
|
|
20569
20218
|
function resolveWorkflowRunSelection(flags) {
|
|
20219
|
+
const manual = flags.manual === true;
|
|
20570
20220
|
const trigger = typeof flags.trigger === "string" ? flags.trigger : undefined;
|
|
20571
20221
|
const useMockPayload = flags.mockPayload === true;
|
|
20572
|
-
const manual = flags.manual === true || trigger !== undefined || useMockPayload;
|
|
20573
20222
|
const fromBlock = typeof flags.fromBlock === "string" ? flags.fromBlock : undefined;
|
|
20574
20223
|
const sourceRun = typeof flags.sourceRun === "string" ? flags.sourceRun : undefined;
|
|
20224
|
+
if ((trigger || useMockPayload) && !manual) {
|
|
20225
|
+
throw new SimApiError("--trigger and --mock-payload require --manual", 0);
|
|
20226
|
+
}
|
|
20575
20227
|
if (fromBlock && (trigger || useMockPayload)) {
|
|
20576
20228
|
throw new SimApiError("--from-block cannot be combined with --trigger or --mock-payload", 0);
|
|
20577
20229
|
}
|
|
@@ -20648,7 +20300,7 @@ async function runWithResultStream(workflowId, command) {
|
|
|
20648
20300
|
const operation = V2_OPERATIONS.executeWorkflow;
|
|
20649
20301
|
const commandSpec = CLI_CONTRACT.executeWorkflow ?? {};
|
|
20650
20302
|
try {
|
|
20651
|
-
const request =
|
|
20303
|
+
const request = buildRequest("executeWorkflow", [workflowId], flags, profile.workspaceId);
|
|
20652
20304
|
const response = await client.requestRaw(request.path, {
|
|
20653
20305
|
method: operation.method,
|
|
20654
20306
|
query: request.query,
|
|
@@ -20723,11 +20375,11 @@ class Commentary {
|
|
|
20723
20375
|
function toolNotice(frame) {
|
|
20724
20376
|
const name = safeOneLine(stringField(frame, "name") ?? "tool");
|
|
20725
20377
|
if (frame.phase === "start")
|
|
20726
|
-
return
|
|
20378
|
+
return source_default.dim(`→ ${name}`);
|
|
20727
20379
|
const status = stringField(frame, "status");
|
|
20728
20380
|
if (status && status !== "success")
|
|
20729
|
-
return
|
|
20730
|
-
return
|
|
20381
|
+
return source_default.yellow(`✗ ${name} (${safeOneLine(status)})`);
|
|
20382
|
+
return source_default.dim(`✓ ${name}`);
|
|
20731
20383
|
}
|
|
20732
20384
|
async function renderRunStream(body, options) {
|
|
20733
20385
|
const commentary = new Commentary(options.stderr);
|
|
@@ -20749,11 +20401,11 @@ async function renderRunStream(body, options) {
|
|
|
20749
20401
|
}
|
|
20750
20402
|
switch (frame.event) {
|
|
20751
20403
|
case "chunk_reset":
|
|
20752
|
-
commentary.line(
|
|
20404
|
+
commentary.line(source_default.dim("… retracted; that turn resolved to tool calls"));
|
|
20753
20405
|
break;
|
|
20754
20406
|
case "thinking":
|
|
20755
20407
|
if (options.includeThinking && typeof frame.data === "string") {
|
|
20756
|
-
commentary.inline(
|
|
20408
|
+
commentary.inline(source_default.dim(sanitize(frame.data)));
|
|
20757
20409
|
}
|
|
20758
20410
|
break;
|
|
20759
20411
|
case "tool":
|
|
@@ -20761,7 +20413,7 @@ async function renderRunStream(body, options) {
|
|
|
20761
20413
|
commentary.line(toolNotice(frame));
|
|
20762
20414
|
break;
|
|
20763
20415
|
case "stream_error":
|
|
20764
|
-
commentary.line(
|
|
20416
|
+
commentary.line(source_default.yellow(`warning: ${safeOneLine(stringField(frame, "error") ?? "stream read failed")}`));
|
|
20765
20417
|
break;
|
|
20766
20418
|
case "error":
|
|
20767
20419
|
commentary.endLine();
|
|
@@ -20790,7 +20442,7 @@ async function followRun(workflowId, command) {
|
|
|
20790
20442
|
const negotiates = includeThinking || includeToolCalls;
|
|
20791
20443
|
const { client, profile } = clientFrom(command);
|
|
20792
20444
|
const operation = V2_OPERATIONS.executeWorkflow;
|
|
20793
|
-
const request =
|
|
20445
|
+
const request = buildRequest("executeWorkflow", [workflowId], flags, profile.workspaceId);
|
|
20794
20446
|
const response = await client.requestRaw(request.path, {
|
|
20795
20447
|
method: "POST",
|
|
20796
20448
|
query: request.query,
|
|
@@ -20816,7 +20468,7 @@ async function followRun(workflowId, command) {
|
|
|
20816
20468
|
const final = await renderRunStream(response.body, {
|
|
20817
20469
|
includeThinking,
|
|
20818
20470
|
includeToolCalls,
|
|
20819
|
-
stderr:
|
|
20471
|
+
stderr: process.stderr
|
|
20820
20472
|
});
|
|
20821
20473
|
renderResult("executeWorkflow", profile.output, final, CLI_CONTRACT.executeWorkflow ?? {});
|
|
20822
20474
|
if (final.success === false) {
|
|
@@ -20831,8 +20483,8 @@ function followOrDelegate(previous) {
|
|
|
20831
20483
|
command.setOptionValue("run", selection);
|
|
20832
20484
|
const flags = command.optsWithGlobals();
|
|
20833
20485
|
if (flags.follow !== true) {
|
|
20834
|
-
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0
|
|
20835
|
-
throw new SimApiError("--select-output
|
|
20486
|
+
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0) {
|
|
20487
|
+
throw new SimApiError(flags.async === true ? "--select-output shapes a streamed result, and --async returns as soon as the run is queued, so there is no stream to shape. Drop one of them, or read the finished run with: sim workflows runs get <runId> --workflow <workflowId> --select-output <blockId>[.path] — that resource matches block ids, not the block names --select-output takes here." : "--select-output shapes a streamed result; add --follow. To narrow a run that has already finished: sim workflows runs get <runId> --workflow <workflowId> --select-output <blockId>[.path] — that resource matches block ids, not the block names --select-output takes here.", 0);
|
|
20836
20488
|
}
|
|
20837
20489
|
if (flags.includeThinking === true || flags.includeToolCalls === true) {
|
|
20838
20490
|
throw new SimApiError("--include-thinking and --include-tool-calls describe a stream; add --follow", 0);
|
|
@@ -20858,119 +20510,7 @@ function attachWorkflowRunFollow(workflows) {
|
|
|
20858
20510
|
}
|
|
20859
20511
|
const held = run._actionHandler;
|
|
20860
20512
|
const previous = typeof held === "function" ? held : null;
|
|
20861
|
-
run.option("--manual", "Run the current saved workflow state instead of the active deployment").option("--trigger <blockId>", "Enter
|
|
20862
|
-
}
|
|
20863
|
-
|
|
20864
|
-
// src/commands/protocol/workflow-run-get.ts
|
|
20865
|
-
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
20866
|
-
var SELECT_OUTPUT_FLAG = "select-output";
|
|
20867
|
-
function normalizeBlockName(name) {
|
|
20868
|
-
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
20869
|
-
}
|
|
20870
|
-
function isRecord2(value) {
|
|
20871
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20872
|
-
}
|
|
20873
|
-
async function loadWorkflowBlocks(client, workflowId) {
|
|
20874
|
-
const operation = V2_OPERATIONS.getWorkflowState;
|
|
20875
|
-
const raw = await client.request(resolvePath(operation.path, { workflowId }), {
|
|
20876
|
-
method: operation.method
|
|
20877
|
-
});
|
|
20878
|
-
const state = isRecord2(raw) && isRecord2(raw.data) ? raw.data : raw;
|
|
20879
|
-
const blocks = isRecord2(state) && isRecord2(state.blocks) ? Object.entries(state.blocks) : [];
|
|
20880
|
-
return blocks.map(([key, block]) => ({
|
|
20881
|
-
id: isRecord2(block) && typeof block.id === "string" ? block.id : key,
|
|
20882
|
-
name: isRecord2(block) && typeof block.name === "string" ? block.name : ""
|
|
20883
|
-
}));
|
|
20884
|
-
}
|
|
20885
|
-
function splitSelector(selector) {
|
|
20886
|
-
const dot = selector.indexOf(".");
|
|
20887
|
-
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
20888
|
-
}
|
|
20889
|
-
function isIdHeaded(selector) {
|
|
20890
|
-
return BLOCK_ID.test(splitSelector(selector).head);
|
|
20891
|
-
}
|
|
20892
|
-
function resolveSelection(typed, blocks, workflowId) {
|
|
20893
|
-
const resolved = [];
|
|
20894
|
-
const typedBy = new Map;
|
|
20895
|
-
const unresolved = [];
|
|
20896
|
-
for (const selector of typed) {
|
|
20897
|
-
const { head, path } = splitSelector(selector);
|
|
20898
|
-
let blockId = head;
|
|
20899
|
-
if (!BLOCK_ID.test(head)) {
|
|
20900
|
-
const wanted = normalizeBlockName(head);
|
|
20901
|
-
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
20902
|
-
if (matches.length === 0) {
|
|
20903
|
-
unresolved.push(selector);
|
|
20904
|
-
continue;
|
|
20905
|
-
}
|
|
20906
|
-
if (matches.length > 1) {
|
|
20907
|
-
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
20908
|
-
}
|
|
20909
|
-
blockId = matches[0].id;
|
|
20910
|
-
}
|
|
20911
|
-
const rewritten = `${blockId}${path}`;
|
|
20912
|
-
resolved.push(rewritten);
|
|
20913
|
-
if (!typedBy.has(rewritten))
|
|
20914
|
-
typedBy.set(rewritten, selector);
|
|
20915
|
-
}
|
|
20916
|
-
if (unresolved.length > 0) {
|
|
20917
|
-
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
20918
|
-
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} did not resolve to any block on this run: ${unresolved.join(", ")}. Pass a block id or its name — "blockId", "blockId.path", "blockName" or "blockName.path"; names match ignoring case, spaces and dots. Blocks on workflow ${workflowId}: ${names.length > 0 ? names.join(", ") : "none"}.`, 0);
|
|
20919
|
-
}
|
|
20920
|
-
return { resolved, typedBy };
|
|
20921
|
-
}
|
|
20922
|
-
function keyByTyped(payload, typedBy) {
|
|
20923
|
-
if (!isRecord2(payload) || !isRecord2(payload.blockOutputs))
|
|
20924
|
-
return payload;
|
|
20925
|
-
const blockOutputs = {};
|
|
20926
|
-
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
20927
|
-
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
20928
|
-
}
|
|
20929
|
-
return { ...payload, blockOutputs };
|
|
20930
|
-
}
|
|
20931
|
-
async function readRunByName(runId, typed, command) {
|
|
20932
|
-
const flags = command.optsWithGlobals();
|
|
20933
|
-
const { client, profile } = clientFrom(command);
|
|
20934
|
-
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
20935
|
-
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
20936
|
-
await buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
20937
|
-
const workflowId = String(flags.workflow);
|
|
20938
|
-
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
20939
|
-
const request = await buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
20940
|
-
let result;
|
|
20941
|
-
try {
|
|
20942
|
-
result = await client.request(request.path, {
|
|
20943
|
-
method: operation.method,
|
|
20944
|
-
headers: request.headers,
|
|
20945
|
-
query: request.query,
|
|
20946
|
-
body: request.body
|
|
20947
|
-
});
|
|
20948
|
-
} catch (error) {
|
|
20949
|
-
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
20950
|
-
}
|
|
20951
|
-
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
20952
|
-
}
|
|
20953
|
-
function attachWorkflowRunGet(runs) {
|
|
20954
|
-
const get = runs.commands.find((command) => command.name() === "get");
|
|
20955
|
-
const held = get?._actionHandler;
|
|
20956
|
-
if (!get || typeof held !== "function") {
|
|
20957
|
-
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
20958
|
-
}
|
|
20959
|
-
const previous = held;
|
|
20960
|
-
get.action(async (runId, _options, command) => {
|
|
20961
|
-
const raw = command.optsWithGlobals().selectOutput;
|
|
20962
|
-
if (raw === undefined) {
|
|
20963
|
-
await previous(command.processedArgs);
|
|
20964
|
-
return;
|
|
20965
|
-
}
|
|
20966
|
-
const typed = await readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
20967
|
-
command.setOptionValue("selectOutput", typed);
|
|
20968
|
-
if (typed.every(isIdHeaded)) {
|
|
20969
|
-
await previous(command.processedArgs);
|
|
20970
|
-
return;
|
|
20971
|
-
}
|
|
20972
|
-
await readRunByName(runId, typed, command);
|
|
20973
|
-
});
|
|
20513
|
+
run.option("--manual", "Run the current saved workflow state instead of the active deployment").option("--trigger <blockId>", "Enter a manual run through this runnable trigger (requires --manual)").option("--mock-payload", "Use the selected trigger's server-derived mock payload (requires --manual)").option("--from-block <blockId>", "Run manually from this saved workflow block").option("--source-run <runId>", "Prior run whose persisted state supplies upstream outputs (requires --from-block)").option("--follow", "Stream the run as it happens; progress on stderr, result on stdout. The stream reports only success and output, so the result omits the run id and timings a non-streaming run returns").option("--include-thinking", "Show model reasoning while following (requires --follow)").option("--include-tool-calls", "Show tool calls while following (requires --follow)").action(followOrDelegate(previous));
|
|
20974
20514
|
}
|
|
20975
20515
|
|
|
20976
20516
|
// src/commands/protocol/workflow-run-wait.ts
|
|
@@ -20987,21 +20527,18 @@ var MAX_POLL_DELAY_MS = 15000;
|
|
|
20987
20527
|
var POLL_BACKOFF_FACTOR = 2;
|
|
20988
20528
|
var DEFAULT_WAIT_TIMEOUT_SECONDS = 3600;
|
|
20989
20529
|
var WAIT_TIMEOUT_FLAG = "--wait-timeout <seconds>";
|
|
20990
|
-
function
|
|
20530
|
+
function isRecord2(value) {
|
|
20991
20531
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20992
20532
|
}
|
|
20993
20533
|
function optionalString(value) {
|
|
20994
20534
|
return typeof value === "string" && value !== "" ? value : null;
|
|
20995
20535
|
}
|
|
20996
|
-
function runData(raw) {
|
|
20997
|
-
return isRecord3(raw) && isRecord3(raw.data) ? raw.data : raw;
|
|
20998
|
-
}
|
|
20999
20536
|
function readRun(raw) {
|
|
21000
|
-
const run =
|
|
21001
|
-
if (!
|
|
20537
|
+
const run = isRecord2(raw) && isRecord2(raw.data) ? raw.data : raw;
|
|
20538
|
+
if (!isRecord2(run) || typeof run.status !== "string") {
|
|
21002
20539
|
throw new SimApiError("Run status response carried no status.", 0);
|
|
21003
20540
|
}
|
|
21004
|
-
const paused =
|
|
20541
|
+
const paused = isRecord2(run.paused) ? run.paused : null;
|
|
21005
20542
|
return {
|
|
21006
20543
|
status: run.status,
|
|
21007
20544
|
pauseKind: paused ? optionalString(paused.pauseKind) : null,
|
|
@@ -21020,16 +20557,16 @@ function waitProgress() {
|
|
|
21020
20557
|
let reported = false;
|
|
21021
20558
|
return {
|
|
21022
20559
|
advance: (status, elapsedMs) => {
|
|
21023
|
-
if (!
|
|
20560
|
+
if (!process.stderr.isTTY)
|
|
21024
20561
|
return;
|
|
21025
20562
|
reported = true;
|
|
21026
|
-
|
|
20563
|
+
process.stderr.write(`\r${source_default.dim(`${status} — waiting ${Math.round(elapsedMs / 1000)}s…`)}\x1B[K`);
|
|
21027
20564
|
},
|
|
21028
20565
|
finish: () => {
|
|
21029
20566
|
if (!reported)
|
|
21030
20567
|
return;
|
|
21031
20568
|
reported = false;
|
|
21032
|
-
|
|
20569
|
+
process.stderr.write("\r\x1B[K");
|
|
21033
20570
|
}
|
|
21034
20571
|
};
|
|
21035
20572
|
}
|
|
@@ -21070,19 +20607,19 @@ function attachWorkflowRunWait(runs) {
|
|
|
21070
20607
|
const outcome = classify(snapshot);
|
|
21071
20608
|
if (outcome) {
|
|
21072
20609
|
progress.finish();
|
|
21073
|
-
renderResult("getWorkflowRun", profile.output,
|
|
20610
|
+
renderResult("getWorkflowRun", profile.output, raw, runSpec());
|
|
21074
20611
|
const message = explain(outcome, runId, options.workflow, snapshot);
|
|
21075
20612
|
if (message)
|
|
21076
|
-
|
|
21077
|
-
|
|
20613
|
+
console.error(source_default.red(message));
|
|
20614
|
+
process.exitCode = WAIT_EXIT_CODES[outcome];
|
|
21078
20615
|
return;
|
|
21079
20616
|
}
|
|
21080
20617
|
const remainingMs = deadline - Date.now();
|
|
21081
20618
|
if (remainingMs <= 0) {
|
|
21082
20619
|
progress.finish();
|
|
21083
|
-
renderResult("getWorkflowRun", profile.output,
|
|
21084
|
-
|
|
21085
|
-
|
|
20620
|
+
renderResult("getWorkflowRun", profile.output, raw, runSpec());
|
|
20621
|
+
console.error(source_default.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.`));
|
|
20622
|
+
process.exitCode = WAIT_EXIT_CODES.timeout;
|
|
21086
20623
|
return;
|
|
21087
20624
|
}
|
|
21088
20625
|
progress.advance(snapshot.status, Date.now() - startedAt);
|
|
@@ -21139,9 +20676,7 @@ function attachProtocolCommands(program) {
|
|
|
21139
20676
|
createFolder: "createWorkflowFolder"
|
|
21140
20677
|
});
|
|
21141
20678
|
attachWorkflowRunFollow(workflows);
|
|
21142
|
-
|
|
21143
|
-
attachWorkflowRunGet(runs);
|
|
21144
|
-
attachWorkflowRunWait(runs);
|
|
20679
|
+
attachWorkflowRunWait(group(workflows, "runs"));
|
|
21145
20680
|
attachWorkspaceOperationWait(group(group(program, "workspaces"), "operations"));
|
|
21146
20681
|
attachLogsFollow(group(program, "logs"));
|
|
21147
20682
|
attachChat(program);
|
|
@@ -21245,12 +20780,12 @@ var SECRET_RESULT = {
|
|
|
21245
20780
|
{ header: "description" }
|
|
21246
20781
|
]
|
|
21247
20782
|
};
|
|
21248
|
-
|
|
20783
|
+
function readValueArgument(raw) {
|
|
21249
20784
|
if (raw.startsWith("@@"))
|
|
21250
20785
|
return raw.slice(1);
|
|
21251
20786
|
if (!raw.startsWith("@"))
|
|
21252
20787
|
return raw;
|
|
21253
|
-
return
|
|
20788
|
+
return readArgumentSource(raw, "value").text;
|
|
21254
20789
|
}
|
|
21255
20790
|
function validateSecretValue(value) {
|
|
21256
20791
|
if (value.length === 0)
|
|
@@ -21270,7 +20805,7 @@ function validateWorkspaceOnlyFlag(flag, value, scope) {
|
|
|
21270
20805
|
}
|
|
21271
20806
|
async function readSecretValue(options) {
|
|
21272
20807
|
if (options.value !== undefined)
|
|
21273
|
-
return validateSecretValue(
|
|
20808
|
+
return validateSecretValue(readValueArgument(options.value));
|
|
21274
20809
|
if (options.description !== undefined || options.unredacted !== undefined)
|
|
21275
20810
|
return;
|
|
21276
20811
|
try {
|
|
@@ -21278,8 +20813,8 @@ async function readSecretValue(options) {
|
|
|
21278
20813
|
} catch (error) {
|
|
21279
20814
|
if (!(error instanceof SecretInputCancelledError))
|
|
21280
20815
|
throw error;
|
|
21281
|
-
|
|
21282
|
-
return
|
|
20816
|
+
console.error(source_default.red(`Error: ${error.message}`));
|
|
20817
|
+
return process.exit(CANCELLED_EXIT_CODE);
|
|
21283
20818
|
}
|
|
21284
20819
|
}
|
|
21285
20820
|
async function setSecret(name, options, command, redactionSpellings) {
|
|
@@ -21451,7 +20986,7 @@ function createCommandTelemetry(options = {}) {
|
|
|
21451
20986
|
writeTelemetryState({ ...state, session });
|
|
21452
20987
|
const properties = {
|
|
21453
20988
|
$lib: LIBRARY_NAME,
|
|
21454
|
-
$lib_version:
|
|
20989
|
+
$lib_version: CLI_VERSION,
|
|
21455
20990
|
$process_person_profile: false,
|
|
21456
20991
|
$session_id: session.id,
|
|
21457
20992
|
session_sequence: session.sequence,
|
|
@@ -21462,7 +20997,7 @@ function createCommandTelemetry(options = {}) {
|
|
|
21462
20997
|
exit_code: outcome.exitCode,
|
|
21463
20998
|
duration_ms: Math.round(elapsed()),
|
|
21464
20999
|
...failureProperties(outcome.error),
|
|
21465
|
-
cli_version:
|
|
21000
|
+
cli_version: CLI_VERSION,
|
|
21466
21001
|
node_version: process.versions.node,
|
|
21467
21002
|
os: process.platform,
|
|
21468
21003
|
arch: process.arch,
|
|
@@ -21601,22 +21136,19 @@ function addVersionOption(program) {
|
|
|
21601
21136
|
}
|
|
21602
21137
|
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.");
|
|
21603
21138
|
});
|
|
21604
|
-
program.version(
|
|
21139
|
+
program.version(CLI_VERSION, "-V, --version [none]", "output the version number (takes no value)");
|
|
21605
21140
|
}
|
|
21606
21141
|
function buildProgram(options = {}) {
|
|
21607
|
-
const program =
|
|
21142
|
+
const program = new Command;
|
|
21608
21143
|
program.name("sim").description(PROGRAM_DESCRIPTION);
|
|
21609
21144
|
if (options.version !== false)
|
|
21610
21145
|
addVersionOption(program);
|
|
21611
21146
|
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]));
|
|
21612
|
-
|
|
21613
|
-
|
|
21614
|
-
|
|
21615
|
-
|
|
21616
|
-
|
|
21617
|
-
configureCommand
|
|
21618
|
-
])
|
|
21619
|
-
program.addCommand(command());
|
|
21147
|
+
program.addCommand(loginCommand());
|
|
21148
|
+
program.addCommand(logoutCommand());
|
|
21149
|
+
program.addCommand(whoamiCommand());
|
|
21150
|
+
program.addCommand(profilesCommand());
|
|
21151
|
+
program.addCommand(configureCommand());
|
|
21620
21152
|
const update = updateCommand();
|
|
21621
21153
|
program.addCommand(update);
|
|
21622
21154
|
program.addCommand(telemetryCommand());
|
|
@@ -21626,7 +21158,7 @@ function buildProgram(options = {}) {
|
|
|
21626
21158
|
attachCredentialCommands(program);
|
|
21627
21159
|
attachProtocolCommands(program);
|
|
21628
21160
|
attachSecretCommands(program);
|
|
21629
|
-
program.addHelpText("after",
|
|
21161
|
+
program.addHelpText("after", HELP_EPILOGUE);
|
|
21630
21162
|
program.hook("preAction", async (_program, command) => {
|
|
21631
21163
|
if (command === update)
|
|
21632
21164
|
return;
|
|
@@ -21637,14 +21169,14 @@ function buildProgram(options = {}) {
|
|
|
21637
21169
|
return program;
|
|
21638
21170
|
}
|
|
21639
21171
|
|
|
21640
|
-
// src/
|
|
21172
|
+
// src/index.ts
|
|
21641
21173
|
function explainFailure(error, program) {
|
|
21642
21174
|
if (error instanceof ProfileConfigError || error instanceof CliUpdateError) {
|
|
21643
|
-
console.error(
|
|
21175
|
+
console.error(source_default.red(`Error: ${sanitize(error.message)}`));
|
|
21644
21176
|
return 1;
|
|
21645
21177
|
}
|
|
21646
21178
|
if (isRequestTimeout(error)) {
|
|
21647
|
-
console.error(
|
|
21179
|
+
console.error(source_default.red(`Error: the request timed out. ${RAISE_TIMEOUT_HINT}`));
|
|
21648
21180
|
return 1;
|
|
21649
21181
|
}
|
|
21650
21182
|
if (error instanceof SimApiError) {
|
|
@@ -21664,32 +21196,30 @@ function explainFailure(error, program) {
|
|
|
21664
21196
|
` : dump(payload));
|
|
21665
21197
|
return error.exitCode;
|
|
21666
21198
|
}
|
|
21667
|
-
console.error(
|
|
21199
|
+
console.error(source_default.red(`Error: ${sanitize(error.message)}`));
|
|
21668
21200
|
if (error.code)
|
|
21669
|
-
console.error(
|
|
21201
|
+
console.error(source_default.dim(` code: ${sanitize(error.code)}`));
|
|
21670
21202
|
if (error.details !== undefined) {
|
|
21671
21203
|
for (const line of formatApiErrorDetails(error.details)) {
|
|
21672
|
-
console.error(
|
|
21204
|
+
console.error(source_default.dim(sanitize(line)));
|
|
21673
21205
|
}
|
|
21674
21206
|
}
|
|
21675
21207
|
return error.exitCode;
|
|
21676
21208
|
}
|
|
21677
21209
|
return null;
|
|
21678
21210
|
}
|
|
21679
|
-
async function
|
|
21680
|
-
const telemetry =
|
|
21681
|
-
const program =
|
|
21682
|
-
telemetry
|
|
21211
|
+
async function main() {
|
|
21212
|
+
const telemetry = createCommandTelemetry();
|
|
21213
|
+
const program = buildProgram();
|
|
21214
|
+
telemetry.observe(program);
|
|
21683
21215
|
try {
|
|
21684
21216
|
await program.parseAsync(process.argv);
|
|
21685
21217
|
} catch (error) {
|
|
21686
21218
|
const exitCode = explainFailure(error, program);
|
|
21687
|
-
telemetry
|
|
21219
|
+
telemetry.complete({ exitCode: exitCode ?? 1, error });
|
|
21688
21220
|
if (exitCode === null)
|
|
21689
21221
|
throw error;
|
|
21690
21222
|
process.exit(exitCode);
|
|
21691
21223
|
}
|
|
21692
21224
|
}
|
|
21693
|
-
|
|
21694
|
-
// src/index.ts
|
|
21695
|
-
runTerminalCli();
|
|
21225
|
+
main();
|