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/index.js CHANGED
@@ -3951,7 +3951,7 @@ var require_lodash = __commonJS({
3951
3951
  }
3952
3952
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
3953
3953
  });
3954
- function join2(array, separator) {
3954
+ function join3(array, separator) {
3955
3955
  return array == null ? "" : nativeJoin.call(array, separator);
3956
3956
  }
3957
3957
  function last(array) {
@@ -5875,7 +5875,7 @@ var require_lodash = __commonJS({
5875
5875
  lodash.isUndefined = isUndefined;
5876
5876
  lodash.isWeakMap = isWeakMap;
5877
5877
  lodash.isWeakSet = isWeakSet;
5878
- lodash.join = join2;
5878
+ lodash.join = join3;
5879
5879
  lodash.kebabCase = kebabCase;
5880
5880
  lodash.last = last;
5881
5881
  lodash.lastIndexOf = lastIndexOf;
@@ -6292,7 +6292,7 @@ var init_index_es = __esm({
6292
6292
  return { drive: t4.toLowerCase() + ":" };
6293
6293
  }, k2 = function() {
6294
6294
  return { drive: null };
6295
- }, z14 = function() {
6295
+ }, z15 = function() {
6296
6296
  return { drive: null };
6297
6297
  }, B2 = function(t4) {
6298
6298
  return { protocol: null, origin: null, absolute: false, drive: null, ...t4 };
@@ -6333,7 +6333,7 @@ var init_index_es = __esm({
6333
6333
  var t4, n4, r4, e4, o4;
6334
6334
  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() {
6335
6335
  var t5;
6336
- return (t5 = x3) !== c2 && (t5 = z14()), t5;
6336
+ return (t5 = x3) !== c2 && (t5 = z15()), t5;
6337
6337
  })()) !== c2 ? (n4 = f2(n4, r4, e4), t4 = n4) : (K2 = t4, t4 = c2)), t4;
6338
6338
  })()) === c2 && (n3 = (function() {
6339
6339
  var n4, r4, e4, o4;
@@ -7496,7 +7496,7 @@ var require_stable = __commonJS({
7496
7496
  return result;
7497
7497
  }
7498
7498
  function stringifyFullFn(key, parent, stack, replacer, indent) {
7499
- var i3, res, join2;
7499
+ var i3, res, join3;
7500
7500
  const originalIndentation = indentation;
7501
7501
  var value = parent[key];
7502
7502
  if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
@@ -7522,12 +7522,12 @@ var require_stable = __commonJS({
7522
7522
  indentation += indent;
7523
7523
  res += `
7524
7524
  ${indentation}`;
7525
- join2 = `,
7525
+ join3 = `,
7526
7526
  ${indentation}`;
7527
7527
  for (i3 = 0; i3 < value.length - 1; i3++) {
7528
7528
  const tmp2 = stringifyFullFn(i3, value, stack, replacer, indent);
7529
7529
  res += tmp2 !== void 0 ? tmp2 : "null";
7530
- res += join2;
7530
+ res += join3;
7531
7531
  }
7532
7532
  const tmp = stringifyFullFn(i3, value, stack, replacer, indent);
7533
7533
  res += tmp !== void 0 ? tmp : "null";
@@ -7549,7 +7549,7 @@ ${originalIndentation}`;
7549
7549
  indentation += indent;
7550
7550
  res += `
7551
7551
  ${indentation}`;
7552
- join2 = `,
7552
+ join3 = `,
7553
7553
  ${indentation}`;
7554
7554
  var separator = "";
7555
7555
  for (i3 = 0; i3 < keys.length; i3++) {
@@ -7557,7 +7557,7 @@ ${indentation}`;
7557
7557
  const tmp = stringifyFullFn(key, value, stack, replacer, indent);
7558
7558
  if (tmp !== void 0) {
7559
7559
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7560
- separator = join2;
7560
+ separator = join3;
7561
7561
  }
7562
7562
  }
7563
7563
  if (separator !== "") {
@@ -7579,7 +7579,7 @@ ${originalIndentation}`;
7579
7579
  }
7580
7580
  }
7581
7581
  function stringifyFullArr(key, value, stack, replacer, indent) {
7582
- var i3, res, join2;
7582
+ var i3, res, join3;
7583
7583
  const originalIndentation = indentation;
7584
7584
  if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
7585
7585
  value = value.toJSON(key);
@@ -7603,12 +7603,12 @@ ${originalIndentation}`;
7603
7603
  indentation += indent;
7604
7604
  res += `
7605
7605
  ${indentation}`;
7606
- join2 = `,
7606
+ join3 = `,
7607
7607
  ${indentation}`;
7608
7608
  for (i3 = 0; i3 < value.length - 1; i3++) {
7609
7609
  const tmp2 = stringifyFullArr(i3, value[i3], stack, replacer, indent);
7610
7610
  res += tmp2 !== void 0 ? tmp2 : "null";
7611
- res += join2;
7611
+ res += join3;
7612
7612
  }
7613
7613
  const tmp = stringifyFullArr(i3, value[i3], stack, replacer, indent);
7614
7614
  res += tmp !== void 0 ? tmp : "null";
@@ -7629,7 +7629,7 @@ ${originalIndentation}`;
7629
7629
  indentation += indent;
7630
7630
  res += `
7631
7631
  ${indentation}`;
7632
- join2 = `,
7632
+ join3 = `,
7633
7633
  ${indentation}`;
7634
7634
  var separator = "";
7635
7635
  for (i3 = 0; i3 < replacer.length; i3++) {
@@ -7638,7 +7638,7 @@ ${indentation}`;
7638
7638
  const tmp = stringifyFullArr(key, value[key], stack, replacer, indent);
7639
7639
  if (tmp !== void 0) {
7640
7640
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7641
- separator = join2;
7641
+ separator = join3;
7642
7642
  }
7643
7643
  }
7644
7644
  }
@@ -7661,7 +7661,7 @@ ${originalIndentation}`;
7661
7661
  }
7662
7662
  }
7663
7663
  function stringifyIndent(key, value, stack, indent) {
7664
- var i3, res, join2;
7664
+ var i3, res, join3;
7665
7665
  const originalIndentation = indentation;
7666
7666
  switch (typeof value) {
7667
7667
  case "object":
@@ -7691,12 +7691,12 @@ ${originalIndentation}`;
7691
7691
  indentation += indent;
7692
7692
  res += `
7693
7693
  ${indentation}`;
7694
- join2 = `,
7694
+ join3 = `,
7695
7695
  ${indentation}`;
7696
7696
  for (i3 = 0; i3 < value.length - 1; i3++) {
7697
7697
  const tmp2 = stringifyIndent(i3, value[i3], stack, indent);
7698
7698
  res += tmp2 !== void 0 ? tmp2 : "null";
7699
- res += join2;
7699
+ res += join3;
7700
7700
  }
7701
7701
  const tmp = stringifyIndent(i3, value[i3], stack, indent);
7702
7702
  res += tmp !== void 0 ? tmp : "null";
@@ -7718,7 +7718,7 @@ ${originalIndentation}`;
7718
7718
  indentation += indent;
7719
7719
  res += `
7720
7720
  ${indentation}`;
7721
- join2 = `,
7721
+ join3 = `,
7722
7722
  ${indentation}`;
7723
7723
  var separator = "";
7724
7724
  for (i3 = 0; i3 < keys.length; i3++) {
@@ -7726,7 +7726,7 @@ ${indentation}`;
7726
7726
  const tmp = stringifyIndent(key, value[key], stack, indent);
7727
7727
  if (tmp !== void 0) {
7728
7728
  res += `${separator}"${strEscape(key)}": ${tmp}`;
7729
- separator = join2;
7729
+ separator = join3;
7730
7730
  }
7731
7731
  }
7732
7732
  if (separator !== "") {
@@ -8022,7 +8022,7 @@ __export(index_es_exports2, {
8022
8022
  resolveExternalRef: () => ye,
8023
8023
  resolveExternalRefWithLocation: () => ge,
8024
8024
  resolveInlineRef: () => B,
8025
- resolveInlineRefWithLocation: () => z12,
8025
+ resolveInlineRefWithLocation: () => z13,
8026
8026
  safeParse: () => de,
8027
8027
  safeStringify: () => ve,
8028
8028
  startsWith: () => be,
@@ -8066,9 +8066,9 @@ function* L(e3, t3, r3) {
8066
8066
  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]);
8067
8067
  }
8068
8068
  function B(e3, t3) {
8069
- return z12(e3, t3).value;
8069
+ return z13(e3, t3).value;
8070
8070
  }
8071
- function z12(e3, t3) {
8071
+ function z13(e3, t3) {
8072
8072
  return (function e4(t4, r3, n3, o3) {
8073
8073
  if (null !== V(r3)) throw new ReferenceError("Cannot resolve external references");
8074
8074
  const i3 = K(r3);
@@ -16898,7 +16898,7 @@ var require_immer_cjs_production_min = __commonJS({
16898
16898
  var t4 = n4[H2];
16899
16899
  return (t4 ? s2(t4) : n4)[r4];
16900
16900
  }
16901
- function z14(n4, r4) {
16901
+ function z15(n4, r4) {
16902
16902
  if (r4 in n4) for (var t4 = Object.getPrototypeOf(n4); t4; ) {
16903
16903
  var e4 = Object.getOwnPropertyDescriptor(t4, r4);
16904
16904
  if (e4) return e4;
@@ -17291,7 +17291,7 @@ var require_immer_cjs_production_min = __commonJS({
17291
17291
  if (r4 === H2) return n4;
17292
17292
  var e4 = s2(n4);
17293
17293
  if (!u2(e4, r4)) return (function(n5, r5, t4) {
17294
- var e5, i5 = z14(r5, t4);
17294
+ var e5, i5 = z15(r5, t4);
17295
17295
  return i5 ? "value" in i5 ? i5.value : null === (e5 = i5.get) || void 0 === e5 ? void 0 : e5.call(n5.k) : void 0;
17296
17296
  })(n4, e4, r4);
17297
17297
  var i4 = e4[r4];
@@ -17301,7 +17301,7 @@ var require_immer_cjs_production_min = __commonJS({
17301
17301
  }, ownKeys: function(n4) {
17302
17302
  return Reflect.ownKeys(s2(n4));
17303
17303
  }, set: function(n4, r4, t4) {
17304
- var e4 = z14(s2(n4), r4);
17304
+ var e4 = z15(s2(n4), r4);
17305
17305
  if (null == e4 ? void 0 : e4.set) return e4.set.call(n4.k, t4), true;
17306
17306
  if (!n4.g) {
17307
17307
  var i4 = A2(s2(n4), r4), o4 = null == i4 ? void 0 : i4[H2];
@@ -35640,11 +35640,11 @@ var require_brace_expansion = __commonJS({
35640
35640
  if (pad) {
35641
35641
  var need = width - c2.length;
35642
35642
  if (need > 0) {
35643
- var z14 = new Array(need + 1).join("0");
35643
+ var z15 = new Array(need + 1).join("0");
35644
35644
  if (i3 < 0)
35645
- c2 = "-" + z14 + c2.slice(1);
35645
+ c2 = "-" + z15 + c2.slice(1);
35646
35646
  else
35647
- c2 = z14 + c2;
35647
+ c2 = z15 + c2;
35648
35648
  }
35649
35649
  }
35650
35650
  }
@@ -52697,7 +52697,7 @@ var require_lodash3 = __commonJS({
52697
52697
  }
52698
52698
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
52699
52699
  });
52700
- function join2(array, separator) {
52700
+ function join3(array, separator) {
52701
52701
  return array == null ? "" : nativeJoin.call(array, separator);
52702
52702
  }
52703
52703
  function last(array) {
@@ -54616,7 +54616,7 @@ var require_lodash3 = __commonJS({
54616
54616
  lodash.isUndefined = isUndefined;
54617
54617
  lodash.isWeakMap = isWeakMap;
54618
54618
  lodash.isWeakSet = isWeakSet;
54619
- lodash.join = join2;
54619
+ lodash.join = join3;
54620
54620
  lodash.kebabCase = kebabCase;
54621
54621
  lodash.last = last;
54622
54622
  lodash.lastIndexOf = lastIndexOf;
@@ -55620,7 +55620,7 @@ var require_dist10 = __commonJS({
55620
55620
  var getSiblings = (parent) => (node) => getChildren(parent).filter(not(eq(node)));
55621
55621
  var concatAll = (
55622
55622
  /*::<T>*/
55623
- (xs) => (ys) => ys.reduce((zs, z14) => zs.concat(z14), xs)
55623
+ (xs) => (ys) => ys.reduce((zs, z15) => zs.concat(z15), xs)
55624
55624
  );
55625
55625
  function getLastSegment(instancePath) {
55626
55626
  const index4 = instancePath.lastIndexOf("/");
@@ -58308,7 +58308,7 @@ var RuleSchema = z.object({
58308
58308
  detection_method: z.string().optional(),
58309
58309
  escalation: z.string().optional(),
58310
58310
  ref: z.string().optional()
58311
- }).strict();
58311
+ }).passthrough();
58312
58312
  var EscalationCriterionSchema = z.object({
58313
58313
  condition: z.string(),
58314
58314
  action: z.enum([
@@ -58316,12 +58316,12 @@ var EscalationCriterionSchema = z.object({
58316
58316
  "report_to_architect",
58317
58317
  "wait_for_approval"
58318
58318
  ])
58319
- }).strict();
58319
+ }).passthrough();
58320
58320
  var PrerequisiteSchema = z.object({
58321
58321
  action: z.enum(["read", "execute"]),
58322
58322
  target: z.string(),
58323
58323
  required: z.boolean()
58324
- }).strict();
58324
+ }).passthrough();
58325
58325
  var AgentSchema = z.object({
58326
58326
  role_name: z.string(),
58327
58327
  purpose: z.string(),
@@ -58363,14 +58363,15 @@ import { z as z3 } from "zod";
58363
58363
  var HandoffTypeSchema = z3.object({
58364
58364
  version: z3.number(),
58365
58365
  description: z3.string().optional(),
58366
- payload: z3.record(z3.string(), z3.any())
58366
+ payload: z3.record(z3.string(), z3.any()),
58367
+ example: z3.record(z3.string(), z3.any()).optional()
58367
58368
  }).passthrough();
58368
58369
 
58369
58370
  // src/schema/policy.ts
58370
58371
  import { z as z4 } from "zod";
58371
58372
  var PolicyWhenSchema = z4.object({
58372
58373
  artifact_type: z4.string().optional(),
58373
- phase: z4.string().optional()
58374
+ workflow: z4.string().optional()
58374
58375
  }).passthrough();
58375
58376
  var PolicySchema = z4.object({
58376
58377
  when: PolicyWhenSchema,
@@ -58385,7 +58386,7 @@ var ExtendsSchema = z5.string().optional();
58385
58386
  var SystemSchema = z5.object({
58386
58387
  id: z5.string(),
58387
58388
  name: z5.string(),
58388
- default_phase_order: z5.array(z5.string())
58389
+ default_workflow_order: z5.array(z5.string())
58389
58390
  }).passthrough();
58390
58391
 
58391
58392
  // src/schema/task.ts
@@ -58393,6 +58394,7 @@ import { z as z6 } from "zod";
58393
58394
  var ExecutionStepSchema = z6.object({
58394
58395
  id: z6.string(),
58395
58396
  action: z6.string(),
58397
+ description: z6.string().optional(),
58396
58398
  required: z6.boolean().optional(),
58397
58399
  abort_on_failure: z6.boolean().optional(),
58398
58400
  uses_tool: z6.string().optional(),
@@ -58400,12 +58402,12 @@ var ExecutionStepSchema = z6.object({
58400
58402
  depends_on: z6.array(z6.string()).optional(),
58401
58403
  skip_condition: z6.string().optional(),
58402
58404
  wait_for_approval: z6.boolean().optional()
58403
- }).strict();
58405
+ }).passthrough();
58404
58406
  var TaskSchema = z6.object({
58405
58407
  description: z6.string(),
58406
58408
  target_agent: z6.string(),
58407
58409
  allowed_from_agents: z6.array(z6.string()),
58408
- phase: z6.string(),
58410
+ workflow: z6.string(),
58409
58411
  input_artifacts: z6.array(z6.string()),
58410
58412
  invocation_handoff: z6.string(),
58411
58413
  result_handoff: z6.string(),
@@ -58445,19 +58447,22 @@ var ValidationSchema = z8.object({
58445
58447
  import { z as z9 } from "zod";
58446
58448
  var WorkflowHandoffStepSchema = z9.object({
58447
58449
  type: z9.literal("handoff"),
58450
+ description: z9.string().optional(),
58448
58451
  handoff_kind: z9.string(),
58449
58452
  task: z9.string().optional(),
58450
58453
  from_agent: z9.string().optional()
58451
- }).strict();
58454
+ }).passthrough();
58452
58455
  var WorkflowValidationStepSchema = z9.object({
58453
58456
  type: z9.literal("validation"),
58457
+ description: z9.string().optional(),
58454
58458
  validation: z9.string()
58455
- }).strict();
58459
+ }).passthrough();
58456
58460
  var WorkflowDecisionStepSchema = z9.object({
58457
58461
  type: z9.literal("decision"),
58462
+ description: z9.string().optional(),
58458
58463
  on: z9.string(),
58459
58464
  branches: z9.record(z9.string(), z9.array(z9.string()))
58460
- }).strict();
58465
+ }).passthrough();
58461
58466
  var WorkflowStepSchema = z9.discriminatedUnion("type", [
58462
58467
  WorkflowHandoffStepSchema,
58463
58468
  WorkflowValidationStepSchema,
@@ -58465,6 +58470,7 @@ var WorkflowStepSchema = z9.discriminatedUnion("type", [
58465
58470
  ]);
58466
58471
  var WorkflowSchema = z9.object({
58467
58472
  entry_conditions: z9.array(z9.string()).default([]),
58473
+ trigger: z9.string().optional(),
58468
58474
  steps: z9.array(WorkflowStepSchema)
58469
58475
  }).passthrough();
58470
58476
 
@@ -58503,8 +58509,8 @@ var RemoveOperatorSchema = z11.object({
58503
58509
  });
58504
58510
 
58505
58511
  // src/loader/loader.ts
58506
- import { readFile } from "fs/promises";
58507
- import { dirname, resolve } from "path";
58512
+ import { readFile, readdir, stat as fsStat } from "fs/promises";
58513
+ import { dirname, resolve, join, extname } from "path";
58508
58514
  import { parse as parseYaml } from "yaml";
58509
58515
  var DslLoadError = class extends Error {
58510
58516
  constructor(message, filePath) {
@@ -58514,18 +58520,16 @@ var DslLoadError = class extends Error {
58514
58520
  }
58515
58521
  filePath;
58516
58522
  };
58517
- var REF_ELIGIBLE_SECTIONS = [
58518
- "agents",
58519
- "tasks",
58520
- "artifacts",
58521
- "tools",
58522
- "validations",
58523
- "handoff_types",
58524
- "workflow",
58525
- "policies"
58526
- ];
58523
+ function isRecord(v2) {
58524
+ return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
58525
+ }
58527
58526
  function isRef(value) {
58528
- return typeof value === "object" && value !== null && "$ref" in value && typeof value["$ref"] === "string";
58527
+ return isRecord(value) && "$ref" in value && typeof value["$ref"] === "string";
58528
+ }
58529
+ function hasRefs(value) {
58530
+ if (!("$refs" in value)) return false;
58531
+ const refs = value["$refs"];
58532
+ return Array.isArray(refs) && refs.every((r3) => typeof r3 === "string");
58529
58533
  }
58530
58534
  async function readYaml(filePath) {
58531
58535
  let content;
@@ -58547,17 +58551,160 @@ async function readYaml(filePath) {
58547
58551
  );
58548
58552
  }
58549
58553
  }
58550
- async function resolveRefs(data, baseDir) {
58551
- const resolved = { ...data };
58552
- for (const section of REF_ELIGIBLE_SECTIONS) {
58553
- const value = resolved[section];
58554
- if (isRef(value)) {
58555
- const refPath = resolve(baseDir, value.$ref);
58556
- resolved[section] = await readYaml(refPath);
58554
+ function deepMergeRefs(a3, b3, sourcePath) {
58555
+ const result = { ...a3 };
58556
+ for (const [key, bVal] of Object.entries(b3)) {
58557
+ const aVal = result[key];
58558
+ if (aVal === void 0) {
58559
+ result[key] = bVal;
58560
+ } else if (isRecord(aVal) && isRecord(bVal)) {
58561
+ result[key] = deepMergeRefs(aVal, bVal, sourcePath);
58562
+ } else {
58563
+ throw new DslLoadError(
58564
+ `Conflicting value for key "${key}" while merging $refs from ${sourcePath}`,
58565
+ sourcePath
58566
+ );
58567
+ }
58568
+ }
58569
+ return result;
58570
+ }
58571
+ async function loadRefsSource(refPath, baseDir, resolving) {
58572
+ const target = resolve(baseDir, refPath);
58573
+ const s2 = await fsStat(target).catch(() => null);
58574
+ if (s2?.isDirectory()) {
58575
+ if (resolving.has(target)) {
58576
+ throw new DslLoadError(`Circular $refs detected: ${target}`, target);
58557
58577
  }
58578
+ resolving.add(target);
58579
+ const result = await loadDirectoryAsMap(target, resolving);
58580
+ resolving.delete(target);
58581
+ return result;
58582
+ }
58583
+ if (!s2?.isFile()) {
58584
+ throw new DslLoadError(`File not found: ${target}`, target);
58585
+ }
58586
+ if (resolving.has(target)) {
58587
+ throw new DslLoadError(`Circular $refs detected: ${target}`, target);
58588
+ }
58589
+ resolving.add(target);
58590
+ const content = await readYaml(target);
58591
+ if (!isRecord(content)) {
58592
+ throw new DslLoadError(
58593
+ `Expected YAML object in ${target}, got ${Array.isArray(content) ? "array" : typeof content}`,
58594
+ target
58595
+ );
58558
58596
  }
58597
+ const resolved = await resolveRefsDeep(
58598
+ content,
58599
+ dirname(target),
58600
+ resolving
58601
+ );
58602
+ resolving.delete(target);
58559
58603
  return resolved;
58560
58604
  }
58605
+ async function loadDirectoryAsMap(dirPath, resolving) {
58606
+ let entries;
58607
+ try {
58608
+ entries = await readdir(dirPath);
58609
+ } catch {
58610
+ throw new DslLoadError(
58611
+ `Cannot read directory: ${dirPath}`,
58612
+ dirPath
58613
+ );
58614
+ }
58615
+ const yamlFiles = entries.filter((f2) => [".yaml", ".yml"].includes(extname(f2))).sort();
58616
+ if (yamlFiles.length === 0) {
58617
+ throw new DslLoadError(
58618
+ `No YAML files found in directory: ${dirPath}`,
58619
+ dirPath
58620
+ );
58621
+ }
58622
+ let merged = {};
58623
+ for (const file of yamlFiles) {
58624
+ const filePath = join(dirPath, file);
58625
+ const content = await readYaml(filePath);
58626
+ if (!isRecord(content)) {
58627
+ throw new DslLoadError(
58628
+ `Expected YAML object in ${filePath}, got ${Array.isArray(content) ? "array" : typeof content}`,
58629
+ filePath
58630
+ );
58631
+ }
58632
+ const resolved = await resolveRefsDeep(
58633
+ content,
58634
+ dirPath,
58635
+ resolving
58636
+ );
58637
+ merged = deepMergeRefs(merged, resolved, filePath);
58638
+ }
58639
+ return merged;
58640
+ }
58641
+ async function processRefs(obj, baseDir, resolving) {
58642
+ const refPaths = obj["$refs"];
58643
+ const inline = {};
58644
+ for (const [key, value] of Object.entries(obj)) {
58645
+ if (key !== "$refs") {
58646
+ inline[key] = value;
58647
+ }
58648
+ }
58649
+ let merged = {};
58650
+ for (const refPath of refPaths) {
58651
+ const loaded = await loadRefsSource(refPath, baseDir, resolving);
58652
+ merged = deepMergeRefs(merged, loaded, refPath);
58653
+ }
58654
+ merged = deepMergeRefs(merged, inline, "(inline)");
58655
+ return merged;
58656
+ }
58657
+ async function resolveRefsDeep(data, baseDir, resolving) {
58658
+ if (typeof data !== "object" || data === null) return data;
58659
+ if (Array.isArray(data)) {
58660
+ return Promise.all(
58661
+ data.map((item) => resolveRefsDeep(item, baseDir, resolving))
58662
+ );
58663
+ }
58664
+ if (isRef(data)) {
58665
+ const refTarget = resolve(baseDir, data.$ref);
58666
+ const s2 = await fsStat(refTarget).catch(() => null);
58667
+ if (s2?.isDirectory()) {
58668
+ if (resolving.has(refTarget)) {
58669
+ throw new DslLoadError(
58670
+ `Circular $ref detected: ${refTarget}`,
58671
+ refTarget
58672
+ );
58673
+ }
58674
+ resolving.add(refTarget);
58675
+ const result2 = await loadDirectoryAsMap(refTarget, resolving);
58676
+ resolving.delete(refTarget);
58677
+ return result2;
58678
+ }
58679
+ if (!s2?.isFile()) {
58680
+ throw new DslLoadError(`File not found: ${refTarget}`, refTarget);
58681
+ }
58682
+ if (resolving.has(refTarget)) {
58683
+ throw new DslLoadError(
58684
+ `Circular $ref detected: ${refTarget}`,
58685
+ refTarget
58686
+ );
58687
+ }
58688
+ resolving.add(refTarget);
58689
+ const content = await readYaml(refTarget);
58690
+ const resolved = await resolveRefsDeep(
58691
+ content,
58692
+ dirname(refTarget),
58693
+ resolving
58694
+ );
58695
+ resolving.delete(refTarget);
58696
+ return resolved;
58697
+ }
58698
+ let obj = data;
58699
+ if (hasRefs(obj)) {
58700
+ obj = await processRefs(obj, baseDir, resolving);
58701
+ }
58702
+ const result = {};
58703
+ for (const [key, value] of Object.entries(obj)) {
58704
+ result[key] = await resolveRefsDeep(value, baseDir, resolving);
58705
+ }
58706
+ return result;
58707
+ }
58561
58708
  function checkVersion(data, filePath) {
58562
58709
  const version = data["version"];
58563
58710
  if (version === void 0) {
@@ -58585,12 +58732,17 @@ async function loadDsl(entryPath) {
58585
58732
  const data = raw;
58586
58733
  checkVersion(data, absPath);
58587
58734
  const baseDir = dirname(absPath);
58588
- const resolved = await resolveRefs(data, baseDir);
58735
+ const resolving = /* @__PURE__ */ new Set([absPath]);
58736
+ const resolved = await resolveRefsDeep(
58737
+ data,
58738
+ baseDir,
58739
+ resolving
58740
+ );
58589
58741
  return { data: resolved, filePath: absPath };
58590
58742
  }
58591
58743
 
58592
58744
  // src/resolver/base-resolver.ts
58593
- import { resolve as resolve2, join } from "path";
58745
+ import { resolve as resolve2, join as join2 } from "path";
58594
58746
  import { stat } from "fs/promises";
58595
58747
  var BaseResolveError = class extends Error {
58596
58748
  constructor(message) {
@@ -58601,7 +58753,7 @@ var BaseResolveError = class extends Error {
58601
58753
  async function findEntryFile(dir) {
58602
58754
  const candidates = ["agent-contracts.yaml", "agent-contracts.yml"];
58603
58755
  for (const name of candidates) {
58604
- const p2 = join(dir, name);
58756
+ const p2 = join2(dir, name);
58605
58757
  try {
58606
58758
  const s2 = await stat(p2);
58607
58759
  if (s2.isFile()) return p2;
@@ -58653,7 +58805,7 @@ var MergeError = class extends Error {
58653
58805
  this.name = "MergeError";
58654
58806
  }
58655
58807
  };
58656
- function isRecord(v2) {
58808
+ function isRecord2(v2) {
58657
58809
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
58658
58810
  }
58659
58811
  function hasOperator(obj) {
@@ -58665,7 +58817,7 @@ function hasOperator(obj) {
58665
58817
  }
58666
58818
  function findIndexById(arr, id) {
58667
58819
  return arr.findIndex(
58668
- (item) => isRecord(item) && item["id"] === id
58820
+ (item) => isRecord2(item) && item["id"] === id
58669
58821
  );
58670
58822
  }
58671
58823
  function applyArrayMergeOperator(baseArray, operatorObj, path) {
@@ -58701,7 +58853,7 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
58701
58853
  const removeList = operatorObj["$remove"];
58702
58854
  const idsToRemove = new Set(removeList.map((r3) => r3["id"]));
58703
58855
  const result = baseArray.filter((item) => {
58704
- if (isRecord(item) && typeof item["id"] === "string") {
58856
+ if (isRecord2(item) && typeof item["id"] === "string") {
58705
58857
  const itemId = item["id"];
58706
58858
  if (idsToRemove.has(itemId)) {
58707
58859
  idsToRemove.delete(itemId);
@@ -58790,7 +58942,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
58790
58942
  for (const key of Object.keys(project)) {
58791
58943
  const baseVal = result[key];
58792
58944
  const projVal = project[key];
58793
- if (isRecord(projVal) && hasOperator(projVal)) {
58945
+ if (isRecord2(projVal) && hasOperator(projVal)) {
58794
58946
  if (!hasExtends) {
58795
58947
  throw new MergeError(
58796
58948
  `Merge operator used without extends at ${path}.${key}`
@@ -58798,12 +58950,12 @@ function deepMergeEntities(base, project, path, hasExtends) {
58798
58950
  }
58799
58951
  if (Array.isArray(baseVal)) {
58800
58952
  result[key] = applyArrayMergeOperator(baseVal, projVal, `${path}.${key}`);
58801
- } else if (isRecord(baseVal)) {
58953
+ } else if (isRecord2(baseVal)) {
58802
58954
  result[key] = applyMapMergeOperator(baseVal, projVal, `${path}.${key}`);
58803
58955
  } else {
58804
58956
  result[key] = applyArrayMergeOperator([], projVal, `${path}.${key}`);
58805
58957
  }
58806
- } else if (isRecord(projVal) && isRecord(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
58958
+ } else if (isRecord2(projVal) && isRecord2(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
58807
58959
  result[key] = deepMergeEntities(
58808
58960
  baseVal,
58809
58961
  projVal,
@@ -58817,7 +58969,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
58817
58969
  return result;
58818
58970
  }
58819
58971
  function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
58820
- if (isRecord(projectMap) && !Array.isArray(projectMap)) {
58972
+ if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
58821
58973
  const op = hasOperator(projectMap);
58822
58974
  if (op) {
58823
58975
  if (!hasExtends) {
@@ -58831,7 +58983,7 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
58831
58983
  const result = { ...baseMap };
58832
58984
  for (const [key, projVal] of Object.entries(projectMap)) {
58833
58985
  const baseVal = result[key];
58834
- if (baseVal !== void 0 && isRecord(baseVal) && isRecord(projVal)) {
58986
+ if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
58835
58987
  result[key] = deepMergeEntities(
58836
58988
  baseVal,
58837
58989
  projVal,
@@ -58871,7 +59023,7 @@ function mergeDsl(base, project) {
58871
59023
  if (projVal === void 0) {
58872
59024
  continue;
58873
59025
  }
58874
- const baseMap = isRecord(baseVal) ? baseVal : {};
59026
+ const baseMap = isRecord2(baseVal) ? baseVal : {};
58875
59027
  result[section] = mergeEntityMaps(
58876
59028
  baseMap,
58877
59029
  projVal,
@@ -58907,113 +59059,66 @@ async function resolve3(projectDirOrFile) {
58907
59059
  }
58908
59060
 
58909
59061
  // src/validator/schema-validator.ts
58910
- function hasNonExtensionCustomProps(obj, knownKeys, path) {
58911
- const diagnostics = [];
58912
- for (const key of Object.keys(obj)) {
58913
- if (knownKeys.has(key)) continue;
58914
- if (key.startsWith("x-")) continue;
58915
- diagnostics.push({
58916
- path: `${path}.${key}`,
58917
- message: `Unknown property "${key}". Custom properties must use "x-" prefix.`,
58918
- code: "unknown-property"
58919
- });
58920
- }
58921
- return diagnostics;
59062
+ import { z as z12 } from "zod";
59063
+ function unwrap(schema) {
59064
+ if (schema instanceof z12.ZodOptional) return unwrap(schema.unwrap());
59065
+ if (schema instanceof z12.ZodDefault) return unwrap(schema.removeDefault());
59066
+ if (schema instanceof z12.ZodNullable) return unwrap(schema.unwrap());
59067
+ return schema;
58922
59068
  }
58923
- var SYSTEM_KEYS = /* @__PURE__ */ new Set(["id", "name", "default_phase_order"]);
58924
- var AGENT_KEYS = /* @__PURE__ */ new Set([
58925
- "role_name",
58926
- "purpose",
58927
- "can_read_artifacts",
58928
- "can_write_artifacts",
58929
- "can_execute_tools",
58930
- "can_perform_validations",
58931
- "can_invoke_agents",
58932
- "can_return_handoffs",
58933
- "dispatch_only",
58934
- "mode",
58935
- "responsibilities",
58936
- "constraints",
58937
- "rules",
58938
- "anti_patterns",
58939
- "escalation_criteria",
58940
- "prerequisites"
58941
- ]);
58942
- var TASK_KEYS = /* @__PURE__ */ new Set([
58943
- "description",
58944
- "target_agent",
58945
- "allowed_from_agents",
58946
- "phase",
58947
- "input_artifacts",
58948
- "invocation_handoff",
58949
- "result_handoff",
58950
- "default_priority",
58951
- "responsibilities",
58952
- "constraints",
58953
- "execution_steps",
58954
- "completion_criteria",
58955
- "rules",
58956
- "anti_patterns",
58957
- "escalation_criteria"
58958
- ]);
58959
- var ARTIFACT_KEYS = /* @__PURE__ */ new Set([
58960
- "type",
58961
- "description",
58962
- "owner",
58963
- "producers",
58964
- "editors",
58965
- "consumers",
58966
- "states",
58967
- "required_validations",
58968
- "visibility"
58969
- ]);
58970
- var TOOL_KEYS = /* @__PURE__ */ new Set([
58971
- "kind",
58972
- "description",
58973
- "input_artifacts",
58974
- "output_artifacts",
58975
- "invokable_by",
58976
- "side_effects"
58977
- ]);
58978
- var VALIDATION_KEYS = /* @__PURE__ */ new Set([
58979
- "target_artifact",
58980
- "kind",
58981
- "executor_type",
58982
- "executor",
58983
- "blocking",
58984
- "produces_evidence"
58985
- ]);
58986
- var HANDOFF_TYPE_KEYS = /* @__PURE__ */ new Set(["version", "description", "payload"]);
58987
- var WORKFLOW_KEYS = /* @__PURE__ */ new Set(["entry_conditions", "steps"]);
58988
- var POLICY_KEYS = /* @__PURE__ */ new Set(["when", "requires_validations", "requires"]);
58989
- function checkCustomProps(data) {
58990
- const diagnostics = [];
58991
- if (data["system"] && typeof data["system"] === "object") {
58992
- diagnostics.push(
58993
- ...hasNonExtensionCustomProps(data["system"], SYSTEM_KEYS, "system")
58994
- );
59069
+ function checkCustomPropsRecursive(data, schema, path) {
59070
+ const inner = unwrap(schema);
59071
+ if (inner instanceof z12.ZodObject) {
59072
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
59073
+ const obj = data;
59074
+ const shape = inner.shape;
59075
+ const knownKeys = new Set(Object.keys(shape));
59076
+ const diagnostics = [];
59077
+ for (const key of Object.keys(obj)) {
59078
+ if (knownKeys.has(key)) continue;
59079
+ if (key.startsWith("x-")) continue;
59080
+ diagnostics.push({
59081
+ path: path ? `${path}.${key}` : key,
59082
+ message: `Unknown property "${key}". Custom properties must use "x-" prefix.`,
59083
+ code: "unknown-property"
59084
+ });
59085
+ }
59086
+ for (const [field, fieldSchema] of Object.entries(shape)) {
59087
+ if (obj[field] === void 0) continue;
59088
+ diagnostics.push(...checkCustomPropsRecursive(obj[field], fieldSchema, path ? `${path}.${field}` : field));
59089
+ }
59090
+ return diagnostics;
58995
59091
  }
58996
- const sections = [
58997
- { key: "agents", knownKeys: AGENT_KEYS },
58998
- { key: "tasks", knownKeys: TASK_KEYS },
58999
- { key: "artifacts", knownKeys: ARTIFACT_KEYS },
59000
- { key: "tools", knownKeys: TOOL_KEYS },
59001
- { key: "validations", knownKeys: VALIDATION_KEYS },
59002
- { key: "handoff_types", knownKeys: HANDOFF_TYPE_KEYS },
59003
- { key: "workflow", knownKeys: WORKFLOW_KEYS },
59004
- { key: "policies", knownKeys: POLICY_KEYS }
59005
- ];
59006
- for (const { key, knownKeys } of sections) {
59007
- const map = data[key];
59008
- if (typeof map !== "object" || map === null || Array.isArray(map)) continue;
59009
- for (const [entryKey, item] of Object.entries(map)) {
59010
- if (typeof item !== "object" || item === null) continue;
59011
- diagnostics.push(
59012
- ...hasNonExtensionCustomProps(item, knownKeys, `${key}.${entryKey}`)
59013
- );
59092
+ if (inner instanceof z12.ZodRecord) {
59093
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
59094
+ const valueSchema = inner._def.valueType;
59095
+ const diagnostics = [];
59096
+ for (const [key, value] of Object.entries(data)) {
59097
+ diagnostics.push(...checkCustomPropsRecursive(value, valueSchema, path ? `${path}.${key}` : key));
59098
+ }
59099
+ return diagnostics;
59100
+ }
59101
+ if (inner instanceof z12.ZodArray) {
59102
+ if (!Array.isArray(data)) return [];
59103
+ const diagnostics = [];
59104
+ for (let i3 = 0; i3 < data.length; i3++) {
59105
+ diagnostics.push(...checkCustomPropsRecursive(data[i3], inner.element, `${path}[${i3}]`));
59014
59106
  }
59107
+ return diagnostics;
59015
59108
  }
59016
- return diagnostics;
59109
+ if (inner instanceof z12.ZodDiscriminatedUnion) {
59110
+ if (typeof data !== "object" || data === null) return [];
59111
+ const obj = data;
59112
+ const disc = inner._def.discriminator;
59113
+ const discValue = obj[disc];
59114
+ const match = inner.options.find((opt) => {
59115
+ const shape = opt.shape;
59116
+ return shape[disc] instanceof z12.ZodLiteral && shape[disc].value === discValue;
59117
+ });
59118
+ if (match) return checkCustomPropsRecursive(data, match, path);
59119
+ return [];
59120
+ }
59121
+ return [];
59017
59122
  }
59018
59123
  function validateSchema(data) {
59019
59124
  const result = DslSchema.safeParse(data);
@@ -59025,7 +59130,7 @@ function validateSchema(data) {
59025
59130
  }));
59026
59131
  return { success: false, diagnostics };
59027
59132
  }
59028
- const customPropDiagnostics = checkCustomProps(data);
59133
+ const customPropDiagnostics = checkCustomPropsRecursive(data, DslSchema, "");
59029
59134
  if (customPropDiagnostics.length > 0) {
59030
59135
  return { success: false, diagnostics: customPropDiagnostics };
59031
59136
  }
@@ -59041,7 +59146,7 @@ function checkReferences(dsl) {
59041
59146
  const validationIds = new Set(Object.keys(dsl.validations));
59042
59147
  const handoffKinds = new Set(Object.keys(dsl.handoff_types));
59043
59148
  const taskIds = new Set(Object.keys(dsl.tasks));
59044
- const phases = new Set(dsl.system.default_phase_order);
59149
+ const workflowIds = new Set(dsl.system.default_workflow_order);
59045
59150
  function checkExists(value, validSet, entityType, path) {
59046
59151
  if (!validSet.has(value)) {
59047
59152
  diagnostics.push({
@@ -59127,26 +59232,26 @@ function checkReferences(dsl) {
59127
59232
  for (const ref of task.allowed_from_agents) {
59128
59233
  checkExists(ref, agentIds, "agents", `tasks.${id}.allowed_from_agents`);
59129
59234
  }
59130
- checkExists(task.phase, phases, "system.default_phase_order", `tasks.${id}.phase`);
59235
+ checkExists(task.workflow, workflowIds, "system.default_workflow_order", `tasks.${id}.workflow`);
59131
59236
  checkExists(task.invocation_handoff, handoffKinds, "handoff_types", `tasks.${id}.invocation_handoff`);
59132
59237
  checkExists(task.result_handoff, handoffKinds, "handoff_types", `tasks.${id}.result_handoff`);
59133
59238
  for (const ref of task.input_artifacts) {
59134
59239
  checkExists(ref, artifactIds, "artifacts", `tasks.${id}.input_artifacts`);
59135
59240
  }
59136
59241
  }
59137
- for (const [phase, wf] of Object.entries(dsl.workflow)) {
59138
- checkExists(phase, phases, "system.default_phase_order", `workflow.${phase}`);
59242
+ for (const [wfId, wf] of Object.entries(dsl.workflow)) {
59243
+ checkExists(wfId, workflowIds, "system.default_workflow_order", `workflow.${wfId}`);
59139
59244
  for (let j2 = 0; j2 < wf.steps.length; j2++) {
59140
59245
  const step = wf.steps[j2];
59141
59246
  if (step.type === "handoff") {
59142
59247
  if (step.task) {
59143
- checkExists(step.task, taskIds, "tasks", `workflow.${phase}.steps[${j2}].task`);
59248
+ checkExists(step.task, taskIds, "tasks", `workflow.${wfId}.steps[${j2}].task`);
59144
59249
  }
59145
59250
  if (step.from_agent) {
59146
- checkExists(step.from_agent, agentIds, "agents", `workflow.${phase}.steps[${j2}].from_agent`);
59251
+ checkExists(step.from_agent, agentIds, "agents", `workflow.${wfId}.steps[${j2}].from_agent`);
59147
59252
  }
59148
59253
  } else if (step.type === "validation") {
59149
- checkExists(step.validation, validationIds, "validations", `workflow.${phase}.steps[${j2}].validation`);
59254
+ checkExists(step.validation, validationIds, "validations", `workflow.${wfId}.steps[${j2}].validation`);
59150
59255
  }
59151
59256
  }
59152
59257
  }
@@ -59354,85 +59459,6 @@ var toolExecutionRule = {
59354
59459
  }
59355
59460
  };
59356
59461
 
59357
- // src/linter/rules/release-audit.ts
59358
- var releaseAuditRule = {
59359
- id: "release-audit",
59360
- description: "Workflow graph completeness: release/audit phases should have proper handoff structures",
59361
- run(dsl) {
59362
- const diagnostics = [];
59363
- const phases = dsl.system.default_phase_order;
59364
- const hasAuditPhase = phases.some(
59365
- (p2) => p2 === "audit" || p2 === "release" || p2 === "review"
59366
- );
59367
- if (!hasAuditPhase) {
59368
- return diagnostics;
59369
- }
59370
- const handoffKinds = new Set(Object.keys(dsl.handoff_types));
59371
- const hasReleaseReadiness = handoffKinds.has("release-readiness");
59372
- const hasReleaseResult = handoffKinds.has("release-result");
59373
- if (!hasReleaseReadiness) {
59374
- diagnostics.push({
59375
- ruleId: "release-audit",
59376
- severity: "warning",
59377
- path: "handoff_types",
59378
- message: 'Missing "release-readiness" handoff type for audit/release workflow'
59379
- });
59380
- }
59381
- if (!hasReleaseResult) {
59382
- diagnostics.push({
59383
- ruleId: "release-audit",
59384
- severity: "warning",
59385
- path: "handoff_types",
59386
- message: 'Missing "release-result" handoff type for audit/release workflow'
59387
- });
59388
- }
59389
- if (phases.some((p2) => p2 === "audit")) {
59390
- const hasAuditReport = handoffKinds.has("audit-report");
59391
- const hasAuditReconciliation = handoffKinds.has("audit-reconciliation");
59392
- if (!hasAuditReport) {
59393
- diagnostics.push({
59394
- ruleId: "release-audit",
59395
- severity: "warning",
59396
- path: "handoff_types",
59397
- message: 'Missing "audit-report" handoff type for audit workflow'
59398
- });
59399
- }
59400
- if (!hasAuditReconciliation) {
59401
- diagnostics.push({
59402
- ruleId: "release-audit",
59403
- severity: "warning",
59404
- path: "handoff_types",
59405
- message: 'Missing "audit-reconciliation" handoff type for audit workflow'
59406
- });
59407
- }
59408
- }
59409
- const workflowPhases = new Set(Object.keys(dsl.workflow));
59410
- for (const phase of phases) {
59411
- if ((phase === "audit" || phase === "release") && !workflowPhases.has(phase)) {
59412
- diagnostics.push({
59413
- ruleId: "release-audit",
59414
- severity: "warning",
59415
- path: "workflow",
59416
- message: `Phase "${phase}" is in default_phase_order but has no workflow definition`
59417
- });
59418
- }
59419
- }
59420
- for (const [phase, wf] of Object.entries(dsl.workflow)) {
59421
- if (phase !== "audit" && phase !== "release") continue;
59422
- const hasDecision = wf.steps.some((s2) => s2.type === "decision");
59423
- if (!hasDecision) {
59424
- diagnostics.push({
59425
- ruleId: "release-audit",
59426
- severity: "info",
59427
- path: `workflow.${phase}`,
59428
- message: `Audit/release workflow phase "${phase}" has no decision step for remediation routing`
59429
- });
59430
- }
59431
- }
59432
- return diagnostics;
59433
- }
59434
- };
59435
-
59436
59462
  // src/linter/rules/task-agent-binding.ts
59437
59463
  var taskAgentBindingRule = {
59438
59464
  id: "task-agent-binding",
@@ -59536,21 +59562,21 @@ var taskAgentBindingRule = {
59536
59562
  // src/linter/rules/merge-integrity.ts
59537
59563
  var mergeIntegrityRule = {
59538
59564
  id: "merge-integrity",
59539
- description: "Post-merge integrity: check that resolved DSL phase order has no duplicates",
59565
+ description: "Post-merge integrity: check that resolved DSL workflow order has no duplicates",
59540
59566
  run(dsl) {
59541
59567
  const diagnostics = [];
59542
- const phases = dsl.system.default_phase_order;
59543
- const phaseSeen = /* @__PURE__ */ new Set();
59544
- for (let i3 = 0; i3 < phases.length; i3++) {
59545
- if (phaseSeen.has(phases[i3])) {
59568
+ const workflows = dsl.system.default_workflow_order;
59569
+ const seen = /* @__PURE__ */ new Set();
59570
+ for (let i3 = 0; i3 < workflows.length; i3++) {
59571
+ if (seen.has(workflows[i3])) {
59546
59572
  diagnostics.push({
59547
59573
  ruleId: "merge-integrity",
59548
59574
  severity: "error",
59549
- path: `system.default_phase_order[${i3}]`,
59550
- message: `Duplicate phase "${phases[i3]}" in default_phase_order`
59575
+ path: `system.default_workflow_order[${i3}]`,
59576
+ message: `Duplicate workflow "${workflows[i3]}" in default_workflow_order`
59551
59577
  });
59552
59578
  }
59553
- phaseSeen.add(phases[i3]);
59579
+ seen.add(workflows[i3]);
59554
59580
  }
59555
59581
  return diagnostics;
59556
59582
  }
@@ -59560,7 +59586,6 @@ var mergeIntegrityRule = {
59560
59586
  var builtinRules = [
59561
59587
  validationCoverageRule,
59562
59588
  toolExecutionRule,
59563
- releaseAuditRule,
59564
59589
  taskAgentBindingRule,
59565
59590
  mergeIntegrityRule
59566
59591
  ];
@@ -60191,9 +60216,9 @@ function buildHandoffTypeContext(dsl, handoffTypeId) {
60191
60216
  ).map(([id, t3]) => ({ ...t3, id }));
60192
60217
  return { handoff_type, relatedTasks, dsl };
60193
60218
  }
60194
- function buildWorkflowContext(dsl, phaseId) {
60195
- const wfDef = dsl.workflow[phaseId];
60196
- const workflow = { ...wfDef, id: phaseId };
60219
+ function buildWorkflowContext(dsl, workflowId) {
60220
+ const wfDef = dsl.workflow[workflowId];
60221
+ const workflow = { ...wfDef, id: workflowId };
60197
60222
  return { workflow, dsl };
60198
60223
  }
60199
60224
  function buildPolicyContext(dsl, policyId) {
@@ -60257,7 +60282,7 @@ function buildDelegatableTasks(dsl, agentId) {
60257
60282
  id: taskId,
60258
60283
  description: t3.description,
60259
60284
  target_agent: t3.target_agent,
60260
- phase: t3.phase,
60285
+ workflow: t3.workflow,
60261
60286
  input_artifacts: t3.input_artifacts,
60262
60287
  invocation_handoff: t3.invocation_handoff,
60263
60288
  invocation_payload_keys: invocationHandoff ? extractPayloadFieldNames(invocationHandoff.payload) : [],
@@ -60508,7 +60533,7 @@ async function checkDriftFromConfig(dsl, renderTargets) {
60508
60533
  }
60509
60534
 
60510
60535
  // src/config/types.ts
60511
- import { z as z13 } from "zod";
60536
+ import { z as z14 } from "zod";
60512
60537
  var CONTEXT_TYPES = [
60513
60538
  "agent",
60514
60539
  "task",
@@ -60520,16 +60545,16 @@ var CONTEXT_TYPES = [
60520
60545
  "policy",
60521
60546
  "system"
60522
60547
  ];
60523
- var ContextTypeSchema = z13.enum(CONTEXT_TYPES);
60548
+ var ContextTypeSchema = z14.enum(CONTEXT_TYPES);
60524
60549
  var ITERABLE_CONTEXT_TYPES = CONTEXT_TYPES.filter(
60525
60550
  (t3) => t3 !== "system"
60526
60551
  );
60527
- var RenderTargetSchema = z13.object({
60528
- template: z13.string(),
60552
+ var RenderTargetSchema = z14.object({
60553
+ template: z14.string(),
60529
60554
  context: ContextTypeSchema,
60530
- output: z13.string(),
60531
- include: z13.array(z13.string()).optional(),
60532
- exclude: z13.array(z13.string()).optional()
60555
+ output: z14.string(),
60556
+ include: z14.array(z14.string()).optional(),
60557
+ exclude: z14.array(z14.string()).optional()
60533
60558
  }).refine(
60534
60559
  (data) => !(data.include && data.exclude),
60535
60560
  { message: "include and exclude are mutually exclusive" }
@@ -60542,9 +60567,9 @@ var RenderTargetSchema = z13.object({
60542
60567
  },
60543
60568
  { message: "include/exclude cannot be used with context: system" }
60544
60569
  );
60545
- var AgentContractsConfigSchema = z13.object({
60546
- dsl: z13.string(),
60547
- renders: z13.array(RenderTargetSchema).min(1)
60570
+ var AgentContractsConfigSchema = z14.object({
60571
+ dsl: z14.string(),
60572
+ renders: z14.array(RenderTargetSchema).min(1)
60548
60573
  });
60549
60574
 
60550
60575
  // src/config/loader.ts