sim 2.2.33-preview.316.1 → 2.2.33-preview.317.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -34992,7 +34992,7 @@ var KNOWLEDGE_TAG_DEFINITIONS_HELP = 'Tag definitions: [{"tagSlot":"tag1","displ
34992
34992
  var CUSTOM_TOOL_SCHEMA_HELP = 'OpenAI function schema: {"type":"function","function":{"name":"...","parameters":{"type":"object","properties":{}}}}';
34993
34993
  var DISPATCH_ROW_LIMIT_HELP = "Stop after this many eligible rows have run (1-1,000,000). Omit for an unbounded run";
34994
34994
  var FILE_EDIT_HELP = 'One edit object: {"mode":"search_replace","search":"old","content":"new","replaceAll":false}, {"mode":"replace_between","beforeAnchor":"start line","afterAnchor":"end line","content":"new"}, {"mode":"insert_after","anchor":"line","content":"new"}, or {"mode":"delete_between","startAnchor":"first line deleted","endAnchor":"ending line kept"}. Anchored modes also accept occurrence starting at 1';
34995
- var WORKFLOW_OPERATIONS_HELP = 'Edits to apply, in a single batch, keyed by operation_type: [{"operation_type":"add","block_id":"my-fn","params":{"type":"function","name":"My Fn","inputs":{"code":"return {ok:true}"}}},{"operation_type":"edit","block_id":"<uuid>","params":{"name":"Renamed","connections":{"success":"my-fn"}}},{"operation_type":"delete","block_id":"<uuid>"}]. Also extract_from_subflow, whose params carry {"subflowId":"<loop-id>"}, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId';
34995
+ var WORKFLOW_OPERATIONS_HELP = 'Edits to apply, in a single batch, keyed by operation_type: [{"operation_type":"add","block_id":"my-fn","params":{"type":"function","name":"My Fn","inputs":{"code":"return {ok:true}"}}},{"operation_type":"edit","block_id":"<uuid>","params":{"name":"Renamed","connections":{"success":"my-fn"}}},{"operation_type":"delete","block_id":"<uuid>"}]. Also extract_from_subflow, whose params carry {"subflowId":"<loop-id>"}, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId. To move an existing block into a loop or parallel (keeping its id), edit it with params {"parentId":"<loop-id>"}; {"parentId":null} moves it out';
34996
34996
  var WORKFLOW_SET_BLOCK_ENABLED_HELP = 'Blocks to enable or disable, applied after --operations: [{"block_id":"<uuid>","enabled":false}]. Disabling a loop or parallel cascades to its unlocked descendants; enabling a block whose container is disabled is declined';
34997
34997
  var WORKFLOW_VARIABLE_OPERATIONS_HELP = 'Variable changes to apply in order, keyed by operation: [{"operation":"add","name":"my_var","type":"string","value":"hello"},{"operation":"edit","name":"my_var","value":"updated"},{"operation":"delete","name":"my_var"}]';
34998
34998
  var MCP_PARAMETER_DESCRIPTIONS_HELP = 'Per-field description overrides applied to the schema generated from the deployed workflow inputs, as [{"name":"email","description":"Customer email address"}]. A name matching no input field is ignored';
@@ -35455,6 +35455,7 @@ var CLI_CONTRACT = {
35455
35455
  revertWorkflowVersion: {
35456
35456
  confirm: "This overwrites the draft graph with the selected version and cannot be undone."
35457
35457
  },
35458
+ deployWorkflow: { acceptsYes: true },
35458
35459
  rollbackWorkflow: {
35459
35460
  confirm: "This changes which deployed version runs in production for every API and chat consumer."
35460
35461
  },
@@ -38061,6 +38062,8 @@ function addOperationOptions(command, operation, commandSpec, operationSpec) {
38061
38062
  if (commandSpec.confirm) {
38062
38063
  const exemptedByDryRun = operationSpec.query?.dryRun !== undefined || operationSpec.body?.dryRun !== undefined;
38063
38064
  command.option("-y, --yes", exemptedByDryRun ? "Confirm this operation (required unless --dry-run)" : "Confirm this operation (required)");
38065
+ } else if (commandSpec.acceptsYes) {
38066
+ command.option("-y, --yes", "Accepted and ignored: this command needs no confirmation");
38064
38067
  }
38065
38068
  }
38066
38069
 
@@ -43530,137 +43533,6 @@ function lockIdentRenames(hints, lock, isStored) {
43530
43533
  return renames;
43531
43534
  }
43532
43535
 
43533
- // ../workflow-code/src/canonicalize/values.ts
43534
- var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
43535
- var VARIABLE_PREFIX = "variable";
43536
- function toJson(value) {
43537
- if (value === null || typeof value === "string" || typeof value === "boolean")
43538
- return value;
43539
- if (typeof value === "number")
43540
- return Number.isFinite(value) ? value : null;
43541
- if (Array.isArray(value))
43542
- return value.map((item) => item === undefined ? null : toJson(item));
43543
- if (isRecordLike(value)) {
43544
- const result = {};
43545
- for (const [key, member] of Object.entries(value)) {
43546
- if (member !== undefined)
43547
- setOwn(result, key, toJson(member));
43548
- }
43549
- return result;
43550
- }
43551
- return null;
43552
- }
43553
- function rewriteReferences(text, context) {
43554
- if (!text.includes("<"))
43555
- return text;
43556
- return text.replace(REFERENCE_CANDIDATE, (match, inner) => {
43557
- if (!isLikelyWorkflowReferenceSegment(match))
43558
- return match;
43559
- const dot = inner.indexOf(".");
43560
- const prefix = dot === -1 ? inner : inner.slice(0, dot);
43561
- if (prefix === VARIABLE_PREFIX && dot !== -1) {
43562
- return rewriteVariableReference(match, inner.slice(dot + 1), context);
43563
- }
43564
- if (isReservedWorkflowBlockName(prefix))
43565
- return match;
43566
- const normalized = normalizeWorkflowBlockName(prefix);
43567
- if (normalized === prefix || !context.referenceableKeys.has(normalized))
43568
- return match;
43569
- return `<${normalized}${dot === -1 ? "" : inner.slice(dot)}>`;
43570
- });
43571
- }
43572
- function rewriteVariableReference(match, rest, context) {
43573
- const end = rest.search(/[.[]/);
43574
- const name = end === -1 ? rest : rest.slice(0, end);
43575
- const normalized = normalizeWorkflowBlockName(name);
43576
- const target = context.variables.find((entry) => entry.normalizedName === normalized || entry.id === name);
43577
- if (!target || target.key === name)
43578
- return match;
43579
- const firstByName = context.variables.find((entry) => entry.normalizedName === target.key);
43580
- if (firstByName !== target)
43581
- return match;
43582
- return `<variable.${target.key}${end === -1 ? "" : rest.slice(end)}>`;
43583
- }
43584
- function toValue(value, context) {
43585
- if (typeof value === "string")
43586
- return rewriteReferences(value, context);
43587
- if (Array.isArray(value)) {
43588
- return value.map((item) => item === undefined ? null : toValue(item, context));
43589
- }
43590
- if (isRecordLike(value)) {
43591
- if (Object.hasOwn(value, "$sim"))
43592
- return { $sim: "literal", value: toJson(value) };
43593
- const result = {};
43594
- for (const [key, member] of Object.entries(value)) {
43595
- if (member !== undefined)
43596
- setOwn(result, key, toValue(member, context));
43597
- }
43598
- return result;
43599
- }
43600
- return toJson(value);
43601
- }
43602
- function liftResourceId(kind, id, context, location) {
43603
- const key = context.resources?.toKey(kind, id) ?? null;
43604
- if (key !== null)
43605
- return { $sim: "resource", kind, key };
43606
- if (context.resources) {
43607
- context.diagnostics.push({
43608
- code: "W_CANON_UNRESOLVED_ID",
43609
- severity: "warning",
43610
- message: `No ${kind} key for stored id "${id}"; kept verbatim`,
43611
- blockKey: location.blockKey,
43612
- param: location.param
43613
- });
43614
- }
43615
- return { $sim: "unresolved", kind, id };
43616
- }
43617
-
43618
- // ../workflow-code/src/canonicalize/branches.ts
43619
- var UI_ROW_KEYS = new Set([
43620
- "showTags",
43621
- "showEnvVars",
43622
- "searchTerm",
43623
- "cursorPosition",
43624
- "activeSourceBlockId"
43625
- ]);
43626
- var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
43627
- function isBranchExtraField(field) {
43628
- return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
43629
- }
43630
-
43631
- // ../workflow-code/src/canonicalize/subflows.ts
43632
- var PARALLEL_BATCH_MIN = 1;
43633
- var PARALLEL_BATCH_MAX = 20;
43634
- var DEFAULT_LOOP_ITERATIONS = 5;
43635
- function effectiveBatchSize(batchSize) {
43636
- if (batchSize === undefined || Number.isNaN(batchSize))
43637
- return PARALLEL_BATCH_MAX;
43638
- return Math.max(PARALLEL_BATCH_MIN, Math.min(PARALLEL_BATCH_MAX, Math.trunc(batchSize)));
43639
- }
43640
- var SUBFLOW_DATA_KEYS = new Set([
43641
- "count",
43642
- "collection",
43643
- "loopType",
43644
- "whileCondition",
43645
- "doWhileCondition",
43646
- "parallelType",
43647
- "batchSize"
43648
- ]);
43649
- var SUPERSEDED_CONTAINER_PARAMS = new Set([
43650
- ...SUBFLOW_DATA_KEYS,
43651
- "iterations",
43652
- "condition"
43653
- ]);
43654
-
43655
- // ../workflow-code/src/forms/condition.ts
43656
- var ELSE_KEY = "else";
43657
- function branchesAtTopLevel(kind, viaCatalogBuilder) {
43658
- return viaCatalogBuilder && kind === "condition";
43659
- }
43660
- function isElseTrue(kind, key, isLast, value) {
43661
- return kind === "condition" && key === ELSE_KEY && isLast && value.type === "BooleanLiteral" && value.value;
43662
- }
43663
-
43664
43536
  // ../workflow-code/src/compile/hints.ts
43665
43537
  var HINTS = {
43666
43538
  let: "Use const; blocks are immutable declarations.",
@@ -43879,6 +43751,226 @@ function suggestBuilder(written, paths) {
43879
43751
  return didYouMean(root, namespaces, (name) => `${name}.*`);
43880
43752
  }
43881
43753
 
43754
+ // ../workflow-code/src/materialize/values.ts
43755
+ function unliftValue(value, context, location) {
43756
+ if (Array.isArray(value))
43757
+ return value.map((item) => unliftValue(item, context, location));
43758
+ if (!isRecordLike(value))
43759
+ return value;
43760
+ if (isSimNode(value))
43761
+ return unliftNode(value, context, location);
43762
+ const result = {};
43763
+ for (const [key, member] of Object.entries(value)) {
43764
+ if (member !== undefined)
43765
+ setOwn(result, key, unliftValue(member, context, location));
43766
+ }
43767
+ return result;
43768
+ }
43769
+ var LISTED_KEYS = 20;
43770
+ function availableKeysHint(kind, keys, written) {
43771
+ if (keys === undefined)
43772
+ return;
43773
+ if (keys.length === 0)
43774
+ return `This workspace has no ${kind} a source can name yet.`;
43775
+ const near = closest(written, keys);
43776
+ return `${near !== null ? `Did you mean ${near}? ` : ""}Keys: ${listed(keys)}.`;
43777
+ }
43778
+ function listed(keys) {
43779
+ const more = keys.length > LISTED_KEYS ? `, and ${keys.length - LISTED_KEYS} more` : "";
43780
+ return `${keys.slice(0, LISTED_KEYS).join(", ")}${more}`;
43781
+ }
43782
+ function variableHint(written, keys) {
43783
+ if (keys.length === 0) {
43784
+ return "This workflow declares no variables; declare it in the workflow's variables option.";
43785
+ }
43786
+ const near = closest(written, keys);
43787
+ return `${near !== null ? `Did you mean vars.${near}? ` : ""}Variables: ${listed(keys)}.`;
43788
+ }
43789
+ function unliftNode(node, context, location) {
43790
+ switch (node.$sim) {
43791
+ case "literal":
43792
+ return node.value;
43793
+ case "unresolved":
43794
+ return node.id;
43795
+ case "csv":
43796
+ return node.items.map((item) => unliftNode(item, context, location)).join(",");
43797
+ case "var": {
43798
+ const id = context.variableIdByKey.get(node.key);
43799
+ if (id !== undefined)
43800
+ return id;
43801
+ const hint = variableHint(node.key, [...context.variableIdByKey.keys()]);
43802
+ context.diagnostics.push({
43803
+ code: "E_MAT_UNKNOWN_VARIABLE",
43804
+ severity: "error",
43805
+ message: `Variable "${node.key}" does not exist in this workflow`,
43806
+ hint,
43807
+ ...location
43808
+ });
43809
+ return node.key;
43810
+ }
43811
+ case "resource": {
43812
+ const id = context.resources?.toId(node.kind, node.key) ?? null;
43813
+ if (id !== null)
43814
+ return id;
43815
+ const hint = availableKeysHint(node.kind, context.resources?.keysOf?.(node.kind), node.key);
43816
+ context.diagnostics.push({
43817
+ code: "E_MAT_UNKNOWN_RESOURCE",
43818
+ severity: "error",
43819
+ message: `No ${node.kind} "${node.key}" in this workspace`,
43820
+ ...hint !== undefined ? { hint } : {},
43821
+ ...location
43822
+ });
43823
+ return node.key;
43824
+ }
43825
+ }
43826
+ }
43827
+ function renamedReferenceRewriter(renames) {
43828
+ const targets = new Map;
43829
+ for (const { from, to } of renames) {
43830
+ const key = from.toLowerCase();
43831
+ if (!targets.has(key))
43832
+ targets.set(key, to);
43833
+ }
43834
+ if (targets.size === 0)
43835
+ return (text) => text;
43836
+ const pattern = new RegExp(`<(${[...targets.keys()].map(escapeRegExp).join("|")})\\.`, "gi");
43837
+ return (text) => text.includes("<") ? text.replace(pattern, (token, from) => {
43838
+ const to = targets.get(from.toLowerCase());
43839
+ return to === undefined ? token : `<${to}.`;
43840
+ }) : text;
43841
+ }
43842
+
43843
+ // ../workflow-code/src/canonicalize/values.ts
43844
+ var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
43845
+ var VARIABLE_PREFIX = "variable";
43846
+ function toJson(value) {
43847
+ if (value === null || typeof value === "string" || typeof value === "boolean")
43848
+ return value;
43849
+ if (typeof value === "number")
43850
+ return Number.isFinite(value) ? value : null;
43851
+ if (Array.isArray(value))
43852
+ return value.map((item) => item === undefined ? null : toJson(item));
43853
+ if (isRecordLike(value)) {
43854
+ const result = {};
43855
+ for (const [key, member] of Object.entries(value)) {
43856
+ if (member !== undefined)
43857
+ setOwn(result, key, toJson(member));
43858
+ }
43859
+ return result;
43860
+ }
43861
+ return null;
43862
+ }
43863
+ function rewriteReferences(text, context) {
43864
+ if (!text.includes("<"))
43865
+ return text;
43866
+ return text.replace(REFERENCE_CANDIDATE, (match, inner) => {
43867
+ if (!isLikelyWorkflowReferenceSegment(match))
43868
+ return match;
43869
+ const dot = inner.indexOf(".");
43870
+ const prefix = dot === -1 ? inner : inner.slice(0, dot);
43871
+ if (prefix === VARIABLE_PREFIX && dot !== -1) {
43872
+ return rewriteVariableReference(match, inner.slice(dot + 1), context);
43873
+ }
43874
+ if (isReservedWorkflowBlockName(prefix))
43875
+ return match;
43876
+ const normalized = normalizeWorkflowBlockName(prefix);
43877
+ if (normalized === prefix || !context.referenceableKeys.has(normalized))
43878
+ return match;
43879
+ return `<${normalized}${dot === -1 ? "" : inner.slice(dot)}>`;
43880
+ });
43881
+ }
43882
+ function rewriteVariableReference(match, rest, context) {
43883
+ const end = rest.search(/[.[]/);
43884
+ const name = end === -1 ? rest : rest.slice(0, end);
43885
+ const normalized = normalizeWorkflowBlockName(name);
43886
+ const target = context.variables.find((entry) => entry.normalizedName === normalized || entry.id === name);
43887
+ if (!target || target.key === name)
43888
+ return match;
43889
+ const firstByName = context.variables.find((entry) => entry.normalizedName === target.key);
43890
+ if (firstByName !== target)
43891
+ return match;
43892
+ return `<variable.${target.key}${end === -1 ? "" : rest.slice(end)}>`;
43893
+ }
43894
+ function toValue(value, context) {
43895
+ if (typeof value === "string")
43896
+ return rewriteReferences(value, context);
43897
+ if (Array.isArray(value)) {
43898
+ return value.map((item) => item === undefined ? null : toValue(item, context));
43899
+ }
43900
+ if (isRecordLike(value)) {
43901
+ if (Object.hasOwn(value, "$sim"))
43902
+ return { $sim: "literal", value: toJson(value) };
43903
+ const result = {};
43904
+ for (const [key, member] of Object.entries(value)) {
43905
+ if (member !== undefined)
43906
+ setOwn(result, key, toValue(member, context));
43907
+ }
43908
+ return result;
43909
+ }
43910
+ return toJson(value);
43911
+ }
43912
+ function liftResourceId(kind, id, context, location) {
43913
+ const key = context.resources?.toKey(kind, id) ?? null;
43914
+ if (key !== null)
43915
+ return { $sim: "resource", kind, key };
43916
+ if (context.resources) {
43917
+ context.diagnostics.push({
43918
+ code: "W_CANON_UNRESOLVED_ID",
43919
+ severity: "warning",
43920
+ message: `No ${kind} key for stored id "${id}"; kept verbatim`,
43921
+ blockKey: location.blockKey,
43922
+ param: location.param
43923
+ });
43924
+ }
43925
+ return { $sim: "unresolved", kind, id };
43926
+ }
43927
+
43928
+ // ../workflow-code/src/canonicalize/branches.ts
43929
+ var UI_ROW_KEYS = new Set([
43930
+ "showTags",
43931
+ "showEnvVars",
43932
+ "searchTerm",
43933
+ "cursorPosition",
43934
+ "activeSourceBlockId"
43935
+ ]);
43936
+ var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
43937
+ function isBranchExtraField(field) {
43938
+ return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
43939
+ }
43940
+
43941
+ // ../workflow-code/src/canonicalize/subflows.ts
43942
+ var PARALLEL_BATCH_MIN = 1;
43943
+ var PARALLEL_BATCH_MAX = 20;
43944
+ var DEFAULT_LOOP_ITERATIONS = 5;
43945
+ function effectiveBatchSize(batchSize) {
43946
+ if (batchSize === undefined || Number.isNaN(batchSize))
43947
+ return PARALLEL_BATCH_MAX;
43948
+ return Math.max(PARALLEL_BATCH_MIN, Math.min(PARALLEL_BATCH_MAX, Math.trunc(batchSize)));
43949
+ }
43950
+ var SUBFLOW_DATA_KEYS = new Set([
43951
+ "count",
43952
+ "collection",
43953
+ "loopType",
43954
+ "whileCondition",
43955
+ "doWhileCondition",
43956
+ "parallelType",
43957
+ "batchSize"
43958
+ ]);
43959
+ var SUPERSEDED_CONTAINER_PARAMS = new Set([
43960
+ ...SUBFLOW_DATA_KEYS,
43961
+ "iterations",
43962
+ "condition"
43963
+ ]);
43964
+
43965
+ // ../workflow-code/src/forms/condition.ts
43966
+ var ELSE_KEY = "else";
43967
+ function branchesAtTopLevel(kind, viaCatalogBuilder) {
43968
+ return viaCatalogBuilder && kind === "condition";
43969
+ }
43970
+ function isElseTrue(kind, key, isLast, value) {
43971
+ return kind === "condition" && key === ELSE_KEY && isLast && value.type === "BooleanLiteral" && value.value;
43972
+ }
43973
+
43882
43974
  // ../workflow-code/src/compile/context.ts
43883
43975
  var EDGE_METHODS = new Set(["to", "onError"]);
43884
43976
  function rangeOf(ctx, node) {
@@ -44491,13 +44583,21 @@ function checkCodeFileRefs(ctx, renamed) {
44491
44583
  const byIdent = ctx.declsByIdent.get(head.name)?.[0];
44492
44584
  const byName = ctx.declsByKey.get(normalizeWorkflowBlockName(head.name));
44493
44585
  const suggested = byIdent ?? byName;
44586
+ const rewritten = (key) => formatMemberPath(REF_ROOT, [{ kind: "name", name: key }, ...rest]);
44494
44587
  ctx.reporter.report("W_UNRESOLVED_REF", `${written} names no block, so it does not resolve at run time.`, at, {
44495
- hint: suggested ? `${REF_ROOT} names a block by its key: write ${formatMemberPath(REF_ROOT, [{ kind: "name", name: suggested.key }, ...rest])}.` : () => didYouMean(head.name, ctx.declsByKey.keys(), (key) => `${REF_ROOT}.${key}`),
44588
+ hint: suggested ? `${REF_ROOT} names a block by its key: write ${rewritten(suggested.key)}.` : ctx.knownKeys.has(head.name) ? formerBlockHint(ctx, head.name, renamed, rewritten) : () => didYouMean(head.name, ctx.declsByKey.keys(), (key) => `${REF_ROOT}.${key}`),
44496
44589
  blockKey
44497
44590
  });
44498
44591
  }
44499
44592
  }
44500
44593
  }
44594
+ function formerBlockHint(ctx, formerKey, renamed, rewritten) {
44595
+ const renamedTo = new Set(renamed.values());
44596
+ const unbound = [...ctx.declsByKey.values()].filter((decl) => !ctx.knownKeys.has(decl.key) && !renamedTo.has(decl.key));
44597
+ const lead = `${REF_ROOT}.${formerKey} is a block this workflow had that ${SOURCE_ENTRY_FILE} no longer declares under that key`;
44598
+ const [only] = unbound;
44599
+ return unbound.length === 1 && only ? `${lead}: if ${only.name} is it renamed, write ${rewritten(only.key)}.` : `${lead}: if you renamed it, write ${REF_ROOT}.<its new key>, the display name lowercased with whitespace and dots removed.`;
44600
+ }
44501
44601
  function subflowScopeRef(ctx, node, container, members, site) {
44502
44602
  const kind = containerKindOf(container) ?? "loop";
44503
44603
  const known = kind === "loop" ? LOOP_PROPERTIES : PARALLEL_PROPERTIES;
@@ -45256,80 +45356,6 @@ function arrayExpr(elements) {
45256
45356
  };
45257
45357
  }
45258
45358
 
45259
- // ../workflow-code/src/materialize/values.ts
45260
- function unliftValue(value, context, location) {
45261
- if (Array.isArray(value))
45262
- return value.map((item) => unliftValue(item, context, location));
45263
- if (!isRecordLike(value))
45264
- return value;
45265
- if (isSimNode(value))
45266
- return unliftNode(value, context, location);
45267
- const result = {};
45268
- for (const [key, member] of Object.entries(value)) {
45269
- if (member !== undefined)
45270
- setOwn(result, key, unliftValue(member, context, location));
45271
- }
45272
- return result;
45273
- }
45274
- var LISTED_KEYS = 20;
45275
- function availableKeysHint(kind, keys, written) {
45276
- if (keys === undefined)
45277
- return;
45278
- if (keys.length === 0)
45279
- return `This workspace has no ${kind} a source can name yet.`;
45280
- const near = closest(written, keys);
45281
- return `${near !== null ? `Did you mean ${near}? ` : ""}Keys: ${listed(keys)}.`;
45282
- }
45283
- function listed(keys) {
45284
- const more = keys.length > LISTED_KEYS ? `, and ${keys.length - LISTED_KEYS} more` : "";
45285
- return `${keys.slice(0, LISTED_KEYS).join(", ")}${more}`;
45286
- }
45287
- function variableHint(written, keys) {
45288
- if (keys.length === 0) {
45289
- return "This workflow declares no variables; declare it in the workflow's variables option.";
45290
- }
45291
- const near = closest(written, keys);
45292
- return `${near !== null ? `Did you mean vars.${near}? ` : ""}Variables: ${listed(keys)}.`;
45293
- }
45294
- function unliftNode(node, context, location) {
45295
- switch (node.$sim) {
45296
- case "literal":
45297
- return node.value;
45298
- case "unresolved":
45299
- return node.id;
45300
- case "csv":
45301
- return node.items.map((item) => unliftNode(item, context, location)).join(",");
45302
- case "var": {
45303
- const id = context.variableIdByKey.get(node.key);
45304
- if (id !== undefined)
45305
- return id;
45306
- const hint = variableHint(node.key, [...context.variableIdByKey.keys()]);
45307
- context.diagnostics.push({
45308
- code: "E_MAT_UNKNOWN_VARIABLE",
45309
- severity: "error",
45310
- message: `Variable "${node.key}" does not exist in this workflow`,
45311
- hint,
45312
- ...location
45313
- });
45314
- return node.key;
45315
- }
45316
- case "resource": {
45317
- const id = context.resources?.toId(node.kind, node.key) ?? null;
45318
- if (id !== null)
45319
- return id;
45320
- const hint = availableKeysHint(node.kind, context.resources?.keysOf?.(node.kind), node.key);
45321
- context.diagnostics.push({
45322
- code: "E_MAT_UNKNOWN_RESOURCE",
45323
- severity: "error",
45324
- message: `No ${node.kind} "${node.key}" in this workspace`,
45325
- ...hint !== undefined ? { hint } : {},
45326
- ...location
45327
- });
45328
- return node.key;
45329
- }
45330
- }
45331
- }
45332
-
45333
45359
  // ../workflow-code/src/structured/codec.ts
45334
45360
  function liftPlain() {
45335
45361
  return null;
@@ -48825,6 +48851,7 @@ var APPLY_DIAGNOSTIC_CODES = [
48825
48851
  "W_APPLY_CATALOG_MOVED",
48826
48852
  "W_APPLY_PROBABLE_RENAME",
48827
48853
  "E_APPLY_LINT",
48854
+ "E_APPLY_UNRESOLVED_REF",
48828
48855
  "W_APPLY_LINT",
48829
48856
  "W_TABLE_UNKNOWN_COLUMN",
48830
48857
  "E_APPLY_INVALID_SCHEDULE",
@@ -49521,10 +49548,23 @@ function emptyResult(reporter, sdkMajor) {
49521
49548
  };
49522
49549
  }
49523
49550
  var BYTE_ORDER_MARK = "\uFEFF";
49524
- function storedHolds(stored, key, param, value) {
49525
- const held = stored && getOwn(stored.blocks, key);
49526
- const storedParam = held ? getOwn(held.params, param) : undefined;
49527
- return storedParam?.kind === "value" && storedParam.value === value;
49551
+ function storedView(stored, renamed) {
49552
+ const storedKeyOf = new Map([...renamed].map(([from, to]) => [to, from]));
49553
+ const rewrite = renamedReferenceRewriter([...renamed].map(([from, to]) => ({ from, to })));
49554
+ const block = (key) => {
49555
+ if (!stored)
49556
+ return;
49557
+ const storedKey = storedKeyOf.get(key);
49558
+ return getOwn(stored.blocks, key) ?? (storedKey === undefined ? undefined : getOwn(stored.blocks, storedKey));
49559
+ };
49560
+ return {
49561
+ block,
49562
+ holds: (key, param, value) => {
49563
+ const held = block(key);
49564
+ const storedParam = held ? getOwn(held.params, param) : undefined;
49565
+ return storedParam?.kind === "value" && typeof storedParam.value === "string" && rewrite(storedParam.value) === value;
49566
+ }
49567
+ };
49528
49568
  }
49529
49569
  function compileWorkflow(input) {
49530
49570
  const file = input.entry.path;
@@ -49657,7 +49697,9 @@ function compileEntry(input, file, text, reporter) {
49657
49697
  }
49658
49698
  const unread = input.stored === undefined ? input.storedUnread : undefined;
49659
49699
  const unreadRenames = unread ? lockIdentRenames(hints, unread, (key) => Object.hasOwn(unread.blocks, key)) : new Map;
49660
- checkCodeFileRefs(ctx, new Map([...unreadRenames, ...input.renamedKeys ?? []]));
49700
+ const renamed = new Map([...unreadRenames, ...input.renamedKeys ?? []]);
49701
+ checkCodeFileRefs(ctx, renamed);
49702
+ const stored = storedView(input.stored, renamed);
49661
49703
  const refTypes = {
49662
49704
  catalog: input.catalog,
49663
49705
  block: (key) => compiled.get(key),
@@ -49673,7 +49715,7 @@ function compileEntry(input, file, text, reporter) {
49673
49715
  const returned = referencedResultKind(ref.token, refTypes.block);
49674
49716
  if (returned === "typed")
49675
49717
  continue;
49676
- if (storedHolds(input.stored, ref.blockKey, id, value) && referencedResultKind(ref.token, (key) => input.stored && getOwn(input.stored.blocks, key)) === returned) {
49718
+ if (stored.holds(ref.blockKey, id, value) && referencedResultKind(ref.token, stored.block) === returned) {
49677
49719
  continue;
49678
49720
  }
49679
49721
  reporter.report("W_JSON_REF_UNTYPED", `Nothing declares the type of ${ref.token}; it is stored bare, so a string value would break the JSON.`, ref.range, {
@@ -53893,7 +53935,7 @@ var MAX_SNIPPET_BYTES = 4096;
53893
53935
  var PARAMS_COMMAND = "sim workflows source params";
53894
53936
  function sharedRules(group) {
53895
53937
  return `- **Identity**: a block is its entry in \`${SOURCE_LOCK_FILE}\`, which binds it by its const name or its display name. Change the display name (first argument) freely: the block keeps its id. Renaming the const too keeps the id when its settings, neighbours or references still tie it to the old block; otherwise the apply refuses it as a delete (\`E_APPLY_BLOCK_DELETE\`), and the dry run names it. Safest: keep the const in the same apply.
53896
- - **References**: in \`${SOURCE_ENTRY_FILE}\` read an output as \`x.content\`, a loop or parallel item as \`p.currentItem\` (\`p.index\`), text as \`\` t\`…\` \`\`, env as \`env.NAME\`. In a function code file (\`codeFile('./functions/x.js')\`) read an output as \`$ref.<key>.<path>\`, the key being the display name lowercased with whitespace and dots removed ("Triage Agent" → \`$ref.triageagent.content\`); in a loop body \`$ref.loop.currentItem\` / \`$ref.loop.index\`, in a parallel \`$ref.parallel.currentItem\` / \`$ref.parallel.index\`; env as \`$env.NAME\`.
53938
+ - **References**: in \`${SOURCE_ENTRY_FILE}\` read an output as \`x.content\`, a loop or parallel item as \`p.currentItem\` (\`p.index\`), text as \`\` t\`…\` \`\`, env as \`env.NAME\`. In a function code file (\`codeFile('./functions/x.js')\`) read an output as \`$ref.<key>.<path>\`, the key being the display name lowercased with whitespace and dots removed ("Triage Agent" → \`$ref.triageagent.content\`); in a loop body \`$ref.loop.currentItem\` / \`$ref.loop.index\`, in a parallel \`$ref.parallel.currentItem\` / \`$ref.parallel.index\`; env as \`$env.NAME\`. A rename keeps its references working: the apply rewrites every \`$ref.<old key>\` in the function files to the new key (and the files it writes back hold it), so leave them or write the new key yourself. A \`$ref\` that names no block is an error in a function file you edited (\`E_APPLY_UNRESOLVED_REF\` in \`check\` and the dry run).
53897
53939
  - **Look up a builder**: \`${PARAMS_COMMAND} <builder>\` (\`table.upsertRow\`, \`agent\`, \`trigger.schedule\`; a namespace such as \`gmail\` lists its builders), offline.
53898
53940
  - **Exit codes**: 0 ok, 1 errors (fix what it printed), ${SOURCE_STALE_EXIT_CODE} stale (\`${group} get --dir <fresh dir>\`, redo the edit there), ${RATE_LIMITED_EXIT_CODE} rate limited, ${SOURCE_BUSY_EXIT_CODE} busy, ${SOURCE_LOCAL_CHANGES_EXIT_CODE}/${SOURCE_DRIFT_EXIT_CODE} \`status\`: your edits / the server changed. Every code: \`${SOURCE_AGENTS_FILE}\`.`;
53899
53941
  }
@@ -61731,6 +61773,9 @@ var STRICT_CODES = new Set([
61731
61773
  ]);
61732
61774
  var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
61733
61775
  var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
61776
+ var EDITED_FILE_REFUSALS = new Map([
61777
+ ["W_UNRESOLVED_REF", "E_APPLY_UNRESOLVED_REF"]
61778
+ ]);
61734
61779
  var KEPT_AS_WRITTEN = /[;,] (?:it|the value|the text) is kept as written\.$/;
61735
61780
  function strictMode(options) {
61736
61781
  if (options.strict === undefined)
@@ -61746,8 +61791,8 @@ does not bind (a block added since the get, or every block of a new workflow):
61746
61791
  ${[...STRICT_CODES].map((code) => ` ${code}`).join(`,
61747
61792
  `)}.
61748
61793
  --strict fails on them in every block, except ${[...STORED_EXEMPT_CODES].join(", ")} on a block the
61749
- lock binds (the stored workflow may hold it, and the server then stays quiet); --no-strict never
61750
- fails on a warning. ${[...EDIT_SCOPED_CODES].join(", ")} is reported only on blocks the lock does not
61794
+ lock binds (the stored workflow may hold it, and the server then stays quiet); --no-strict fails
61795
+ on none of them. In a function file changed since the get, ${[...EDITED_FILE_REFUSALS].map(([warning, refusal]) => `${warning} is the error ${refusal}`).join(", ")} in every mode, as the server refuses it. ${[...EDIT_SCOPED_CODES].join(", ")} is reported only on blocks the lock does not
61751
61796
  bind, and with --strict on every block.`;
61752
61797
  function strictFlags(command) {
61753
61798
  return command.option("--strict", "Fail on the warnings listed below in every block, not only new ones").option("--no-strict", "Never fail on a warning");
@@ -61976,6 +62021,18 @@ async function checkWorkflowDir(dir, catalog, options) {
61976
62021
  };
61977
62022
  }) : [];
61978
62023
  const bound = (blockKey) => lock !== undefined && blockKey !== undefined && Object.hasOwn(lock.blocks, blockKey);
62024
+ const written = await readFolderWritten(dir);
62025
+ const edited = (file, blockKey) => {
62026
+ const text = files[file];
62027
+ if (text === undefined)
62028
+ return true;
62029
+ const textDigest = digest(text);
62030
+ if (written.digests[file] === textDigest)
62031
+ return false;
62032
+ const previousFile = lock && blockKey !== undefined && Object.hasOwn(lock.blocks, blockKey) ? lock.blocks[blockKey].codeFile : undefined;
62033
+ return previousFile === undefined || written.digests[previousFile] !== textDigest;
62034
+ };
62035
+ const editedRefusal = (code, file, blockKey) => file !== undefined && file !== SOURCE_ENTRY_FILE && edited(file, blockKey) ? EDITED_FILE_REFUSALS.get(code) : undefined;
61979
62036
  const fails = (code, blockKey) => STRICT_CODES.has(code) && !(STORED_EXEMPT_CODES.has(code) && bound(blockKey)) && (options.strict === "all" || options.strict === "new" && !bound(blockKey));
61980
62037
  const prefix = options.prefix ?? "";
61981
62038
  const reported = (code, blockKey) => !SERVER_ONLY_CODES.has(code) && !(EDIT_SCOPED_CODES.has(code) && options.strict !== "all" && bound(blockKey));
@@ -61983,9 +62040,10 @@ async function checkWorkflowDir(dir, catalog, options) {
61983
62040
  ...compiled.diagnostics.filter((diagnostic) => reported(diagnostic.code, diagnostic.blockKey)),
61984
62041
  ...declared
61985
62042
  ].map(({ code, severity, message, hint, frame, span, blockKey }) => {
61986
- const raised = severity === "warning" && fails(code, blockKey);
62043
+ const refusal = severity === "warning" ? editedRefusal(code, span?.file, blockKey) : undefined;
62044
+ const raised = refusal !== undefined || severity === "warning" && fails(code, blockKey);
61987
62045
  return {
61988
- code,
62046
+ code: refusal ?? code,
61989
62047
  severity: raised ? "error" : severity,
61990
62048
  message: raised ? message.replace(KEPT_AS_WRITTEN, ".") : message,
61991
62049
  ...hint !== undefined ? { hint } : {},
@@ -62723,6 +62781,9 @@ function splitLines2(text) {
62723
62781
  return result;
62724
62782
  }
62725
62783
  // src/commands/protocol/source-status.ts
62784
+ function planFindings(diagnostics, listed) {
62785
+ return diagnostics.filter((finding) => (finding.severity === "error" || finding.severity === "warning" || finding.code === "I_FINDINGS_TRUNCATED") && !listed(finding.code));
62786
+ }
62726
62787
  var STATUS_EXIT_CODES_HELP = `
62727
62788
  Exit codes: 0 clean (nothing to apply, and the server changed nothing since the directory was
62728
62789
  read); ${SOURCE_LOCAL_CHANGES_EXIT_CODE} local changes only (applying writes them); ${SOURCE_DRIFT_EXIT_CODE} the server changed since the
@@ -62767,11 +62828,13 @@ var SERVER_WORDS = {
62767
62828
  moved: "moved on the server",
62768
62829
  added: "added on the server"
62769
62830
  };
62770
- function printStatusReport(format, heading, report, planLine) {
62831
+ function printStatusReport(format, heading, report, planLine, findings) {
62832
+ const shown = findingsOutput(format);
62771
62833
  if (format === "json" || format === "yaml") {
62772
- printDocument(format, report);
62834
+ printDocument(format, findings.length > 0 ? { ...report, ...shown.result(findings) } : report);
62773
62835
  return;
62774
62836
  }
62837
+ shown.print(findings);
62775
62838
  const s = styles3();
62776
62839
  const lines = [s.bold(sanitize(heading))];
62777
62840
  if (report.local.length === 0)
@@ -62976,8 +63039,12 @@ async function readLocalWorkflow(dir) {
62976
63039
  changed: changedFiles(current, written.digests, () => true)
62977
63040
  };
62978
63041
  }
63042
+ function workflowPlanFindings(data) {
63043
+ return planFindings(data.diagnostics, (code) => code === "E_APPLY_STALE");
63044
+ }
62979
63045
  function planSummary(data) {
62980
- const findings = (severity) => data.diagnostics.filter((finding) => finding.severity === severity && finding.code !== "E_APPLY_STALE").length;
63046
+ const planned = workflowPlanFindings(data);
63047
+ const findings = (severity) => planned.filter((finding) => finding.severity === severity).length;
62981
63048
  return {
62982
63049
  blocksAdded: data.diff.blocks.added.length,
62983
63050
  blocksRemoved: data.diff.blocks.removed.length,
@@ -63060,7 +63127,7 @@ function attachWorkflowSourceStatus(source) {
63060
63127
  login
63061
63128
  })
63062
63129
  };
63063
- printStatusReport(output, `Workflow ${workflowId} in ${options.dir}`, report, planLine);
63130
+ printStatusReport(output, `Workflow ${workflowId} in ${options.dir}`, report, planLine, data ? workflowPlanFindings(data) : []);
63064
63131
  setSoftExitCode(statusExitCode(status.state, login));
63065
63132
  });
63066
63133
  }
@@ -64065,9 +64132,13 @@ function planAsApplied(plan, local, target) {
64065
64132
  }
64066
64133
  return plan.map((change) => change.kind === "workflow" && byBase.has(change.key) && change.action !== "noop" ? { kind: change.kind, key: change.key, action: "noop" } : change);
64067
64134
  }
64135
+ function workspacePlanFindings(data) {
64136
+ return planFindings(data.diagnostics, isServerChangeFinding);
64137
+ }
64068
64138
  function planSummary2(data, plan) {
64069
64139
  const count = (...actions) => plan.filter((change) => actions.includes(change.action)).length;
64070
- const findings = (severity) => data.diagnostics.filter((finding) => finding.severity === severity && !isServerChangeFinding(finding.code)).length;
64140
+ const planned = workspacePlanFindings(data);
64141
+ const findings = (severity) => planned.filter((finding) => finding.severity === severity).length;
64071
64142
  return {
64072
64143
  create: count("create"),
64073
64144
  update: count("update", "adopt"),
@@ -64177,7 +64248,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, invoked) => {
64177
64248
  login
64178
64249
  })
64179
64250
  };
64180
- printStatusReport(output, `Workspace ${workspaceId ?? "(no base)"} in ${options.dir}`, report, planLine2);
64251
+ printStatusReport(output, `Workspace ${workspaceId ?? "(no base)"} in ${options.dir}`, report, planLine2, data ? workspacePlanFindings(data) : []);
64181
64252
  setSoftExitCode(statusExitCode(status.state, login));
64182
64253
  }, READ_ONLY);
64183
64254
  });