@fluidgrids/cli 2026.1113.1 → 2026.1113.2

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 +196 -16
  3. package/package.json +1 -1
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
@@ -4683,6 +4683,21 @@ function safeRelativePath2(raw, what) {
4683
4683
  throw new CliUserError26(`The service sent an unsafe ${what} path: ${JSON.stringify(raw)}`);
4684
4684
  return raw;
4685
4685
  }
4686
+ function parseJsonObjectArg(raw, flag, readFile) {
4687
+ if (raw === undefined)
4688
+ return;
4689
+ const text = raw.startsWith("@") ? readFile(raw.slice(1)) : raw;
4690
+ let parsed;
4691
+ try {
4692
+ parsed = JSON.parse(text);
4693
+ } catch {
4694
+ throw new CliUserError26(`${flag} must be a JSON object (or @file holding one).`);
4695
+ }
4696
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
4697
+ throw new CliUserError26(`${flag} must be a JSON object (or @file holding one).`);
4698
+ }
4699
+ return parsed;
4700
+ }
4686
4701
  var init_shared2 = __esm(() => {
4687
4702
  init_api2();
4688
4703
  });
@@ -9586,8 +9601,168 @@ var init_batch = __esm(() => {
9586
9601
  JOB_HEADERS = ["Id", "Type", "Status", "Total", "Succeeded", "Failed", "Skipped"];
9587
9602
  });
9588
9603
 
9589
- // src/phase-c/commands/signal-tokens.ts
9604
+ // src/phase-d/duration.ts
9590
9605
  import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
9606
+ import { toMs } from "@fluidgrids/workflows";
9607
+ function parseDurationOption(raw, flag) {
9608
+ if (raw === undefined)
9609
+ return;
9610
+ const value = raw.trim();
9611
+ const sent = /^\d+(\.\d+)?$/.test(value) ? `${value}ms` : value;
9612
+ try {
9613
+ toMs(sent, flag);
9614
+ } catch {
9615
+ throw new CliUserError46(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
9616
+ }
9617
+ return sent;
9618
+ }
9619
+ var init_duration = () => {};
9620
+
9621
+ // src/phase-d/commands/activity-start.ts
9622
+ import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
9623
+ import { resolve as resolve12 } from "path";
9624
+ import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
9625
+ function retryPolicy(raw, maxAttempts, readFile) {
9626
+ const parsed = parseJsonObjectArg(raw, "--retry", readFile);
9627
+ const policy = {};
9628
+ if (parsed !== undefined) {
9629
+ for (const key of Object.keys(parsed)) {
9630
+ if (!RETRY_KEYS.some((known) => known === key)) {
9631
+ throw new CliUserError47(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
9632
+ }
9633
+ }
9634
+ const text = (key) => {
9635
+ const value = parsed[key];
9636
+ if (value === undefined)
9637
+ return;
9638
+ if (typeof value !== "string")
9639
+ throw new CliUserError47(`--retry: ${key} must be a duration.`);
9640
+ policy[key] = parseDurationOption(value, `--retry ${key}`);
9641
+ };
9642
+ text("initialInterval");
9643
+ text("maximumInterval");
9644
+ const backoff = parsed["backoffCoefficient"];
9645
+ if (backoff !== undefined) {
9646
+ if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
9647
+ throw new CliUserError47("--retry: backoffCoefficient must be a number of at least 1.");
9648
+ }
9649
+ policy.backoffCoefficient = backoff;
9650
+ }
9651
+ const attempts = parsed["maximumAttempts"];
9652
+ if (attempts !== undefined) {
9653
+ if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
9654
+ throw new CliUserError47("--retry: maximumAttempts must be a whole number (0 = unlimited).");
9655
+ }
9656
+ policy.maximumAttempts = attempts;
9657
+ }
9658
+ const types = parsed["nonRetryableErrorTypes"];
9659
+ if (types !== undefined) {
9660
+ if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
9661
+ throw new CliUserError47("--retry: nonRetryableErrorTypes must be a list of strings.");
9662
+ }
9663
+ policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
9664
+ }
9665
+ }
9666
+ if (maxAttempts !== undefined) {
9667
+ const value = maxAttempts.trim();
9668
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
9669
+ throw new CliUserError47(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
9670
+ }
9671
+ policy.maximumAttempts = Number(value);
9672
+ }
9673
+ return Object.keys(policy).length > 0 ? policy : undefined;
9674
+ }
9675
+ function requireName(raw, what) {
9676
+ const value = raw.trim();
9677
+ if (value === "")
9678
+ throw new CliUserError47(`The ${what} is empty.`);
9679
+ return value;
9680
+ }
9681
+ async function runActivityStart(env, nodeType, operation, options) {
9682
+ const readFile = (path) => {
9683
+ const absolute = resolve12(env.cwd(), path);
9684
+ if (!existsSync14(absolute))
9685
+ throw new CliUserError47(`${path} does not exist.`);
9686
+ return readFileSync12(absolute, "utf8");
9687
+ };
9688
+ if (options.args === undefined) {
9689
+ throw new CliUserError47("--args is required: the operation arguments as a JSON object.", {
9690
+ hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
9691
+ });
9692
+ }
9693
+ const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
9694
+ const summary = options.summary?.trim();
9695
+ if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
9696
+ throw new CliUserError47(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
9697
+ }
9698
+ const key = options.idempotencyKey?.trim();
9699
+ if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
9700
+ throw new CliUserError47(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
9701
+ }
9702
+ const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
9703
+ const nodeVersion = options.nodeVersion?.trim();
9704
+ const connection = options.connection?.trim();
9705
+ const startToClose = parseDurationOption(options.startToCloseTimeout, "--start-to-close-timeout");
9706
+ const scheduleToClose = parseDurationOption(options.scheduleToCloseTimeout, "--schedule-to-close-timeout");
9707
+ const heartbeat = parseDurationOption(options.heartbeatTimeout, "--heartbeat-timeout");
9708
+ const input = {
9709
+ nodeType: requireName(nodeType, "node type"),
9710
+ operation: requireName(operation, "operation"),
9711
+ args,
9712
+ ...nodeVersion ? { nodeVersion } : {},
9713
+ ...connection ? { connection } : {},
9714
+ ...retry ? { retry } : {},
9715
+ ...startToClose ? { startToCloseTimeout: startToClose } : {},
9716
+ ...scheduleToClose ? { scheduleToCloseTimeout: scheduleToClose } : {},
9717
+ ...heartbeat ? { heartbeatTimeout: heartbeat } : {},
9718
+ ...summary ? { summary } : {},
9719
+ ...key ? { idempotencyKey: key } : {}
9720
+ };
9721
+ const started = await env.pd.startActivity(input);
9722
+ const result = { ...started };
9723
+ let finalStatus = started.run.status;
9724
+ if (options.wait) {
9725
+ const finished = await waitForRun(env, started.run.id, options);
9726
+ finalStatus = finished.status;
9727
+ result.run = { ...started.run, status: finished.status, completedAt: finished.completedAt };
9728
+ result.outcome = await durableOutcome(env, finished);
9729
+ }
9730
+ const details = [
9731
+ started.existing ? `Run ${started.run.id} already existed (idempotency key).` : `Started run ${started.run.id} (${input.nodeType} ${input.operation}).`
9732
+ ];
9733
+ if (result.outcome?.output !== undefined) {
9734
+ details.push(`Output: ${JSON.stringify(result.outcome.output)}`);
9735
+ }
9736
+ if (result.outcome?.failure !== undefined) {
9737
+ details.push(`Failure: ${JSON.stringify(result.outcome.failure)}`);
9738
+ }
9739
+ emit(env, options, result, {
9740
+ headers: ["Run", "Status", "Existing"],
9741
+ rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
9742
+ }, details);
9743
+ if (options.wait && finalStatus !== "COMPLETED") {
9744
+ throw new CliUserError47(`Run ${started.run.id} ended ${finalStatus}.`);
9745
+ }
9746
+ return result;
9747
+ }
9748
+ var MAX_SUMMARY_CHARS = 200, MAX_IDEMPOTENCY_KEY_CHARS = 128, IDEMPOTENCY_KEY, RETRY_KEYS;
9749
+ var init_activity_start = __esm(() => {
9750
+ init_runs();
9751
+ init_shared();
9752
+ init_duration();
9753
+ init_shared2();
9754
+ IDEMPOTENCY_KEY = /^[A-Za-z0-9._:-]{1,128}$/;
9755
+ RETRY_KEYS = [
9756
+ "initialInterval",
9757
+ "backoffCoefficient",
9758
+ "maximumInterval",
9759
+ "maximumAttempts",
9760
+ "nonRetryableErrorTypes"
9761
+ ];
9762
+ });
9763
+
9764
+ // src/phase-c/commands/signal-tokens.ts
9765
+ import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
9591
9766
  function row(token) {
9592
9767
  return [
9593
9768
  token.id,
@@ -9604,12 +9779,12 @@ async function runSignalTokenCreate(env, runId, options) {
9604
9779
  const signalName = requireText(options.signal, "--signal");
9605
9780
  const ttlMs = parseMs(options.ttl, "--ttl");
9606
9781
  if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
9607
- throw new CliUserError46("--ttl is counted in whole seconds.");
9782
+ throw new CliUserError48("--ttl is counted in whole seconds.");
9608
9783
  }
9609
9784
  const ipAllowlist = parseList(options.allowIp);
9610
9785
  for (const entry of ipAllowlist) {
9611
9786
  if (!IPV4_OR_CIDR.test(entry)) {
9612
- throw new CliUserError46(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
9787
+ throw new CliUserError48(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
9613
9788
  }
9614
9789
  }
9615
9790
  const created = await env.pc.createSignalToken({
@@ -9645,7 +9820,7 @@ var init_signal_tokens = __esm(() => {
9645
9820
  });
9646
9821
 
9647
9822
  // src/phase-c/commands/search-attributes.ts
9648
- import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
9823
+ import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
9649
9824
  function row2(attribute) {
9650
9825
  return [
9651
9826
  attribute.name,
@@ -9662,11 +9837,11 @@ async function runSearchAttributesList(env, options) {
9662
9837
  }
9663
9838
  async function runSearchAttributesCreate(env, name, options) {
9664
9839
  if (!NAME.test(name)) {
9665
- throw new CliUserError47(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
9840
+ throw new CliUserError49(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
9666
9841
  }
9667
9842
  const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
9668
9843
  if (type === undefined) {
9669
- throw new CliUserError47(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
9844
+ throw new CliUserError49(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
9670
9845
  }
9671
9846
  const attribute = await env.pc.createSearchAttribute({
9672
9847
  name,
@@ -9679,7 +9854,7 @@ async function runSearchAttributesCreate(env, name, options) {
9679
9854
  async function runSearchAttributesDelete(env, name, options) {
9680
9855
  const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
9681
9856
  if (!attribute) {
9682
- throw new CliUserError47(`The workspace has no search attribute ${name}.`, {
9857
+ throw new CliUserError49(`The workspace has no search attribute ${name}.`, {
9683
9858
  hint: "List them with `fluidgrids search-attributes list`."
9684
9859
  });
9685
9860
  }
@@ -9707,7 +9882,7 @@ var init_search_attributes = __esm(() => {
9707
9882
  });
9708
9883
 
9709
9884
  // src/phase-c/commands/schedules.ts
9710
- import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
9885
+ import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
9711
9886
  function isRecord20(value) {
9712
9887
  return typeof value === "object" && value !== null && !Array.isArray(value);
9713
9888
  }
@@ -9832,9 +10007,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
9832
10007
  const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
9833
10008
  const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
9834
10009
  if (from >= to)
9835
- throw new CliUserError48("--from must be before --to.");
10010
+ throw new CliUserError50("--from must be before --to.");
9836
10011
  if (Date.parse(to) > Date.now())
9837
- throw new CliUserError48("--to must be in the past.");
10012
+ throw new CliUserError50("--to must be in the past.");
9838
10013
  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
10014
  const overlapPolicy = parseOverlap(options.overlapPolicy);
9840
10015
  const result = await env.pc.backfillSchedule({
@@ -9883,10 +10058,10 @@ var init_schedules = __esm(() => {
9883
10058
 
9884
10059
  // src/cli.ts
9885
10060
  init_json_contract();
9886
- import { readFileSync as readFileSync12 } from "fs";
10061
+ import { readFileSync as readFileSync13 } from "fs";
9887
10062
  import { join as join12, dirname as dirname6 } from "path";
9888
10063
  import { fileURLToPath } from "url";
9889
- import { CliUserError as CliUserError49, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
10064
+ import { CliUserError as CliUserError51, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
9890
10065
 
9891
10066
  // src/output/run-envelope.ts
9892
10067
  init_json_contract();
@@ -10719,7 +10894,12 @@ function addCompletionTarget(command) {
10719
10894
  return addTargetOptions2(command).option("--task-token-env <VAR>", "Act through the activity's task token, read from this variable (asynchronous completion)");
10720
10895
  }
10721
10896
  function registerActivities(program, make) {
10722
- const activities = program.command("activities").alias("activity").description("Durable-function activities: completion, pause, reset, options and pause rules");
10897
+ const activities = program.command("activities").alias("activity").description("Durable-function activities: standalone starts, completion, pause, reset, options and pause rules");
10898
+ 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) => {
10899
+ await Promise.resolve().then(() => init_activity_start());
10900
+ await Promise.resolve().then(() => init_shared2());
10901
+ await runActivityStart(phaseDEnv(await make()), nodeType, operation, withGlobalFormat(options, command));
10902
+ });
10723
10903
  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
10904
  await Promise.resolve().then(() => init_activities());
10725
10905
  await runActivityComplete(await make(), first, second, withGlobalFormat(options, command));
@@ -10948,7 +11128,7 @@ var __filename2 = fileURLToPath(import.meta.url);
10948
11128
  var __dirname2 = dirname6(__filename2);
10949
11129
  var version = "0.0.0-dev";
10950
11130
  try {
10951
- const packageJson = JSON.parse(readFileSync12(join12(__dirname2, "../package.json"), "utf8"));
11131
+ const packageJson = JSON.parse(readFileSync13(join12(__dirname2, "../package.json"), "utf8"));
10952
11132
  if (packageJson.version)
10953
11133
  version = packageJson.version;
10954
11134
  } catch {}
@@ -10967,7 +11147,7 @@ try {
10967
11147
  }
10968
11148
  } catch (error) {
10969
11149
  console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
10970
- if (error instanceof CliUserError49 && error.hint)
11150
+ if (error instanceof CliUserError51 && error.hint)
10971
11151
  console.error(`ℹ ${error.hint}`);
10972
- process.exitCode = error instanceof CliUserError49 ? error.exitCode : 1;
11152
+ process.exitCode = error instanceof CliUserError51 ? error.exitCode : 1;
10973
11153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidgrids/cli",
3
- "version": "2026.1113.1",
3
+ "version": "2026.1113.2",
4
4
  "description": "CLI tool for FluidGrids — workflow automation management (thin shell over @burdenoff/cli-sdk)",
5
5
  "type": "module",
6
6
  "private": false,