@fluidgrids/cli 2026.1115.5 → 2026.1116.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 (3) hide show
  1. package/README.md +10 -2
  2. package/dist/cli.js +131 -25
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -485,7 +485,8 @@ fluidgrids import export.json --from n8n --key my-flow --allow-missing-nodes
485
485
 
486
486
  # The replay debugger (local code needs no flag; --remote-code needs durable functions)
487
487
  fluidgrids replay histories/run.history.json --trace
488
- fluidgrids replay <runId> --trace --remote-code # the exact code that ran (DD8)
488
+ fluidgrids replay <runId> --trace --remote-code # the exact code that ran (DD8); asks first
489
+ fluidgrids replay <runId> --remote-code --yes --output json # scripts: no prompt, warning in the envelope
489
490
  fluidgrids replay <runId> --inspect # node --inspect-brk, stops at the mismatch
490
491
 
491
492
  # One node operation as a durable activity (fluidgrids.standalone-activities)
@@ -518,7 +519,14 @@ fluidgrids activity start internal:http request --args '{"url":"https://example.
518
519
  archive and refuses unless the `buildId` is the run's and this CLI bundles
519
520
  the `@fluidgrids/workflows` version that built it. The replay runs that code
520
521
  on your machine in a Node `vm`, which is not a sandbox (the managed workers
521
- use the QuickJS isolate), so debug only code from people you trust.
522
+ use the QuickJS isolate): the code can reach your process, files and
523
+ credentials, so debug only code from people you trust. Any workspace member
524
+ may have pushed that version, so `--remote-code` asks `Run the stored code of
525
+ <key> <version> on this machine? [y/N]` before it downloads anything, and
526
+ stops unless you answer yes. Without a terminal, and always with `--output
527
+ json`, it refuses unless you pass `--yes`. The warning goes to stderr and,
528
+ with `--output json`, is also a `debug.untrustedCode` warning in the
529
+ envelope. With `--inspect` it asks before starting the debuggee.
522
530
  - `activity start` (also `activities start`) takes literal arguments; routing
523
531
  nodes such as `internal:if` are refused. A repeated `--idempotency-key` (1 to
524
532
  128 letters, digits, `.`, `_`, `:` or `-`) from the same caller returns the
package/dist/cli.js CHANGED
@@ -2055,6 +2055,37 @@ import { existsSync as existsSync3 } from "fs";
2055
2055
  import { join as join3 } from "path";
2056
2056
  import { CliUserError as CliUserError11 } from "@burdenoff/cli-sdk/core";
2057
2057
  import { irHash } from "@fluidgrids/workflows/ir";
2058
+ function calverAtLeast(a, b) {
2059
+ const parse = (value) => {
2060
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(value.trim());
2061
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
2062
+ };
2063
+ const left = parse(a);
2064
+ const right = parse(b);
2065
+ if (!left || !right)
2066
+ return false;
2067
+ for (let index = 0;index < 3; index += 1) {
2068
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
2069
+ if (difference !== 0)
2070
+ return difference > 0;
2071
+ }
2072
+ return true;
2073
+ }
2074
+ async function pythonCutsNodeClients(python, root) {
2075
+ try {
2076
+ const { stdout } = await runPythonCli({
2077
+ python,
2078
+ root,
2079
+ command: "--version",
2080
+ args: ["--version"],
2081
+ stdin: ""
2082
+ });
2083
+ const version = /(\d+\.\d+\.\d+)\s*$/.exec(stdout.trim())?.[1];
2084
+ return version !== undefined && calverAtLeast(version, CUT_NODE_CLIENTS_SDK);
2085
+ } catch {
2086
+ return false;
2087
+ }
2088
+ }
2058
2089
  function resolvePythonInterpreter(root, configured, env = process.env) {
2059
2090
  const fromEnv = env["FLUIDGRIDS_PYTHON"];
2060
2091
  if (fromEnv && fromEnv.trim() !== "")
@@ -2104,14 +2135,38 @@ function parseLowerResult(stdout) {
2104
2135
  definition: item["definition"]
2105
2136
  };
2106
2137
  });
2138
+ const sourceFiles = parseSourceFiles(value["sourceFiles"]);
2107
2139
  return {
2108
2140
  sdkVersion,
2109
2141
  sourceHash: value["sourceHash"],
2142
+ ...sourceFiles ? { sourceFiles } : {},
2110
2143
  workflows,
2111
2144
  warnings,
2112
2145
  issues: parseIssues(value["issues"])
2113
2146
  };
2114
2147
  }
2148
+ function parseSourceFiles(value) {
2149
+ if (value === undefined)
2150
+ return;
2151
+ if (!isRecord7(value)) {
2152
+ throw new CliUserError11(`python -m ${PYTHON_MODULE} lower returned malformed sourceFiles.`, {
2153
+ hint: UPGRADE_HINT
2154
+ });
2155
+ }
2156
+ const files = {};
2157
+ for (const [path, content] of Object.entries(value)) {
2158
+ if (typeof content !== "string" || path === "" || path.startsWith("/") || path.split("/").includes("..")) {
2159
+ throw new CliUserError11(`python -m ${PYTHON_MODULE} lower returned a malformed source file (${JSON.stringify(path)}).`, { hint: UPGRADE_HINT });
2160
+ }
2161
+ Object.defineProperty(files, path, {
2162
+ value: content,
2163
+ enumerable: true,
2164
+ writable: true,
2165
+ configurable: true
2166
+ });
2167
+ }
2168
+ return files;
2169
+ }
2115
2170
  function parseIssues(value) {
2116
2171
  if (value === undefined)
2117
2172
  return [];
@@ -2228,6 +2283,8 @@ async function lowerPython(options) {
2228
2283
  const args = ["lower", options.root, "--connections", "-"];
2229
2284
  for (const entry of options.entries)
2230
2285
  args.push("--entry", entry);
2286
+ if (options.cutNodeClients)
2287
+ args.push("--cut-node-clients");
2231
2288
  const { stdout } = await runPythonCli({
2232
2289
  python: options.python,
2233
2290
  root: options.root,
@@ -2239,7 +2296,7 @@ async function lowerPython(options) {
2239
2296
  });
2240
2297
  return parseLowerResult(stdout);
2241
2298
  }
2242
- var PYTHON_MODULE = "fluidgrids_workflows", PYTHON_PACKAGE = "fluidgrids-workflows", LOWER_RESULT_FORMAT = "fluidgrids.python-lower-result", MAX_PYTHON_OUTPUT_BYTES, DEFAULT_PYTHON_TIMEOUT_MS = 120000, UNRESOLVED_PREFIX = "Create these connections in the workspace first: ", PythonUnresolvedConnectionsError, UPGRADE_HINT;
2299
+ var PYTHON_MODULE = "fluidgrids_workflows", PYTHON_PACKAGE = "fluidgrids-workflows", LOWER_RESULT_FORMAT = "fluidgrids.python-lower-result", MAX_PYTHON_OUTPUT_BYTES, DEFAULT_PYTHON_TIMEOUT_MS = 120000, UNRESOLVED_PREFIX = "Create these connections in the workspace first: ", PythonUnresolvedConnectionsError, CUT_NODE_CLIENTS_SDK = "2026.1115.6", UPGRADE_HINT;
2243
2300
  var init_python = __esm(() => {
2244
2301
  MAX_PYTHON_OUTPUT_BYTES = 64 * 1024 * 1024;
2245
2302
  PythonUnresolvedConnectionsError = class PythonUnresolvedConnectionsError extends CliUserError11 {
@@ -3091,6 +3148,8 @@ async function buildPython(options) {
3091
3148
  const args = ["build", options.root, "--out", out, "--connections", "-"];
3092
3149
  for (const entry of options.entries)
3093
3150
  args.push("--entry", entry);
3151
+ if (options.cutNodeClients)
3152
+ args.push("--cut-node-clients");
3094
3153
  const { stdout } = await runPythonCli({
3095
3154
  python: options.python,
3096
3155
  root: options.root,
@@ -3376,7 +3435,14 @@ async function lowerProject(project, options) {
3376
3435
  try {
3377
3436
  const python = resolvePythonInterpreter(project.root, project.config.python);
3378
3437
  const connections = connectionMap(options.connectionNames, options.connections);
3379
- const lowered = await lowerPython({ python, root: project.root, entries, connections });
3438
+ const cutNodeClients = await pythonCutsNodeClients(python, project.root);
3439
+ const lowered = await lowerPython({
3440
+ python,
3441
+ root: project.root,
3442
+ entries,
3443
+ connections,
3444
+ cutNodeClients
3445
+ });
3380
3446
  result.python = python;
3381
3447
  result.sourceHash = lowered.sourceHash;
3382
3448
  result.warnings.push(...lowered.warnings);
@@ -3403,8 +3469,11 @@ async function lowerProject(project, options) {
3403
3469
  const [buildId] = [...buildIds];
3404
3470
  if (buildId !== undefined) {
3405
3471
  result.buildId = buildId;
3406
- result.sourceFiles = pythonSourceFiles(project.root);
3407
- result.buildPython = () => buildPython({ python, root: project.root, entries, connections });
3472
+ if (cutNodeClients && !lowered.sourceFiles) {
3473
+ throw new CliUserError16(`python -m ${PYTHON_MODULE} lower --cut-node-clients listed no sourceFiles.`, { hint: "Reinstall the fluidgrids-workflows package." });
3474
+ }
3475
+ result.sourceFiles = lowered.sourceFiles ?? pythonSourceFiles(project.root);
3476
+ result.buildPython = () => buildPython({ python, root: project.root, entries, connections, cutNodeClients });
3408
3477
  }
3409
3478
  } catch (error) {
3410
3479
  if (error instanceof PythonUnresolvedConnectionsError) {
@@ -4728,6 +4797,19 @@ var init_n8n_import = __esm(() => {
4728
4797
  IMPORT_SOURCES = ["n8n"];
4729
4798
  });
4730
4799
 
4800
+ // src/output/confirm.ts
4801
+ import { createInterface } from "readline/promises";
4802
+ async function confirmOnTerminal(question) {
4803
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
4804
+ try {
4805
+ const answer = await rl.question(`${question} [y/N] `);
4806
+ return /^y(es)?$/i.test(answer.trim());
4807
+ } finally {
4808
+ rl.close();
4809
+ }
4810
+ }
4811
+ var init_confirm = () => {};
4812
+
4731
4813
  // src/phase-d/operations.ts
4732
4814
  var FIDELITY_FIELDS = "level items { kind nodeId path detail }", GENERATION_FIELDS = `
4733
4815
  id status message attempts prompt template modelUsed createdAt updatedAt
@@ -4881,7 +4963,7 @@ var init_api2 = __esm(() => {
4881
4963
  import { isAbsolute as isAbsolute2 } from "path";
4882
4964
  import { CliUserError as CliUserError26 } from "@burdenoff/cli-sdk/core";
4883
4965
  function phaseDEnv(env) {
4884
- return { ...env, pd: createPhaseDApi(env.ctx) };
4966
+ return { ...env, pd: createPhaseDApi(env.ctx), confirm: confirmOnTerminal };
4885
4967
  }
4886
4968
  function safeRelativePath2(raw, what) {
4887
4969
  const bad = raw === "" || raw.length > 512 || isAbsolute2(raw) || raw.startsWith("/") || /^[A-Za-z]:/.test(raw) || raw.includes("\\") || [...raw].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) || raw.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
@@ -4905,6 +4987,7 @@ function parseJsonObjectArg(raw, flag, readFile) {
4905
4987
  return parsed;
4906
4988
  }
4907
4989
  var init_shared2 = __esm(() => {
4990
+ init_confirm();
4908
4991
  init_api2();
4909
4992
  });
4910
4993
 
@@ -5734,7 +5817,7 @@ var init_parity = __esm(() => {
5734
5817
  // src/code-first/commands/runs.ts
5735
5818
  import { writeFileSync as writeFileSync6 } from "fs";
5736
5819
  import { resolve as resolve7 } from "path";
5737
- import { createInterface } from "readline/promises";
5820
+ import { createInterface as createInterface2 } from "readline/promises";
5738
5821
  import { CliUserError as CliUserError31 } from "@burdenoff/cli-sdk/core";
5739
5822
  import { serializeHistoryFile as serializeHistoryFile2 } from "@fluidgrids/workflows/history";
5740
5823
  function parityRows(run) {
@@ -6025,7 +6108,7 @@ async function runSignal(env, first, second, options) {
6025
6108
  return result;
6026
6109
  }
6027
6110
  async function confirm(question) {
6028
- const rl = createInterface({ input: process.stdin, output: process.stderr });
6111
+ const rl = createInterface2({ input: process.stdin, output: process.stderr });
6029
6112
  try {
6030
6113
  const answer = await rl.question(`${question} [y/N] `);
6031
6114
  return /^y(es)?$/i.test(answer.trim());
@@ -6781,6 +6864,27 @@ function inspectMatches(raw, address) {
6781
6864
  return false;
6782
6865
  }
6783
6866
  }
6867
+ function remoteCodeWarning(what) {
6868
+ return `Replaying the stored code of ${what} on this machine: a Node vm is not a sandbox, so the code can reach this process, your files and your credentials. Only debug code from people you trust.`;
6869
+ }
6870
+ async function confirmRemoteCode(env, options, what) {
6871
+ const warning = remoteCodeWarning(what);
6872
+ console.error(warning);
6873
+ reportDiagnostics(env.ctx.output, [
6874
+ diagnostic({ severity: "warning", code: "debug.untrustedCode", message: warning })
6875
+ ]);
6876
+ if (options.yes === true)
6877
+ return;
6878
+ const question = `Run the stored code of ${what} on this machine?`;
6879
+ if (isEnvelopeOutput(env.ctx.output) || !env.interactive()) {
6880
+ throw new CliUserError34(`${question} This needs confirmation.`, {
6881
+ hint: "Pass --yes to replay it without a prompt, once you trust whoever pushed that version."
6882
+ });
6883
+ }
6884
+ if (!await env.confirm(question)) {
6885
+ throw new CliUserError34("Aborted: the stored code was not downloaded or run.");
6886
+ }
6887
+ }
6784
6888
  async function reexecUnderInspector(env, options, facts) {
6785
6889
  const address = inspectAddress(options.inspect ?? true);
6786
6890
  if (!facts.node) {
@@ -6791,8 +6895,19 @@ async function reexecUnderInspector(env, options, facts) {
6791
6895
  const script = facts.argv[1];
6792
6896
  if (script === undefined)
6793
6897
  throw new CliUserError34("--inspect: the CLI script path is unknown.");
6898
+ const args = childArgs(facts.argv, address);
6899
+ if (options.remoteCode === true) {
6900
+ await confirmRemoteCode(env, options, "the run");
6901
+ if (!args.includes("--yes")) {
6902
+ const end = args.indexOf("--");
6903
+ if (end < 0)
6904
+ args.push("--yes");
6905
+ else
6906
+ args.splice(end, 0, "--yes");
6907
+ }
6908
+ }
6794
6909
  console.error(`Debugger listening on ${address}; attach to continue (the replay stops at the mismatch).`);
6795
- const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...childArgs(facts.argv, address)], env.cwd(), { stdout: "inherit" });
6910
+ const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...args], env.cwd(), { stdout: "inherit" });
6796
6911
  throw new DelegatedExit(status);
6797
6912
  }
6798
6913
  async function loadHistory(env, target) {
@@ -6804,7 +6919,7 @@ async function loadHistory(env, target) {
6804
6919
  throw new CliUserError34(`History file not found: ${target}`);
6805
6920
  return { file: (await fetchHistory(env, target)).file, name: target };
6806
6921
  }
6807
- async function remoteScript(env, file, name) {
6922
+ async function remoteScript(env, options, file, name) {
6808
6923
  const key = file.info?.workflowKey;
6809
6924
  const version = file.info?.version;
6810
6925
  const buildId = file.info?.buildId;
@@ -6824,7 +6939,7 @@ async function remoteScript(env, file, name) {
6824
6939
  });
6825
6940
  }
6826
6941
  presignedUrl(archive.url, "source archive");
6827
- console.error(`Replaying the stored code of ${key} ${String(version)} on this machine: a Node vm is not a sandbox, so only debug code from people you trust.`);
6942
+ await confirmRemoteCode(env, options, `${key} ${String(version)}`);
6828
6943
  let response;
6829
6944
  try {
6830
6945
  response = await env.fetch(archive.url, { method: "GET" });
@@ -6914,9 +7029,9 @@ async function runDebugReplay(env, target, options, facts = currentProcess()) {
6914
7029
  throw new CliUserError34(`${name} is marked "replay": false (it uses Phase C features).`);
6915
7030
  }
6916
7031
  const remote = options.remoteCode === true;
6917
- const script = remote ? await remoteScript(env, file, name) : await localScript(env, options, file, name);
7032
+ const script = remote ? await remoteScript(env, options, file, name) : await localScript(env, options, file, name);
6918
7033
  const breakOnMismatch = options.breakOnMismatch === true;
6919
- const trace = await traceReplay(script.script, replayRequest2(file.workflowFn, file.events, file.info ?? {}, file.nowMs), breakOnMismatch ? { breakOnMismatch: true, onBreak: breakAtMismatch } : {});
7034
+ const trace = await traceReplay(script.script, replayRequest2(file.workflowFn, file.events, file.info ?? {}, file.nowMs), breakOnMismatch ? { trustedCode: true, breakOnMismatch: true, onBreak: breakAtMismatch } : { trustedCode: true });
6920
7035
  const runBuildId = file.info?.buildId ?? null;
6921
7036
  const result = {
6922
7037
  name,
@@ -7270,7 +7385,7 @@ var init_suite = __esm(() => {
7270
7385
  });
7271
7386
 
7272
7387
  // src/code-first/commands/versions.ts
7273
- import { createInterface as createInterface2 } from "readline/promises";
7388
+ import { createInterface as createInterface3 } from "readline/promises";
7274
7389
  import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
7275
7390
  async function runVersionsList(env, workflowKey, options) {
7276
7391
  const versions = sortVersions(await env.api.workflowVersions(workflowKey));
@@ -7357,7 +7472,7 @@ function rolloutDeleteOptions(options, parent) {
7357
7472
  return { ...options, environment: inherited };
7358
7473
  }
7359
7474
  async function confirm2(question) {
7360
- const rl = createInterface2({ input: process.stdin, output: process.stderr });
7475
+ const rl = createInterface3({ input: process.stdin, output: process.stderr });
7361
7476
  try {
7362
7477
  const answer = await rl.question(`${question} [y/N] `);
7363
7478
  return /^y(es)?$/i.test(answer.trim());
@@ -9091,17 +9206,7 @@ except BridgeClosedError as error:
9091
9206
  });
9092
9207
 
9093
9208
  // src/phase-c/shared.ts
9094
- import { createInterface as createInterface3 } from "readline/promises";
9095
9209
  import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
9096
- async function confirmOnTerminal(question) {
9097
- const rl = createInterface3({ input: process.stdin, output: process.stderr });
9098
- try {
9099
- const answer = await rl.question(`${question} [y/N] `);
9100
- return /^y(es)?$/i.test(answer.trim());
9101
- } finally {
9102
- rl.close();
9103
- }
9104
- }
9105
9210
  function phaseCEnv(env) {
9106
9211
  return {
9107
9212
  ...env,
@@ -9215,6 +9320,7 @@ function parseInstant(raw, flag) {
9215
9320
  return new Date(ms).toISOString();
9216
9321
  }
9217
9322
  var init_shared3 = __esm(() => {
9323
+ init_confirm();
9218
9324
  init_api3();
9219
9325
  });
9220
9326
 
@@ -11304,7 +11410,7 @@ function registerDurable(program, env) {
11304
11410
  });
11305
11411
  addHistory(program, env, "history");
11306
11412
  addSignal(program, env, "signal");
11307
- program.command("replay <history>").description("Replay a history file, a run archive's history.jsonl.gz or a run id against the local code; fails on non-determinism").option("--isolate", "Replay in the QuickJS isolate the managed workers use").option("--debug", "Print the full task result (commands, logs, stack)").option("--trace", "Print every step: the command, the recorded event and the source line").option("--break-on-mismatch", "Stop in an attached debugger where the code diverges").option("--inspect [address]", "Re-run under node --inspect-brk (loopback host:port, default 127.0.0.1:9229); implies --break-on-mismatch").option("--remote-code", "Rebuild the run's exact code from its source archive instead of the local project").option(...PROJECT_OPTION).option(...OUTPUT_OPTION).action(async (history, options, command) => {
11413
+ program.command("replay <history>").description("Replay a history file, a run archive's history.jsonl.gz or a run id against the local code; fails on non-determinism").option("--isolate", "Replay in the QuickJS isolate the managed workers use").option("--debug", "Print the full task result (commands, logs, stack)").option("--trace", "Print every step: the command, the recorded event and the source line").option("--break-on-mismatch", "Stop in an attached debugger where the code diverges").option("--inspect [address]", "Re-run under node --inspect-brk (loopback host:port, default 127.0.0.1:9229); implies --break-on-mismatch").option("--remote-code", "Rebuild the run's exact code from its source archive instead of the local project (asks first: it runs that code here)").option("--yes", "With --remote-code: run the stored code without asking (for scripts)").option(...PROJECT_OPTION).option(...OUTPUT_OPTION).action(async (history, options, command) => {
11308
11414
  const resolved = withGlobalFormat(options, command);
11309
11415
  if (resolved.trace || resolved.breakOnMismatch || resolved.inspect !== undefined || resolved.remoteCode) {
11310
11416
  await Promise.resolve().then(() => init_replay_debug());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidgrids/cli",
3
- "version": "2026.1115.5",
3
+ "version": "2026.1116.1",
4
4
  "description": "CLI tool for FluidGrids — workflow automation management (thin shell over @burdenoff/cli-sdk)",
5
5
  "type": "module",
6
6
  "private": false,
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@burdenoff/cli-sdk": "2026.1109.1",
58
- "@fluidgrids/workflows": "2026.1115.3",
58
+ "@fluidgrids/workflows": "2026.1116.1",
59
59
  "@napi-rs/keyring": "2.1.1",
60
60
  "commander": "^14.0.3",
61
61
  "esbuild": "0.28.2",