agent-contracts 0.23.3 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -106,15 +106,33 @@ type Agent = z.infer<typeof AgentSchema>;
106
106
  declare const ArtifactSchema: z.ZodObject<{
107
107
  type: z.ZodString;
108
108
  description: z.ZodOptional<z.ZodString>;
109
- owner: z.ZodString;
110
- producers: z.ZodArray<z.ZodString>;
111
- editors: z.ZodArray<z.ZodString>;
112
- consumers: z.ZodArray<z.ZodString>;
113
- states: z.ZodArray<z.ZodString>;
109
+ owner: z.ZodOptional<z.ZodString>;
110
+ producers: z.ZodDefault<z.ZodArray<z.ZodString>>;
111
+ editors: z.ZodDefault<z.ZodArray<z.ZodString>>;
112
+ consumers: z.ZodDefault<z.ZodArray<z.ZodString>>;
113
+ states: z.ZodDefault<z.ZodArray<z.ZodString>>;
114
114
  required_validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
115
115
  visibility: z.ZodOptional<z.ZodString>;
116
116
  classification: z.ZodOptional<z.ZodString>;
117
117
  guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ authority: z.ZodOptional<z.ZodEnum<{
119
+ canonical: "canonical";
120
+ derived: "derived";
121
+ generated: "generated";
122
+ control: "control";
123
+ }>>;
124
+ path_patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
125
+ exclude_patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ manual_edit: z.ZodOptional<z.ZodEnum<{
127
+ allowed: "allowed";
128
+ discouraged: "discouraged";
129
+ forbidden: "forbidden";
130
+ }>>;
131
+ change_control: z.ZodOptional<z.ZodEnum<{
132
+ none: "none";
133
+ "approval-required": "approval-required";
134
+ "regeneration-required": "regeneration-required";
135
+ }>>;
118
136
  }, z.core.$loose>;
119
137
  type Artifact = z.infer<typeof ArtifactSchema>;
120
138
 
@@ -501,22 +519,40 @@ declare const DslSchema: z.ZodObject<{
501
519
  artifacts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
502
520
  type: z.ZodString;
503
521
  description: z.ZodOptional<z.ZodString>;
504
- owner: z.ZodString;
505
- producers: z.ZodArray<z.ZodString>;
506
- editors: z.ZodArray<z.ZodString>;
507
- consumers: z.ZodArray<z.ZodString>;
508
- states: z.ZodArray<z.ZodString>;
522
+ owner: z.ZodOptional<z.ZodString>;
523
+ producers: z.ZodDefault<z.ZodArray<z.ZodString>>;
524
+ editors: z.ZodDefault<z.ZodArray<z.ZodString>>;
525
+ consumers: z.ZodDefault<z.ZodArray<z.ZodString>>;
526
+ states: z.ZodDefault<z.ZodArray<z.ZodString>>;
509
527
  required_validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
510
528
  visibility: z.ZodOptional<z.ZodString>;
511
529
  classification: z.ZodOptional<z.ZodString>;
512
530
  guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
531
+ authority: z.ZodOptional<z.ZodEnum<{
532
+ canonical: "canonical";
533
+ derived: "derived";
534
+ generated: "generated";
535
+ control: "control";
536
+ }>>;
537
+ path_patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
538
+ exclude_patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
539
+ manual_edit: z.ZodOptional<z.ZodEnum<{
540
+ allowed: "allowed";
541
+ discouraged: "discouraged";
542
+ forbidden: "forbidden";
543
+ }>>;
544
+ change_control: z.ZodOptional<z.ZodEnum<{
545
+ none: "none";
546
+ "approval-required": "approval-required";
547
+ "regeneration-required": "regeneration-required";
548
+ }>>;
513
549
  }, z.core.$loose>>>;
514
550
  tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
515
551
  kind: z.ZodString;
516
552
  description: z.ZodOptional<z.ZodString>;
517
553
  input_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
518
554
  output_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
519
- invokable_by: z.ZodArray<z.ZodString>;
555
+ invokable_by: z.ZodDefault<z.ZodArray<z.ZodString>>;
520
556
  side_effects: z.ZodDefault<z.ZodArray<z.ZodString>>;
521
557
  commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
522
558
  command: z.ZodString;
@@ -1035,7 +1071,7 @@ declare const ToolSchema: z.ZodObject<{
1035
1071
  description: z.ZodOptional<z.ZodString>;
1036
1072
  input_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
1037
1073
  output_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
1038
- invokable_by: z.ZodArray<z.ZodString>;
1074
+ invokable_by: z.ZodDefault<z.ZodArray<z.ZodString>>;
1039
1075
  side_effects: z.ZodDefault<z.ZodArray<z.ZodString>>;
1040
1076
  commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
1041
1077
  command: z.ZodString;
package/dist/index.js CHANGED
@@ -48942,15 +48942,20 @@ import { z as z2 } from "zod";
48942
48942
  var ArtifactSchema = z2.object({
48943
48943
  type: z2.string(),
48944
48944
  description: z2.string().optional(),
48945
- owner: z2.string(),
48946
- producers: z2.array(z2.string()),
48947
- editors: z2.array(z2.string()),
48948
- consumers: z2.array(z2.string()),
48949
- states: z2.array(z2.string()),
48945
+ owner: z2.string().optional(),
48946
+ producers: z2.array(z2.string()).default([]),
48947
+ editors: z2.array(z2.string()).default([]),
48948
+ consumers: z2.array(z2.string()).default([]),
48949
+ states: z2.array(z2.string()).default([]),
48950
48950
  required_validations: z2.array(z2.string()).default([]),
48951
48951
  visibility: z2.string().optional(),
48952
48952
  classification: z2.string().optional(),
48953
- guardrails: z2.array(z2.string()).optional()
48953
+ guardrails: z2.array(z2.string()).optional(),
48954
+ authority: z2.enum(["canonical", "derived", "generated", "control"]).optional(),
48955
+ path_patterns: z2.array(z2.string()).optional(),
48956
+ exclude_patterns: z2.array(z2.string()).optional(),
48957
+ manual_edit: z2.enum(["allowed", "discouraged", "forbidden"]).optional(),
48958
+ change_control: z2.enum(["none", "approval-required", "regeneration-required"]).optional()
48954
48959
  }).passthrough();
48955
48960
 
48956
48961
  // src/schema/binding.ts
@@ -49213,7 +49218,7 @@ var ToolSchema = z12.object({
49213
49218
  description: z12.string().optional(),
49214
49219
  input_artifacts: z12.array(z12.string()).default([]),
49215
49220
  output_artifacts: z12.array(z12.string()).default([]),
49216
- invokable_by: z12.array(z12.string()),
49221
+ invokable_by: z12.array(z12.string()).default([]),
49217
49222
  side_effects: z12.array(z12.string()).default([]),
49218
49223
  commands: z12.array(CommandSchema).default([]),
49219
49224
  guardrails: z12.array(z12.string()).optional()
@@ -50974,28 +50979,38 @@ function checkReferences(dsl) {
50974
50979
  }
50975
50980
  }
50976
50981
  for (const [id, art] of Object.entries(dsl.artifacts)) {
50977
- checkExists(art.owner, agentIds, "agents", `artifacts.${id}.owner`);
50978
- for (const ref of art.producers) {
50979
- checkExists(ref, agentIds, "agents", `artifacts.${id}.producers`);
50982
+ if (art.owner) {
50983
+ checkExists(art.owner, agentIds, "agents", `artifacts.${id}.owner`);
50980
50984
  }
50981
- for (const ref of art.editors) {
50982
- checkExists(ref, agentIds, "agents", `artifacts.${id}.editors`);
50985
+ if (art.producers.length > 0) {
50986
+ for (const ref of art.producers) {
50987
+ checkExists(ref, agentIds, "agents", `artifacts.${id}.producers`);
50988
+ }
50989
+ }
50990
+ if (art.editors.length > 0) {
50991
+ for (const ref of art.editors) {
50992
+ checkExists(ref, agentIds, "agents", `artifacts.${id}.editors`);
50993
+ }
50983
50994
  }
50984
- for (const ref of art.consumers) {
50985
- checkExists(ref, agentIds, "agents", `artifacts.${id}.consumers`);
50995
+ if (art.consumers.length > 0) {
50996
+ for (const ref of art.consumers) {
50997
+ checkExists(ref, agentIds, "agents", `artifacts.${id}.consumers`);
50998
+ }
50986
50999
  }
50987
51000
  for (const ref of art.required_validations) {
50988
51001
  checkExists(ref, validationIds, "validations", `artifacts.${id}.required_validations`);
50989
51002
  }
50990
51003
  }
50991
51004
  for (const [id, art] of Object.entries(dsl.artifacts)) {
50992
- const ownerAgent = dsl.agents[art.owner];
50993
- if (ownerAgent && !ownerAgent.can_read_artifacts.includes(id)) {
50994
- diagnostics.push({
50995
- path: `artifacts.${id}.owner`,
50996
- message: `Agent "${art.owner}" owns artifact "${id}" but cannot read it (missing from can_read_artifacts)`,
50997
- code: "artifact-owner-no-read"
50998
- });
51005
+ if (art.owner) {
51006
+ const ownerAgent = dsl.agents[art.owner];
51007
+ if (ownerAgent && !ownerAgent.can_read_artifacts.includes(id)) {
51008
+ diagnostics.push({
51009
+ path: `artifacts.${id}.owner`,
51010
+ message: `Agent "${art.owner}" owns artifact "${id}" but cannot read it (missing from can_read_artifacts)`,
51011
+ code: "artifact-owner-no-read"
51012
+ });
51013
+ }
50999
51014
  }
51000
51015
  for (const valId of art.required_validations) {
51001
51016
  const validation = dsl.validations[valId];
@@ -51012,8 +51027,10 @@ function checkReferences(dsl) {
51012
51027
  }
51013
51028
  }
51014
51029
  for (const [id, tool] of Object.entries(dsl.tools)) {
51015
- for (const ref of tool.invokable_by) {
51016
- checkExists(ref, agentIds, "agents", `tools.${id}.invokable_by`);
51030
+ if (tool.invokable_by.length > 0) {
51031
+ for (const ref of tool.invokable_by) {
51032
+ checkExists(ref, agentIds, "agents", `tools.${id}.invokable_by`);
51033
+ }
51017
51034
  }
51018
51035
  }
51019
51036
  for (const [id, val] of Object.entries(dsl.validations)) {
@@ -51404,10 +51421,10 @@ var toolExecutionRule = {
51404
51421
  for (const [agentId, agent] of Object.entries(dsl.agents)) {
51405
51422
  for (const toolId of agent.can_execute_tools) {
51406
51423
  const invokableBy = toolInvokableBy.get(toolId);
51407
- if (invokableBy && !invokableBy.has(agentId)) {
51424
+ if (invokableBy && invokableBy.size > 0 && !invokableBy.has(agentId)) {
51408
51425
  diagnostics.push({
51409
51426
  ruleId: "tool-execution",
51410
- severity: "error",
51427
+ severity: "warning",
51411
51428
  path: `agents.${agentId}.can_execute_tools`,
51412
51429
  message: `Agent "${agentId}" has can_execute_tools "${toolId}" but tool's invokable_by does not include "${agentId}"`
51413
51430
  });
@@ -51415,12 +51432,13 @@ var toolExecutionRule = {
51415
51432
  }
51416
51433
  }
51417
51434
  for (const [toolId, tool] of Object.entries(dsl.tools)) {
51435
+ if (tool.invokable_by.length === 0) continue;
51418
51436
  for (const agentId of tool.invokable_by) {
51419
51437
  const agent = dsl.agents[agentId];
51420
51438
  if (agent && !agent.can_execute_tools.includes(toolId)) {
51421
51439
  diagnostics.push({
51422
51440
  ruleId: "tool-execution",
51423
- severity: "error",
51441
+ severity: "warning",
51424
51442
  path: `tools.${toolId}.invokable_by`,
51425
51443
  message: `Tool "${toolId}" has invokable_by "${agentId}" but agent's can_execute_tools does not include "${toolId}"`
51426
51444
  });
@@ -51536,10 +51554,10 @@ var taskAgentBindingRule = {
51536
51554
  });
51537
51555
  }
51538
51556
  const tool = dsl.tools[step.uses_tool];
51539
- if (tool && !tool.invokable_by.includes(task.target_agent)) {
51557
+ if (tool && tool.invokable_by.length > 0 && !tool.invokable_by.includes(task.target_agent)) {
51540
51558
  diagnostics.push({
51541
51559
  ruleId: "task-agent-binding",
51542
- severity: "error",
51560
+ severity: "warning",
51543
51561
  path: `tasks.${taskId}.execution_steps`,
51544
51562
  message: `Task "${taskId}" step uses_tool "${step.uses_tool}" but tool's invokable_by does not include "${task.target_agent}"`
51545
51563
  });
@@ -51606,7 +51624,7 @@ var artifactOwnershipRule = {
51606
51624
  for (const step of task.execution_steps) {
51607
51625
  if (step.produces_artifact) {
51608
51626
  const artifact = dsl.artifacts[step.produces_artifact];
51609
- if (artifact) {
51627
+ if (artifact && (artifact.producers.length > 0 || artifact.editors.length > 0)) {
51610
51628
  const canWrite = artifact.producers.includes(agentId) || artifact.editors.includes(agentId);
51611
51629
  if (!canWrite) {
51612
51630
  diagnostics.push({
@@ -51620,7 +51638,7 @@ var artifactOwnershipRule = {
51620
51638
  }
51621
51639
  if (step.reads_artifact) {
51622
51640
  const artifact = dsl.artifacts[step.reads_artifact];
51623
- if (artifact) {
51641
+ if (artifact && (artifact.consumers.length > 0 || artifact.producers.length > 0 || artifact.editors.length > 0)) {
51624
51642
  const canRead = artifact.consumers.includes(agentId) || artifact.producers.includes(agentId) || artifact.editors.includes(agentId);
51625
51643
  if (!canRead) {
51626
51644
  diagnostics.push({
@@ -52519,9 +52537,9 @@ var ruleset = {
52519
52537
  }
52520
52538
  },
52521
52539
  "artifact-producers-ref": {
52522
- description: "Artifact producers must reference existing agents",
52540
+ description: "(deprecated) Artifact producers must reference existing agents",
52523
52541
  message: "{{error}}",
52524
- severity: "error",
52542
+ severity: "warn",
52525
52543
  given: "$.artifacts.*",
52526
52544
  then: {
52527
52545
  field: "producers",
@@ -52530,9 +52548,9 @@ var ruleset = {
52530
52548
  }
52531
52549
  },
52532
52550
  "artifact-editors-ref": {
52533
- description: "Artifact editors must reference existing agents",
52551
+ description: "(deprecated) Artifact editors must reference existing agents",
52534
52552
  message: "{{error}}",
52535
- severity: "error",
52553
+ severity: "warn",
52536
52554
  given: "$.artifacts.*",
52537
52555
  then: {
52538
52556
  field: "editors",
@@ -52541,9 +52559,9 @@ var ruleset = {
52541
52559
  }
52542
52560
  },
52543
52561
  "artifact-consumers-ref": {
52544
- description: "Artifact consumers must reference existing agents",
52562
+ description: "(deprecated) Artifact consumers must reference existing agents",
52545
52563
  message: "{{error}}",
52546
- severity: "error",
52564
+ severity: "warn",
52547
52565
  given: "$.artifacts.*",
52548
52566
  then: {
52549
52567
  field: "consumers",
@@ -52706,9 +52724,9 @@ var ruleset = {
52706
52724
  }
52707
52725
  },
52708
52726
  "tool-invokable-by-ref": {
52709
- description: "Tool invokable_by must reference existing agents",
52727
+ description: "(deprecated) Tool invokable_by must reference existing agents",
52710
52728
  message: "{{error}}",
52711
- severity: "error",
52729
+ severity: "warn",
52712
52730
  given: "$.tools.*",
52713
52731
  then: {
52714
52732
  field: "invokable_by",
@@ -52718,17 +52736,17 @@ var ruleset = {
52718
52736
  },
52719
52737
  // ========== 15.2.2 Artifact responsibility integrity ==========
52720
52738
  "artifact-editors-not-empty": {
52721
- description: "Artifact editors must not be empty (15.2.2)",
52739
+ description: "(deprecated) Artifact editors must not be empty (15.2.2)",
52722
52740
  message: "{{error}}",
52723
- severity: "error",
52741
+ severity: "info",
52724
52742
  given: "$.artifacts.*.editors",
52725
52743
  then: {
52726
52744
  function: editors_not_empty_default
52727
52745
  }
52728
52746
  },
52729
52747
  "artifact-owner-exists": {
52730
- description: "Every artifact must have an owner",
52731
- severity: "error",
52748
+ description: "(deprecated) Every artifact must have an owner",
52749
+ severity: "warn",
52732
52750
  given: "$.artifacts.*",
52733
52751
  then: {
52734
52752
  field: "owner",
@@ -54799,60 +54817,6 @@ function schemaCompleteness(dsl) {
54799
54817
  recommendations: lowSections.length > 0 ? [`Low optional field coverage in: ${lowSections.join(", ")}`] : []
54800
54818
  };
54801
54819
  }
54802
- function crossReferenceBidirectionality(dsl) {
54803
- let totalChecks = 0;
54804
- let passedChecks = 0;
54805
- const issues = [];
54806
- for (const [agentId, agent] of Object.entries(dsl.agents)) {
54807
- for (const toolId of agent.can_execute_tools) {
54808
- totalChecks++;
54809
- const tool = dsl.tools[toolId];
54810
- if (tool && tool.invokable_by.includes(agentId)) {
54811
- passedChecks++;
54812
- } else {
54813
- issues.push(`agent ${agentId} \u2192 tool ${toolId}`);
54814
- }
54815
- }
54816
- for (const artId of agent.can_write_artifacts) {
54817
- totalChecks++;
54818
- const art = dsl.artifacts[artId];
54819
- if (art && (art.producers.includes(agentId) || art.editors.includes(agentId))) {
54820
- passedChecks++;
54821
- } else {
54822
- issues.push(`agent ${agentId} \u2192 artifact ${artId} (write)`);
54823
- }
54824
- }
54825
- for (const artId of agent.can_read_artifacts) {
54826
- totalChecks++;
54827
- const art = dsl.artifacts[artId];
54828
- if (art && (art.consumers.includes(agentId) || art.producers.includes(agentId) || art.editors.includes(agentId))) {
54829
- passedChecks++;
54830
- } else {
54831
- issues.push(`agent ${agentId} \u2192 artifact ${artId} (read)`);
54832
- }
54833
- }
54834
- }
54835
- for (const [toolId, tool] of Object.entries(dsl.tools)) {
54836
- for (const agentId of tool.invokable_by) {
54837
- totalChecks++;
54838
- const agent = dsl.agents[agentId];
54839
- if (agent && agent.can_execute_tools.includes(toolId)) {
54840
- passedChecks++;
54841
- } else {
54842
- issues.push(`tool ${toolId} \u2192 agent ${agentId}`);
54843
- }
54844
- }
54845
- }
54846
- return {
54847
- id: "cross-reference-bidirectionality",
54848
- label: "Cross-reference bidirectionality",
54849
- score: passedChecks,
54850
- total: totalChecks,
54851
- percent: pct(passedChecks, totalChecks),
54852
- weight: 2,
54853
- recommendations: issues.length > 0 ? [`${issues.length} unreciprocated cross-references: ${issues.slice(0, 5).join(", ")}${issues.length > 5 ? `, ... (${issues.length - 5} more)` : ""}`] : []
54854
- };
54855
- }
54856
54820
  function entityGuardrailCoverage(dsl) {
54857
54821
  const entitySections = [
54858
54822
  { name: "agents", entities: dsl.agents },
@@ -54943,7 +54907,6 @@ function score(dsl) {
54943
54907
  guardrailPolicyCoverage(dsl),
54944
54908
  workflowValidationIntegration(dsl),
54945
54909
  schemaCompleteness(dsl),
54946
- crossReferenceBidirectionality(dsl),
54947
54910
  guardrailScopeResolution(dsl),
54948
54911
  entityGuardrailCoverage(dsl)
54949
54912
  ];