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/runtime.js CHANGED
@@ -35041,7 +35041,7 @@ var KNOWLEDGE_TAG_DEFINITIONS_HELP = 'Tag definitions: [{"tagSlot":"tag1","displ
35041
35041
  var CUSTOM_TOOL_SCHEMA_HELP = 'OpenAI function schema: {"type":"function","function":{"name":"...","parameters":{"type":"object","properties":{}}}}';
35042
35042
  var DISPATCH_ROW_LIMIT_HELP = "Stop after this many eligible rows have run (1-1,000,000). Omit for an unbounded run";
35043
35043
  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';
35044
- 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';
35044
+ 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';
35045
35045
  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';
35046
35046
  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"}]';
35047
35047
  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';
@@ -35504,6 +35504,7 @@ var CLI_CONTRACT = {
35504
35504
  revertWorkflowVersion: {
35505
35505
  confirm: "This overwrites the draft graph with the selected version and cannot be undone."
35506
35506
  },
35507
+ deployWorkflow: { acceptsYes: true },
35507
35508
  rollbackWorkflow: {
35508
35509
  confirm: "This changes which deployed version runs in production for every API and chat consumer."
35509
35510
  },
@@ -38110,6 +38111,8 @@ function addOperationOptions(command, operation, commandSpec, operationSpec) {
38110
38111
  if (commandSpec.confirm) {
38111
38112
  const exemptedByDryRun = operationSpec.query?.dryRun !== undefined || operationSpec.body?.dryRun !== undefined;
38112
38113
  command.option("-y, --yes", exemptedByDryRun ? "Confirm this operation (required unless --dry-run)" : "Confirm this operation (required)");
38114
+ } else if (commandSpec.acceptsYes) {
38115
+ command.option("-y, --yes", "Accepted and ignored: this command needs no confirmation");
38113
38116
  }
38114
38117
  }
38115
38118
 
@@ -43579,137 +43582,6 @@ function lockIdentRenames(hints, lock, isStored) {
43579
43582
  return renames;
43580
43583
  }
43581
43584
 
43582
- // ../workflow-code/src/canonicalize/values.ts
43583
- var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
43584
- var VARIABLE_PREFIX = "variable";
43585
- function toJson(value) {
43586
- if (value === null || typeof value === "string" || typeof value === "boolean")
43587
- return value;
43588
- if (typeof value === "number")
43589
- return Number.isFinite(value) ? value : null;
43590
- if (Array.isArray(value))
43591
- return value.map((item) => item === undefined ? null : toJson(item));
43592
- if (isRecordLike(value)) {
43593
- const result = {};
43594
- for (const [key, member] of Object.entries(value)) {
43595
- if (member !== undefined)
43596
- setOwn(result, key, toJson(member));
43597
- }
43598
- return result;
43599
- }
43600
- return null;
43601
- }
43602
- function rewriteReferences(text, context) {
43603
- if (!text.includes("<"))
43604
- return text;
43605
- return text.replace(REFERENCE_CANDIDATE, (match, inner) => {
43606
- if (!isLikelyWorkflowReferenceSegment(match))
43607
- return match;
43608
- const dot = inner.indexOf(".");
43609
- const prefix = dot === -1 ? inner : inner.slice(0, dot);
43610
- if (prefix === VARIABLE_PREFIX && dot !== -1) {
43611
- return rewriteVariableReference(match, inner.slice(dot + 1), context);
43612
- }
43613
- if (isReservedWorkflowBlockName(prefix))
43614
- return match;
43615
- const normalized = normalizeWorkflowBlockName(prefix);
43616
- if (normalized === prefix || !context.referenceableKeys.has(normalized))
43617
- return match;
43618
- return `<${normalized}${dot === -1 ? "" : inner.slice(dot)}>`;
43619
- });
43620
- }
43621
- function rewriteVariableReference(match, rest, context) {
43622
- const end = rest.search(/[.[]/);
43623
- const name = end === -1 ? rest : rest.slice(0, end);
43624
- const normalized = normalizeWorkflowBlockName(name);
43625
- const target = context.variables.find((entry) => entry.normalizedName === normalized || entry.id === name);
43626
- if (!target || target.key === name)
43627
- return match;
43628
- const firstByName = context.variables.find((entry) => entry.normalizedName === target.key);
43629
- if (firstByName !== target)
43630
- return match;
43631
- return `<variable.${target.key}${end === -1 ? "" : rest.slice(end)}>`;
43632
- }
43633
- function toValue(value, context) {
43634
- if (typeof value === "string")
43635
- return rewriteReferences(value, context);
43636
- if (Array.isArray(value)) {
43637
- return value.map((item) => item === undefined ? null : toValue(item, context));
43638
- }
43639
- if (isRecordLike(value)) {
43640
- if (Object.hasOwn(value, "$sim"))
43641
- return { $sim: "literal", value: toJson(value) };
43642
- const result = {};
43643
- for (const [key, member] of Object.entries(value)) {
43644
- if (member !== undefined)
43645
- setOwn(result, key, toValue(member, context));
43646
- }
43647
- return result;
43648
- }
43649
- return toJson(value);
43650
- }
43651
- function liftResourceId(kind, id, context, location) {
43652
- const key = context.resources?.toKey(kind, id) ?? null;
43653
- if (key !== null)
43654
- return { $sim: "resource", kind, key };
43655
- if (context.resources) {
43656
- context.diagnostics.push({
43657
- code: "W_CANON_UNRESOLVED_ID",
43658
- severity: "warning",
43659
- message: `No ${kind} key for stored id "${id}"; kept verbatim`,
43660
- blockKey: location.blockKey,
43661
- param: location.param
43662
- });
43663
- }
43664
- return { $sim: "unresolved", kind, id };
43665
- }
43666
-
43667
- // ../workflow-code/src/canonicalize/branches.ts
43668
- var UI_ROW_KEYS = new Set([
43669
- "showTags",
43670
- "showEnvVars",
43671
- "searchTerm",
43672
- "cursorPosition",
43673
- "activeSourceBlockId"
43674
- ]);
43675
- var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
43676
- function isBranchExtraField(field) {
43677
- return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
43678
- }
43679
-
43680
- // ../workflow-code/src/canonicalize/subflows.ts
43681
- var PARALLEL_BATCH_MIN = 1;
43682
- var PARALLEL_BATCH_MAX = 20;
43683
- var DEFAULT_LOOP_ITERATIONS = 5;
43684
- function effectiveBatchSize(batchSize) {
43685
- if (batchSize === undefined || Number.isNaN(batchSize))
43686
- return PARALLEL_BATCH_MAX;
43687
- return Math.max(PARALLEL_BATCH_MIN, Math.min(PARALLEL_BATCH_MAX, Math.trunc(batchSize)));
43688
- }
43689
- var SUBFLOW_DATA_KEYS = new Set([
43690
- "count",
43691
- "collection",
43692
- "loopType",
43693
- "whileCondition",
43694
- "doWhileCondition",
43695
- "parallelType",
43696
- "batchSize"
43697
- ]);
43698
- var SUPERSEDED_CONTAINER_PARAMS = new Set([
43699
- ...SUBFLOW_DATA_KEYS,
43700
- "iterations",
43701
- "condition"
43702
- ]);
43703
-
43704
- // ../workflow-code/src/forms/condition.ts
43705
- var ELSE_KEY = "else";
43706
- function branchesAtTopLevel(kind, viaCatalogBuilder) {
43707
- return viaCatalogBuilder && kind === "condition";
43708
- }
43709
- function isElseTrue(kind, key, isLast, value) {
43710
- return kind === "condition" && key === ELSE_KEY && isLast && value.type === "BooleanLiteral" && value.value;
43711
- }
43712
-
43713
43585
  // ../workflow-code/src/compile/hints.ts
43714
43586
  var HINTS = {
43715
43587
  let: "Use const; blocks are immutable declarations.",
@@ -43928,6 +43800,226 @@ function suggestBuilder(written, paths) {
43928
43800
  return didYouMean(root, namespaces, (name) => `${name}.*`);
43929
43801
  }
43930
43802
 
43803
+ // ../workflow-code/src/materialize/values.ts
43804
+ function unliftValue(value, context, location) {
43805
+ if (Array.isArray(value))
43806
+ return value.map((item) => unliftValue(item, context, location));
43807
+ if (!isRecordLike(value))
43808
+ return value;
43809
+ if (isSimNode(value))
43810
+ return unliftNode(value, context, location);
43811
+ const result = {};
43812
+ for (const [key, member] of Object.entries(value)) {
43813
+ if (member !== undefined)
43814
+ setOwn(result, key, unliftValue(member, context, location));
43815
+ }
43816
+ return result;
43817
+ }
43818
+ var LISTED_KEYS = 20;
43819
+ function availableKeysHint(kind, keys, written) {
43820
+ if (keys === undefined)
43821
+ return;
43822
+ if (keys.length === 0)
43823
+ return `This workspace has no ${kind} a source can name yet.`;
43824
+ const near = closest(written, keys);
43825
+ return `${near !== null ? `Did you mean ${near}? ` : ""}Keys: ${listed(keys)}.`;
43826
+ }
43827
+ function listed(keys) {
43828
+ const more = keys.length > LISTED_KEYS ? `, and ${keys.length - LISTED_KEYS} more` : "";
43829
+ return `${keys.slice(0, LISTED_KEYS).join(", ")}${more}`;
43830
+ }
43831
+ function variableHint(written, keys) {
43832
+ if (keys.length === 0) {
43833
+ return "This workflow declares no variables; declare it in the workflow's variables option.";
43834
+ }
43835
+ const near = closest(written, keys);
43836
+ return `${near !== null ? `Did you mean vars.${near}? ` : ""}Variables: ${listed(keys)}.`;
43837
+ }
43838
+ function unliftNode(node, context, location) {
43839
+ switch (node.$sim) {
43840
+ case "literal":
43841
+ return node.value;
43842
+ case "unresolved":
43843
+ return node.id;
43844
+ case "csv":
43845
+ return node.items.map((item) => unliftNode(item, context, location)).join(",");
43846
+ case "var": {
43847
+ const id = context.variableIdByKey.get(node.key);
43848
+ if (id !== undefined)
43849
+ return id;
43850
+ const hint = variableHint(node.key, [...context.variableIdByKey.keys()]);
43851
+ context.diagnostics.push({
43852
+ code: "E_MAT_UNKNOWN_VARIABLE",
43853
+ severity: "error",
43854
+ message: `Variable "${node.key}" does not exist in this workflow`,
43855
+ hint,
43856
+ ...location
43857
+ });
43858
+ return node.key;
43859
+ }
43860
+ case "resource": {
43861
+ const id = context.resources?.toId(node.kind, node.key) ?? null;
43862
+ if (id !== null)
43863
+ return id;
43864
+ const hint = availableKeysHint(node.kind, context.resources?.keysOf?.(node.kind), node.key);
43865
+ context.diagnostics.push({
43866
+ code: "E_MAT_UNKNOWN_RESOURCE",
43867
+ severity: "error",
43868
+ message: `No ${node.kind} "${node.key}" in this workspace`,
43869
+ ...hint !== undefined ? { hint } : {},
43870
+ ...location
43871
+ });
43872
+ return node.key;
43873
+ }
43874
+ }
43875
+ }
43876
+ function renamedReferenceRewriter(renames) {
43877
+ const targets = new Map;
43878
+ for (const { from, to } of renames) {
43879
+ const key = from.toLowerCase();
43880
+ if (!targets.has(key))
43881
+ targets.set(key, to);
43882
+ }
43883
+ if (targets.size === 0)
43884
+ return (text) => text;
43885
+ const pattern = new RegExp(`<(${[...targets.keys()].map(escapeRegExp).join("|")})\\.`, "gi");
43886
+ return (text) => text.includes("<") ? text.replace(pattern, (token, from) => {
43887
+ const to = targets.get(from.toLowerCase());
43888
+ return to === undefined ? token : `<${to}.`;
43889
+ }) : text;
43890
+ }
43891
+
43892
+ // ../workflow-code/src/canonicalize/values.ts
43893
+ var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
43894
+ var VARIABLE_PREFIX = "variable";
43895
+ function toJson(value) {
43896
+ if (value === null || typeof value === "string" || typeof value === "boolean")
43897
+ return value;
43898
+ if (typeof value === "number")
43899
+ return Number.isFinite(value) ? value : null;
43900
+ if (Array.isArray(value))
43901
+ return value.map((item) => item === undefined ? null : toJson(item));
43902
+ if (isRecordLike(value)) {
43903
+ const result = {};
43904
+ for (const [key, member] of Object.entries(value)) {
43905
+ if (member !== undefined)
43906
+ setOwn(result, key, toJson(member));
43907
+ }
43908
+ return result;
43909
+ }
43910
+ return null;
43911
+ }
43912
+ function rewriteReferences(text, context) {
43913
+ if (!text.includes("<"))
43914
+ return text;
43915
+ return text.replace(REFERENCE_CANDIDATE, (match, inner) => {
43916
+ if (!isLikelyWorkflowReferenceSegment(match))
43917
+ return match;
43918
+ const dot = inner.indexOf(".");
43919
+ const prefix = dot === -1 ? inner : inner.slice(0, dot);
43920
+ if (prefix === VARIABLE_PREFIX && dot !== -1) {
43921
+ return rewriteVariableReference(match, inner.slice(dot + 1), context);
43922
+ }
43923
+ if (isReservedWorkflowBlockName(prefix))
43924
+ return match;
43925
+ const normalized = normalizeWorkflowBlockName(prefix);
43926
+ if (normalized === prefix || !context.referenceableKeys.has(normalized))
43927
+ return match;
43928
+ return `<${normalized}${dot === -1 ? "" : inner.slice(dot)}>`;
43929
+ });
43930
+ }
43931
+ function rewriteVariableReference(match, rest, context) {
43932
+ const end = rest.search(/[.[]/);
43933
+ const name = end === -1 ? rest : rest.slice(0, end);
43934
+ const normalized = normalizeWorkflowBlockName(name);
43935
+ const target = context.variables.find((entry) => entry.normalizedName === normalized || entry.id === name);
43936
+ if (!target || target.key === name)
43937
+ return match;
43938
+ const firstByName = context.variables.find((entry) => entry.normalizedName === target.key);
43939
+ if (firstByName !== target)
43940
+ return match;
43941
+ return `<variable.${target.key}${end === -1 ? "" : rest.slice(end)}>`;
43942
+ }
43943
+ function toValue(value, context) {
43944
+ if (typeof value === "string")
43945
+ return rewriteReferences(value, context);
43946
+ if (Array.isArray(value)) {
43947
+ return value.map((item) => item === undefined ? null : toValue(item, context));
43948
+ }
43949
+ if (isRecordLike(value)) {
43950
+ if (Object.hasOwn(value, "$sim"))
43951
+ return { $sim: "literal", value: toJson(value) };
43952
+ const result = {};
43953
+ for (const [key, member] of Object.entries(value)) {
43954
+ if (member !== undefined)
43955
+ setOwn(result, key, toValue(member, context));
43956
+ }
43957
+ return result;
43958
+ }
43959
+ return toJson(value);
43960
+ }
43961
+ function liftResourceId(kind, id, context, location) {
43962
+ const key = context.resources?.toKey(kind, id) ?? null;
43963
+ if (key !== null)
43964
+ return { $sim: "resource", kind, key };
43965
+ if (context.resources) {
43966
+ context.diagnostics.push({
43967
+ code: "W_CANON_UNRESOLVED_ID",
43968
+ severity: "warning",
43969
+ message: `No ${kind} key for stored id "${id}"; kept verbatim`,
43970
+ blockKey: location.blockKey,
43971
+ param: location.param
43972
+ });
43973
+ }
43974
+ return { $sim: "unresolved", kind, id };
43975
+ }
43976
+
43977
+ // ../workflow-code/src/canonicalize/branches.ts
43978
+ var UI_ROW_KEYS = new Set([
43979
+ "showTags",
43980
+ "showEnvVars",
43981
+ "searchTerm",
43982
+ "cursorPosition",
43983
+ "activeSourceBlockId"
43984
+ ]);
43985
+ var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
43986
+ function isBranchExtraField(field) {
43987
+ return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
43988
+ }
43989
+
43990
+ // ../workflow-code/src/canonicalize/subflows.ts
43991
+ var PARALLEL_BATCH_MIN = 1;
43992
+ var PARALLEL_BATCH_MAX = 20;
43993
+ var DEFAULT_LOOP_ITERATIONS = 5;
43994
+ function effectiveBatchSize(batchSize) {
43995
+ if (batchSize === undefined || Number.isNaN(batchSize))
43996
+ return PARALLEL_BATCH_MAX;
43997
+ return Math.max(PARALLEL_BATCH_MIN, Math.min(PARALLEL_BATCH_MAX, Math.trunc(batchSize)));
43998
+ }
43999
+ var SUBFLOW_DATA_KEYS = new Set([
44000
+ "count",
44001
+ "collection",
44002
+ "loopType",
44003
+ "whileCondition",
44004
+ "doWhileCondition",
44005
+ "parallelType",
44006
+ "batchSize"
44007
+ ]);
44008
+ var SUPERSEDED_CONTAINER_PARAMS = new Set([
44009
+ ...SUBFLOW_DATA_KEYS,
44010
+ "iterations",
44011
+ "condition"
44012
+ ]);
44013
+
44014
+ // ../workflow-code/src/forms/condition.ts
44015
+ var ELSE_KEY = "else";
44016
+ function branchesAtTopLevel(kind, viaCatalogBuilder) {
44017
+ return viaCatalogBuilder && kind === "condition";
44018
+ }
44019
+ function isElseTrue(kind, key, isLast, value) {
44020
+ return kind === "condition" && key === ELSE_KEY && isLast && value.type === "BooleanLiteral" && value.value;
44021
+ }
44022
+
43931
44023
  // ../workflow-code/src/compile/context.ts
43932
44024
  var EDGE_METHODS = new Set(["to", "onError"]);
43933
44025
  function rangeOf(ctx, node) {
@@ -44540,13 +44632,21 @@ function checkCodeFileRefs(ctx, renamed) {
44540
44632
  const byIdent = ctx.declsByIdent.get(head.name)?.[0];
44541
44633
  const byName = ctx.declsByKey.get(normalizeWorkflowBlockName(head.name));
44542
44634
  const suggested = byIdent ?? byName;
44635
+ const rewritten = (key) => formatMemberPath(REF_ROOT, [{ kind: "name", name: key }, ...rest]);
44543
44636
  ctx.reporter.report("W_UNRESOLVED_REF", `${written} names no block, so it does not resolve at run time.`, at, {
44544
- 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}`),
44637
+ 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}`),
44545
44638
  blockKey
44546
44639
  });
44547
44640
  }
44548
44641
  }
44549
44642
  }
44643
+ function formerBlockHint(ctx, formerKey, renamed, rewritten) {
44644
+ const renamedTo = new Set(renamed.values());
44645
+ const unbound = [...ctx.declsByKey.values()].filter((decl) => !ctx.knownKeys.has(decl.key) && !renamedTo.has(decl.key));
44646
+ const lead = `${REF_ROOT}.${formerKey} is a block this workflow had that ${SOURCE_ENTRY_FILE} no longer declares under that key`;
44647
+ const [only] = unbound;
44648
+ 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.`;
44649
+ }
44550
44650
  function subflowScopeRef(ctx, node, container, members, site) {
44551
44651
  const kind = containerKindOf(container) ?? "loop";
44552
44652
  const known = kind === "loop" ? LOOP_PROPERTIES : PARALLEL_PROPERTIES;
@@ -45305,80 +45405,6 @@ function arrayExpr(elements) {
45305
45405
  };
45306
45406
  }
45307
45407
 
45308
- // ../workflow-code/src/materialize/values.ts
45309
- function unliftValue(value, context, location) {
45310
- if (Array.isArray(value))
45311
- return value.map((item) => unliftValue(item, context, location));
45312
- if (!isRecordLike(value))
45313
- return value;
45314
- if (isSimNode(value))
45315
- return unliftNode(value, context, location);
45316
- const result = {};
45317
- for (const [key, member] of Object.entries(value)) {
45318
- if (member !== undefined)
45319
- setOwn(result, key, unliftValue(member, context, location));
45320
- }
45321
- return result;
45322
- }
45323
- var LISTED_KEYS = 20;
45324
- function availableKeysHint(kind, keys, written) {
45325
- if (keys === undefined)
45326
- return;
45327
- if (keys.length === 0)
45328
- return `This workspace has no ${kind} a source can name yet.`;
45329
- const near = closest(written, keys);
45330
- return `${near !== null ? `Did you mean ${near}? ` : ""}Keys: ${listed(keys)}.`;
45331
- }
45332
- function listed(keys) {
45333
- const more = keys.length > LISTED_KEYS ? `, and ${keys.length - LISTED_KEYS} more` : "";
45334
- return `${keys.slice(0, LISTED_KEYS).join(", ")}${more}`;
45335
- }
45336
- function variableHint(written, keys) {
45337
- if (keys.length === 0) {
45338
- return "This workflow declares no variables; declare it in the workflow's variables option.";
45339
- }
45340
- const near = closest(written, keys);
45341
- return `${near !== null ? `Did you mean vars.${near}? ` : ""}Variables: ${listed(keys)}.`;
45342
- }
45343
- function unliftNode(node, context, location) {
45344
- switch (node.$sim) {
45345
- case "literal":
45346
- return node.value;
45347
- case "unresolved":
45348
- return node.id;
45349
- case "csv":
45350
- return node.items.map((item) => unliftNode(item, context, location)).join(",");
45351
- case "var": {
45352
- const id = context.variableIdByKey.get(node.key);
45353
- if (id !== undefined)
45354
- return id;
45355
- const hint = variableHint(node.key, [...context.variableIdByKey.keys()]);
45356
- context.diagnostics.push({
45357
- code: "E_MAT_UNKNOWN_VARIABLE",
45358
- severity: "error",
45359
- message: `Variable "${node.key}" does not exist in this workflow`,
45360
- hint,
45361
- ...location
45362
- });
45363
- return node.key;
45364
- }
45365
- case "resource": {
45366
- const id = context.resources?.toId(node.kind, node.key) ?? null;
45367
- if (id !== null)
45368
- return id;
45369
- const hint = availableKeysHint(node.kind, context.resources?.keysOf?.(node.kind), node.key);
45370
- context.diagnostics.push({
45371
- code: "E_MAT_UNKNOWN_RESOURCE",
45372
- severity: "error",
45373
- message: `No ${node.kind} "${node.key}" in this workspace`,
45374
- ...hint !== undefined ? { hint } : {},
45375
- ...location
45376
- });
45377
- return node.key;
45378
- }
45379
- }
45380
- }
45381
-
45382
45408
  // ../workflow-code/src/structured/codec.ts
45383
45409
  function liftPlain() {
45384
45410
  return null;
@@ -48874,6 +48900,7 @@ var APPLY_DIAGNOSTIC_CODES = [
48874
48900
  "W_APPLY_CATALOG_MOVED",
48875
48901
  "W_APPLY_PROBABLE_RENAME",
48876
48902
  "E_APPLY_LINT",
48903
+ "E_APPLY_UNRESOLVED_REF",
48877
48904
  "W_APPLY_LINT",
48878
48905
  "W_TABLE_UNKNOWN_COLUMN",
48879
48906
  "E_APPLY_INVALID_SCHEDULE",
@@ -49570,10 +49597,23 @@ function emptyResult(reporter, sdkMajor) {
49570
49597
  };
49571
49598
  }
49572
49599
  var BYTE_ORDER_MARK = "\uFEFF";
49573
- function storedHolds(stored, key, param, value) {
49574
- const held = stored && getOwn(stored.blocks, key);
49575
- const storedParam = held ? getOwn(held.params, param) : undefined;
49576
- return storedParam?.kind === "value" && storedParam.value === value;
49600
+ function storedView(stored, renamed) {
49601
+ const storedKeyOf = new Map([...renamed].map(([from, to]) => [to, from]));
49602
+ const rewrite = renamedReferenceRewriter([...renamed].map(([from, to]) => ({ from, to })));
49603
+ const block = (key) => {
49604
+ if (!stored)
49605
+ return;
49606
+ const storedKey = storedKeyOf.get(key);
49607
+ return getOwn(stored.blocks, key) ?? (storedKey === undefined ? undefined : getOwn(stored.blocks, storedKey));
49608
+ };
49609
+ return {
49610
+ block,
49611
+ holds: (key, param, value) => {
49612
+ const held = block(key);
49613
+ const storedParam = held ? getOwn(held.params, param) : undefined;
49614
+ return storedParam?.kind === "value" && typeof storedParam.value === "string" && rewrite(storedParam.value) === value;
49615
+ }
49616
+ };
49577
49617
  }
49578
49618
  function compileWorkflow(input) {
49579
49619
  const file = input.entry.path;
@@ -49706,7 +49746,9 @@ function compileEntry(input, file, text, reporter) {
49706
49746
  }
49707
49747
  const unread = input.stored === undefined ? input.storedUnread : undefined;
49708
49748
  const unreadRenames = unread ? lockIdentRenames(hints, unread, (key) => Object.hasOwn(unread.blocks, key)) : new Map;
49709
- checkCodeFileRefs(ctx, new Map([...unreadRenames, ...input.renamedKeys ?? []]));
49749
+ const renamed = new Map([...unreadRenames, ...input.renamedKeys ?? []]);
49750
+ checkCodeFileRefs(ctx, renamed);
49751
+ const stored = storedView(input.stored, renamed);
49710
49752
  const refTypes = {
49711
49753
  catalog: input.catalog,
49712
49754
  block: (key) => compiled.get(key),
@@ -49722,7 +49764,7 @@ function compileEntry(input, file, text, reporter) {
49722
49764
  const returned = referencedResultKind(ref.token, refTypes.block);
49723
49765
  if (returned === "typed")
49724
49766
  continue;
49725
- if (storedHolds(input.stored, ref.blockKey, id, value) && referencedResultKind(ref.token, (key) => input.stored && getOwn(input.stored.blocks, key)) === returned) {
49767
+ if (stored.holds(ref.blockKey, id, value) && referencedResultKind(ref.token, stored.block) === returned) {
49726
49768
  continue;
49727
49769
  }
49728
49770
  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, {
@@ -53942,7 +53984,7 @@ var MAX_SNIPPET_BYTES = 4096;
53942
53984
  var PARAMS_COMMAND = "sim workflows source params";
53943
53985
  function sharedRules(group) {
53944
53986
  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.
53945
- - **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\`.
53987
+ - **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).
53946
53988
  - **Look up a builder**: \`${PARAMS_COMMAND} <builder>\` (\`table.upsertRow\`, \`agent\`, \`trigger.schedule\`; a namespace such as \`gmail\` lists its builders), offline.
53947
53989
  - **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}\`.`;
53948
53990
  }
@@ -61780,6 +61822,9 @@ var STRICT_CODES = new Set([
61780
61822
  ]);
61781
61823
  var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
61782
61824
  var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
61825
+ var EDITED_FILE_REFUSALS = new Map([
61826
+ ["W_UNRESOLVED_REF", "E_APPLY_UNRESOLVED_REF"]
61827
+ ]);
61783
61828
  var KEPT_AS_WRITTEN = /[;,] (?:it|the value|the text) is kept as written\.$/;
61784
61829
  function strictMode(options) {
61785
61830
  if (options.strict === undefined)
@@ -61795,8 +61840,8 @@ does not bind (a block added since the get, or every block of a new workflow):
61795
61840
  ${[...STRICT_CODES].map((code) => ` ${code}`).join(`,
61796
61841
  `)}.
61797
61842
  --strict fails on them in every block, except ${[...STORED_EXEMPT_CODES].join(", ")} on a block the
61798
- lock binds (the stored workflow may hold it, and the server then stays quiet); --no-strict never
61799
- fails on a warning. ${[...EDIT_SCOPED_CODES].join(", ")} is reported only on blocks the lock does not
61843
+ lock binds (the stored workflow may hold it, and the server then stays quiet); --no-strict fails
61844
+ 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
61800
61845
  bind, and with --strict on every block.`;
61801
61846
  function strictFlags(command) {
61802
61847
  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");
@@ -62025,6 +62070,18 @@ async function checkWorkflowDir(dir, catalog, options) {
62025
62070
  };
62026
62071
  }) : [];
62027
62072
  const bound = (blockKey) => lock !== undefined && blockKey !== undefined && Object.hasOwn(lock.blocks, blockKey);
62073
+ const written = await readFolderWritten(dir);
62074
+ const edited = (file, blockKey) => {
62075
+ const text = files[file];
62076
+ if (text === undefined)
62077
+ return true;
62078
+ const textDigest = digest(text);
62079
+ if (written.digests[file] === textDigest)
62080
+ return false;
62081
+ const previousFile = lock && blockKey !== undefined && Object.hasOwn(lock.blocks, blockKey) ? lock.blocks[blockKey].codeFile : undefined;
62082
+ return previousFile === undefined || written.digests[previousFile] !== textDigest;
62083
+ };
62084
+ const editedRefusal = (code, file, blockKey) => file !== undefined && file !== SOURCE_ENTRY_FILE && edited(file, blockKey) ? EDITED_FILE_REFUSALS.get(code) : undefined;
62028
62085
  const fails = (code, blockKey) => STRICT_CODES.has(code) && !(STORED_EXEMPT_CODES.has(code) && bound(blockKey)) && (options.strict === "all" || options.strict === "new" && !bound(blockKey));
62029
62086
  const prefix = options.prefix ?? "";
62030
62087
  const reported = (code, blockKey) => !SERVER_ONLY_CODES.has(code) && !(EDIT_SCOPED_CODES.has(code) && options.strict !== "all" && bound(blockKey));
@@ -62032,9 +62089,10 @@ async function checkWorkflowDir(dir, catalog, options) {
62032
62089
  ...compiled.diagnostics.filter((diagnostic) => reported(diagnostic.code, diagnostic.blockKey)),
62033
62090
  ...declared
62034
62091
  ].map(({ code, severity, message, hint, frame, span, blockKey }) => {
62035
- const raised = severity === "warning" && fails(code, blockKey);
62092
+ const refusal = severity === "warning" ? editedRefusal(code, span?.file, blockKey) : undefined;
62093
+ const raised = refusal !== undefined || severity === "warning" && fails(code, blockKey);
62036
62094
  return {
62037
- code,
62095
+ code: refusal ?? code,
62038
62096
  severity: raised ? "error" : severity,
62039
62097
  message: raised ? message.replace(KEPT_AS_WRITTEN, ".") : message,
62040
62098
  ...hint !== undefined ? { hint } : {},
@@ -62772,6 +62830,9 @@ function splitLines2(text) {
62772
62830
  return result;
62773
62831
  }
62774
62832
  // src/commands/protocol/source-status.ts
62833
+ function planFindings(diagnostics, listed) {
62834
+ return diagnostics.filter((finding) => (finding.severity === "error" || finding.severity === "warning" || finding.code === "I_FINDINGS_TRUNCATED") && !listed(finding.code));
62835
+ }
62775
62836
  var STATUS_EXIT_CODES_HELP = `
62776
62837
  Exit codes: 0 clean (nothing to apply, and the server changed nothing since the directory was
62777
62838
  read); ${SOURCE_LOCAL_CHANGES_EXIT_CODE} local changes only (applying writes them); ${SOURCE_DRIFT_EXIT_CODE} the server changed since the
@@ -62816,11 +62877,13 @@ var SERVER_WORDS = {
62816
62877
  moved: "moved on the server",
62817
62878
  added: "added on the server"
62818
62879
  };
62819
- function printStatusReport(format, heading, report, planLine) {
62880
+ function printStatusReport(format, heading, report, planLine, findings) {
62881
+ const shown = findingsOutput(format);
62820
62882
  if (format === "json" || format === "yaml") {
62821
- printDocument(format, report);
62883
+ printDocument(format, findings.length > 0 ? { ...report, ...shown.result(findings) } : report);
62822
62884
  return;
62823
62885
  }
62886
+ shown.print(findings);
62824
62887
  const s = styles3();
62825
62888
  const lines = [s.bold(sanitize(heading))];
62826
62889
  if (report.local.length === 0)
@@ -63025,8 +63088,12 @@ async function readLocalWorkflow(dir) {
63025
63088
  changed: changedFiles(current, written.digests, () => true)
63026
63089
  };
63027
63090
  }
63091
+ function workflowPlanFindings(data) {
63092
+ return planFindings(data.diagnostics, (code) => code === "E_APPLY_STALE");
63093
+ }
63028
63094
  function planSummary(data) {
63029
- const findings = (severity) => data.diagnostics.filter((finding) => finding.severity === severity && finding.code !== "E_APPLY_STALE").length;
63095
+ const planned = workflowPlanFindings(data);
63096
+ const findings = (severity) => planned.filter((finding) => finding.severity === severity).length;
63030
63097
  return {
63031
63098
  blocksAdded: data.diff.blocks.added.length,
63032
63099
  blocksRemoved: data.diff.blocks.removed.length,
@@ -63109,7 +63176,7 @@ function attachWorkflowSourceStatus(source) {
63109
63176
  login
63110
63177
  })
63111
63178
  };
63112
- printStatusReport(output, `Workflow ${workflowId} in ${options.dir}`, report, planLine);
63179
+ printStatusReport(output, `Workflow ${workflowId} in ${options.dir}`, report, planLine, data ? workflowPlanFindings(data) : []);
63113
63180
  setSoftExitCode(statusExitCode(status.state, login));
63114
63181
  });
63115
63182
  }
@@ -64114,9 +64181,13 @@ function planAsApplied(plan, local, target) {
64114
64181
  }
64115
64182
  return plan.map((change) => change.kind === "workflow" && byBase.has(change.key) && change.action !== "noop" ? { kind: change.kind, key: change.key, action: "noop" } : change);
64116
64183
  }
64184
+ function workspacePlanFindings(data) {
64185
+ return planFindings(data.diagnostics, isServerChangeFinding);
64186
+ }
64117
64187
  function planSummary2(data, plan) {
64118
64188
  const count = (...actions) => plan.filter((change) => actions.includes(change.action)).length;
64119
- const findings = (severity) => data.diagnostics.filter((finding) => finding.severity === severity && !isServerChangeFinding(finding.code)).length;
64189
+ const planned = workspacePlanFindings(data);
64190
+ const findings = (severity) => planned.filter((finding) => finding.severity === severity).length;
64120
64191
  return {
64121
64192
  create: count("create"),
64122
64193
  update: count("update", "adopt"),
@@ -64226,7 +64297,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, invoked) => {
64226
64297
  login
64227
64298
  })
64228
64299
  };
64229
- printStatusReport(output, `Workspace ${workspaceId ?? "(no base)"} in ${options.dir}`, report, planLine2);
64300
+ printStatusReport(output, `Workspace ${workspaceId ?? "(no base)"} in ${options.dir}`, report, planLine2, data ? workspacePlanFindings(data) : []);
64230
64301
  setSoftExitCode(statusExitCode(status.state, login));
64231
64302
  }, READ_ONLY);
64232
64303
  });