sim 2.1.5-dev.73.1 → 2.1.5-preview.72.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 +80 -103
- package/package.json +1 -7
package/dist/index.js
CHANGED
|
@@ -2314,30 +2314,6 @@ function credentialsPath() {
|
|
|
2314
2314
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2315
2315
|
import { dirname } from "node:path";
|
|
2316
2316
|
|
|
2317
|
-
// src/embed-context.ts
|
|
2318
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2319
|
-
function setSoftExitCode(code) {
|
|
2320
|
-
const ctx = embedStore.getStore();
|
|
2321
|
-
if (ctx)
|
|
2322
|
-
ctx.softExitCode = code;
|
|
2323
|
-
else
|
|
2324
|
-
process.exitCode = code;
|
|
2325
|
-
}
|
|
2326
|
-
var embedStore = new AsyncLocalStorage;
|
|
2327
|
-
function embeddedProfile() {
|
|
2328
|
-
const ctx = embedStore.getStore();
|
|
2329
|
-
if (!ctx)
|
|
2330
|
-
return null;
|
|
2331
|
-
return {
|
|
2332
|
-
name: "embedded",
|
|
2333
|
-
endpoint: ctx.identity.endpoint,
|
|
2334
|
-
apiKey: ctx.identity.apiKey,
|
|
2335
|
-
workspaceId: ctx.identity.workspaceId ?? null,
|
|
2336
|
-
output: "json",
|
|
2337
|
-
sources: { endpoint: "flag", apiKey: "flag", workspaceId: "flag", output: "flag" }
|
|
2338
|
-
};
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
2317
|
// src/config/ini.ts
|
|
2342
2318
|
class ProfileConfigError extends Error {
|
|
2343
2319
|
constructor(message) {
|
|
@@ -2653,9 +2629,6 @@ function refuseBlankOverrides(overrides) {
|
|
|
2653
2629
|
}
|
|
2654
2630
|
}
|
|
2655
2631
|
function resolveProfile(overrides = {}) {
|
|
2656
|
-
const embedded = embeddedProfile();
|
|
2657
|
-
if (embedded)
|
|
2658
|
-
return embedded;
|
|
2659
2632
|
refuseBlankOverrides(overrides);
|
|
2660
2633
|
const named = overrides.profile || process.env.SIM_PROFILE;
|
|
2661
2634
|
const name = named || DEFAULT_PROFILE;
|
|
@@ -2708,22 +2681,14 @@ function resolveProfile(overrides = {}) {
|
|
|
2708
2681
|
// src/version.ts
|
|
2709
2682
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2710
2683
|
function readPackageVersion() {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
} catch {}
|
|
2717
|
-
return "0.0.0-embedded";
|
|
2718
|
-
}
|
|
2719
|
-
var cachedVersion = null;
|
|
2720
|
-
function cliVersion() {
|
|
2721
|
-
cachedVersion ??= readPackageVersion();
|
|
2722
|
-
return cachedVersion;
|
|
2723
|
-
}
|
|
2724
|
-
function userAgent() {
|
|
2725
|
-
return `sim-cli/${cliVersion()} node/${process.versions.node} (${process.platform}; ${process.arch})`;
|
|
2684
|
+
const metadata = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
|
|
2685
|
+
if (typeof metadata !== "object" || metadata === null || !("version" in metadata) || typeof metadata.version !== "string") {
|
|
2686
|
+
throw new Error("CLI package metadata is missing a valid version");
|
|
2687
|
+
}
|
|
2688
|
+
return metadata.version;
|
|
2726
2689
|
}
|
|
2690
|
+
var CLI_VERSION = readPackageVersion();
|
|
2691
|
+
var USER_AGENT = `sim-cli/${CLI_VERSION} node/${process.versions.node} (${process.platform}; ${process.arch})`;
|
|
2727
2692
|
|
|
2728
2693
|
// src/http/environment.ts
|
|
2729
2694
|
var reported = new Set;
|
|
@@ -3006,7 +2971,7 @@ class SimClient {
|
|
|
3006
2971
|
headers: {
|
|
3007
2972
|
...apiKey ? { "x-api-key": apiKey } : {},
|
|
3008
2973
|
accept: "application/json",
|
|
3009
|
-
"user-agent":
|
|
2974
|
+
"user-agent": USER_AGENT,
|
|
3010
2975
|
...hasBody ? { "content-type": "application/json" } : {},
|
|
3011
2976
|
...options.headers
|
|
3012
2977
|
},
|
|
@@ -6505,7 +6470,7 @@ async function pollForKey(endpoint, auth, signal) {
|
|
|
6505
6470
|
headers: {
|
|
6506
6471
|
"content-type": "application/json",
|
|
6507
6472
|
accept: "application/json",
|
|
6508
|
-
"user-agent":
|
|
6473
|
+
"user-agent": USER_AGENT
|
|
6509
6474
|
},
|
|
6510
6475
|
body: JSON.stringify({ request: auth.request, verifier: auth.pollSecret }),
|
|
6511
6476
|
signal,
|
|
@@ -7002,11 +6967,6 @@ var V2_OPERATIONS = {
|
|
|
7002
6967
|
conversationId: {
|
|
7003
6968
|
kind: "string",
|
|
7004
6969
|
describe: "Conversation to continue; a new one starts when omitted."
|
|
7005
|
-
},
|
|
7006
|
-
effort: {
|
|
7007
|
-
kind: "enum",
|
|
7008
|
-
values: ["low", "medium", "high", "xhigh", "max"],
|
|
7009
|
-
describe: "Model effort for this turn; defaults to the deployment default (high)."
|
|
7010
6970
|
}
|
|
7011
6971
|
}
|
|
7012
6972
|
},
|
|
@@ -8303,6 +8263,37 @@ var V2_OPERATIONS = {
|
|
|
8303
8263
|
}
|
|
8304
8264
|
}
|
|
8305
8265
|
},
|
|
8266
|
+
executeTool: {
|
|
8267
|
+
method: "POST",
|
|
8268
|
+
path: "/api/v2/tools/[toolId]/execute",
|
|
8269
|
+
pathParams: ["toolId"],
|
|
8270
|
+
pathParamDocs: {
|
|
8271
|
+
toolId: "Tool identifier. An unversioned name resolves to the newest version, and the response echoes the resolved id."
|
|
8272
|
+
},
|
|
8273
|
+
responseMode: "json",
|
|
8274
|
+
summary: "Run Tool",
|
|
8275
|
+
personalKeyOnly: true,
|
|
8276
|
+
body: {
|
|
8277
|
+
workspaceId: {
|
|
8278
|
+
kind: "string",
|
|
8279
|
+
required: true,
|
|
8280
|
+
describe: "Workspace whose integration allowlist, credentials, and environment variables govern this call."
|
|
8281
|
+
},
|
|
8282
|
+
input: {
|
|
8283
|
+
kind: "object",
|
|
8284
|
+
default: {},
|
|
8285
|
+
describe: "Arguments for the tool, keyed by the parameter ids the tool catalog publishes for it. A parameter whose visibility is `user-only` also accepts an environment-variable reference written as the whole value, `{{VAR_NAME}}`, resolved server-side against the workspace environment; any other value is sent verbatim."
|
|
8286
|
+
},
|
|
8287
|
+
credentialId: {
|
|
8288
|
+
kind: "string",
|
|
8289
|
+
describe: "Credential to authenticate with. Required when the tool declares an OAuth requirement; the workspace credentials list names the candidates."
|
|
8290
|
+
},
|
|
8291
|
+
timeoutSeconds: {
|
|
8292
|
+
kind: "integer",
|
|
8293
|
+
describe: "How long to wait for the tool before abandoning the call."
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
},
|
|
8306
8297
|
executeWorkflow: {
|
|
8307
8298
|
method: "POST",
|
|
8308
8299
|
path: "/api/v2/workflows/[workflowId]/execute",
|
|
@@ -8335,7 +8326,7 @@ var V2_OPERATIONS = {
|
|
|
8335
8326
|
},
|
|
8336
8327
|
selectedOutputs: {
|
|
8337
8328
|
kind: "array",
|
|
8338
|
-
describe: "Block output references to include in
|
|
8329
|
+
describe: "Block output references to include in a streamed response. Use `<blockName>.<outputPath>` for the executed workflow or `<childWorkflowId>.<blockName>.<outputPath>` for a child workflow; block names are normalized workflow reference names. Selecting a child workflow applies to every invocation of it. Requires `stream: true` — it shapes the streamed envelope only, so it is rejected on a sync request and when `async` is true. To narrow a finished run, pass `selectedOutputs` to the run resource instead."
|
|
8339
8330
|
},
|
|
8340
8331
|
includeThinking: {
|
|
8341
8332
|
kind: "boolean",
|
|
@@ -8987,7 +8978,8 @@ var V2_OPERATIONS = {
|
|
|
8987
8978
|
"knowledge-base",
|
|
8988
8979
|
"voice-input",
|
|
8989
8980
|
"enrichment",
|
|
8990
|
-
"voice-output"
|
|
8981
|
+
"voice-output",
|
|
8982
|
+
"api-tool"
|
|
8991
8983
|
],
|
|
8992
8984
|
describe: "Restrict results to one usage source."
|
|
8993
8985
|
},
|
|
@@ -11867,7 +11859,7 @@ function whoamiCommand() {
|
|
|
11867
11859
|
});
|
|
11868
11860
|
const exitCode = WHOAMI_EXIT_CODES[verification.status];
|
|
11869
11861
|
if (exitCode !== 0)
|
|
11870
|
-
|
|
11862
|
+
process.exitCode = exitCode;
|
|
11871
11863
|
});
|
|
11872
11864
|
}
|
|
11873
11865
|
var PROFILE_COLUMNS = [
|
|
@@ -13065,6 +13057,24 @@ var CLI_CONTRACT = {
|
|
|
13065
13057
|
describe: "Print a workflow as a portable JSON document",
|
|
13066
13058
|
document: true
|
|
13067
13059
|
},
|
|
13060
|
+
executeTool: {
|
|
13061
|
+
command: "tools execute",
|
|
13062
|
+
describe: "Run one built-in tool and print what it produced",
|
|
13063
|
+
flags: {
|
|
13064
|
+
input: {
|
|
13065
|
+
json: true,
|
|
13066
|
+
describe: "Tool arguments as JSON, keyed by the parameter ids `sim tools get <toolId>` lists"
|
|
13067
|
+
},
|
|
13068
|
+
credentialId: { describe: "Credential to authenticate with, required for OAuth tools" },
|
|
13069
|
+
timeoutSeconds: { name: "timeout", describe: "Seconds to wait before abandoning the call" }
|
|
13070
|
+
},
|
|
13071
|
+
fields: [
|
|
13072
|
+
{ path: "toolId", header: "Tool" },
|
|
13073
|
+
{ path: "status", header: "Status" },
|
|
13074
|
+
{ path: "output", header: "Output" },
|
|
13075
|
+
{ path: "error.message", header: "Error" }
|
|
13076
|
+
]
|
|
13077
|
+
},
|
|
13068
13078
|
executeWorkflow: {
|
|
13069
13079
|
command: "workflows run",
|
|
13070
13080
|
describe: "Run a deployed workflow or execute saved state manually",
|
|
@@ -13078,7 +13088,7 @@ var CLI_CONTRACT = {
|
|
|
13078
13088
|
selectedOutputs: {
|
|
13079
13089
|
name: "select-output",
|
|
13080
13090
|
list: true,
|
|
13081
|
-
describe: "Return
|
|
13091
|
+
describe: "Return streamed outputs as blockName.path or childWorkflowId.blockName.path; selecting a child workflow applies to every invocation, requires --follow"
|
|
13082
13092
|
},
|
|
13083
13093
|
stream: { omit: true },
|
|
13084
13094
|
includeThinking: { omit: true },
|
|
@@ -13296,13 +13306,6 @@ function readArgumentSource(raw, flagName) {
|
|
|
13296
13306
|
return { text: raw.slice(1), from: "" };
|
|
13297
13307
|
if (!raw.startsWith("@"))
|
|
13298
13308
|
return { text: raw, from: "" };
|
|
13299
|
-
const embedded = embedStore.getStore();
|
|
13300
|
-
if (embedded) {
|
|
13301
|
-
const preloaded = embedded.fileArguments?.[raw.slice(1)];
|
|
13302
|
-
if (preloaded !== undefined)
|
|
13303
|
-
return { text: preloaded, from: " (read from your machine)" };
|
|
13304
|
-
throw new SimApiError(`--${flagName}: no file "${raw.slice(1)}" on this machine — write it first (run_code), or pass the value inline`, 0);
|
|
13305
|
-
}
|
|
13306
13309
|
const path = raw.slice(1);
|
|
13307
13310
|
if (path === "-") {
|
|
13308
13311
|
if (process.stdin.isTTY) {
|
|
@@ -13986,20 +13989,25 @@ function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
|
13986
13989
|
}
|
|
13987
13990
|
|
|
13988
13991
|
// src/runtime/execute.ts
|
|
13989
|
-
var RUN_OUTCOME_OPERATIONS =
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13992
|
+
var RUN_OUTCOME_OPERATIONS = {
|
|
13993
|
+
executeWorkflow: {
|
|
13994
|
+
failed: "The workflow run failed.",
|
|
13995
|
+
cancelled: "The workflow run was cancelled."
|
|
13996
|
+
},
|
|
13997
|
+
executeTool: {
|
|
13998
|
+
failed: "The tool call failed."
|
|
13999
|
+
}
|
|
13993
14000
|
};
|
|
13994
14001
|
function runFailureMessage(operation, payload) {
|
|
13995
|
-
|
|
14002
|
+
const failureMessages = RUN_OUTCOME_OPERATIONS[operation];
|
|
14003
|
+
if (!failureMessages)
|
|
13996
14004
|
return null;
|
|
13997
14005
|
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
13998
14006
|
return null;
|
|
13999
14007
|
const { status, error } = payload;
|
|
14000
14008
|
if (typeof status !== "string")
|
|
14001
14009
|
return null;
|
|
14002
|
-
const fallback =
|
|
14010
|
+
const fallback = failureMessages[status];
|
|
14003
14011
|
if (!fallback)
|
|
14004
14012
|
return null;
|
|
14005
14013
|
const reported2 = error?.message;
|
|
@@ -14967,18 +14975,6 @@ async function saveStagedFile(body, target, force) {
|
|
|
14967
14975
|
}
|
|
14968
14976
|
}
|
|
14969
14977
|
async function saveToFile(body, target, force) {
|
|
14970
|
-
const embedded = embedStore.getStore();
|
|
14971
|
-
if (embedded) {
|
|
14972
|
-
if (!embedded.writeFile) {
|
|
14973
|
-
throw new SimApiError(`--output-file cannot save ${target} here: this surface has no machine to write to. Read the file instead, or pipe a text command with | to-sandbox <name>.`, 0);
|
|
14974
|
-
}
|
|
14975
|
-
const bytes2 = new Uint8Array(await new Response(body).arrayBuffer());
|
|
14976
|
-
const written = await embedded.writeFile(target, bytes2);
|
|
14977
|
-
if (!written) {
|
|
14978
|
-
throw new SimApiError(`Could not write ${target} on your machine — the workbench is not running yet; run any run_code call first, then retry.`, 0);
|
|
14979
|
-
}
|
|
14980
|
-
return;
|
|
14981
|
-
}
|
|
14982
14978
|
return saveStagedFile(body, target, force);
|
|
14983
14979
|
}
|
|
14984
14980
|
async function streamToStdout(body, output = process.stdout) {
|
|
@@ -15050,16 +15046,6 @@ function attachFileGet(files) {
|
|
|
15050
15046
|
import { constants } from "node:fs";
|
|
15051
15047
|
import { access, stat } from "node:fs/promises";
|
|
15052
15048
|
import { basename } from "node:path";
|
|
15053
|
-
function embeddedFileKey(path) {
|
|
15054
|
-
return path.startsWith("@") ? path.slice(1) : path;
|
|
15055
|
-
}
|
|
15056
|
-
function embeddedFileContent(embedded, path) {
|
|
15057
|
-
const key = embeddedFileKey(path);
|
|
15058
|
-
const content = embedded.fileArguments?.[key];
|
|
15059
|
-
if (content !== undefined)
|
|
15060
|
-
return content;
|
|
15061
|
-
throw new SimApiError(`Files on your machine are passed as @path: use @${key}. (If it does not exist yet, write it with run_code or | to-sandbox first.)`, 0);
|
|
15062
|
-
}
|
|
15063
15049
|
var CONTENT_TYPES = {
|
|
15064
15050
|
css: "text/css",
|
|
15065
15051
|
csv: "text/csv",
|
|
@@ -15093,14 +15079,6 @@ function contentTypeFor(name) {
|
|
|
15093
15079
|
return CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
15094
15080
|
}
|
|
15095
15081
|
async function localFile(path, override) {
|
|
15096
|
-
const embedded = embedStore.getStore();
|
|
15097
|
-
if (embedded) {
|
|
15098
|
-
const content = embeddedFileContent(embedded, path);
|
|
15099
|
-
const size2 = Buffer.byteLength(content);
|
|
15100
|
-
if (size2 === 0)
|
|
15101
|
-
throw new SimApiError(`${path} is empty`, 0);
|
|
15102
|
-
return { name: override ?? basename(embeddedFileKey(path)), size: size2 };
|
|
15103
|
-
}
|
|
15104
15082
|
let size;
|
|
15105
15083
|
try {
|
|
15106
15084
|
const stats = await stat(path);
|
|
@@ -15163,8 +15141,7 @@ async function uploadParts(client, workspaceId, session, transfer, blob) {
|
|
|
15163
15141
|
}
|
|
15164
15142
|
async function finishUploadSession(client, workspaceId, session, path) {
|
|
15165
15143
|
try {
|
|
15166
|
-
const
|
|
15167
|
-
const blob = embedded ? new Blob([embeddedFileContent(embedded, path)]) : await openAsBlob(path);
|
|
15144
|
+
const blob = await openAsBlob(path);
|
|
15168
15145
|
if (session.transfer.method === "put") {
|
|
15169
15146
|
await uploadPut(session.transfer, blob);
|
|
15170
15147
|
} else {
|
|
@@ -16003,8 +15980,8 @@ function followOrDelegate(previous) {
|
|
|
16003
15980
|
command.setOptionValue("run", selection);
|
|
16004
15981
|
const flags = command.optsWithGlobals();
|
|
16005
15982
|
if (flags.follow !== true) {
|
|
16006
|
-
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0
|
|
16007
|
-
throw new SimApiError("--select-output
|
|
15983
|
+
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0) {
|
|
15984
|
+
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);
|
|
16008
15985
|
}
|
|
16009
15986
|
if (flags.includeThinking === true || flags.includeToolCalls === true) {
|
|
16010
15987
|
throw new SimApiError("--include-thinking and --include-tool-calls describe a stream; add --follow", 0);
|
|
@@ -16127,7 +16104,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16127
16104
|
const message = explain(outcome, runId, options.workflow, snapshot);
|
|
16128
16105
|
if (message)
|
|
16129
16106
|
console.error(source_default.red(message));
|
|
16130
|
-
|
|
16107
|
+
process.exitCode = WAIT_EXIT_CODES[outcome];
|
|
16131
16108
|
return;
|
|
16132
16109
|
}
|
|
16133
16110
|
const remainingMs = deadline - Date.now();
|
|
@@ -16135,7 +16112,7 @@ function attachWorkflowRunWait(runs) {
|
|
|
16135
16112
|
progress.finish();
|
|
16136
16113
|
renderResult("getWorkflowRun", profile.output, raw, runSpec());
|
|
16137
16114
|
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.`));
|
|
16138
|
-
|
|
16115
|
+
process.exitCode = WAIT_EXIT_CODES.timeout;
|
|
16139
16116
|
return;
|
|
16140
16117
|
}
|
|
16141
16118
|
progress.advance(snapshot.status, Date.now() - startedAt);
|
|
@@ -16419,7 +16396,7 @@ function addVersionOption(program2) {
|
|
|
16419
16396
|
}
|
|
16420
16397
|
program2.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.");
|
|
16421
16398
|
});
|
|
16422
|
-
program2.version(
|
|
16399
|
+
program2.version(CLI_VERSION, "-V, --version [none]", "output the version number (takes no value)");
|
|
16423
16400
|
}
|
|
16424
16401
|
function buildProgram(options = {}) {
|
|
16425
16402
|
const program2 = new Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sim",
|
|
3
|
-
"version": "2.1.5-
|
|
3
|
+
"version": "2.1.5-preview.72.1",
|
|
4
4
|
"description": "Sim CLI - talk to the Sim API from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -57,11 +57,5 @@
|
|
|
57
57
|
"@types/node": "24.2.1",
|
|
58
58
|
"typescript": "^7.0.2",
|
|
59
59
|
"vitest": "^4.1.0"
|
|
60
|
-
},
|
|
61
|
-
"exports": {
|
|
62
|
-
"./embed": {
|
|
63
|
-
"types": "./src/embed.ts",
|
|
64
|
-
"default": "./src/embed.ts"
|
|
65
|
-
}
|
|
66
60
|
}
|
|
67
61
|
}
|