agent-contracts 0.14.0 → 0.15.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
@@ -70,6 +70,10 @@ declare const AgentSchema: z.ZodObject<{
70
70
  wait_for_approval: "wait_for_approval";
71
71
  }>;
72
72
  }, z.core.$loose>>>;
73
+ sections: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
+ title: z.ZodString;
75
+ content: z.ZodString;
76
+ }, z.core.$strip>>>;
73
77
  prerequisites: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
78
  action: z.ZodEnum<{
75
79
  read: "read";
@@ -385,6 +389,10 @@ declare const DslSchema: z.ZodObject<{
385
389
  wait_for_approval: "wait_for_approval";
386
390
  }>;
387
391
  }, z.core.$loose>>>;
392
+ sections: z.ZodOptional<z.ZodArray<z.ZodObject<{
393
+ title: z.ZodString;
394
+ content: z.ZodString;
395
+ }, z.core.$strip>>>;
388
396
  prerequisites: z.ZodOptional<z.ZodArray<z.ZodObject<{
389
397
  action: z.ZodEnum<{
390
398
  read: "read";
@@ -1134,7 +1142,7 @@ declare const RenderTargetSchema: z.ZodObject<{
1134
1142
  }, z.core.$strip>;
1135
1143
  type RenderTarget = z.infer<typeof RenderTargetSchema>;
1136
1144
  declare const AgentContractsConfigSchema: z.ZodObject<{
1137
- dsl: z.ZodString;
1145
+ dsl: z.ZodOptional<z.ZodString>;
1138
1146
  vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1139
1147
  renders: z.ZodDefault<z.ZodArray<z.ZodObject<{
1140
1148
  template: z.ZodString;
@@ -1159,6 +1167,14 @@ declare const AgentContractsConfigSchema: z.ZodObject<{
1159
1167
  bindings: z.ZodDefault<z.ZodArray<z.ZodString>>;
1160
1168
  active_guardrail_policy: z.ZodOptional<z.ZodString>;
1161
1169
  paths: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1170
+ teams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1171
+ dsl: z.ZodOptional<z.ZodString>;
1172
+ bindings: z.ZodDefault<z.ZodArray<z.ZodString>>;
1173
+ vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1174
+ paths: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1175
+ active_guardrail_policy: z.ZodOptional<z.ZodString>;
1176
+ interface_output: z.ZodOptional<z.ZodString>;
1177
+ }, z.core.$strip>>>;
1162
1178
  }, z.core.$strip>;
1163
1179
  type AgentContractsConfig = z.infer<typeof AgentContractsConfigSchema>;
1164
1180
  interface ResolvedRenderTarget {
@@ -1169,6 +1185,14 @@ interface ResolvedRenderTarget {
1169
1185
  exclude?: string[];
1170
1186
  skip_empty?: boolean;
1171
1187
  }
1188
+ interface ResolvedTeamConfig {
1189
+ dsl: string;
1190
+ vars?: Record<string, string>;
1191
+ bindings: string[];
1192
+ activeGuardrailPolicy?: string;
1193
+ paths?: Record<string, string>;
1194
+ interfaceOutput?: string;
1195
+ }
1172
1196
  interface ResolvedConfig {
1173
1197
  dsl: string;
1174
1198
  vars?: Record<string, string>;
@@ -1177,6 +1201,7 @@ interface ResolvedConfig {
1177
1201
  bindings: string[];
1178
1202
  activeGuardrailPolicy?: string;
1179
1203
  paths?: Record<string, string>;
1204
+ teams?: Record<string, ResolvedTeamConfig>;
1180
1205
  }
1181
1206
 
1182
1207
  interface LoadedBinding {
package/dist/index.js CHANGED
@@ -50463,6 +50463,12 @@ var AgentSchema = z.object({
50463
50463
  rules: z.array(RuleSchema).optional(),
50464
50464
  anti_patterns: z.array(z.string()).optional(),
50465
50465
  escalation_criteria: z.array(EscalationCriterionSchema).optional(),
50466
+ sections: z.array(
50467
+ z.object({
50468
+ title: z.string(),
50469
+ content: z.string()
50470
+ })
50471
+ ).optional(),
50466
50472
  prerequisites: z.array(PrerequisiteSchema).optional(),
50467
50473
  guardrails: z.array(z.string()).optional()
50468
50474
  }).passthrough();
@@ -55409,13 +55415,51 @@ var RenderTargetSchema = z17.object({
55409
55415
  },
55410
55416
  { message: "include/exclude cannot be used with context: system" }
55411
55417
  );
55418
+ var TeamConfigSchema = z17.object({
55419
+ dsl: z17.string().optional(),
55420
+ bindings: z17.array(z17.string()).default([]),
55421
+ vars: z17.record(z17.string(), z17.string()).optional(),
55422
+ paths: z17.record(z17.string(), z17.string()).optional(),
55423
+ active_guardrail_policy: z17.string().optional(),
55424
+ interface_output: z17.string().optional()
55425
+ });
55412
55426
  var AgentContractsConfigSchema = z17.object({
55413
- dsl: z17.string(),
55427
+ dsl: z17.string().optional(),
55414
55428
  vars: z17.record(z17.string(), z17.string()).optional(),
55415
55429
  renders: z17.array(RenderTargetSchema).default([]),
55416
55430
  bindings: z17.array(z17.string()).default([]),
55417
55431
  active_guardrail_policy: z17.string().optional(),
55418
- paths: z17.record(z17.string(), z17.string()).optional()
55432
+ paths: z17.record(z17.string(), z17.string()).optional(),
55433
+ teams: z17.record(z17.string(), TeamConfigSchema).optional()
55434
+ }).superRefine((data, ctx) => {
55435
+ if (data.dsl !== void 0 && data.teams !== void 0) {
55436
+ ctx.addIssue({
55437
+ code: z17.ZodIssueCode.custom,
55438
+ message: "dsl and teams are mutually exclusive",
55439
+ path: ["teams"]
55440
+ });
55441
+ return;
55442
+ }
55443
+ if (data.dsl === void 0 && data.teams === void 0) {
55444
+ ctx.addIssue({
55445
+ code: z17.ZodIssueCode.custom,
55446
+ message: "Either dsl or teams must be specified",
55447
+ path: []
55448
+ });
55449
+ return;
55450
+ }
55451
+ if (data.teams) {
55452
+ for (const [key, team] of Object.entries(data.teams)) {
55453
+ if (key === "_defaults") continue;
55454
+ if (team.dsl === void 0) {
55455
+ ctx.addIssue({
55456
+ code: z17.ZodIssueCode.custom,
55457
+ message: `Team "${key}" must specify dsl`,
55458
+ path: ["teams", key, "dsl"]
55459
+ });
55460
+ }
55461
+ }
55462
+ }
55419
55463
  });
55420
55464
 
55421
55465
  // src/config/loader.ts
@@ -55436,6 +55480,27 @@ async function fileExists2(filePath) {
55436
55480
  return false;
55437
55481
  }
55438
55482
  }
55483
+ function resolveTeamConfigs(teams, configDir) {
55484
+ const defaults = teams._defaults;
55485
+ const result = {};
55486
+ for (const [key, team] of Object.entries(teams)) {
55487
+ if (key === "_defaults") continue;
55488
+ const mergedBindings = [...defaults?.bindings ?? [], ...team.bindings].map(
55489
+ (b3) => resolve4(configDir, b3)
55490
+ );
55491
+ const mergedVars = defaults?.vars || team.vars ? { ...defaults?.vars ?? {}, ...team.vars ?? {} } : void 0;
55492
+ const mergedPaths = defaults?.paths || team.paths ? { ...defaults?.paths ?? {}, ...team.paths ?? {} } : void 0;
55493
+ result[key] = {
55494
+ dsl: resolve4(configDir, team.dsl),
55495
+ bindings: mergedBindings,
55496
+ vars: mergedVars,
55497
+ activeGuardrailPolicy: team.active_guardrail_policy ?? defaults?.active_guardrail_policy,
55498
+ paths: mergedPaths,
55499
+ interfaceOutput: team.interface_output ? resolve4(configDir, team.interface_output) : void 0
55500
+ };
55501
+ }
55502
+ return result;
55503
+ }
55439
55504
  async function loadConfig(configPath) {
55440
55505
  const isExplicit = configPath !== void 0;
55441
55506
  const targetPath = resolve4(configPath ?? DEFAULT_CONFIG_NAME);
@@ -55478,14 +55543,27 @@ ${issues}`,
55478
55543
  }
55479
55544
  const configDir = dirname4(targetPath);
55480
55545
  const config = result.data;
55546
+ const renders = config.renders.map((r3) => ({
55547
+ ...r3,
55548
+ template: resolve4(configDir, r3.template),
55549
+ output: resolve4(configDir, r3.output)
55550
+ }));
55551
+ if (config.teams) {
55552
+ return {
55553
+ dsl: "",
55554
+ vars: void 0,
55555
+ renders,
55556
+ configDir,
55557
+ bindings: [],
55558
+ activeGuardrailPolicy: void 0,
55559
+ paths: void 0,
55560
+ teams: resolveTeamConfigs(config.teams, configDir)
55561
+ };
55562
+ }
55481
55563
  return {
55482
55564
  dsl: resolve4(configDir, config.dsl),
55483
55565
  vars: config.vars,
55484
- renders: config.renders.map((r3) => ({
55485
- ...r3,
55486
- template: resolve4(configDir, r3.template),
55487
- output: resolve4(configDir, r3.output)
55488
- })),
55566
+ renders,
55489
55567
  configDir,
55490
55568
  bindings: (config.bindings ?? []).map((b3) => resolve4(configDir, b3)),
55491
55569
  activeGuardrailPolicy: config.active_guardrail_policy,