@fluidgrids/cli 2026.1113.1 → 2026.1113.3

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 +9 -3
  2. package/dist/cli.js +202 -17
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -397,7 +397,7 @@ fluidgrids --profile alpha runs list
397
397
  profile; `FLUIDGRIDS_<KEY>` variables and the usual `FLUIDGRIDS_*` overrides
398
398
  win over it key by key. Without a config file nothing changes.
399
399
 
400
- ## AI to code, n8n import and the replay debugger (Phase D)
400
+ ## AI to code, n8n import, the replay debugger and standalone activities (Phase D)
401
401
 
402
402
  Each command except the n8n import needs its Phase D flag on the workspace;
403
403
  the service refuses with `FEATURE_DISABLED` otherwise, and the CLI names the
@@ -420,6 +420,8 @@ fluidgrids replay histories/run.history.json --trace
420
420
  fluidgrids replay <runId> --trace --remote-code # the exact code that ran (DD8)
421
421
  fluidgrids replay <runId> --inspect # node --inspect-brk, stops at the mismatch
422
422
 
423
+ # One node operation as a durable activity (fluidgrids.standalone-activities)
424
+ fluidgrids activity start internal:http request --args '{"url":"https://example.com"}' --wait
423
425
  ```
424
426
 
425
427
  - `generate` writes the draft the service lifted from a validated definition
@@ -449,8 +451,12 @@ fluidgrids replay <runId> --inspect # node --inspect-brk, st
449
451
  the `@fluidgrids/workflows` version that built it. The replay runs that code
450
452
  on your machine in a Node `vm`, which is not a sandbox (the managed workers
451
453
  use the QuickJS isolate), so debug only code from people you trust.
452
- - `activity start` (standalone activities) is not in this release; it ships
453
- once the service serves it.
454
+ - `activity start` (also `activities start`) takes literal arguments; routing
455
+ nodes such as `internal:if` are refused. A repeated `--idempotency-key` (1 to
456
+ 128 letters, digits, `.`, `_`, `:` or `-`) from the same caller returns the
457
+ run it started (needs fluidgrids.durable-parity). Durations take a unit
458
+ (`250ms`, `30s`, `5m`, `2h`, `1d`, `PT2H`); a bare number is milliseconds and
459
+ is sent as `<n>ms`.
454
460
 
455
461
  ### Machine-readable output (`--output json`)
456
462
 
package/dist/cli.js CHANGED
@@ -3713,7 +3713,11 @@ var init_replay = () => {};
3713
3713
  import { diffDefinitions, irHash as irHash4, validate } from "@fluidgrids/workflows/ir";
3714
3714
  import { CliUserError as CliUserError20 } from "@burdenoff/cli-sdk/core";
3715
3715
  function durableSummary(issues) {
3716
- return issues.some((issue) => issue.code === "durable.phaseC") ? "The project uses durable-function features that arrive in Phase C" : "The project uses durable-function features this release refuses";
3716
+ if (issues.some((issue) => issue.code === "durable.phaseC"))
3717
+ return "The project uses durable-function features that arrive in Phase C";
3718
+ if (issues.length > 0 && issues.every((issue) => issue.code === USER_ACTIVITY_ON_MANAGED))
3719
+ return "The project runs a user activity on the managed queue, which has no worker for user activities; declare each activity on a self-hosted task queue";
3720
+ return "The project uses durable-function features this release refuses";
3717
3721
  }
3718
3722
  function assertNoDurableIssues(issues) {
3719
3723
  if (issues.length === 0)
@@ -3963,6 +3967,7 @@ async function runPush(env, keys, options) {
3963
3967
  }, details);
3964
3968
  return result;
3965
3969
  }
3970
+ var USER_ACTIVITY_ON_MANAGED = "taskQueue.userActivityOnManaged";
3966
3971
  var init_push = __esm(() => {
3967
3972
  init_code_upload();
3968
3973
  init_connections();
@@ -4683,6 +4688,21 @@ function safeRelativePath2(raw, what) {
4683
4688
  throw new CliUserError26(`The service sent an unsafe ${what} path: ${JSON.stringify(raw)}`);
4684
4689
  return raw;
4685
4690
  }
4691
+ function parseJsonObjectArg(raw, flag, readFile) {
4692
+ if (raw === undefined)
4693
+ return;
4694
+ const text = raw.startsWith("@") ? readFile(raw.slice(1)) : raw;
4695
+ let parsed;
4696
+ try {
4697
+ parsed = JSON.parse(text);
4698
+ } catch {
4699
+ throw new CliUserError26(`${flag} must be a JSON object (or @file holding one).`);
4700
+ }
4701
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
4702
+ throw new CliUserError26(`${flag} must be a JSON object (or @file holding one).`);
4703
+ }
4704
+ return parsed;
4705
+ }
4686
4706
  var init_shared2 = __esm(() => {
4687
4707
  init_api2();
4688
4708
  });
@@ -9586,8 +9606,168 @@ var init_batch = __esm(() => {
9586
9606
  JOB_HEADERS = ["Id", "Type", "Status", "Total", "Succeeded", "Failed", "Skipped"];
9587
9607
  });
9588
9608
 
9589
- // src/phase-c/commands/signal-tokens.ts
9609
+ // src/phase-d/duration.ts
9590
9610
  import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
9611
+ import { toMs } from "@fluidgrids/workflows";
9612
+ function parseDurationOption(raw, flag) {
9613
+ if (raw === undefined)
9614
+ return;
9615
+ const value = raw.trim();
9616
+ const sent = /^\d+(\.\d+)?$/.test(value) ? `${value}ms` : value;
9617
+ try {
9618
+ toMs(sent, flag);
9619
+ } catch {
9620
+ throw new CliUserError46(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
9621
+ }
9622
+ return sent;
9623
+ }
9624
+ var init_duration = () => {};
9625
+
9626
+ // src/phase-d/commands/activity-start.ts
9627
+ import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
9628
+ import { resolve as resolve12 } from "path";
9629
+ import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
9630
+ function retryPolicy(raw, maxAttempts, readFile) {
9631
+ const parsed = parseJsonObjectArg(raw, "--retry", readFile);
9632
+ const policy = {};
9633
+ if (parsed !== undefined) {
9634
+ for (const key of Object.keys(parsed)) {
9635
+ if (!RETRY_KEYS.some((known) => known === key)) {
9636
+ throw new CliUserError47(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
9637
+ }
9638
+ }
9639
+ const text = (key) => {
9640
+ const value = parsed[key];
9641
+ if (value === undefined)
9642
+ return;
9643
+ if (typeof value !== "string")
9644
+ throw new CliUserError47(`--retry: ${key} must be a duration.`);
9645
+ policy[key] = parseDurationOption(value, `--retry ${key}`);
9646
+ };
9647
+ text("initialInterval");
9648
+ text("maximumInterval");
9649
+ const backoff = parsed["backoffCoefficient"];
9650
+ if (backoff !== undefined) {
9651
+ if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
9652
+ throw new CliUserError47("--retry: backoffCoefficient must be a number of at least 1.");
9653
+ }
9654
+ policy.backoffCoefficient = backoff;
9655
+ }
9656
+ const attempts = parsed["maximumAttempts"];
9657
+ if (attempts !== undefined) {
9658
+ if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
9659
+ throw new CliUserError47("--retry: maximumAttempts must be a whole number (0 = unlimited).");
9660
+ }
9661
+ policy.maximumAttempts = attempts;
9662
+ }
9663
+ const types = parsed["nonRetryableErrorTypes"];
9664
+ if (types !== undefined) {
9665
+ if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
9666
+ throw new CliUserError47("--retry: nonRetryableErrorTypes must be a list of strings.");
9667
+ }
9668
+ policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
9669
+ }
9670
+ }
9671
+ if (maxAttempts !== undefined) {
9672
+ const value = maxAttempts.trim();
9673
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
9674
+ throw new CliUserError47(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
9675
+ }
9676
+ policy.maximumAttempts = Number(value);
9677
+ }
9678
+ return Object.keys(policy).length > 0 ? policy : undefined;
9679
+ }
9680
+ function requireName(raw, what) {
9681
+ const value = raw.trim();
9682
+ if (value === "")
9683
+ throw new CliUserError47(`The ${what} is empty.`);
9684
+ return value;
9685
+ }
9686
+ async function runActivityStart(env, nodeType, operation, options) {
9687
+ const readFile = (path) => {
9688
+ const absolute = resolve12(env.cwd(), path);
9689
+ if (!existsSync14(absolute))
9690
+ throw new CliUserError47(`${path} does not exist.`);
9691
+ return readFileSync12(absolute, "utf8");
9692
+ };
9693
+ if (options.args === undefined) {
9694
+ throw new CliUserError47("--args is required: the operation arguments as a JSON object.", {
9695
+ hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
9696
+ });
9697
+ }
9698
+ const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
9699
+ const summary = options.summary?.trim();
9700
+ if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
9701
+ throw new CliUserError47(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
9702
+ }
9703
+ const key = options.idempotencyKey?.trim();
9704
+ if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
9705
+ throw new CliUserError47(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
9706
+ }
9707
+ const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
9708
+ const nodeVersion = options.nodeVersion?.trim();
9709
+ const connection = options.connection?.trim();
9710
+ const startToClose = parseDurationOption(options.startToCloseTimeout, "--start-to-close-timeout");
9711
+ const scheduleToClose = parseDurationOption(options.scheduleToCloseTimeout, "--schedule-to-close-timeout");
9712
+ const heartbeat = parseDurationOption(options.heartbeatTimeout, "--heartbeat-timeout");
9713
+ const input = {
9714
+ nodeType: requireName(nodeType, "node type"),
9715
+ operation: requireName(operation, "operation"),
9716
+ args,
9717
+ ...nodeVersion ? { nodeVersion } : {},
9718
+ ...connection ? { connection } : {},
9719
+ ...retry ? { retry } : {},
9720
+ ...startToClose ? { startToCloseTimeout: startToClose } : {},
9721
+ ...scheduleToClose ? { scheduleToCloseTimeout: scheduleToClose } : {},
9722
+ ...heartbeat ? { heartbeatTimeout: heartbeat } : {},
9723
+ ...summary ? { summary } : {},
9724
+ ...key ? { idempotencyKey: key } : {}
9725
+ };
9726
+ const started = await env.pd.startActivity(input);
9727
+ const result = { ...started };
9728
+ let finalStatus = started.run.status;
9729
+ if (options.wait) {
9730
+ const finished = await waitForRun(env, started.run.id, options);
9731
+ finalStatus = finished.status;
9732
+ result.run = { ...started.run, status: finished.status, completedAt: finished.completedAt };
9733
+ result.outcome = await durableOutcome(env, finished);
9734
+ }
9735
+ const details = [
9736
+ started.existing ? `Run ${started.run.id} already existed (idempotency key).` : `Started run ${started.run.id} (${input.nodeType} ${input.operation}).`
9737
+ ];
9738
+ if (result.outcome?.output !== undefined) {
9739
+ details.push(`Output: ${JSON.stringify(result.outcome.output)}`);
9740
+ }
9741
+ if (result.outcome?.failure !== undefined) {
9742
+ details.push(`Failure: ${JSON.stringify(result.outcome.failure)}`);
9743
+ }
9744
+ emit(env, options, result, {
9745
+ headers: ["Run", "Status", "Existing"],
9746
+ rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
9747
+ }, details);
9748
+ if (options.wait && finalStatus !== "COMPLETED") {
9749
+ throw new CliUserError47(`Run ${started.run.id} ended ${finalStatus}.`);
9750
+ }
9751
+ return result;
9752
+ }
9753
+ var MAX_SUMMARY_CHARS = 200, MAX_IDEMPOTENCY_KEY_CHARS = 128, IDEMPOTENCY_KEY, RETRY_KEYS;
9754
+ var init_activity_start = __esm(() => {
9755
+ init_runs();
9756
+ init_shared();
9757
+ init_duration();
9758
+ init_shared2();
9759
+ IDEMPOTENCY_KEY = /^[A-Za-z0-9._:-]{1,128}$/;
9760
+ RETRY_KEYS = [
9761
+ "initialInterval",
9762
+ "backoffCoefficient",
9763
+ "maximumInterval",
9764
+ "maximumAttempts",
9765
+ "nonRetryableErrorTypes"
9766
+ ];
9767
+ });
9768
+
9769
+ // src/phase-c/commands/signal-tokens.ts
9770
+ import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
9591
9771
  function row(token) {
9592
9772
  return [
9593
9773
  token.id,
@@ -9604,12 +9784,12 @@ async function runSignalTokenCreate(env, runId, options) {
9604
9784
  const signalName = requireText(options.signal, "--signal");
9605
9785
  const ttlMs = parseMs(options.ttl, "--ttl");
9606
9786
  if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
9607
- throw new CliUserError46("--ttl is counted in whole seconds.");
9787
+ throw new CliUserError48("--ttl is counted in whole seconds.");
9608
9788
  }
9609
9789
  const ipAllowlist = parseList(options.allowIp);
9610
9790
  for (const entry of ipAllowlist) {
9611
9791
  if (!IPV4_OR_CIDR.test(entry)) {
9612
- throw new CliUserError46(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
9792
+ throw new CliUserError48(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
9613
9793
  }
9614
9794
  }
9615
9795
  const created = await env.pc.createSignalToken({
@@ -9645,7 +9825,7 @@ var init_signal_tokens = __esm(() => {
9645
9825
  });
9646
9826
 
9647
9827
  // src/phase-c/commands/search-attributes.ts
9648
- import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
9828
+ import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
9649
9829
  function row2(attribute) {
9650
9830
  return [
9651
9831
  attribute.name,
@@ -9662,11 +9842,11 @@ async function runSearchAttributesList(env, options) {
9662
9842
  }
9663
9843
  async function runSearchAttributesCreate(env, name, options) {
9664
9844
  if (!NAME.test(name)) {
9665
- throw new CliUserError47(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
9845
+ throw new CliUserError49(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
9666
9846
  }
9667
9847
  const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
9668
9848
  if (type === undefined) {
9669
- throw new CliUserError47(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
9849
+ throw new CliUserError49(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
9670
9850
  }
9671
9851
  const attribute = await env.pc.createSearchAttribute({
9672
9852
  name,
@@ -9679,7 +9859,7 @@ async function runSearchAttributesCreate(env, name, options) {
9679
9859
  async function runSearchAttributesDelete(env, name, options) {
9680
9860
  const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
9681
9861
  if (!attribute) {
9682
- throw new CliUserError47(`The workspace has no search attribute ${name}.`, {
9862
+ throw new CliUserError49(`The workspace has no search attribute ${name}.`, {
9683
9863
  hint: "List them with `fluidgrids search-attributes list`."
9684
9864
  });
9685
9865
  }
@@ -9707,7 +9887,7 @@ var init_search_attributes = __esm(() => {
9707
9887
  });
9708
9888
 
9709
9889
  // src/phase-c/commands/schedules.ts
9710
- import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
9890
+ import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
9711
9891
  function isRecord20(value) {
9712
9892
  return typeof value === "object" && value !== null && !Array.isArray(value);
9713
9893
  }
@@ -9832,9 +10012,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
9832
10012
  const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
9833
10013
  const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
9834
10014
  if (from >= to)
9835
- throw new CliUserError48("--from must be before --to.");
10015
+ throw new CliUserError50("--from must be before --to.");
9836
10016
  if (Date.parse(to) > Date.now())
9837
- throw new CliUserError48("--to must be in the past.");
10017
+ throw new CliUserError50("--to must be in the past.");
9838
10018
  await requireConfirmation(env, `Backfill ${workflowKey} ${triggerNodeId} from ${from} to ${to}? Each fire time starts a run (at most ${MAX_BACKFILL_FIRES}) and counts toward the monthly runs.`, options.force);
9839
10019
  const overlapPolicy = parseOverlap(options.overlapPolicy);
9840
10020
  const result = await env.pc.backfillSchedule({
@@ -9883,10 +10063,10 @@ var init_schedules = __esm(() => {
9883
10063
 
9884
10064
  // src/cli.ts
9885
10065
  init_json_contract();
9886
- import { readFileSync as readFileSync12 } from "fs";
10066
+ import { readFileSync as readFileSync13 } from "fs";
9887
10067
  import { join as join12, dirname as dirname6 } from "path";
9888
10068
  import { fileURLToPath } from "url";
9889
- import { CliUserError as CliUserError49, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
10069
+ import { CliUserError as CliUserError51, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
9890
10070
 
9891
10071
  // src/output/run-envelope.ts
9892
10072
  init_json_contract();
@@ -10719,7 +10899,12 @@ function addCompletionTarget(command) {
10719
10899
  return addTargetOptions2(command).option("--task-token-env <VAR>", "Act through the activity's task token, read from this variable (asynchronous completion)");
10720
10900
  }
10721
10901
  function registerActivities(program, make) {
10722
- const activities = program.command("activities").alias("activity").description("Durable-function activities: completion, pause, reset, options and pause rules");
10902
+ const activities = program.command("activities").alias("activity").description("Durable-function activities: standalone starts, completion, pause, reset, options and pause rules");
10903
+ activities.command("start <nodeType> <operation>").description("Run one node operation as a durable activity (retries, timeouts, history; needs fluidgrids.standalone-activities)").option("--args <json>", "The operation arguments: a JSON object, or @file (literal values)").option("--node-version <version>", "Node version (default: the latest)").option("--connection <id>", "The connection id the operation authenticates with").option("--retry <json>", "Retry policy: {initialInterval, backoffCoefficient, maximumInterval, maximumAttempts, nonRetryableErrorTypes}").option("--max-attempts <n>", "Most attempts (0 = unlimited); overrides --retry").option("--start-to-close-timeout <duration>", "How long one attempt may run (30s, 5m, PT1H)").option("--schedule-to-close-timeout <duration>", "How long the activity may take overall, retries included").option("--heartbeat-timeout <duration>", "Longest gap between two heartbeats of an attempt").option("--summary <text>", "One line shown with the activity in the history").option("--idempotency-key <key>", "Return the run this key started before (yours only; needs fluidgrids.durable-parity)").option("--wait", "Wait for the run and print the activity's output").option("--timeout <ms>", "With --wait: give up after this many milliseconds", "300000").option("--poll-interval <ms>", "With --wait: delay between polls in milliseconds", "1000").option(...OUTPUT_OPTION2).action(async (nodeType, operation, options, command) => {
10904
+ await Promise.resolve().then(() => init_activity_start());
10905
+ await Promise.resolve().then(() => init_shared2());
10906
+ await runActivityStart(phaseDEnv(await make()), nodeType, operation, withGlobalFormat(options, command));
10907
+ });
10723
10908
  addCompletionTarget(activities.command("complete [runId] [activityId]").description("Complete an activity that waits for an asynchronous completion").option("--result <json>", "The result (JSON)")).option(...OUTPUT_OPTION2).action(async (first, second, options, command) => {
10724
10909
  await Promise.resolve().then(() => init_activities());
10725
10910
  await runActivityComplete(await make(), first, second, withGlobalFormat(options, command));
@@ -10948,7 +11133,7 @@ var __filename2 = fileURLToPath(import.meta.url);
10948
11133
  var __dirname2 = dirname6(__filename2);
10949
11134
  var version = "0.0.0-dev";
10950
11135
  try {
10951
- const packageJson = JSON.parse(readFileSync12(join12(__dirname2, "../package.json"), "utf8"));
11136
+ const packageJson = JSON.parse(readFileSync13(join12(__dirname2, "../package.json"), "utf8"));
10952
11137
  if (packageJson.version)
10953
11138
  version = packageJson.version;
10954
11139
  } catch {}
@@ -10967,7 +11152,7 @@ try {
10967
11152
  }
10968
11153
  } catch (error) {
10969
11154
  console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
10970
- if (error instanceof CliUserError49 && error.hint)
11155
+ if (error instanceof CliUserError51 && error.hint)
10971
11156
  console.error(`ℹ ${error.hint}`);
10972
- process.exitCode = error instanceof CliUserError49 ? error.exitCode : 1;
11157
+ process.exitCode = error instanceof CliUserError51 ? error.exitCode : 1;
10973
11158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidgrids/cli",
3
- "version": "2026.1113.1",
3
+ "version": "2026.1113.3",
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.1111.2",
58
+ "@fluidgrids/workflows": "2026.1113.1",
59
59
  "@napi-rs/keyring": "2.1.1",
60
60
  "commander": "^14.0.3",
61
61
  "esbuild": "0.28.2",