agent-contracts 0.12.4 → 0.14.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
@@ -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
- }, z17 = function() {
6296
+ }, z18 = 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 = z17()), t5;
6337
+ return (t5 = x3) !== c2 && (t5 = z18()), 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;
@@ -8023,7 +8023,7 @@ __export(index_es_exports2, {
8023
8023
  resolveExternalRef: () => ye,
8024
8024
  resolveExternalRefWithLocation: () => ge,
8025
8025
  resolveInlineRef: () => B,
8026
- resolveInlineRefWithLocation: () => z16,
8026
+ resolveInlineRefWithLocation: () => z17,
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 z16(e3, t3).value;
8070
+ return z17(e3, t3).value;
8071
8071
  }
8072
- function z16(e3, t3) {
8072
+ function z17(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 z17(n4, r4) {
16902
+ function z18(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 = z17(r5, t4);
17295
+ var e5, i5 = z18(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 = z17(s2(n4), r4);
17305
+ var e4 = z18(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 z17 = new Array(need + 1).join("0");
35644
+ var z18 = new Array(need + 1).join("0");
35645
35645
  if (i3 < 0)
35646
- c2 = "-" + z17 + c2.slice(1);
35646
+ c2 = "-" + z18 + c2.slice(1);
35647
35647
  else
35648
- c2 = z17 + c2;
35648
+ c2 = z18 + c2;
35649
35649
  }
35650
35650
  }
35651
35651
  }
@@ -49169,7 +49169,7 @@ var require_dist10 = __commonJS({
49169
49169
  var getSiblings = (parent) => (node) => getChildren(parent).filter(not(eq(node)));
49170
49170
  var concatAll = (
49171
49171
  /*::<T>*/
49172
- (xs) => (ys) => ys.reduce((zs, z17) => zs.concat(z17), xs)
49172
+ (xs) => (ys) => ys.reduce((zs, z18) => zs.concat(z18), xs)
49173
49173
  );
49174
49174
  function getLastSegment(instancePath) {
49175
49175
  const index4 = instancePath.lastIndexOf("/");
@@ -49864,7 +49864,7 @@ var require_dist12 = __commonJS({
49864
49864
  var draft4MetaSchema = require_json_schema_draft_04();
49865
49865
  var META_SUPPORT_DATA = ["/properties"];
49866
49866
  var META_SCHEMA_ID = "http://json-schema.org/draft-04/schema";
49867
- var Ajv2 = class extends core_1.default {
49867
+ var Ajv3 = class extends core_1.default {
49868
49868
  constructor(opts = {}) {
49869
49869
  super({
49870
49870
  ...opts,
@@ -49889,9 +49889,9 @@ var require_dist12 = __commonJS({
49889
49889
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
49890
49890
  }
49891
49891
  };
49892
- module.exports = exports = Ajv2;
49892
+ module.exports = exports = Ajv3;
49893
49893
  Object.defineProperty(exports, "__esModule", { value: true });
49894
- exports.default = Ajv2;
49894
+ exports.default = Ajv3;
49895
49895
  var core_2 = __require("ajv/dist/core");
49896
49896
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
49897
49897
  return core_2.KeywordCxt;
@@ -50088,8 +50088,8 @@ var require_ajv2 = __commonJS({
50088
50088
  log: console.log,
50089
50089
  error: console.error
50090
50090
  };
50091
- function createAjvInstance(Ajv2, allErrors) {
50092
- const ajv2 = new Ajv2({
50091
+ function createAjvInstance(Ajv3, allErrors) {
50092
+ const ajv2 = new Ajv3({
50093
50093
  allErrors,
50094
50094
  meta: true,
50095
50095
  messages: true,
@@ -50102,22 +50102,22 @@ var require_ajv2 = __commonJS({
50102
50102
  if (allErrors) {
50103
50103
  (0, ajv_errors_1.default)(ajv2);
50104
50104
  }
50105
- if (Ajv2 === ajv_1.default) {
50105
+ if (Ajv3 === ajv_1.default) {
50106
50106
  ajv2.addSchema(draft4MetaSchema);
50107
50107
  ajv2.addSchema(draft6MetaSchema);
50108
50108
  }
50109
50109
  return ajv2;
50110
50110
  }
50111
- function _createAjvInstances(Ajv2) {
50111
+ function _createAjvInstances(Ajv3) {
50112
50112
  let _default;
50113
50113
  let _allErrors;
50114
50114
  return {
50115
50115
  get default() {
50116
- _default !== null && _default !== void 0 ? _default : _default = createAjvInstance(Ajv2, false);
50116
+ _default !== null && _default !== void 0 ? _default : _default = createAjvInstance(Ajv3, false);
50117
50117
  return _default;
50118
50118
  },
50119
50119
  get allErrors() {
50120
- _allErrors !== null && _allErrors !== void 0 ? _allErrors : _allErrors = createAjvInstance(Ajv2, true);
50120
+ _allErrors !== null && _allErrors !== void 0 ? _allErrors : _allErrors = createAjvInstance(Ajv3, true);
50121
50121
  return _allErrors;
50122
50122
  }
50123
50123
  };
@@ -50499,44 +50499,66 @@ var ArtifactSchema = z2.object({
50499
50499
  }).passthrough();
50500
50500
 
50501
50501
  // src/schema/binding.ts
50502
+ import { z as z4 } from "zod";
50503
+
50504
+ // src/schema/context-type.ts
50502
50505
  import { z as z3 } from "zod";
50503
- var CommandRegexMatcherSchema = z3.object({
50504
- type: z3.literal("command_regex"),
50505
- pattern: z3.string()
50506
+ var CONTEXT_TYPES = [
50507
+ "agent",
50508
+ "task",
50509
+ "artifact",
50510
+ "tool",
50511
+ "validation",
50512
+ "handoff_type",
50513
+ "workflow",
50514
+ "policy",
50515
+ "guardrail",
50516
+ "guardrail_policy",
50517
+ "system"
50518
+ ];
50519
+ var ContextTypeSchema = z3.enum(CONTEXT_TYPES);
50520
+ var ITERABLE_CONTEXT_TYPES = CONTEXT_TYPES.filter(
50521
+ (t3) => t3 !== "system"
50522
+ );
50523
+
50524
+ // src/schema/binding.ts
50525
+ var CommandRegexMatcherSchema = z4.object({
50526
+ type: z4.literal("command_regex"),
50527
+ pattern: z4.string()
50506
50528
  }).passthrough();
50507
- var ContentRegexMatcherSchema = z3.object({
50508
- type: z3.literal("content_regex"),
50509
- pattern: z3.string(),
50510
- file_glob: z3.string().optional(),
50511
- exclude_glob: z3.string().optional()
50529
+ var ContentRegexMatcherSchema = z4.object({
50530
+ type: z4.literal("content_regex"),
50531
+ pattern: z4.string(),
50532
+ file_glob: z4.string().optional(),
50533
+ exclude_glob: z4.string().optional()
50512
50534
  }).passthrough();
50513
- var FileGlobMatcherSchema = z3.object({
50514
- type: z3.literal("file_glob"),
50515
- pattern: z3.string(),
50516
- exclude_glob: z3.string().optional()
50535
+ var FileGlobMatcherSchema = z4.object({
50536
+ type: z4.literal("file_glob"),
50537
+ pattern: z4.string(),
50538
+ exclude_glob: z4.string().optional()
50517
50539
  }).passthrough();
50518
- var MatcherSchema = z3.discriminatedUnion("type", [
50540
+ var MatcherSchema = z4.discriminatedUnion("type", [
50519
50541
  CommandRegexMatcherSchema,
50520
50542
  ContentRegexMatcherSchema,
50521
50543
  FileGlobMatcherSchema
50522
50544
  ]);
50523
- var CheckSchema = z3.object({
50545
+ var CheckSchema = z4.object({
50524
50546
  matcher: MatcherSchema.optional(),
50525
- script: z3.string().optional(),
50526
- message: z3.string().optional()
50547
+ script: z4.string().optional(),
50548
+ message: z4.string().optional()
50527
50549
  }).passthrough();
50528
- var BindingOutputSchema = z3.object({
50529
- target: z3.string(),
50530
- template: z3.string().optional(),
50531
- inline_template: z3.string().optional(),
50532
- source: z3.string().optional(),
50533
- mode: z3.enum(["write", "patch"]).default("write"),
50534
- format: z3.enum(["json", "yaml", "text"]).optional(),
50535
- patch_strategy: z3.enum(["deep_merge", "append"]).optional(),
50536
- array_merge_key: z3.string().optional(),
50537
- group_by: z3.string().optional(),
50538
- executable: z3.boolean().optional(),
50539
- skip_empty: z3.boolean().optional()
50550
+ var BindingOutputSchema = z4.object({
50551
+ target: z4.string(),
50552
+ template: z4.string().optional(),
50553
+ inline_template: z4.string().optional(),
50554
+ source: z4.string().optional(),
50555
+ mode: z4.enum(["write", "patch"]).default("write"),
50556
+ format: z4.enum(["json", "yaml", "text"]).optional(),
50557
+ patch_strategy: z4.enum(["deep_merge", "append"]).optional(),
50558
+ array_merge_key: z4.string().optional(),
50559
+ group_by: z4.string().optional(),
50560
+ executable: z4.boolean().optional(),
50561
+ skip_empty: z4.boolean().optional()
50540
50562
  }).passthrough().refine(
50541
50563
  (data) => {
50542
50564
  const count = [data.template, data.inline_template, data.source].filter(Boolean).length;
@@ -50544,247 +50566,300 @@ var BindingOutputSchema = z3.object({
50544
50566
  },
50545
50567
  { message: "Only one of template, inline_template, or source may be specified" }
50546
50568
  );
50547
- var ReportingSchema = z3.object({
50548
- commands: z3.record(z3.string(), z3.string()),
50549
- fail_open: z3.boolean().default(true),
50550
- timeout_ms: z3.number().default(5e3)
50569
+ var ReportingSchema = z4.object({
50570
+ commands: z4.record(z4.string(), z4.string()),
50571
+ fail_open: z4.boolean().default(true),
50572
+ timeout_ms: z4.number().default(5e3)
50551
50573
  }).passthrough();
50552
- var GuardrailImplSchema = z3.object({
50553
- checks: z3.array(CheckSchema)
50554
- });
50555
- var SoftwareBindingSchema = z3.object({
50556
- software: z3.string(),
50557
- version: z3.literal(1),
50558
- extends: z3.string().optional(),
50559
- guardrail_impl: z3.record(z3.string(), GuardrailImplSchema).optional(),
50560
- outputs: z3.record(z3.string(), BindingOutputSchema).optional(),
50574
+ var GuardrailImplSchema = z4.object({
50575
+ checks: z4.array(CheckSchema)
50576
+ });
50577
+ var BindingRenderTargetSchema = z4.object({
50578
+ template: z4.string().optional(),
50579
+ inline_template: z4.string().optional(),
50580
+ context: ContextTypeSchema,
50581
+ output: z4.string(),
50582
+ include: z4.array(z4.string()).optional(),
50583
+ exclude: z4.array(z4.string()).optional(),
50584
+ skip_empty: z4.boolean().optional(),
50585
+ executable: z4.boolean().optional()
50586
+ }).passthrough().refine(
50587
+ (data) => {
50588
+ const count = [data.template, data.inline_template].filter(Boolean).length;
50589
+ return count === 1;
50590
+ },
50591
+ { message: "Exactly one of template or inline_template must be specified" }
50592
+ ).refine(
50593
+ (data) => !(data.include && data.exclude),
50594
+ { message: "include and exclude are mutually exclusive" }
50595
+ ).refine(
50596
+ (data) => {
50597
+ if (data.context === "system" && (data.include || data.exclude)) {
50598
+ return false;
50599
+ }
50600
+ return true;
50601
+ },
50602
+ { message: "include/exclude cannot be used with context: system" }
50603
+ );
50604
+ var SoftwareBindingSchema = z4.object({
50605
+ software: z4.string(),
50606
+ version: z4.literal(1),
50607
+ extends: z4.string().optional(),
50608
+ guardrail_impl: z4.record(z4.string(), GuardrailImplSchema).optional(),
50609
+ outputs: z4.record(z4.string(), BindingOutputSchema).optional(),
50610
+ renders: z4.array(BindingRenderTargetSchema).optional(),
50561
50611
  reporting: ReportingSchema.optional()
50562
50612
  }).passthrough();
50563
50613
 
50564
50614
  // src/schema/dsl.ts
50565
- import { z as z12 } from "zod";
50615
+ import { z as z13 } from "zod";
50566
50616
 
50567
50617
  // src/schema/handoff-type.ts
50568
- import { z as z4 } from "zod";
50569
- var HandoffTypeSchema = z4.object({
50570
- version: z4.number(),
50571
- description: z4.string().optional(),
50572
- schema: z4.record(z4.string(), z4.any()),
50573
- example: z4.record(z4.string(), z4.any()).optional()
50618
+ import { z as z5 } from "zod";
50619
+ var HandoffTypeSchema = z5.object({
50620
+ version: z5.number(),
50621
+ description: z5.string().optional(),
50622
+ schema: z5.record(z5.string(), z5.any()),
50623
+ example: z5.record(z5.string(), z5.any()).optional()
50574
50624
  }).passthrough();
50575
50625
 
50576
50626
  // src/schema/guardrail.ts
50577
- import { z as z5 } from "zod";
50578
- var GuardrailScopeSchema = z5.object({
50579
- agents: z5.array(z5.string()).optional(),
50580
- tasks: z5.array(z5.string()).optional(),
50581
- tools: z5.array(z5.string()).optional(),
50582
- artifacts: z5.array(z5.string()).optional(),
50583
- workflows: z5.array(z5.string()).optional()
50627
+ import { z as z6 } from "zod";
50628
+ var GuardrailScopeSchema = z6.object({
50629
+ agents: z6.array(z6.string()).optional(),
50630
+ tasks: z6.array(z6.string()).optional(),
50631
+ tools: z6.array(z6.string()).optional(),
50632
+ artifacts: z6.array(z6.string()).optional(),
50633
+ workflows: z6.array(z6.string()).optional()
50584
50634
  }).passthrough();
50585
- var GuardrailSchema = z5.object({
50586
- description: z5.string(),
50635
+ var GuardrailSchema = z6.object({
50636
+ description: z6.string(),
50587
50637
  scope: GuardrailScopeSchema,
50588
- rationale: z5.string().optional(),
50589
- tags: z5.array(z5.string()).default([]),
50590
- exemptions: z5.array(z5.string()).optional()
50638
+ rationale: z6.string().optional(),
50639
+ tags: z6.array(z6.string()).default([]),
50640
+ exemptions: z6.array(z6.string()).optional()
50591
50641
  }).passthrough();
50592
- var GuardrailPolicyRuleEscalationSchema = z5.object({
50593
- target: z5.string(),
50594
- condition: z5.string().optional()
50642
+ var GuardrailPolicyRuleEscalationSchema = z6.object({
50643
+ target: z6.string(),
50644
+ condition: z6.string().optional()
50595
50645
  }).passthrough();
50596
- var GuardrailPolicyRuleSchema = z5.object({
50597
- guardrail: z5.string(),
50598
- severity: z5.enum(["critical", "mandatory", "warning", "info"]),
50599
- action: z5.enum(["block", "warn", "shadow", "info"]),
50600
- allow_override: z5.boolean().default(false),
50601
- override_requires: z5.array(z5.string()).optional(),
50646
+ var GuardrailPolicyRuleSchema = z6.object({
50647
+ guardrail: z6.string(),
50648
+ severity: z6.enum(["critical", "mandatory", "warning", "info"]),
50649
+ action: z6.enum(["block", "warn", "shadow", "info"]),
50650
+ allow_override: z6.boolean().default(false),
50651
+ override_requires: z6.array(z6.string()).optional(),
50602
50652
  escalation: GuardrailPolicyRuleEscalationSchema.optional()
50603
50653
  }).passthrough();
50604
- var GuardrailPolicySchema = z5.object({
50605
- description: z5.string().optional(),
50606
- rules: z5.array(GuardrailPolicyRuleSchema)
50654
+ var GuardrailPolicySchema = z6.object({
50655
+ description: z6.string().optional(),
50656
+ rules: z6.array(GuardrailPolicyRuleSchema)
50607
50657
  }).passthrough();
50608
50658
 
50609
50659
  // src/schema/policy.ts
50610
- import { z as z6 } from "zod";
50611
- var PolicyWhenSchema = z6.object({
50612
- artifact_type: z6.string().optional(),
50613
- workflow: z6.string().optional()
50660
+ import { z as z7 } from "zod";
50661
+ var PolicyWhenSchema = z7.object({
50662
+ artifact_type: z7.string().optional(),
50663
+ workflow: z7.string().optional()
50614
50664
  }).passthrough();
50615
- var PolicySchema = z6.object({
50665
+ var PolicySchema = z7.object({
50616
50666
  when: PolicyWhenSchema,
50617
- requires_validations: z6.array(z6.string()).optional(),
50618
- requires: z6.array(z6.string()).optional()
50667
+ requires_validations: z7.array(z7.string()).optional(),
50668
+ requires: z7.array(z7.string()).optional()
50619
50669
  }).passthrough();
50620
50670
 
50621
50671
  // src/schema/system.ts
50622
- import { z as z7 } from "zod";
50623
- var VersionLiteralSchema = z7.literal(1);
50624
- var ExtendsSchema = z7.string().optional();
50625
- var SystemSchema = z7.object({
50626
- id: z7.string(),
50627
- name: z7.string(),
50628
- default_workflow_order: z7.array(z7.string())
50629
- }).passthrough();
50630
-
50631
- // src/schema/task.ts
50632
50672
  import { z as z8 } from "zod";
50633
- var ExecutionStepSchema = z8.object({
50673
+ var VersionLiteralSchema = z8.literal(1);
50674
+ var ExtendsSchema = z8.string().optional();
50675
+ var SystemSchema = z8.object({
50634
50676
  id: z8.string(),
50635
- action: z8.string(),
50636
- description: z8.string().optional(),
50637
- required: z8.boolean().optional(),
50638
- abort_on_failure: z8.boolean().optional(),
50639
- uses_tool: z8.string().optional(),
50640
- produces_artifact: z8.string().optional(),
50641
- reads_artifact: z8.string().optional(),
50642
- depends_on: z8.array(z8.string()).optional(),
50643
- skip_condition: z8.string().optional(),
50644
- wait_for_approval: z8.boolean().optional()
50645
- }).passthrough();
50646
- var TaskSchema = z8.object({
50647
- description: z8.string(),
50648
- target_agent: z8.string(),
50649
- allowed_from_agents: z8.array(z8.string()),
50650
- workflow: z8.string(),
50651
- input_artifacts: z8.array(z8.string()),
50652
- invocation_handoff: z8.string(),
50653
- result_handoff: z8.string(),
50654
- default_priority: z8.string().optional(),
50655
- responsibilities: z8.array(z8.string()).optional(),
50656
- constraints: z8.array(z8.string()).optional(),
50657
- execution_steps: z8.array(ExecutionStepSchema).optional(),
50658
- completion_criteria: z8.array(z8.string()).optional(),
50659
- rules: z8.array(RuleSchema).optional(),
50660
- anti_patterns: z8.array(z8.string()).optional(),
50661
- escalation_criteria: z8.array(EscalationCriterionSchema).optional(),
50662
- validations: z8.array(z8.string()).default([]),
50663
- guardrails: z8.array(z8.string()).optional()
50677
+ name: z8.string(),
50678
+ default_workflow_order: z8.array(z8.string())
50664
50679
  }).passthrough();
50665
50680
 
50666
- // src/schema/tool.ts
50681
+ // src/schema/task.ts
50667
50682
  import { z as z9 } from "zod";
50668
- var CommandSchema = z9.object({
50669
- command: z9.string(),
50670
- category: z9.string(),
50671
- reads: z9.array(z9.string()).default([]),
50672
- writes: z9.array(z9.string()).default([]),
50673
- purpose: z9.string().optional()
50674
- });
50675
- var ToolSchema = z9.object({
50676
- kind: z9.string(),
50683
+ var ExecutionStepSchema = z9.object({
50684
+ id: z9.string(),
50685
+ action: z9.string(),
50677
50686
  description: z9.string().optional(),
50678
- input_artifacts: z9.array(z9.string()).default([]),
50679
- output_artifacts: z9.array(z9.string()).default([]),
50680
- invokable_by: z9.array(z9.string()),
50681
- side_effects: z9.array(z9.string()).default([]),
50682
- commands: z9.array(CommandSchema).default([]),
50687
+ required: z9.boolean().optional(),
50688
+ abort_on_failure: z9.boolean().optional(),
50689
+ uses_tool: z9.string().optional(),
50690
+ produces_artifact: z9.string().optional(),
50691
+ reads_artifact: z9.string().optional(),
50692
+ depends_on: z9.array(z9.string()).optional(),
50693
+ skip_condition: z9.string().optional(),
50694
+ wait_for_approval: z9.boolean().optional()
50695
+ }).passthrough();
50696
+ var TaskSchema = z9.object({
50697
+ description: z9.string(),
50698
+ target_agent: z9.string(),
50699
+ allowed_from_agents: z9.array(z9.string()),
50700
+ workflow: z9.string(),
50701
+ input_artifacts: z9.array(z9.string()),
50702
+ invocation_handoff: z9.string(),
50703
+ result_handoff: z9.string(),
50704
+ default_priority: z9.string().optional(),
50705
+ responsibilities: z9.array(z9.string()).optional(),
50706
+ constraints: z9.array(z9.string()).optional(),
50707
+ execution_steps: z9.array(ExecutionStepSchema).optional(),
50708
+ completion_criteria: z9.array(z9.string()).optional(),
50709
+ rules: z9.array(RuleSchema).optional(),
50710
+ anti_patterns: z9.array(z9.string()).optional(),
50711
+ escalation_criteria: z9.array(EscalationCriterionSchema).optional(),
50712
+ validations: z9.array(z9.string()).default([]),
50683
50713
  guardrails: z9.array(z9.string()).optional()
50684
50714
  }).passthrough();
50685
50715
 
50686
- // src/schema/validation.ts
50716
+ // src/schema/tool.ts
50687
50717
  import { z as z10 } from "zod";
50688
- var ValidationSchema = z10.object({
50689
- target_artifact: z10.string(),
50690
- kind: z10.enum(["schema", "mechanical", "semantic", "approval", "provenance", "traceability", "fidelity"]),
50691
- executor_type: z10.enum(["tool", "agent"]),
50692
- executor: z10.string(),
50693
- blocking: z10.boolean(),
50694
- produces_evidence: z10.string().optional()
50718
+ var CommandSchema = z10.object({
50719
+ command: z10.string(),
50720
+ category: z10.string(),
50721
+ reads: z10.array(z10.string()).default([]),
50722
+ writes: z10.array(z10.string()).default([]),
50723
+ purpose: z10.string().optional()
50724
+ });
50725
+ var ToolSchema = z10.object({
50726
+ kind: z10.string(),
50727
+ description: z10.string().optional(),
50728
+ input_artifacts: z10.array(z10.string()).default([]),
50729
+ output_artifacts: z10.array(z10.string()).default([]),
50730
+ invokable_by: z10.array(z10.string()),
50731
+ side_effects: z10.array(z10.string()).default([]),
50732
+ commands: z10.array(CommandSchema).default([]),
50733
+ guardrails: z10.array(z10.string()).optional()
50695
50734
  }).passthrough();
50696
50735
 
50697
- // src/schema/workflow.ts
50736
+ // src/schema/validation.ts
50698
50737
  import { z as z11 } from "zod";
50699
- var RetrySchema = z11.object({
50700
- condition: z11.string(),
50701
- fix_task: z11.string(),
50702
- revalidate_task: z11.string().optional()
50703
- });
50704
- var ExternalParticipantSchema = z11.object({
50705
- id: z11.string(),
50706
- kind: z11.enum(["actor", "participant"]),
50707
- label: z11.string(),
50708
- description: z11.string().optional()
50709
- });
50710
- var WorkflowDelegateStepSchema = z11.object({
50711
- type: z11.literal("delegate"),
50712
- description: z11.string().optional(),
50713
- task: z11.string(),
50714
- from_agent: z11.string(),
50715
- group: z11.string().optional(),
50738
+ var ValidationSchema = z11.object({
50739
+ target_artifact: z11.string(),
50740
+ kind: z11.enum(["schema", "mechanical", "semantic", "approval", "provenance", "traceability", "fidelity"]),
50741
+ executor_type: z11.enum(["tool", "agent"]),
50742
+ executor: z11.string(),
50743
+ blocking: z11.boolean(),
50744
+ produces_evidence: z11.string().optional()
50745
+ }).passthrough();
50746
+
50747
+ // src/schema/workflow.ts
50748
+ import { z as z12 } from "zod";
50749
+ var RetrySchema = z12.object({
50750
+ condition: z12.string(),
50751
+ fix_task: z12.string(),
50752
+ revalidate_task: z12.string().optional()
50753
+ });
50754
+ var ExternalParticipantSchema = z12.object({
50755
+ id: z12.string(),
50756
+ kind: z12.enum(["actor", "participant"]),
50757
+ label: z12.string(),
50758
+ description: z12.string().optional()
50759
+ });
50760
+ var WorkflowDelegateStepSchema = z12.object({
50761
+ type: z12.literal("delegate"),
50762
+ description: z12.string().optional(),
50763
+ task: z12.string(),
50764
+ from_agent: z12.string(),
50765
+ group: z12.string().optional(),
50716
50766
  retry: RetrySchema.optional()
50717
50767
  }).passthrough();
50718
- var WorkflowGateStepSchema = z11.object({
50719
- type: z11.literal("gate"),
50720
- description: z11.string().optional(),
50721
- gate_kind: z11.string(),
50722
- group: z11.string().optional()
50768
+ var WorkflowGateStepSchema = z12.object({
50769
+ type: z12.literal("gate"),
50770
+ description: z12.string().optional(),
50771
+ gate_kind: z12.string(),
50772
+ group: z12.string().optional()
50723
50773
  }).passthrough();
50724
- var WorkflowHandoffStepSchema = z11.object({
50725
- type: z11.literal("handoff"),
50726
- description: z11.string().optional(),
50727
- handoff_kind: z11.string(),
50728
- task: z11.string().optional(),
50729
- from_agent: z11.string().optional(),
50730
- group: z11.string().optional(),
50774
+ var WorkflowHandoffStepSchema = z12.object({
50775
+ type: z12.literal("handoff"),
50776
+ description: z12.string().optional(),
50777
+ handoff_kind: z12.string(),
50778
+ task: z12.string().optional(),
50779
+ from_agent: z12.string().optional(),
50780
+ group: z12.string().optional(),
50731
50781
  retry: RetrySchema.optional()
50732
50782
  }).passthrough();
50733
- var WorkflowValidationStepSchema = z11.object({
50734
- type: z11.literal("validation"),
50735
- description: z11.string().optional(),
50736
- validation: z11.string(),
50737
- group: z11.string().optional()
50783
+ var WorkflowValidationStepSchema = z12.object({
50784
+ type: z12.literal("validation"),
50785
+ description: z12.string().optional(),
50786
+ validation: z12.string(),
50787
+ group: z12.string().optional()
50738
50788
  }).passthrough();
50739
- var WorkflowDecisionStepSchema = z11.object({
50740
- type: z11.literal("decision"),
50741
- description: z11.string().optional(),
50789
+ var WorkflowDecisionStepSchema = z12.object({
50790
+ type: z12.literal("decision"),
50791
+ description: z12.string().optional(),
50742
50792
  /** @deprecated Use `routing_key` instead. `on` is kept for backward compatibility. */
50743
- on: z11.string().optional(),
50744
- routing_key: z11.string().optional(),
50745
- branches: z11.record(z11.string(), z11.array(z11.string())),
50746
- group: z11.string().optional()
50793
+ on: z12.string().optional(),
50794
+ routing_key: z12.string().optional(),
50795
+ branches: z12.record(z12.string(), z12.array(z12.string())),
50796
+ group: z12.string().optional()
50747
50797
  }).passthrough();
50748
- var WorkflowStepSchema = z11.discriminatedUnion("type", [
50798
+ var WorkflowStepSchema = z12.discriminatedUnion("type", [
50749
50799
  WorkflowDelegateStepSchema,
50750
50800
  WorkflowGateStepSchema,
50751
50801
  WorkflowHandoffStepSchema,
50752
50802
  WorkflowValidationStepSchema,
50753
50803
  WorkflowDecisionStepSchema
50754
50804
  ]);
50755
- var WorkflowSchema = z11.object({
50756
- description: z11.string().optional(),
50757
- entry_conditions: z11.array(z11.string()).default([]),
50758
- trigger: z11.string().optional(),
50759
- steps: z11.array(WorkflowStepSchema),
50760
- external_participants: z11.array(ExternalParticipantSchema).default([])
50805
+ var WorkflowSchema = z12.object({
50806
+ description: z12.string().optional(),
50807
+ entry_conditions: z12.array(z12.string()).default([]),
50808
+ trigger: z12.string().optional(),
50809
+ steps: z12.array(WorkflowStepSchema),
50810
+ external_participants: z12.array(ExternalParticipantSchema).default([])
50761
50811
  }).passthrough();
50762
50812
 
50763
50813
  // src/schema/dsl.ts
50764
- var ComponentsSchema = z12.object({
50765
- schemas: z12.record(z12.string(), z12.record(z12.string(), z12.any())).default({})
50814
+ var ComponentsSchema = z13.object({
50815
+ schemas: z13.record(z13.string(), z13.record(z13.string(), z13.any())).default({})
50766
50816
  }).passthrough();
50767
- var XExtensionDeclSchema = z12.object({
50768
- type: z12.string(),
50769
- items: z12.string().optional(),
50770
- description: z12.string().optional()
50771
- });
50772
- var DslSchema = z12.object({
50773
- version: z12.literal(1),
50774
- extends: z12.string().optional(),
50817
+ var SCOPE_NODE_TYPES = [
50818
+ "root",
50819
+ "system",
50820
+ "agent",
50821
+ "task",
50822
+ "execution_step",
50823
+ "artifact",
50824
+ "tool",
50825
+ "tool_command",
50826
+ "validation",
50827
+ "handoff_type",
50828
+ "workflow",
50829
+ "workflow_step",
50830
+ "policy",
50831
+ "guardrail",
50832
+ "guardrail_policy",
50833
+ "rule",
50834
+ "escalation_criterion",
50835
+ "prerequisite"
50836
+ ];
50837
+ var ScopeNodeTypeSchema = z13.enum(SCOPE_NODE_TYPES);
50838
+ var XExtensionDeclSchema = z13.object({
50839
+ type: z13.string(),
50840
+ items: z13.string().optional(),
50841
+ description: z13.string().optional(),
50842
+ scope: z13.array(ScopeNodeTypeSchema).optional(),
50843
+ schema: z13.record(z13.string(), z13.any()).optional(),
50844
+ required: z13.boolean().default(false)
50845
+ });
50846
+ var DslSchema = z13.object({
50847
+ version: z13.literal(1),
50848
+ extends: z13.string().optional(),
50775
50849
  system: SystemSchema,
50776
- agents: z12.record(z12.string(), AgentSchema).default({}),
50777
- tasks: z12.record(z12.string(), TaskSchema).default({}),
50778
- artifacts: z12.record(z12.string(), ArtifactSchema).default({}),
50779
- tools: z12.record(z12.string(), ToolSchema).default({}),
50780
- validations: z12.record(z12.string(), ValidationSchema).default({}),
50781
- handoff_types: z12.record(z12.string(), HandoffTypeSchema).default({}),
50782
- workflow: z12.record(z12.string(), WorkflowSchema).default({}),
50783
- policies: z12.record(z12.string(), PolicySchema).default({}),
50784
- guardrails: z12.record(z12.string(), GuardrailSchema).default({}),
50785
- guardrail_policies: z12.record(z12.string(), GuardrailPolicySchema).default({}),
50850
+ agents: z13.record(z13.string(), AgentSchema).default({}),
50851
+ tasks: z13.record(z13.string(), TaskSchema).default({}),
50852
+ artifacts: z13.record(z13.string(), ArtifactSchema).default({}),
50853
+ tools: z13.record(z13.string(), ToolSchema).default({}),
50854
+ validations: z13.record(z13.string(), ValidationSchema).default({}),
50855
+ handoff_types: z13.record(z13.string(), HandoffTypeSchema).default({}),
50856
+ workflow: z13.record(z13.string(), WorkflowSchema).default({}),
50857
+ policies: z13.record(z13.string(), PolicySchema).default({}),
50858
+ guardrails: z13.record(z13.string(), GuardrailSchema).default({}),
50859
+ guardrail_policies: z13.record(z13.string(), GuardrailPolicySchema).default({}),
50786
50860
  components: ComponentsSchema.default({ schemas: {} }),
50787
- "x-extensions": z12.record(z12.string(), XExtensionDeclSchema).optional()
50861
+ extensions: z13.record(z13.string(), XExtensionDeclSchema).default({}),
50862
+ extensions_strict: z13.boolean().default(false)
50788
50863
  }).passthrough();
50789
50864
 
50790
50865
  // src/schema/json-schema-utils.ts
@@ -50836,22 +50911,22 @@ function resolveAllOf(schema) {
50836
50911
  }
50837
50912
 
50838
50913
  // src/schema/merge-operators.ts
50839
- import { z as z13 } from "zod";
50840
- var AppendOperatorSchema = z13.object({
50841
- $append: z13.record(z13.string(), z13.any())
50914
+ import { z as z14 } from "zod";
50915
+ var AppendOperatorSchema = z14.object({
50916
+ $append: z14.record(z14.string(), z14.any())
50842
50917
  });
50843
- var PrependOperatorSchema = z13.object({
50844
- $prepend: z13.record(z13.string(), z13.any())
50918
+ var PrependOperatorSchema = z14.object({
50919
+ $prepend: z14.record(z14.string(), z14.any())
50845
50920
  });
50846
- var InsertAfterOperatorSchema = z13.object({
50847
- $insert_after: z13.object({
50848
- after: z13.string(),
50849
- entries: z13.record(z13.string(), z13.any())
50921
+ var InsertAfterOperatorSchema = z14.object({
50922
+ $insert_after: z14.object({
50923
+ after: z14.string(),
50924
+ entries: z14.record(z14.string(), z14.any())
50850
50925
  })
50851
50926
  });
50852
- var ReplaceOperatorSchema = z13.object({ $replace: z13.any() });
50853
- var RemoveOperatorSchema = z13.object({
50854
- $remove: z13.array(z13.string())
50927
+ var ReplaceOperatorSchema = z14.object({ $replace: z14.any() });
50928
+ var RemoveOperatorSchema = z14.object({
50929
+ $remove: z14.array(z14.string())
50855
50930
  });
50856
50931
 
50857
50932
  // src/config/loader.ts
@@ -50860,31 +50935,14 @@ import { resolve, dirname } from "path";
50860
50935
  import { parse as parseYaml } from "yaml";
50861
50936
 
50862
50937
  // src/config/types.ts
50863
- import { z as z14 } from "zod";
50864
- var CONTEXT_TYPES = [
50865
- "agent",
50866
- "task",
50867
- "artifact",
50868
- "tool",
50869
- "validation",
50870
- "handoff_type",
50871
- "workflow",
50872
- "policy",
50873
- "guardrail",
50874
- "guardrail_policy",
50875
- "system"
50876
- ];
50877
- var ContextTypeSchema = z14.enum(CONTEXT_TYPES);
50878
- var ITERABLE_CONTEXT_TYPES = CONTEXT_TYPES.filter(
50879
- (t3) => t3 !== "system"
50880
- );
50881
- var RenderTargetSchema = z14.object({
50882
- template: z14.string(),
50938
+ import { z as z15 } from "zod";
50939
+ var RenderTargetSchema = z15.object({
50940
+ template: z15.string(),
50883
50941
  context: ContextTypeSchema,
50884
- output: z14.string(),
50885
- include: z14.array(z14.string()).optional(),
50886
- exclude: z14.array(z14.string()).optional(),
50887
- skip_empty: z14.boolean().optional()
50942
+ output: z15.string(),
50943
+ include: z15.array(z15.string()).optional(),
50944
+ exclude: z15.array(z15.string()).optional(),
50945
+ skip_empty: z15.boolean().optional()
50888
50946
  }).refine(
50889
50947
  (data) => !(data.include && data.exclude),
50890
50948
  { message: "include and exclude are mutually exclusive" }
@@ -50897,13 +50955,13 @@ var RenderTargetSchema = z14.object({
50897
50955
  },
50898
50956
  { message: "include/exclude cannot be used with context: system" }
50899
50957
  );
50900
- var AgentContractsConfigSchema = z14.object({
50901
- dsl: z14.string(),
50902
- vars: z14.record(z14.string(), z14.string()).optional(),
50903
- renders: z14.array(RenderTargetSchema).min(1),
50904
- bindings: z14.array(z14.string()).default([]),
50905
- active_guardrail_policy: z14.string().optional(),
50906
- paths: z14.record(z14.string(), z14.string()).optional()
50958
+ var AgentContractsConfigSchema = z15.object({
50959
+ dsl: z15.string(),
50960
+ vars: z15.record(z15.string(), z15.string()).optional(),
50961
+ renders: z15.array(RenderTargetSchema).default([]),
50962
+ bindings: z15.array(z15.string()).default([]),
50963
+ active_guardrail_policy: z15.string().optional(),
50964
+ paths: z15.record(z15.string(), z15.string()).optional()
50907
50965
  });
50908
50966
 
50909
50967
  // src/config/loader.ts
@@ -51541,7 +51599,8 @@ var MERGE_SECTIONS = [
51541
51599
  "policies",
51542
51600
  "guardrails",
51543
51601
  "guardrail_policies",
51544
- "components"
51602
+ "components",
51603
+ "extensions"
51545
51604
  ];
51546
51605
  function mergeDsl(base, project) {
51547
51606
  const hasExtends = typeof project["extends"] === "string";
@@ -51650,11 +51709,12 @@ function expandDefaults(data) {
51650
51709
  function isRecord3(v2) {
51651
51710
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
51652
51711
  }
51653
- var BINDING_MERGE_SECTIONS = ["guardrail_impl", "outputs"];
51712
+ var BINDING_MAP_MERGE_SECTIONS = ["guardrail_impl", "outputs"];
51713
+ var BINDING_ARRAY_MERGE_SECTIONS = ["renders"];
51654
51714
  function mergeBinding(base, project) {
51655
51715
  const hasExtends = typeof project["extends"] === "string";
51656
51716
  const result = { ...base, ...project };
51657
- for (const section of BINDING_MERGE_SECTIONS) {
51717
+ for (const section of BINDING_MAP_MERGE_SECTIONS) {
51658
51718
  const baseVal = base[section];
51659
51719
  const projVal = project[section];
51660
51720
  if (projVal === void 0) {
@@ -51668,6 +51728,14 @@ function mergeBinding(base, project) {
51668
51728
  hasExtends
51669
51729
  );
51670
51730
  }
51731
+ for (const section of BINDING_ARRAY_MERGE_SECTIONS) {
51732
+ const baseVal = base[section];
51733
+ const projVal = project[section];
51734
+ if (projVal === void 0) continue;
51735
+ const baseArr = Array.isArray(baseVal) ? baseVal : [];
51736
+ const projArr = Array.isArray(projVal) ? projVal : [];
51737
+ result[section] = [...baseArr, ...projArr];
51738
+ }
51671
51739
  if (project["reporting"] !== void 0 && isRecord3(base["reporting"]) && isRecord3(project["reporting"])) {
51672
51740
  result["reporting"] = deepMergeEntities(
51673
51741
  base["reporting"],
@@ -51812,16 +51880,17 @@ var resolveCommand = new Command("resolve").description("Resolve DSL (load + mer
51812
51880
  import { Command as Command2 } from "commander";
51813
51881
 
51814
51882
  // src/validator/schema-validator.ts
51815
- import { z as z15 } from "zod";
51883
+ import Ajv from "ajv";
51884
+ import { z as z16 } from "zod";
51816
51885
  function unwrap(schema) {
51817
- if (schema instanceof z15.ZodOptional) return unwrap(schema.unwrap());
51818
- if (schema instanceof z15.ZodDefault) return unwrap(schema.removeDefault());
51819
- if (schema instanceof z15.ZodNullable) return unwrap(schema.unwrap());
51886
+ if (schema instanceof z16.ZodOptional) return unwrap(schema.unwrap());
51887
+ if (schema instanceof z16.ZodDefault) return unwrap(schema.removeDefault());
51888
+ if (schema instanceof z16.ZodNullable) return unwrap(schema.unwrap());
51820
51889
  return schema;
51821
51890
  }
51822
51891
  function checkCustomPropsRecursive(data, schema, path) {
51823
51892
  const inner = unwrap(schema);
51824
- if (inner instanceof z15.ZodObject) {
51893
+ if (inner instanceof z16.ZodObject) {
51825
51894
  if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
51826
51895
  const obj = data;
51827
51896
  const shape = inner.shape;
@@ -51842,7 +51911,7 @@ function checkCustomPropsRecursive(data, schema, path) {
51842
51911
  }
51843
51912
  return diagnostics;
51844
51913
  }
51845
- if (inner instanceof z15.ZodRecord) {
51914
+ if (inner instanceof z16.ZodRecord) {
51846
51915
  if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
51847
51916
  const valueSchema = inner._def.valueType;
51848
51917
  const diagnostics = [];
@@ -51851,7 +51920,7 @@ function checkCustomPropsRecursive(data, schema, path) {
51851
51920
  }
51852
51921
  return diagnostics;
51853
51922
  }
51854
- if (inner instanceof z15.ZodArray) {
51923
+ if (inner instanceof z16.ZodArray) {
51855
51924
  if (!Array.isArray(data)) return [];
51856
51925
  const diagnostics = [];
51857
51926
  for (let i3 = 0; i3 < data.length; i3++) {
@@ -51859,28 +51928,28 @@ function checkCustomPropsRecursive(data, schema, path) {
51859
51928
  }
51860
51929
  return diagnostics;
51861
51930
  }
51862
- if (inner instanceof z15.ZodDiscriminatedUnion) {
51931
+ if (inner instanceof z16.ZodDiscriminatedUnion) {
51863
51932
  if (typeof data !== "object" || data === null) return [];
51864
51933
  const obj = data;
51865
51934
  const disc = inner._def.discriminator;
51866
51935
  const discValue = obj[disc];
51867
51936
  const match = inner.options.find((opt) => {
51868
51937
  const shape = opt.shape;
51869
- return shape[disc] instanceof z15.ZodLiteral && shape[disc].value === discValue;
51938
+ return shape[disc] instanceof z16.ZodLiteral && shape[disc].value === discValue;
51870
51939
  });
51871
51940
  if (match) return checkCustomPropsRecursive(data, match, path);
51872
51941
  return [];
51873
51942
  }
51874
51943
  return [];
51875
51944
  }
51876
- function checkXExtensionsKeys(data) {
51877
- const extensions = data["x-extensions"];
51945
+ function checkExtensionsKeys(data) {
51946
+ const extensions = data["extensions"];
51878
51947
  if (typeof extensions !== "object" || extensions === null) return [];
51879
51948
  const diagnostics = [];
51880
51949
  for (const key of Object.keys(extensions)) {
51881
51950
  if (!key.startsWith("x-")) {
51882
51951
  diagnostics.push({
51883
- path: `x-extensions.${key}`,
51952
+ path: `extensions.${key}`,
51884
51953
  message: `Extension key "${key}" must start with "x-" prefix.`,
51885
51954
  code: "x-extension-key-prefix"
51886
51955
  });
@@ -51914,29 +51983,634 @@ function checkDecisionStepRoutingKey(data) {
51914
51983
  }
51915
51984
  return diagnostics;
51916
51985
  }
51917
- function validateSchema(data) {
51918
- const result = DslSchema.safeParse(data);
51919
- if (!result.success) {
51920
- const diagnostics = result.error.issues.map((issue) => ({
51921
- path: issue.path.join("."),
51922
- message: issue.message,
51923
- code: "schema-validation"
51924
- }));
51925
- return { success: false, diagnostics };
51986
+ function isRecord4(v2) {
51987
+ return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
51988
+ }
51989
+ function* enumerateEntitiesByType(data, nodeType) {
51990
+ switch (nodeType) {
51991
+ case "root":
51992
+ yield { path: "", obj: data };
51993
+ return;
51994
+ case "system": {
51995
+ const sys = data["system"];
51996
+ if (isRecord4(sys)) yield { path: "system", obj: sys };
51997
+ return;
51998
+ }
51999
+ case "agent": {
52000
+ const agents = data["agents"];
52001
+ if (!isRecord4(agents)) return;
52002
+ for (const [id, a3] of Object.entries(agents)) {
52003
+ if (isRecord4(a3)) yield { path: `agents.${id}`, obj: a3 };
52004
+ }
52005
+ return;
52006
+ }
52007
+ case "rule": {
52008
+ const agents = data["agents"];
52009
+ if (!isRecord4(agents)) return;
52010
+ for (const [aid, a3] of Object.entries(agents)) {
52011
+ if (!isRecord4(a3)) continue;
52012
+ const rules = a3["rules"];
52013
+ if (!Array.isArray(rules)) continue;
52014
+ for (let i3 = 0; i3 < rules.length; i3++) {
52015
+ const r3 = rules[i3];
52016
+ if (isRecord4(r3)) yield { path: `agents.${aid}.rules[${i3}]`, obj: r3 };
52017
+ }
52018
+ }
52019
+ return;
52020
+ }
52021
+ case "escalation_criterion": {
52022
+ const agents = data["agents"];
52023
+ if (!isRecord4(agents)) return;
52024
+ for (const [aid, a3] of Object.entries(agents)) {
52025
+ if (!isRecord4(a3)) continue;
52026
+ const esc = a3["escalation_criteria"];
52027
+ if (!Array.isArray(esc)) continue;
52028
+ for (let i3 = 0; i3 < esc.length; i3++) {
52029
+ const e3 = esc[i3];
52030
+ if (isRecord4(e3)) {
52031
+ yield {
52032
+ path: `agents.${aid}.escalation_criteria[${i3}]`,
52033
+ obj: e3
52034
+ };
52035
+ }
52036
+ }
52037
+ }
52038
+ return;
52039
+ }
52040
+ case "prerequisite": {
52041
+ const agents = data["agents"];
52042
+ if (!isRecord4(agents)) return;
52043
+ for (const [aid, a3] of Object.entries(agents)) {
52044
+ if (!isRecord4(a3)) continue;
52045
+ const pre = a3["prerequisites"];
52046
+ if (!Array.isArray(pre)) continue;
52047
+ for (let i3 = 0; i3 < pre.length; i3++) {
52048
+ const p2 = pre[i3];
52049
+ if (isRecord4(p2)) {
52050
+ yield { path: `agents.${aid}.prerequisites[${i3}]`, obj: p2 };
52051
+ }
52052
+ }
52053
+ }
52054
+ return;
52055
+ }
52056
+ case "task": {
52057
+ const tasks = data["tasks"];
52058
+ if (!isRecord4(tasks)) return;
52059
+ for (const [id, t3] of Object.entries(tasks)) {
52060
+ if (isRecord4(t3)) yield { path: `tasks.${id}`, obj: t3 };
52061
+ }
52062
+ return;
52063
+ }
52064
+ case "execution_step": {
52065
+ const tasks = data["tasks"];
52066
+ if (!isRecord4(tasks)) return;
52067
+ for (const [tid, t3] of Object.entries(tasks)) {
52068
+ if (!isRecord4(t3)) continue;
52069
+ const steps = t3["execution_steps"];
52070
+ if (!Array.isArray(steps)) continue;
52071
+ for (let i3 = 0; i3 < steps.length; i3++) {
52072
+ const s2 = steps[i3];
52073
+ if (isRecord4(s2)) {
52074
+ yield {
52075
+ path: `tasks.${tid}.execution_steps[${i3}]`,
52076
+ obj: s2
52077
+ };
52078
+ }
52079
+ }
52080
+ }
52081
+ return;
52082
+ }
52083
+ case "artifact": {
52084
+ const arts = data["artifacts"];
52085
+ if (!isRecord4(arts)) return;
52086
+ for (const [id, a3] of Object.entries(arts)) {
52087
+ if (isRecord4(a3)) yield { path: `artifacts.${id}`, obj: a3 };
52088
+ }
52089
+ return;
52090
+ }
52091
+ case "tool": {
52092
+ const tools = data["tools"];
52093
+ if (!isRecord4(tools)) return;
52094
+ for (const [id, t3] of Object.entries(tools)) {
52095
+ if (isRecord4(t3)) yield { path: `tools.${id}`, obj: t3 };
52096
+ }
52097
+ return;
52098
+ }
52099
+ case "tool_command": {
52100
+ const tools = data["tools"];
52101
+ if (!isRecord4(tools)) return;
52102
+ for (const [tid, t3] of Object.entries(tools)) {
52103
+ if (!isRecord4(t3)) continue;
52104
+ const cmds = t3["commands"];
52105
+ if (!Array.isArray(cmds)) continue;
52106
+ for (let i3 = 0; i3 < cmds.length; i3++) {
52107
+ const c2 = cmds[i3];
52108
+ if (isRecord4(c2)) {
52109
+ yield { path: `tools.${tid}.commands[${i3}]`, obj: c2 };
52110
+ }
52111
+ }
52112
+ }
52113
+ return;
52114
+ }
52115
+ case "validation": {
52116
+ const vals = data["validations"];
52117
+ if (!isRecord4(vals)) return;
52118
+ for (const [id, v2] of Object.entries(vals)) {
52119
+ if (isRecord4(v2)) yield { path: `validations.${id}`, obj: v2 };
52120
+ }
52121
+ return;
52122
+ }
52123
+ case "handoff_type": {
52124
+ const ht = data["handoff_types"];
52125
+ if (!isRecord4(ht)) return;
52126
+ for (const [id, h2] of Object.entries(ht)) {
52127
+ if (isRecord4(h2)) yield { path: `handoff_types.${id}`, obj: h2 };
52128
+ }
52129
+ return;
52130
+ }
52131
+ case "workflow": {
52132
+ const wf = data["workflow"];
52133
+ if (!isRecord4(wf)) return;
52134
+ for (const [id, w2] of Object.entries(wf)) {
52135
+ if (isRecord4(w2)) yield { path: `workflow.${id}`, obj: w2 };
52136
+ }
52137
+ return;
52138
+ }
52139
+ case "workflow_step": {
52140
+ const wf = data["workflow"];
52141
+ if (!isRecord4(wf)) return;
52142
+ for (const [wid, w2] of Object.entries(wf)) {
52143
+ if (!isRecord4(w2)) continue;
52144
+ const steps = w2["steps"];
52145
+ if (!Array.isArray(steps)) continue;
52146
+ for (let i3 = 0; i3 < steps.length; i3++) {
52147
+ const s2 = steps[i3];
52148
+ if (isRecord4(s2)) {
52149
+ yield { path: `workflow.${wid}.steps[${i3}]`, obj: s2 };
52150
+ }
52151
+ }
52152
+ }
52153
+ return;
52154
+ }
52155
+ case "policy": {
52156
+ const pol = data["policies"];
52157
+ if (!isRecord4(pol)) return;
52158
+ for (const [id, p2] of Object.entries(pol)) {
52159
+ if (isRecord4(p2)) yield { path: `policies.${id}`, obj: p2 };
52160
+ }
52161
+ return;
52162
+ }
52163
+ case "guardrail": {
52164
+ const gr = data["guardrails"];
52165
+ if (!isRecord4(gr)) return;
52166
+ for (const [id, g2] of Object.entries(gr)) {
52167
+ if (isRecord4(g2)) yield { path: `guardrails.${id}`, obj: g2 };
52168
+ }
52169
+ return;
52170
+ }
52171
+ case "guardrail_policy": {
52172
+ const gp = data["guardrail_policies"];
52173
+ if (!isRecord4(gp)) return;
52174
+ for (const [id, p2] of Object.entries(gp)) {
52175
+ if (isRecord4(p2)) yield { path: `guardrail_policies.${id}`, obj: p2 };
52176
+ }
52177
+ return;
52178
+ }
52179
+ default:
52180
+ return;
52181
+ }
52182
+ }
52183
+ function validateDeclaredExtension(parentPath, nodeType, key, val, declMap, diagnostics, ajvInstance, strict) {
52184
+ const path = parentPath ? `${parentPath}.${key}` : key;
52185
+ const decl = declMap[key];
52186
+ if (decl === void 0) {
52187
+ diagnostics.push({
52188
+ path,
52189
+ message: `Extension "${key}" is not declared in extensions.`,
52190
+ code: "undeclared-extension",
52191
+ ...!strict ? { severity: "warning" } : {}
52192
+ });
52193
+ return;
52194
+ }
52195
+ const scope = decl.scope;
52196
+ if (scope && scope.length > 0 && !scope.includes(nodeType)) {
52197
+ diagnostics.push({
52198
+ path,
52199
+ message: `Extension "${key}" is not allowed on ${nodeType} (declared scope: ${scope.join(", ")}).`,
52200
+ code: "extension-scope-mismatch"
52201
+ });
52202
+ return;
52203
+ }
52204
+ if (decl.schema && typeof decl.schema === "object" && decl.schema !== null && Object.keys(decl.schema).length > 0) {
52205
+ try {
52206
+ const validate = ajvInstance.compile(decl.schema);
52207
+ if (!validate(val)) {
52208
+ diagnostics.push({
52209
+ path,
52210
+ message: `Extension "${key}" value does not match declared schema: ${ajvInstance.errorsText(validate.errors)}`,
52211
+ code: "extension-schema-violation"
52212
+ });
52213
+ }
52214
+ } catch (e3) {
52215
+ diagnostics.push({
52216
+ path,
52217
+ message: `Extension "${key}" has invalid JSON Schema in declaration: ${e3 instanceof Error ? e3.message : String(e3)}`,
52218
+ code: "extension-schema-violation"
52219
+ });
52220
+ }
52221
+ }
52222
+ }
52223
+ function walkExtensionNodes(value, path, nodeType, declMap, diagnostics, ajvInstance, strict) {
52224
+ if (!isRecord4(value)) return;
52225
+ const obj = value;
52226
+ for (const key of Object.keys(obj)) {
52227
+ if (key === "extensions" || key === "extensions_strict" || key === "x-extensions" || key === "x-extensions-strict") {
52228
+ continue;
52229
+ }
52230
+ if (key.startsWith("x-")) {
52231
+ validateDeclaredExtension(
52232
+ path,
52233
+ nodeType,
52234
+ key,
52235
+ obj[key],
52236
+ declMap,
52237
+ diagnostics,
52238
+ ajvInstance,
52239
+ strict
52240
+ );
52241
+ }
52242
+ }
52243
+ switch (nodeType) {
52244
+ case "root": {
52245
+ const sys = obj["system"];
52246
+ if (isRecord4(sys)) {
52247
+ walkExtensionNodes(
52248
+ sys,
52249
+ "system",
52250
+ "system",
52251
+ declMap,
52252
+ diagnostics,
52253
+ ajvInstance,
52254
+ strict
52255
+ );
52256
+ }
52257
+ const agents = obj["agents"];
52258
+ if (isRecord4(agents)) {
52259
+ for (const [id, a3] of Object.entries(agents)) {
52260
+ if (isRecord4(a3)) {
52261
+ walkExtensionNodes(
52262
+ a3,
52263
+ `agents.${id}`,
52264
+ "agent",
52265
+ declMap,
52266
+ diagnostics,
52267
+ ajvInstance,
52268
+ strict
52269
+ );
52270
+ }
52271
+ }
52272
+ }
52273
+ const tasks = obj["tasks"];
52274
+ if (isRecord4(tasks)) {
52275
+ for (const [id, t3] of Object.entries(tasks)) {
52276
+ if (isRecord4(t3)) {
52277
+ walkExtensionNodes(
52278
+ t3,
52279
+ `tasks.${id}`,
52280
+ "task",
52281
+ declMap,
52282
+ diagnostics,
52283
+ ajvInstance,
52284
+ strict
52285
+ );
52286
+ }
52287
+ }
52288
+ }
52289
+ const artifacts = obj["artifacts"];
52290
+ if (isRecord4(artifacts)) {
52291
+ for (const [id, a3] of Object.entries(artifacts)) {
52292
+ if (isRecord4(a3)) {
52293
+ walkExtensionNodes(
52294
+ a3,
52295
+ `artifacts.${id}`,
52296
+ "artifact",
52297
+ declMap,
52298
+ diagnostics,
52299
+ ajvInstance,
52300
+ strict
52301
+ );
52302
+ }
52303
+ }
52304
+ }
52305
+ const tools = obj["tools"];
52306
+ if (isRecord4(tools)) {
52307
+ for (const [id, t3] of Object.entries(tools)) {
52308
+ if (isRecord4(t3)) {
52309
+ walkExtensionNodes(
52310
+ t3,
52311
+ `tools.${id}`,
52312
+ "tool",
52313
+ declMap,
52314
+ diagnostics,
52315
+ ajvInstance,
52316
+ strict
52317
+ );
52318
+ }
52319
+ }
52320
+ }
52321
+ const validations = obj["validations"];
52322
+ if (isRecord4(validations)) {
52323
+ for (const [id, v2] of Object.entries(validations)) {
52324
+ if (isRecord4(v2)) {
52325
+ walkExtensionNodes(
52326
+ v2,
52327
+ `validations.${id}`,
52328
+ "validation",
52329
+ declMap,
52330
+ diagnostics,
52331
+ ajvInstance,
52332
+ strict
52333
+ );
52334
+ }
52335
+ }
52336
+ }
52337
+ const handoffTypes = obj["handoff_types"];
52338
+ if (isRecord4(handoffTypes)) {
52339
+ for (const [id, h2] of Object.entries(handoffTypes)) {
52340
+ if (isRecord4(h2)) {
52341
+ walkExtensionNodes(
52342
+ h2,
52343
+ `handoff_types.${id}`,
52344
+ "handoff_type",
52345
+ declMap,
52346
+ diagnostics,
52347
+ ajvInstance,
52348
+ strict
52349
+ );
52350
+ }
52351
+ }
52352
+ }
52353
+ const workflow = obj["workflow"];
52354
+ if (isRecord4(workflow)) {
52355
+ for (const [id, w2] of Object.entries(workflow)) {
52356
+ if (isRecord4(w2)) {
52357
+ walkExtensionNodes(
52358
+ w2,
52359
+ `workflow.${id}`,
52360
+ "workflow",
52361
+ declMap,
52362
+ diagnostics,
52363
+ ajvInstance,
52364
+ strict
52365
+ );
52366
+ }
52367
+ }
52368
+ }
52369
+ const policies = obj["policies"];
52370
+ if (isRecord4(policies)) {
52371
+ for (const [id, p2] of Object.entries(policies)) {
52372
+ if (isRecord4(p2)) {
52373
+ walkExtensionNodes(
52374
+ p2,
52375
+ `policies.${id}`,
52376
+ "policy",
52377
+ declMap,
52378
+ diagnostics,
52379
+ ajvInstance,
52380
+ strict
52381
+ );
52382
+ }
52383
+ }
52384
+ }
52385
+ const guardrails = obj["guardrails"];
52386
+ if (isRecord4(guardrails)) {
52387
+ for (const [id, g2] of Object.entries(guardrails)) {
52388
+ if (isRecord4(g2)) {
52389
+ walkExtensionNodes(
52390
+ g2,
52391
+ `guardrails.${id}`,
52392
+ "guardrail",
52393
+ declMap,
52394
+ diagnostics,
52395
+ ajvInstance,
52396
+ strict
52397
+ );
52398
+ }
52399
+ }
52400
+ }
52401
+ const guardrailPolicies = obj["guardrail_policies"];
52402
+ if (isRecord4(guardrailPolicies)) {
52403
+ for (const [id, p2] of Object.entries(guardrailPolicies)) {
52404
+ if (isRecord4(p2)) {
52405
+ walkExtensionNodes(
52406
+ p2,
52407
+ `guardrail_policies.${id}`,
52408
+ "guardrail_policy",
52409
+ declMap,
52410
+ diagnostics,
52411
+ ajvInstance,
52412
+ strict
52413
+ );
52414
+ }
52415
+ }
52416
+ }
52417
+ break;
52418
+ }
52419
+ case "agent": {
52420
+ const rules = obj["rules"];
52421
+ if (Array.isArray(rules)) {
52422
+ for (let i3 = 0; i3 < rules.length; i3++) {
52423
+ const r3 = rules[i3];
52424
+ if (isRecord4(r3)) {
52425
+ walkExtensionNodes(
52426
+ r3,
52427
+ `${path}.rules[${i3}]`,
52428
+ "rule",
52429
+ declMap,
52430
+ diagnostics,
52431
+ ajvInstance,
52432
+ strict
52433
+ );
52434
+ }
52435
+ }
52436
+ }
52437
+ const esc = obj["escalation_criteria"];
52438
+ if (Array.isArray(esc)) {
52439
+ for (let i3 = 0; i3 < esc.length; i3++) {
52440
+ const e3 = esc[i3];
52441
+ if (isRecord4(e3)) {
52442
+ walkExtensionNodes(
52443
+ e3,
52444
+ `${path}.escalation_criteria[${i3}]`,
52445
+ "escalation_criterion",
52446
+ declMap,
52447
+ diagnostics,
52448
+ ajvInstance,
52449
+ strict
52450
+ );
52451
+ }
52452
+ }
52453
+ }
52454
+ const pre = obj["prerequisites"];
52455
+ if (Array.isArray(pre)) {
52456
+ for (let i3 = 0; i3 < pre.length; i3++) {
52457
+ const p2 = pre[i3];
52458
+ if (isRecord4(p2)) {
52459
+ walkExtensionNodes(
52460
+ p2,
52461
+ `${path}.prerequisites[${i3}]`,
52462
+ "prerequisite",
52463
+ declMap,
52464
+ diagnostics,
52465
+ ajvInstance,
52466
+ strict
52467
+ );
52468
+ }
52469
+ }
52470
+ }
52471
+ break;
52472
+ }
52473
+ case "task": {
52474
+ const steps = obj["execution_steps"];
52475
+ if (Array.isArray(steps)) {
52476
+ for (let i3 = 0; i3 < steps.length; i3++) {
52477
+ const s2 = steps[i3];
52478
+ if (isRecord4(s2)) {
52479
+ walkExtensionNodes(
52480
+ s2,
52481
+ `${path}.execution_steps[${i3}]`,
52482
+ "execution_step",
52483
+ declMap,
52484
+ diagnostics,
52485
+ ajvInstance,
52486
+ strict
52487
+ );
52488
+ }
52489
+ }
52490
+ }
52491
+ break;
52492
+ }
52493
+ case "tool": {
52494
+ const cmds = obj["commands"];
52495
+ if (Array.isArray(cmds)) {
52496
+ for (let i3 = 0; i3 < cmds.length; i3++) {
52497
+ const c2 = cmds[i3];
52498
+ if (isRecord4(c2)) {
52499
+ walkExtensionNodes(
52500
+ c2,
52501
+ `${path}.commands[${i3}]`,
52502
+ "tool_command",
52503
+ declMap,
52504
+ diagnostics,
52505
+ ajvInstance,
52506
+ strict
52507
+ );
52508
+ }
52509
+ }
52510
+ }
52511
+ break;
52512
+ }
52513
+ case "workflow": {
52514
+ const steps = obj["steps"];
52515
+ if (Array.isArray(steps)) {
52516
+ for (let i3 = 0; i3 < steps.length; i3++) {
52517
+ const s2 = steps[i3];
52518
+ if (isRecord4(s2)) {
52519
+ walkExtensionNodes(
52520
+ s2,
52521
+ `${path}.steps[${i3}]`,
52522
+ "workflow_step",
52523
+ declMap,
52524
+ diagnostics,
52525
+ ajvInstance,
52526
+ strict
52527
+ );
52528
+ }
52529
+ }
52530
+ }
52531
+ break;
52532
+ }
52533
+ default:
52534
+ break;
51926
52535
  }
51927
- const customPropDiagnostics = checkCustomPropsRecursive(data, DslSchema, "");
51928
- if (customPropDiagnostics.length > 0) {
51929
- return { success: false, diagnostics: customPropDiagnostics };
52536
+ }
52537
+ function checkExtensionValidation(data) {
52538
+ const strict = data["extensions_strict"] === true;
52539
+ const raw = data["extensions"];
52540
+ let declMap;
52541
+ if (!isRecord4(raw) || Object.keys(raw).length === 0) {
52542
+ if (!strict) return [];
52543
+ declMap = {};
52544
+ } else {
52545
+ declMap = raw;
51930
52546
  }
51931
- const decisionDiagnostics = checkDecisionStepRoutingKey(data);
51932
- if (decisionDiagnostics.length > 0) {
51933
- return { success: false, diagnostics: decisionDiagnostics };
52547
+ const diagnostics = [];
52548
+ const ajvInstance = new Ajv({ allErrors: true, strict: false });
52549
+ walkExtensionNodes(data, "", "root", declMap, diagnostics, ajvInstance, strict);
52550
+ for (const [extKey, decl] of Object.entries(declMap)) {
52551
+ if (!decl.required) continue;
52552
+ const applicableTypes = decl.scope && decl.scope.length > 0 ? decl.scope : [...SCOPE_NODE_TYPES];
52553
+ for (const t3 of applicableTypes) {
52554
+ for (const { path, obj } of enumerateEntitiesByType(data, t3)) {
52555
+ if (!(extKey in obj)) {
52556
+ diagnostics.push({
52557
+ path,
52558
+ message: `Required extension "${extKey}" is missing on ${t3}.`,
52559
+ code: "extension-required-missing"
52560
+ });
52561
+ }
52562
+ }
52563
+ }
52564
+ }
52565
+ return diagnostics;
52566
+ }
52567
+ function hasBlockingDiagnostic(diagnostics) {
52568
+ return diagnostics.some((d2) => d2.severity !== "warning");
52569
+ }
52570
+ function validateSchema(data) {
52571
+ const deprecationWarnings = [];
52572
+ if ("x-extensions" in data && !("extensions" in data)) {
52573
+ data["extensions"] = data["x-extensions"];
52574
+ deprecationWarnings.push({
52575
+ path: "x-extensions",
52576
+ message: '"x-extensions" is deprecated. Use "extensions" instead.',
52577
+ code: "deprecated-property",
52578
+ severity: "warning"
52579
+ });
51934
52580
  }
51935
- const xExtDiagnostics = checkXExtensionsKeys(data);
51936
- if (xExtDiagnostics.length > 0) {
51937
- return { success: false, diagnostics: xExtDiagnostics };
52581
+ if ("x-extensions-strict" in data && !("extensions_strict" in data)) {
52582
+ data["extensions_strict"] = data["x-extensions-strict"];
52583
+ deprecationWarnings.push({
52584
+ path: "x-extensions-strict",
52585
+ message: '"x-extensions-strict" is deprecated. Use "extensions_strict" instead.',
52586
+ code: "deprecated-property",
52587
+ severity: "warning"
52588
+ });
51938
52589
  }
51939
- return { success: true, data: result.data, diagnostics: [] };
52590
+ const result = DslSchema.safeParse(data);
52591
+ if (!result.success) {
52592
+ const diagnostics2 = [
52593
+ ...deprecationWarnings,
52594
+ ...result.error.issues.map((issue) => ({
52595
+ path: issue.path.join("."),
52596
+ message: issue.message,
52597
+ code: "schema-validation"
52598
+ }))
52599
+ ];
52600
+ return { success: false, diagnostics: diagnostics2 };
52601
+ }
52602
+ const diagnostics = [
52603
+ ...deprecationWarnings,
52604
+ ...checkCustomPropsRecursive(data, DslSchema, ""),
52605
+ ...checkDecisionStepRoutingKey(data),
52606
+ ...checkExtensionsKeys(data),
52607
+ ...checkExtensionValidation(data)
52608
+ ];
52609
+ return {
52610
+ success: !hasBlockingDiagnostic(diagnostics),
52611
+ data: result.data,
52612
+ diagnostics
52613
+ };
51940
52614
  }
51941
52615
 
51942
52616
  // src/validator/reference-resolver.ts
@@ -52244,8 +52918,8 @@ function checkReferences(dsl) {
52244
52918
  }
52245
52919
 
52246
52920
  // src/validator/handoff-schema-validator.ts
52247
- import Ajv from "ajv";
52248
- var ajv = new Ajv({ allErrors: true, strict: false });
52921
+ import Ajv2 from "ajv";
52922
+ var ajv = new Ajv2({ allErrors: true, strict: false });
52249
52923
  function validateHandoffSchemas(dsl) {
52250
52924
  const diagnostics = [];
52251
52925
  for (const [kind, ht] of Object.entries(dsl.handoff_types)) {
@@ -52280,13 +52954,16 @@ function formatDiagnostics(diagnostics, options) {
52280
52954
 
52281
52955
  // src/cli/commands/validate.ts
52282
52956
  var DIR_DEFAULT2 = "agent-contracts.yaml";
52283
- var validateCommand = new Command2("validate").description("Validate DSL against schema and check references").argument("[dir]", "Path to agent-contracts.yaml", DIR_DEFAULT2).option("-c, --config <path>", "Path to agent-contracts.config.yaml").option("--format <format>", "Output format (text|json)", "text").option("--quiet", "Suppress output on success", false).action(async (dir, opts) => {
52957
+ var validateCommand = new Command2("validate").description("Validate DSL against schema and check references").argument("[dir]", "Path to agent-contracts.yaml", DIR_DEFAULT2).option("-c, --config <path>", "Path to agent-contracts.config.yaml").option("--format <format>", "Output format (text|json)", "text").option("--quiet", "Suppress output on success", false).option("--strict", "Treat warnings as errors", false).action(async (dir, opts) => {
52284
52958
  try {
52285
52959
  const config = await loadConfig(opts.config);
52286
52960
  const dslPath = resolveDslPath(dir, DIR_DEFAULT2, config);
52287
52961
  const resolved = await resolve4(dslPath);
52288
52962
  const data = config?.vars ? substituteVars(resolved.data, config.vars) : resolved.data;
52289
52963
  const schemaResult = validateSchema(data);
52964
+ const schemaWarnings = schemaResult.diagnostics.filter(
52965
+ (d2) => d2.severity === "warning"
52966
+ );
52290
52967
  if (!schemaResult.success) {
52291
52968
  const output = formatDiagnostics(schemaResult.diagnostics, opts);
52292
52969
  if (output) process.stderr.write(output + "\n");
@@ -52294,13 +52971,18 @@ var validateCommand = new Command2("validate").description("Validate DSL against
52294
52971
  }
52295
52972
  const refDiags = checkReferences(schemaResult.data);
52296
52973
  const handoffDiags = validateHandoffSchemas(schemaResult.data);
52297
- const allDiags = [...refDiags, ...handoffDiags];
52974
+ const allDiags = [...refDiags, ...handoffDiags, ...schemaWarnings];
52975
+ const hasWarnings = allDiags.some(
52976
+ (d2) => "severity" in d2 && d2.severity === "warning"
52977
+ );
52298
52978
  if (allDiags.length > 0) {
52299
52979
  const output = formatDiagnostics(allDiags, opts);
52300
52980
  if (output) process.stderr.write(output + "\n");
52301
- process.exit(1);
52981
+ if (refDiags.length > 0 || handoffDiags.length > 0 || opts.strict && hasWarnings) {
52982
+ process.exit(1);
52983
+ }
52302
52984
  }
52303
- if (!opts.quiet) {
52985
+ if (!opts.quiet && allDiags.length === 0) {
52304
52986
  process.stdout.write("Validation passed.\n");
52305
52987
  }
52306
52988
  } catch (err) {
@@ -53715,6 +54397,9 @@ var lintCommand = new Command3("lint").description("Run semantic lint rules on r
53715
54397
  const resolved = await resolve4(dslPath);
53716
54398
  const data = config?.vars ? substituteVars(resolved.data, config.vars) : resolved.data;
53717
54399
  const schemaResult = validateSchema(data);
54400
+ const schemaWarnings = schemaResult.diagnostics.filter(
54401
+ (d2) => d2.severity === "warning"
54402
+ );
53718
54403
  if (!schemaResult.success) {
53719
54404
  const output = formatDiagnostics(schemaResult.diagnostics, {
53720
54405
  format: opts.format,
@@ -53725,7 +54410,7 @@ var lintCommand = new Command3("lint").description("Run semantic lint rules on r
53725
54410
  }
53726
54411
  const tsDiagnostics = lint(schemaResult.data);
53727
54412
  const spectralDiagnostics = await spectralLint(schemaResult.data);
53728
- const diagnostics = [...tsDiagnostics, ...spectralDiagnostics];
54413
+ const diagnostics = [...tsDiagnostics, ...spectralDiagnostics, ...schemaWarnings];
53729
54414
  if (diagnostics.length > 0) {
53730
54415
  const output = formatDiagnostics(diagnostics, {
53731
54416
  format: opts.format,
@@ -55230,6 +55915,9 @@ var checkCommand = new Command5("check").description("Run full pipeline: resolve
55230
55915
  const resolved = await resolve4(config.dsl);
55231
55916
  const data = config.vars ? substituteVars(resolved.data, config.vars) : resolved.data;
55232
55917
  const schemaResult = validateSchema(data);
55918
+ const schemaWarnings = schemaResult.diagnostics.filter(
55919
+ (d2) => d2.severity === "warning"
55920
+ );
55233
55921
  if (!schemaResult.success) {
55234
55922
  const output = formatDiagnostics(schemaResult.diagnostics, {
55235
55923
  format: opts.format,
@@ -55240,7 +55928,7 @@ var checkCommand = new Command5("check").description("Run full pipeline: resolve
55240
55928
  }
55241
55929
  const refDiags = checkReferences(schemaResult.data);
55242
55930
  const handoffDiags = validateHandoffSchemas(schemaResult.data);
55243
- const allRefDiags = [...refDiags, ...handoffDiags];
55931
+ const allRefDiags = [...refDiags, ...handoffDiags, ...schemaWarnings];
55244
55932
  if (allRefDiags.length > 0) {
55245
55933
  const output = formatDiagnostics(allRefDiags, {
55246
55934
  format: opts.format,
@@ -55504,7 +56192,7 @@ async function generateGuardrails(options) {
55504
56192
  if (filterBindings && !filterBindings.includes(binding.software)) {
55505
56193
  continue;
55506
56194
  }
55507
- if (!binding.outputs) continue;
56195
+ if (!binding.outputs && !binding.renders) continue;
55508
56196
  const checkResult = resolveChecks(dsl, binding, policy);
55509
56197
  diagnostics.push(...checkResult.diagnostics);
55510
56198
  const ctx = {
@@ -55516,9 +56204,14 @@ async function generateGuardrails(options) {
55516
56204
  vars,
55517
56205
  paths,
55518
56206
  reporting,
55519
- resolved_checks: checkResult.resolved
55520
- };
55521
- for (const [outputId, outputDef] of Object.entries(binding.outputs)) {
56207
+ resolved_checks: checkResult.resolved,
56208
+ tasks: dsl.tasks,
56209
+ artifacts: dsl.artifacts,
56210
+ agents: dsl.agents,
56211
+ handoff_types: dsl.handoff_types,
56212
+ workflow: dsl.workflow
56213
+ };
56214
+ for (const [outputId, outputDef] of Object.entries(binding.outputs ?? {})) {
55522
56215
  const pathResult = resolveBindingTargetPath(
55523
56216
  outputDef.target,
55524
56217
  paths,
@@ -55648,9 +56341,98 @@ async function generateGuardrails(options) {
55648
56341
  }
55649
56342
  }
55650
56343
  }
56344
+ for (const renderTarget of binding.renders ?? []) {
56345
+ let templateContent;
56346
+ if (renderTarget.inline_template) {
56347
+ templateContent = renderTarget.inline_template;
56348
+ } else if (renderTarget.template) {
56349
+ const templatePath = resolve6(config.configDir, renderTarget.template);
56350
+ try {
56351
+ templateContent = await readFile5(templatePath, "utf8");
56352
+ } catch {
56353
+ diagnostics.push({
56354
+ path: `binding.${binding.software}.renders`,
56355
+ message: `Template file not found: ${templatePath}`,
56356
+ severity: "error"
56357
+ });
56358
+ continue;
56359
+ }
56360
+ } else {
56361
+ diagnostics.push({
56362
+ path: `binding.${binding.software}.renders`,
56363
+ message: "Render target has neither template nor inline_template",
56364
+ severity: "error"
56365
+ });
56366
+ continue;
56367
+ }
56368
+ const compiled = Handlebars2.compile(templateContent, { noEscape: true });
56369
+ const shouldSkipEmpty = renderTarget.skip_empty === true;
56370
+ const context = renderTarget.context;
56371
+ if (context === "system") {
56372
+ const sysCtx = buildSystemContext(dsl);
56373
+ const mergedCtx = { ...sysCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
56374
+ const rendered = compiled(mergedCtx);
56375
+ const resolvedOutput = resolveBindingRenderOutputPath(renderTarget.output, paths);
56376
+ const outputPath = resolve6(config.configDir, resolvedOutput);
56377
+ if (shouldSkipEmpty && rendered.trim().length === 0) {
56378
+ if (!dryRun) {
56379
+ try {
56380
+ await unlink2(outputPath);
56381
+ } catch {
56382
+ }
56383
+ }
56384
+ continue;
56385
+ }
56386
+ if (!dryRun) {
56387
+ await mkdir2(dirname6(outputPath), { recursive: true });
56388
+ await writeFile2(outputPath, rendered, "utf8");
56389
+ if (renderTarget.executable) {
56390
+ await chmod(outputPath, 493);
56391
+ }
56392
+ }
56393
+ outputFiles.push(outputPath);
56394
+ } else {
56395
+ const section = getDslSection(dsl, context);
56396
+ const allIds = Object.keys(section);
56397
+ const ids = filterIds(allIds, renderTarget.include, renderTarget.exclude);
56398
+ for (const entityId of ids) {
56399
+ const entityCtx = buildEntityContext(dsl, context, entityId);
56400
+ const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
56401
+ const rendered = compiled(mergedCtx);
56402
+ const resolvedOutput = resolveBindingRenderOutputPath(
56403
+ expandOutputPath(renderTarget.output, context, entityId),
56404
+ paths
56405
+ );
56406
+ const outputPath = resolve6(config.configDir, resolvedOutput);
56407
+ if (shouldSkipEmpty && rendered.trim().length === 0) {
56408
+ if (!dryRun) {
56409
+ try {
56410
+ await unlink2(outputPath);
56411
+ } catch {
56412
+ }
56413
+ }
56414
+ continue;
56415
+ }
56416
+ if (!dryRun) {
56417
+ await mkdir2(dirname6(outputPath), { recursive: true });
56418
+ await writeFile2(outputPath, rendered, "utf8");
56419
+ if (renderTarget.executable) {
56420
+ await chmod(outputPath, 493);
56421
+ }
56422
+ }
56423
+ outputFiles.push(outputPath);
56424
+ }
56425
+ }
56426
+ }
55651
56427
  }
55652
56428
  return { outputFiles, diagnostics };
55653
56429
  }
56430
+ function resolveBindingRenderOutputPath(output, paths) {
56431
+ return output.replace(/\{(\w+)\}/g, (match, varName) => {
56432
+ const value = paths[varName];
56433
+ return value !== void 0 ? value : match;
56434
+ });
56435
+ }
55654
56436
 
55655
56437
  // src/cli/commands/generate-guardrails.ts
55656
56438
  var generateGuardrailsCommand = new Command6("generate").description("Generate guardrail runtime artifacts from DSL, policies, and bindings").argument("[type]", "Type of artifacts to generate", "guardrails").option("-c, --config <path>", "Path to agent-contracts.config.yaml").option("--binding <name...>", "Filter to specific software binding(s)").option("--dry-run", "Print what would be generated without writing files", false).option("--quiet", "Suppress output on success", false).action(