@fluidgrids/cli 2026.1114.3 → 2026.1115.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 +18 -0
  2. package/dist/cli.js +567 -271
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -895,7 +895,13 @@ var PRESIGNED_PUT_FIELDS = "url method headers expiresAt alreadyStored", CF_PREP
895
895
  query FluidgridsCodeWorkflowRunHistory($runId: ID!, $after: Int, $limit: Int) {
896
896
  workflowRunHistory(runId: $runId, after: $after, limit: $limit) {
897
897
  events { runId seq type taskId payload payloadUrl createdAt }
898
- nextAfter hasMore historyLength historyBytes
898
+ nextAfter hasMore historyLength historyBytes archived archiveRef archiveReadError
899
+ }
900
+ }
901
+ `, CF_WORKFLOW_RUN_ARCHIVE = `
902
+ query FluidgridsCodeWorkflowRunArchive($runId: ID!) {
903
+ workflowRunArchive(runId: $runId) {
904
+ runId workflowKey version executionKind status archivedAt archiveRef includePayloads eventCount
899
905
  }
900
906
  }
901
907
  `, CF_SIGNAL_WORKFLOW_RUN = `
@@ -1008,6 +1014,22 @@ var DURABLE_RUN_FIELDS2 = `
1008
1014
  groupsTruncated
1009
1015
  }
1010
1016
  }
1017
+ `, CF_RUNS_COUNT_BY_ATTRIBUTE = `
1018
+ query FluidgridsCodeRunsCountByAttribute(
1019
+ $filter: ListWorkflowRunsInput
1020
+ $groupBy: [RunGroupBy!]
1021
+ $groupBySearchAttributes: [String!]
1022
+ ) {
1023
+ workflowRunsCount(
1024
+ filter: $filter
1025
+ groupBy: $groupBy
1026
+ groupBySearchAttributes: $groupBySearchAttributes
1027
+ ) {
1028
+ total
1029
+ groups { key values count }
1030
+ groupsTruncated
1031
+ }
1032
+ }
1011
1033
  `, CF_SIGNAL_RUN_BY_TARGET = `
1012
1034
  mutation FluidgridsCodeSignalRunByTarget(
1013
1035
  $target: RunTargetInput!
@@ -1455,6 +1477,10 @@ function createCodeFirstApi(ctx) {
1455
1477
  throw new CliUserError8(`Run ${runId} not found (NOT_FOUND)`);
1456
1478
  return data.workflowRun;
1457
1479
  },
1480
+ async runArchive(runId) {
1481
+ const data = await request(CF_WORKFLOW_RUN_ARCHIVE, { runId });
1482
+ return data.workflowRunArchive;
1483
+ },
1458
1484
  async runHistoryPage(runId, after, limit) {
1459
1485
  const data = await request(CF_WORKFLOW_RUN_HISTORY, {
1460
1486
  runId,
@@ -1548,10 +1574,15 @@ function createCodeFirstApi(ctx) {
1548
1574
  throw new CliUserError8(`Run ${runId} not found (NOT_FOUND)`);
1549
1575
  return data.workflowRun;
1550
1576
  },
1551
- async countRuns(filter, groupBy) {
1552
- const data = await request(CF_RUNS_COUNT, {
1577
+ async countRuns(filter, groupBy, groupBySearchAttributes = []) {
1578
+ const columns = groupBy.length > 0 ? groupBy : null;
1579
+ const data = groupBySearchAttributes.length > 0 ? await request(CF_RUNS_COUNT_BY_ATTRIBUTE, {
1580
+ filter,
1581
+ groupBy: columns,
1582
+ groupBySearchAttributes
1583
+ }) : await request(CF_RUNS_COUNT, {
1553
1584
  filter,
1554
- groupBy: groupBy.length > 0 ? groupBy : null
1585
+ groupBy: columns
1555
1586
  });
1556
1587
  return data.workflowRunsCount;
1557
1588
  },
@@ -3653,13 +3684,24 @@ async function offloadedPayload(env, event, runId) {
3653
3684
  }
3654
3685
  return objectPayload(parsed, where);
3655
3686
  }
3687
+ function assertArchiveReadable(runId, page) {
3688
+ if (!page.archived || page.archiveReadError === null)
3689
+ return;
3690
+ const where = page.archiveRef ? ` (${page.archiveRef})` : "";
3691
+ throw new CliUserError19(`Run ${runId} was archived${where}, but its history could not be read back: ${page.archiveReadError}`, {
3692
+ hint: [
3693
+ "The archive destination must grant s3:GetObject on the archive prefix to the archive role.",
3694
+ `You can also download history.jsonl.gz from the archive yourself and run \`fluidgrids replay <path>/history.jsonl.gz\`.`
3695
+ ].join(`
3696
+ `)
3697
+ });
3698
+ }
3656
3699
  async function fetchRunEvents(env, runId) {
3657
3700
  const events = [];
3658
3701
  let after = 0;
3659
- let historyBytes = 0;
3660
3702
  for (let page = 0;page < MAX_PAGES; page++) {
3661
3703
  const result = await env.api.runHistoryPage(runId, after, HISTORY_PAGE_SIZE);
3662
- historyBytes = result.historyBytes;
3704
+ assertArchiveReadable(runId, result);
3663
3705
  for (const event of result.events) {
3664
3706
  const payload = event.payloadUrl ? await offloadedPayload(env, event, runId) : objectPayload(event.payload, `Run ${runId} event ${event.seq}`);
3665
3707
  events.push({
@@ -3671,8 +3713,15 @@ async function fetchRunEvents(env, runId) {
3671
3713
  });
3672
3714
  }
3673
3715
  const last = result.events[result.events.length - 1];
3674
- if (!result.hasMore || !last)
3675
- return { events, historyBytes };
3716
+ if (!result.hasMore || !last) {
3717
+ return {
3718
+ events,
3719
+ historyBytes: result.historyBytes,
3720
+ archived: result.archived === true,
3721
+ archiveRef: result.archiveRef ?? null,
3722
+ historyLength: result.historyLength
3723
+ };
3724
+ }
3676
3725
  after = result.nextAfter ?? last.seq;
3677
3726
  }
3678
3727
  throw new CliUserError19(`The history of run ${runId} did not end after ${MAX_PAGES} pages; refusing to continue.`);
@@ -3682,12 +3731,70 @@ function assertDurable(run) {
3682
3731
  throw new CliUserError19(`Run ${run.id} is a ${run.executionKind} run; only durable-function runs have an event history.`, { hint: `Use \`fluidgrids runs logs ${run.id}\` for a canvas run.` });
3683
3732
  }
3684
3733
  }
3734
+ function workflowFnOf(run, events) {
3735
+ if (run?.workflowFn)
3736
+ return run.workflowFn;
3737
+ const started = events[0]?.type === "WORKFLOW_STARTED" ? events[0].payload : undefined;
3738
+ return started && typeof started["workflowFn"] === "string" ? started["workflowFn"] : undefined;
3739
+ }
3740
+ function validated(file, runId) {
3741
+ try {
3742
+ return parseHistoryFile(file);
3743
+ } catch (error) {
3744
+ if (error instanceof HistoryFileError) {
3745
+ throw new CliUserError19(`The history of run ${runId} is not a valid history file.`, {
3746
+ hint: [error.message, ...error.issues].join(`
3747
+ `)
3748
+ });
3749
+ }
3750
+ throw error;
3751
+ }
3752
+ }
3753
+ async function fetchArchivedHistory(env, runId) {
3754
+ const archive = await env.api.runArchive(runId);
3755
+ if (!archive)
3756
+ throw new CliUserError19(`Run ${runId} not found (NOT_FOUND)`);
3757
+ const where = `Run ${runId} was archived (${archive.archiveRef})`;
3758
+ if (archive.executionKind !== "DURABLE_FN") {
3759
+ throw new CliUserError19(`${where} as a ${archive.executionKind} run; only durable-function runs have an event history.`, { hint: "A canvas run keeps its node executions in nodes.jsonl.gz next to the archive." });
3760
+ }
3761
+ if (!archive.includePayloads) {
3762
+ throw new CliUserError19(`${where} without its payloads (includePayloads: false), so its history cannot be replayed.`);
3763
+ }
3764
+ const fetched = await fetchRunEvents(env, runId);
3765
+ if (fetched.events.length === 0) {
3766
+ throw new CliUserError19(`${where} with no history events.`);
3767
+ }
3768
+ const workflowFn = workflowFnOf(null, fetched.events);
3769
+ if (!workflowFn)
3770
+ throw new CliUserError19(`Run ${runId} records no workflow function.`);
3771
+ const workspaceId = env.ctx.auth.read()?.workspaceId ?? "unknown";
3772
+ const file = createHistoryFile(workflowFn, fetched.events, {
3773
+ name: runId,
3774
+ info: { runId, workspaceId, workflowKey: archive.workflowKey, version: archive.version }
3775
+ });
3776
+ return {
3777
+ run: null,
3778
+ file: validated(file, runId),
3779
+ historyBytes: fetched.historyBytes,
3780
+ archive: { archiveRef: archive.archiveRef }
3781
+ };
3782
+ }
3783
+ function isRunNotFound(error) {
3784
+ return error instanceof CliUserError19 && /\(NOT_FOUND\)/.test(error.message);
3785
+ }
3685
3786
  async function fetchHistory(env, runId) {
3686
- const run = await env.api.describeRun(runId);
3787
+ let run;
3788
+ try {
3789
+ run = await env.api.describeRun(runId);
3790
+ } catch (error) {
3791
+ if (isRunNotFound(error))
3792
+ return fetchArchivedHistory(env, runId);
3793
+ throw error;
3794
+ }
3687
3795
  assertDurable(run);
3688
3796
  const { events, historyBytes } = await fetchRunEvents(env, runId);
3689
- const started = events[0]?.type === "WORKFLOW_STARTED" ? events[0].payload : undefined;
3690
- const workflowFn = run.workflowFn ?? (started && typeof started["workflowFn"] === "string" ? started["workflowFn"] : undefined);
3797
+ const workflowFn = workflowFnOf(run, events);
3691
3798
  if (!workflowFn) {
3692
3799
  throw new CliUserError19(`Run ${runId} records no workflow function.`);
3693
3800
  }
@@ -3705,17 +3812,7 @@ async function fetchHistory(env, runId) {
3705
3812
  rootRunId: run.rootRunId
3706
3813
  }
3707
3814
  });
3708
- try {
3709
- return { run, file: parseHistoryFile(file), historyBytes };
3710
- } catch (error) {
3711
- if (error instanceof HistoryFileError) {
3712
- throw new CliUserError19(`The history of run ${runId} is not a valid history file.`, {
3713
- hint: [error.message, ...error.issues].join(`
3714
- `)
3715
- });
3716
- }
3717
- throw error;
3718
- }
3815
+ return { run, file: validated(file, runId), historyBytes, archive: null };
3719
3816
  }
3720
3817
  function parseHistoryText(text, path) {
3721
3818
  try {
@@ -5402,6 +5499,17 @@ function parseGroupBy(raw) {
5402
5499
  throw new CliUserError30("--group-by takes at most two columns.");
5403
5500
  return distinct;
5404
5501
  }
5502
+ function parseGroupByAttributes(raw, columns) {
5503
+ if (raw === undefined)
5504
+ return [];
5505
+ const names = [...new Set(raw.split(",").map((part) => part.trim()))].filter((name) => name !== "");
5506
+ if (names.length === 0)
5507
+ throw new CliUserError30("--group-by-attribute needs a search attribute name.");
5508
+ if (names.length + columns > 2) {
5509
+ throw new CliUserError30("--group-by and --group-by-attribute take at most two columns together.");
5510
+ }
5511
+ return names;
5512
+ }
5405
5513
  function parseDuration(raw, flag) {
5406
5514
  if (raw === undefined)
5407
5515
  return;
@@ -5811,14 +5919,18 @@ async function runDescribe(env, runId, options) {
5811
5919
  }
5812
5920
  async function runHistory(env, runIdArg, options) {
5813
5921
  const runId = await resolveRunId(env, runRefOf(runIdArg, options));
5814
- const { file, historyBytes } = await fetchHistory(env, runId);
5922
+ const { file, historyBytes, archive } = await fetchHistory(env, runId);
5815
5923
  const result = {
5816
5924
  runId,
5817
5925
  workflowFn: file.workflowFn,
5818
5926
  events: file.events.length,
5819
5927
  historyBytes,
5820
- out: null
5928
+ out: null,
5929
+ archiveRef: archive ? archive.archiveRef : null
5821
5930
  };
5931
+ const archivedNote = archive ? [
5932
+ `Run ${runId} was archived and purged; its history was read back from ${archive.archiveRef}.`
5933
+ ] : [];
5822
5934
  if (options.out) {
5823
5935
  const target = resolve7(env.cwd(), options.out);
5824
5936
  writeFileSync6(target, serializeHistoryFile2(file), "utf8");
@@ -5826,7 +5938,7 @@ async function runHistory(env, runIdArg, options) {
5826
5938
  emit(env, options, result, {
5827
5939
  headers: ["Run", "Function", "Events", "File"],
5828
5940
  rows: [[runId, file.workflowFn, String(result.events), target]]
5829
- });
5941
+ }, archivedNote);
5830
5942
  return result;
5831
5943
  }
5832
5944
  emit(env, options, file, {
@@ -5837,7 +5949,7 @@ async function runHistory(env, runIdArg, options) {
5837
5949
  event.taskId ?? "-",
5838
5950
  event.createdAt
5839
5951
  ])
5840
- });
5952
+ }, archivedNote);
5841
5953
  return result;
5842
5954
  }
5843
5955
  function isTargeted(options) {
@@ -6003,7 +6115,8 @@ async function runCount(env, options) {
6003
6115
  if (memo)
6004
6116
  filter.memo = memo;
6005
6117
  const groupBy = parseGroupBy(options.groupBy);
6006
- const counted = await env.api.countRuns(filter, groupBy);
6118
+ const attributes = parseGroupByAttributes(options.groupByAttribute, groupBy.length);
6119
+ const counted = attributes.length > 0 ? await env.api.countRuns(filter, groupBy, attributes) : await env.api.countRuns(filter, groupBy);
6007
6120
  const details = [`Total: ${counted.total}`];
6008
6121
  if (counted.groupsTruncated)
6009
6122
  details.push("More than 1000 groups: the smallest were left out.");
@@ -6136,13 +6249,194 @@ var init_runs = __esm(() => {
6136
6249
  ];
6137
6250
  });
6138
6251
 
6139
- // src/code-first/commands/replay.ts
6140
- import { existsSync as existsSync11, readdirSync as readdirSync2, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
6141
- import { join as join10, relative as relative3, resolve as resolve8, sep as sep3 } from "path";
6252
+ // src/code-first/archive-file.ts
6253
+ import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
6254
+ import { dirname as dirname6, join as join10 } from "path";
6255
+ import { gunzipSync } from "zlib";
6142
6256
  import { CliUserError as CliUserError32 } from "@burdenoff/cli-sdk/core";
6257
+ import {
6258
+ createHistoryFile as createHistoryFile2,
6259
+ HistoryFileError as HistoryFileError2,
6260
+ parseHistoryFile as parseHistoryFile2
6261
+ } from "@fluidgrids/workflows/history";
6143
6262
  function isRecord17(value) {
6144
6263
  return typeof value === "object" && value !== null && !Array.isArray(value);
6145
6264
  }
6265
+ function isGzip(bytes) {
6266
+ return bytes.length >= 2 && bytes[0] === GZIP_MAGIC[0] && bytes[1] === GZIP_MAGIC[1];
6267
+ }
6268
+ function looksLikeHistoryPath(target) {
6269
+ return /[\\/]|\.json$|\.jsonl$|\.gz$/.test(target);
6270
+ }
6271
+ function optionalString2(value) {
6272
+ return typeof value === "string" && value !== "" ? value : undefined;
6273
+ }
6274
+ function nullableString(value) {
6275
+ if (value === null)
6276
+ return null;
6277
+ return optionalString2(value);
6278
+ }
6279
+ function parseRunDocument(text, display) {
6280
+ let value;
6281
+ try {
6282
+ value = JSON.parse(text);
6283
+ } catch {
6284
+ throw new CliUserError32(`${display} is not JSON.`);
6285
+ }
6286
+ if (!isRecord17(value) || value["format"] !== RUN_ARCHIVE_FORMAT) {
6287
+ throw new CliUserError32(`${display} is not a run archive's run.json (format ${RUN_ARCHIVE_FORMAT}).`);
6288
+ }
6289
+ const runId = optionalString2(value["runId"]);
6290
+ const workspaceId = optionalString2(value["workspaceId"]);
6291
+ if (!runId || !workspaceId) {
6292
+ throw new CliUserError32(`${display} does not name the run and its workspace.`);
6293
+ }
6294
+ const doc = { runId, workspaceId };
6295
+ const workflowKey = optionalString2(value["workflowKey"]);
6296
+ if (workflowKey)
6297
+ doc.workflowKey = workflowKey;
6298
+ const version = optionalString2(value["version"]);
6299
+ if (version)
6300
+ doc.version = version;
6301
+ const kind = optionalString2(value["executionKind"]);
6302
+ if (kind)
6303
+ doc.executionKind = kind;
6304
+ for (const field of ["parentRunId", "rootRunId", "firstRunId", "businessId"]) {
6305
+ const id = nullableString(value[field]);
6306
+ if (id !== undefined)
6307
+ doc[field] = id;
6308
+ }
6309
+ if (typeof value["includePayloads"] === "boolean")
6310
+ doc.includePayloads = value["includePayloads"];
6311
+ return doc;
6312
+ }
6313
+ function archivedEvent(line, lineNumber, display) {
6314
+ const where = `${display} line ${lineNumber}`;
6315
+ let value;
6316
+ try {
6317
+ value = JSON.parse(line);
6318
+ } catch {
6319
+ throw new CliUserError32(`${where} is not JSON.`);
6320
+ }
6321
+ if (!isRecord17(value))
6322
+ throw new CliUserError32(`${where} is not a history event.`);
6323
+ const { seq, type, taskId, payload, createdAt } = value;
6324
+ if (typeof seq !== "number" || typeof type !== "string" || typeof createdAt !== "string") {
6325
+ throw new CliUserError32(`${where} is not a history event (it needs seq, type and createdAt).`);
6326
+ }
6327
+ if (payload === undefined) {
6328
+ throw new CliUserError32(`${display} was archived without its payloads (includePayloads: false), so it cannot be replayed.`);
6329
+ }
6330
+ if (!isRecord17(payload))
6331
+ throw new CliUserError32(`${where}: the payload is not a JSON object.`);
6332
+ return {
6333
+ seq,
6334
+ type,
6335
+ ...typeof taskId === "string" && taskId !== "" ? { taskId } : {},
6336
+ payload,
6337
+ createdAt
6338
+ };
6339
+ }
6340
+ function infoOf(doc, fallbackRunId) {
6341
+ if (!doc)
6342
+ return { runId: fallbackRunId, workspaceId: "unknown" };
6343
+ return {
6344
+ runId: doc.runId,
6345
+ workspaceId: doc.workspaceId,
6346
+ ...doc.workflowKey ? { workflowKey: doc.workflowKey } : {},
6347
+ ...doc.version ? { version: doc.version } : {},
6348
+ ...doc.businessId ? { businessId: doc.businessId, workflowId: doc.businessId } : {},
6349
+ ...doc.parentRunId !== undefined ? { parentRunId: doc.parentRunId } : {},
6350
+ ...doc.rootRunId !== undefined ? { rootRunId: doc.rootRunId } : {},
6351
+ ...doc.firstRunId !== undefined ? { firstRunId: doc.firstRunId } : {}
6352
+ };
6353
+ }
6354
+ function parseArchivedHistory(text, display, doc = null) {
6355
+ if (doc?.executionKind !== undefined && doc.executionKind !== "DURABLE_FN") {
6356
+ throw new CliUserError32(`${display} is the archive of a ${doc.executionKind} run; only durable-function runs have an event history to replay.`);
6357
+ }
6358
+ if (doc?.includePayloads === false) {
6359
+ throw new CliUserError32(`${display} was archived without its payloads (includePayloads: false), so it cannot be replayed.`);
6360
+ }
6361
+ const events = [];
6362
+ let lineNumber = 0;
6363
+ for (const line of text.split(`
6364
+ `)) {
6365
+ lineNumber += 1;
6366
+ if (line.trim() === "")
6367
+ continue;
6368
+ events.push(archivedEvent(line, lineNumber, display));
6369
+ }
6370
+ if (events.length === 0) {
6371
+ throw new CliUserError32(`${display} holds no history events.`, {
6372
+ hint: "A canvas (graph) run archives no history events; its node executions are in nodes.jsonl.gz."
6373
+ });
6374
+ }
6375
+ const started = events[0];
6376
+ const workflowFn = started?.type === "WORKFLOW_STARTED" && typeof started.payload["workflowFn"] === "string" ? started.payload["workflowFn"] : undefined;
6377
+ if (!workflowFn) {
6378
+ throw new CliUserError32(`${display} does not start with a WORKFLOW_STARTED event naming its function.`);
6379
+ }
6380
+ const file = createHistoryFile2(workflowFn, events, {
6381
+ name: doc?.runId ?? display,
6382
+ info: infoOf(doc, display)
6383
+ });
6384
+ try {
6385
+ return parseHistoryFile2(file);
6386
+ } catch (error) {
6387
+ if (error instanceof HistoryFileError2) {
6388
+ throw new CliUserError32(`${display} is not a valid run history: ${error.message}`, {
6389
+ ...error.issues.length > 0 ? { hint: error.issues.join(`
6390
+ `) } : {}
6391
+ });
6392
+ }
6393
+ throw error;
6394
+ }
6395
+ }
6396
+ function gunzip(bytes, display) {
6397
+ try {
6398
+ return gunzipSync(bytes, { maxOutputLength: MAX_ARCHIVE_HISTORY_BYTES }).toString("utf8");
6399
+ } catch (error) {
6400
+ const code = isRecord17(error) ? error["code"] : undefined;
6401
+ if (code === "ERR_BUFFER_TOO_LARGE") {
6402
+ throw new CliUserError32(`${display} decompresses to more than ${MAX_ARCHIVE_HISTORY_BYTES} bytes; it is not a run archive's history.`);
6403
+ }
6404
+ throw new CliUserError32(`${display} is not a readable gzip file.`);
6405
+ }
6406
+ }
6407
+ function siblingRunDocument(path, display) {
6408
+ const runJson = join10(dirname6(path), "run.json");
6409
+ if (!existsSync11(runJson))
6410
+ return null;
6411
+ return parseRunDocument(readFileSync10(runJson, "utf8"), join10(dirname6(display), "run.json"));
6412
+ }
6413
+ function readHistoryFromDisk(path, display) {
6414
+ const bytes = readFileSync10(path);
6415
+ if (isGzip(bytes)) {
6416
+ return parseArchivedHistory(gunzip(bytes, display), display, siblingRunDocument(path, display));
6417
+ }
6418
+ const text = bytes.toString("utf8");
6419
+ if (path.endsWith(".jsonl")) {
6420
+ return parseArchivedHistory(text, display, siblingRunDocument(path, display));
6421
+ }
6422
+ if (path.endsWith(".gz"))
6423
+ throw new CliUserError32(`${display} is not a readable gzip file.`);
6424
+ return parseHistoryText(text, display);
6425
+ }
6426
+ var RUN_ARCHIVE_FORMAT = "fluidgrids.run-archive", MAX_ARCHIVE_HISTORY_BYTES, GZIP_MAGIC;
6427
+ var init_archive_file = __esm(() => {
6428
+ init_history();
6429
+ MAX_ARCHIVE_HISTORY_BYTES = 1024 * 1024 * 1024;
6430
+ GZIP_MAGIC = [31, 139];
6431
+ });
6432
+
6433
+ // src/code-first/commands/replay.ts
6434
+ import { existsSync as existsSync12, readdirSync as readdirSync2, readFileSync as readFileSync11, statSync as statSync4 } from "fs";
6435
+ import { join as join11, relative as relative3, resolve as resolve8, sep as sep3 } from "path";
6436
+ import { CliUserError as CliUserError33 } from "@burdenoff/cli-sdk/core";
6437
+ function isRecord18(value) {
6438
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6439
+ }
6146
6440
  async function lowerOffline(project) {
6147
6441
  return lowerProject(project, {
6148
6442
  connections: placeholderRef,
@@ -6154,10 +6448,10 @@ function durableExportNames(lowered) {
6154
6448
  const names = new Set;
6155
6449
  for (const workflow of lowered.workflows) {
6156
6450
  const code = workflow.definition["code"];
6157
- if (!isRecord17(code) || !isRecord17(code["exports"]))
6451
+ if (!isRecord18(code) || !isRecord18(code["exports"]))
6158
6452
  continue;
6159
6453
  const workflows = code["exports"]["workflows"];
6160
- if (isRecord17(workflows))
6454
+ if (isRecord18(workflows))
6161
6455
  for (const name of Object.keys(workflows))
6162
6456
  names.add(name);
6163
6457
  }
@@ -6165,7 +6459,7 @@ function durableExportNames(lowered) {
6165
6459
  }
6166
6460
  function requireBundle(lowered) {
6167
6461
  if (!lowered.bundle || !lowered.buildId || durableExportNames(lowered).length === 0) {
6168
- throw new CliUserError32("The project defines no durable functions to replay.", {
6462
+ throw new CliUserError33("The project defines no durable functions to replay.", {
6169
6463
  hint: "Durable functions are `workflow()` exports in workflows/*.ts."
6170
6464
  });
6171
6465
  }
@@ -6174,7 +6468,7 @@ function requireBundle(lowered) {
6174
6468
  async function openReplayer(project, lowered, isolate) {
6175
6469
  if (project.config.language === "py") {
6176
6470
  if (!lowered.buildId || durableExportNames(lowered).length === 0) {
6177
- throw new CliUserError32("The project defines no durable functions to replay.", {
6471
+ throw new CliUserError33("The project defines no durable functions to replay.", {
6178
6472
  hint: "Durable functions are `@workflow` functions in workflows/*.py."
6179
6473
  });
6180
6474
  }
@@ -6188,7 +6482,7 @@ async function openReplayer(project, lowered, isolate) {
6188
6482
  }
6189
6483
  function requireExport(file, exported, name) {
6190
6484
  if (!exported.includes(file.workflowFn)) {
6191
- throw new CliUserError32(`${name} runs ${file.workflowFn}, which this project does not export.`, {
6485
+ throw new CliUserError33(`${name} runs ${file.workflowFn}, which this project does not export.`, {
6192
6486
  hint: `Exported durable functions: ${exported.join(", ")}`
6193
6487
  });
6194
6488
  }
@@ -6211,11 +6505,11 @@ async function runReplay(env, target, options) {
6211
6505
  const path = resolve8(env.cwd(), target);
6212
6506
  let file;
6213
6507
  let name;
6214
- if (existsSync11(path) && statSync4(path).isFile()) {
6215
- file = parseHistoryText(readFileSync10(path, "utf8"), target);
6508
+ if (existsSync12(path) && statSync4(path).isFile()) {
6509
+ file = readHistoryFromDisk(path, target);
6216
6510
  name = target;
6217
- } else if (/[\\/]|\.json$/.test(target)) {
6218
- throw new CliUserError32(`History file not found: ${target}`);
6511
+ } else if (looksLikeHistoryPath(target)) {
6512
+ throw new CliUserError33(`History file not found: ${target}`);
6219
6513
  } else {
6220
6514
  file = (await fetchHistory(env, target)).file;
6221
6515
  name = target;
@@ -6225,7 +6519,7 @@ async function runReplay(env, target, options) {
6225
6519
  requireBundle(lowered);
6226
6520
  requireExport(file, durableExportNames(lowered), name);
6227
6521
  if (file.replay === false) {
6228
- throw new CliUserError32(`${name} is marked "replay": false (it uses Phase C features).`);
6522
+ throw new CliUserError33(`${name} is marked "replay": false (it uses Phase C features).`);
6229
6523
  }
6230
6524
  const { replayer, buildId } = await openReplayer(project, lowered, options.isolate);
6231
6525
  let outcome;
@@ -6255,7 +6549,7 @@ async function runReplay(env, target, options) {
6255
6549
  ]
6256
6550
  }, details);
6257
6551
  if (!outcome.ok) {
6258
- throw new CliUserError32(outcome.cause === "NON_DETERMINISM" ? `The local code does not replay ${name}: determinism violation.` : `Replaying ${name} failed (${outcome.cause ?? "INTERNAL"}).`, { hint: describeOutcome(outcome) });
6552
+ throw new CliUserError33(outcome.cause === "NON_DETERMINISM" ? `The local code does not replay ${name}: determinism violation.` : `Replaying ${name} failed (${outcome.cause ?? "INTERNAL"}).`, { hint: describeOutcome(outcome) });
6259
6553
  }
6260
6554
  return outcome;
6261
6555
  }
@@ -6263,7 +6557,7 @@ function historyFiles(dir) {
6263
6557
  const out = [];
6264
6558
  const walk = (current) => {
6265
6559
  for (const entry of readdirSync2(current, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
6266
- const full = join10(current, entry.name);
6560
+ const full = join11(current, entry.name);
6267
6561
  if (entry.isDirectory()) {
6268
6562
  if (entry.name !== "node_modules" && !entry.name.startsWith("."))
6269
6563
  walk(full);
@@ -6276,23 +6570,23 @@ function historyFiles(dir) {
6276
6570
  return out;
6277
6571
  }
6278
6572
  function testScript(root) {
6279
- const manifestPath = join10(root, "package.json");
6280
- if (!existsSync11(manifestPath))
6573
+ const manifestPath = join11(root, "package.json");
6574
+ if (!existsSync12(manifestPath))
6281
6575
  return null;
6282
6576
  let manifest;
6283
6577
  try {
6284
- manifest = JSON.parse(readFileSync10(manifestPath, "utf8"));
6578
+ manifest = JSON.parse(readFileSync11(manifestPath, "utf8"));
6285
6579
  } catch {
6286
- throw new CliUserError32("package.json is not valid JSON.");
6580
+ throw new CliUserError33("package.json is not valid JSON.");
6287
6581
  }
6288
- const scripts = isRecord17(manifest) ? manifest["scripts"] : undefined;
6289
- if (!isRecord17(scripts) || typeof scripts["test"] !== "string")
6582
+ const scripts = isRecord18(manifest) ? manifest["scripts"] : undefined;
6583
+ if (!isRecord18(scripts) || typeof scripts["test"] !== "string")
6290
6584
  return null;
6291
- const runner = existsSync11(join10(root, "bun.lock")) || existsSync11(join10(root, "bun.lockb")) ? "bun" : "npm";
6585
+ const runner = existsSync12(join11(root, "bun.lock")) || existsSync12(join11(root, "bun.lockb")) ? "bun" : "npm";
6292
6586
  return { command: runner, args: ["run", "test"] };
6293
6587
  }
6294
6588
  function pythonTestScript(project) {
6295
- if (!existsSync11(join10(project.root, "tests")))
6589
+ if (!existsSync12(join11(project.root, "tests")))
6296
6590
  return null;
6297
6591
  return {
6298
6592
  command: resolvePythonInterpreter(project.root, project.config.python),
@@ -6309,7 +6603,7 @@ async function runTest(env, options) {
6309
6603
  const exitCode = await env.exec(script.command, script.args, project.root);
6310
6604
  result.script = { command: `${script.command} ${script.args.join(" ")}`, exitCode };
6311
6605
  if (exitCode !== 0) {
6312
- throw new CliUserError32(`The project tests failed (\`${result.script.command}\` exited ${exitCode}).`);
6606
+ throw new CliUserError33(`The project tests failed (\`${result.script.command}\` exited ${exitCode}).`);
6313
6607
  }
6314
6608
  } else {
6315
6609
  details.push(project.config.language === "py" ? "No tests/ directory; skipped." : 'No "test" script in package.json; skipped.');
@@ -6318,12 +6612,12 @@ async function runTest(env, options) {
6318
6612
  const outcomes = [];
6319
6613
  if (options.replay !== undefined) {
6320
6614
  const dir = resolve8(env.cwd(), options.replay);
6321
- if (!existsSync11(dir) || !statSync4(dir).isDirectory()) {
6322
- throw new CliUserError32(`--replay: ${options.replay} is not a directory.`);
6615
+ if (!existsSync12(dir) || !statSync4(dir).isDirectory()) {
6616
+ throw new CliUserError33(`--replay: ${options.replay} is not a directory.`);
6323
6617
  }
6324
6618
  const files = historyFiles(dir);
6325
6619
  if (files.length === 0) {
6326
- throw new CliUserError32(`--replay: no *.history.json files under ${options.replay}.`);
6620
+ throw new CliUserError33(`--replay: no *.history.json files under ${options.replay}.`);
6327
6621
  }
6328
6622
  const lowered = await lowerOffline(project);
6329
6623
  const exported = durableExportNames(lowered);
@@ -6331,7 +6625,7 @@ async function runTest(env, options) {
6331
6625
  try {
6332
6626
  for (const path of files) {
6333
6627
  const name = relative3(env.cwd(), path).split(sep3).join("/");
6334
- const file = parseHistoryText(readFileSync10(path, "utf8"), name);
6628
+ const file = parseHistoryText(readFileSync11(path, "utf8"), name);
6335
6629
  if (file.replay === false) {
6336
6630
  details.push(`${name}: skipped ("replay": false)`);
6337
6631
  continue;
@@ -6356,7 +6650,7 @@ async function runTest(env, options) {
6356
6650
  }, details);
6357
6651
  const failed = outcomes.filter((outcome) => !outcome.ok);
6358
6652
  if (failed.length > 0) {
6359
- throw new CliUserError32(`${failed.length} of ${outcomes.length} histories failed to replay.`, {
6653
+ throw new CliUserError33(`${failed.length} of ${outcomes.length} histories failed to replay.`, {
6360
6654
  hint: failed.map(describeOutcome).join(`
6361
6655
  `)
6362
6656
  });
@@ -6364,6 +6658,7 @@ async function runTest(env, options) {
6364
6658
  return result;
6365
6659
  }
6366
6660
  var init_replay2 = __esm(() => {
6661
+ init_archive_file();
6367
6662
  init_connections();
6368
6663
  init_history();
6369
6664
  init_lowering();
@@ -6380,10 +6675,10 @@ function breakAtMismatch() {
6380
6675
  }
6381
6676
 
6382
6677
  // src/phase-d/commands/replay-debug.ts
6383
- import { existsSync as existsSync12, readFileSync as readFileSync11, statSync as statSync5 } from "fs";
6678
+ import { existsSync as existsSync13, statSync as statSync5 } from "fs";
6384
6679
  import { resolve as resolve9 } from "path";
6385
6680
  import { pathToFileURL } from "url";
6386
- import { CliUserError as CliUserError33 } from "@burdenoff/cli-sdk/core";
6681
+ import { CliUserError as CliUserError34 } from "@burdenoff/cli-sdk/core";
6387
6682
  import { SDK_VERSION as SDK_VERSION4 } from "@fluidgrids/workflows";
6388
6683
  import {
6389
6684
  buildDebugScript,
@@ -6408,10 +6703,10 @@ function inspectAddress(raw) {
6408
6703
  const host = portOnly ? "127.0.0.1" : value.slice(0, at);
6409
6704
  const port = portOnly ? value : value.slice(at + 1);
6410
6705
  if (!portOnly && at <= 0 || !/^\d{1,5}$/.test(port) || Number(port) > 65535) {
6411
- throw new CliUserError33(`Invalid value '${value}' for --inspect: expected host:port or a port, such as ${DEFAULT_INSPECT_ADDRESS}.`, { hint: "Give the history or run id before --inspect, or write --inspect=<host:port>." });
6706
+ throw new CliUserError34(`Invalid value '${value}' for --inspect: expected host:port or a port, such as ${DEFAULT_INSPECT_ADDRESS}.`, { hint: "Give the history or run id before --inspect, or write --inspect=<host:port>." });
6412
6707
  }
6413
6708
  if (!LOOPBACK.has(host)) {
6414
- throw new CliUserError33(`--inspect listens on loopback only; ${host} is not.`, {
6709
+ throw new CliUserError34(`--inspect listens on loopback only; ${host} is not.`, {
6415
6710
  hint: "An inspector on another interface lets anyone who reaches it run code as you."
6416
6711
  });
6417
6712
  }
@@ -6454,24 +6749,24 @@ function inspectMatches(raw, address) {
6454
6749
  async function reexecUnderInspector(env, options, facts) {
6455
6750
  const address = inspectAddress(options.inspect ?? true);
6456
6751
  if (!facts.node) {
6457
- throw new CliUserError33("--inspect needs the CLI to run on Node.", {
6752
+ throw new CliUserError34("--inspect needs the CLI to run on Node.", {
6458
6753
  hint: "Run it as `node <path to fluidgrids>/dist/cli.js replay … --inspect`."
6459
6754
  });
6460
6755
  }
6461
6756
  const script = facts.argv[1];
6462
6757
  if (script === undefined)
6463
- throw new CliUserError33("--inspect: the CLI script path is unknown.");
6758
+ throw new CliUserError34("--inspect: the CLI script path is unknown.");
6464
6759
  console.error(`Debugger listening on ${address}; attach to continue (the replay stops at the mismatch).`);
6465
6760
  const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...childArgs(facts.argv, address)], env.cwd(), { stdout: "inherit" });
6466
6761
  throw new DelegatedExit(status);
6467
6762
  }
6468
6763
  async function loadHistory(env, target) {
6469
6764
  const path = resolve9(env.cwd(), target);
6470
- if (existsSync12(path) && statSync5(path).isFile()) {
6471
- return { file: parseHistoryText(readFileSync11(path, "utf8"), target), name: target };
6765
+ if (existsSync13(path) && statSync5(path).isFile()) {
6766
+ return { file: readHistoryFromDisk(path, target), name: target };
6472
6767
  }
6473
- if (/[\\/]|\.json$/.test(target))
6474
- throw new CliUserError33(`History file not found: ${target}`);
6768
+ if (looksLikeHistoryPath(target))
6769
+ throw new CliUserError34(`History file not found: ${target}`);
6475
6770
  return { file: (await fetchHistory(env, target)).file, name: target };
6476
6771
  }
6477
6772
  async function remoteScript(env, file, name) {
@@ -6479,17 +6774,17 @@ async function remoteScript(env, file, name) {
6479
6774
  const version = file.info?.version;
6480
6775
  const buildId = file.info?.buildId;
6481
6776
  if (!key || version === undefined || version === "" || !buildId) {
6482
- throw new CliUserError33(`${name} does not say which workflow version and build it ran (info.workflowKey, info.version, info.buildId).`, { hint: "Replay a run id, or a history file from `fluidgrids history <runId> --out`." });
6777
+ throw new CliUserError34(`${name} does not say which workflow version and build it ran (info.workflowKey, info.version, info.buildId).`, { hint: "Replay a run id, or a history file from `fluidgrids history <runId> --out`." });
6483
6778
  }
6484
6779
  const archive = await env.pd.workflowCodeArchive(key, String(version));
6485
6780
  if (archive === null) {
6486
- throw new CliUserError33(`${key} ${String(version)} has no stored source archive.`);
6781
+ throw new CliUserError34(`${key} ${String(version)} has no stored source archive.`);
6487
6782
  }
6488
6783
  if (archive.buildId !== buildId) {
6489
6784
  throw new CliDiagnosticsError(`The stored archive of ${key} ${String(version)} builds ${archive.buildId}, but the run used ${buildId}; the debugger only debugs the exact code that ran.`, "debug.buildIdMismatch", []);
6490
6785
  }
6491
6786
  if (archive.sdkVersion !== SDK_VERSION4) {
6492
- throw new CliUserError33(`The run was built with @fluidgrids/workflows ${archive.sdkVersion}; this CLI has ${SDK_VERSION4}.`, {
6787
+ throw new CliUserError34(`The run was built with @fluidgrids/workflows ${archive.sdkVersion}; this CLI has ${SDK_VERSION4}.`, {
6493
6788
  hint: `Use a CLI release that bundles @fluidgrids/workflows ${archive.sdkVersion} to rebuild the exact bundle.`
6494
6789
  });
6495
6790
  }
@@ -6499,17 +6794,17 @@ async function remoteScript(env, file, name) {
6499
6794
  try {
6500
6795
  response = await env.fetch(archive.url, { method: "GET" });
6501
6796
  } catch (error) {
6502
- throw new CliUserError33(`Fetching the source archive failed: ${describeError(error)}`);
6797
+ throw new CliUserError34(`Fetching the source archive failed: ${describeError(error)}`);
6503
6798
  }
6504
6799
  if (!response.ok) {
6505
- throw new CliUserError33(`Fetching the source archive failed with HTTP ${response.status}.`);
6800
+ throw new CliUserError34(`Fetching the source archive failed with HTTP ${response.status}.`);
6506
6801
  }
6507
- const bytes = await readCapped(response, MAX_SOURCE_ARCHIVE_BYTES, () => new CliUserError33(`The source archive is larger than ${MAX_SOURCE_ARCHIVE_BYTES} bytes; refusing to read it.`));
6802
+ const bytes = await readCapped(response, MAX_SOURCE_ARCHIVE_BYTES, () => new CliUserError34(`The source archive is larger than ${MAX_SOURCE_ARCHIVE_BYTES} bytes; refusing to read it.`));
6508
6803
  let sources;
6509
6804
  try {
6510
6805
  sources = unpackSources(bytes, { maxBytes: MAX_SOURCE_ARCHIVE_BYTES });
6511
6806
  } catch (error) {
6512
- throw new CliUserError33(`The source archive could not be read: ${describeError(error)}`);
6807
+ throw new CliUserError34(`The source archive could not be read: ${describeError(error)}`);
6513
6808
  }
6514
6809
  try {
6515
6810
  return await buildDebugScript(new Map(Object.entries(sources.files)), {
@@ -6521,13 +6816,13 @@ async function remoteScript(env, file, name) {
6521
6816
  if (error instanceof DebugBuildMismatchError) {
6522
6817
  throw new CliDiagnosticsError(error.message, error.code, []);
6523
6818
  }
6524
- throw new CliUserError33(`Rebuilding the run's code failed: ${describeError(error)}`);
6819
+ throw new CliUserError34(`Rebuilding the run's code failed: ${describeError(error)}`);
6525
6820
  }
6526
6821
  }
6527
6822
  async function localScript(env, options, file, name) {
6528
6823
  const project = loadProject(options.project, env.cwd());
6529
6824
  if (project.config.language === "py") {
6530
- throw new CliUserError33("The replay debugger needs a TypeScript project.", {
6825
+ throw new CliUserError34("The replay debugger needs a TypeScript project.", {
6531
6826
  hint: "Python projects replay with plain `fluidgrids replay` (no --trace or --break-on-mismatch)."
6532
6827
  });
6533
6828
  }
@@ -6538,12 +6833,12 @@ async function localScript(env, options, file, name) {
6538
6833
  });
6539
6834
  const exported = durableExportNames(lowered);
6540
6835
  if (!lowered.sourceFiles || exported.length === 0) {
6541
- throw new CliUserError33("The project defines no durable functions to replay.", {
6836
+ throw new CliUserError34("The project defines no durable functions to replay.", {
6542
6837
  hint: "Durable functions are `workflow()` exports in workflows/*.ts."
6543
6838
  });
6544
6839
  }
6545
6840
  if (!exported.includes(file.workflowFn)) {
6546
- throw new CliUserError33(`${name} runs ${file.workflowFn}, which this project does not export.`, {
6841
+ throw new CliUserError34(`${name} runs ${file.workflowFn}, which this project does not export.`, {
6547
6842
  hint: `Exported durable functions: ${exported.join(", ")}`
6548
6843
  });
6549
6844
  }
@@ -6554,7 +6849,7 @@ async function localScript(env, options, file, name) {
6554
6849
  sourceRoot: `${pathToFileURL(project.root).href}/`
6555
6850
  });
6556
6851
  } catch (error) {
6557
- throw new CliUserError33(`Building the debug script failed: ${describeError(error)}`);
6852
+ throw new CliUserError34(`Building the debug script failed: ${describeError(error)}`);
6558
6853
  }
6559
6854
  }
6560
6855
  function where(location) {
@@ -6575,13 +6870,13 @@ function failureDiagnostics(result) {
6575
6870
  }
6576
6871
  async function runDebugReplay(env, target, options, facts = currentProcess()) {
6577
6872
  if (options.isolate) {
6578
- throw new CliUserError33("--isolate does not combine with --trace, --break-on-mismatch, --inspect or --remote-code.", { hint: "The replay debugger runs in a Node vm; replay without them to use the isolate." });
6873
+ throw new CliUserError34("--isolate does not combine with --trace, --break-on-mismatch, --inspect or --remote-code.", { hint: "The replay debugger runs in a Node vm; replay without them to use the isolate." });
6579
6874
  }
6580
6875
  if (options.inspect !== undefined)
6581
6876
  return reexecUnderInspector(env, options, facts);
6582
6877
  const { file, name } = await loadHistory(env, target);
6583
6878
  if (file.replay === false) {
6584
- throw new CliUserError33(`${name} is marked "replay": false (it uses Phase C features).`);
6879
+ throw new CliUserError34(`${name} is marked "replay": false (it uses Phase C features).`);
6585
6880
  }
6586
6881
  const remote = options.remoteCode === true;
6587
6882
  const script = remote ? await remoteScript(env, file, name) : await localScript(env, options, file, name);
@@ -6638,6 +6933,7 @@ var init_replay_debug = __esm(() => {
6638
6933
  init_code_upload();
6639
6934
  init_replay2();
6640
6935
  init_connections();
6936
+ init_archive_file();
6641
6937
  init_history();
6642
6938
  init_lowering();
6643
6939
  init_presigned();
@@ -6778,7 +7074,7 @@ var REPLACEMENT_CHARACTER = "�";
6778
7074
  // src/code-first/commands/suite.ts
6779
7075
  import { writeFileSync as writeFileSync7 } from "fs";
6780
7076
  import { resolve as resolve10 } from "path";
6781
- import { CliAuthError as CliAuthError5, CliUserError as CliUserError34 } from "@burdenoff/cli-sdk/core";
7077
+ import { CliAuthError as CliAuthError5, CliUserError as CliUserError35 } from "@burdenoff/cli-sdk/core";
6782
7078
  function testSuiteOptions(options) {
6783
7079
  const misplaced = [
6784
7080
  options.replay !== undefined ? "--replay" : null,
@@ -6787,7 +7083,7 @@ function testSuiteOptions(options) {
6787
7083
  options.project !== undefined ? "--project" : null
6788
7084
  ].filter((flag) => flag !== null);
6789
7085
  if (misplaced.length > 0) {
6790
- throw new CliUserError34(`${misplaced.join(", ")} ${misplaced.length === 1 ? "applies" : "apply"} to the code-first tests, not to a workflow's test suite.`, { hint: "Run `fluidgrids test` without a workflow key in a code-first project for those." });
7086
+ throw new CliUserError35(`${misplaced.join(", ")} ${misplaced.length === 1 ? "applies" : "apply"} to the code-first tests, not to a workflow's test suite.`, { hint: "Run `fluidgrids test` without a workflow key in a code-first project for those." });
6791
7087
  }
6792
7088
  return {
6793
7089
  ...options.format !== undefined ? { format: options.format } : {},
@@ -6807,7 +7103,7 @@ function codeFirstTestOptions(options) {
6807
7103
  options.pollInterval !== undefined ? "--poll-interval" : null
6808
7104
  ].filter((flag) => flag !== null);
6809
7105
  if (misplaced.length > 0) {
6810
- throw new CliUserError34(`${misplaced.join(", ")} ${misplaced.length === 1 ? "needs" : "need"} a workflow key: \`fluidgrids test <workflowKey>\`.`);
7106
+ throw new CliUserError35(`${misplaced.join(", ")} ${misplaced.length === 1 ? "needs" : "need"} a workflow key: \`fluidgrids test <workflowKey>\`.`);
6811
7107
  }
6812
7108
  return {
6813
7109
  ...options.format !== undefined ? { format: options.format } : {},
@@ -6822,7 +7118,7 @@ function caseIds(raw) {
6822
7118
  return;
6823
7119
  const ids = [...new Set(raw.map((id) => id.trim()))];
6824
7120
  if (ids.some((id) => id === ""))
6825
- throw new CliUserError34("--case needs a test case id.");
7121
+ throw new CliUserError35("--case needs a test case id.");
6826
7122
  return ids;
6827
7123
  }
6828
7124
  function finished(suite) {
@@ -6850,7 +7146,7 @@ async function waitForSuite(env, started, timeoutMs, intervalMs) {
6850
7146
  continue;
6851
7147
  }
6852
7148
  if (!next) {
6853
- throw new CliUserError34(`Suite run ${suite.id} is no longer visible (NOT_FOUND).`);
7149
+ throw new CliUserError35(`Suite run ${suite.id} is no longer visible (NOT_FOUND).`);
6854
7150
  }
6855
7151
  suite = next;
6856
7152
  if (finished(suite) !== reported) {
@@ -6885,7 +7181,7 @@ function detailLines(suite, timedOut, junit) {
6885
7181
  async function runTestSuite(env, workflowKey, options) {
6886
7182
  const key = workflowKey.trim();
6887
7183
  if (key === "")
6888
- throw new CliUserError34("The workflow key is empty.");
7184
+ throw new CliUserError35("The workflow key is empty.");
6889
7185
  const timeoutMs = parsePositiveInt(options.timeout, "--timeout") ?? DEFAULT_SUITE_TIMEOUT_MS;
6890
7186
  const intervalMs = parsePositiveInt(options.pollInterval, "--poll-interval") ?? DEFAULT_SUITE_POLL_INTERVAL_MS;
6891
7187
  const ids = caseIds(options.case);
@@ -6904,7 +7200,7 @@ async function runTestSuite(env, workflowKey, options) {
6904
7200
  try {
6905
7201
  writeFileSync7(path, suiteToJUnit(suite), "utf8");
6906
7202
  } catch (error) {
6907
- throw new CliUserError34(`Could not write the JUnit report to ${options.junit}: ${error instanceof Error ? error.message : String(error)}`);
7203
+ throw new CliUserError35(`Could not write the JUnit report to ${options.junit}: ${error instanceof Error ? error.message : String(error)}`);
6908
7204
  }
6909
7205
  result.junit = options.junit;
6910
7206
  }
@@ -6918,16 +7214,16 @@ async function runTestSuite(env, workflowKey, options) {
6918
7214
  ])
6919
7215
  }, detailLines(suite, timedOut, result.junit));
6920
7216
  if (timedOut) {
6921
- throw new CliUserError34(`Suite ${suite.id} was still ${suite.status} after ${timeoutMs} ms (${finished(suite)}/${suite.summary.total} cases finished).`, {
7217
+ throw new CliUserError35(`Suite ${suite.id} was still ${suite.status} after ${timeoutMs} ms (${finished(suite)}/${suite.summary.total} cases finished).`, {
6922
7218
  exitCode: SUITE_TIMEOUT_EXIT_CODE,
6923
7219
  hint: "It keeps running on the service. Raise --timeout to wait longer."
6924
7220
  });
6925
7221
  }
6926
7222
  if (suite.status === "FAILED") {
6927
- throw new CliUserError34(`${suite.summary.failed} of ${suite.summary.total} test cases of ${suite.workflowKey} failed.`);
7223
+ throw new CliUserError35(`${suite.summary.failed} of ${suite.summary.total} test cases of ${suite.workflowKey} failed.`);
6928
7224
  }
6929
7225
  if (suite.status === "ERROR") {
6930
- throw new CliUserError34(`${suite.summary.errored} of ${suite.summary.total} test cases of ${suite.workflowKey} could not run.`);
7226
+ throw new CliUserError35(`${suite.summary.errored} of ${suite.summary.total} test cases of ${suite.workflowKey} could not run.`);
6931
7227
  }
6932
7228
  return result;
6933
7229
  }
@@ -6940,7 +7236,7 @@ var init_suite = __esm(() => {
6940
7236
 
6941
7237
  // src/code-first/commands/versions.ts
6942
7238
  import { createInterface as createInterface2 } from "readline/promises";
6943
- import { CliUserError as CliUserError35 } from "@burdenoff/cli-sdk/core";
7239
+ import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
6944
7240
  async function runVersionsList(env, workflowKey, options) {
6945
7241
  const versions = sortVersions(await env.api.workflowVersions(workflowKey));
6946
7242
  const rows = [];
@@ -6980,7 +7276,7 @@ function checkLine(check, what) {
6980
7276
  }
6981
7277
  function parsePercent(raw) {
6982
7278
  if (raw === undefined || !/^\d{1,3}$/.test(raw.trim()) || Number(raw) > 100) {
6983
- throw new CliUserError35(`Invalid value '${raw ?? ""}' for --percent: expected 0 to 100.`);
7279
+ throw new CliUserError36(`Invalid value '${raw ?? ""}' for --percent: expected 0 to 100.`);
6984
7280
  }
6985
7281
  return Number(raw.trim());
6986
7282
  }
@@ -6992,7 +7288,7 @@ async function runRollout(env, workflowKey, options) {
6992
7288
  return rollouts;
6993
7289
  }
6994
7290
  if (options.to === undefined || options.to.trim() === "") {
6995
- throw new CliUserError35("--percent needs --to <version>.");
7291
+ throw new CliUserError36("--percent needs --to <version>.");
6996
7292
  }
6997
7293
  const input = {
6998
7294
  toVersion: options.to,
@@ -7014,14 +7310,14 @@ async function runRollout(env, workflowKey, options) {
7014
7310
  function rolloutDeleteOptions(options, parent) {
7015
7311
  for (const flag of ["to", "percent", "from"]) {
7016
7312
  if (parent[flag] !== undefined) {
7017
- throw new CliUserError35(`--${flag} does not apply to \`versions rollout delete\`.`);
7313
+ throw new CliUserError36(`--${flag} does not apply to \`versions rollout delete\`.`);
7018
7314
  }
7019
7315
  }
7020
7316
  const inherited = parent["environment"];
7021
7317
  if (typeof inherited !== "string")
7022
7318
  return options;
7023
7319
  if (options.environment !== undefined && options.environment !== inherited) {
7024
- throw new CliUserError35(`Conflicting --environment values '${inherited}' and '${options.environment}'.`);
7320
+ throw new CliUserError36(`Conflicting --environment values '${inherited}' and '${options.environment}'.`);
7025
7321
  }
7026
7322
  return { ...options, environment: inherited };
7027
7323
  }
@@ -7038,12 +7334,12 @@ async function runRolloutDelete(env, workflowKey, options) {
7038
7334
  const environment = parseChoice(options.environment?.toUpperCase(), "--environment", ENVIRONMENTS);
7039
7335
  if (!options.force) {
7040
7336
  if (!env.interactive()) {
7041
- throw new CliUserError35(`Removing the rollout of ${workflowKey} needs confirmation.`, {
7337
+ throw new CliUserError36(`Removing the rollout of ${workflowKey} needs confirmation.`, {
7042
7338
  hint: "Pass --force to remove it without a prompt."
7043
7339
  });
7044
7340
  }
7045
7341
  if (!await confirm2(`Remove the rollout of ${workflowKey}? New starts run the ACTIVE version.`)) {
7046
- throw new CliUserError35("Aborted: nothing was changed.");
7342
+ throw new CliUserError36("Aborted: nothing was changed.");
7047
7343
  }
7048
7344
  }
7049
7345
  const removed = await env.api.deleteWorkflowRollout(workflowKey, environment);
@@ -7069,12 +7365,12 @@ async function runDrainage(env, workflowKey, version, options) {
7069
7365
  async function runOverride(env, runId, options) {
7070
7366
  const chosen = [options.pin !== undefined, options.autoUpgrade === true, options.clear === true];
7071
7367
  if (chosen.filter(Boolean).length !== 1) {
7072
- throw new CliUserError35("Give exactly one of --pin <version>, --auto-upgrade or --clear.");
7368
+ throw new CliUserError36("Give exactly one of --pin <version>, --auto-upgrade or --clear.");
7073
7369
  }
7074
7370
  let override = null;
7075
7371
  if (options.pin !== undefined) {
7076
7372
  if (options.pin.trim() === "")
7077
- throw new CliUserError35("--pin needs a version.");
7373
+ throw new CliUserError36("--pin needs a version.");
7078
7374
  override = { behavior: "PINNED", version: options.pin };
7079
7375
  } else if (options.autoUpgrade) {
7080
7376
  override = { behavior: "AUTO_UPGRADE" };
@@ -7103,12 +7399,12 @@ var init_versions = __esm(() => {
7103
7399
  });
7104
7400
 
7105
7401
  // src/code-first/commands/deploy.ts
7106
- import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
7402
+ import { CliUserError as CliUserError37 } from "@burdenoff/cli-sdk/core";
7107
7403
  function parseEnvironment(raw) {
7108
7404
  const value = raw?.trim().toUpperCase();
7109
7405
  const match = ENVIRONMENTS2.find((environment) => environment === value);
7110
7406
  if (match === undefined) {
7111
- throw new CliUserError36(raw === undefined ? "deploy needs --env dev, staging or prod." : `Invalid value '${raw}' for --env. Allowed: dev, staging, prod`);
7407
+ throw new CliUserError37(raw === undefined ? "deploy needs --env dev, staging or prod." : `Invalid value '${raw}' for --env. Allowed: dev, staging, prod`);
7112
7408
  }
7113
7409
  return match;
7114
7410
  }
@@ -7117,7 +7413,7 @@ function parseRamp(raw) {
7117
7413
  return;
7118
7414
  const trimmed = raw.trim();
7119
7415
  if (!/^\d{1,3}$/.test(trimmed) || Number(trimmed) > 100) {
7120
- throw new CliUserError36(`Invalid value '${raw}' for --ramp: expected 0 to 100.`);
7416
+ throw new CliUserError37(`Invalid value '${raw}' for --ramp: expected 0 to 100.`);
7121
7417
  }
7122
7418
  return Number(trimmed);
7123
7419
  }
@@ -7167,10 +7463,10 @@ async function runDeploy(env, workflowKey, options) {
7167
7463
  const environment = parseEnvironment(options.env);
7168
7464
  const ramp = parseRamp(options.ramp);
7169
7465
  if (ramp !== undefined && environment !== "PROD") {
7170
- throw new CliUserError36("--ramp applies to --env prod only (rollouts split PROD starts).");
7466
+ throw new CliUserError37("--ramp applies to --env prod only (rollouts split PROD starts).");
7171
7467
  }
7172
7468
  if (options.note !== undefined && environment === "DEV") {
7173
- throw new CliUserError36("--note is for promotion requests (--env staging or prod).");
7469
+ throw new CliUserError37("--note is for promotion requests (--env staging or prod).");
7174
7470
  }
7175
7471
  const timeoutMs = parsePositiveInt(options.timeout, "--timeout") ?? DEFAULT_DEPLOY_TIMEOUT_MS;
7176
7472
  const intervalMs = parsePositiveInt(options.pollInterval, "--poll-interval") ?? DEFAULT_DEPLOY_POLL_INTERVAL_MS;
@@ -7188,7 +7484,7 @@ async function deployToDev(env, workflowKey, options) {
7188
7484
  const versions = await env.api.workflowVersions(workflowKey);
7189
7485
  const picked = pickVersion(versions, wanted);
7190
7486
  if (!picked) {
7191
- throw new CliUserError36(versions.length === 0 ? `${workflowKey} has no stored version.` : `${workflowKey} has no version ${wanted}.`, versions.length === 0 ? { hint: "Push one first: fluidgrids push " + workflowKey } : { hint: `Stored: ${versions.map((version) => version.version).join(", ")}` });
7487
+ throw new CliUserError37(versions.length === 0 ? `${workflowKey} has no stored version.` : `${workflowKey} has no version ${wanted}.`, versions.length === 0 ? { hint: "Push one first: fluidgrids push " + workflowKey } : { hint: `Stored: ${versions.map((version) => version.version).join(", ")}` });
7192
7488
  }
7193
7489
  const before = await env.api.workflowEnvironments(workflowKey);
7194
7490
  const base = { workflowKey, environment: "DEV", version: picked.version };
@@ -7210,15 +7506,15 @@ async function promote(env, workflowKey, target, options) {
7210
7506
  const view = await env.api.workflowEnvironments(workflowKey);
7211
7507
  const source = stateOf(view, sourceName);
7212
7508
  if (!source?.version) {
7213
- throw new CliUserError36(`Nothing is deployed to ${sourceName} for ${workflowKey}.`, {
7509
+ throw new CliUserError37(`Nothing is deployed to ${sourceName} for ${workflowKey}.`, {
7214
7510
  hint: `Deploy there first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()}${sourceName === "DEV" ? " --wf-version <version>" : ""}`
7215
7511
  });
7216
7512
  }
7217
7513
  if (!source.available) {
7218
- throw new CliUserError36(`${sourceName} holds ${source.version} of ${workflowKey}, which has since been deleted.`, { hint: `Deploy another version to ${sourceName} first.` });
7514
+ throw new CliUserError37(`${sourceName} holds ${source.version} of ${workflowKey}, which has since been deleted.`, { hint: `Deploy another version to ${sourceName} first.` });
7219
7515
  }
7220
7516
  if (options.wfVersion !== undefined && options.wfVersion !== source.version) {
7221
- throw new CliUserError36(`${sourceName} holds ${source.version} of ${workflowKey}, not ${options.wfVersion}; ${target} is promoted from ${sourceName}.`, {
7517
+ throw new CliUserError37(`${sourceName} holds ${source.version} of ${workflowKey}, not ${options.wfVersion}; ${target} is promoted from ${sourceName}.`, {
7222
7518
  hint: `Deploy ${options.wfVersion} to ${sourceName} first: fluidgrids deploy ${workflowKey} --env ${sourceName.toLowerCase()} --wf-version ${options.wfVersion}`
7223
7519
  });
7224
7520
  }
@@ -7231,7 +7527,7 @@ async function promote(env, workflowKey, target, options) {
7231
7527
  }
7232
7528
  if (options.ramp !== undefined && options.ramp < 100) {
7233
7529
  if (view.policy.lockDirectActivation) {
7234
- throw new CliUserError36(`The workspace locks PROD to approved promotions, so ${workflowKey} cannot be ramped.`, { hint: `Promote it in full instead: fluidgrids deploy ${workflowKey} --env prod` });
7530
+ throw new CliUserError37(`The workspace locks PROD to approved promotions, so ${workflowKey} cannot be ramped.`, { hint: `Promote it in full instead: fluidgrids deploy ${workflowKey} --env prod` });
7235
7531
  }
7236
7532
  const rollout = await env.api.setWorkflowRollout(workflowKey, {
7237
7533
  toVersion: version,
@@ -7249,7 +7545,7 @@ async function promote(env, workflowKey, target, options) {
7249
7545
  }
7250
7546
  const pending = view.pendingPromotions.find((request) => request.toEnvironment === target);
7251
7547
  if (pending && pending.version !== version) {
7252
- throw new CliUserError36(`A promotion of ${pending.version} to ${target} (request ${pending.id}) is already waiting for an approver.`, { hint: "An approver decides it, or its requester cancels it, before another can be made." });
7548
+ throw new CliUserError37(`A promotion of ${pending.version} to ${target} (request ${pending.id}) is already waiting for an approver.`, { hint: "An approver decides it, or its requester cancels it, before another can be made." });
7253
7549
  }
7254
7550
  if (pending && options.note !== undefined) {
7255
7551
  notice(env, options, "warning", `Request ${pending.id} for ${version} is already open; --note was not added to it.`);
@@ -7275,7 +7571,7 @@ function finish(env, options, base, promotion) {
7275
7571
  ]);
7276
7572
  case "REJECTED":
7277
7573
  case "CANCELED":
7278
- throw new CliUserError36(`The promotion of ${version} of ${workflowKey} to ${environment} was ${promotion.status === "REJECTED" ? "rejected" : "canceled"}${promotion.reviewNote ? `: ${promotion.reviewNote}` : "."}`, { hint: `Request ${promotion.id}; ${environment} is unchanged.` });
7574
+ throw new CliUserError37(`The promotion of ${version} of ${workflowKey} to ${environment} was ${promotion.status === "REJECTED" ? "rejected" : "canceled"}${promotion.reviewNote ? `: ${promotion.reviewNote}` : "."}`, { hint: `Request ${promotion.id}; ${environment} is unchanged.` });
7279
7575
  }
7280
7576
  }
7281
7577
  async function waitForPromotion(env, promotion, options) {
@@ -7284,7 +7580,7 @@ async function waitForPromotion(env, promotion, options) {
7284
7580
  let current = promotion;
7285
7581
  while (current.status === "PENDING") {
7286
7582
  if (slept >= options.timeoutMs || Date.now() >= deadline) {
7287
- throw new CliUserError36(`Promotion ${current.id} of ${current.version} to ${current.toEnvironment} still waits for an approver after ${Math.round(options.timeoutMs / 1000)} s.`, {
7583
+ throw new CliUserError37(`Promotion ${current.id} of ${current.version} to ${current.toEnvironment} still waits for an approver after ${Math.round(options.timeoutMs / 1000)} s.`, {
7288
7584
  hint: "The request stays open; run the same command again to keep waiting, or pass --no-wait."
7289
7585
  });
7290
7586
  }
@@ -7293,7 +7589,7 @@ async function waitForPromotion(env, promotion, options) {
7293
7589
  const history = await env.api.promotionRequests(current.workflowKey, PROMOTION_HISTORY_LIMIT);
7294
7590
  const found = history.find((request) => request.id === current.id);
7295
7591
  if (!found) {
7296
- throw new CliUserError36(`Promotion ${current.id} is no longer in the promotion history of ${current.workflowKey}.`);
7592
+ throw new CliUserError37(`Promotion ${current.id} is no longer in the promotion history of ${current.workflowKey}.`);
7297
7593
  }
7298
7594
  current = found;
7299
7595
  }
@@ -7814,7 +8110,7 @@ var init_operations3 = __esm(() => {
7814
8110
  });
7815
8111
 
7816
8112
  // src/phase-c/api.ts
7817
- import { CliAuthError as CliAuthError6, CliUserError as CliUserError38 } from "@burdenoff/cli-sdk/core";
8113
+ import { CliAuthError as CliAuthError6, CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
7818
8114
  function runVariables(run) {
7819
8115
  return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
7820
8116
  }
@@ -7834,7 +8130,7 @@ function createPhaseCApi(ctx) {
7834
8130
  function context() {
7835
8131
  const workspaceId = ctx.auth.read()?.workspaceId;
7836
8132
  if (!workspaceId) {
7837
- throw new CliUserError38("No workspace is selected.", {
8133
+ throw new CliUserError39("No workspace is selected.", {
7838
8134
  hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
7839
8135
  });
7840
8136
  }
@@ -7967,7 +8263,7 @@ function createPhaseCApi(ctx) {
7967
8263
  });
7968
8264
  const found = data.workflowRunByWorkflowId;
7969
8265
  if (!found) {
7970
- throw new CliUserError38(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
8266
+ throw new CliUserError39(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
7971
8267
  }
7972
8268
  return found.id;
7973
8269
  },
@@ -8102,7 +8398,7 @@ function createPhaseCApi(ctx) {
8102
8398
  if (!pagination?.hasMore || jobs.length === 0)
8103
8399
  return all;
8104
8400
  }
8105
- throw new CliUserError38(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
8401
+ throw new CliUserError39(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
8106
8402
  },
8107
8403
  async describeSchedule(workflowKey, triggerNodeId) {
8108
8404
  const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
@@ -8136,17 +8432,17 @@ var init_api3 = __esm(() => {
8136
8432
  });
8137
8433
 
8138
8434
  // src/phase-c/commands/queues.ts
8139
- import { CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
8435
+ import { CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
8140
8436
  function parseEnvironment2(raw) {
8141
8437
  return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
8142
8438
  }
8143
8439
  function checkQueueName(name) {
8144
8440
  const value = name.trim();
8145
8441
  if (value === "managed") {
8146
- throw new CliUserError39("`managed` is the platform queue; it cannot be created or changed.");
8442
+ throw new CliUserError40("`managed` is the platform queue; it cannot be created or changed.");
8147
8443
  }
8148
8444
  if (!QUEUE_NAME.test(value)) {
8149
- throw new CliUserError39(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
8445
+ throw new CliUserError40(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
8150
8446
  }
8151
8447
  return value;
8152
8448
  }
@@ -8158,7 +8454,7 @@ function checkWorkerQueue(raw) {
8158
8454
  const name = checkQueueName(value.slice(0, at));
8159
8455
  const environment = value.slice(at + 1).toLowerCase();
8160
8456
  if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
8161
- throw new CliUserError39(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
8457
+ throw new CliUserError40(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
8162
8458
  }
8163
8459
  return `${name}@${environment}`;
8164
8460
  }
@@ -8171,7 +8467,7 @@ function bindWorkerQueues(queues, raw) {
8171
8467
  if (at < 0)
8172
8468
  return `${queue}@${environment}`;
8173
8469
  if (queue.slice(at + 1) !== environment) {
8174
- throw new CliUserError39(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
8470
+ throw new CliUserError40(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
8175
8471
  }
8176
8472
  return queue;
8177
8473
  });
@@ -8187,11 +8483,11 @@ async function findQueue(env, name, environment) {
8187
8483
  if (found)
8188
8484
  return found;
8189
8485
  if (environment === undefined && rows.length > 0) {
8190
- throw new CliUserError39(`Queue ${name} has only environment-scoped rows.`, {
8486
+ throw new CliUserError40(`Queue ${name} has only environment-scoped rows.`, {
8191
8487
  hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
8192
8488
  });
8193
8489
  }
8194
- throw new CliUserError39(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
8490
+ throw new CliUserError40(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
8195
8491
  }
8196
8492
  async function runQueuesList(env, options) {
8197
8493
  const queues = await env.pc.taskQueues();
@@ -8252,7 +8548,7 @@ async function runQueuesUpdate(env, name, options) {
8252
8548
  const environment = parseEnvironment2(options.environment);
8253
8549
  const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
8254
8550
  if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
8255
- throw new CliUserError39("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
8551
+ throw new CliUserError40("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
8256
8552
  }
8257
8553
  const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
8258
8554
  const input = {
@@ -8262,7 +8558,7 @@ async function runQueuesUpdate(env, name, options) {
8262
8558
  ...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
8263
8559
  };
8264
8560
  if (Object.keys(input).length === 0) {
8265
- throw new CliUserError39("Nothing to change.", {
8561
+ throw new CliUserError40("Nothing to change.", {
8266
8562
  hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
8267
8563
  });
8268
8564
  }
@@ -8337,12 +8633,12 @@ __export(exports_worker_run, {
8337
8633
  });
8338
8634
  import { spawn as spawn3 } from "child_process";
8339
8635
  import { randomBytes } from "crypto";
8340
- import { existsSync as existsSync13 } from "fs";
8636
+ import { existsSync as existsSync14 } from "fs";
8341
8637
  import { hostname } from "os";
8342
- import { extname as extname3, isAbsolute as isAbsolute3, join as join11, resolve as resolve11 } from "path";
8638
+ import { extname as extname3, isAbsolute as isAbsolute3, join as join12, resolve as resolve11 } from "path";
8343
8639
  import { pathToFileURL as pathToFileURL2 } from "url";
8344
- import { CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
8345
- function isRecord18(value) {
8640
+ import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
8641
+ function isRecord19(value) {
8346
8642
  return typeof value === "object" && value !== null && !Array.isArray(value);
8347
8643
  }
8348
8644
  function bridgeUrlFor(env, explicit, issued) {
@@ -8352,11 +8648,11 @@ function bridgeUrlFor(env, explicit, issued) {
8352
8648
  try {
8353
8649
  url = new URL(raw);
8354
8650
  } catch {
8355
- throw new CliUserError40(`Invalid bridge URL '${raw}'.`);
8651
+ throw new CliUserError41(`Invalid bridge URL '${raw}'.`);
8356
8652
  }
8357
8653
  const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
8358
8654
  if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
8359
- throw new CliUserError40(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
8655
+ throw new CliUserError41(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
8360
8656
  }
8361
8657
  return url.toString();
8362
8658
  }
@@ -8372,18 +8668,18 @@ function bridgeHeaders(env) {
8372
8668
  const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
8373
8669
  const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
8374
8670
  if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
8375
- throw new CliUserError40("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
8671
+ throw new CliUserError41("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
8376
8672
  }
8377
8673
  return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
8378
8674
  }
8379
8675
  function workerToken(env, tokenEnv) {
8380
8676
  const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
8381
8677
  if (!ENV_NAME2.test(variable)) {
8382
- throw new CliUserError40("Invalid environment variable name for --token-env.");
8678
+ throw new CliUserError41("Invalid environment variable name for --token-env.");
8383
8679
  }
8384
8680
  const token = env.getEnv(variable)?.trim() ?? "";
8385
8681
  if (!WORKER_TOKEN.test(token)) {
8386
- throw new CliUserError40(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
8682
+ throw new CliUserError41(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
8387
8683
  hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
8388
8684
  });
8389
8685
  }
@@ -8396,37 +8692,37 @@ async function buildWorkerBundle(project) {
8396
8692
  explainUnresolved: (names) => [...names]
8397
8693
  });
8398
8694
  if (!lowered.workflows.some((workflow) => workflow.durable)) {
8399
- throw new CliUserError40("The project defines no durable functions for a worker to serve.");
8695
+ throw new CliUserError41("The project defines no durable functions for a worker to serve.");
8400
8696
  }
8401
8697
  await prepareProjectBundle(project, lowered);
8402
8698
  return bundlePathOf(project);
8403
8699
  }
8404
8700
  function bundlePathOf(project) {
8405
8701
  const relative = project.config.language === "py" ? PYTHON_BUNDLE_PATH : TYPESCRIPT_BUNDLE_PATH;
8406
- return join11(project.root, ...relative.split("/"));
8702
+ return join12(project.root, ...relative.split("/"));
8407
8703
  }
8408
8704
  function activitiesFor(project, raw) {
8409
8705
  if (raw === undefined)
8410
8706
  return;
8411
8707
  const value = raw.trim();
8412
8708
  if (value === "")
8413
- throw new CliUserError40("--activities cannot be empty.");
8709
+ throw new CliUserError41("--activities cannot be empty.");
8414
8710
  if (project.config.language === "py") {
8415
8711
  if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
8416
- throw new CliUserError40(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
8712
+ throw new CliUserError41(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
8417
8713
  }
8418
8714
  return value;
8419
8715
  }
8420
8716
  const path = isAbsolute3(value) ? value : resolve11(project.root, value);
8421
- if (!existsSync13(path))
8422
- throw new CliUserError40(`--activities: ${raw} not found.`);
8717
+ if (!existsSync14(path))
8718
+ throw new CliUserError41(`--activities: ${raw} not found.`);
8423
8719
  return path;
8424
8720
  }
8425
8721
  function launchOf(settings) {
8426
8722
  const { project, options } = settings;
8427
8723
  const activities = activitiesFor(project, options.activities);
8428
8724
  if (!settings.bundlePath && !activities) {
8429
- throw new CliUserError40("The worker would serve nothing: give workflows, --activities or both.");
8725
+ throw new CliUserError41("The worker would serve nothing: give workflows, --activities or both.");
8430
8726
  }
8431
8727
  const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
8432
8728
  const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
@@ -8456,10 +8752,10 @@ async function workflowBundle(project, options, build) {
8456
8752
  if (build)
8457
8753
  return buildWorkerBundle(project);
8458
8754
  const path = bundlePathOf(project);
8459
- if (!existsSync13(path)) {
8755
+ if (!existsSync14(path)) {
8460
8756
  if (options.activities !== undefined)
8461
8757
  return;
8462
- throw new CliUserError40(`No workflow bundle at ${path}.`, {
8758
+ throw new CliUserError41(`No workflow bundle at ${path}.`, {
8463
8759
  hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
8464
8760
  });
8465
8761
  }
@@ -8468,7 +8764,7 @@ async function workflowBundle(project, options, build) {
8468
8764
  async function runWorkerRun(env, options) {
8469
8765
  const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
8470
8766
  if (queues.length === 0)
8471
- throw new CliUserError40("Name the task queue(s) to serve with --queue.");
8767
+ throw new CliUserError41("Name the task queue(s) to serve with --queue.");
8472
8768
  const project = loadProject(options.project, env.cwd());
8473
8769
  const token = workerToken(env, options.tokenEnv);
8474
8770
  const launch = launchOf({
@@ -8491,7 +8787,7 @@ function devQueueName() {
8491
8787
  async function runDev(env, options) {
8492
8788
  const project = loadProject(options.project, env.cwd());
8493
8789
  if (options.lang !== undefined && options.lang !== project.config.language) {
8494
- throw new CliUserError40(`--lang ${options.lang} does not match the project language (${project.config.language}).`, { hint: "Run `fluidgrids dev` in a project of that language (`fluidgrids init --lang …`)." });
8790
+ throw new CliUserError41(`--lang ${options.lang} does not match the project language (${project.config.language}).`, { hint: "Run `fluidgrids dev` in a project of that language (`fluidgrids init --lang …`)." });
8495
8791
  }
8496
8792
  const bundlePath = await workflowBundle(project, options, options.workflows !== false);
8497
8793
  const queueName = devQueueName();
@@ -8562,7 +8858,7 @@ async function loadTypeScriptActivities(root, path) {
8562
8858
  let target = path;
8563
8859
  if ([".ts", ".mts", ".cts", ".tsx"].includes(extname3(path))) {
8564
8860
  const { build } = await import("esbuild");
8565
- const outfile = join11(root, ...ACTIVITIES_BUILD_PATH.split("/"));
8861
+ const outfile = join12(root, ...ACTIVITIES_BUILD_PATH.split("/"));
8566
8862
  await build({
8567
8863
  entryPoints: [path],
8568
8864
  outfile,
@@ -8584,9 +8880,9 @@ async function loadTypeScriptActivities(root, path) {
8584
8880
  else if (Array.isArray(value))
8585
8881
  value.forEach(visit);
8586
8882
  };
8587
- if (isRecord18(module)) {
8883
+ if (isRecord19(module)) {
8588
8884
  for (const [name, value] of Object.entries(module)) {
8589
- if (name === "default" && isRecord18(value) && !isActivityImplementation(value)) {
8885
+ if (name === "default" && isRecord19(value) && !isActivityImplementation(value)) {
8590
8886
  Object.values(value).forEach(visit);
8591
8887
  } else {
8592
8888
  visit(value);
@@ -8594,7 +8890,7 @@ async function loadTypeScriptActivities(root, path) {
8594
8890
  }
8595
8891
  }
8596
8892
  if (found.length === 0) {
8597
- throw new CliUserError40(`${path} exports no activity implementations.`, {
8893
+ throw new CliUserError41(`${path} exports no activity implementations.`, {
8598
8894
  hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
8599
8895
  });
8600
8896
  }
@@ -8620,21 +8916,21 @@ async function runTypeScriptWorker(launch) {
8620
8916
  }
8621
8917
  function pythonWorkerExitError(python, code, signal) {
8622
8918
  if (signal)
8623
- return new CliUserError40(`The Python worker was stopped by ${signal}.`);
8919
+ return new CliUserError41(`The Python worker was stopped by ${signal}.`);
8624
8920
  const status = String(code);
8625
8921
  switch (code) {
8626
8922
  case PYTHON_EXIT_NO_WORKER:
8627
- return new CliUserError40(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
8923
+ return new CliUserError41(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
8628
8924
  hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
8629
8925
  });
8630
8926
  case PYTHON_EXIT_NO_ACTIVITIES:
8631
- return new CliUserError40(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
8927
+ return new CliUserError41(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
8632
8928
  hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
8633
8929
  });
8634
8930
  case PYTHON_EXIT_BRIDGE_CLOSED:
8635
- return new CliUserError40(`The Python worker exited with status ${status}: the worker bridge closed the connection (the close code and its meaning are above).`);
8931
+ return new CliUserError41(`The Python worker exited with status ${status}: the worker bridge closed the connection (the close code and its meaning are above).`);
8636
8932
  default:
8637
- return new CliUserError40(`The Python worker exited with status ${status}.`);
8933
+ return new CliUserError41(`The Python worker exited with status ${status}.`);
8638
8934
  }
8639
8935
  }
8640
8936
  function pythonWorkerSpec(launch) {
@@ -8678,7 +8974,7 @@ function runPythonWorker(launch) {
8678
8974
  };
8679
8975
  child.on("error", (error) => {
8680
8976
  done();
8681
- reject(error.code === "ENOENT" ? new CliUserError40(`Python interpreter "${python}" was not found.`) : new CliUserError40(`Could not start ${python}: ${error.message}`));
8977
+ reject(error.code === "ENOENT" ? new CliUserError41(`Python interpreter "${python}" was not found.`) : new CliUserError41(`Could not start ${python}: ${error.message}`));
8682
8978
  });
8683
8979
  child.on("close", (code, signal) => {
8684
8980
  done();
@@ -8761,7 +9057,7 @@ except BridgeClosedError as error:
8761
9057
 
8762
9058
  // src/phase-c/shared.ts
8763
9059
  import { createInterface as createInterface3 } from "readline/promises";
8764
- import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
9060
+ import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
8765
9061
  async function confirmOnTerminal(question) {
8766
9062
  const rl = createInterface3({ input: process.stdin, output: process.stderr });
8767
9063
  try {
@@ -8783,32 +9079,32 @@ async function requireConfirmation(env, question, force) {
8783
9079
  if (force)
8784
9080
  return;
8785
9081
  if (!env.interactive()) {
8786
- throw new CliUserError41(`${question} needs confirmation.`, {
9082
+ throw new CliUserError42(`${question} needs confirmation.`, {
8787
9083
  hint: "Pass --force to go ahead without a prompt."
8788
9084
  });
8789
9085
  }
8790
9086
  if (!await env.confirm(question))
8791
- throw new CliUserError41("Aborted: nothing was changed.");
9087
+ throw new CliUserError42("Aborted: nothing was changed.");
8792
9088
  }
8793
9089
  function runSelectorOf(runId, flags) {
8794
9090
  const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
8795
9091
  if (!targeted) {
8796
9092
  if (runId === undefined || runId.trim() === "") {
8797
- throw new CliUserError41("Give a run id, or --workflow-id with --key.");
9093
+ throw new CliUserError42("Give a run id, or --workflow-id with --key.");
8798
9094
  }
8799
9095
  return { runId: runId.trim() };
8800
9096
  }
8801
9097
  if (runId !== undefined) {
8802
- throw new CliUserError41("Give a run id or --workflow-id with --key, not both.");
9098
+ throw new CliUserError42("Give a run id or --workflow-id with --key, not both.");
8803
9099
  }
8804
9100
  const workflowId = flags.workflowId?.trim() ?? "";
8805
9101
  const key = flags.key?.trim() ?? "";
8806
9102
  if (workflowId === "" || key === "") {
8807
- throw new CliUserError41("--workflow-id and --key go together (the workflow id of that key).");
9103
+ throw new CliUserError42("--workflow-id and --key go together (the workflow id of that key).");
8808
9104
  }
8809
9105
  const firstRunId = flags.firstRunId?.trim();
8810
9106
  if (flags.firstRunId !== undefined && !firstRunId) {
8811
- throw new CliUserError41("--first-run-id cannot be empty.");
9107
+ throw new CliUserError42("--first-run-id cannot be empty.");
8812
9108
  }
8813
9109
  return {
8814
9110
  target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
@@ -8824,7 +9120,7 @@ function parseEnumOption(raw, flag, allowed) {
8824
9120
  const match = allowed.find((value) => value === normal);
8825
9121
  if (match === undefined) {
8826
9122
  const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
8827
- throw new CliUserError41(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
9123
+ throw new CliUserError42(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
8828
9124
  }
8829
9125
  return match;
8830
9126
  }
@@ -8833,7 +9129,7 @@ function parseNonNegativeInt(raw, flag) {
8833
9129
  return;
8834
9130
  const value = raw.trim();
8835
9131
  if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
8836
- throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
9132
+ throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
8837
9133
  }
8838
9134
  return Number(value);
8839
9135
  }
@@ -8842,14 +9138,14 @@ function parseNumberOption(raw, flag) {
8842
9138
  return;
8843
9139
  const value = Number(raw.trim());
8844
9140
  if (raw.trim() === "" || !Number.isFinite(value)) {
8845
- throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected a number.`);
9141
+ throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected a number.`);
8846
9142
  }
8847
9143
  return value;
8848
9144
  }
8849
9145
  function requireText(raw, flag) {
8850
9146
  const value = raw?.trim() ?? "";
8851
9147
  if (value === "")
8852
- throw new CliUserError41(`${flag} is required.`);
9148
+ throw new CliUserError42(`${flag} is required.`);
8853
9149
  return value;
8854
9150
  }
8855
9151
  function parseList(raw) {
@@ -8879,7 +9175,7 @@ function parseInstant(raw, flag) {
8879
9175
  const value = raw.trim();
8880
9176
  const ms = Date.parse(value);
8881
9177
  if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
8882
- throw new CliUserError41(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
9178
+ throw new CliUserError42(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
8883
9179
  }
8884
9180
  return new Date(ms).toISOString();
8885
9181
  }
@@ -8888,7 +9184,7 @@ var init_shared3 = __esm(() => {
8888
9184
  });
8889
9185
 
8890
9186
  // src/config/commands.ts
8891
- import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
9187
+ import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
8892
9188
  function output(env, options, data, rows, headers) {
8893
9189
  env.ctx.output.formatAndOutput(options, data, { headers, rows });
8894
9190
  }
@@ -8904,7 +9200,7 @@ function isLocal(url) {
8904
9200
  function checkProfileValue(key, value, profile) {
8905
9201
  const trimmed = value.trim();
8906
9202
  if (trimmed === "" || trimmed.length > 2048) {
8907
- throw new CliUserError42(`${key} must be 1 to 2048 characters.`);
9203
+ throw new CliUserError43(`${key} must be 1 to 2048 characters.`);
8908
9204
  }
8909
9205
  switch (key) {
8910
9206
  case "apiUrl":
@@ -8913,20 +9209,20 @@ function checkProfileValue(key, value, profile) {
8913
9209
  try {
8914
9210
  url = new URL(trimmed);
8915
9211
  } catch {
8916
- throw new CliUserError42(`${key} must be a URL.`);
9212
+ throw new CliUserError43(`${key} must be a URL.`);
8917
9213
  }
8918
9214
  if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
8919
- throw new CliUserError42(`${key} must use https (http only for localhost).`);
9215
+ throw new CliUserError43(`${key} must use https (http only for localhost).`);
8920
9216
  }
8921
9217
  if (url.username || url.password) {
8922
- throw new CliUserError42(`${key} must not carry credentials.`);
9218
+ throw new CliUserError43(`${key} must not carry credentials.`);
8923
9219
  }
8924
9220
  return trimmed;
8925
9221
  }
8926
9222
  case "environment": {
8927
9223
  const upper = trimmed.toUpperCase();
8928
9224
  if (!ENVIRONMENTS4.includes(upper)) {
8929
- throw new CliUserError42(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
9225
+ throw new CliUserError43(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
8930
9226
  }
8931
9227
  return upper;
8932
9228
  }
@@ -8940,15 +9236,15 @@ function checkProfileValue(key, value, profile) {
8940
9236
  async function readToken(env, fromEnv) {
8941
9237
  if (fromEnv !== undefined) {
8942
9238
  if (!ENV_NAME3.test(fromEnv))
8943
- throw new CliUserError42("Invalid environment variable name for --from-env.");
9239
+ throw new CliUserError43("Invalid environment variable name for --from-env.");
8944
9240
  const value = env.env[fromEnv]?.trim() ?? "";
8945
9241
  if (value === "")
8946
- throw new CliUserError42(`The environment variable ${fromEnv} is empty or unset.`);
9242
+ throw new CliUserError43(`The environment variable ${fromEnv} is empty or unset.`);
8947
9243
  return value;
8948
9244
  }
8949
9245
  const piped = (await env.readStdin()).trim();
8950
9246
  if (piped === "") {
8951
- throw new CliUserError42("Pipe the token on standard input, or pass --from-env <VAR>.", {
9247
+ throw new CliUserError43("Pipe the token on standard input, or pass --from-env <VAR>.", {
8952
9248
  hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
8953
9249
  });
8954
9250
  }
@@ -8968,7 +9264,7 @@ async function runConfigSet(env, key, value, options) {
8968
9264
  const profile = profileName(env, options);
8969
9265
  if (key === "token") {
8970
9266
  if (value !== undefined) {
8971
- throw new CliUserError42("A token is never given on the command line.", {
9267
+ throw new CliUserError43("A token is never given on the command line.", {
8972
9268
  hint: "Pipe it on standard input, or pass --from-env <VAR>."
8973
9269
  });
8974
9270
  }
@@ -8985,12 +9281,12 @@ async function runConfigSet(env, key, value, options) {
8985
9281
  return out;
8986
9282
  }
8987
9283
  if (!isProfileKey(key)) {
8988
- throw new CliUserError42(`Unknown profile key ${key}.`, {
9284
+ throw new CliUserError43(`Unknown profile key ${key}.`, {
8989
9285
  hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
8990
9286
  });
8991
9287
  }
8992
9288
  if (value === undefined)
8993
- throw new CliUserError42(`Give a value for ${key}.`);
9289
+ throw new CliUserError43(`Give a value for ${key}.`);
8994
9290
  const checked = checkProfileValue(key, value, profile);
8995
9291
  updateConfig(file, (document) => {
8996
9292
  const table = profileTable(document, profile, true);
@@ -9006,7 +9302,7 @@ async function runConfigGet(env, key, options) {
9006
9302
  const config = readConfig(file);
9007
9303
  const resolved = resolveProfile(config, env.env, options.profile, file);
9008
9304
  if (key !== undefined && !isProfileKey(key)) {
9009
- throw new CliUserError42(`Unknown profile key ${key}.`, {
9305
+ throw new CliUserError43(`Unknown profile key ${key}.`, {
9010
9306
  hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
9011
9307
  });
9012
9308
  }
@@ -9051,10 +9347,10 @@ async function runConfigDelete(env, key, options) {
9051
9347
  const profile = profileName(env, options);
9052
9348
  const existing = readConfig(file).profiles[profile];
9053
9349
  if (existing === undefined)
9054
- throw new CliUserError42(`There is no profile ${profile} in ${file}.`);
9350
+ throw new CliUserError43(`There is no profile ${profile} in ${file}.`);
9055
9351
  if (key !== undefined) {
9056
9352
  if (!isProfileKey(key))
9057
- throw new CliUserError42(`Unknown profile key ${key}.`);
9353
+ throw new CliUserError43(`Unknown profile key ${key}.`);
9058
9354
  updateConfig(file, (document) => {
9059
9355
  const table = profileTable(document, profile, false);
9060
9356
  if (table)
@@ -9091,7 +9387,7 @@ async function runConfigMigrate(env, options) {
9091
9387
  values.workspace = workspace;
9092
9388
  if (options.tokenEnv !== undefined) {
9093
9389
  if (!ENV_NAME3.test(options.tokenEnv))
9094
- throw new CliUserError42("Invalid environment variable name for --token-env.");
9390
+ throw new CliUserError43("Invalid environment variable name for --token-env.");
9095
9391
  values.tokenRef = `env:${options.tokenEnv}`;
9096
9392
  }
9097
9393
  updateConfig(file, (document) => {
@@ -9116,7 +9412,7 @@ var init_commands = __esm(() => {
9116
9412
  });
9117
9413
 
9118
9414
  // src/phase-c/commands/workers.ts
9119
- import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
9415
+ import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
9120
9416
  function workerRows(workers) {
9121
9417
  return workers.map((worker) => [
9122
9418
  worker.identity,
@@ -9130,7 +9426,7 @@ function workerRows(workers) {
9130
9426
  }
9131
9427
  async function runWorkersList(env, options) {
9132
9428
  if (options.stale && options.notStale) {
9133
- throw new CliUserError43("Give --stale or --not-stale, not both.");
9429
+ throw new CliUserError44("Give --stale or --not-stale, not both.");
9134
9430
  }
9135
9431
  const filter = {
9136
9432
  ...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
@@ -9173,7 +9469,7 @@ function connectionNames(raw) {
9173
9469
  const names = parseList(raw);
9174
9470
  for (const name of names) {
9175
9471
  if (!CONNECTION_NAME.test(name)) {
9176
- throw new CliUserError43(`Invalid connection name '${name}'.`);
9472
+ throw new CliUserError44(`Invalid connection name '${name}'.`);
9177
9473
  }
9178
9474
  }
9179
9475
  return names;
@@ -9188,10 +9484,10 @@ function issued(env, options, result) {
9188
9484
  async function runTokensCreate(env, name, options) {
9189
9485
  const tokenName = name.trim();
9190
9486
  if (tokenName === "")
9191
- throw new CliUserError43("A worker token needs a name.");
9487
+ throw new CliUserError44("A worker token needs a name.");
9192
9488
  const taskQueues = parseList(options.queue).map(checkWorkerQueue);
9193
9489
  if (taskQueues.length === 0) {
9194
- throw new CliUserError43("A worker token needs at least one --queue.", {
9490
+ throw new CliUserError44("A worker token needs at least one --queue.", {
9195
9491
  hint: "Create the queue first with `fluidgrids queues create <name>`."
9196
9492
  });
9197
9493
  }
@@ -9220,10 +9516,10 @@ async function runTokensDelete(env, id, options) {
9220
9516
  async function runTokensAllowConnections(env, id, names, options) {
9221
9517
  const list = connectionNames(names);
9222
9518
  if (list.length === 0 && !options.clear) {
9223
- throw new CliUserError43("Name the connections to allow, or pass --clear to allow none.");
9519
+ throw new CliUserError44("Name the connections to allow, or pass --clear to allow none.");
9224
9520
  }
9225
9521
  if (list.length > 0 && options.clear) {
9226
- throw new CliUserError43("Give connection names or --clear, not both.");
9522
+ throw new CliUserError44("Give connection names or --clear, not both.");
9227
9523
  }
9228
9524
  const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
9229
9525
  emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
@@ -9243,17 +9539,17 @@ var init_workers = __esm(() => {
9243
9539
 
9244
9540
  // src/phase-c/commands/run-control.ts
9245
9541
  import { randomUUID } from "crypto";
9246
- import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
9542
+ import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
9247
9543
  function runAndName(first, second, flags) {
9248
9544
  const targeted = flags.workflowId !== undefined || flags.key !== undefined;
9249
9545
  if (targeted) {
9250
9546
  if (second !== undefined) {
9251
- throw new CliUserError44("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
9547
+ throw new CliUserError45("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
9252
9548
  }
9253
9549
  return { run: runSelectorOf(undefined, flags), name: first };
9254
9550
  }
9255
9551
  if (second === undefined) {
9256
- throw new CliUserError44("Give the run id and the name: `<runId> <name>`.");
9552
+ throw new CliUserError45("Give the run id and the name: `<runId> <name>`.");
9257
9553
  }
9258
9554
  return { run: runSelectorOf(first, flags), name: second };
9259
9555
  }
@@ -9267,7 +9563,7 @@ async function runQuery(env, first, second, options) {
9267
9563
  rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
9268
9564
  }, result.error ? [`error: ${result.error}`] : []);
9269
9565
  if (result.rejected) {
9270
- throw new CliUserError44(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
9566
+ throw new CliUserError45(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
9271
9567
  }
9272
9568
  return result;
9273
9569
  }
@@ -9309,13 +9605,13 @@ async function runUpdate(env, first, second, options) {
9309
9605
  rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
9310
9606
  });
9311
9607
  if (!reached(result.status, waitFor)) {
9312
- throw new CliUserError44(`The update ${name} is still ${result.status} after ${timeoutMs} ms (waiting for ${waitFor}); check it later with \`fluidgrids runs update-status ${result.runId} ${updateId}\`.`);
9608
+ throw new CliUserError45(`The update ${name} is still ${result.status} after ${timeoutMs} ms (waiting for ${waitFor}); check it later with \`fluidgrids runs update-status ${result.runId} ${updateId}\`.`);
9313
9609
  }
9314
9610
  if (result.status === "REJECTED") {
9315
- throw new CliUserError44(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
9611
+ throw new CliUserError45(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
9316
9612
  }
9317
9613
  if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
9318
- throw new CliUserError44(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
9614
+ throw new CliUserError45(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
9319
9615
  }
9320
9616
  return result;
9321
9617
  }
@@ -9331,33 +9627,33 @@ async function runUpdateStatus(env, first, second, options) {
9331
9627
  function parseResetTo(raw, buildId) {
9332
9628
  const value = raw?.trim() ?? "";
9333
9629
  if (value === "") {
9334
- throw new CliUserError44("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
9630
+ throw new CliUserError45("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
9335
9631
  }
9336
9632
  if (/^\d+$/.test(value)) {
9337
9633
  if (buildId !== undefined)
9338
- throw new CliUserError44("--build-id goes with --to build-id only.");
9634
+ throw new CliUserError45("--build-id goes with --to build-id only.");
9339
9635
  const seq = Number(value);
9340
9636
  if (!Number.isSafeInteger(seq) || seq <= 0) {
9341
- throw new CliUserError44(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
9637
+ throw new CliUserError45(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
9342
9638
  }
9343
9639
  return { seq };
9344
9640
  }
9345
9641
  const normal = value.toUpperCase().replace(/-/g, "_");
9346
9642
  if (normal === "LAST_CLEAN_TASK") {
9347
9643
  if (buildId !== undefined)
9348
- throw new CliUserError44("--build-id goes with --to build-id only.");
9644
+ throw new CliUserError45("--build-id goes with --to build-id only.");
9349
9645
  return "LAST_CLEAN_TASK";
9350
9646
  }
9351
9647
  const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
9352
9648
  if (type === "BUILD_ID") {
9353
9649
  const id = buildId?.trim() ?? "";
9354
9650
  if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
9355
- throw new CliUserError44("--to build-id needs --build-id sha256:<64 hex>.");
9651
+ throw new CliUserError45("--to build-id needs --build-id sha256:<64 hex>.");
9356
9652
  }
9357
9653
  return { type, buildId: id };
9358
9654
  }
9359
9655
  if (buildId !== undefined)
9360
- throw new CliUserError44("--build-id goes with --to build-id only.");
9656
+ throw new CliUserError45("--build-id goes with --to build-id only.");
9361
9657
  return { type };
9362
9658
  }
9363
9659
  async function runReset(env, runId, options) {
@@ -9416,7 +9712,7 @@ async function runTrace(env, runIdArg, options) {
9416
9712
  const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
9417
9713
  const hierarchy = await env.pc.runHierarchy(runId);
9418
9714
  if (!hierarchy)
9419
- throw new CliUserError44(`Run ${runId} not found (NOT_FOUND)`);
9715
+ throw new CliUserError45(`Run ${runId} not found (NOT_FOUND)`);
9420
9716
  const entries = flatten(hierarchy);
9421
9717
  const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
9422
9718
  const read = new Map;
@@ -9456,32 +9752,32 @@ var init_run_control = __esm(() => {
9456
9752
  });
9457
9753
 
9458
9754
  // src/phase-c/commands/activities.ts
9459
- import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
9755
+ import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
9460
9756
  import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
9461
9757
  function completionOf(env, first, second, options) {
9462
9758
  if (options.taskTokenEnv !== undefined) {
9463
9759
  if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
9464
- throw new CliUserError45("Give --task-token-env, or the run and activity id, not both.");
9760
+ throw new CliUserError46("Give --task-token-env, or the run and activity id, not both.");
9465
9761
  }
9466
9762
  const variable = options.taskTokenEnv.trim();
9467
9763
  if (!ENV_NAME4.test(variable)) {
9468
- throw new CliUserError45("Invalid environment variable name for --task-token-env.");
9764
+ throw new CliUserError46("Invalid environment variable name for --task-token-env.");
9469
9765
  }
9470
9766
  const taskToken = env.getEnv(variable)?.trim() ?? "";
9471
9767
  if (taskToken === "") {
9472
- throw new CliUserError45(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
9768
+ throw new CliUserError46(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
9473
9769
  }
9474
9770
  return { kind: "token", taskToken };
9475
9771
  }
9476
9772
  const targeted = options.workflowId !== undefined || options.key !== undefined;
9477
9773
  if (targeted) {
9478
9774
  if (first === undefined || second !== undefined) {
9479
- throw new CliUserError45("With --workflow-id, give only the activity id.");
9775
+ throw new CliUserError46("With --workflow-id, give only the activity id.");
9480
9776
  }
9481
9777
  return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
9482
9778
  }
9483
9779
  if (first === undefined || second === undefined) {
9484
- throw new CliUserError45("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
9780
+ throw new CliUserError46("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
9485
9781
  }
9486
9782
  return { kind: "id", run: runSelectorOf(first, options), activityId: second };
9487
9783
  }
@@ -9539,7 +9835,7 @@ function selectorOf(options) {
9539
9835
  options.all === true
9540
9836
  ];
9541
9837
  if (given.filter(Boolean).length !== 1) {
9542
- throw new CliUserError45("Choose the activities with exactly one of --activity-id, --type or --all.");
9838
+ throw new CliUserError46("Choose the activities with exactly one of --activity-id, --type or --all.");
9543
9839
  }
9544
9840
  if (options.activityId !== undefined) {
9545
9841
  return { activityId: requireText(options.activityId, "--activity-id") };
@@ -9580,18 +9876,18 @@ function parseMs(raw, flag) {
9580
9876
  const value = raw.trim();
9581
9877
  const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
9582
9878
  if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
9583
- throw new CliUserError45(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
9879
+ throw new CliUserError46(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
9584
9880
  }
9585
9881
  return Math.round(ms);
9586
9882
  }
9587
9883
  function activityOptionsOf(options) {
9588
9884
  const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
9589
9885
  if (Number.isNaN(maxRetries)) {
9590
- throw new CliUserError45(`Invalid value '${options.maxRetries}' for --max-retries.`);
9886
+ throw new CliUserError46(`Invalid value '${options.maxRetries}' for --max-retries.`);
9591
9887
  }
9592
9888
  const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
9593
9889
  if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
9594
- throw new CliUserError45(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
9890
+ throw new CliUserError46(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
9595
9891
  }
9596
9892
  const retryOn = [];
9597
9893
  for (const value of parseList(options.retryOn)) {
@@ -9615,7 +9911,7 @@ function activityOptionsOf(options) {
9615
9911
  };
9616
9912
  const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
9617
9913
  if (Object.keys(out).length === 0) {
9618
- throw new CliUserError45("Nothing to change: give a retry option or a timeout.");
9914
+ throw new CliUserError46("Nothing to change: give a retry option or a timeout.");
9619
9915
  }
9620
9916
  return out;
9621
9917
  }
@@ -9642,10 +9938,10 @@ async function runPauseRulesList(env, options) {
9642
9938
  }
9643
9939
  async function runPauseRulesCreate(env, options) {
9644
9940
  if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
9645
- throw new CliUserError45("A pause rule needs --activity-type, --node-type or --workflow-key.");
9941
+ throw new CliUserError46("A pause rule needs --activity-type, --node-type or --workflow-key.");
9646
9942
  }
9647
9943
  if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
9648
- throw new CliUserError45("Give --expires-at or --expires-in, not both.");
9944
+ throw new CliUserError46("Give --expires-at or --expires-in, not both.");
9649
9945
  }
9650
9946
  const expiresIn = parseMs(options.expiresIn, "--expires-in");
9651
9947
  const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
@@ -9683,11 +9979,11 @@ var init_activities = __esm(() => {
9683
9979
  });
9684
9980
 
9685
9981
  // src/phase-c/commands/batch.ts
9686
- import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
9982
+ import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
9687
9983
  function isBatchType(name) {
9688
9984
  return Object.hasOwn(BATCH_TYPES, name);
9689
9985
  }
9690
- function isRecord19(value) {
9986
+ function isRecord20(value) {
9691
9987
  return typeof value === "object" && value !== null && !Array.isArray(value);
9692
9988
  }
9693
9989
  function batchSelection(options) {
@@ -9695,8 +9991,8 @@ function batchSelection(options) {
9695
9991
  const filter = {};
9696
9992
  if (options.filter !== undefined) {
9697
9993
  const raw = parseJsonOption(options.filter, "--filter");
9698
- if (!isRecord19(raw))
9699
- throw new CliUserError46("--filter must be a JSON object (ListWorkflowRunsInput).");
9994
+ if (!isRecord20(raw))
9995
+ throw new CliUserError47("--filter must be a JSON object (ListWorkflowRunsInput).");
9700
9996
  Object.assign(filter, raw);
9701
9997
  delete filter["limit"];
9702
9998
  delete filter["offset"];
@@ -9715,20 +10011,20 @@ function batchSelection(options) {
9715
10011
  filter["firstRunId"] = requireText(options.firstRunId, "--first-run-id");
9716
10012
  if (options.searchAttributes !== undefined) {
9717
10013
  const query = parseJsonOption(options.searchAttributes, "--search-attributes");
9718
- if (!isRecord19(query)) {
9719
- throw new CliUserError46("--search-attributes must be a JSON object ({and, or, text}).");
10014
+ if (!isRecord20(query)) {
10015
+ throw new CliUserError47("--search-attributes must be a JSON object ({and, or, text}).");
9720
10016
  }
9721
10017
  filter["searchAttributes"] = query;
9722
10018
  }
9723
10019
  const filtered = Object.keys(filter).length > 0;
9724
10020
  if (runIds.length > 0 && filtered) {
9725
- throw new CliUserError46("Choose the runs with --run-id or with filter options, not both.");
10021
+ throw new CliUserError47("Choose the runs with --run-id or with filter options, not both.");
9726
10022
  }
9727
10023
  if (runIds.length > MAX_BATCH_RUN_IDS) {
9728
- throw new CliUserError46(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
10024
+ throw new CliUserError47(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
9729
10025
  }
9730
10026
  if (runIds.length === 0 && !filtered) {
9731
- throw new CliUserError46("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
10027
+ throw new CliUserError47("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
9732
10028
  }
9733
10029
  const rate = parsePositiveInt(options.rate, "--rate");
9734
10030
  return {
@@ -9790,7 +10086,7 @@ function batchPayload(type, options) {
9790
10086
  options.clearOverride === true
9791
10087
  ];
9792
10088
  if (chosen.filter(Boolean).length !== 1) {
9793
- throw new CliUserError46("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
10089
+ throw new CliUserError47("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
9794
10090
  }
9795
10091
  if (options.clearOverride)
9796
10092
  return { clearVersioningOverride: true };
@@ -9824,7 +10120,7 @@ function refuseUnused(type, options) {
9824
10120
  unused.push("--activity-id/--type/--all");
9825
10121
  }
9826
10122
  if (unused.length > 0) {
9827
- throw new CliUserError46(`${unused.join(", ")} do not apply to a ${type} batch.`);
10123
+ throw new CliUserError47(`${unused.join(", ")} do not apply to a ${type} batch.`);
9828
10124
  }
9829
10125
  }
9830
10126
  function jobRow(job) {
@@ -9852,7 +10148,7 @@ function jobDetails(job) {
9852
10148
  }
9853
10149
  async function runBatchStart(env, typeName, options) {
9854
10150
  if (!isBatchType(typeName)) {
9855
- throw new CliUserError46(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
10151
+ throw new CliUserError47(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
9856
10152
  }
9857
10153
  const type = BATCH_TYPES[typeName];
9858
10154
  refuseUnused(type, options);
@@ -9902,10 +10198,10 @@ async function runBatchDescribe(env, id, options) {
9902
10198
  }
9903
10199
  emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
9904
10200
  if (options.watch && !TERMINAL_JOB.includes(job.status)) {
9905
- throw new CliUserError46(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
10201
+ throw new CliUserError47(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
9906
10202
  }
9907
10203
  if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
9908
- throw new CliUserError46(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
10204
+ throw new CliUserError47(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
9909
10205
  }
9910
10206
  return job;
9911
10207
  }
@@ -9949,7 +10245,7 @@ var init_batch = __esm(() => {
9949
10245
  });
9950
10246
 
9951
10247
  // src/phase-d/duration.ts
9952
- import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
10248
+ import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
9953
10249
  import { toMs } from "@fluidgrids/workflows";
9954
10250
  function parseDurationOption(raw, flag) {
9955
10251
  if (raw === undefined)
@@ -9959,23 +10255,23 @@ function parseDurationOption(raw, flag) {
9959
10255
  try {
9960
10256
  toMs(sent, flag);
9961
10257
  } catch {
9962
- throw new CliUserError47(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
10258
+ throw new CliUserError48(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
9963
10259
  }
9964
10260
  return sent;
9965
10261
  }
9966
10262
  var init_duration = () => {};
9967
10263
 
9968
10264
  // src/phase-d/commands/activity-start.ts
9969
- import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
10265
+ import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
9970
10266
  import { resolve as resolve12 } from "path";
9971
- import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
10267
+ import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
9972
10268
  function retryPolicy(raw, maxAttempts, readFile) {
9973
10269
  const parsed = parseJsonObjectArg(raw, "--retry", readFile);
9974
10270
  const policy = {};
9975
10271
  if (parsed !== undefined) {
9976
10272
  for (const key of Object.keys(parsed)) {
9977
10273
  if (!RETRY_KEYS.some((known) => known === key)) {
9978
- throw new CliUserError48(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
10274
+ throw new CliUserError49(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
9979
10275
  }
9980
10276
  }
9981
10277
  const text = (key) => {
@@ -9983,7 +10279,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
9983
10279
  if (value === undefined)
9984
10280
  return;
9985
10281
  if (typeof value !== "string")
9986
- throw new CliUserError48(`--retry: ${key} must be a duration.`);
10282
+ throw new CliUserError49(`--retry: ${key} must be a duration.`);
9987
10283
  policy[key] = parseDurationOption(value, `--retry ${key}`);
9988
10284
  };
9989
10285
  text("initialInterval");
@@ -9991,21 +10287,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
9991
10287
  const backoff = parsed["backoffCoefficient"];
9992
10288
  if (backoff !== undefined) {
9993
10289
  if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
9994
- throw new CliUserError48("--retry: backoffCoefficient must be a number of at least 1.");
10290
+ throw new CliUserError49("--retry: backoffCoefficient must be a number of at least 1.");
9995
10291
  }
9996
10292
  policy.backoffCoefficient = backoff;
9997
10293
  }
9998
10294
  const attempts = parsed["maximumAttempts"];
9999
10295
  if (attempts !== undefined) {
10000
10296
  if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
10001
- throw new CliUserError48("--retry: maximumAttempts must be a whole number (0 = unlimited).");
10297
+ throw new CliUserError49("--retry: maximumAttempts must be a whole number (0 = unlimited).");
10002
10298
  }
10003
10299
  policy.maximumAttempts = attempts;
10004
10300
  }
10005
10301
  const types = parsed["nonRetryableErrorTypes"];
10006
10302
  if (types !== undefined) {
10007
10303
  if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
10008
- throw new CliUserError48("--retry: nonRetryableErrorTypes must be a list of strings.");
10304
+ throw new CliUserError49("--retry: nonRetryableErrorTypes must be a list of strings.");
10009
10305
  }
10010
10306
  policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
10011
10307
  }
@@ -10013,7 +10309,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
10013
10309
  if (maxAttempts !== undefined) {
10014
10310
  const value = maxAttempts.trim();
10015
10311
  if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
10016
- throw new CliUserError48(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
10312
+ throw new CliUserError49(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
10017
10313
  }
10018
10314
  policy.maximumAttempts = Number(value);
10019
10315
  }
@@ -10022,29 +10318,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
10022
10318
  function requireName(raw, what) {
10023
10319
  const value = raw.trim();
10024
10320
  if (value === "")
10025
- throw new CliUserError48(`The ${what} is empty.`);
10321
+ throw new CliUserError49(`The ${what} is empty.`);
10026
10322
  return value;
10027
10323
  }
10028
10324
  async function runActivityStart(env, nodeType, operation, options) {
10029
10325
  const readFile = (path) => {
10030
10326
  const absolute = resolve12(env.cwd(), path);
10031
- if (!existsSync14(absolute))
10032
- throw new CliUserError48(`${path} does not exist.`);
10327
+ if (!existsSync15(absolute))
10328
+ throw new CliUserError49(`${path} does not exist.`);
10033
10329
  return readFileSync12(absolute, "utf8");
10034
10330
  };
10035
10331
  if (options.args === undefined) {
10036
- throw new CliUserError48("--args is required: the operation arguments as a JSON object.", {
10332
+ throw new CliUserError49("--args is required: the operation arguments as a JSON object.", {
10037
10333
  hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
10038
10334
  });
10039
10335
  }
10040
10336
  const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
10041
10337
  const summary = options.summary?.trim();
10042
10338
  if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
10043
- throw new CliUserError48(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
10339
+ throw new CliUserError49(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
10044
10340
  }
10045
10341
  const key = options.idempotencyKey?.trim();
10046
10342
  if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
10047
- throw new CliUserError48(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
10343
+ throw new CliUserError49(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
10048
10344
  }
10049
10345
  const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
10050
10346
  const nodeVersion = options.nodeVersion?.trim();
@@ -10088,7 +10384,7 @@ async function runActivityStart(env, nodeType, operation, options) {
10088
10384
  rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
10089
10385
  }, details);
10090
10386
  if (options.wait && finalStatus !== "COMPLETED") {
10091
- throw new CliUserError48(`Run ${started.run.id} ended ${finalStatus}.`);
10387
+ throw new CliUserError49(`Run ${started.run.id} ended ${finalStatus}.`);
10092
10388
  }
10093
10389
  return result;
10094
10390
  }
@@ -10109,7 +10405,7 @@ var init_activity_start = __esm(() => {
10109
10405
  });
10110
10406
 
10111
10407
  // src/phase-c/commands/signal-tokens.ts
10112
- import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
10408
+ import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
10113
10409
  function row(token) {
10114
10410
  return [
10115
10411
  token.id,
@@ -10126,12 +10422,12 @@ async function runSignalTokenCreate(env, runId, options) {
10126
10422
  const signalName = requireText(options.signal, "--signal");
10127
10423
  const ttlMs = parseMs(options.ttl, "--ttl");
10128
10424
  if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
10129
- throw new CliUserError49("--ttl is counted in whole seconds.");
10425
+ throw new CliUserError50("--ttl is counted in whole seconds.");
10130
10426
  }
10131
10427
  const ipAllowlist = parseList(options.allowIp);
10132
10428
  for (const entry of ipAllowlist) {
10133
10429
  if (!IPV4_OR_CIDR.test(entry)) {
10134
- throw new CliUserError49(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
10430
+ throw new CliUserError50(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
10135
10431
  }
10136
10432
  }
10137
10433
  const created = await env.pc.createSignalToken({
@@ -10167,7 +10463,7 @@ var init_signal_tokens = __esm(() => {
10167
10463
  });
10168
10464
 
10169
10465
  // src/phase-c/commands/search-attributes.ts
10170
- import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
10466
+ import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
10171
10467
  function row2(attribute) {
10172
10468
  return [
10173
10469
  attribute.name,
@@ -10184,11 +10480,11 @@ async function runSearchAttributesList(env, options) {
10184
10480
  }
10185
10481
  async function runSearchAttributesCreate(env, name, options) {
10186
10482
  if (!NAME.test(name)) {
10187
- throw new CliUserError50(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
10483
+ throw new CliUserError51(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
10188
10484
  }
10189
10485
  const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
10190
10486
  if (type === undefined) {
10191
- throw new CliUserError50(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
10487
+ throw new CliUserError51(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
10192
10488
  }
10193
10489
  const attribute = await env.pc.createSearchAttribute({
10194
10490
  name,
@@ -10201,7 +10497,7 @@ async function runSearchAttributesCreate(env, name, options) {
10201
10497
  async function runSearchAttributesDelete(env, name, options) {
10202
10498
  const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
10203
10499
  if (!attribute) {
10204
- throw new CliUserError50(`The workspace has no search attribute ${name}.`, {
10500
+ throw new CliUserError51(`The workspace has no search attribute ${name}.`, {
10205
10501
  hint: "List them with `fluidgrids search-attributes list`."
10206
10502
  });
10207
10503
  }
@@ -10229,12 +10525,12 @@ var init_search_attributes = __esm(() => {
10229
10525
  });
10230
10526
 
10231
10527
  // src/phase-c/commands/schedules.ts
10232
- import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
10233
- function isRecord20(value) {
10528
+ import { CliUserError as CliUserError52 } from "@burdenoff/cli-sdk/core";
10529
+ function isRecord21(value) {
10234
10530
  return typeof value === "object" && value !== null && !Array.isArray(value);
10235
10531
  }
10236
10532
  function triggerNodeOf(job) {
10237
- if (isRecord20(job.config) && typeof job.config["triggerNodeId"] === "string") {
10533
+ if (isRecord21(job.config) && typeof job.config["triggerNodeId"] === "string") {
10238
10534
  return job.config["triggerNodeId"];
10239
10535
  }
10240
10536
  const prefix = `${job.workflowKey}:`;
@@ -10354,9 +10650,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
10354
10650
  const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
10355
10651
  const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
10356
10652
  if (from >= to)
10357
- throw new CliUserError51("--from must be before --to.");
10653
+ throw new CliUserError52("--from must be before --to.");
10358
10654
  if (Date.parse(to) > Date.now())
10359
- throw new CliUserError51("--to must be in the past.");
10655
+ throw new CliUserError52("--to must be in the past.");
10360
10656
  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);
10361
10657
  const overlapPolicy = parseOverlap(options.overlapPolicy);
10362
10658
  const result = await env.pc.backfillSchedule({
@@ -10406,9 +10702,9 @@ var init_schedules = __esm(() => {
10406
10702
  // src/cli.ts
10407
10703
  init_json_contract();
10408
10704
  import { readFileSync as readFileSync13 } from "fs";
10409
- import { join as join12, dirname as dirname6 } from "path";
10705
+ import { join as join13, dirname as dirname7 } from "path";
10410
10706
  import { fileURLToPath } from "url";
10411
- import { CliUserError as CliUserError52, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
10707
+ import { CliUserError as CliUserError53, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
10412
10708
 
10413
10709
  // src/output/run-envelope.ts
10414
10710
  init_json_contract();
@@ -10837,7 +11133,7 @@ import healthModule from "@burdenoff/cli-sdk/modules/health";
10837
11133
 
10838
11134
  // src/code-first/register.ts
10839
11135
  init_shared();
10840
- import { CliUserError as CliUserError37 } from "@burdenoff/cli-sdk/core";
11136
+ import { CliUserError as CliUserError38 } from "@burdenoff/cli-sdk/core";
10841
11137
  var PROJECT_OPTION = [
10842
11138
  "--project <dir>",
10843
11139
  "Project directory (default: nearest fluidgrids.config.json)"
@@ -10895,7 +11191,7 @@ function registerImport(program, env) {
10895
11191
  return;
10896
11192
  }
10897
11193
  if (resolved.preview) {
10898
- throw new CliUserError37("--preview needs --from <tool>.");
11194
+ throw new CliUserError38("--preview needs --from <tool>.");
10899
11195
  }
10900
11196
  await Promise.resolve().then(() => init_import());
10901
11197
  await runImport(env, file, resolved);
@@ -10967,13 +11263,13 @@ function registerDurable(program, env) {
10967
11263
  await Promise.resolve().then(() => init_runs());
10968
11264
  await runResult(env, runId, withGlobalFormat(options, command));
10969
11265
  });
10970
- runs.command("count").description("How many runs match, in total and per group (durable-function parity)").option("--key <workflowKey>", "Only runs of this workflow key").option("--status <status>", "Only runs with this status").option("--kind <kind>", "Only GRAPH or DURABLE_FN runs").option("--workflow-id <id>", "Only runs with this workflow id").option("--first-run-id <id>", "Only the chain that started with this run").option("--root-run-id <id>", "Only runs under this root run").option("--memo <json>", "Only runs whose memo contains this JSON object").option("--group-by <columns>", "Up to two of status, workflow-key, execution-kind, task-queue (comma separated)").option(...OUTPUT_OPTION).action(async (options, command) => {
11266
+ runs.command("count").description("How many runs match, in total and per group (durable-function parity)").option("--key <workflowKey>", "Only runs of this workflow key").option("--status <status>", "Only runs with this status").option("--kind <kind>", "Only GRAPH or DURABLE_FN runs").option("--workflow-id <id>", "Only runs with this workflow id").option("--first-run-id <id>", "Only the chain that started with this run").option("--root-run-id <id>", "Only runs under this root run").option("--memo <json>", "Only runs whose memo contains this JSON object").option("--group-by <columns>", "Up to two of status, workflow-key, execution-kind, task-queue (comma separated)").option("--group-by-attribute <names>", "Search attributes to group by after --group-by, two columns in all (needs fluidgrids.search-attributes)").option(...OUTPUT_OPTION).action(async (options, command) => {
10971
11267
  await Promise.resolve().then(() => init_runs());
10972
11268
  await runCount(env, withGlobalFormat(options, command));
10973
11269
  });
10974
11270
  addHistory(program, env, "history");
10975
11271
  addSignal(program, env, "signal");
10976
- program.command("replay <history>").description("Replay a history file (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) => {
11272
+ 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) => {
10977
11273
  const resolved = withGlobalFormat(options, command);
10978
11274
  if (resolved.trace || resolved.breakOnMismatch || resolved.inspect !== undefined || resolved.remoteCode) {
10979
11275
  await Promise.resolve().then(() => init_replay_debug());
@@ -11481,10 +11777,10 @@ function createCli(options) {
11481
11777
 
11482
11778
  // src/cli.ts
11483
11779
  var __filename2 = fileURLToPath(import.meta.url);
11484
- var __dirname2 = dirname6(__filename2);
11780
+ var __dirname2 = dirname7(__filename2);
11485
11781
  var version = "0.0.0-dev";
11486
11782
  try {
11487
- const packageJson = JSON.parse(readFileSync13(join12(__dirname2, "../package.json"), "utf8"));
11783
+ const packageJson = JSON.parse(readFileSync13(join13(__dirname2, "../package.json"), "utf8"));
11488
11784
  if (packageJson.version)
11489
11785
  version = packageJson.version;
11490
11786
  } catch {}
@@ -11503,7 +11799,7 @@ try {
11503
11799
  }
11504
11800
  } catch (error) {
11505
11801
  console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
11506
- if (error instanceof CliUserError52 && error.hint)
11802
+ if (error instanceof CliUserError53 && error.hint)
11507
11803
  console.error(`ℹ ${error.hint}`);
11508
- process.exitCode = error instanceof CliUserError52 ? error.exitCode : 1;
11804
+ process.exitCode = error instanceof CliUserError53 ? error.exitCode : 1;
11509
11805
  }