@aaac/runtime 0.0.1 → 0.1.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.
@@ -0,0 +1,321 @@
1
+ // src/lib/plugin.ts
2
+ var PluginRegistry = class {
3
+ plugins = [];
4
+ register(plugin) {
5
+ if (this.plugins.some((p) => p.id === plugin.id)) {
6
+ throw new Error(`Plugin "${plugin.id}" is already registered`);
7
+ }
8
+ this.plugins.push(plugin);
9
+ }
10
+ getAll() {
11
+ return this.plugins;
12
+ }
13
+ async runBeforeTask(taskId, context) {
14
+ let ctx = context;
15
+ for (const plugin of this.plugins) {
16
+ if (!plugin.beforeTask || ctx === null) continue;
17
+ ctx = await plugin.beforeTask(taskId, ctx);
18
+ }
19
+ return ctx;
20
+ }
21
+ async runAfterTask(taskId, outcome) {
22
+ let result = outcome;
23
+ for (const plugin of this.plugins) {
24
+ if (!plugin.afterTask) continue;
25
+ result = await plugin.afterTask(taskId, result);
26
+ }
27
+ return result;
28
+ }
29
+ applyContextEnhancers(taskId, context) {
30
+ let ctx = context;
31
+ for (const plugin of this.plugins) {
32
+ if (!plugin.contextEnhancer) continue;
33
+ ctx = plugin.contextEnhancer(taskId, ctx);
34
+ }
35
+ return ctx;
36
+ }
37
+ /**
38
+ * Try plugin promptBuilder hooks. Returns custom prompt if any plugin provides one,
39
+ * or null to use the default buildTaskPrompt.
40
+ */
41
+ applyPromptBuilder(args) {
42
+ for (const plugin of this.plugins) {
43
+ if (!plugin.promptBuilder) continue;
44
+ const result = plugin.promptBuilder(args);
45
+ if (result !== null) return result;
46
+ }
47
+ return null;
48
+ }
49
+ applyPromptEnhancers(taskId, prompt, context) {
50
+ let enhanced = prompt;
51
+ for (const plugin of this.plugins) {
52
+ if (!plugin.promptEnhancer) continue;
53
+ enhanced = plugin.promptEnhancer(taskId, enhanced, context);
54
+ }
55
+ return enhanced;
56
+ }
57
+ evaluateCommandGuardrails(command) {
58
+ const results = [];
59
+ for (const plugin of this.plugins) {
60
+ if (!plugin.customGuardrails?.evaluateCommand) continue;
61
+ results.push(...plugin.customGuardrails.evaluateCommand(command));
62
+ }
63
+ return results;
64
+ }
65
+ evaluateFilePathGuardrails(filePath) {
66
+ const results = [];
67
+ for (const plugin of this.plugins) {
68
+ if (!plugin.customGuardrails?.evaluateFilePath) continue;
69
+ results.push(...plugin.customGuardrails.evaluateFilePath(filePath));
70
+ }
71
+ return results;
72
+ }
73
+ evaluateFileContentGuardrails(filePath, content) {
74
+ const results = [];
75
+ for (const plugin of this.plugins) {
76
+ if (!plugin.customGuardrails?.evaluateFileContent) continue;
77
+ results.push(...plugin.customGuardrails.evaluateFileContent(filePath, content));
78
+ }
79
+ return results;
80
+ }
81
+ async runBeforeWorkflow(workflowId, userRequest) {
82
+ for (const plugin of this.plugins) {
83
+ if (!plugin.beforeWorkflow) continue;
84
+ await plugin.beforeWorkflow(workflowId, userRequest);
85
+ }
86
+ }
87
+ async runAfterWorkflow(workflowId, result) {
88
+ for (const plugin of this.plugins) {
89
+ if (!plugin.afterWorkflow) continue;
90
+ await plugin.afterWorkflow(workflowId, result);
91
+ }
92
+ }
93
+ };
94
+ var pluginRegistry = new PluginRegistry();
95
+
96
+ // src/lib/guardrail-hooks.ts
97
+ function globFragmentToRegex(fragment) {
98
+ let out = "";
99
+ for (const ch of fragment) {
100
+ if (ch === "*") out += "[^/]*";
101
+ else if (ch === "?") out += "[^/]";
102
+ else if (".+^$|()[]\\".includes(ch)) out += "\\" + ch;
103
+ else out += ch;
104
+ }
105
+ return out;
106
+ }
107
+ function matchGlob(pattern, path) {
108
+ let regex = "";
109
+ let i = 0;
110
+ while (i < pattern.length) {
111
+ if (pattern[i] === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
112
+ regex += "(?:.+/)?";
113
+ i += 3;
114
+ } else if (pattern[i] === "*" && pattern[i + 1] === "*") {
115
+ regex += ".*";
116
+ i += 2;
117
+ } else if (pattern[i] === "*") {
118
+ regex += "[^/]*";
119
+ i += 1;
120
+ } else if (pattern[i] === "?") {
121
+ regex += "[^/]";
122
+ i += 1;
123
+ } else if (pattern[i] === "{") {
124
+ const end = pattern.indexOf("}", i);
125
+ if (end !== -1) {
126
+ const alts = pattern.slice(i + 1, end).split(",").map(globFragmentToRegex);
127
+ regex += "(?:" + alts.join("|") + ")";
128
+ i = end + 1;
129
+ } else {
130
+ regex += "\\{";
131
+ i += 1;
132
+ }
133
+ } else if (".+^$|()[]\\".includes(pattern[i])) {
134
+ regex += "\\" + pattern[i];
135
+ i += 1;
136
+ } else {
137
+ regex += pattern[i];
138
+ i += 1;
139
+ }
140
+ }
141
+ return new RegExp("^" + regex + "$").test(path);
142
+ }
143
+ function getBlockingViolations(results) {
144
+ return results.filter((r) => !r.passed && r.action === "block");
145
+ }
146
+ function getWarnings(results) {
147
+ return results.filter((r) => !r.passed && r.action === "warn");
148
+ }
149
+ function hasBlockingViolation(results) {
150
+ return results.some((r) => !r.passed && r.action === "block");
151
+ }
152
+ function pluginResultToCheckResult(r) {
153
+ return {
154
+ guardrail_id: r.guardrail_id,
155
+ passed: !r.matched,
156
+ action: r.action,
157
+ message: r.matched ? r.message : ""
158
+ };
159
+ }
160
+ function createGuardrailHooks(checks) {
161
+ function runChecks(ctx) {
162
+ const results = [];
163
+ if (ctx.command) {
164
+ results.push(...checks.checkCommand(ctx.command));
165
+ results.push(
166
+ ...pluginRegistry.evaluateCommandGuardrails(ctx.command).map(pluginResultToCheckResult)
167
+ );
168
+ }
169
+ if (ctx.filePath) {
170
+ results.push(...checks.checkFilePath(ctx.filePath));
171
+ results.push(
172
+ ...pluginRegistry.evaluateFilePathGuardrails(ctx.filePath).map(pluginResultToCheckResult)
173
+ );
174
+ }
175
+ if (ctx.filePath && ctx.content) {
176
+ results.push(...checks.checkContent(ctx.filePath, ctx.content));
177
+ results.push(
178
+ ...pluginRegistry.evaluateFileContentGuardrails(ctx.filePath, ctx.content).map(pluginResultToCheckResult)
179
+ );
180
+ }
181
+ return results;
182
+ }
183
+ function beforeShellExecution(input) {
184
+ const command = input.command ?? "";
185
+ if (!command) return {};
186
+ const results = runChecks({ command });
187
+ const blocks = getBlockingViolations(results);
188
+ const warns = getWarnings(results);
189
+ if (blocks.length > 0) {
190
+ const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join("\n");
191
+ return { permission: "deny", user_message: msg, agent_message: msg };
192
+ }
193
+ if (warns.length > 0) {
194
+ return {
195
+ additionalContext: warns.map((r) => `[${r.guardrail_id}] ${r.message}`).join("\n")
196
+ };
197
+ }
198
+ return {};
199
+ }
200
+ function preToolUse(input) {
201
+ const filePath = input.tool_input?.file_path ?? input.tool_input?.path ?? "";
202
+ if (!filePath) return {};
203
+ const results = runChecks({ filePath });
204
+ const blocks = getBlockingViolations(results);
205
+ if (blocks.length > 0) {
206
+ const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join("\n");
207
+ return { permission: "deny", user_message: msg, agent_message: msg };
208
+ }
209
+ return {};
210
+ }
211
+ function afterFileEdit(input) {
212
+ const filePath = input.file_path ?? "";
213
+ const content = input.content ?? "";
214
+ if (!filePath) return {};
215
+ const results = runChecks({ filePath, content });
216
+ const blocks = getBlockingViolations(results);
217
+ if (blocks.length > 0) {
218
+ const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join("\n");
219
+ return { permission: "deny", user_message: msg, agent_message: msg };
220
+ }
221
+ return {};
222
+ }
223
+ return { beforeShellExecution, preToolUse, afterFileEdit, runChecks };
224
+ }
225
+ function createGuardrailHooksForAgent(agentId, perAgent) {
226
+ const rules = perAgent.get(agentId);
227
+ if (!rules) {
228
+ return createGuardrailHooks({
229
+ checkCommand: () => [],
230
+ checkFilePath: () => [],
231
+ checkContent: () => []
232
+ });
233
+ }
234
+ const hooks = createGuardrailHooksFromRules(rules);
235
+ const baseRunChecks = hooks.runChecks;
236
+ return {
237
+ ...hooks,
238
+ runChecks(ctx) {
239
+ return baseRunChecks({ ...ctx, agentId });
240
+ }
241
+ };
242
+ }
243
+ function createGuardrailHooksFromRules(rules) {
244
+ const commandChecks = rules.commandRules.map((rule) => ({
245
+ guardrail_id: rule.guardrail_id,
246
+ pattern: new RegExp(rule.pattern),
247
+ action: rule.action,
248
+ message: rule.message
249
+ }));
250
+ const fileChecks = rules.fileRules;
251
+ const contentChecks = rules.contentRules.map((rule) => ({
252
+ guardrail_id: rule.guardrail_id,
253
+ pattern: new RegExp(rule.pattern),
254
+ action: rule.action,
255
+ message: rule.message,
256
+ file_glob: rule.file_glob,
257
+ exclude_glob: rule.exclude_glob
258
+ }));
259
+ return createGuardrailHooks({
260
+ checkCommand(command) {
261
+ const results = [];
262
+ for (const check of commandChecks) {
263
+ const passed = !check.pattern.test(command);
264
+ results.push({
265
+ guardrail_id: check.guardrail_id,
266
+ passed,
267
+ action: check.action,
268
+ message: passed ? "" : check.message
269
+ });
270
+ }
271
+ return results;
272
+ },
273
+ checkFilePath(filePath) {
274
+ const results = [];
275
+ for (const check of fileChecks) {
276
+ if (check.exclude_glob && matchGlob(check.exclude_glob, filePath)) {
277
+ continue;
278
+ }
279
+ const matched = matchGlob(check.pattern, filePath);
280
+ results.push({
281
+ guardrail_id: check.guardrail_id,
282
+ passed: !matched,
283
+ action: check.action,
284
+ message: matched ? check.message : ""
285
+ });
286
+ }
287
+ return results;
288
+ },
289
+ checkContent(filePath, content) {
290
+ const results = [];
291
+ for (const check of contentChecks) {
292
+ if (check.file_glob && !matchGlob(check.file_glob, filePath)) {
293
+ continue;
294
+ }
295
+ if (check.exclude_glob && matchGlob(check.exclude_glob, filePath)) {
296
+ continue;
297
+ }
298
+ const matched = check.pattern.test(content);
299
+ results.push({
300
+ guardrail_id: check.guardrail_id,
301
+ passed: !matched,
302
+ action: check.action,
303
+ message: matched ? check.message : ""
304
+ });
305
+ }
306
+ return results;
307
+ }
308
+ });
309
+ }
310
+
311
+ export {
312
+ PluginRegistry,
313
+ pluginRegistry,
314
+ getBlockingViolations,
315
+ getWarnings,
316
+ hasBlockingViolation,
317
+ createGuardrailHooks,
318
+ createGuardrailHooksForAgent,
319
+ createGuardrailHooksFromRules
320
+ };
321
+ //# sourceMappingURL=chunk-MGRZBGQL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/plugin.ts","../src/lib/guardrail-hooks.ts"],"sourcesContent":["/**\n * Plugin Interface — extension points for user code injection\n */\n\nimport type { TaskContext, TaskOutcome, AgentContractLike, TaskContractLike, PromptBuilderOptions } from \"./task-runner.js\";\nimport type { WorkflowResult } from \"./workflow-runner.js\";\n\nexport interface GuardrailResult {\n matched: boolean;\n guardrail_id: string;\n severity: \"critical\" | \"mandatory\" | \"warning\" | \"info\";\n action: \"block\" | \"warn\" | \"shadow\" | \"info\";\n message: string;\n}\n\nexport interface PromptBuilderArgs {\n agent: AgentContractLike;\n task: TaskContractLike;\n context: TaskContext;\n options?: PromptBuilderOptions;\n}\n\nexport interface AgentPlugin {\n readonly id: string;\n beforeTask?(taskId: string, context: TaskContext): Promise<TaskContext | null>;\n afterTask?(taskId: string, outcome: TaskOutcome): Promise<TaskOutcome>;\n /**\n * Enrich the structured TaskContext before prompt generation.\n * Unlike beforeTask (which can skip a task by returning null),\n * this hook is purely for context augmentation.\n */\n contextEnhancer?(taskId: string, context: TaskContext): TaskContext;\n /**\n * Lightweight prompt post-processor. Applied after the prompt is built.\n * Use for appending instructions or modifying sections.\n */\n promptEnhancer?(taskId: string, prompt: string, context: TaskContext): string;\n /**\n * Full prompt builder override. If provided and returns a non-null string,\n * replaces the default buildTaskPrompt output entirely.\n * Receives the agent/task contracts and context so the plugin can build\n * a completely custom prompt.\n */\n promptBuilder?(args: PromptBuilderArgs): string | null;\n customGuardrails?: {\n evaluateCommand?(command: string): GuardrailResult[];\n evaluateFilePath?(filePath: string): GuardrailResult[];\n evaluateFileContent?(filePath: string, content: string): GuardrailResult[];\n };\n beforeWorkflow?(workflowId: string, userRequest: string): Promise<void>;\n afterWorkflow?(workflowId: string, result: WorkflowResult): Promise<void>;\n}\n\nexport class PluginRegistry {\n private plugins: AgentPlugin[] = [];\n\n register(plugin: AgentPlugin): void {\n if (this.plugins.some((p) => p.id === plugin.id)) {\n throw new Error(`Plugin \"${plugin.id}\" is already registered`);\n }\n this.plugins.push(plugin);\n }\n\n getAll(): readonly AgentPlugin[] {\n return this.plugins;\n }\n\n async runBeforeTask(taskId: string, context: TaskContext): Promise<TaskContext | null> {\n let ctx: TaskContext | null = context;\n for (const plugin of this.plugins) {\n if (!plugin.beforeTask || ctx === null) continue;\n ctx = await plugin.beforeTask(taskId, ctx);\n }\n return ctx;\n }\n\n async runAfterTask(taskId: string, outcome: TaskOutcome): Promise<TaskOutcome> {\n let result = outcome;\n for (const plugin of this.plugins) {\n if (!plugin.afterTask) continue;\n result = await plugin.afterTask(taskId, result);\n }\n return result;\n }\n\n applyContextEnhancers(taskId: string, context: TaskContext): TaskContext {\n let ctx = context;\n for (const plugin of this.plugins) {\n if (!plugin.contextEnhancer) continue;\n ctx = plugin.contextEnhancer(taskId, ctx);\n }\n return ctx;\n }\n\n /**\n * Try plugin promptBuilder hooks. Returns custom prompt if any plugin provides one,\n * or null to use the default buildTaskPrompt.\n */\n applyPromptBuilder(args: PromptBuilderArgs): string | null {\n for (const plugin of this.plugins) {\n if (!plugin.promptBuilder) continue;\n const result = plugin.promptBuilder(args);\n if (result !== null) return result;\n }\n return null;\n }\n\n applyPromptEnhancers(taskId: string, prompt: string, context: TaskContext): string {\n let enhanced = prompt;\n for (const plugin of this.plugins) {\n if (!plugin.promptEnhancer) continue;\n enhanced = plugin.promptEnhancer(taskId, enhanced, context);\n }\n return enhanced;\n }\n\n evaluateCommandGuardrails(command: string): GuardrailResult[] {\n const results: GuardrailResult[] = [];\n for (const plugin of this.plugins) {\n if (!plugin.customGuardrails?.evaluateCommand) continue;\n results.push(...plugin.customGuardrails.evaluateCommand(command));\n }\n return results;\n }\n\n evaluateFilePathGuardrails(filePath: string): GuardrailResult[] {\n const results: GuardrailResult[] = [];\n for (const plugin of this.plugins) {\n if (!plugin.customGuardrails?.evaluateFilePath) continue;\n results.push(...plugin.customGuardrails.evaluateFilePath(filePath));\n }\n return results;\n }\n\n evaluateFileContentGuardrails(filePath: string, content: string): GuardrailResult[] {\n const results: GuardrailResult[] = [];\n for (const plugin of this.plugins) {\n if (!plugin.customGuardrails?.evaluateFileContent) continue;\n results.push(...plugin.customGuardrails.evaluateFileContent(filePath, content));\n }\n return results;\n }\n\n async runBeforeWorkflow(workflowId: string, userRequest: string): Promise<void> {\n for (const plugin of this.plugins) {\n if (!plugin.beforeWorkflow) continue;\n await plugin.beforeWorkflow(workflowId, userRequest);\n }\n }\n\n async runAfterWorkflow(workflowId: string, result: WorkflowResult): Promise<void> {\n for (const plugin of this.plugins) {\n if (!plugin.afterWorkflow) continue;\n await plugin.afterWorkflow(workflowId, result);\n }\n }\n}\n\nexport const pluginRegistry = new PluginRegistry();\n","/**\n * SDK Guardrail Hook Bridge — generic adapter from guardrail check functions\n * + plugin guardrails to SDK-compatible hook responses.\n *\n * Embedded guardrail rules are converted via createGuardrailHooksFromRules(),\n * which delegates to createGuardrailHooks(). All hook logic lives here.\n */\n\nimport { pluginRegistry } from \"./plugin.js\";\n\nexport interface GuardrailCheckResult {\n guardrail_id: string;\n passed: boolean;\n action: \"block\" | \"warn\" | \"shadow\" | \"info\";\n message: string;\n}\n\nexport interface HookResponse {\n permission?: \"deny\";\n user_message?: string;\n agent_message?: string;\n additionalContext?: string;\n}\n\nexport interface GuardrailRule {\n guardrail_id: string;\n pattern: string;\n action: \"block\" | \"warn\" | \"shadow\" | \"info\";\n message: string;\n file_glob?: string;\n exclude_glob?: string;\n}\n\nexport interface GuardrailRuleData {\n commandRules: GuardrailRule[];\n fileRules: GuardrailRule[];\n contentRules: GuardrailRule[];\n}\n\nexport interface GuardrailCheckFunctions {\n checkCommand: (command: string) => GuardrailCheckResult[];\n checkFilePath: (filePath: string) => GuardrailCheckResult[];\n checkContent: (filePath: string, content: string) => GuardrailCheckResult[];\n}\n\nfunction globFragmentToRegex(fragment: string): string {\n let out = \"\";\n for (const ch of fragment) {\n if (ch === \"*\") out += \"[^/]*\";\n else if (ch === \"?\") out += \"[^/]\";\n else if (\".+^$|()[]\\\\\".includes(ch)) out += \"\\\\\" + ch;\n else out += ch;\n }\n return out;\n}\n\nexport function matchGlob(pattern: string, path: string): boolean {\n let regex = \"\";\n let i = 0;\n while (i < pattern.length) {\n if (pattern[i] === \"*\" && pattern[i + 1] === \"*\" && pattern[i + 2] === \"/\") {\n regex += \"(?:.+/)?\";\n i += 3;\n } else if (pattern[i] === \"*\" && pattern[i + 1] === \"*\") {\n regex += \".*\";\n i += 2;\n } else if (pattern[i] === \"*\") {\n regex += \"[^/]*\";\n i += 1;\n } else if (pattern[i] === \"?\") {\n regex += \"[^/]\";\n i += 1;\n } else if (pattern[i] === \"{\") {\n const end = pattern.indexOf(\"}\", i);\n if (end !== -1) {\n const alts = pattern.slice(i + 1, end).split(\",\").map(globFragmentToRegex);\n regex += \"(?:\" + alts.join(\"|\") + \")\";\n i = end + 1;\n } else {\n regex += \"\\\\{\";\n i += 1;\n }\n } else if (\".+^$|()[]\\\\\".includes(pattern[i])) {\n regex += \"\\\\\" + pattern[i];\n i += 1;\n } else {\n regex += pattern[i];\n i += 1;\n }\n }\n return new RegExp(\"^\" + regex + \"$\").test(path);\n}\n\nexport interface HookContext {\n /** Agent id for per-agent guardrail filtering. */\n agentId?: string;\n command?: string;\n filePath?: string;\n content?: string;\n}\n\nexport interface GuardrailHooks {\n beforeShellExecution: (input: { command?: string }) => HookResponse;\n preToolUse: (input: {\n tool_name?: string;\n tool_input?: { file_path?: string; path?: string };\n }) => HookResponse;\n afterFileEdit: (input: { file_path?: string; content?: string }) => HookResponse;\n runChecks: (ctx: HookContext) => GuardrailCheckResult[];\n}\n\nexport function getBlockingViolations(results: GuardrailCheckResult[]): GuardrailCheckResult[] {\n return results.filter((r) => !r.passed && r.action === \"block\");\n}\n\nexport function getWarnings(results: GuardrailCheckResult[]): GuardrailCheckResult[] {\n return results.filter((r) => !r.passed && r.action === \"warn\");\n}\n\nexport function hasBlockingViolation(results: GuardrailCheckResult[]): boolean {\n return results.some((r) => !r.passed && r.action === \"block\");\n}\n\nfunction pluginResultToCheckResult(r: {\n matched: boolean;\n guardrail_id: string;\n action: string;\n message: string;\n}): GuardrailCheckResult {\n return {\n guardrail_id: r.guardrail_id,\n passed: !r.matched,\n action: r.action as GuardrailCheckResult[\"action\"],\n message: r.matched ? r.message : \"\",\n };\n}\n\n/**\n * Create SDK hook functions from generated guardrail check functions.\n *\n * Merges DSL-generated checks with plugin-registered guardrails and\n * returns hook functions in the format expected by the Claude SDK,\n * plus a generic runChecks() for programmatic use.\n */\nexport function createGuardrailHooks(checks: GuardrailCheckFunctions): GuardrailHooks {\n function runChecks(ctx: HookContext): GuardrailCheckResult[] {\n const results: GuardrailCheckResult[] = [];\n\n if (ctx.command) {\n results.push(...checks.checkCommand(ctx.command));\n results.push(\n ...pluginRegistry.evaluateCommandGuardrails(ctx.command).map(pluginResultToCheckResult),\n );\n }\n\n if (ctx.filePath) {\n results.push(...checks.checkFilePath(ctx.filePath));\n results.push(\n ...pluginRegistry.evaluateFilePathGuardrails(ctx.filePath).map(pluginResultToCheckResult),\n );\n }\n\n if (ctx.filePath && ctx.content) {\n results.push(...checks.checkContent(ctx.filePath, ctx.content));\n results.push(\n ...pluginRegistry\n .evaluateFileContentGuardrails(ctx.filePath, ctx.content)\n .map(pluginResultToCheckResult),\n );\n }\n\n return results;\n }\n\n function beforeShellExecution(input: { command?: string }): HookResponse {\n const command = input.command ?? \"\";\n if (!command) return {};\n\n const results = runChecks({ command });\n const blocks = getBlockingViolations(results);\n const warns = getWarnings(results);\n\n if (blocks.length > 0) {\n const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join(\"\\n\");\n return { permission: \"deny\", user_message: msg, agent_message: msg };\n }\n\n if (warns.length > 0) {\n return {\n additionalContext: warns.map((r) => `[${r.guardrail_id}] ${r.message}`).join(\"\\n\"),\n };\n }\n\n return {};\n }\n\n function preToolUse(input: {\n tool_name?: string;\n tool_input?: { file_path?: string; path?: string };\n }): HookResponse {\n const filePath = input.tool_input?.file_path ?? input.tool_input?.path ?? \"\";\n if (!filePath) return {};\n\n const results = runChecks({ filePath });\n const blocks = getBlockingViolations(results);\n\n if (blocks.length > 0) {\n const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join(\"\\n\");\n return { permission: \"deny\", user_message: msg, agent_message: msg };\n }\n\n return {};\n }\n\n function afterFileEdit(input: { file_path?: string; content?: string }): HookResponse {\n const filePath = input.file_path ?? \"\";\n const content = input.content ?? \"\";\n if (!filePath) return {};\n\n const results = runChecks({ filePath, content });\n const blocks = getBlockingViolations(results);\n\n if (blocks.length > 0) {\n const msg = blocks.map((r) => `[${r.guardrail_id}] ${r.message}`).join(\"\\n\");\n return { permission: \"deny\", user_message: msg, agent_message: msg };\n }\n\n return {};\n }\n\n return { beforeShellExecution, preToolUse, afterFileEdit, runChecks };\n}\n\n/**\n * Create SDK hook functions from embedded guardrail rule data.\n */\n/**\n * Create SDK hooks scoped to a single agent from a per-agent guardrail map.\n * Returns empty-passing hooks when the agent has no rules in the map.\n */\nexport function createGuardrailHooksForAgent(\n agentId: string,\n perAgent: Map<string, GuardrailRuleData>,\n): GuardrailHooks {\n const rules = perAgent.get(agentId);\n if (!rules) {\n return createGuardrailHooks({\n checkCommand: () => [],\n checkFilePath: () => [],\n checkContent: () => [],\n });\n }\n const hooks = createGuardrailHooksFromRules(rules);\n const baseRunChecks = hooks.runChecks;\n return {\n ...hooks,\n runChecks(ctx: HookContext) {\n return baseRunChecks({ ...ctx, agentId });\n },\n };\n}\n\nexport function createGuardrailHooksFromRules(rules: GuardrailRuleData): GuardrailHooks {\n const commandChecks = rules.commandRules.map((rule) => ({\n guardrail_id: rule.guardrail_id,\n pattern: new RegExp(rule.pattern),\n action: rule.action,\n message: rule.message,\n }));\n\n const fileChecks = rules.fileRules;\n\n const contentChecks = rules.contentRules.map((rule) => ({\n guardrail_id: rule.guardrail_id,\n pattern: new RegExp(rule.pattern),\n action: rule.action,\n message: rule.message,\n file_glob: rule.file_glob,\n exclude_glob: rule.exclude_glob,\n }));\n\n return createGuardrailHooks({\n checkCommand(command: string): GuardrailCheckResult[] {\n const results: GuardrailCheckResult[] = [];\n for (const check of commandChecks) {\n const passed = !check.pattern.test(command);\n results.push({\n guardrail_id: check.guardrail_id,\n passed,\n action: check.action,\n message: passed ? \"\" : check.message,\n });\n }\n return results;\n },\n\n checkFilePath(filePath: string): GuardrailCheckResult[] {\n const results: GuardrailCheckResult[] = [];\n for (const check of fileChecks) {\n if (check.exclude_glob && matchGlob(check.exclude_glob, filePath)) {\n continue;\n }\n const matched = matchGlob(check.pattern, filePath);\n results.push({\n guardrail_id: check.guardrail_id,\n passed: !matched,\n action: check.action,\n message: matched ? check.message : \"\",\n });\n }\n return results;\n },\n\n checkContent(filePath: string, content: string): GuardrailCheckResult[] {\n const results: GuardrailCheckResult[] = [];\n for (const check of contentChecks) {\n if (check.file_glob && !matchGlob(check.file_glob, filePath)) {\n continue;\n }\n if (check.exclude_glob && matchGlob(check.exclude_glob, filePath)) {\n continue;\n }\n const matched = check.pattern.test(content);\n results.push({\n guardrail_id: check.guardrail_id,\n passed: !matched,\n action: check.action,\n message: matched ? check.message : \"\",\n });\n }\n return results;\n },\n });\n}\n"],"mappings":";AAqDO,IAAM,iBAAN,MAAqB;AAAA,EAClB,UAAyB,CAAC;AAAA,EAElC,SAAS,QAA2B;AAClC,QAAI,KAAK,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO,EAAE,GAAG;AAChD,YAAM,IAAI,MAAM,WAAW,OAAO,EAAE,yBAAyB;AAAA,IAC/D;AACA,SAAK,QAAQ,KAAK,MAAM;AAAA,EAC1B;AAAA,EAEA,SAAiC;AAC/B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,cAAc,QAAgB,SAAmD;AACrF,QAAI,MAA0B;AA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AM;AAAA,UACd,SAAS,UAAU,MAAM,UAAU;AAAA,QACrC,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT;AAAA,IAEA,aAAa,UAAkB,SAAyC;AACtE,YAAM,UAAkC,CAAC;AACzC,iBAAW,SAAS,eAAe;AACjC,YAAI,MAAM,aAAa,CAAC,UAAU,MAAM,WAAW,QAAQ,GAAG;AAC5D;AAAA,QACF;AACA,YAAI,MAAM,gBAAgB,UAAU,MAAM,cAAc,QAAQ,GAAG;AACjE;AAAA,QACF;AACA,cAAM,UAAU,MAAM,QAAQ,KAAK,OAAO;AAC1C,gBAAQ,KAAK;AAAA,UACX,cAAc,MAAM;AAAA,UACpB,QAAQ,CAAC;AAAA,UACT,QAAQ,MAAM;AAAA,UACd,SAAS,UAAU,MAAM,UAAU;AAAA,QACrC,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Build template contexts from resolved DSL data
3
+ */
4
+ interface AgentEntry {
5
+ id: string;
6
+ varName: string;
7
+ role_name: string;
8
+ purpose: string;
9
+ mode: string;
10
+ dispatch_only: boolean;
11
+ can_read_artifacts: string[];
12
+ can_write_artifacts: string[];
13
+ can_execute_tools: string[];
14
+ can_invoke_agents: string[];
15
+ can_return_handoffs: string[];
16
+ responsibilities: string[];
17
+ constraints: string[];
18
+ rules: Array<{
19
+ id: string;
20
+ description: string;
21
+ severity: string;
22
+ }>;
23
+ escalation_criteria: Array<{
24
+ condition: string;
25
+ action: string;
26
+ }>;
27
+ }
28
+ interface TaskEntry {
29
+ id: string;
30
+ varName: string;
31
+ description: string;
32
+ target_agent: string;
33
+ allowed_from_agents: string[];
34
+ workflow: string;
35
+ invocation_handoff: string;
36
+ result_handoff: string;
37
+ input_artifacts: string[];
38
+ responsibilities: string[];
39
+ completion_criteria: string[];
40
+ optional: boolean;
41
+ model_class?: string;
42
+ }
43
+ interface WorkflowStepEntry {
44
+ type: string;
45
+ task?: string;
46
+ from_agent?: string;
47
+ description?: string;
48
+ optional?: boolean;
49
+ max_retries?: number;
50
+ max_follow_ups?: number;
51
+ depends_on?: string[];
52
+ gate_kind?: string;
53
+ retry?: {
54
+ condition: string;
55
+ fix_task: string;
56
+ revalidate_task?: string;
57
+ };
58
+ }
59
+ interface WorkflowEntry {
60
+ id: string;
61
+ varName: string;
62
+ description: string;
63
+ trigger: string;
64
+ entry_conditions: string[];
65
+ steps: WorkflowStepEntry[];
66
+ }
67
+ interface HandoffEntry {
68
+ id: string;
69
+ varName: string;
70
+ pascalName: string;
71
+ schemaName: string;
72
+ description: string;
73
+ schema: Record<string, unknown>;
74
+ }
75
+ interface ContractContext {
76
+ agentEntries: AgentEntry[];
77
+ taskEntries: TaskEntry[];
78
+ workflowEntries: WorkflowEntry[];
79
+ handoffEntries: HandoffEntry[];
80
+ }
81
+ declare function buildContractContext(dsl: any): ContractContext;
82
+ interface GuardrailCheckEntry {
83
+ guardrail_id: string;
84
+ description: string;
85
+ severity: string;
86
+ action: string;
87
+ matcher_type: string;
88
+ pattern: string;
89
+ message: string;
90
+ file_glob?: string;
91
+ exclude_glob?: string;
92
+ }
93
+ interface GuardrailContext {
94
+ commandChecks: GuardrailCheckEntry[];
95
+ fileChecks: GuardrailCheckEntry[];
96
+ contentChecks: GuardrailCheckEntry[];
97
+ allChecks: GuardrailCheckEntry[];
98
+ hasGuardrails: boolean;
99
+ }
100
+ /**
101
+ * Build guardrail context from DSL guardrails, binding guardrail_impl, and active policy.
102
+ * Mirrors the agent-contracts resolveChecks pattern.
103
+ */
104
+ declare function buildGuardrailContext(dsl: any, binding: any, policyName?: string): GuardrailContext;
105
+
106
+ export { type GuardrailContext as G, buildGuardrailContext as a, buildContractContext as b };
@@ -0,0 +1,140 @@
1
+ import { z } from 'zod';
2
+ export { b as buildContractContext, a as buildGuardrailContext } from '../context-B_bekYiE.js';
3
+
4
+ /**
5
+ * Generator configuration — loads and validates agents.conf.yaml / agent-runtime.config.yaml
6
+ */
7
+
8
+ declare const DEFAULT_CONFIG_PATH = "./agents.conf.yaml";
9
+ declare const RuntimeConfigSchema: z.ZodObject<{
10
+ dsl: z.ZodDefault<z.ZodString>;
11
+ generated_dir: z.ZodDefault<z.ZodString>;
12
+ bindings: z.ZodDefault<z.ZodArray<z.ZodString>>;
13
+ active_guardrail_policy: z.ZodOptional<z.ZodString>;
14
+ templates_dir: z.ZodOptional<z.ZodString>;
15
+ plugins: z.ZodDefault<z.ZodArray<z.ZodString>>;
16
+ recovery: z.ZodDefault<z.ZodObject<{
17
+ max_follow_ups: z.ZodDefault<z.ZodNumber>;
18
+ max_retries: z.ZodDefault<z.ZodNumber>;
19
+ }, z.core.$strip>>;
20
+ model_mapping: z.ZodDefault<z.ZodObject<{
21
+ fast: z.ZodOptional<z.ZodObject<{
22
+ adapter: z.ZodString;
23
+ model: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>>;
25
+ standard: z.ZodOptional<z.ZodObject<{
26
+ adapter: z.ZodString;
27
+ model: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>>;
29
+ thinking: z.ZodOptional<z.ZodObject<{
30
+ adapter: z.ZodString;
31
+ model: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>;
33
+ }, z.core.$strip>>;
34
+ logging: z.ZodDefault<z.ZodObject<{
35
+ progress_log: z.ZodDefault<z.ZodObject<{
36
+ destination: z.ZodDefault<z.ZodEnum<{
37
+ file: "file";
38
+ stderr: "stderr";
39
+ both: "both";
40
+ none: "none";
41
+ }>>;
42
+ file: z.ZodOptional<z.ZodString>;
43
+ naming: z.ZodDefault<z.ZodEnum<{
44
+ single: "single";
45
+ "per-invocation": "per-invocation";
46
+ daily: "daily";
47
+ }>>;
48
+ }, z.core.$strip>>;
49
+ }, z.core.$strip>>;
50
+ }, z.core.$strip>;
51
+ type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
52
+ declare const ProjectConfigSchema: z.ZodObject<{
53
+ dsl: z.ZodOptional<z.ZodString>;
54
+ generated_dir: z.ZodOptional<z.ZodString>;
55
+ bindings: z.ZodOptional<z.ZodArray<z.ZodString>>;
56
+ active_guardrail_policy: z.ZodOptional<z.ZodString>;
57
+ templates_dir: z.ZodOptional<z.ZodString>;
58
+ plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ recovery: z.ZodDefault<z.ZodObject<{
60
+ max_follow_ups: z.ZodDefault<z.ZodNumber>;
61
+ max_retries: z.ZodDefault<z.ZodNumber>;
62
+ }, z.core.$strip>>;
63
+ model_mapping: z.ZodDefault<z.ZodObject<{
64
+ fast: z.ZodOptional<z.ZodObject<{
65
+ adapter: z.ZodString;
66
+ model: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strip>>;
68
+ standard: z.ZodOptional<z.ZodObject<{
69
+ adapter: z.ZodString;
70
+ model: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ thinking: z.ZodOptional<z.ZodObject<{
73
+ adapter: z.ZodString;
74
+ model: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>>;
77
+ logging: z.ZodDefault<z.ZodObject<{
78
+ progress_log: z.ZodDefault<z.ZodObject<{
79
+ destination: z.ZodDefault<z.ZodEnum<{
80
+ file: "file";
81
+ stderr: "stderr";
82
+ both: "both";
83
+ none: "none";
84
+ }>>;
85
+ file: z.ZodOptional<z.ZodString>;
86
+ naming: z.ZodDefault<z.ZodEnum<{
87
+ single: "single";
88
+ "per-invocation": "per-invocation";
89
+ daily: "daily";
90
+ }>>;
91
+ }, z.core.$strip>>;
92
+ }, z.core.$strip>>;
93
+ cli: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
94
+ dsl: z.ZodOptional<z.ZodString>;
95
+ generated_dir: z.ZodOptional<z.ZodString>;
96
+ plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
+ bindings: z.ZodOptional<z.ZodArray<z.ZodString>>;
98
+ }, z.core.$strict>>>;
99
+ }, z.core.$strip>;
100
+ type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
101
+ interface ResolvedProgressLog {
102
+ destination: "stderr" | "file" | "both" | "none";
103
+ file: string | undefined;
104
+ naming: "single" | "per-invocation" | "daily";
105
+ }
106
+ interface ResolvedConfig extends RuntimeConfig {
107
+ configDir: string;
108
+ dslPath: string;
109
+ generatedDir: string;
110
+ bindingPaths: string[];
111
+ templatesDir: string | undefined;
112
+ pluginPaths: string[];
113
+ resolvedLogging: {
114
+ progressLog: ResolvedProgressLog;
115
+ };
116
+ }
117
+ declare function loadConfig(configPath: string): Promise<ResolvedConfig>;
118
+ declare function loadProjectConfig(configPath: string, cliName?: string): Promise<ResolvedConfig>;
119
+
120
+ /**
121
+ * Generator — orchestrates DSL-to-TypeScript code generation
122
+ */
123
+ interface GenerateOptions {
124
+ clean?: boolean;
125
+ check?: boolean;
126
+ templates?: string;
127
+ configPath?: string;
128
+ }
129
+ interface GenerateResult {
130
+ files_generated: string[];
131
+ dsl_hash: string;
132
+ generation_input_hash: string;
133
+ cleaned: boolean;
134
+ check_mode: boolean;
135
+ has_differences: boolean;
136
+ }
137
+ declare function generate(options?: GenerateOptions): Promise<GenerateResult>;
138
+ declare function checkFreshness(configPath?: string): Promise<boolean>;
139
+
140
+ export { DEFAULT_CONFIG_PATH, type GenerateOptions, type GenerateResult, type ProjectConfig, ProjectConfigSchema, type ResolvedConfig, checkFreshness, generate, loadConfig, loadProjectConfig };