agent-contracts 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ type Prerequisite = z.infer<typeof PrerequisiteSchema>;
46
46
  declare const AgentSchema: z.ZodObject<{
47
47
  role_name: z.ZodString;
48
48
  purpose: z.ZodString;
49
+ own_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
49
50
  can_read_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
50
51
  can_write_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
51
52
  can_execute_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -401,6 +402,7 @@ declare const DslSchema: z.ZodObject<{
401
402
  agents: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
402
403
  role_name: z.ZodString;
403
404
  purpose: z.ZodString;
405
+ own_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
404
406
  can_read_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
405
407
  can_write_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
406
408
  can_execute_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -476,6 +478,16 @@ declare const DslSchema: z.ZodObject<{
476
478
  uses_tool: z.ZodOptional<z.ZodString>;
477
479
  produces_artifact: z.ZodOptional<z.ZodString>;
478
480
  reads_artifact: z.ZodOptional<z.ZodString>;
481
+ validates_artifact: z.ZodOptional<z.ZodString>;
482
+ validation_kind: z.ZodOptional<z.ZodEnum<{
483
+ schema: "schema";
484
+ mechanical: "mechanical";
485
+ semantic: "semantic";
486
+ approval: "approval";
487
+ provenance: "provenance";
488
+ traceability: "traceability";
489
+ fidelity: "fidelity";
490
+ }>>;
479
491
  depends_on: z.ZodOptional<z.ZodArray<z.ZodString>>;
480
492
  skip_condition: z.ZodOptional<z.ZodString>;
481
493
  wait_for_approval: z.ZodOptional<z.ZodBoolean>;
@@ -553,6 +565,8 @@ declare const DslSchema: z.ZodObject<{
553
565
  input_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
554
566
  output_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
555
567
  invokable_by: z.ZodDefault<z.ZodArray<z.ZodString>>;
568
+ cli_contract: z.ZodOptional<z.ZodString>;
569
+ artifact_bindings: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
556
570
  side_effects: z.ZodDefault<z.ZodArray<z.ZodString>>;
557
571
  commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
558
572
  command: z.ZodString;
@@ -574,11 +588,11 @@ declare const DslSchema: z.ZodObject<{
574
588
  traceability: "traceability";
575
589
  fidelity: "fidelity";
576
590
  }>;
577
- executor_type: z.ZodEnum<{
591
+ executor_type: z.ZodOptional<z.ZodEnum<{
578
592
  agent: "agent";
579
593
  tool: "tool";
580
- }>;
581
- executor: z.ZodString;
594
+ }>>;
595
+ executor: z.ZodOptional<z.ZodString>;
582
596
  blocking: z.ZodBoolean;
583
597
  produces_evidence: z.ZodOptional<z.ZodString>;
584
598
  description: z.ZodOptional<z.ZodString>;
@@ -991,6 +1005,16 @@ declare const ExecutionStepSchema: z.ZodObject<{
991
1005
  uses_tool: z.ZodOptional<z.ZodString>;
992
1006
  produces_artifact: z.ZodOptional<z.ZodString>;
993
1007
  reads_artifact: z.ZodOptional<z.ZodString>;
1008
+ validates_artifact: z.ZodOptional<z.ZodString>;
1009
+ validation_kind: z.ZodOptional<z.ZodEnum<{
1010
+ schema: "schema";
1011
+ mechanical: "mechanical";
1012
+ semantic: "semantic";
1013
+ approval: "approval";
1014
+ provenance: "provenance";
1015
+ traceability: "traceability";
1016
+ fidelity: "fidelity";
1017
+ }>>;
994
1018
  depends_on: z.ZodOptional<z.ZodArray<z.ZodString>>;
995
1019
  skip_condition: z.ZodOptional<z.ZodString>;
996
1020
  wait_for_approval: z.ZodOptional<z.ZodBoolean>;
@@ -1016,6 +1040,16 @@ declare const TaskSchema: z.ZodObject<{
1016
1040
  uses_tool: z.ZodOptional<z.ZodString>;
1017
1041
  produces_artifact: z.ZodOptional<z.ZodString>;
1018
1042
  reads_artifact: z.ZodOptional<z.ZodString>;
1043
+ validates_artifact: z.ZodOptional<z.ZodString>;
1044
+ validation_kind: z.ZodOptional<z.ZodEnum<{
1045
+ schema: "schema";
1046
+ mechanical: "mechanical";
1047
+ semantic: "semantic";
1048
+ approval: "approval";
1049
+ provenance: "provenance";
1050
+ traceability: "traceability";
1051
+ fidelity: "fidelity";
1052
+ }>>;
1019
1053
  depends_on: z.ZodOptional<z.ZodArray<z.ZodString>>;
1020
1054
  skip_condition: z.ZodOptional<z.ZodString>;
1021
1055
  wait_for_approval: z.ZodOptional<z.ZodBoolean>;
@@ -1072,6 +1106,8 @@ declare const ToolSchema: z.ZodObject<{
1072
1106
  input_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
1073
1107
  output_artifacts: z.ZodDefault<z.ZodArray<z.ZodString>>;
1074
1108
  invokable_by: z.ZodDefault<z.ZodArray<z.ZodString>>;
1109
+ cli_contract: z.ZodOptional<z.ZodString>;
1110
+ artifact_bindings: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1075
1111
  side_effects: z.ZodDefault<z.ZodArray<z.ZodString>>;
1076
1112
  commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
1077
1113
  command: z.ZodString;
@@ -1095,11 +1131,11 @@ declare const ValidationSchema: z.ZodObject<{
1095
1131
  traceability: "traceability";
1096
1132
  fidelity: "fidelity";
1097
1133
  }>;
1098
- executor_type: z.ZodEnum<{
1134
+ executor_type: z.ZodOptional<z.ZodEnum<{
1099
1135
  agent: "agent";
1100
1136
  tool: "tool";
1101
- }>;
1102
- executor: z.ZodString;
1137
+ }>>;
1138
+ executor: z.ZodOptional<z.ZodString>;
1103
1139
  blocking: z.ZodBoolean;
1104
1140
  produces_evidence: z.ZodOptional<z.ZodString>;
1105
1141
  description: z.ZodOptional<z.ZodString>;
@@ -1519,7 +1555,7 @@ interface EntityValidationEntry {
1519
1555
  validation_id: string;
1520
1556
  kind: string;
1521
1557
  target_artifact: string;
1522
- executor_type: string;
1558
+ executor_type?: string;
1523
1559
  blocking: boolean;
1524
1560
  produces_evidence?: string;
1525
1561
  }
package/dist/index.js CHANGED
@@ -48919,6 +48919,7 @@ var PrerequisiteSchema = z.object({
48919
48919
  var AgentSchema = z.object({
48920
48920
  role_name: z.string(),
48921
48921
  purpose: z.string(),
48922
+ own_artifacts: z.array(z.string()).default([]),
48922
48923
  can_read_artifacts: z.array(z.string()).default([]),
48923
48924
  can_write_artifacts: z.array(z.string()).default([]),
48924
48925
  can_execute_tools: z.array(z.string()).default([]),
@@ -49152,6 +49153,8 @@ var ExecutionStepSchema = z9.object({
49152
49153
  uses_tool: z9.string().optional(),
49153
49154
  produces_artifact: z9.string().optional(),
49154
49155
  reads_artifact: z9.string().optional(),
49156
+ validates_artifact: z9.string().optional(),
49157
+ validation_kind: z9.enum(["schema", "mechanical", "semantic", "approval", "provenance", "traceability", "fidelity"]).optional(),
49155
49158
  depends_on: z9.array(z9.string()).optional(),
49156
49159
  skip_condition: z9.string().optional(),
49157
49160
  wait_for_approval: z9.boolean().optional()
@@ -49219,6 +49222,8 @@ var ToolSchema = z12.object({
49219
49222
  input_artifacts: z12.array(z12.string()).default([]),
49220
49223
  output_artifacts: z12.array(z12.string()).default([]),
49221
49224
  invokable_by: z12.array(z12.string()).default([]),
49225
+ cli_contract: z12.string().optional(),
49226
+ artifact_bindings: z12.record(z12.string(), z12.string()).default({}),
49222
49227
  side_effects: z12.array(z12.string()).default([]),
49223
49228
  commands: z12.array(CommandSchema).default([]),
49224
49229
  guardrails: z12.array(z12.string()).optional()
@@ -49229,8 +49234,8 @@ import { z as z13 } from "zod";
49229
49234
  var ValidationSchema = z13.object({
49230
49235
  target_artifact: z13.string(),
49231
49236
  kind: z13.enum(["schema", "mechanical", "semantic", "approval", "provenance", "traceability", "fidelity"]),
49232
- executor_type: z13.enum(["tool", "agent"]),
49233
- executor: z13.string(),
49237
+ executor_type: z13.enum(["tool", "agent"]).optional(),
49238
+ executor: z13.string().optional(),
49234
49239
  blocking: z13.boolean(),
49235
49240
  produces_evidence: z13.string().optional(),
49236
49241
  description: z13.string().optional()
@@ -50959,6 +50964,9 @@ function checkReferences(dsl) {
50959
50964
  }
50960
50965
  }
50961
50966
  for (const [id, agent] of Object.entries(dsl.agents)) {
50967
+ for (const ref of agent.own_artifacts) {
50968
+ checkExists(ref, artifactIds, "artifacts", `agents.${id}.own_artifacts`);
50969
+ }
50962
50970
  for (const ref of agent.can_read_artifacts) {
50963
50971
  checkExists(ref, artifactIds, "artifacts", `agents.${id}.can_read_artifacts`);
50964
50972
  }
@@ -51014,7 +51022,7 @@ function checkReferences(dsl) {
51014
51022
  }
51015
51023
  for (const valId of art.required_validations) {
51016
51024
  const validation = dsl.validations[valId];
51017
- if (validation?.executor_type === "tool") {
51025
+ if (validation?.executor_type === "tool" && validation.executor) {
51018
51026
  const tool = dsl.tools[validation.executor];
51019
51027
  if (tool && tool.invokable_by.length === 0) {
51020
51028
  diagnostics.push({
@@ -51032,12 +51040,15 @@ function checkReferences(dsl) {
51032
51040
  checkExists(ref, agentIds, "agents", `tools.${id}.invokable_by`);
51033
51041
  }
51034
51042
  }
51043
+ for (const ref of Object.values(tool.artifact_bindings)) {
51044
+ checkExists(ref, artifactIds, "artifacts", `tools.${id}.artifact_bindings`);
51045
+ }
51035
51046
  }
51036
51047
  for (const [id, val] of Object.entries(dsl.validations)) {
51037
51048
  checkExists(val.target_artifact, artifactIds, "artifacts", `validations.${id}.target_artifact`);
51038
- if (val.executor_type === "tool") {
51049
+ if (val.executor_type === "tool" && val.executor) {
51039
51050
  checkExists(val.executor, toolIds, "tools", `validations.${id}.executor`);
51040
- } else if (val.executor_type === "agent") {
51051
+ } else if (val.executor_type === "agent" && val.executor) {
51041
51052
  checkExists(val.executor, agentIds, "agents", `validations.${id}.executor`);
51042
51053
  }
51043
51054
  }
@@ -51421,10 +51432,10 @@ var toolExecutionRule = {
51421
51432
  for (const [agentId, agent] of Object.entries(dsl.agents)) {
51422
51433
  for (const toolId of agent.can_execute_tools) {
51423
51434
  const invokableBy = toolInvokableBy.get(toolId);
51424
- if (invokableBy && !invokableBy.has(agentId)) {
51435
+ if (invokableBy && invokableBy.size > 0 && !invokableBy.has(agentId)) {
51425
51436
  diagnostics.push({
51426
51437
  ruleId: "tool-execution",
51427
- severity: "error",
51438
+ severity: "warning",
51428
51439
  path: `agents.${agentId}.can_execute_tools`,
51429
51440
  message: `Agent "${agentId}" has can_execute_tools "${toolId}" but tool's invokable_by does not include "${agentId}"`
51430
51441
  });
@@ -51432,12 +51443,13 @@ var toolExecutionRule = {
51432
51443
  }
51433
51444
  }
51434
51445
  for (const [toolId, tool] of Object.entries(dsl.tools)) {
51446
+ if (tool.invokable_by.length === 0) continue;
51435
51447
  for (const agentId of tool.invokable_by) {
51436
51448
  const agent = dsl.agents[agentId];
51437
51449
  if (agent && !agent.can_execute_tools.includes(toolId)) {
51438
51450
  diagnostics.push({
51439
51451
  ruleId: "tool-execution",
51440
- severity: "error",
51452
+ severity: "warning",
51441
51453
  path: `tools.${toolId}.invokable_by`,
51442
51454
  message: `Tool "${toolId}" has invokable_by "${agentId}" but agent's can_execute_tools does not include "${toolId}"`
51443
51455
  });
@@ -51460,7 +51472,7 @@ var toolExecutionRule = {
51460
51472
  }
51461
51473
  }
51462
51474
  for (const [valId, val] of Object.entries(dsl.validations)) {
51463
- if (val.executor_type !== "tool") continue;
51475
+ if (val.executor_type !== "tool" || !val.executor) continue;
51464
51476
  const hasExecutor = Object.values(dsl.agents).some(
51465
51477
  (a3) => a3.can_execute_tools.includes(val.executor)
51466
51478
  );
@@ -51553,10 +51565,10 @@ var taskAgentBindingRule = {
51553
51565
  });
51554
51566
  }
51555
51567
  const tool = dsl.tools[step.uses_tool];
51556
- if (tool && !tool.invokable_by.includes(task.target_agent)) {
51568
+ if (tool && tool.invokable_by.length > 0 && !tool.invokable_by.includes(task.target_agent)) {
51557
51569
  diagnostics.push({
51558
51570
  ruleId: "task-agent-binding",
51559
- severity: "error",
51571
+ severity: "warning",
51560
51572
  path: `tasks.${taskId}.execution_steps`,
51561
51573
  message: `Task "${taskId}" step uses_tool "${step.uses_tool}" but tool's invokable_by does not include "${task.target_agent}"`
51562
51574
  });
@@ -52040,6 +52052,7 @@ var validationExecutorNoContextRule = {
52040
52052
  run(dsl) {
52041
52053
  const diagnostics = [];
52042
52054
  for (const [validationId, val] of Object.entries(dsl.validations)) {
52055
+ if (!val.executor) continue;
52043
52056
  if (val.executor_type === "agent") {
52044
52057
  const agent = dsl.agents[val.executor];
52045
52058
  if (!agent) continue;
@@ -52067,6 +52080,40 @@ var validationExecutorNoContextRule = {
52067
52080
  }
52068
52081
  };
52069
52082
 
52083
+ // src/linter/rules/artifact-ownership-consistency.ts
52084
+ var artifactOwnershipConsistencyRule = {
52085
+ id: "artifact-ownership-consistency",
52086
+ description: "Ensure own_artifacts entries are included in can_read_artifacts and check deprecated owner field consistency",
52087
+ run(dsl) {
52088
+ const diagnostics = [];
52089
+ for (const [agentId, agent] of Object.entries(dsl.agents)) {
52090
+ for (const artId of agent.own_artifacts) {
52091
+ if (!agent.can_read_artifacts.includes(artId)) {
52092
+ diagnostics.push({
52093
+ ruleId: "artifact-ownership-consistency",
52094
+ severity: "warning",
52095
+ path: `agents.${agentId}.own_artifacts`,
52096
+ message: `Agent "${agentId}" owns artifact "${artId}" but does not include it in can_read_artifacts`
52097
+ });
52098
+ }
52099
+ }
52100
+ }
52101
+ for (const [artId, art] of Object.entries(dsl.artifacts)) {
52102
+ if (!art.owner) continue;
52103
+ const ownerAgent = dsl.agents[art.owner];
52104
+ if (ownerAgent && !ownerAgent.own_artifacts.includes(artId)) {
52105
+ diagnostics.push({
52106
+ ruleId: "artifact-ownership-consistency",
52107
+ severity: "warning",
52108
+ path: `artifacts.${artId}.owner`,
52109
+ message: `Artifact "${artId}" has deprecated owner "${art.owner}" but agent does not list it in own_artifacts`
52110
+ });
52111
+ }
52112
+ }
52113
+ return diagnostics;
52114
+ }
52115
+ };
52116
+
52070
52117
  // src/linter/rules/extension-consumption.ts
52071
52118
  function isRecord4(v2) {
52072
52119
  return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
@@ -52254,6 +52301,7 @@ var builtinRules = [
52254
52301
  entityNoGuardrailsRule,
52255
52302
  guardrailOrphanedRule,
52256
52303
  validationExecutorNoContextRule,
52304
+ artifactOwnershipConsistencyRule,
52257
52305
  extensionDeclaredButUnusedRule,
52258
52306
  extensionScopeMismatchRule,
52259
52307
  extensionUndeclaredUsageRule
@@ -52723,9 +52771,9 @@ var ruleset = {
52723
52771
  }
52724
52772
  },
52725
52773
  "tool-invokable-by-ref": {
52726
- description: "Tool invokable_by must reference existing agents",
52774
+ description: "(deprecated) Tool invokable_by must reference existing agents",
52727
52775
  message: "{{error}}",
52728
- severity: "error",
52776
+ severity: "warn",
52729
52777
  given: "$.tools.*",
52730
52778
  then: {
52731
52779
  field: "invokable_by",
@@ -52744,8 +52792,8 @@ var ruleset = {
52744
52792
  }
52745
52793
  },
52746
52794
  "artifact-owner-exists": {
52747
- description: "Every artifact must have an owner",
52748
- severity: "error",
52795
+ description: "(deprecated) Every artifact must have an owner",
52796
+ severity: "warn",
52749
52797
  given: "$.artifacts.*",
52750
52798
  then: {
52751
52799
  field: "owner",
@@ -53464,8 +53512,8 @@ function collectReferencedIds(workflow, dsl, relatedTasks) {
53464
53512
  } else if (step.type === "validation") {
53465
53513
  const val = dsl.validations[step.validation];
53466
53514
  if (val) {
53467
- if (val.executor_type === "agent") addAgent(val.executor);
53468
- else tools.add(val.executor);
53515
+ if (val.executor && val.executor_type === "agent") addAgent(val.executor);
53516
+ else if (val.executor) tools.add(val.executor);
53469
53517
  artifacts.add(val.target_artifact);
53470
53518
  }
53471
53519
  }
@@ -53841,9 +53889,9 @@ function collectPhaseOps(dsl, wfId) {
53841
53889
  } else if (step.type === "validation") {
53842
53890
  const val = dsl.validations[step.validation];
53843
53891
  if (val) {
53844
- if (val.executor_type === "agent") {
53892
+ if (val.executor_type === "agent" && val.executor) {
53845
53893
  addOp(agentOps, val.executor, "validate");
53846
- } else {
53894
+ } else if (val.executor) {
53847
53895
  addOp(toolOps, val.executor, "verification");
53848
53896
  }
53849
53897
  addOp(artifactOps, val.target_artifact, "V");