agent-contracts 0.23.0 → 0.23.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.
package/dist/cli.js CHANGED
@@ -51005,7 +51005,12 @@ function deepMergeEntities(base, project, path, hasExtends) {
51005
51005
  } else if (isRecord2(baseVal)) {
51006
51006
  result[key] = applyMapMergeOperator(baseVal, projVal, `${path}.${key}`);
51007
51007
  } else {
51008
- result[key] = applyArrayMergeOperator([], projVal, `${path}.${key}`);
51008
+ const op = hasOperator(projVal, `${path}.${key}`);
51009
+ if (op === "$replace") {
51010
+ result[key] = projVal["$replace"];
51011
+ } else {
51012
+ result[key] = applyArrayMergeOperator([], projVal, `${path}.${key}`);
51013
+ }
51009
51014
  }
51010
51015
  } else if (isRecord2(projVal) && isRecord2(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
51011
51016
  result[key] = deepMergeEntities(
@@ -51021,6 +51026,40 @@ function deepMergeEntities(base, project, path, hasExtends) {
51021
51026
  return result;
51022
51027
  }
51023
51028
  var OPERATOR_KEYS = /* @__PURE__ */ new Set(["$append", "$prepend", "$insert_after", "$replace", "$remove"]);
51029
+ function mergeSection(base, project, path, hasExtends, mode) {
51030
+ switch (mode) {
51031
+ case "map": {
51032
+ const baseMap = isRecord2(base) ? base : {};
51033
+ return mergeEntityMaps(baseMap, project, path, hasExtends);
51034
+ }
51035
+ case "array": {
51036
+ const baseArr = Array.isArray(base) ? base : [];
51037
+ if (isRecord2(project) && hasOperator(project, path)) {
51038
+ if (!hasExtends) {
51039
+ throw new MergeError(
51040
+ `Merge operator used without extends at ${path}`
51041
+ );
51042
+ }
51043
+ return applyArrayMergeOperator(baseArr, project, path);
51044
+ }
51045
+ const projArr = Array.isArray(project) ? project : [];
51046
+ return [...baseArr, ...projArr];
51047
+ }
51048
+ case "object": {
51049
+ const baseObj = isRecord2(base) ? base : {};
51050
+ const projObj = isRecord2(project) ? project : {};
51051
+ if (hasOperator(projObj, path)) {
51052
+ if (!hasExtends) {
51053
+ throw new MergeError(
51054
+ `Merge operator used without extends at ${path}`
51055
+ );
51056
+ }
51057
+ return applyMapMergeOperator(baseObj, projObj, path);
51058
+ }
51059
+ return deepMergeEntities(baseObj, projObj, path, hasExtends);
51060
+ }
51061
+ }
51062
+ }
51024
51063
  function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
51025
51064
  let result;
51026
51065
  if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
@@ -51041,9 +51080,10 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
51041
51080
  for (const [key, projVal] of Object.entries(projectMap)) {
51042
51081
  if (OPERATOR_KEYS.has(key)) continue;
51043
51082
  const baseVal = result[key];
51044
- if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
51083
+ if (isRecord2(projVal) && !Array.isArray(projVal)) {
51084
+ const baseObj = isRecord2(baseVal) ? baseVal : {};
51045
51085
  result[key] = deepMergeEntities(
51046
- baseVal,
51086
+ baseObj,
51047
51087
  projVal,
51048
51088
  `${path}.${key}`,
51049
51089
  hasExtends
@@ -51054,44 +51094,33 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
51054
51094
  }
51055
51095
  return result;
51056
51096
  }
51057
- var MERGE_SECTIONS = [
51058
- "agents",
51059
- "tasks",
51060
- "artifacts",
51061
- "tools",
51062
- "validations",
51063
- "handoff_types",
51064
- "imports",
51065
- "workflow",
51066
- "policies",
51067
- "guardrails",
51068
- "guardrail_policies",
51069
- "components",
51070
- "extensions"
51071
- ];
51097
+ var DSL_SECTIONS = {
51098
+ agents: "map",
51099
+ tasks: "map",
51100
+ artifacts: "map",
51101
+ tools: "map",
51102
+ validations: "map",
51103
+ handoff_types: "map",
51104
+ imports: "map",
51105
+ workflow: "map",
51106
+ policies: "map",
51107
+ guardrails: "map",
51108
+ guardrail_policies: "map",
51109
+ components: "map",
51110
+ extensions: "map",
51111
+ system: "object"
51112
+ };
51072
51113
  function mergeDsl(base, project) {
51073
51114
  const hasExtends = typeof project["extends"] === "string";
51074
51115
  const result = { ...base, ...project };
51075
- if (project["system"] && base["system"]) {
51076
- result["system"] = deepMergeEntities(
51077
- base["system"],
51078
- project["system"],
51079
- "system",
51080
- hasExtends
51081
- );
51082
- }
51083
- for (const section of MERGE_SECTIONS) {
51084
- const baseVal = base[section];
51085
- const projVal = project[section];
51086
- if (projVal === void 0) {
51087
- continue;
51088
- }
51089
- const baseMap = isRecord2(baseVal) ? baseVal : {};
51090
- result[section] = mergeEntityMaps(
51091
- baseMap,
51092
- projVal,
51116
+ for (const [section, mode] of Object.entries(DSL_SECTIONS)) {
51117
+ if (project[section] === void 0) continue;
51118
+ result[section] = mergeSection(
51119
+ base[section],
51120
+ project[section],
51093
51121
  section,
51094
- hasExtends
51122
+ hasExtends,
51123
+ mode
51095
51124
  );
51096
51125
  }
51097
51126
  delete result["extends"];
@@ -51188,42 +51217,23 @@ function expandDefaults(data) {
51188
51217
  }
51189
51218
 
51190
51219
  // src/config/binding-merger.ts
51191
- function isRecord3(v2) {
51192
- return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
51193
- }
51194
- var BINDING_MAP_MERGE_SECTIONS = ["guardrail_impl", "outputs"];
51195
- var BINDING_ARRAY_MERGE_SECTIONS = ["renders"];
51220
+ var BINDING_SECTIONS = {
51221
+ guardrail_impl: "map",
51222
+ outputs: "map",
51223
+ renders: "array",
51224
+ reporting: "object"
51225
+ };
51196
51226
  function mergeBinding(base, project) {
51197
51227
  const hasExtends = typeof project["extends"] === "string";
51198
51228
  const result = { ...base, ...project };
51199
- for (const section of BINDING_MAP_MERGE_SECTIONS) {
51200
- const baseVal = base[section];
51201
- const projVal = project[section];
51202
- if (projVal === void 0) {
51203
- continue;
51204
- }
51205
- const baseMap = isRecord3(baseVal) ? baseVal : {};
51206
- result[section] = mergeEntityMaps(
51207
- baseMap,
51208
- projVal,
51229
+ for (const [section, mode] of Object.entries(BINDING_SECTIONS)) {
51230
+ if (project[section] === void 0) continue;
51231
+ result[section] = mergeSection(
51232
+ base[section],
51233
+ project[section],
51209
51234
  section,
51210
- hasExtends
51211
- );
51212
- }
51213
- for (const section of BINDING_ARRAY_MERGE_SECTIONS) {
51214
- const baseVal = base[section];
51215
- const projVal = project[section];
51216
- if (projVal === void 0) continue;
51217
- const baseArr = Array.isArray(baseVal) ? baseVal : [];
51218
- const projArr = Array.isArray(projVal) ? projVal : [];
51219
- result[section] = [...baseArr, ...projArr];
51220
- }
51221
- if (project["reporting"] !== void 0 && isRecord3(base["reporting"]) && isRecord3(project["reporting"])) {
51222
- result["reporting"] = deepMergeEntities(
51223
- base["reporting"],
51224
- project["reporting"],
51225
- "reporting",
51226
- hasExtends
51235
+ hasExtends,
51236
+ mode
51227
51237
  );
51228
51238
  }
51229
51239
  delete result["extends"];
@@ -51437,7 +51447,7 @@ function checkDecisionStepRoutingKey(data) {
51437
51447
  }
51438
51448
  return diagnostics;
51439
51449
  }
51440
- function isRecord4(v2) {
51450
+ function isRecord3(v2) {
51441
51451
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
51442
51452
  }
51443
51453
  function* enumerateEntitiesByType(data, nodeType) {
@@ -51447,41 +51457,41 @@ function* enumerateEntitiesByType(data, nodeType) {
51447
51457
  return;
51448
51458
  case "system": {
51449
51459
  const sys = data["system"];
51450
- if (isRecord4(sys)) yield { path: "system", obj: sys };
51460
+ if (isRecord3(sys)) yield { path: "system", obj: sys };
51451
51461
  return;
51452
51462
  }
51453
51463
  case "agent": {
51454
51464
  const agents = data["agents"];
51455
- if (!isRecord4(agents)) return;
51465
+ if (!isRecord3(agents)) return;
51456
51466
  for (const [id, a3] of Object.entries(agents)) {
51457
- if (isRecord4(a3)) yield { path: `agents.${id}`, obj: a3 };
51467
+ if (isRecord3(a3)) yield { path: `agents.${id}`, obj: a3 };
51458
51468
  }
51459
51469
  return;
51460
51470
  }
51461
51471
  case "rule": {
51462
51472
  const agents = data["agents"];
51463
- if (!isRecord4(agents)) return;
51473
+ if (!isRecord3(agents)) return;
51464
51474
  for (const [aid, a3] of Object.entries(agents)) {
51465
- if (!isRecord4(a3)) continue;
51475
+ if (!isRecord3(a3)) continue;
51466
51476
  const rules = a3["rules"];
51467
51477
  if (!Array.isArray(rules)) continue;
51468
51478
  for (let i3 = 0; i3 < rules.length; i3++) {
51469
51479
  const r3 = rules[i3];
51470
- if (isRecord4(r3)) yield { path: `agents.${aid}.rules[${i3}]`, obj: r3 };
51480
+ if (isRecord3(r3)) yield { path: `agents.${aid}.rules[${i3}]`, obj: r3 };
51471
51481
  }
51472
51482
  }
51473
51483
  return;
51474
51484
  }
51475
51485
  case "escalation_criterion": {
51476
51486
  const agents = data["agents"];
51477
- if (!isRecord4(agents)) return;
51487
+ if (!isRecord3(agents)) return;
51478
51488
  for (const [aid, a3] of Object.entries(agents)) {
51479
- if (!isRecord4(a3)) continue;
51489
+ if (!isRecord3(a3)) continue;
51480
51490
  const esc = a3["escalation_criteria"];
51481
51491
  if (!Array.isArray(esc)) continue;
51482
51492
  for (let i3 = 0; i3 < esc.length; i3++) {
51483
51493
  const e3 = esc[i3];
51484
- if (isRecord4(e3)) {
51494
+ if (isRecord3(e3)) {
51485
51495
  yield {
51486
51496
  path: `agents.${aid}.escalation_criteria[${i3}]`,
51487
51497
  obj: e3
@@ -51493,14 +51503,14 @@ function* enumerateEntitiesByType(data, nodeType) {
51493
51503
  }
51494
51504
  case "prerequisite": {
51495
51505
  const agents = data["agents"];
51496
- if (!isRecord4(agents)) return;
51506
+ if (!isRecord3(agents)) return;
51497
51507
  for (const [aid, a3] of Object.entries(agents)) {
51498
- if (!isRecord4(a3)) continue;
51508
+ if (!isRecord3(a3)) continue;
51499
51509
  const pre = a3["prerequisites"];
51500
51510
  if (!Array.isArray(pre)) continue;
51501
51511
  for (let i3 = 0; i3 < pre.length; i3++) {
51502
51512
  const p2 = pre[i3];
51503
- if (isRecord4(p2)) {
51513
+ if (isRecord3(p2)) {
51504
51514
  yield { path: `agents.${aid}.prerequisites[${i3}]`, obj: p2 };
51505
51515
  }
51506
51516
  }
@@ -51509,22 +51519,22 @@ function* enumerateEntitiesByType(data, nodeType) {
51509
51519
  }
51510
51520
  case "task": {
51511
51521
  const tasks = data["tasks"];
51512
- if (!isRecord4(tasks)) return;
51522
+ if (!isRecord3(tasks)) return;
51513
51523
  for (const [id, t3] of Object.entries(tasks)) {
51514
- if (isRecord4(t3)) yield { path: `tasks.${id}`, obj: t3 };
51524
+ if (isRecord3(t3)) yield { path: `tasks.${id}`, obj: t3 };
51515
51525
  }
51516
51526
  return;
51517
51527
  }
51518
51528
  case "execution_step": {
51519
51529
  const tasks = data["tasks"];
51520
- if (!isRecord4(tasks)) return;
51530
+ if (!isRecord3(tasks)) return;
51521
51531
  for (const [tid, t3] of Object.entries(tasks)) {
51522
- if (!isRecord4(t3)) continue;
51532
+ if (!isRecord3(t3)) continue;
51523
51533
  const steps = t3["execution_steps"];
51524
51534
  if (!Array.isArray(steps)) continue;
51525
51535
  for (let i3 = 0; i3 < steps.length; i3++) {
51526
51536
  const s2 = steps[i3];
51527
- if (isRecord4(s2)) {
51537
+ if (isRecord3(s2)) {
51528
51538
  yield {
51529
51539
  path: `tasks.${tid}.execution_steps[${i3}]`,
51530
51540
  obj: s2
@@ -51536,30 +51546,30 @@ function* enumerateEntitiesByType(data, nodeType) {
51536
51546
  }
51537
51547
  case "artifact": {
51538
51548
  const arts = data["artifacts"];
51539
- if (!isRecord4(arts)) return;
51549
+ if (!isRecord3(arts)) return;
51540
51550
  for (const [id, a3] of Object.entries(arts)) {
51541
- if (isRecord4(a3)) yield { path: `artifacts.${id}`, obj: a3 };
51551
+ if (isRecord3(a3)) yield { path: `artifacts.${id}`, obj: a3 };
51542
51552
  }
51543
51553
  return;
51544
51554
  }
51545
51555
  case "tool": {
51546
51556
  const tools = data["tools"];
51547
- if (!isRecord4(tools)) return;
51557
+ if (!isRecord3(tools)) return;
51548
51558
  for (const [id, t3] of Object.entries(tools)) {
51549
- if (isRecord4(t3)) yield { path: `tools.${id}`, obj: t3 };
51559
+ if (isRecord3(t3)) yield { path: `tools.${id}`, obj: t3 };
51550
51560
  }
51551
51561
  return;
51552
51562
  }
51553
51563
  case "tool_command": {
51554
51564
  const tools = data["tools"];
51555
- if (!isRecord4(tools)) return;
51565
+ if (!isRecord3(tools)) return;
51556
51566
  for (const [tid, t3] of Object.entries(tools)) {
51557
- if (!isRecord4(t3)) continue;
51567
+ if (!isRecord3(t3)) continue;
51558
51568
  const cmds = t3["commands"];
51559
51569
  if (!Array.isArray(cmds)) continue;
51560
51570
  for (let i3 = 0; i3 < cmds.length; i3++) {
51561
51571
  const c2 = cmds[i3];
51562
- if (isRecord4(c2)) {
51572
+ if (isRecord3(c2)) {
51563
51573
  yield { path: `tools.${tid}.commands[${i3}]`, obj: c2 };
51564
51574
  }
51565
51575
  }
@@ -51568,38 +51578,38 @@ function* enumerateEntitiesByType(data, nodeType) {
51568
51578
  }
51569
51579
  case "validation": {
51570
51580
  const vals = data["validations"];
51571
- if (!isRecord4(vals)) return;
51581
+ if (!isRecord3(vals)) return;
51572
51582
  for (const [id, v2] of Object.entries(vals)) {
51573
- if (isRecord4(v2)) yield { path: `validations.${id}`, obj: v2 };
51583
+ if (isRecord3(v2)) yield { path: `validations.${id}`, obj: v2 };
51574
51584
  }
51575
51585
  return;
51576
51586
  }
51577
51587
  case "handoff_type": {
51578
51588
  const ht = data["handoff_types"];
51579
- if (!isRecord4(ht)) return;
51589
+ if (!isRecord3(ht)) return;
51580
51590
  for (const [id, h2] of Object.entries(ht)) {
51581
- if (isRecord4(h2)) yield { path: `handoff_types.${id}`, obj: h2 };
51591
+ if (isRecord3(h2)) yield { path: `handoff_types.${id}`, obj: h2 };
51582
51592
  }
51583
51593
  return;
51584
51594
  }
51585
51595
  case "workflow": {
51586
51596
  const wf = data["workflow"];
51587
- if (!isRecord4(wf)) return;
51597
+ if (!isRecord3(wf)) return;
51588
51598
  for (const [id, w2] of Object.entries(wf)) {
51589
- if (isRecord4(w2)) yield { path: `workflow.${id}`, obj: w2 };
51599
+ if (isRecord3(w2)) yield { path: `workflow.${id}`, obj: w2 };
51590
51600
  }
51591
51601
  return;
51592
51602
  }
51593
51603
  case "workflow_step": {
51594
51604
  const wf = data["workflow"];
51595
- if (!isRecord4(wf)) return;
51605
+ if (!isRecord3(wf)) return;
51596
51606
  for (const [wid, w2] of Object.entries(wf)) {
51597
- if (!isRecord4(w2)) continue;
51607
+ if (!isRecord3(w2)) continue;
51598
51608
  const steps = w2["steps"];
51599
51609
  if (!Array.isArray(steps)) continue;
51600
51610
  for (let i3 = 0; i3 < steps.length; i3++) {
51601
51611
  const s2 = steps[i3];
51602
- if (isRecord4(s2)) {
51612
+ if (isRecord3(s2)) {
51603
51613
  yield { path: `workflow.${wid}.steps[${i3}]`, obj: s2 };
51604
51614
  }
51605
51615
  }
@@ -51608,25 +51618,25 @@ function* enumerateEntitiesByType(data, nodeType) {
51608
51618
  }
51609
51619
  case "policy": {
51610
51620
  const pol = data["policies"];
51611
- if (!isRecord4(pol)) return;
51621
+ if (!isRecord3(pol)) return;
51612
51622
  for (const [id, p2] of Object.entries(pol)) {
51613
- if (isRecord4(p2)) yield { path: `policies.${id}`, obj: p2 };
51623
+ if (isRecord3(p2)) yield { path: `policies.${id}`, obj: p2 };
51614
51624
  }
51615
51625
  return;
51616
51626
  }
51617
51627
  case "guardrail": {
51618
51628
  const gr = data["guardrails"];
51619
- if (!isRecord4(gr)) return;
51629
+ if (!isRecord3(gr)) return;
51620
51630
  for (const [id, g2] of Object.entries(gr)) {
51621
- if (isRecord4(g2)) yield { path: `guardrails.${id}`, obj: g2 };
51631
+ if (isRecord3(g2)) yield { path: `guardrails.${id}`, obj: g2 };
51622
51632
  }
51623
51633
  return;
51624
51634
  }
51625
51635
  case "guardrail_policy": {
51626
51636
  const gp = data["guardrail_policies"];
51627
- if (!isRecord4(gp)) return;
51637
+ if (!isRecord3(gp)) return;
51628
51638
  for (const [id, p2] of Object.entries(gp)) {
51629
- if (isRecord4(p2)) yield { path: `guardrail_policies.${id}`, obj: p2 };
51639
+ if (isRecord3(p2)) yield { path: `guardrail_policies.${id}`, obj: p2 };
51630
51640
  }
51631
51641
  return;
51632
51642
  }
@@ -51675,7 +51685,7 @@ function validateDeclaredExtension(parentPath, nodeType, key, val, declMap, diag
51675
51685
  }
51676
51686
  }
51677
51687
  function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInstance, strict) {
51678
- if (!isRecord4(value)) return;
51688
+ if (!isRecord3(value)) return;
51679
51689
  const obj = value;
51680
51690
  for (const key of Object.keys(obj)) {
51681
51691
  if (key === "extensions" || key === "extensions_strict" || key === "x-extensions" || key === "x-extensions-strict") {
@@ -51697,7 +51707,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51697
51707
  switch (nodeType) {
51698
51708
  case "root": {
51699
51709
  const sys = obj["system"];
51700
- if (isRecord4(sys)) {
51710
+ if (isRecord3(sys)) {
51701
51711
  walkExtensionNodes(
51702
51712
  sys,
51703
51713
  "system",
@@ -51709,9 +51719,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51709
51719
  );
51710
51720
  }
51711
51721
  const agents = obj["agents"];
51712
- if (isRecord4(agents)) {
51722
+ if (isRecord3(agents)) {
51713
51723
  for (const [id, a3] of Object.entries(agents)) {
51714
- if (isRecord4(a3)) {
51724
+ if (isRecord3(a3)) {
51715
51725
  walkExtensionNodes(
51716
51726
  a3,
51717
51727
  `agents.${id}`,
@@ -51725,9 +51735,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51725
51735
  }
51726
51736
  }
51727
51737
  const tasks = obj["tasks"];
51728
- if (isRecord4(tasks)) {
51738
+ if (isRecord3(tasks)) {
51729
51739
  for (const [id, t3] of Object.entries(tasks)) {
51730
- if (isRecord4(t3)) {
51740
+ if (isRecord3(t3)) {
51731
51741
  walkExtensionNodes(
51732
51742
  t3,
51733
51743
  `tasks.${id}`,
@@ -51741,9 +51751,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51741
51751
  }
51742
51752
  }
51743
51753
  const artifacts = obj["artifacts"];
51744
- if (isRecord4(artifacts)) {
51754
+ if (isRecord3(artifacts)) {
51745
51755
  for (const [id, a3] of Object.entries(artifacts)) {
51746
- if (isRecord4(a3)) {
51756
+ if (isRecord3(a3)) {
51747
51757
  walkExtensionNodes(
51748
51758
  a3,
51749
51759
  `artifacts.${id}`,
@@ -51757,9 +51767,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51757
51767
  }
51758
51768
  }
51759
51769
  const tools = obj["tools"];
51760
- if (isRecord4(tools)) {
51770
+ if (isRecord3(tools)) {
51761
51771
  for (const [id, t3] of Object.entries(tools)) {
51762
- if (isRecord4(t3)) {
51772
+ if (isRecord3(t3)) {
51763
51773
  walkExtensionNodes(
51764
51774
  t3,
51765
51775
  `tools.${id}`,
@@ -51773,9 +51783,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51773
51783
  }
51774
51784
  }
51775
51785
  const validations = obj["validations"];
51776
- if (isRecord4(validations)) {
51786
+ if (isRecord3(validations)) {
51777
51787
  for (const [id, v2] of Object.entries(validations)) {
51778
- if (isRecord4(v2)) {
51788
+ if (isRecord3(v2)) {
51779
51789
  walkExtensionNodes(
51780
51790
  v2,
51781
51791
  `validations.${id}`,
@@ -51789,9 +51799,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51789
51799
  }
51790
51800
  }
51791
51801
  const handoffTypes = obj["handoff_types"];
51792
- if (isRecord4(handoffTypes)) {
51802
+ if (isRecord3(handoffTypes)) {
51793
51803
  for (const [id, h2] of Object.entries(handoffTypes)) {
51794
- if (isRecord4(h2)) {
51804
+ if (isRecord3(h2)) {
51795
51805
  walkExtensionNodes(
51796
51806
  h2,
51797
51807
  `handoff_types.${id}`,
@@ -51805,9 +51815,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51805
51815
  }
51806
51816
  }
51807
51817
  const workflow = obj["workflow"];
51808
- if (isRecord4(workflow)) {
51818
+ if (isRecord3(workflow)) {
51809
51819
  for (const [id, w2] of Object.entries(workflow)) {
51810
- if (isRecord4(w2)) {
51820
+ if (isRecord3(w2)) {
51811
51821
  walkExtensionNodes(
51812
51822
  w2,
51813
51823
  `workflow.${id}`,
@@ -51821,9 +51831,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51821
51831
  }
51822
51832
  }
51823
51833
  const policies = obj["policies"];
51824
- if (isRecord4(policies)) {
51834
+ if (isRecord3(policies)) {
51825
51835
  for (const [id, p2] of Object.entries(policies)) {
51826
- if (isRecord4(p2)) {
51836
+ if (isRecord3(p2)) {
51827
51837
  walkExtensionNodes(
51828
51838
  p2,
51829
51839
  `policies.${id}`,
@@ -51837,9 +51847,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51837
51847
  }
51838
51848
  }
51839
51849
  const guardrails = obj["guardrails"];
51840
- if (isRecord4(guardrails)) {
51850
+ if (isRecord3(guardrails)) {
51841
51851
  for (const [id, g2] of Object.entries(guardrails)) {
51842
- if (isRecord4(g2)) {
51852
+ if (isRecord3(g2)) {
51843
51853
  walkExtensionNodes(
51844
51854
  g2,
51845
51855
  `guardrails.${id}`,
@@ -51853,9 +51863,9 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51853
51863
  }
51854
51864
  }
51855
51865
  const guardrailPolicies = obj["guardrail_policies"];
51856
- if (isRecord4(guardrailPolicies)) {
51866
+ if (isRecord3(guardrailPolicies)) {
51857
51867
  for (const [id, p2] of Object.entries(guardrailPolicies)) {
51858
- if (isRecord4(p2)) {
51868
+ if (isRecord3(p2)) {
51859
51869
  walkExtensionNodes(
51860
51870
  p2,
51861
51871
  `guardrail_policies.${id}`,
@@ -51875,7 +51885,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51875
51885
  if (Array.isArray(rules)) {
51876
51886
  for (let i3 = 0; i3 < rules.length; i3++) {
51877
51887
  const r3 = rules[i3];
51878
- if (isRecord4(r3)) {
51888
+ if (isRecord3(r3)) {
51879
51889
  walkExtensionNodes(
51880
51890
  r3,
51881
51891
  `${path}.rules[${i3}]`,
@@ -51892,7 +51902,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51892
51902
  if (Array.isArray(esc)) {
51893
51903
  for (let i3 = 0; i3 < esc.length; i3++) {
51894
51904
  const e3 = esc[i3];
51895
- if (isRecord4(e3)) {
51905
+ if (isRecord3(e3)) {
51896
51906
  walkExtensionNodes(
51897
51907
  e3,
51898
51908
  `${path}.escalation_criteria[${i3}]`,
@@ -51909,7 +51919,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51909
51919
  if (Array.isArray(pre)) {
51910
51920
  for (let i3 = 0; i3 < pre.length; i3++) {
51911
51921
  const p2 = pre[i3];
51912
- if (isRecord4(p2)) {
51922
+ if (isRecord3(p2)) {
51913
51923
  walkExtensionNodes(
51914
51924
  p2,
51915
51925
  `${path}.prerequisites[${i3}]`,
@@ -51929,7 +51939,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51929
51939
  if (Array.isArray(steps)) {
51930
51940
  for (let i3 = 0; i3 < steps.length; i3++) {
51931
51941
  const s2 = steps[i3];
51932
- if (isRecord4(s2)) {
51942
+ if (isRecord3(s2)) {
51933
51943
  walkExtensionNodes(
51934
51944
  s2,
51935
51945
  `${path}.execution_steps[${i3}]`,
@@ -51949,7 +51959,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51949
51959
  if (Array.isArray(cmds)) {
51950
51960
  for (let i3 = 0; i3 < cmds.length; i3++) {
51951
51961
  const c2 = cmds[i3];
51952
- if (isRecord4(c2)) {
51962
+ if (isRecord3(c2)) {
51953
51963
  walkExtensionNodes(
51954
51964
  c2,
51955
51965
  `${path}.commands[${i3}]`,
@@ -51969,7 +51979,7 @@ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInst
51969
51979
  if (Array.isArray(steps)) {
51970
51980
  for (let i3 = 0; i3 < steps.length; i3++) {
51971
51981
  const s2 = steps[i3];
51972
- if (isRecord4(s2)) {
51982
+ if (isRecord3(s2)) {
51973
51983
  walkExtensionNodes(
51974
51984
  s2,
51975
51985
  `${path}.steps[${i3}]`,
@@ -51992,7 +52002,7 @@ function checkExtensionValidation(data) {
51992
52002
  const strict = data["extensions_strict"] === true;
51993
52003
  const raw = data["extensions"];
51994
52004
  let declMap;
51995
- if (!isRecord4(raw) || Object.keys(raw).length === 0) {
52005
+ if (!isRecord3(raw) || Object.keys(raw).length === 0) {
51996
52006
  if (!strict) return [];
51997
52007
  declMap = {};
51998
52008
  } else {
@@ -53185,7 +53195,7 @@ var validationExecutorNoContextRule = {
53185
53195
  };
53186
53196
 
53187
53197
  // src/linter/rules/extension-consumption.ts
53188
- function isRecord5(v2) {
53198
+ function isRecord4(v2) {
53189
53199
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
53190
53200
  }
53191
53201
  function collectXUsages(dsl) {
@@ -53206,7 +53216,7 @@ function collectXUsages(dsl) {
53206
53216
  }
53207
53217
  }
53208
53218
  walkObj(dsl, "", "root");
53209
- if (isRecord5(dsl.system)) {
53219
+ if (isRecord4(dsl.system)) {
53210
53220
  walkObj(dsl.system, "system", "system");
53211
53221
  }
53212
53222
  for (const [id, agent] of Object.entries(dsl.agents)) {
@@ -53215,19 +53225,19 @@ function collectXUsages(dsl) {
53215
53225
  if (Array.isArray(agentObj["rules"])) {
53216
53226
  for (let i3 = 0; i3 < agentObj["rules"].length; i3++) {
53217
53227
  const r3 = agentObj["rules"][i3];
53218
- if (isRecord5(r3)) walkObj(r3, `agents.${id}.rules[${i3}]`, "rule");
53228
+ if (isRecord4(r3)) walkObj(r3, `agents.${id}.rules[${i3}]`, "rule");
53219
53229
  }
53220
53230
  }
53221
53231
  if (Array.isArray(agentObj["escalation_criteria"])) {
53222
53232
  for (let i3 = 0; i3 < agentObj["escalation_criteria"].length; i3++) {
53223
53233
  const e3 = agentObj["escalation_criteria"][i3];
53224
- if (isRecord5(e3)) walkObj(e3, `agents.${id}.escalation_criteria[${i3}]`, "escalation_criterion");
53234
+ if (isRecord4(e3)) walkObj(e3, `agents.${id}.escalation_criteria[${i3}]`, "escalation_criterion");
53225
53235
  }
53226
53236
  }
53227
53237
  if (Array.isArray(agentObj["prerequisites"])) {
53228
53238
  for (let i3 = 0; i3 < agentObj["prerequisites"].length; i3++) {
53229
53239
  const p2 = agentObj["prerequisites"][i3];
53230
- if (isRecord5(p2)) walkObj(p2, `agents.${id}.prerequisites[${i3}]`, "prerequisite");
53240
+ if (isRecord4(p2)) walkObj(p2, `agents.${id}.prerequisites[${i3}]`, "prerequisite");
53231
53241
  }
53232
53242
  }
53233
53243
  }
@@ -53237,7 +53247,7 @@ function collectXUsages(dsl) {
53237
53247
  if (Array.isArray(taskObj["execution_steps"])) {
53238
53248
  for (let i3 = 0; i3 < taskObj["execution_steps"].length; i3++) {
53239
53249
  const s2 = taskObj["execution_steps"][i3];
53240
- if (isRecord5(s2)) walkObj(s2, `tasks.${id}.execution_steps[${i3}]`, "execution_step");
53250
+ if (isRecord4(s2)) walkObj(s2, `tasks.${id}.execution_steps[${i3}]`, "execution_step");
53241
53251
  }
53242
53252
  }
53243
53253
  }
@@ -53250,7 +53260,7 @@ function collectXUsages(dsl) {
53250
53260
  if (Array.isArray(toolObj["commands"])) {
53251
53261
  for (let i3 = 0; i3 < toolObj["commands"].length; i3++) {
53252
53262
  const c2 = toolObj["commands"][i3];
53253
- if (isRecord5(c2)) walkObj(c2, `tools.${id}.commands[${i3}]`, "tool_command");
53263
+ if (isRecord4(c2)) walkObj(c2, `tools.${id}.commands[${i3}]`, "tool_command");
53254
53264
  }
53255
53265
  }
53256
53266
  }
@@ -53266,7 +53276,7 @@ function collectXUsages(dsl) {
53266
53276
  if (Array.isArray(wfObj["steps"])) {
53267
53277
  for (let i3 = 0; i3 < wfObj["steps"].length; i3++) {
53268
53278
  const s2 = wfObj["steps"][i3];
53269
- if (isRecord5(s2)) walkObj(s2, `workflow.${id}.steps[${i3}]`, "workflow_step");
53279
+ if (isRecord4(s2)) walkObj(s2, `workflow.${id}.steps[${i3}]`, "workflow_step");
53270
53280
  }
53271
53281
  }
53272
53282
  }
@@ -55289,8 +55299,16 @@ function filterIds(allIds, include, exclude) {
55289
55299
  if (exclude) return allIds.filter((id) => !exclude.includes(id));
55290
55300
  return allIds;
55291
55301
  }
55292
- function expandOutputPath(pattern, context, entityId) {
55293
- return pattern.replace(new RegExp(`\\{${context}\\.id\\}`, "g"), entityId);
55302
+ function expandOutputPath(pattern, context, entityId, entity) {
55303
+ return pattern.replace(
55304
+ new RegExp(`\\{${context}\\.([^}]+)\\}`, "g"),
55305
+ (_match, field) => {
55306
+ if (field === "id") return entityId;
55307
+ if (entity === void 0) return _match;
55308
+ const value = entity[field];
55309
+ return typeof value === "string" ? value : _match;
55310
+ }
55311
+ );
55294
55312
  }
55295
55313
  function buildEntityContext(dsl, context, entityId) {
55296
55314
  switch (context) {
@@ -55355,7 +55373,8 @@ async function renderFromConfig(dsl, renderTargets, options) {
55355
55373
  for (const entityId of ids) {
55356
55374
  const ctx = buildEntityContext(dsl, target.context, entityId);
55357
55375
  const output = compiled(ctx);
55358
- const outputPath = expandOutputPath(target.output, target.context, entityId);
55376
+ const entity = section[entityId];
55377
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
55359
55378
  if (target.skip_empty && isEffectivelyEmpty(output)) {
55360
55379
  await removeIfExists(outputPath);
55361
55380
  continue;
@@ -55404,7 +55423,8 @@ async function checkDriftFromConfig(dsl, renderTargets, options) {
55404
55423
  for (const entityId of ids) {
55405
55424
  const ctx = buildEntityContext(dsl, target.context, entityId);
55406
55425
  const expected = compiled(ctx);
55407
- const outputPath = expandOutputPath(target.output, target.context, entityId);
55426
+ const entity = section[entityId];
55427
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
55408
55428
  await checkExpectedVsExisting(expected, outputPath, target.skip_empty, diffs);
55409
55429
  }
55410
55430
  }
@@ -56126,8 +56146,9 @@ async function generateGuardrails(options) {
56126
56146
  const entityCtx = buildEntityContext(dsl, context, entityId);
56127
56147
  const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
56128
56148
  const rendered = compiled(mergedCtx);
56149
+ const entity = section[entityId];
56129
56150
  const resolvedOutput = resolveBindingRenderOutputPath(
56130
- expandOutputPath(renderTarget.output, context, entityId),
56151
+ expandOutputPath(renderTarget.output, context, entityId, entity),
56131
56152
  paths
56132
56153
  );
56133
56154
  const outputPath = resolve6(config.configDir, resolvedOutput);
@@ -56254,7 +56275,8 @@ async function loadRenderedFiles(dsl, renderTargets) {
56254
56275
  const section = getDslSection(dsl, target.context);
56255
56276
  const ids = filterIds(Object.keys(section), target.include, target.exclude);
56256
56277
  for (const entityId of ids) {
56257
- const outputPath = expandOutputPath(target.output, target.context, entityId);
56278
+ const entity = section[entityId];
56279
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
56258
56280
  try {
56259
56281
  const content = await readFile6(outputPath, "utf8");
56260
56282
  entries.push({ agent_id: entityId, path: outputPath, content });
@@ -56306,7 +56328,7 @@ function formatDslOverview(dsl) {
56306
56328
  `- Validations: ${Object.keys(dsl.validations).join(", ")}`
56307
56329
  ].join("\n");
56308
56330
  }
56309
- function isRecord6(v2) {
56331
+ function isRecord5(v2) {
56310
56332
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
56311
56333
  }
56312
56334
  function collectAllXUsages(dsl) {
@@ -56319,7 +56341,7 @@ function collectAllXUsages(dsl) {
56319
56341
  }
56320
56342
  }
56321
56343
  walk2(dsl, "", "root");
56322
- if (isRecord6(dsl.system)) walk2(dsl.system, "system", "system");
56344
+ if (isRecord5(dsl.system)) walk2(dsl.system, "system", "system");
56323
56345
  for (const [id, a3] of Object.entries(dsl.agents))
56324
56346
  walk2(a3, `agents.${id}`, "agent");
56325
56347
  for (const [id, t3] of Object.entries(dsl.tasks))