agent-contracts 0.11.4 → 0.11.5

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
@@ -198,6 +198,17 @@ declare const ComponentsSchema: z.ZodObject<{
198
198
  schemas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
199
199
  }, z.core.$loose>;
200
200
  type Components = z.infer<typeof ComponentsSchema>;
201
+ /**
202
+ * Declaration of project-specific `x-*` extension fields.
203
+ * Each key must start with `x-` and describes the expected type/shape
204
+ * so that tooling can validate custom extensions in the future.
205
+ */
206
+ declare const XExtensionDeclSchema: z.ZodObject<{
207
+ type: z.ZodString;
208
+ items: z.ZodOptional<z.ZodString>;
209
+ description: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strip>;
211
+ type XExtensionDecl = z.infer<typeof XExtensionDeclSchema>;
201
212
  declare const DslSchema: z.ZodObject<{
202
213
  version: z.ZodLiteral<1>;
203
214
  extends: z.ZodOptional<z.ZodString>;
@@ -390,7 +401,8 @@ declare const DslSchema: z.ZodObject<{
390
401
  }, z.core.$loose>, z.ZodObject<{
391
402
  type: z.ZodLiteral<"decision">;
392
403
  description: z.ZodOptional<z.ZodString>;
393
- on: z.ZodString;
404
+ on: z.ZodOptional<z.ZodString>;
405
+ routing_key: z.ZodOptional<z.ZodString>;
394
406
  branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
395
407
  group: z.ZodOptional<z.ZodString>;
396
408
  }, z.core.$loose>], "type">>;
@@ -452,6 +464,11 @@ declare const DslSchema: z.ZodObject<{
452
464
  components: z.ZodDefault<z.ZodObject<{
453
465
  schemas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
454
466
  }, z.core.$loose>>;
467
+ "x-extensions": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
468
+ type: z.ZodString;
469
+ items: z.ZodOptional<z.ZodString>;
470
+ description: z.ZodOptional<z.ZodString>;
471
+ }, z.core.$strip>>>;
455
472
  }, z.core.$loose>;
456
473
  type Dsl = z.infer<typeof DslSchema>;
457
474
 
@@ -777,7 +794,8 @@ declare const WorkflowStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
777
794
  }, z.core.$loose>, z.ZodObject<{
778
795
  type: z.ZodLiteral<"decision">;
779
796
  description: z.ZodOptional<z.ZodString>;
780
- on: z.ZodString;
797
+ on: z.ZodOptional<z.ZodString>;
798
+ routing_key: z.ZodOptional<z.ZodString>;
781
799
  branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
782
800
  group: z.ZodOptional<z.ZodString>;
783
801
  }, z.core.$loose>], "type">;
@@ -822,7 +840,8 @@ declare const WorkflowSchema: z.ZodObject<{
822
840
  }, z.core.$loose>, z.ZodObject<{
823
841
  type: z.ZodLiteral<"decision">;
824
842
  description: z.ZodOptional<z.ZodString>;
825
- on: z.ZodString;
843
+ on: z.ZodOptional<z.ZodString>;
844
+ routing_key: z.ZodOptional<z.ZodString>;
826
845
  branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
827
846
  group: z.ZodOptional<z.ZodString>;
828
847
  }, z.core.$loose>], "type">>;
@@ -866,6 +885,15 @@ interface ResolveResult {
866
885
  }
867
886
  declare function resolve(projectDirOrFile: string): Promise<ResolveResult>;
868
887
 
888
+ /**
889
+ * Parse the resolved DSL through Zod to fill all schema-defined default
890
+ * values, then return the fully-expanded plain object.
891
+ *
892
+ * If parsing fails (e.g. the DSL has validation errors), the original
893
+ * data is returned unchanged so that `resolve` remains non-destructive.
894
+ */
895
+ declare function expandDefaults(data: Record<string, unknown>): Record<string, unknown>;
896
+
869
897
  interface DiagnosticMessage {
870
898
  path: string;
871
899
  message: string;
@@ -916,6 +944,8 @@ declare function lint(dsl: Dsl, rules?: LintRule[]): LintDiagnostic[];
916
944
  */
917
945
  declare function spectralLint(dslObject: Record<string, unknown>): Promise<LintDiagnostic[]>;
918
946
 
947
+ declare const yamlReservedKeySafetyRule: LintRule;
948
+
919
949
  declare const CONTEXT_TYPES: readonly ["agent", "task", "artifact", "tool", "validation", "handoff_type", "workflow", "policy", "guardrail", "guardrail_policy", "system"];
920
950
  declare const ContextTypeSchema: z.ZodEnum<{
921
951
  guardrail: "guardrail";
@@ -1229,4 +1259,4 @@ interface PathResolveResult {
1229
1259
  }
1230
1260
  declare function resolveBindingTargetPath(target: string, paths: Record<string, string>, bindingSoftware: string): PathResolveResult;
1231
1261
 
1232
- 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 Dsl, DslLoadError, DslSchema, 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 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, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, spectralLint, validateHandoffSchemas, validateSchema };
1262
+ 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 Dsl, DslLoadError, DslSchema, 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 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, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
package/dist/index.js CHANGED
@@ -50712,7 +50712,9 @@ var WorkflowValidationStepSchema = z11.object({
50712
50712
  var WorkflowDecisionStepSchema = z11.object({
50713
50713
  type: z11.literal("decision"),
50714
50714
  description: z11.string().optional(),
50715
- on: z11.string(),
50715
+ /** @deprecated Use `routing_key` instead. `on` is kept for backward compatibility. */
50716
+ on: z11.string().optional(),
50717
+ routing_key: z11.string().optional(),
50716
50718
  branches: z11.record(z11.string(), z11.array(z11.string())),
50717
50719
  group: z11.string().optional()
50718
50720
  }).passthrough();
@@ -50735,6 +50737,11 @@ var WorkflowSchema = z11.object({
50735
50737
  var ComponentsSchema = z12.object({
50736
50738
  schemas: z12.record(z12.string(), z12.record(z12.string(), z12.any())).default({})
50737
50739
  }).passthrough();
50740
+ var XExtensionDeclSchema = z12.object({
50741
+ type: z12.string(),
50742
+ items: z12.string().optional(),
50743
+ description: z12.string().optional()
50744
+ });
50738
50745
  var DslSchema = z12.object({
50739
50746
  version: z12.literal(1),
50740
50747
  extends: z12.string().optional(),
@@ -50749,7 +50756,8 @@ var DslSchema = z12.object({
50749
50756
  policies: z12.record(z12.string(), PolicySchema).default({}),
50750
50757
  guardrails: z12.record(z12.string(), GuardrailSchema).default({}),
50751
50758
  guardrail_policies: z12.record(z12.string(), GuardrailPolicySchema).default({}),
50752
- components: ComponentsSchema.default({ schemas: {} })
50759
+ components: ComponentsSchema.default({ schemas: {} }),
50760
+ "x-extensions": z12.record(z12.string(), XExtensionDeclSchema).optional()
50753
50761
  }).passthrough();
50754
50762
 
50755
50763
  // src/schema/json-schema-utils.ts
@@ -51422,6 +51430,13 @@ async function resolve3(projectDirOrFile) {
51422
51430
  };
51423
51431
  }
51424
51432
 
51433
+ // src/resolver/expand-defaults.ts
51434
+ function expandDefaults(data) {
51435
+ const result = DslSchema.safeParse(data);
51436
+ if (!result.success) return data;
51437
+ return JSON.parse(JSON.stringify(result.data));
51438
+ }
51439
+
51425
51440
  // src/validator/schema-validator.ts
51426
51441
  import { z as z14 } from "zod";
51427
51442
  function unwrap(schema) {
@@ -51484,6 +51499,47 @@ function checkCustomPropsRecursive(data, schema, path) {
51484
51499
  }
51485
51500
  return [];
51486
51501
  }
51502
+ function checkXExtensionsKeys(data) {
51503
+ const extensions = data["x-extensions"];
51504
+ if (typeof extensions !== "object" || extensions === null) return [];
51505
+ const diagnostics = [];
51506
+ for (const key of Object.keys(extensions)) {
51507
+ if (!key.startsWith("x-")) {
51508
+ diagnostics.push({
51509
+ path: `x-extensions.${key}`,
51510
+ message: `Extension key "${key}" must start with "x-" prefix.`,
51511
+ code: "x-extension-key-prefix"
51512
+ });
51513
+ }
51514
+ }
51515
+ return diagnostics;
51516
+ }
51517
+ function checkDecisionStepRoutingKey(data) {
51518
+ const workflow = data["workflow"];
51519
+ if (typeof workflow !== "object" || workflow === null) return [];
51520
+ const diagnostics = [];
51521
+ for (const [wfKey, wf] of Object.entries(
51522
+ workflow
51523
+ )) {
51524
+ if (typeof wf !== "object" || wf === null) continue;
51525
+ const steps = wf["steps"];
51526
+ if (!Array.isArray(steps)) continue;
51527
+ for (let i3 = 0; i3 < steps.length; i3++) {
51528
+ const step = steps[i3];
51529
+ if (typeof step !== "object" || step === null) continue;
51530
+ const s2 = step;
51531
+ if (s2["type"] !== "decision") continue;
51532
+ if (s2["routing_key"] === void 0 && s2["on"] === void 0) {
51533
+ diagnostics.push({
51534
+ path: `workflow.${wfKey}.steps[${i3}]`,
51535
+ message: 'Decision step requires "routing_key" (or deprecated "on"). Prefer "routing_key".',
51536
+ code: "decision-missing-routing-key"
51537
+ });
51538
+ }
51539
+ }
51540
+ }
51541
+ return diagnostics;
51542
+ }
51487
51543
  function validateSchema(data) {
51488
51544
  const result = DslSchema.safeParse(data);
51489
51545
  if (!result.success) {
@@ -51498,6 +51554,14 @@ function validateSchema(data) {
51498
51554
  if (customPropDiagnostics.length > 0) {
51499
51555
  return { success: false, diagnostics: customPropDiagnostics };
51500
51556
  }
51557
+ const decisionDiagnostics = checkDecisionStepRoutingKey(data);
51558
+ if (decisionDiagnostics.length > 0) {
51559
+ return { success: false, diagnostics: decisionDiagnostics };
51560
+ }
51561
+ const xExtDiagnostics = checkXExtensionsKeys(data);
51562
+ if (xExtDiagnostics.length > 0) {
51563
+ return { success: false, diagnostics: xExtDiagnostics };
51564
+ }
51501
51565
  return { success: true, data: result.data, diagnostics: [] };
51502
51566
  }
51503
51567
 
@@ -52174,6 +52238,51 @@ var guardrailPolicyCoverageRule = {
52174
52238
  }
52175
52239
  };
52176
52240
 
52241
+ // src/linter/rules/yaml-reserved-key-safety.ts
52242
+ var YAML_11_RESERVED_KEYS = /* @__PURE__ */ new Set([
52243
+ "on",
52244
+ "off",
52245
+ "yes",
52246
+ "no",
52247
+ "true",
52248
+ "false",
52249
+ "y",
52250
+ "n"
52251
+ ]);
52252
+ var yamlReservedKeySafetyRule = {
52253
+ id: "yaml-reserved-key-safety",
52254
+ description: "Warns when YAML 1.1 reserved words are used as field values in positions where they may be misinterpreted by non-1.2 parsers",
52255
+ run(dsl) {
52256
+ const diagnostics = [];
52257
+ for (const [wfKey, wf] of Object.entries(dsl.workflow)) {
52258
+ for (let i3 = 0; i3 < wf.steps.length; i3++) {
52259
+ const step = wf.steps[i3];
52260
+ if (step.type !== "decision") continue;
52261
+ if (step.on !== void 0 && step.routing_key === void 0) {
52262
+ diagnostics.push({
52263
+ ruleId: "yaml-reserved-key-safety",
52264
+ severity: "warning",
52265
+ path: `workflow.${wfKey}.steps[${i3}].on`,
52266
+ message: 'Field name "on" is a YAML 1.1 reserved word and may be interpreted as boolean true by some parsers. Use "routing_key" instead.'
52267
+ });
52268
+ }
52269
+ const branchKeys = Object.keys(step.branches);
52270
+ for (const key of branchKeys) {
52271
+ if (YAML_11_RESERVED_KEYS.has(key.toLowerCase())) {
52272
+ diagnostics.push({
52273
+ ruleId: "yaml-reserved-key-safety",
52274
+ severity: "warning",
52275
+ path: `workflow.${wfKey}.steps[${i3}].branches.${key}`,
52276
+ message: `Branch key "${key}" is a YAML 1.1 reserved word and may be interpreted as a boolean by some parsers. Consider quoting or renaming.`
52277
+ });
52278
+ }
52279
+ }
52280
+ }
52281
+ }
52282
+ return diagnostics;
52283
+ }
52284
+ };
52285
+
52177
52286
  // src/linter/linter.ts
52178
52287
  var builtinRules = [
52179
52288
  validationCoverageRule,
@@ -52182,7 +52291,8 @@ var builtinRules = [
52182
52291
  mergeIntegrityRule,
52183
52292
  artifactOwnershipRule,
52184
52293
  toolCommandsRule,
52185
- guardrailPolicyCoverageRule
52294
+ guardrailPolicyCoverageRule,
52295
+ yamlReservedKeySafetyRule
52186
52296
  ];
52187
52297
  function lint(dsl, rules = builtinRules) {
52188
52298
  const diagnostics = [];
@@ -54609,6 +54719,7 @@ export {
54609
54719
  VersionLiteralSchema,
54610
54720
  WorkflowSchema,
54611
54721
  WorkflowStepSchema,
54722
+ XExtensionDeclSchema,
54612
54723
  buildArtifactContext,
54613
54724
  buildGlobalContext,
54614
54725
  buildGuardrailContext,
@@ -54624,6 +54735,7 @@ export {
54624
54735
  builtinRules,
54625
54736
  checkDriftFromConfig,
54626
54737
  checkReferences,
54738
+ expandDefaults,
54627
54739
  generateGuardrails,
54628
54740
  lint,
54629
54741
  loadBindings,
@@ -54639,7 +54751,8 @@ export {
54639
54751
  resolveDslPath,
54640
54752
  spectralLint,
54641
54753
  validateHandoffSchemas,
54642
- validateSchema
54754
+ validateSchema,
54755
+ yamlReservedKeySafetyRule
54643
54756
  };
54644
54757
  /*! Bundled license information:
54645
54758