agent-contracts 0.14.1 → 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/README.md +58 -0
- package/dist/cli.js +586 -73
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +79 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1142,7 +1142,7 @@ declare const RenderTargetSchema: z.ZodObject<{
|
|
|
1142
1142
|
}, z.core.$strip>;
|
|
1143
1143
|
type RenderTarget = z.infer<typeof RenderTargetSchema>;
|
|
1144
1144
|
declare const AgentContractsConfigSchema: z.ZodObject<{
|
|
1145
|
-
dsl: z.ZodString
|
|
1145
|
+
dsl: z.ZodOptional<z.ZodString>;
|
|
1146
1146
|
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1147
1147
|
renders: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1148
1148
|
template: z.ZodString;
|
|
@@ -1167,6 +1167,14 @@ declare const AgentContractsConfigSchema: z.ZodObject<{
|
|
|
1167
1167
|
bindings: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1168
1168
|
active_guardrail_policy: z.ZodOptional<z.ZodString>;
|
|
1169
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>>>;
|
|
1170
1178
|
}, z.core.$strip>;
|
|
1171
1179
|
type AgentContractsConfig = z.infer<typeof AgentContractsConfigSchema>;
|
|
1172
1180
|
interface ResolvedRenderTarget {
|
|
@@ -1177,6 +1185,14 @@ interface ResolvedRenderTarget {
|
|
|
1177
1185
|
exclude?: string[];
|
|
1178
1186
|
skip_empty?: boolean;
|
|
1179
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
|
+
}
|
|
1180
1196
|
interface ResolvedConfig {
|
|
1181
1197
|
dsl: string;
|
|
1182
1198
|
vars?: Record<string, string>;
|
|
@@ -1185,6 +1201,7 @@ interface ResolvedConfig {
|
|
|
1185
1201
|
bindings: string[];
|
|
1186
1202
|
activeGuardrailPolicy?: string;
|
|
1187
1203
|
paths?: Record<string, string>;
|
|
1204
|
+
teams?: Record<string, ResolvedTeamConfig>;
|
|
1188
1205
|
}
|
|
1189
1206
|
|
|
1190
1207
|
interface LoadedBinding {
|
package/dist/index.js
CHANGED
|
@@ -55415,13 +55415,51 @@ var RenderTargetSchema = z17.object({
|
|
|
55415
55415
|
},
|
|
55416
55416
|
{ message: "include/exclude cannot be used with context: system" }
|
|
55417
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
|
+
});
|
|
55418
55426
|
var AgentContractsConfigSchema = z17.object({
|
|
55419
|
-
dsl: z17.string(),
|
|
55427
|
+
dsl: z17.string().optional(),
|
|
55420
55428
|
vars: z17.record(z17.string(), z17.string()).optional(),
|
|
55421
55429
|
renders: z17.array(RenderTargetSchema).default([]),
|
|
55422
55430
|
bindings: z17.array(z17.string()).default([]),
|
|
55423
55431
|
active_guardrail_policy: z17.string().optional(),
|
|
55424
|
-
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
|
+
}
|
|
55425
55463
|
});
|
|
55426
55464
|
|
|
55427
55465
|
// src/config/loader.ts
|
|
@@ -55442,6 +55480,27 @@ async function fileExists2(filePath) {
|
|
|
55442
55480
|
return false;
|
|
55443
55481
|
}
|
|
55444
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
|
+
}
|
|
55445
55504
|
async function loadConfig(configPath) {
|
|
55446
55505
|
const isExplicit = configPath !== void 0;
|
|
55447
55506
|
const targetPath = resolve4(configPath ?? DEFAULT_CONFIG_NAME);
|
|
@@ -55484,14 +55543,27 @@ ${issues}`,
|
|
|
55484
55543
|
}
|
|
55485
55544
|
const configDir = dirname4(targetPath);
|
|
55486
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
|
+
}
|
|
55487
55563
|
return {
|
|
55488
55564
|
dsl: resolve4(configDir, config.dsl),
|
|
55489
55565
|
vars: config.vars,
|
|
55490
|
-
renders
|
|
55491
|
-
...r3,
|
|
55492
|
-
template: resolve4(configDir, r3.template),
|
|
55493
|
-
output: resolve4(configDir, r3.output)
|
|
55494
|
-
})),
|
|
55566
|
+
renders,
|
|
55495
55567
|
configDir,
|
|
55496
55568
|
bindings: (config.bindings ?? []).map((b3) => resolve4(configDir, b3)),
|
|
55497
55569
|
activeGuardrailPolicy: config.active_guardrail_policy,
|