agent-contracts 0.12.3 → 0.12.4

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
@@ -1128,6 +1128,14 @@ interface EntityGuardrailEntry {
1128
1128
  severity?: string;
1129
1129
  action?: string;
1130
1130
  }
1131
+ interface EntityValidationEntry {
1132
+ validation_id: string;
1133
+ kind: string;
1134
+ target_artifact: string;
1135
+ executor_type: string;
1136
+ blocking: boolean;
1137
+ produces_evidence?: string;
1138
+ }
1131
1139
  interface PerTaskContext {
1132
1140
  task: Task & {
1133
1141
  id: string;
@@ -1136,6 +1144,7 @@ interface PerTaskContext {
1136
1144
  id: string;
1137
1145
  }) | null;
1138
1146
  relatedGuardrails: EntityGuardrailEntry[];
1147
+ relatedValidations: EntityValidationEntry[];
1139
1148
  dsl: Dsl;
1140
1149
  [key: string]: unknown;
1141
1150
  }
@@ -1161,6 +1170,7 @@ interface PerToolContext {
1161
1170
  inputArtifactDetails: Dsl["artifacts"];
1162
1171
  outputArtifactDetails: Dsl["artifacts"];
1163
1172
  relatedGuardrails: EntityGuardrailEntry[];
1173
+ relatedValidations: EntityValidationEntry[];
1164
1174
  dsl: Dsl;
1165
1175
  [key: string]: unknown;
1166
1176
  }
@@ -1252,6 +1262,7 @@ interface PerAgentContext {
1252
1262
  relatedHandoffTypes: Dsl["handoff_types"];
1253
1263
  mergedBehavior: MergedBehavioralSpec;
1254
1264
  relatedGuardrails: EntityGuardrailEntry[];
1265
+ relatedValidations: EntityValidationEntry[];
1255
1266
  dsl: Dsl;
1256
1267
  [key: string]: unknown;
1257
1268
  }
@@ -1262,6 +1273,11 @@ declare function buildSystemContext(dsl: Dsl, options?: {
1262
1273
  }): SystemContext;
1263
1274
  type EntityType = "agents" | "tasks" | "tools" | "artifacts";
1264
1275
  declare function resolveEffectiveGuardrails(dsl: Dsl, entityType: EntityType, entityId: string): EntityGuardrailEntry[];
1276
+ /**
1277
+ * Resolves validation IDs for an agent, task, or tool into full entries for prompts.
1278
+ * For tools, includes validations where executor_type is "tool" and executor is the tool id.
1279
+ */
1280
+ declare function resolveEntityValidations(dsl: Dsl, entityType: "agents" | "tasks" | "tools", entityId: string): EntityValidationEntry[];
1265
1281
  declare function buildTaskContext(dsl: Dsl, taskId: string): PerTaskContext;
1266
1282
  declare function buildArtifactContext(dsl: Dsl, artifactId: string): PerArtifactContext;
1267
1283
  declare function buildToolContext(dsl: Dsl, toolId: string): PerToolContext;
@@ -1353,4 +1369,4 @@ interface PathResolveResult {
1353
1369
  }
1354
1370
  declare function resolveBindingTargetPath(target: string, paths: Record<string, string>, bindingSoftware: string): PathResolveResult;
1355
1371
 
1356
- export { type Agent, type AgentContractsConfig, AgentContractsConfigSchema, AgentSchema, type AppendOperator, AppendOperatorSchema, type Artifact, ArtifactSchema, BaseResolveError, type BindingOutput, BindingOutputSchema, CONTEXT_TYPES, type Check, CheckSchema, type Command, CommandSchema, type Components, ComponentsSchema, ConfigLoadError, type ContextType, ContextTypeSchema, type DelegatableTaskView, type DiagnosticMessage, type DimensionResult, type Dsl, DslLoadError, DslSchema, type EntityGuardrailEntry, type EscalationCriterion, EscalationCriterionSchema, type ExecutionStep, ExecutionStepSchema, type Extends, ExtendsSchema, type ExternalParticipant, type GenerateDiagnostic, type GenerateGuardrailsOptions, type GenerateResult, type GlobalContext, type Guardrail, type GuardrailGenerationContext, type GuardrailPolicy, type GuardrailPolicyRule, type GuardrailPolicyRuleEscalation, GuardrailPolicyRuleEscalationSchema, GuardrailPolicyRuleSchema, GuardrailPolicySchema, GuardrailSchema, type GuardrailScope, GuardrailScopeSchema, type HandoffType, HandoffTypeSchema, type InsertAfterOperator, InsertAfterOperatorSchema, type LintDiagnostic, type LintRule, type LoadResult, type LoadedBinding, type Matcher, MatcherSchema, MergeError, type MergeableRecord, type MergedBehavioralSpec, type PathResolveResult, type PerAgentContext, type PerArtifactContext, type PerGuardrailContext, type PerGuardrailPolicyContext, type PerHandoffTypeContext, type PerPolicyContext, type PerTaskContext, type PerToolContext, type PerValidationContext, type PerWorkflowContext, type Policy, PolicySchema, type PolicyWhen, PolicyWhenSchema, type PrependOperator, PrependOperatorSchema, type Prerequisite, PrerequisiteSchema, type ReferenceDiagnostic, type RemoveOperator, RemoveOperatorSchema, type RenderTarget, RenderTargetSchema, type ReplaceOperator, ReplaceOperatorSchema, type Reporting, ReportingSchema, type ResolveChecksResult, type ResolveResult, type ResolvedCheck, type ResolvedConfig, type ResolvedRenderTarget, type Retry, type Rule, RuleSchema, type SchemaValidationResult, type ScoreResult, type Severity, type SoftwareBinding, SoftwareBindingSchema, type System, type SystemContext, SystemSchema, type Task, TaskSchema, type Tool, ToolSchema, type Validation, ValidationSchema, type VersionLiteral, VersionLiteralSchema, type Workflow, WorkflowSchema, type WorkflowStep, WorkflowStepSchema, type XExtensionDecl, XExtensionDeclSchema, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, expandDefaults, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, resolveEffectiveGuardrails, score, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
1372
+ export { type Agent, type AgentContractsConfig, AgentContractsConfigSchema, AgentSchema, type AppendOperator, AppendOperatorSchema, type Artifact, ArtifactSchema, BaseResolveError, type BindingOutput, BindingOutputSchema, CONTEXT_TYPES, type Check, CheckSchema, type Command, CommandSchema, type Components, ComponentsSchema, ConfigLoadError, type ContextType, ContextTypeSchema, type DelegatableTaskView, type DiagnosticMessage, type DimensionResult, type Dsl, DslLoadError, DslSchema, type EntityGuardrailEntry, type EntityValidationEntry, type EscalationCriterion, EscalationCriterionSchema, type ExecutionStep, ExecutionStepSchema, type Extends, ExtendsSchema, type ExternalParticipant, type GenerateDiagnostic, type GenerateGuardrailsOptions, type GenerateResult, type GlobalContext, type Guardrail, type GuardrailGenerationContext, type GuardrailPolicy, type GuardrailPolicyRule, type GuardrailPolicyRuleEscalation, GuardrailPolicyRuleEscalationSchema, GuardrailPolicyRuleSchema, GuardrailPolicySchema, GuardrailSchema, type GuardrailScope, GuardrailScopeSchema, type HandoffType, HandoffTypeSchema, type InsertAfterOperator, InsertAfterOperatorSchema, type LintDiagnostic, type LintRule, type LoadResult, type LoadedBinding, type Matcher, MatcherSchema, MergeError, type MergeableRecord, type MergedBehavioralSpec, type PathResolveResult, type PerAgentContext, type PerArtifactContext, type PerGuardrailContext, type PerGuardrailPolicyContext, type PerHandoffTypeContext, type PerPolicyContext, type PerTaskContext, type PerToolContext, type PerValidationContext, type PerWorkflowContext, type Policy, PolicySchema, type PolicyWhen, PolicyWhenSchema, type PrependOperator, PrependOperatorSchema, type Prerequisite, PrerequisiteSchema, type ReferenceDiagnostic, type RemoveOperator, RemoveOperatorSchema, type RenderTarget, RenderTargetSchema, type ReplaceOperator, ReplaceOperatorSchema, type Reporting, ReportingSchema, type ResolveChecksResult, type ResolveResult, type ResolvedCheck, type ResolvedConfig, type ResolvedRenderTarget, type Retry, type Rule, RuleSchema, type SchemaValidationResult, type ScoreResult, type Severity, type SoftwareBinding, SoftwareBindingSchema, type System, type SystemContext, SystemSchema, type Task, TaskSchema, type Tool, ToolSchema, type Validation, ValidationSchema, type VersionLiteral, VersionLiteralSchema, type Workflow, WorkflowSchema, type WorkflowStep, WorkflowStepSchema, type XExtensionDecl, XExtensionDeclSchema, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, expandDefaults, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, resolveEffectiveGuardrails, resolveEntityValidations, score, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
package/dist/index.js CHANGED
@@ -52597,6 +52597,40 @@ var guardrailOrphanedRule = {
52597
52597
  }
52598
52598
  };
52599
52599
 
52600
+ // src/linter/rules/validation-executor-no-context.ts
52601
+ var validationExecutorNoContextRule = {
52602
+ id: "validation-executor-no-context",
52603
+ description: "Validation executor is not wired so the validation appears in the executor's rendered context",
52604
+ run(dsl) {
52605
+ const diagnostics = [];
52606
+ for (const [validationId, val] of Object.entries(dsl.validations)) {
52607
+ if (val.executor_type === "agent") {
52608
+ const agent = dsl.agents[val.executor];
52609
+ if (!agent) continue;
52610
+ const allowed = new Set(agent.can_perform_validations ?? []);
52611
+ if (!allowed.has(validationId)) {
52612
+ diagnostics.push({
52613
+ ruleId: "validation-executor-no-context",
52614
+ severity: "warning",
52615
+ path: `agents.${val.executor}.can_perform_validations`,
52616
+ message: `Validation "${validationId}" is executed by agent "${val.executor}" but is not listed in can_perform_validations, so it will be missing from that agent's prompt context`
52617
+ });
52618
+ }
52619
+ } else if (val.executor_type === "tool") {
52620
+ if (!dsl.tools[val.executor]) {
52621
+ diagnostics.push({
52622
+ ruleId: "validation-executor-no-context",
52623
+ severity: "warning",
52624
+ path: `validations.${validationId}.executor`,
52625
+ message: `Validation "${validationId}" references tool executor "${val.executor}" which is not defined in tools`
52626
+ });
52627
+ }
52628
+ }
52629
+ }
52630
+ return diagnostics;
52631
+ }
52632
+ };
52633
+
52600
52634
  // src/linter/linter.ts
52601
52635
  var builtinRules = [
52602
52636
  validationCoverageRule,
@@ -52612,7 +52646,8 @@ var builtinRules = [
52612
52646
  semanticValidationPhaseCoverageRule,
52613
52647
  entityGuardrailUndefinedRule,
52614
52648
  entityNoGuardrailsRule,
52615
- guardrailOrphanedRule
52649
+ guardrailOrphanedRule,
52650
+ validationExecutorNoContextRule
52616
52651
  ];
52617
52652
  function lint(dsl, rules = builtinRules) {
52618
52653
  const diagnostics = [];
@@ -53368,13 +53403,54 @@ function resolveEffectiveGuardrails(dsl, entityType, entityId) {
53368
53403
  }
53369
53404
  return entries;
53370
53405
  }
53406
+ function validationToEntityEntry(validationId, validation) {
53407
+ return {
53408
+ validation_id: validationId,
53409
+ kind: validation.kind,
53410
+ target_artifact: validation.target_artifact,
53411
+ executor_type: validation.executor_type,
53412
+ blocking: validation.blocking,
53413
+ produces_evidence: validation.produces_evidence
53414
+ };
53415
+ }
53416
+ function resolveEntityValidations(dsl, entityType, entityId) {
53417
+ if (entityType === "agents") {
53418
+ const agent = dsl.agents[entityId];
53419
+ if (!agent) return [];
53420
+ const entries2 = [];
53421
+ for (const vid of agent.can_perform_validations ?? []) {
53422
+ const v2 = dsl.validations[vid];
53423
+ if (v2) entries2.push(validationToEntityEntry(vid, v2));
53424
+ }
53425
+ return entries2;
53426
+ }
53427
+ if (entityType === "tasks") {
53428
+ const task = dsl.tasks[entityId];
53429
+ if (!task) return [];
53430
+ const entries2 = [];
53431
+ for (const vid of task.validations ?? []) {
53432
+ const v2 = dsl.validations[vid];
53433
+ if (v2) entries2.push(validationToEntityEntry(vid, v2));
53434
+ }
53435
+ return entries2;
53436
+ }
53437
+ const entries = [];
53438
+ for (const [vid, v2] of Object.entries(dsl.validations)) {
53439
+ if (v2.executor_type === "tool" && v2.executor === entityId) {
53440
+ entries.push(validationToEntityEntry(vid, v2));
53441
+ }
53442
+ }
53443
+ entries.sort((a3, b3) => a3.validation_id.localeCompare(b3.validation_id));
53444
+ return entries;
53445
+ }
53371
53446
  function buildTaskContext(dsl, taskId) {
53372
53447
  const taskDef = dsl.tasks[taskId];
53373
53448
  const task = { ...taskDef, id: taskId };
53374
53449
  const agentDef = dsl.agents[taskDef.target_agent];
53375
53450
  const targetAgent = agentDef ? { ...agentDef, id: taskDef.target_agent } : null;
53376
53451
  const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tasks", taskId);
53377
- return { task, targetAgent, relatedGuardrails, dsl };
53452
+ const relatedValidations = resolveEntityValidations(dsl, "tasks", taskId);
53453
+ return { task, targetAgent, relatedGuardrails, relatedValidations, dsl };
53378
53454
  }
53379
53455
  function buildArtifactContext(dsl, artifactId) {
53380
53456
  const artifactDef = dsl.artifacts[artifactId];
@@ -53445,12 +53521,14 @@ function buildToolContext(dsl, toolId) {
53445
53521
  return result;
53446
53522
  };
53447
53523
  const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tools", toolId);
53524
+ const relatedValidations = resolveEntityValidations(dsl, "tools", toolId);
53448
53525
  return {
53449
53526
  tool,
53450
53527
  invokableAgents,
53451
53528
  inputArtifactDetails: pickArtifacts(toolDef.input_artifacts),
53452
53529
  outputArtifactDetails: pickArtifacts(toolDef.output_artifacts),
53453
53530
  relatedGuardrails,
53531
+ relatedValidations,
53454
53532
  dsl
53455
53533
  };
53456
53534
  }
@@ -53683,6 +53761,7 @@ function buildPerAgentContext(dsl, agent) {
53683
53761
  const rawReceivableTasks = receivableTasks.map(({ id: _id, ...rest }) => rest);
53684
53762
  const mergedBehavior = mergeBehavioralSpec(agent, rawReceivableTasks);
53685
53763
  const relatedGuardrails = resolveEffectiveGuardrails(dsl, "agents", agentId);
53764
+ const relatedValidations = resolveEntityValidations(dsl, "agents", agentId);
53686
53765
  return {
53687
53766
  agent,
53688
53767
  tasks: receivableTasks,
@@ -53693,6 +53772,7 @@ function buildPerAgentContext(dsl, agent) {
53693
53772
  relatedHandoffTypes,
53694
53773
  mergedBehavior,
53695
53774
  relatedGuardrails,
53775
+ relatedValidations,
53696
53776
  dsl
53697
53777
  };
53698
53778
  }
@@ -55623,6 +55703,7 @@ export {
55623
55703
  resolveChecks,
55624
55704
  resolveDslPath,
55625
55705
  resolveEffectiveGuardrails,
55706
+ resolveEntityValidations,
55626
55707
  score,
55627
55708
  spectralLint,
55628
55709
  validateHandoffSchemas,