agent-contracts-runtime 0.36.7 → 0.36.9
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 +8 -0
- package/cli-contract.yaml +76 -0
- package/dist/agent-runtime.bundle.mjs +520 -339
- package/dist/agent-runtime.bundle.mjs.map +4 -4
- package/dist/bound-resolver-K4UHLXN6.js +17 -0
- package/dist/bound-resolver-K4UHLXN6.js.map +1 -0
- package/dist/{chunk-DPJFPYJO.js → chunk-5UGCLWDM.js} +8 -429
- package/dist/chunk-5UGCLWDM.js.map +1 -0
- package/dist/chunk-D2QTXQB2.js +266 -0
- package/dist/chunk-D2QTXQB2.js.map +1 -0
- package/dist/chunk-MWZXU25C.js +171 -0
- package/dist/chunk-MWZXU25C.js.map +1 -0
- package/dist/{chunk-PEHJ3J5C.js → chunk-VOBS62OH.js} +17 -1
- package/dist/chunk-VOBS62OH.js.map +1 -0
- package/dist/cli/index.js +94 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/dsl-context-LACANPO4.js +13 -0
- package/dist/dsl-context-LACANPO4.js.map +1 -0
- package/dist/generator/index.d.ts +15 -0
- package/dist/generator/index.js +1 -1
- package/dist/index.js +17 -13
- package/docs/cli-reference.md +160 -0
- package/package.json +10 -3
- package/dist/chunk-DPJFPYJO.js.map +0 -1
- package/dist/chunk-PEHJ3J5C.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundResolver,
|
|
3
|
+
buildPerAgentGuardrails,
|
|
4
|
+
getEffectiveGuardrailIds,
|
|
5
|
+
getGuardrailRulesForAgent,
|
|
6
|
+
guardrailContextToRuleData
|
|
7
|
+
} from "./chunk-MWZXU25C.js";
|
|
8
|
+
import "./chunk-LTZA6QWC.js";
|
|
9
|
+
import "./chunk-D2QTXQB2.js";
|
|
10
|
+
export {
|
|
11
|
+
BoundResolver,
|
|
12
|
+
buildPerAgentGuardrails,
|
|
13
|
+
getEffectiveGuardrailIds,
|
|
14
|
+
getGuardrailRulesForAgent,
|
|
15
|
+
guardrailContextToRuleData
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=bound-resolver-K4UHLXN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundResolver,
|
|
3
|
+
getGuardrailRulesForAgent
|
|
4
|
+
} from "./chunk-MWZXU25C.js";
|
|
1
5
|
import {
|
|
2
6
|
createGuardrailHooksFromRules,
|
|
3
7
|
pluginRegistry
|
|
4
8
|
} from "./chunk-MGRZBGQL.js";
|
|
5
9
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
buildGuardrailRulesFromDsl,
|
|
11
|
+
loadDslContext
|
|
12
|
+
} from "./chunk-D2QTXQB2.js";
|
|
8
13
|
|
|
9
14
|
// src/lib/task-runner.ts
|
|
10
15
|
import { z } from "zod";
|
|
@@ -973,422 +978,6 @@ function emitStepEvent(options, workflowId, stepIndex, step, result) {
|
|
|
973
978
|
});
|
|
974
979
|
}
|
|
975
980
|
|
|
976
|
-
// src/lib/bound-resolver.ts
|
|
977
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
978
|
-
import YAML2 from "yaml";
|
|
979
|
-
|
|
980
|
-
// src/lib/dsl-context.ts
|
|
981
|
-
import { readFile } from "fs/promises";
|
|
982
|
-
import YAML from "yaml";
|
|
983
|
-
|
|
984
|
-
// src/lib/schema-converter.ts
|
|
985
|
-
import { z as z2 } from "zod";
|
|
986
|
-
function applyStringValidations(schema, def) {
|
|
987
|
-
let s = schema;
|
|
988
|
-
if (typeof def.minLength === "number") s = s.min(def.minLength);
|
|
989
|
-
if (typeof def.maxLength === "number") s = s.max(def.maxLength);
|
|
990
|
-
if (typeof def.pattern === "string") s = s.regex(new RegExp(def.pattern));
|
|
991
|
-
return s;
|
|
992
|
-
}
|
|
993
|
-
function applyNumberValidations(schema, def, isInteger) {
|
|
994
|
-
let n = schema;
|
|
995
|
-
if (isInteger) n = n.int();
|
|
996
|
-
if (typeof def.minimum === "number") n = n.min(def.minimum);
|
|
997
|
-
if (typeof def.maximum === "number") n = n.max(def.maximum);
|
|
998
|
-
return n;
|
|
999
|
-
}
|
|
1000
|
-
function applyArrayValidations(schema, def) {
|
|
1001
|
-
let a = schema;
|
|
1002
|
-
if (typeof def.minItems === "number") a = a.min(def.minItems);
|
|
1003
|
-
if (typeof def.maxItems === "number") a = a.max(def.maxItems);
|
|
1004
|
-
return a;
|
|
1005
|
-
}
|
|
1006
|
-
function jsonSchemaToZod(schema) {
|
|
1007
|
-
if (!schema || typeof schema !== "object") return z2.unknown();
|
|
1008
|
-
if (schema.enum) {
|
|
1009
|
-
const vals = schema.enum;
|
|
1010
|
-
if (vals.length === 0) return z2.unknown();
|
|
1011
|
-
return z2.enum(vals);
|
|
1012
|
-
}
|
|
1013
|
-
if (schema.const !== void 0) {
|
|
1014
|
-
const val = schema.const;
|
|
1015
|
-
if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") {
|
|
1016
|
-
return z2.literal(val);
|
|
1017
|
-
}
|
|
1018
|
-
return z2.unknown();
|
|
1019
|
-
}
|
|
1020
|
-
const type = schema.type;
|
|
1021
|
-
if (type === "string") return applyStringValidations(z2.string(), schema);
|
|
1022
|
-
if (type === "integer") return applyNumberValidations(z2.number(), schema, true);
|
|
1023
|
-
if (type === "number") return applyNumberValidations(z2.number(), schema, false);
|
|
1024
|
-
if (type === "boolean") return z2.boolean();
|
|
1025
|
-
if (type === "array") {
|
|
1026
|
-
const items = schema.items;
|
|
1027
|
-
const inner = items ? jsonSchemaToZod(items) : z2.unknown();
|
|
1028
|
-
return applyArrayValidations(z2.array(inner), schema);
|
|
1029
|
-
}
|
|
1030
|
-
if (type === "object") {
|
|
1031
|
-
const props = schema.properties;
|
|
1032
|
-
if (!props) return z2.record(z2.string(), z2.unknown());
|
|
1033
|
-
const required = new Set(schema.required ?? []);
|
|
1034
|
-
const shape = {};
|
|
1035
|
-
for (const [key, val] of Object.entries(props)) {
|
|
1036
|
-
const fieldSchema = jsonSchemaToZod(val);
|
|
1037
|
-
shape[key] = required.has(key) ? fieldSchema : fieldSchema.optional();
|
|
1038
|
-
}
|
|
1039
|
-
return z2.object(shape).passthrough();
|
|
1040
|
-
}
|
|
1041
|
-
if (schema.allOf) {
|
|
1042
|
-
const parts = schema.allOf.map(jsonSchemaToZod);
|
|
1043
|
-
if (parts.length === 0) return z2.unknown();
|
|
1044
|
-
if (parts.length === 1) return parts[0];
|
|
1045
|
-
let merged = parts[0];
|
|
1046
|
-
for (let i = 1; i < parts.length; i++) {
|
|
1047
|
-
const part = parts[i];
|
|
1048
|
-
if (merged instanceof z2.ZodObject && part instanceof z2.ZodObject) {
|
|
1049
|
-
merged = merged.merge(part);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
return merged;
|
|
1053
|
-
}
|
|
1054
|
-
return z2.unknown();
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
// src/lib/dsl-context.ts
|
|
1058
|
-
var DslValidationError = class extends Error {
|
|
1059
|
-
missing;
|
|
1060
|
-
constructor(missing) {
|
|
1061
|
-
super(
|
|
1062
|
-
"Required entities missing after DSL merge:\n" + missing.map((m) => ` - ${m}`).join("\n")
|
|
1063
|
-
);
|
|
1064
|
-
this.name = "DslValidationError";
|
|
1065
|
-
this.missing = missing;
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
function buildAgentRegistry(agents) {
|
|
1069
|
-
const registry = {};
|
|
1070
|
-
for (const [id, agent] of Object.entries(agents)) {
|
|
1071
|
-
const rawMode = agent.mode ?? "read-only";
|
|
1072
|
-
const mode = rawMode === "read-write" ? "read-write" : "read-only";
|
|
1073
|
-
registry[id] = {
|
|
1074
|
-
id,
|
|
1075
|
-
role_name: agent.role_name ?? id,
|
|
1076
|
-
purpose: agent.purpose ?? "",
|
|
1077
|
-
mode,
|
|
1078
|
-
responsibilities: agent.responsibilities ?? [],
|
|
1079
|
-
constraints: agent.constraints ?? [],
|
|
1080
|
-
rules: agent.rules ?? [],
|
|
1081
|
-
can_invoke_agents: agent.can_invoke_agents ?? void 0,
|
|
1082
|
-
can_execute_tools: agent.can_execute_tools ?? void 0
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
return registry;
|
|
1086
|
-
}
|
|
1087
|
-
function buildTaskRegistry(tasks) {
|
|
1088
|
-
const registry = {};
|
|
1089
|
-
for (const [id, task] of Object.entries(tasks)) {
|
|
1090
|
-
registry[id] = {
|
|
1091
|
-
id,
|
|
1092
|
-
description: task.description ?? "",
|
|
1093
|
-
target_agent: task.target_agent ?? "",
|
|
1094
|
-
result_handoff: task.result_handoff ?? "",
|
|
1095
|
-
completion_criteria: task.completion_criteria ?? [],
|
|
1096
|
-
model_class: task.model_class
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
return registry;
|
|
1100
|
-
}
|
|
1101
|
-
function buildWorkflowStep(step) {
|
|
1102
|
-
if (step.type === "gate") {
|
|
1103
|
-
return {
|
|
1104
|
-
type: "gate",
|
|
1105
|
-
gate_kind: step.gate_kind ?? "",
|
|
1106
|
-
description: step.description ?? "",
|
|
1107
|
-
depends_on: step.depends_on
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
return {
|
|
1111
|
-
type: "delegate",
|
|
1112
|
-
task: step.task ?? "",
|
|
1113
|
-
from_agent: step.from_agent ?? "",
|
|
1114
|
-
description: step.description ?? "",
|
|
1115
|
-
optional: step.optional ?? false,
|
|
1116
|
-
max_retries: step.max_retries ?? 0,
|
|
1117
|
-
max_follow_ups: step.max_follow_ups,
|
|
1118
|
-
depends_on: step.depends_on,
|
|
1119
|
-
retry: step.retry
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
function buildWorkflowRegistry(workflows) {
|
|
1123
|
-
const registry = {};
|
|
1124
|
-
for (const [id, wf] of Object.entries(workflows)) {
|
|
1125
|
-
const steps = (wf.steps ?? []).map(buildWorkflowStep);
|
|
1126
|
-
registry[id] = { id, description: wf.description ?? "", steps };
|
|
1127
|
-
}
|
|
1128
|
-
return registry;
|
|
1129
|
-
}
|
|
1130
|
-
function buildHandoffSchemas(handoffTypes) {
|
|
1131
|
-
const schemas = {};
|
|
1132
|
-
for (const [id, ht] of Object.entries(handoffTypes)) {
|
|
1133
|
-
const schema = ht.schema;
|
|
1134
|
-
if (schema) {
|
|
1135
|
-
schemas[id] = jsonSchemaToZod(schema);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return schemas;
|
|
1139
|
-
}
|
|
1140
|
-
function buildGuardrailRulesFromDsl(dsl) {
|
|
1141
|
-
const raw = dsl._guardrailRules;
|
|
1142
|
-
if (!raw) return void 0;
|
|
1143
|
-
return {
|
|
1144
|
-
commandRules: raw.commandRules ?? [],
|
|
1145
|
-
fileRules: raw.fileRules ?? [],
|
|
1146
|
-
contentRules: raw.contentRules ?? []
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
function buildRegistriesFromDsl(dsl) {
|
|
1150
|
-
const agents = dsl.agents ?? {};
|
|
1151
|
-
const tasks = dsl.tasks ?? {};
|
|
1152
|
-
const workflows = dsl.workflow ?? {};
|
|
1153
|
-
const handoffTypes = dsl.handoff_types ?? {};
|
|
1154
|
-
return {
|
|
1155
|
-
agentRegistry: buildAgentRegistry(agents),
|
|
1156
|
-
taskRegistry: buildTaskRegistry(tasks),
|
|
1157
|
-
workflowRegistry: buildWorkflowRegistry(workflows),
|
|
1158
|
-
handoffSchemas: buildHandoffSchemas(handoffTypes)
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
function validateRequiredEntities(dsl, required) {
|
|
1162
|
-
const missing = [];
|
|
1163
|
-
const workflows = dsl.workflow ?? {};
|
|
1164
|
-
const tasks = dsl.tasks ?? {};
|
|
1165
|
-
const handoffTypes = dsl.handoff_types ?? {};
|
|
1166
|
-
if (required.workflows) {
|
|
1167
|
-
for (const wfId of required.workflows) {
|
|
1168
|
-
if (!(wfId in workflows)) {
|
|
1169
|
-
missing.push(`workflow "${wfId}" is required by the CLI but not found in the resolved DSL`);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
if (required.tasks) {
|
|
1174
|
-
for (const taskId of required.tasks) {
|
|
1175
|
-
if (!(taskId in tasks)) {
|
|
1176
|
-
missing.push(`task "${taskId}" is required by the CLI but not found in the resolved DSL`);
|
|
1177
|
-
continue;
|
|
1178
|
-
}
|
|
1179
|
-
const task = tasks[taskId];
|
|
1180
|
-
const invHandoff = task.invocation_handoff;
|
|
1181
|
-
const resHandoff = task.result_handoff;
|
|
1182
|
-
if (invHandoff && !(invHandoff in handoffTypes)) {
|
|
1183
|
-
missing.push(`handoff_type "${invHandoff}" (invocation_handoff of task "${taskId}") not found`);
|
|
1184
|
-
}
|
|
1185
|
-
if (resHandoff && !(resHandoff in handoffTypes)) {
|
|
1186
|
-
missing.push(`handoff_type "${resHandoff}" (result_handoff of task "${taskId}") not found`);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
if (required.workflows) {
|
|
1191
|
-
for (const wfId of required.workflows) {
|
|
1192
|
-
if (!(wfId in workflows)) continue;
|
|
1193
|
-
const wf = workflows[wfId];
|
|
1194
|
-
const steps = wf.steps ?? [];
|
|
1195
|
-
for (const step of steps) {
|
|
1196
|
-
if (step.type !== "delegate") continue;
|
|
1197
|
-
const taskId = step.task;
|
|
1198
|
-
if (taskId && taskId in tasks) {
|
|
1199
|
-
const task = tasks[taskId];
|
|
1200
|
-
const resHandoff = task.result_handoff;
|
|
1201
|
-
if (resHandoff && !(resHandoff in handoffTypes)) {
|
|
1202
|
-
missing.push(`handoff_type "${resHandoff}" (result of task "${taskId}" in workflow "${wfId}") not found`);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
if (missing.length > 0) {
|
|
1209
|
-
throw new DslValidationError(missing);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
async function loadDslContext(options) {
|
|
1213
|
-
let dsl;
|
|
1214
|
-
if (options.projectDslPath) {
|
|
1215
|
-
const { resolve: resolveDsl, mergeDsl, expandDefaults } = await import("agent-contracts");
|
|
1216
|
-
const raw = await readFile(options.projectDslPath, "utf8");
|
|
1217
|
-
const projectData = YAML.parse(raw);
|
|
1218
|
-
if (projectData.extends === "/$embedded/") {
|
|
1219
|
-
const { extends: _extends, ...projectOverrides } = projectData;
|
|
1220
|
-
const merged = mergeDsl(options.embeddedDsl, projectOverrides);
|
|
1221
|
-
dsl = expandDefaults(merged);
|
|
1222
|
-
} else {
|
|
1223
|
-
const projectResult = await resolveDsl(options.projectDslPath);
|
|
1224
|
-
const merged = mergeDsl(options.embeddedDsl, projectResult.data);
|
|
1225
|
-
dsl = expandDefaults(merged);
|
|
1226
|
-
}
|
|
1227
|
-
} else {
|
|
1228
|
-
dsl = options.embeddedDsl;
|
|
1229
|
-
}
|
|
1230
|
-
if (options.requiredEntities) {
|
|
1231
|
-
validateRequiredEntities(dsl, options.requiredEntities);
|
|
1232
|
-
}
|
|
1233
|
-
const registries = buildRegistriesFromDsl(dsl);
|
|
1234
|
-
const guardrailRules = buildGuardrailRulesFromDsl(dsl);
|
|
1235
|
-
return { registries, dsl, guardrailRules };
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// src/lib/bound-resolver.ts
|
|
1239
|
-
function getEffectiveGuardrailIds(dsl, agentId) {
|
|
1240
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1241
|
-
const agents = dsl.agents ?? {};
|
|
1242
|
-
const agent = agents[agentId];
|
|
1243
|
-
if (agent) {
|
|
1244
|
-
for (const ref of agent.guardrails ?? []) {
|
|
1245
|
-
ids.add(ref);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
const guardrails = dsl.guardrails ?? {};
|
|
1249
|
-
for (const [guardrailId, guardrail] of Object.entries(guardrails)) {
|
|
1250
|
-
if (guardrail.scope?.agents?.includes(agentId)) {
|
|
1251
|
-
ids.add(guardrailId);
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
return ids;
|
|
1255
|
-
}
|
|
1256
|
-
function guardrailCheckToCommandRule(c) {
|
|
1257
|
-
return {
|
|
1258
|
-
guardrail_id: c.guardrail_id,
|
|
1259
|
-
pattern: c.pattern,
|
|
1260
|
-
action: c.action,
|
|
1261
|
-
message: c.message
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
function guardrailCheckToFileRule(c) {
|
|
1265
|
-
return {
|
|
1266
|
-
guardrail_id: c.guardrail_id,
|
|
1267
|
-
pattern: c.pattern,
|
|
1268
|
-
action: c.action,
|
|
1269
|
-
message: c.message,
|
|
1270
|
-
...c.exclude_glob ? { exclude_glob: c.exclude_glob } : {}
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
function guardrailCheckToContentRule(c) {
|
|
1274
|
-
return {
|
|
1275
|
-
guardrail_id: c.guardrail_id,
|
|
1276
|
-
pattern: c.pattern,
|
|
1277
|
-
action: c.action,
|
|
1278
|
-
message: c.message,
|
|
1279
|
-
...c.file_glob ? { file_glob: c.file_glob } : {},
|
|
1280
|
-
...c.exclude_glob ? { exclude_glob: c.exclude_glob } : {}
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
function guardrailContextToRuleData(ctx, effectiveIds) {
|
|
1284
|
-
const filter = (checks) => effectiveIds ? checks.filter((c) => effectiveIds.has(c.guardrail_id)) : checks;
|
|
1285
|
-
return {
|
|
1286
|
-
commandRules: filter(ctx.commandChecks).map(guardrailCheckToCommandRule),
|
|
1287
|
-
fileRules: filter(ctx.fileChecks).map(guardrailCheckToFileRule),
|
|
1288
|
-
contentRules: filter(ctx.contentChecks).map(guardrailCheckToContentRule)
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
function buildPerAgentGuardrails(dsl, guardrailCtx) {
|
|
1292
|
-
const perAgent = /* @__PURE__ */ new Map();
|
|
1293
|
-
const agents = dsl.agents ?? {};
|
|
1294
|
-
for (const agentId of Object.keys(agents)) {
|
|
1295
|
-
const effectiveIds = getEffectiveGuardrailIds(dsl, agentId);
|
|
1296
|
-
const rules = guardrailContextToRuleData(guardrailCtx, effectiveIds);
|
|
1297
|
-
if (rules.commandRules.length > 0 || rules.fileRules.length > 0 || rules.contentRules.length > 0) {
|
|
1298
|
-
perAgent.set(agentId, rules);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
return perAgent;
|
|
1302
|
-
}
|
|
1303
|
-
function hasGuardrailRules(rules) {
|
|
1304
|
-
return rules.commandRules.length > 0 || rules.fileRules.length > 0 || rules.contentRules.length > 0;
|
|
1305
|
-
}
|
|
1306
|
-
var BoundResolver = class {
|
|
1307
|
-
cache = /* @__PURE__ */ new Map();
|
|
1308
|
-
/**
|
|
1309
|
-
* Resolve binding + policy in one pass. Results are cached by component id.
|
|
1310
|
-
*/
|
|
1311
|
-
async resolve(opts) {
|
|
1312
|
-
const cached = this.cache.get(opts.id);
|
|
1313
|
-
if (cached) return cached;
|
|
1314
|
-
const diagnostics = [];
|
|
1315
|
-
let dsl;
|
|
1316
|
-
if (opts.embeddedDsl) {
|
|
1317
|
-
dsl = opts.embeddedDsl;
|
|
1318
|
-
} else if (opts.dslPath) {
|
|
1319
|
-
const { resolve: resolveDsl } = await import("agent-contracts");
|
|
1320
|
-
const result = await resolveDsl(opts.dslPath);
|
|
1321
|
-
dsl = result.data;
|
|
1322
|
-
} else {
|
|
1323
|
-
throw new Error("BoundResolver.resolve requires embeddedDsl or dslPath");
|
|
1324
|
-
}
|
|
1325
|
-
if (opts.artifactBinding) {
|
|
1326
|
-
const { resolveBound } = await import("agent-contracts");
|
|
1327
|
-
const boundResult = await resolveBound(dsl, {
|
|
1328
|
-
artifactBinding: opts.artifactBinding,
|
|
1329
|
-
paths: opts.paths
|
|
1330
|
-
});
|
|
1331
|
-
dsl = boundResult.data;
|
|
1332
|
-
for (const d of boundResult.diagnostics) {
|
|
1333
|
-
diagnostics.push({
|
|
1334
|
-
path: d.rule,
|
|
1335
|
-
message: d.message,
|
|
1336
|
-
severity: d.severity
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
let guardrailCtx = {
|
|
1341
|
-
commandChecks: [],
|
|
1342
|
-
fileChecks: [],
|
|
1343
|
-
contentChecks: [],
|
|
1344
|
-
allChecks: [],
|
|
1345
|
-
hasGuardrails: false
|
|
1346
|
-
};
|
|
1347
|
-
if (opts.bindingPaths && opts.bindingPaths.length > 0) {
|
|
1348
|
-
for (const bindingPath of opts.bindingPaths) {
|
|
1349
|
-
const raw = await readFile2(bindingPath, "utf8");
|
|
1350
|
-
const binding = YAML2.parse(raw);
|
|
1351
|
-
guardrailCtx = buildGuardrailContext(
|
|
1352
|
-
dsl,
|
|
1353
|
-
binding,
|
|
1354
|
-
opts.activeGuardrailPolicy
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
const perAgent = guardrailCtx.hasGuardrails ? buildPerAgentGuardrails(dsl, guardrailCtx) : /* @__PURE__ */ new Map();
|
|
1359
|
-
const component = {
|
|
1360
|
-
id: opts.id,
|
|
1361
|
-
dsl,
|
|
1362
|
-
registries: buildRegistriesFromDsl(dsl),
|
|
1363
|
-
guardrails: { perAgent },
|
|
1364
|
-
diagnostics
|
|
1365
|
-
};
|
|
1366
|
-
this.cache.set(opts.id, component);
|
|
1367
|
-
return component;
|
|
1368
|
-
}
|
|
1369
|
-
/** Clear cached components (e.g. for testing). */
|
|
1370
|
-
clearCache() {
|
|
1371
|
-
this.cache.clear();
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
function getGuardrailRulesForAgent(component, agentId, fallbackDsl) {
|
|
1375
|
-
const perAgent = component.guardrails.perAgent.get(agentId);
|
|
1376
|
-
if (perAgent && hasGuardrailRules(perAgent)) {
|
|
1377
|
-
return perAgent;
|
|
1378
|
-
}
|
|
1379
|
-
if (fallbackDsl) {
|
|
1380
|
-
const raw = fallbackDsl._guardrailRules;
|
|
1381
|
-
if (raw) {
|
|
1382
|
-
return {
|
|
1383
|
-
commandRules: raw.commandRules ?? [],
|
|
1384
|
-
fileRules: raw.fileRules ?? [],
|
|
1385
|
-
contentRules: raw.contentRules ?? []
|
|
1386
|
-
};
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
return void 0;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
981
|
// src/lib/builder.ts
|
|
1393
982
|
function createRuntime(config) {
|
|
1394
983
|
return {
|
|
@@ -1802,16 +1391,6 @@ export {
|
|
|
1802
1391
|
runWorkflow,
|
|
1803
1392
|
buildGateEvaluationPrompt,
|
|
1804
1393
|
parseGateEvaluationResponse,
|
|
1805
|
-
jsonSchemaToZod,
|
|
1806
|
-
DslValidationError,
|
|
1807
|
-
buildGuardrailRulesFromDsl,
|
|
1808
|
-
buildRegistriesFromDsl,
|
|
1809
|
-
loadDslContext,
|
|
1810
|
-
getEffectiveGuardrailIds,
|
|
1811
|
-
guardrailContextToRuleData,
|
|
1812
|
-
buildPerAgentGuardrails,
|
|
1813
|
-
BoundResolver,
|
|
1814
|
-
getGuardrailRulesForAgent,
|
|
1815
1394
|
createRuntime,
|
|
1816
1395
|
WorkflowBuilder,
|
|
1817
1396
|
loadPluginsFromPaths,
|
|
@@ -1823,4 +1402,4 @@ export {
|
|
|
1823
1402
|
executeTask,
|
|
1824
1403
|
executeWorkflow
|
|
1825
1404
|
};
|
|
1826
|
-
//# sourceMappingURL=chunk-
|
|
1405
|
+
//# sourceMappingURL=chunk-5UGCLWDM.js.map
|