agent-contracts 0.5.1 → 0.6.0

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
@@ -3952,7 +3952,7 @@ var require_lodash = __commonJS({
3952
3952
  }
3953
3953
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
3954
3954
  });
3955
- function join2(array, separator) {
3955
+ function join3(array, separator) {
3956
3956
  return array == null ? "" : nativeJoin.call(array, separator);
3957
3957
  }
3958
3958
  function last(array) {
@@ -5876,7 +5876,7 @@ var require_lodash = __commonJS({
5876
5876
  lodash.isUndefined = isUndefined;
5877
5877
  lodash.isWeakMap = isWeakMap;
5878
5878
  lodash.isWeakSet = isWeakSet;
5879
- lodash.join = join2;
5879
+ lodash.join = join3;
5880
5880
  lodash.kebabCase = kebabCase;
5881
5881
  lodash.last = last;
5882
5882
  lodash.lastIndexOf = lastIndexOf;
@@ -6293,7 +6293,7 @@ var init_index_es = __esm({
6293
6293
  return { drive: t4.toLowerCase() + ":" };
6294
6294
  }, k2 = function() {
6295
6295
  return { drive: null };
6296
- }, z14 = function() {
6296
+ }, z15 = function() {
6297
6297
  return { drive: null };
6298
6298
  }, B2 = function(t4) {
6299
6299
  return { protocol: null, origin: null, absolute: false, drive: null, ...t4 };
@@ -6334,7 +6334,7 @@ var init_index_es = __esm({
6334
6334
  var t4, n4, r4, e4, o4;
6335
6335
  return t4 = K2, (n4 = rt()) !== c2 && (r4 = et()) !== c2 && (e4 = ut()) !== c2 && (o4 = it()) !== c2 ? (n4 = s2(n4, r4, e4, o4), t4 = n4) : (K2 = t4, t4 = c2), t4 === c2 && (t4 = K2, (n4 = rt()) !== c2 && (r4 = et()) !== c2 && (e4 = (function() {
6336
6336
  var t5;
6337
- return (t5 = x3) !== c2 && (t5 = z14()), t5;
6337
+ return (t5 = x3) !== c2 && (t5 = z15()), t5;
6338
6338
  })()) !== c2 ? (n4 = f2(n4, r4, e4), t4 = n4) : (K2 = t4, t4 = c2)), t4;
6339
6339
  })()) === c2 && (n3 = (function() {
6340
6340
  var n4, r4, e4, o4;
@@ -7497,7 +7497,7 @@ var require_stable = __commonJS({
7497
7497
  return result;
7498
7498
  }
7499
7499
  function stringifyFullFn(key, parent, stack, replacer, indent) {
7500
- var i3, res, join2;
7500
+ var i3, res, join3;
7501
7501
  const originalIndentation = indentation;
7502
7502
  var value = parent[key];
7503
7503
  if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
@@ -7523,12 +7523,12 @@ var require_stable = __commonJS({
7523
7523
  indentation += indent;
7524
7524
  res += `
7525
7525
  ${indentation}`;
7526
- join2 = `,
7526
+ join3 = `,
7527
7527
  ${indentation}`;
7528
7528
  for (i3 = 0; i3 < value.length - 1; i3++) {
7529
7529
  const tmp2 = stringifyFullFn(i3, value, stack, replacer, indent);
7530
7530
  res += tmp2 !== void 0 ? tmp2 : "null";
7531
- res += join2;
7531
+ res += join3;
7532
7532
  }
7533
7533
  const tmp = stringifyFullFn(i3, value, stack, replacer, indent);
7534
7534
  res += tmp !== void 0 ? tmp : "null";
@@ -7550,7 +7550,7 @@ ${originalIndentation}`;
7550
7550
  indentation += indent;
7551
7551
  res += `
7552
7552
  ${indentation}`;
7553
- join2 = `,
7553
+ join3 = `,
7554
7554
  ${indentation}`;
7555
7555
  var separator = "";
7556
7556
  for (i3 = 0; i3 < keys.length; i3++) {
@@ -7558,7 +7558,7 @@ ${indentation}`;
7558
7558
  const tmp = stringifyFullFn(key, value, stack, replacer, indent);
7559
7559
  if (tmp !== void 0) {
7560
7560
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7561
- separator = join2;
7561
+ separator = join3;
7562
7562
  }
7563
7563
  }
7564
7564
  if (separator !== "") {
@@ -7580,7 +7580,7 @@ ${originalIndentation}`;
7580
7580
  }
7581
7581
  }
7582
7582
  function stringifyFullArr(key, value, stack, replacer, indent) {
7583
- var i3, res, join2;
7583
+ var i3, res, join3;
7584
7584
  const originalIndentation = indentation;
7585
7585
  if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
7586
7586
  value = value.toJSON(key);
@@ -7604,12 +7604,12 @@ ${originalIndentation}`;
7604
7604
  indentation += indent;
7605
7605
  res += `
7606
7606
  ${indentation}`;
7607
- join2 = `,
7607
+ join3 = `,
7608
7608
  ${indentation}`;
7609
7609
  for (i3 = 0; i3 < value.length - 1; i3++) {
7610
7610
  const tmp2 = stringifyFullArr(i3, value[i3], stack, replacer, indent);
7611
7611
  res += tmp2 !== void 0 ? tmp2 : "null";
7612
- res += join2;
7612
+ res += join3;
7613
7613
  }
7614
7614
  const tmp = stringifyFullArr(i3, value[i3], stack, replacer, indent);
7615
7615
  res += tmp !== void 0 ? tmp : "null";
@@ -7630,7 +7630,7 @@ ${originalIndentation}`;
7630
7630
  indentation += indent;
7631
7631
  res += `
7632
7632
  ${indentation}`;
7633
- join2 = `,
7633
+ join3 = `,
7634
7634
  ${indentation}`;
7635
7635
  var separator = "";
7636
7636
  for (i3 = 0; i3 < replacer.length; i3++) {
@@ -7639,7 +7639,7 @@ ${indentation}`;
7639
7639
  const tmp = stringifyFullArr(key, value[key], stack, replacer, indent);
7640
7640
  if (tmp !== void 0) {
7641
7641
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7642
- separator = join2;
7642
+ separator = join3;
7643
7643
  }
7644
7644
  }
7645
7645
  }
@@ -7662,7 +7662,7 @@ ${originalIndentation}`;
7662
7662
  }
7663
7663
  }
7664
7664
  function stringifyIndent(key, value, stack, indent) {
7665
- var i3, res, join2;
7665
+ var i3, res, join3;
7666
7666
  const originalIndentation = indentation;
7667
7667
  switch (typeof value) {
7668
7668
  case "object":
@@ -7692,12 +7692,12 @@ ${originalIndentation}`;
7692
7692
  indentation += indent;
7693
7693
  res += `
7694
7694
  ${indentation}`;
7695
- join2 = `,
7695
+ join3 = `,
7696
7696
  ${indentation}`;
7697
7697
  for (i3 = 0; i3 < value.length - 1; i3++) {
7698
7698
  const tmp2 = stringifyIndent(i3, value[i3], stack, indent);
7699
7699
  res += tmp2 !== void 0 ? tmp2 : "null";
7700
- res += join2;
7700
+ res += join3;
7701
7701
  }
7702
7702
  const tmp = stringifyIndent(i3, value[i3], stack, indent);
7703
7703
  res += tmp !== void 0 ? tmp : "null";
@@ -7719,7 +7719,7 @@ ${originalIndentation}`;
7719
7719
  indentation += indent;
7720
7720
  res += `
7721
7721
  ${indentation}`;
7722
- join2 = `,
7722
+ join3 = `,
7723
7723
  ${indentation}`;
7724
7724
  var separator = "";
7725
7725
  for (i3 = 0; i3 < keys.length; i3++) {
@@ -7727,7 +7727,7 @@ ${indentation}`;
7727
7727
  const tmp = stringifyIndent(key, value[key], stack, indent);
7728
7728
  if (tmp !== void 0) {
7729
7729
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7730
- separator = join2;
7730
+ separator = join3;
7731
7731
  }
7732
7732
  }
7733
7733
  if (separator !== "") {
@@ -8023,7 +8023,7 @@ __export(index_es_exports2, {
8023
8023
  resolveExternalRef: () => ye,
8024
8024
  resolveExternalRefWithLocation: () => ge,
8025
8025
  resolveInlineRef: () => B,
8026
- resolveInlineRefWithLocation: () => z13,
8026
+ resolveInlineRefWithLocation: () => z14,
8027
8027
  safeParse: () => de,
8028
8028
  safeStringify: () => ve,
8029
8029
  startsWith: () => be,
@@ -8067,9 +8067,9 @@ function* L(e3, t3, r3) {
8067
8067
  for (const [n3, o3] of t3.entries()) O(e3.value, o3, r3), e3.value = e3.value[o3], A(e3.value) && (j(e3.value), yield [n3, e3.value]);
8068
8068
  }
8069
8069
  function B(e3, t3) {
8070
- return z13(e3, t3).value;
8070
+ return z14(e3, t3).value;
8071
8071
  }
8072
- function z13(e3, t3) {
8072
+ function z14(e3, t3) {
8073
8073
  return (function e4(t4, r3, n3, o3) {
8074
8074
  if (null !== V(r3)) throw new ReferenceError("Cannot resolve external references");
8075
8075
  const i3 = K(r3);
@@ -16899,7 +16899,7 @@ var require_immer_cjs_production_min = __commonJS({
16899
16899
  var t4 = n4[H2];
16900
16900
  return (t4 ? s2(t4) : n4)[r4];
16901
16901
  }
16902
- function z14(n4, r4) {
16902
+ function z15(n4, r4) {
16903
16903
  if (r4 in n4) for (var t4 = Object.getPrototypeOf(n4); t4; ) {
16904
16904
  var e4 = Object.getOwnPropertyDescriptor(t4, r4);
16905
16905
  if (e4) return e4;
@@ -17292,7 +17292,7 @@ var require_immer_cjs_production_min = __commonJS({
17292
17292
  if (r4 === H2) return n4;
17293
17293
  var e4 = s2(n4);
17294
17294
  if (!u2(e4, r4)) return (function(n5, r5, t4) {
17295
- var e5, i5 = z14(r5, t4);
17295
+ var e5, i5 = z15(r5, t4);
17296
17296
  return i5 ? "value" in i5 ? i5.value : null === (e5 = i5.get) || void 0 === e5 ? void 0 : e5.call(n5.k) : void 0;
17297
17297
  })(n4, e4, r4);
17298
17298
  var i4 = e4[r4];
@@ -17302,7 +17302,7 @@ var require_immer_cjs_production_min = __commonJS({
17302
17302
  }, ownKeys: function(n4) {
17303
17303
  return Reflect.ownKeys(s2(n4));
17304
17304
  }, set: function(n4, r4, t4) {
17305
- var e4 = z14(s2(n4), r4);
17305
+ var e4 = z15(s2(n4), r4);
17306
17306
  if (null == e4 ? void 0 : e4.set) return e4.set.call(n4.k, t4), true;
17307
17307
  if (!n4.g) {
17308
17308
  var i4 = A2(s2(n4), r4), o4 = null == i4 ? void 0 : i4[H2];
@@ -35641,11 +35641,11 @@ var require_brace_expansion = __commonJS({
35641
35641
  if (pad) {
35642
35642
  var need = width - c2.length;
35643
35643
  if (need > 0) {
35644
- var z14 = new Array(need + 1).join("0");
35644
+ var z15 = new Array(need + 1).join("0");
35645
35645
  if (i3 < 0)
35646
- c2 = "-" + z14 + c2.slice(1);
35646
+ c2 = "-" + z15 + c2.slice(1);
35647
35647
  else
35648
- c2 = z14 + c2;
35648
+ c2 = z15 + c2;
35649
35649
  }
35650
35650
  }
35651
35651
  }
@@ -52698,7 +52698,7 @@ var require_lodash3 = __commonJS({
52698
52698
  }
52699
52699
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
52700
52700
  });
52701
- function join2(array, separator) {
52701
+ function join3(array, separator) {
52702
52702
  return array == null ? "" : nativeJoin.call(array, separator);
52703
52703
  }
52704
52704
  function last(array) {
@@ -54617,7 +54617,7 @@ var require_lodash3 = __commonJS({
54617
54617
  lodash.isUndefined = isUndefined;
54618
54618
  lodash.isWeakMap = isWeakMap;
54619
54619
  lodash.isWeakSet = isWeakSet;
54620
- lodash.join = join2;
54620
+ lodash.join = join3;
54621
54621
  lodash.kebabCase = kebabCase;
54622
54622
  lodash.last = last;
54623
54623
  lodash.lastIndexOf = lastIndexOf;
@@ -55621,7 +55621,7 @@ var require_dist10 = __commonJS({
55621
55621
  var getSiblings = (parent) => (node) => getChildren(parent).filter(not(eq(node)));
55622
55622
  var concatAll = (
55623
55623
  /*::<T>*/
55624
- (xs) => (ys) => ys.reduce((zs, z14) => zs.concat(z14), xs)
55624
+ (xs) => (ys) => ys.reduce((zs, z15) => zs.concat(z15), xs)
55625
55625
  );
55626
55626
  function getLastSegment(instancePath) {
55627
55627
  const index4 = instancePath.lastIndexOf("/");
@@ -58429,12 +58429,12 @@ function resolveDslPath(dirArg, dirArgDefault, config) {
58429
58429
  }
58430
58430
 
58431
58431
  // src/resolver/base-resolver.ts
58432
- import { resolve as resolve3, join } from "path";
58432
+ import { resolve as resolve3, join as join2 } from "path";
58433
58433
  import { stat } from "fs/promises";
58434
58434
 
58435
58435
  // src/loader/loader.ts
58436
- import { readFile as readFile2 } from "fs/promises";
58437
- import { dirname as dirname2, resolve as resolve2 } from "path";
58436
+ import { readFile as readFile2, readdir, stat as fsStat } from "fs/promises";
58437
+ import { dirname as dirname2, resolve as resolve2, join, extname } from "path";
58438
58438
  import { parse as parseYaml2 } from "yaml";
58439
58439
  var DslLoadError = class extends Error {
58440
58440
  constructor(message, filePath) {
@@ -58444,18 +58444,16 @@ var DslLoadError = class extends Error {
58444
58444
  }
58445
58445
  filePath;
58446
58446
  };
58447
- var REF_ELIGIBLE_SECTIONS = [
58448
- "agents",
58449
- "tasks",
58450
- "artifacts",
58451
- "tools",
58452
- "validations",
58453
- "handoff_types",
58454
- "workflow",
58455
- "policies"
58456
- ];
58447
+ function isRecord(v2) {
58448
+ return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
58449
+ }
58457
58450
  function isRef(value) {
58458
- return typeof value === "object" && value !== null && "$ref" in value && typeof value["$ref"] === "string";
58451
+ return isRecord(value) && "$ref" in value && typeof value["$ref"] === "string";
58452
+ }
58453
+ function hasRefs(value) {
58454
+ if (!("$refs" in value)) return false;
58455
+ const refs = value["$refs"];
58456
+ return Array.isArray(refs) && refs.every((r3) => typeof r3 === "string");
58459
58457
  }
58460
58458
  async function readYaml(filePath) {
58461
58459
  let content;
@@ -58477,17 +58475,160 @@ async function readYaml(filePath) {
58477
58475
  );
58478
58476
  }
58479
58477
  }
58480
- async function resolveRefs(data, baseDir) {
58481
- const resolved = { ...data };
58482
- for (const section of REF_ELIGIBLE_SECTIONS) {
58483
- const value = resolved[section];
58484
- if (isRef(value)) {
58485
- const refPath = resolve2(baseDir, value.$ref);
58486
- resolved[section] = await readYaml(refPath);
58478
+ function deepMergeRefs(a3, b3, sourcePath) {
58479
+ const result = { ...a3 };
58480
+ for (const [key, bVal] of Object.entries(b3)) {
58481
+ const aVal = result[key];
58482
+ if (aVal === void 0) {
58483
+ result[key] = bVal;
58484
+ } else if (isRecord(aVal) && isRecord(bVal)) {
58485
+ result[key] = deepMergeRefs(aVal, bVal, sourcePath);
58486
+ } else {
58487
+ throw new DslLoadError(
58488
+ `Conflicting value for key "${key}" while merging $refs from ${sourcePath}`,
58489
+ sourcePath
58490
+ );
58487
58491
  }
58488
58492
  }
58493
+ return result;
58494
+ }
58495
+ async function loadRefsSource(refPath, baseDir, resolving) {
58496
+ const target = resolve2(baseDir, refPath);
58497
+ const s2 = await fsStat(target).catch(() => null);
58498
+ if (s2?.isDirectory()) {
58499
+ if (resolving.has(target)) {
58500
+ throw new DslLoadError(`Circular $refs detected: ${target}`, target);
58501
+ }
58502
+ resolving.add(target);
58503
+ const result = await loadDirectoryAsMap(target, resolving);
58504
+ resolving.delete(target);
58505
+ return result;
58506
+ }
58507
+ if (!s2?.isFile()) {
58508
+ throw new DslLoadError(`File not found: ${target}`, target);
58509
+ }
58510
+ if (resolving.has(target)) {
58511
+ throw new DslLoadError(`Circular $refs detected: ${target}`, target);
58512
+ }
58513
+ resolving.add(target);
58514
+ const content = await readYaml(target);
58515
+ if (!isRecord(content)) {
58516
+ throw new DslLoadError(
58517
+ `Expected YAML object in ${target}, got ${Array.isArray(content) ? "array" : typeof content}`,
58518
+ target
58519
+ );
58520
+ }
58521
+ const resolved = await resolveRefsDeep(
58522
+ content,
58523
+ dirname2(target),
58524
+ resolving
58525
+ );
58526
+ resolving.delete(target);
58489
58527
  return resolved;
58490
58528
  }
58529
+ async function loadDirectoryAsMap(dirPath, resolving) {
58530
+ let entries;
58531
+ try {
58532
+ entries = await readdir(dirPath);
58533
+ } catch {
58534
+ throw new DslLoadError(
58535
+ `Cannot read directory: ${dirPath}`,
58536
+ dirPath
58537
+ );
58538
+ }
58539
+ const yamlFiles = entries.filter((f2) => [".yaml", ".yml"].includes(extname(f2))).sort();
58540
+ if (yamlFiles.length === 0) {
58541
+ throw new DslLoadError(
58542
+ `No YAML files found in directory: ${dirPath}`,
58543
+ dirPath
58544
+ );
58545
+ }
58546
+ let merged = {};
58547
+ for (const file of yamlFiles) {
58548
+ const filePath = join(dirPath, file);
58549
+ const content = await readYaml(filePath);
58550
+ if (!isRecord(content)) {
58551
+ throw new DslLoadError(
58552
+ `Expected YAML object in ${filePath}, got ${Array.isArray(content) ? "array" : typeof content}`,
58553
+ filePath
58554
+ );
58555
+ }
58556
+ const resolved = await resolveRefsDeep(
58557
+ content,
58558
+ dirPath,
58559
+ resolving
58560
+ );
58561
+ merged = deepMergeRefs(merged, resolved, filePath);
58562
+ }
58563
+ return merged;
58564
+ }
58565
+ async function processRefs(obj, baseDir, resolving) {
58566
+ const refPaths = obj["$refs"];
58567
+ const inline = {};
58568
+ for (const [key, value] of Object.entries(obj)) {
58569
+ if (key !== "$refs") {
58570
+ inline[key] = value;
58571
+ }
58572
+ }
58573
+ let merged = {};
58574
+ for (const refPath of refPaths) {
58575
+ const loaded = await loadRefsSource(refPath, baseDir, resolving);
58576
+ merged = deepMergeRefs(merged, loaded, refPath);
58577
+ }
58578
+ merged = deepMergeRefs(merged, inline, "(inline)");
58579
+ return merged;
58580
+ }
58581
+ async function resolveRefsDeep(data, baseDir, resolving) {
58582
+ if (typeof data !== "object" || data === null) return data;
58583
+ if (Array.isArray(data)) {
58584
+ return Promise.all(
58585
+ data.map((item) => resolveRefsDeep(item, baseDir, resolving))
58586
+ );
58587
+ }
58588
+ if (isRef(data)) {
58589
+ const refTarget = resolve2(baseDir, data.$ref);
58590
+ const s2 = await fsStat(refTarget).catch(() => null);
58591
+ if (s2?.isDirectory()) {
58592
+ if (resolving.has(refTarget)) {
58593
+ throw new DslLoadError(
58594
+ `Circular $ref detected: ${refTarget}`,
58595
+ refTarget
58596
+ );
58597
+ }
58598
+ resolving.add(refTarget);
58599
+ const result2 = await loadDirectoryAsMap(refTarget, resolving);
58600
+ resolving.delete(refTarget);
58601
+ return result2;
58602
+ }
58603
+ if (!s2?.isFile()) {
58604
+ throw new DslLoadError(`File not found: ${refTarget}`, refTarget);
58605
+ }
58606
+ if (resolving.has(refTarget)) {
58607
+ throw new DslLoadError(
58608
+ `Circular $ref detected: ${refTarget}`,
58609
+ refTarget
58610
+ );
58611
+ }
58612
+ resolving.add(refTarget);
58613
+ const content = await readYaml(refTarget);
58614
+ const resolved = await resolveRefsDeep(
58615
+ content,
58616
+ dirname2(refTarget),
58617
+ resolving
58618
+ );
58619
+ resolving.delete(refTarget);
58620
+ return resolved;
58621
+ }
58622
+ let obj = data;
58623
+ if (hasRefs(obj)) {
58624
+ obj = await processRefs(obj, baseDir, resolving);
58625
+ }
58626
+ const result = {};
58627
+ for (const [key, value] of Object.entries(obj)) {
58628
+ result[key] = await resolveRefsDeep(value, baseDir, resolving);
58629
+ }
58630
+ return result;
58631
+ }
58491
58632
  function checkVersion(data, filePath) {
58492
58633
  const version = data["version"];
58493
58634
  if (version === void 0) {
@@ -58515,7 +58656,12 @@ async function loadDsl(entryPath) {
58515
58656
  const data = raw;
58516
58657
  checkVersion(data, absPath);
58517
58658
  const baseDir = dirname2(absPath);
58518
- const resolved = await resolveRefs(data, baseDir);
58659
+ const resolving = /* @__PURE__ */ new Set([absPath]);
58660
+ const resolved = await resolveRefsDeep(
58661
+ data,
58662
+ baseDir,
58663
+ resolving
58664
+ );
58519
58665
  return { data: resolved, filePath: absPath };
58520
58666
  }
58521
58667
 
@@ -58529,7 +58675,7 @@ var BaseResolveError = class extends Error {
58529
58675
  async function findEntryFile(dir) {
58530
58676
  const candidates = ["agent-contracts.yaml", "agent-contracts.yml"];
58531
58677
  for (const name of candidates) {
58532
- const p2 = join(dir, name);
58678
+ const p2 = join2(dir, name);
58533
58679
  try {
58534
58680
  const s2 = await stat(p2);
58535
58681
  if (s2.isFile()) return p2;
@@ -58581,7 +58727,7 @@ var MergeError = class extends Error {
58581
58727
  this.name = "MergeError";
58582
58728
  }
58583
58729
  };
58584
- function isRecord(v2) {
58730
+ function isRecord2(v2) {
58585
58731
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
58586
58732
  }
58587
58733
  function hasOperator(obj) {
@@ -58593,7 +58739,7 @@ function hasOperator(obj) {
58593
58739
  }
58594
58740
  function findIndexById(arr, id) {
58595
58741
  return arr.findIndex(
58596
- (item) => isRecord(item) && item["id"] === id
58742
+ (item) => isRecord2(item) && item["id"] === id
58597
58743
  );
58598
58744
  }
58599
58745
  function applyArrayMergeOperator(baseArray, operatorObj, path) {
@@ -58629,7 +58775,7 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
58629
58775
  const removeList = operatorObj["$remove"];
58630
58776
  const idsToRemove = new Set(removeList.map((r3) => r3["id"]));
58631
58777
  const result = baseArray.filter((item) => {
58632
- if (isRecord(item) && typeof item["id"] === "string") {
58778
+ if (isRecord2(item) && typeof item["id"] === "string") {
58633
58779
  const itemId = item["id"];
58634
58780
  if (idsToRemove.has(itemId)) {
58635
58781
  idsToRemove.delete(itemId);
@@ -58718,7 +58864,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
58718
58864
  for (const key of Object.keys(project)) {
58719
58865
  const baseVal = result[key];
58720
58866
  const projVal = project[key];
58721
- if (isRecord(projVal) && hasOperator(projVal)) {
58867
+ if (isRecord2(projVal) && hasOperator(projVal)) {
58722
58868
  if (!hasExtends) {
58723
58869
  throw new MergeError(
58724
58870
  `Merge operator used without extends at ${path}.${key}`
@@ -58726,12 +58872,12 @@ function deepMergeEntities(base, project, path, hasExtends) {
58726
58872
  }
58727
58873
  if (Array.isArray(baseVal)) {
58728
58874
  result[key] = applyArrayMergeOperator(baseVal, projVal, `${path}.${key}`);
58729
- } else if (isRecord(baseVal)) {
58875
+ } else if (isRecord2(baseVal)) {
58730
58876
  result[key] = applyMapMergeOperator(baseVal, projVal, `${path}.${key}`);
58731
58877
  } else {
58732
58878
  result[key] = applyArrayMergeOperator([], projVal, `${path}.${key}`);
58733
58879
  }
58734
- } else if (isRecord(projVal) && isRecord(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
58880
+ } else if (isRecord2(projVal) && isRecord2(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
58735
58881
  result[key] = deepMergeEntities(
58736
58882
  baseVal,
58737
58883
  projVal,
@@ -58745,7 +58891,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
58745
58891
  return result;
58746
58892
  }
58747
58893
  function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
58748
- if (isRecord(projectMap) && !Array.isArray(projectMap)) {
58894
+ if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
58749
58895
  const op = hasOperator(projectMap);
58750
58896
  if (op) {
58751
58897
  if (!hasExtends) {
@@ -58759,7 +58905,7 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
58759
58905
  const result = { ...baseMap };
58760
58906
  for (const [key, projVal] of Object.entries(projectMap)) {
58761
58907
  const baseVal = result[key];
58762
- if (baseVal !== void 0 && isRecord(baseVal) && isRecord(projVal)) {
58908
+ if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
58763
58909
  result[key] = deepMergeEntities(
58764
58910
  baseVal,
58765
58911
  projVal,
@@ -58799,7 +58945,7 @@ function mergeDsl(base, project) {
58799
58945
  if (projVal === void 0) {
58800
58946
  continue;
58801
58947
  }
58802
- const baseMap = isRecord(baseVal) ? baseVal : {};
58948
+ const baseMap = isRecord2(baseVal) ? baseVal : {};
58803
58949
  result[section] = mergeEntityMaps(
58804
58950
  baseMap,
58805
58951
  projVal,
@@ -58858,6 +59004,9 @@ var resolveCommand = new Command("resolve").description("Resolve DSL (load + mer
58858
59004
  // src/cli/commands/validate.ts
58859
59005
  import { Command as Command2 } from "commander";
58860
59006
 
59007
+ // src/validator/schema-validator.ts
59008
+ import { z as z13 } from "zod";
59009
+
58861
59010
  // src/schema/agent.ts
58862
59011
  import { z as z2 } from "zod";
58863
59012
  var RuleSchema = z2.object({
@@ -58868,7 +59017,7 @@ var RuleSchema = z2.object({
58868
59017
  detection_method: z2.string().optional(),
58869
59018
  escalation: z2.string().optional(),
58870
59019
  ref: z2.string().optional()
58871
- }).strict();
59020
+ }).passthrough();
58872
59021
  var EscalationCriterionSchema = z2.object({
58873
59022
  condition: z2.string(),
58874
59023
  action: z2.enum([
@@ -58876,12 +59025,12 @@ var EscalationCriterionSchema = z2.object({
58876
59025
  "report_to_architect",
58877
59026
  "wait_for_approval"
58878
59027
  ])
58879
- }).strict();
59028
+ }).passthrough();
58880
59029
  var PrerequisiteSchema = z2.object({
58881
59030
  action: z2.enum(["read", "execute"]),
58882
59031
  target: z2.string(),
58883
59032
  required: z2.boolean()
58884
- }).strict();
59033
+ }).passthrough();
58885
59034
  var AgentSchema = z2.object({
58886
59035
  role_name: z2.string(),
58887
59036
  purpose: z2.string(),
@@ -58923,14 +59072,15 @@ import { z as z4 } from "zod";
58923
59072
  var HandoffTypeSchema = z4.object({
58924
59073
  version: z4.number(),
58925
59074
  description: z4.string().optional(),
58926
- payload: z4.record(z4.string(), z4.any())
59075
+ payload: z4.record(z4.string(), z4.any()),
59076
+ example: z4.record(z4.string(), z4.any()).optional()
58927
59077
  }).passthrough();
58928
59078
 
58929
59079
  // src/schema/policy.ts
58930
59080
  import { z as z5 } from "zod";
58931
59081
  var PolicyWhenSchema = z5.object({
58932
59082
  artifact_type: z5.string().optional(),
58933
- phase: z5.string().optional()
59083
+ workflow: z5.string().optional()
58934
59084
  }).passthrough();
58935
59085
  var PolicySchema = z5.object({
58936
59086
  when: PolicyWhenSchema,
@@ -58945,7 +59095,7 @@ var ExtendsSchema = z6.string().optional();
58945
59095
  var SystemSchema = z6.object({
58946
59096
  id: z6.string(),
58947
59097
  name: z6.string(),
58948
- default_phase_order: z6.array(z6.string())
59098
+ default_workflow_order: z6.array(z6.string())
58949
59099
  }).passthrough();
58950
59100
 
58951
59101
  // src/schema/task.ts
@@ -58953,6 +59103,7 @@ import { z as z7 } from "zod";
58953
59103
  var ExecutionStepSchema = z7.object({
58954
59104
  id: z7.string(),
58955
59105
  action: z7.string(),
59106
+ description: z7.string().optional(),
58956
59107
  required: z7.boolean().optional(),
58957
59108
  abort_on_failure: z7.boolean().optional(),
58958
59109
  uses_tool: z7.string().optional(),
@@ -58960,12 +59111,12 @@ var ExecutionStepSchema = z7.object({
58960
59111
  depends_on: z7.array(z7.string()).optional(),
58961
59112
  skip_condition: z7.string().optional(),
58962
59113
  wait_for_approval: z7.boolean().optional()
58963
- }).strict();
59114
+ }).passthrough();
58964
59115
  var TaskSchema = z7.object({
58965
59116
  description: z7.string(),
58966
59117
  target_agent: z7.string(),
58967
59118
  allowed_from_agents: z7.array(z7.string()),
58968
- phase: z7.string(),
59119
+ workflow: z7.string(),
58969
59120
  input_artifacts: z7.array(z7.string()),
58970
59121
  invocation_handoff: z7.string(),
58971
59122
  result_handoff: z7.string(),
@@ -59005,19 +59156,22 @@ var ValidationSchema = z9.object({
59005
59156
  import { z as z10 } from "zod";
59006
59157
  var WorkflowHandoffStepSchema = z10.object({
59007
59158
  type: z10.literal("handoff"),
59159
+ description: z10.string().optional(),
59008
59160
  handoff_kind: z10.string(),
59009
59161
  task: z10.string().optional(),
59010
59162
  from_agent: z10.string().optional()
59011
- }).strict();
59163
+ }).passthrough();
59012
59164
  var WorkflowValidationStepSchema = z10.object({
59013
59165
  type: z10.literal("validation"),
59166
+ description: z10.string().optional(),
59014
59167
  validation: z10.string()
59015
- }).strict();
59168
+ }).passthrough();
59016
59169
  var WorkflowDecisionStepSchema = z10.object({
59017
59170
  type: z10.literal("decision"),
59171
+ description: z10.string().optional(),
59018
59172
  on: z10.string(),
59019
59173
  branches: z10.record(z10.string(), z10.array(z10.string()))
59020
- }).strict();
59174
+ }).passthrough();
59021
59175
  var WorkflowStepSchema = z10.discriminatedUnion("type", [
59022
59176
  WorkflowHandoffStepSchema,
59023
59177
  WorkflowValidationStepSchema,
@@ -59025,6 +59179,7 @@ var WorkflowStepSchema = z10.discriminatedUnion("type", [
59025
59179
  ]);
59026
59180
  var WorkflowSchema = z10.object({
59027
59181
  entry_conditions: z10.array(z10.string()).default([]),
59182
+ trigger: z10.string().optional(),
59028
59183
  steps: z10.array(WorkflowStepSchema)
59029
59184
  }).passthrough();
59030
59185
 
@@ -59063,113 +59218,65 @@ var RemoveOperatorSchema = z12.object({
59063
59218
  });
59064
59219
 
59065
59220
  // src/validator/schema-validator.ts
59066
- function hasNonExtensionCustomProps(obj, knownKeys, path) {
59067
- const diagnostics = [];
59068
- for (const key of Object.keys(obj)) {
59069
- if (knownKeys.has(key)) continue;
59070
- if (key.startsWith("x-")) continue;
59071
- diagnostics.push({
59072
- path: `${path}.${key}`,
59073
- message: `Unknown property "${key}". Custom properties must use "x-" prefix.`,
59074
- code: "unknown-property"
59075
- });
59076
- }
59077
- return diagnostics;
59221
+ function unwrap(schema) {
59222
+ if (schema instanceof z13.ZodOptional) return unwrap(schema.unwrap());
59223
+ if (schema instanceof z13.ZodDefault) return unwrap(schema.removeDefault());
59224
+ if (schema instanceof z13.ZodNullable) return unwrap(schema.unwrap());
59225
+ return schema;
59078
59226
  }
59079
- var SYSTEM_KEYS = /* @__PURE__ */ new Set(["id", "name", "default_phase_order"]);
59080
- var AGENT_KEYS = /* @__PURE__ */ new Set([
59081
- "role_name",
59082
- "purpose",
59083
- "can_read_artifacts",
59084
- "can_write_artifacts",
59085
- "can_execute_tools",
59086
- "can_perform_validations",
59087
- "can_invoke_agents",
59088
- "can_return_handoffs",
59089
- "dispatch_only",
59090
- "mode",
59091
- "responsibilities",
59092
- "constraints",
59093
- "rules",
59094
- "anti_patterns",
59095
- "escalation_criteria",
59096
- "prerequisites"
59097
- ]);
59098
- var TASK_KEYS = /* @__PURE__ */ new Set([
59099
- "description",
59100
- "target_agent",
59101
- "allowed_from_agents",
59102
- "phase",
59103
- "input_artifacts",
59104
- "invocation_handoff",
59105
- "result_handoff",
59106
- "default_priority",
59107
- "responsibilities",
59108
- "constraints",
59109
- "execution_steps",
59110
- "completion_criteria",
59111
- "rules",
59112
- "anti_patterns",
59113
- "escalation_criteria"
59114
- ]);
59115
- var ARTIFACT_KEYS = /* @__PURE__ */ new Set([
59116
- "type",
59117
- "description",
59118
- "owner",
59119
- "producers",
59120
- "editors",
59121
- "consumers",
59122
- "states",
59123
- "required_validations",
59124
- "visibility"
59125
- ]);
59126
- var TOOL_KEYS = /* @__PURE__ */ new Set([
59127
- "kind",
59128
- "description",
59129
- "input_artifacts",
59130
- "output_artifacts",
59131
- "invokable_by",
59132
- "side_effects"
59133
- ]);
59134
- var VALIDATION_KEYS = /* @__PURE__ */ new Set([
59135
- "target_artifact",
59136
- "kind",
59137
- "executor_type",
59138
- "executor",
59139
- "blocking",
59140
- "produces_evidence"
59141
- ]);
59142
- var HANDOFF_TYPE_KEYS = /* @__PURE__ */ new Set(["version", "description", "payload"]);
59143
- var WORKFLOW_KEYS = /* @__PURE__ */ new Set(["entry_conditions", "steps"]);
59144
- var POLICY_KEYS = /* @__PURE__ */ new Set(["when", "requires_validations", "requires"]);
59145
- function checkCustomProps(data) {
59146
- const diagnostics = [];
59147
- if (data["system"] && typeof data["system"] === "object") {
59148
- diagnostics.push(
59149
- ...hasNonExtensionCustomProps(data["system"], SYSTEM_KEYS, "system")
59150
- );
59227
+ function checkCustomPropsRecursive(data, schema, path) {
59228
+ const inner = unwrap(schema);
59229
+ if (inner instanceof z13.ZodObject) {
59230
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
59231
+ const obj = data;
59232
+ const shape = inner.shape;
59233
+ const knownKeys = new Set(Object.keys(shape));
59234
+ const diagnostics = [];
59235
+ for (const key of Object.keys(obj)) {
59236
+ if (knownKeys.has(key)) continue;
59237
+ if (key.startsWith("x-")) continue;
59238
+ diagnostics.push({
59239
+ path: path ? `${path}.${key}` : key,
59240
+ message: `Unknown property "${key}". Custom properties must use "x-" prefix.`,
59241
+ code: "unknown-property"
59242
+ });
59243
+ }
59244
+ for (const [field, fieldSchema] of Object.entries(shape)) {
59245
+ if (obj[field] === void 0) continue;
59246
+ diagnostics.push(...checkCustomPropsRecursive(obj[field], fieldSchema, path ? `${path}.${field}` : field));
59247
+ }
59248
+ return diagnostics;
59151
59249
  }
59152
- const sections = [
59153
- { key: "agents", knownKeys: AGENT_KEYS },
59154
- { key: "tasks", knownKeys: TASK_KEYS },
59155
- { key: "artifacts", knownKeys: ARTIFACT_KEYS },
59156
- { key: "tools", knownKeys: TOOL_KEYS },
59157
- { key: "validations", knownKeys: VALIDATION_KEYS },
59158
- { key: "handoff_types", knownKeys: HANDOFF_TYPE_KEYS },
59159
- { key: "workflow", knownKeys: WORKFLOW_KEYS },
59160
- { key: "policies", knownKeys: POLICY_KEYS }
59161
- ];
59162
- for (const { key, knownKeys } of sections) {
59163
- const map = data[key];
59164
- if (typeof map !== "object" || map === null || Array.isArray(map)) continue;
59165
- for (const [entryKey, item] of Object.entries(map)) {
59166
- if (typeof item !== "object" || item === null) continue;
59167
- diagnostics.push(
59168
- ...hasNonExtensionCustomProps(item, knownKeys, `${key}.${entryKey}`)
59169
- );
59250
+ if (inner instanceof z13.ZodRecord) {
59251
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
59252
+ const valueSchema = inner._def.valueType;
59253
+ const diagnostics = [];
59254
+ for (const [key, value] of Object.entries(data)) {
59255
+ diagnostics.push(...checkCustomPropsRecursive(value, valueSchema, path ? `${path}.${key}` : key));
59256
+ }
59257
+ return diagnostics;
59258
+ }
59259
+ if (inner instanceof z13.ZodArray) {
59260
+ if (!Array.isArray(data)) return [];
59261
+ const diagnostics = [];
59262
+ for (let i3 = 0; i3 < data.length; i3++) {
59263
+ diagnostics.push(...checkCustomPropsRecursive(data[i3], inner.element, `${path}[${i3}]`));
59170
59264
  }
59265
+ return diagnostics;
59171
59266
  }
59172
- return diagnostics;
59267
+ if (inner instanceof z13.ZodDiscriminatedUnion) {
59268
+ if (typeof data !== "object" || data === null) return [];
59269
+ const obj = data;
59270
+ const disc = inner._def.discriminator;
59271
+ const discValue = obj[disc];
59272
+ const match = inner.options.find((opt) => {
59273
+ const shape = opt.shape;
59274
+ return shape[disc] instanceof z13.ZodLiteral && shape[disc].value === discValue;
59275
+ });
59276
+ if (match) return checkCustomPropsRecursive(data, match, path);
59277
+ return [];
59278
+ }
59279
+ return [];
59173
59280
  }
59174
59281
  function validateSchema(data) {
59175
59282
  const result = DslSchema.safeParse(data);
@@ -59181,7 +59288,7 @@ function validateSchema(data) {
59181
59288
  }));
59182
59289
  return { success: false, diagnostics };
59183
59290
  }
59184
- const customPropDiagnostics = checkCustomProps(data);
59291
+ const customPropDiagnostics = checkCustomPropsRecursive(data, DslSchema, "");
59185
59292
  if (customPropDiagnostics.length > 0) {
59186
59293
  return { success: false, diagnostics: customPropDiagnostics };
59187
59294
  }
@@ -59197,7 +59304,7 @@ function checkReferences(dsl) {
59197
59304
  const validationIds = new Set(Object.keys(dsl.validations));
59198
59305
  const handoffKinds = new Set(Object.keys(dsl.handoff_types));
59199
59306
  const taskIds = new Set(Object.keys(dsl.tasks));
59200
- const phases = new Set(dsl.system.default_phase_order);
59307
+ const workflowIds = new Set(dsl.system.default_workflow_order);
59201
59308
  function checkExists(value, validSet, entityType, path) {
59202
59309
  if (!validSet.has(value)) {
59203
59310
  diagnostics.push({
@@ -59283,26 +59390,26 @@ function checkReferences(dsl) {
59283
59390
  for (const ref of task.allowed_from_agents) {
59284
59391
  checkExists(ref, agentIds, "agents", `tasks.${id}.allowed_from_agents`);
59285
59392
  }
59286
- checkExists(task.phase, phases, "system.default_phase_order", `tasks.${id}.phase`);
59393
+ checkExists(task.workflow, workflowIds, "system.default_workflow_order", `tasks.${id}.workflow`);
59287
59394
  checkExists(task.invocation_handoff, handoffKinds, "handoff_types", `tasks.${id}.invocation_handoff`);
59288
59395
  checkExists(task.result_handoff, handoffKinds, "handoff_types", `tasks.${id}.result_handoff`);
59289
59396
  for (const ref of task.input_artifacts) {
59290
59397
  checkExists(ref, artifactIds, "artifacts", `tasks.${id}.input_artifacts`);
59291
59398
  }
59292
59399
  }
59293
- for (const [phase, wf] of Object.entries(dsl.workflow)) {
59294
- checkExists(phase, phases, "system.default_phase_order", `workflow.${phase}`);
59400
+ for (const [wfId, wf] of Object.entries(dsl.workflow)) {
59401
+ checkExists(wfId, workflowIds, "system.default_workflow_order", `workflow.${wfId}`);
59295
59402
  for (let j2 = 0; j2 < wf.steps.length; j2++) {
59296
59403
  const step = wf.steps[j2];
59297
59404
  if (step.type === "handoff") {
59298
59405
  if (step.task) {
59299
- checkExists(step.task, taskIds, "tasks", `workflow.${phase}.steps[${j2}].task`);
59406
+ checkExists(step.task, taskIds, "tasks", `workflow.${wfId}.steps[${j2}].task`);
59300
59407
  }
59301
59408
  if (step.from_agent) {
59302
- checkExists(step.from_agent, agentIds, "agents", `workflow.${phase}.steps[${j2}].from_agent`);
59409
+ checkExists(step.from_agent, agentIds, "agents", `workflow.${wfId}.steps[${j2}].from_agent`);
59303
59410
  }
59304
59411
  } else if (step.type === "validation") {
59305
- checkExists(step.validation, validationIds, "validations", `workflow.${phase}.steps[${j2}].validation`);
59412
+ checkExists(step.validation, validationIds, "validations", `workflow.${wfId}.steps[${j2}].validation`);
59306
59413
  }
59307
59414
  }
59308
59415
  }
@@ -59556,85 +59663,6 @@ var toolExecutionRule = {
59556
59663
  }
59557
59664
  };
59558
59665
 
59559
- // src/linter/rules/release-audit.ts
59560
- var releaseAuditRule = {
59561
- id: "release-audit",
59562
- description: "Workflow graph completeness: release/audit phases should have proper handoff structures",
59563
- run(dsl) {
59564
- const diagnostics = [];
59565
- const phases = dsl.system.default_phase_order;
59566
- const hasAuditPhase = phases.some(
59567
- (p2) => p2 === "audit" || p2 === "release" || p2 === "review"
59568
- );
59569
- if (!hasAuditPhase) {
59570
- return diagnostics;
59571
- }
59572
- const handoffKinds = new Set(Object.keys(dsl.handoff_types));
59573
- const hasReleaseReadiness = handoffKinds.has("release-readiness");
59574
- const hasReleaseResult = handoffKinds.has("release-result");
59575
- if (!hasReleaseReadiness) {
59576
- diagnostics.push({
59577
- ruleId: "release-audit",
59578
- severity: "warning",
59579
- path: "handoff_types",
59580
- message: 'Missing "release-readiness" handoff type for audit/release workflow'
59581
- });
59582
- }
59583
- if (!hasReleaseResult) {
59584
- diagnostics.push({
59585
- ruleId: "release-audit",
59586
- severity: "warning",
59587
- path: "handoff_types",
59588
- message: 'Missing "release-result" handoff type for audit/release workflow'
59589
- });
59590
- }
59591
- if (phases.some((p2) => p2 === "audit")) {
59592
- const hasAuditReport = handoffKinds.has("audit-report");
59593
- const hasAuditReconciliation = handoffKinds.has("audit-reconciliation");
59594
- if (!hasAuditReport) {
59595
- diagnostics.push({
59596
- ruleId: "release-audit",
59597
- severity: "warning",
59598
- path: "handoff_types",
59599
- message: 'Missing "audit-report" handoff type for audit workflow'
59600
- });
59601
- }
59602
- if (!hasAuditReconciliation) {
59603
- diagnostics.push({
59604
- ruleId: "release-audit",
59605
- severity: "warning",
59606
- path: "handoff_types",
59607
- message: 'Missing "audit-reconciliation" handoff type for audit workflow'
59608
- });
59609
- }
59610
- }
59611
- const workflowPhases = new Set(Object.keys(dsl.workflow));
59612
- for (const phase of phases) {
59613
- if ((phase === "audit" || phase === "release") && !workflowPhases.has(phase)) {
59614
- diagnostics.push({
59615
- ruleId: "release-audit",
59616
- severity: "warning",
59617
- path: "workflow",
59618
- message: `Phase "${phase}" is in default_phase_order but has no workflow definition`
59619
- });
59620
- }
59621
- }
59622
- for (const [phase, wf] of Object.entries(dsl.workflow)) {
59623
- if (phase !== "audit" && phase !== "release") continue;
59624
- const hasDecision = wf.steps.some((s2) => s2.type === "decision");
59625
- if (!hasDecision) {
59626
- diagnostics.push({
59627
- ruleId: "release-audit",
59628
- severity: "info",
59629
- path: `workflow.${phase}`,
59630
- message: `Audit/release workflow phase "${phase}" has no decision step for remediation routing`
59631
- });
59632
- }
59633
- }
59634
- return diagnostics;
59635
- }
59636
- };
59637
-
59638
59666
  // src/linter/rules/task-agent-binding.ts
59639
59667
  var taskAgentBindingRule = {
59640
59668
  id: "task-agent-binding",
@@ -59738,21 +59766,21 @@ var taskAgentBindingRule = {
59738
59766
  // src/linter/rules/merge-integrity.ts
59739
59767
  var mergeIntegrityRule = {
59740
59768
  id: "merge-integrity",
59741
- description: "Post-merge integrity: check that resolved DSL phase order has no duplicates",
59769
+ description: "Post-merge integrity: check that resolved DSL workflow order has no duplicates",
59742
59770
  run(dsl) {
59743
59771
  const diagnostics = [];
59744
- const phases = dsl.system.default_phase_order;
59745
- const phaseSeen = /* @__PURE__ */ new Set();
59746
- for (let i3 = 0; i3 < phases.length; i3++) {
59747
- if (phaseSeen.has(phases[i3])) {
59772
+ const workflows = dsl.system.default_workflow_order;
59773
+ const seen = /* @__PURE__ */ new Set();
59774
+ for (let i3 = 0; i3 < workflows.length; i3++) {
59775
+ if (seen.has(workflows[i3])) {
59748
59776
  diagnostics.push({
59749
59777
  ruleId: "merge-integrity",
59750
59778
  severity: "error",
59751
- path: `system.default_phase_order[${i3}]`,
59752
- message: `Duplicate phase "${phases[i3]}" in default_phase_order`
59779
+ path: `system.default_workflow_order[${i3}]`,
59780
+ message: `Duplicate workflow "${workflows[i3]}" in default_workflow_order`
59753
59781
  });
59754
59782
  }
59755
- phaseSeen.add(phases[i3]);
59783
+ seen.add(workflows[i3]);
59756
59784
  }
59757
59785
  return diagnostics;
59758
59786
  }
@@ -59762,7 +59790,6 @@ var mergeIntegrityRule = {
59762
59790
  var builtinRules = [
59763
59791
  validationCoverageRule,
59764
59792
  toolExecutionRule,
59765
- releaseAuditRule,
59766
59793
  taskAgentBindingRule,
59767
59794
  mergeIntegrityRule
59768
59795
  ];
@@ -60427,9 +60454,9 @@ function buildHandoffTypeContext(dsl, handoffTypeId) {
60427
60454
  ).map(([id, t3]) => ({ ...t3, id }));
60428
60455
  return { handoff_type, relatedTasks, dsl };
60429
60456
  }
60430
- function buildWorkflowContext(dsl, phaseId) {
60431
- const wfDef = dsl.workflow[phaseId];
60432
- const workflow = { ...wfDef, id: phaseId };
60457
+ function buildWorkflowContext(dsl, workflowId) {
60458
+ const wfDef = dsl.workflow[workflowId];
60459
+ const workflow = { ...wfDef, id: workflowId };
60433
60460
  return { workflow, dsl };
60434
60461
  }
60435
60462
  function buildPolicyContext(dsl, policyId) {
@@ -60493,7 +60520,7 @@ function buildDelegatableTasks(dsl, agentId) {
60493
60520
  id: taskId,
60494
60521
  description: t3.description,
60495
60522
  target_agent: t3.target_agent,
60496
- phase: t3.phase,
60523
+ workflow: t3.workflow,
60497
60524
  input_artifacts: t3.input_artifacts,
60498
60525
  invocation_handoff: t3.invocation_handoff,
60499
60526
  invocation_payload_keys: invocationHandoff ? extractPayloadFieldNames(invocationHandoff.payload) : [],