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/cli.js +60 -97
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +48 -12
- package/dist/index.js +60 -97
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -49713,15 +49713,20 @@ import { z as z2 } from "zod";
|
|
|
49713
49713
|
var ArtifactSchema = z2.object({
|
|
49714
49714
|
type: z2.string(),
|
|
49715
49715
|
description: z2.string().optional(),
|
|
49716
|
-
owner: z2.string(),
|
|
49717
|
-
producers: z2.array(z2.string()),
|
|
49718
|
-
editors: z2.array(z2.string()),
|
|
49719
|
-
consumers: z2.array(z2.string()),
|
|
49720
|
-
states: z2.array(z2.string()),
|
|
49716
|
+
owner: z2.string().optional(),
|
|
49717
|
+
producers: z2.array(z2.string()).default([]),
|
|
49718
|
+
editors: z2.array(z2.string()).default([]),
|
|
49719
|
+
consumers: z2.array(z2.string()).default([]),
|
|
49720
|
+
states: z2.array(z2.string()).default([]),
|
|
49721
49721
|
required_validations: z2.array(z2.string()).default([]),
|
|
49722
49722
|
visibility: z2.string().optional(),
|
|
49723
49723
|
classification: z2.string().optional(),
|
|
49724
|
-
guardrails: z2.array(z2.string()).optional()
|
|
49724
|
+
guardrails: z2.array(z2.string()).optional(),
|
|
49725
|
+
authority: z2.enum(["canonical", "derived", "generated", "control"]).optional(),
|
|
49726
|
+
path_patterns: z2.array(z2.string()).optional(),
|
|
49727
|
+
exclude_patterns: z2.array(z2.string()).optional(),
|
|
49728
|
+
manual_edit: z2.enum(["allowed", "discouraged", "forbidden"]).optional(),
|
|
49729
|
+
change_control: z2.enum(["none", "approval-required", "regeneration-required"]).optional()
|
|
49725
49730
|
}).passthrough();
|
|
49726
49731
|
|
|
49727
49732
|
// src/schema/binding.ts
|
|
@@ -49984,7 +49989,7 @@ var ToolSchema = z12.object({
|
|
|
49984
49989
|
description: z12.string().optional(),
|
|
49985
49990
|
input_artifacts: z12.array(z12.string()).default([]),
|
|
49986
49991
|
output_artifacts: z12.array(z12.string()).default([]),
|
|
49987
|
-
invokable_by: z12.array(z12.string()),
|
|
49992
|
+
invokable_by: z12.array(z12.string()).default([]),
|
|
49988
49993
|
side_effects: z12.array(z12.string()).default([]),
|
|
49989
49994
|
commands: z12.array(CommandSchema).default([]),
|
|
49990
49995
|
guardrails: z12.array(z12.string()).optional()
|
|
@@ -52118,28 +52123,38 @@ function checkReferences(dsl) {
|
|
|
52118
52123
|
}
|
|
52119
52124
|
}
|
|
52120
52125
|
for (const [id, art] of Object.entries(dsl.artifacts)) {
|
|
52121
|
-
|
|
52122
|
-
|
|
52123
|
-
checkExists(ref, agentIds, "agents", `artifacts.${id}.producers`);
|
|
52126
|
+
if (art.owner) {
|
|
52127
|
+
checkExists(art.owner, agentIds, "agents", `artifacts.${id}.owner`);
|
|
52124
52128
|
}
|
|
52125
|
-
|
|
52126
|
-
|
|
52129
|
+
if (art.producers.length > 0) {
|
|
52130
|
+
for (const ref of art.producers) {
|
|
52131
|
+
checkExists(ref, agentIds, "agents", `artifacts.${id}.producers`);
|
|
52132
|
+
}
|
|
52133
|
+
}
|
|
52134
|
+
if (art.editors.length > 0) {
|
|
52135
|
+
for (const ref of art.editors) {
|
|
52136
|
+
checkExists(ref, agentIds, "agents", `artifacts.${id}.editors`);
|
|
52137
|
+
}
|
|
52127
52138
|
}
|
|
52128
|
-
|
|
52129
|
-
|
|
52139
|
+
if (art.consumers.length > 0) {
|
|
52140
|
+
for (const ref of art.consumers) {
|
|
52141
|
+
checkExists(ref, agentIds, "agents", `artifacts.${id}.consumers`);
|
|
52142
|
+
}
|
|
52130
52143
|
}
|
|
52131
52144
|
for (const ref of art.required_validations) {
|
|
52132
52145
|
checkExists(ref, validationIds, "validations", `artifacts.${id}.required_validations`);
|
|
52133
52146
|
}
|
|
52134
52147
|
}
|
|
52135
52148
|
for (const [id, art] of Object.entries(dsl.artifacts)) {
|
|
52136
|
-
|
|
52137
|
-
|
|
52138
|
-
|
|
52139
|
-
|
|
52140
|
-
|
|
52141
|
-
|
|
52142
|
-
|
|
52149
|
+
if (art.owner) {
|
|
52150
|
+
const ownerAgent = dsl.agents[art.owner];
|
|
52151
|
+
if (ownerAgent && !ownerAgent.can_read_artifacts.includes(id)) {
|
|
52152
|
+
diagnostics.push({
|
|
52153
|
+
path: `artifacts.${id}.owner`,
|
|
52154
|
+
message: `Agent "${art.owner}" owns artifact "${id}" but cannot read it (missing from can_read_artifacts)`,
|
|
52155
|
+
code: "artifact-owner-no-read"
|
|
52156
|
+
});
|
|
52157
|
+
}
|
|
52143
52158
|
}
|
|
52144
52159
|
for (const valId of art.required_validations) {
|
|
52145
52160
|
const validation = dsl.validations[valId];
|
|
@@ -52156,8 +52171,10 @@ function checkReferences(dsl) {
|
|
|
52156
52171
|
}
|
|
52157
52172
|
}
|
|
52158
52173
|
for (const [id, tool] of Object.entries(dsl.tools)) {
|
|
52159
|
-
|
|
52160
|
-
|
|
52174
|
+
if (tool.invokable_by.length > 0) {
|
|
52175
|
+
for (const ref of tool.invokable_by) {
|
|
52176
|
+
checkExists(ref, agentIds, "agents", `tools.${id}.invokable_by`);
|
|
52177
|
+
}
|
|
52161
52178
|
}
|
|
52162
52179
|
}
|
|
52163
52180
|
for (const [id, val] of Object.entries(dsl.validations)) {
|
|
@@ -52548,10 +52565,10 @@ var toolExecutionRule = {
|
|
|
52548
52565
|
for (const [agentId, agent] of Object.entries(dsl.agents)) {
|
|
52549
52566
|
for (const toolId of agent.can_execute_tools) {
|
|
52550
52567
|
const invokableBy = toolInvokableBy.get(toolId);
|
|
52551
|
-
if (invokableBy && !invokableBy.has(agentId)) {
|
|
52568
|
+
if (invokableBy && invokableBy.size > 0 && !invokableBy.has(agentId)) {
|
|
52552
52569
|
diagnostics.push({
|
|
52553
52570
|
ruleId: "tool-execution",
|
|
52554
|
-
severity: "
|
|
52571
|
+
severity: "warning",
|
|
52555
52572
|
path: `agents.${agentId}.can_execute_tools`,
|
|
52556
52573
|
message: `Agent "${agentId}" has can_execute_tools "${toolId}" but tool's invokable_by does not include "${agentId}"`
|
|
52557
52574
|
});
|
|
@@ -52559,12 +52576,13 @@ var toolExecutionRule = {
|
|
|
52559
52576
|
}
|
|
52560
52577
|
}
|
|
52561
52578
|
for (const [toolId, tool] of Object.entries(dsl.tools)) {
|
|
52579
|
+
if (tool.invokable_by.length === 0) continue;
|
|
52562
52580
|
for (const agentId of tool.invokable_by) {
|
|
52563
52581
|
const agent = dsl.agents[agentId];
|
|
52564
52582
|
if (agent && !agent.can_execute_tools.includes(toolId)) {
|
|
52565
52583
|
diagnostics.push({
|
|
52566
52584
|
ruleId: "tool-execution",
|
|
52567
|
-
severity: "
|
|
52585
|
+
severity: "warning",
|
|
52568
52586
|
path: `tools.${toolId}.invokable_by`,
|
|
52569
52587
|
message: `Tool "${toolId}" has invokable_by "${agentId}" but agent's can_execute_tools does not include "${toolId}"`
|
|
52570
52588
|
});
|
|
@@ -52680,10 +52698,10 @@ var taskAgentBindingRule = {
|
|
|
52680
52698
|
});
|
|
52681
52699
|
}
|
|
52682
52700
|
const tool = dsl.tools[step.uses_tool];
|
|
52683
|
-
if (tool && !tool.invokable_by.includes(task.target_agent)) {
|
|
52701
|
+
if (tool && tool.invokable_by.length > 0 && !tool.invokable_by.includes(task.target_agent)) {
|
|
52684
52702
|
diagnostics.push({
|
|
52685
52703
|
ruleId: "task-agent-binding",
|
|
52686
|
-
severity: "
|
|
52704
|
+
severity: "warning",
|
|
52687
52705
|
path: `tasks.${taskId}.execution_steps`,
|
|
52688
52706
|
message: `Task "${taskId}" step uses_tool "${step.uses_tool}" but tool's invokable_by does not include "${task.target_agent}"`
|
|
52689
52707
|
});
|
|
@@ -52750,7 +52768,7 @@ var artifactOwnershipRule = {
|
|
|
52750
52768
|
for (const step of task.execution_steps) {
|
|
52751
52769
|
if (step.produces_artifact) {
|
|
52752
52770
|
const artifact = dsl.artifacts[step.produces_artifact];
|
|
52753
|
-
if (artifact) {
|
|
52771
|
+
if (artifact && (artifact.producers.length > 0 || artifact.editors.length > 0)) {
|
|
52754
52772
|
const canWrite = artifact.producers.includes(agentId) || artifact.editors.includes(agentId);
|
|
52755
52773
|
if (!canWrite) {
|
|
52756
52774
|
diagnostics.push({
|
|
@@ -52764,7 +52782,7 @@ var artifactOwnershipRule = {
|
|
|
52764
52782
|
}
|
|
52765
52783
|
if (step.reads_artifact) {
|
|
52766
52784
|
const artifact = dsl.artifacts[step.reads_artifact];
|
|
52767
|
-
if (artifact) {
|
|
52785
|
+
if (artifact && (artifact.consumers.length > 0 || artifact.producers.length > 0 || artifact.editors.length > 0)) {
|
|
52768
52786
|
const canRead = artifact.consumers.includes(agentId) || artifact.producers.includes(agentId) || artifact.editors.includes(agentId);
|
|
52769
52787
|
if (!canRead) {
|
|
52770
52788
|
diagnostics.push({
|
|
@@ -53663,9 +53681,9 @@ var ruleset = {
|
|
|
53663
53681
|
}
|
|
53664
53682
|
},
|
|
53665
53683
|
"artifact-producers-ref": {
|
|
53666
|
-
description: "Artifact producers must reference existing agents",
|
|
53684
|
+
description: "(deprecated) Artifact producers must reference existing agents",
|
|
53667
53685
|
message: "{{error}}",
|
|
53668
|
-
severity: "
|
|
53686
|
+
severity: "warn",
|
|
53669
53687
|
given: "$.artifacts.*",
|
|
53670
53688
|
then: {
|
|
53671
53689
|
field: "producers",
|
|
@@ -53674,9 +53692,9 @@ var ruleset = {
|
|
|
53674
53692
|
}
|
|
53675
53693
|
},
|
|
53676
53694
|
"artifact-editors-ref": {
|
|
53677
|
-
description: "Artifact editors must reference existing agents",
|
|
53695
|
+
description: "(deprecated) Artifact editors must reference existing agents",
|
|
53678
53696
|
message: "{{error}}",
|
|
53679
|
-
severity: "
|
|
53697
|
+
severity: "warn",
|
|
53680
53698
|
given: "$.artifacts.*",
|
|
53681
53699
|
then: {
|
|
53682
53700
|
field: "editors",
|
|
@@ -53685,9 +53703,9 @@ var ruleset = {
|
|
|
53685
53703
|
}
|
|
53686
53704
|
},
|
|
53687
53705
|
"artifact-consumers-ref": {
|
|
53688
|
-
description: "Artifact consumers must reference existing agents",
|
|
53706
|
+
description: "(deprecated) Artifact consumers must reference existing agents",
|
|
53689
53707
|
message: "{{error}}",
|
|
53690
|
-
severity: "
|
|
53708
|
+
severity: "warn",
|
|
53691
53709
|
given: "$.artifacts.*",
|
|
53692
53710
|
then: {
|
|
53693
53711
|
field: "consumers",
|
|
@@ -53850,9 +53868,9 @@ var ruleset = {
|
|
|
53850
53868
|
}
|
|
53851
53869
|
},
|
|
53852
53870
|
"tool-invokable-by-ref": {
|
|
53853
|
-
description: "Tool invokable_by must reference existing agents",
|
|
53871
|
+
description: "(deprecated) Tool invokable_by must reference existing agents",
|
|
53854
53872
|
message: "{{error}}",
|
|
53855
|
-
severity: "
|
|
53873
|
+
severity: "warn",
|
|
53856
53874
|
given: "$.tools.*",
|
|
53857
53875
|
then: {
|
|
53858
53876
|
field: "invokable_by",
|
|
@@ -53862,17 +53880,17 @@ var ruleset = {
|
|
|
53862
53880
|
},
|
|
53863
53881
|
// ========== 15.2.2 Artifact responsibility integrity ==========
|
|
53864
53882
|
"artifact-editors-not-empty": {
|
|
53865
|
-
description: "Artifact editors must not be empty (15.2.2)",
|
|
53883
|
+
description: "(deprecated) Artifact editors must not be empty (15.2.2)",
|
|
53866
53884
|
message: "{{error}}",
|
|
53867
|
-
severity: "
|
|
53885
|
+
severity: "info",
|
|
53868
53886
|
given: "$.artifacts.*.editors",
|
|
53869
53887
|
then: {
|
|
53870
53888
|
function: editors_not_empty_default
|
|
53871
53889
|
}
|
|
53872
53890
|
},
|
|
53873
53891
|
"artifact-owner-exists": {
|
|
53874
|
-
description: "Every artifact must have an owner",
|
|
53875
|
-
severity: "
|
|
53892
|
+
description: "(deprecated) Every artifact must have an owner",
|
|
53893
|
+
severity: "warn",
|
|
53876
53894
|
given: "$.artifacts.*",
|
|
53877
53895
|
then: {
|
|
53878
53896
|
field: "owner",
|
|
@@ -55595,60 +55613,6 @@ function schemaCompleteness(dsl) {
|
|
|
55595
55613
|
recommendations: lowSections.length > 0 ? [`Low optional field coverage in: ${lowSections.join(", ")}`] : []
|
|
55596
55614
|
};
|
|
55597
55615
|
}
|
|
55598
|
-
function crossReferenceBidirectionality(dsl) {
|
|
55599
|
-
let totalChecks = 0;
|
|
55600
|
-
let passedChecks = 0;
|
|
55601
|
-
const issues = [];
|
|
55602
|
-
for (const [agentId, agent] of Object.entries(dsl.agents)) {
|
|
55603
|
-
for (const toolId of agent.can_execute_tools) {
|
|
55604
|
-
totalChecks++;
|
|
55605
|
-
const tool = dsl.tools[toolId];
|
|
55606
|
-
if (tool && tool.invokable_by.includes(agentId)) {
|
|
55607
|
-
passedChecks++;
|
|
55608
|
-
} else {
|
|
55609
|
-
issues.push(`agent ${agentId} \u2192 tool ${toolId}`);
|
|
55610
|
-
}
|
|
55611
|
-
}
|
|
55612
|
-
for (const artId of agent.can_write_artifacts) {
|
|
55613
|
-
totalChecks++;
|
|
55614
|
-
const art = dsl.artifacts[artId];
|
|
55615
|
-
if (art && (art.producers.includes(agentId) || art.editors.includes(agentId))) {
|
|
55616
|
-
passedChecks++;
|
|
55617
|
-
} else {
|
|
55618
|
-
issues.push(`agent ${agentId} \u2192 artifact ${artId} (write)`);
|
|
55619
|
-
}
|
|
55620
|
-
}
|
|
55621
|
-
for (const artId of agent.can_read_artifacts) {
|
|
55622
|
-
totalChecks++;
|
|
55623
|
-
const art = dsl.artifacts[artId];
|
|
55624
|
-
if (art && (art.consumers.includes(agentId) || art.producers.includes(agentId) || art.editors.includes(agentId))) {
|
|
55625
|
-
passedChecks++;
|
|
55626
|
-
} else {
|
|
55627
|
-
issues.push(`agent ${agentId} \u2192 artifact ${artId} (read)`);
|
|
55628
|
-
}
|
|
55629
|
-
}
|
|
55630
|
-
}
|
|
55631
|
-
for (const [toolId, tool] of Object.entries(dsl.tools)) {
|
|
55632
|
-
for (const agentId of tool.invokable_by) {
|
|
55633
|
-
totalChecks++;
|
|
55634
|
-
const agent = dsl.agents[agentId];
|
|
55635
|
-
if (agent && agent.can_execute_tools.includes(toolId)) {
|
|
55636
|
-
passedChecks++;
|
|
55637
|
-
} else {
|
|
55638
|
-
issues.push(`tool ${toolId} \u2192 agent ${agentId}`);
|
|
55639
|
-
}
|
|
55640
|
-
}
|
|
55641
|
-
}
|
|
55642
|
-
return {
|
|
55643
|
-
id: "cross-reference-bidirectionality",
|
|
55644
|
-
label: "Cross-reference bidirectionality",
|
|
55645
|
-
score: passedChecks,
|
|
55646
|
-
total: totalChecks,
|
|
55647
|
-
percent: pct(passedChecks, totalChecks),
|
|
55648
|
-
weight: 2,
|
|
55649
|
-
recommendations: issues.length > 0 ? [`${issues.length} unreciprocated cross-references: ${issues.slice(0, 5).join(", ")}${issues.length > 5 ? `, ... (${issues.length - 5} more)` : ""}`] : []
|
|
55650
|
-
};
|
|
55651
|
-
}
|
|
55652
55616
|
function entityGuardrailCoverage(dsl) {
|
|
55653
55617
|
const entitySections = [
|
|
55654
55618
|
{ name: "agents", entities: dsl.agents },
|
|
@@ -55739,7 +55703,6 @@ function score(dsl) {
|
|
|
55739
55703
|
guardrailPolicyCoverage(dsl),
|
|
55740
55704
|
workflowValidationIntegration(dsl),
|
|
55741
55705
|
schemaCompleteness(dsl),
|
|
55742
|
-
crossReferenceBidirectionality(dsl),
|
|
55743
55706
|
guardrailScopeResolution(dsl),
|
|
55744
55707
|
entityGuardrailCoverage(dsl)
|
|
55745
55708
|
];
|