@fluidgrids/cli 2026.1115.4 → 2026.1115.6

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/cli.js +116 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1265,6 +1265,15 @@ function compareText(a, b) {
1265
1265
  function isRecord5(value) {
1266
1266
  return typeof value === "object" && value !== null && !Array.isArray(value);
1267
1267
  }
1268
+ function isConsistentListing(rows, totals) {
1269
+ if (totals.size > 1)
1270
+ return false;
1271
+ const [total] = [...totals];
1272
+ if (total !== undefined && rows.length !== total)
1273
+ return false;
1274
+ const seen = new Set(rows.map((row) => `${row.nodeType}\x00${row.nodeVersion}`));
1275
+ return seen.size === rows.length;
1276
+ }
1268
1277
  function manifestFromConfig(row) {
1269
1278
  const operations = row.operations;
1270
1279
  const usable = Array.isArray(operations) || isRecord5(operations) && Array.isArray(operations["operations"]);
@@ -1415,16 +1424,27 @@ function createCodeFirstApi(ctx) {
1415
1424
  return data.workflowInterface;
1416
1425
  },
1417
1426
  async nodeManifests() {
1418
- const rows = await paginate(async (offset) => {
1419
- const data = await request(CF_LIST_NODE_MANIFESTS, {
1420
- status: "AVAILABLE",
1421
- pagination: { limit: PAGE_SIZE, offset }
1427
+ let rows = null;
1428
+ for (let attempt = 1;attempt <= REGISTRY_LISTING_ATTEMPTS && rows === null; attempt++) {
1429
+ const totals = new Set;
1430
+ const listed = await paginate(async (offset) => {
1431
+ const data = await request(CF_LIST_NODE_MANIFESTS, {
1432
+ status: "AVAILABLE",
1433
+ pagination: { limit: PAGE_SIZE, offset }
1434
+ });
1435
+ const pagination = data.nodeEndpointConfigs.pagination;
1436
+ if (typeof pagination?.total === "number")
1437
+ totals.add(pagination.total);
1438
+ return { rows: data.nodeEndpointConfigs.configs, hasMore: pagination?.hasMore ?? false };
1422
1439
  });
1423
- return {
1424
- rows: data.nodeEndpointConfigs.configs,
1425
- hasMore: data.nodeEndpointConfigs.pagination?.hasMore ?? false
1426
- };
1427
- });
1440
+ if (isConsistentListing(listed, totals))
1441
+ rows = listed;
1442
+ }
1443
+ if (rows === null) {
1444
+ throw new CliUserError8(`The node registry changed while it was being read, ${REGISTRY_LISTING_ATTEMPTS} times in a row.`, {
1445
+ hint: "Nodes are being published to the workspace registry right now; run the command again in a minute."
1446
+ });
1447
+ }
1428
1448
  return rows.map(manifestFromConfig).filter((manifest) => manifest !== null).sort((a, b) => compareText(`${a.nodeType}\x00${String(a.nodeVersion)}`, `${b.nodeType}\x00${String(b.nodeVersion)}`));
1429
1449
  },
1430
1450
  async connections() {
@@ -1667,7 +1687,7 @@ function createCodeFirstApi(ctx) {
1667
1687
  }
1668
1688
  };
1669
1689
  }
1670
- var PARITY_START_FIELDS, PAGE_SIZE = 100, MAX_PAGES = 200;
1690
+ var PARITY_START_FIELDS, PAGE_SIZE = 100, MAX_PAGES = 200, REGISTRY_LISTING_ATTEMPTS = 4;
1671
1691
  var init_api = __esm(() => {
1672
1692
  init_redact();
1673
1693
  init_flag_hint();
@@ -2035,6 +2055,37 @@ import { existsSync as existsSync3 } from "fs";
2035
2055
  import { join as join3 } from "path";
2036
2056
  import { CliUserError as CliUserError11 } from "@burdenoff/cli-sdk/core";
2037
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
+ }
2038
2089
  function resolvePythonInterpreter(root, configured, env = process.env) {
2039
2090
  const fromEnv = env["FLUIDGRIDS_PYTHON"];
2040
2091
  if (fromEnv && fromEnv.trim() !== "")
@@ -2084,14 +2135,38 @@ function parseLowerResult(stdout) {
2084
2135
  definition: item["definition"]
2085
2136
  };
2086
2137
  });
2138
+ const sourceFiles = parseSourceFiles(value["sourceFiles"]);
2087
2139
  return {
2088
2140
  sdkVersion,
2089
2141
  sourceHash: value["sourceHash"],
2142
+ ...sourceFiles ? { sourceFiles } : {},
2090
2143
  workflows,
2091
2144
  warnings,
2092
2145
  issues: parseIssues(value["issues"])
2093
2146
  };
2094
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
+ }
2095
2170
  function parseIssues(value) {
2096
2171
  if (value === undefined)
2097
2172
  return [];
@@ -2208,6 +2283,8 @@ async function lowerPython(options) {
2208
2283
  const args = ["lower", options.root, "--connections", "-"];
2209
2284
  for (const entry of options.entries)
2210
2285
  args.push("--entry", entry);
2286
+ if (options.cutNodeClients)
2287
+ args.push("--cut-node-clients");
2211
2288
  const { stdout } = await runPythonCli({
2212
2289
  python: options.python,
2213
2290
  root: options.root,
@@ -2219,7 +2296,7 @@ async function lowerPython(options) {
2219
2296
  });
2220
2297
  return parseLowerResult(stdout);
2221
2298
  }
2222
- 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;
2223
2300
  var init_python = __esm(() => {
2224
2301
  MAX_PYTHON_OUTPUT_BYTES = 64 * 1024 * 1024;
2225
2302
  PythonUnresolvedConnectionsError = class PythonUnresolvedConnectionsError extends CliUserError11 {
@@ -2685,6 +2762,16 @@ import { CliUserError as CliUserError14 } from "@burdenoff/cli-sdk/core";
2685
2762
  import { registrySnapshotHash } from "@fluidgrids/workflows/codegen";
2686
2763
  import { buildExportDocument, irHash as irHash3, serializeWorkflowDocument } from "@fluidgrids/workflows/ir";
2687
2764
  import { exportWorkflowCode } from "@fluidgrids/workflows/roundtrip";
2765
+ function withoutSnapshot(content) {
2766
+ return content.replace(SNAPSHOT_LINE, "$1 Node registry snapshot");
2767
+ }
2768
+ function keepUnlessChanged(file, existing) {
2769
+ if (existing === null || existing === file.content)
2770
+ return file;
2771
+ if (!SNAPSHOT_LINE.test(existing) || !SNAPSHOT_LINE.test(file.content))
2772
+ return file;
2773
+ return withoutSnapshot(existing) === withoutSnapshot(file.content) ? { ...file, content: existing } : file;
2774
+ }
2688
2775
  function isNodesFile(path) {
2689
2776
  return path === `${GENERATED_DIR}/nodes.ts` || path === `${GENERATED_DIR}/nodes.py`;
2690
2777
  }
@@ -2835,7 +2922,7 @@ async function runPull(env, keys, rawOptions) {
2835
2922
  throw new CliUserError14(`${key} export: refusing ${path}, which is outside ${WORKFLOWS_DIR}/ and ${GENERATED_DIR}/.`);
2836
2923
  }
2837
2924
  }
2838
- const codeFiles = options.server ? files : files.filter((file) => !isNodesFile(file.path));
2925
+ const codeFiles = (options.server ? files : files.filter((file) => !isNodesFile(file.path))).map((file) => keepUnlessChanged(file, readProjectFile(project.root, file.path)));
2839
2926
  if (!options.server && files.some((file) => isNodesFile(file.path)) && format !== "json") {
2840
2927
  clientsUsed = format;
2841
2928
  }
@@ -2907,12 +2994,14 @@ async function runPull(env, keys, rawOptions) {
2907
2994
  }
2908
2995
  return result;
2909
2996
  }
2997
+ var SNAPSHOT_LINE;
2910
2998
  var init_pull = __esm(() => {
2911
2999
  init_connections();
2912
3000
  init_project();
2913
3001
  init_remote();
2914
3002
  init_codegen();
2915
3003
  init_shared();
3004
+ SNAPSHOT_LINE = /^(\/\/|#) Node registry snapshot sha256:[0-9a-f]{64}\.$/m;
2916
3005
  });
2917
3006
 
2918
3007
  // src/code-first/imports.ts
@@ -3059,6 +3148,8 @@ async function buildPython(options) {
3059
3148
  const args = ["build", options.root, "--out", out, "--connections", "-"];
3060
3149
  for (const entry of options.entries)
3061
3150
  args.push("--entry", entry);
3151
+ if (options.cutNodeClients)
3152
+ args.push("--cut-node-clients");
3062
3153
  const { stdout } = await runPythonCli({
3063
3154
  python: options.python,
3064
3155
  root: options.root,
@@ -3344,7 +3435,14 @@ async function lowerProject(project, options) {
3344
3435
  try {
3345
3436
  const python = resolvePythonInterpreter(project.root, project.config.python);
3346
3437
  const connections = connectionMap(options.connectionNames, options.connections);
3347
- 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
+ });
3348
3446
  result.python = python;
3349
3447
  result.sourceHash = lowered.sourceHash;
3350
3448
  result.warnings.push(...lowered.warnings);
@@ -3371,8 +3469,11 @@ async function lowerProject(project, options) {
3371
3469
  const [buildId] = [...buildIds];
3372
3470
  if (buildId !== undefined) {
3373
3471
  result.buildId = buildId;
3374
- result.sourceFiles = pythonSourceFiles(project.root);
3375
- 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 });
3376
3477
  }
3377
3478
  } catch (error) {
3378
3479
  if (error instanceof PythonUnresolvedConnectionsError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidgrids/cli",
3
- "version": "2026.1115.4",
3
+ "version": "2026.1115.6",
4
4
  "description": "CLI tool for FluidGrids — workflow automation management (thin shell over @burdenoff/cli-sdk)",
5
5
  "type": "module",
6
6
  "private": false,