sim 2.1.4-preview.68.1 → 2.1.5-dev.70.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.
Files changed (2) hide show
  1. package/dist/index.js +71 -79
  2. package/package.json +7 -1
package/dist/index.js CHANGED
@@ -2314,6 +2314,30 @@ 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
+
2317
2341
  // src/config/ini.ts
2318
2342
  class ProfileConfigError extends Error {
2319
2343
  constructor(message) {
@@ -2629,6 +2653,9 @@ function refuseBlankOverrides(overrides) {
2629
2653
  }
2630
2654
  }
2631
2655
  function resolveProfile(overrides = {}) {
2656
+ const embedded = embeddedProfile();
2657
+ if (embedded)
2658
+ return embedded;
2632
2659
  refuseBlankOverrides(overrides);
2633
2660
  const named = overrides.profile || process.env.SIM_PROFILE;
2634
2661
  const name = named || DEFAULT_PROFILE;
@@ -2681,14 +2708,22 @@ function resolveProfile(overrides = {}) {
2681
2708
  // src/version.ts
2682
2709
  import { readFileSync as readFileSync2 } from "node:fs";
2683
2710
  function readPackageVersion() {
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;
2711
+ try {
2712
+ const metadata = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
2713
+ if (typeof metadata === "object" && metadata !== null && "version" in metadata && typeof metadata.version === "string") {
2714
+ return metadata.version;
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})`;
2689
2726
  }
2690
- var CLI_VERSION = readPackageVersion();
2691
- var USER_AGENT = `sim-cli/${CLI_VERSION} node/${process.versions.node} (${process.platform}; ${process.arch})`;
2692
2727
 
2693
2728
  // src/http/environment.ts
2694
2729
  var reported = new Set;
@@ -2971,7 +3006,7 @@ class SimClient {
2971
3006
  headers: {
2972
3007
  ...apiKey ? { "x-api-key": apiKey } : {},
2973
3008
  accept: "application/json",
2974
- "user-agent": USER_AGENT,
3009
+ "user-agent": userAgent(),
2975
3010
  ...hasBody ? { "content-type": "application/json" } : {},
2976
3011
  ...options.headers
2977
3012
  },
@@ -6470,7 +6505,7 @@ async function pollForKey(endpoint, auth, signal) {
6470
6505
  headers: {
6471
6506
  "content-type": "application/json",
6472
6507
  accept: "application/json",
6473
- "user-agent": USER_AGENT
6508
+ "user-agent": userAgent()
6474
6509
  },
6475
6510
  body: JSON.stringify({ request: auth.request, verifier: auth.pollSecret }),
6476
6511
  signal,
@@ -6967,6 +7002,11 @@ var V2_OPERATIONS = {
6967
7002
  conversationId: {
6968
7003
  kind: "string",
6969
7004
  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)."
6970
7010
  }
6971
7011
  }
6972
7012
  },
@@ -8263,37 +8303,6 @@ var V2_OPERATIONS = {
8263
8303
  }
8264
8304
  }
8265
8305
  },
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
- },
8297
8306
  executeWorkflow: {
8298
8307
  method: "POST",
8299
8308
  path: "/api/v2/workflows/[workflowId]/execute",
@@ -8326,7 +8335,7 @@ var V2_OPERATIONS = {
8326
8335
  },
8327
8336
  selectedOutputs: {
8328
8337
  kind: "array",
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."
8338
+ describe: "Block output references to include in the response. Use `<blockName>.<outputPath>` for the executed workflow or `<childWorkflowId>.<blockName>.<outputPath>` for a child workflow; block names are normalized workflow reference names, and selecting a child workflow applies to every invocation of it. On a sync request the named outputs come back in `blockOutputs`, keyed by these selector strings; on a stream they shape the streamed envelope. Selectors that resolve to no block or no value are omitted. Rejected when `async` is true — a queued run has produced nothing to select; narrow the finished run via the run resource instead."
8330
8339
  },
8331
8340
  includeThinking: {
8332
8341
  kind: "boolean",
@@ -8978,8 +8987,7 @@ var V2_OPERATIONS = {
8978
8987
  "knowledge-base",
8979
8988
  "voice-input",
8980
8989
  "enrichment",
8981
- "voice-output",
8982
- "api-tool"
8990
+ "voice-output"
8983
8991
  ],
8984
8992
  describe: "Restrict results to one usage source."
8985
8993
  },
@@ -11859,7 +11867,7 @@ function whoamiCommand() {
11859
11867
  });
11860
11868
  const exitCode = WHOAMI_EXIT_CODES[verification.status];
11861
11869
  if (exitCode !== 0)
11862
- process.exitCode = exitCode;
11870
+ setSoftExitCode(exitCode);
11863
11871
  });
11864
11872
  }
11865
11873
  var PROFILE_COLUMNS = [
@@ -13057,24 +13065,6 @@ var CLI_CONTRACT = {
13057
13065
  describe: "Print a workflow as a portable JSON document",
13058
13066
  document: true
13059
13067
  },
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
- },
13078
13068
  executeWorkflow: {
13079
13069
  command: "workflows run",
13080
13070
  describe: "Run a deployed workflow or execute saved state manually",
@@ -13088,7 +13078,7 @@ var CLI_CONTRACT = {
13088
13078
  selectedOutputs: {
13089
13079
  name: "select-output",
13090
13080
  list: true,
13091
- describe: "Return streamed outputs as blockName.path or childWorkflowId.blockName.path; selecting a child workflow applies to every invocation, requires --follow"
13081
+ describe: "Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async"
13092
13082
  },
13093
13083
  stream: { omit: true },
13094
13084
  includeThinking: { omit: true },
@@ -13306,6 +13296,13 @@ function readArgumentSource(raw, flagName) {
13306
13296
  return { text: raw.slice(1), from: "" };
13307
13297
  if (!raw.startsWith("@"))
13308
13298
  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
+ }
13309
13306
  const path = raw.slice(1);
13310
13307
  if (path === "-") {
13311
13308
  if (process.stdin.isTTY) {
@@ -13989,25 +13986,20 @@ function renderResult(operation, format, raw, spec, options = {}, envelope) {
13989
13986
  }
13990
13987
 
13991
13988
  // src/runtime/execute.ts
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
- }
13989
+ var RUN_OUTCOME_OPERATIONS = new Set(["executeWorkflow"]);
13990
+ var FAILED_RUN_STATUS_MESSAGES = {
13991
+ failed: "The workflow run failed.",
13992
+ cancelled: "The workflow run was cancelled."
14000
13993
  };
14001
13994
  function runFailureMessage(operation, payload) {
14002
- const failureMessages = RUN_OUTCOME_OPERATIONS[operation];
14003
- if (!failureMessages)
13995
+ if (!RUN_OUTCOME_OPERATIONS.has(operation))
14004
13996
  return null;
14005
13997
  if (!payload || typeof payload !== "object" || Array.isArray(payload))
14006
13998
  return null;
14007
13999
  const { status, error } = payload;
14008
14000
  if (typeof status !== "string")
14009
14001
  return null;
14010
- const fallback = failureMessages[status];
14002
+ const fallback = FAILED_RUN_STATUS_MESSAGES[status];
14011
14003
  if (!fallback)
14012
14004
  return null;
14013
14005
  const reported2 = error?.message;
@@ -15980,8 +15972,8 @@ function followOrDelegate(previous) {
15980
15972
  command.setOptionValue("run", selection);
15981
15973
  const flags = command.optsWithGlobals();
15982
15974
  if (flags.follow !== true) {
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);
15975
+ if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0 && flags.async === true) {
15976
+ throw new SimApiError("--select-output names outputs of a completed run, and --async returns as soon as the run is queued. 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.", 0);
15985
15977
  }
15986
15978
  if (flags.includeThinking === true || flags.includeToolCalls === true) {
15987
15979
  throw new SimApiError("--include-thinking and --include-tool-calls describe a stream; add --follow", 0);
@@ -16104,7 +16096,7 @@ function attachWorkflowRunWait(runs) {
16104
16096
  const message = explain(outcome, runId, options.workflow, snapshot);
16105
16097
  if (message)
16106
16098
  console.error(source_default.red(message));
16107
- process.exitCode = WAIT_EXIT_CODES[outcome];
16099
+ setSoftExitCode(WAIT_EXIT_CODES[outcome]);
16108
16100
  return;
16109
16101
  }
16110
16102
  const remainingMs = deadline - Date.now();
@@ -16112,7 +16104,7 @@ function attachWorkflowRunWait(runs) {
16112
16104
  progress.finish();
16113
16105
  renderResult("getWorkflowRun", profile.output, raw, runSpec());
16114
16106
  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.`));
16115
- process.exitCode = WAIT_EXIT_CODES.timeout;
16107
+ setSoftExitCode(WAIT_EXIT_CODES.timeout);
16116
16108
  return;
16117
16109
  }
16118
16110
  progress.advance(snapshot.status, Date.now() - startedAt);
@@ -16396,7 +16388,7 @@ function addVersionOption(program2) {
16396
16388
  }
16397
16389
  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.");
16398
16390
  });
16399
- program2.version(CLI_VERSION, "-V, --version [none]", "output the version number (takes no value)");
16391
+ program2.version(cliVersion(), "-V, --version [none]", "output the version number (takes no value)");
16400
16392
  }
16401
16393
  function buildProgram(options = {}) {
16402
16394
  const program2 = new Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.1.4-preview.68.1",
3
+ "version": "2.1.5-dev.70.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,5 +57,11 @@
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
+ }
60
66
  }
61
67
  }