23 lines
830 B
TypeScript
23 lines
830 B
TypeScript
// PoC probe extension: verify extension loading + tool_call block hook in headless mode.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const MARKER = path.join(process.cwd(), "probes", "ext-loaded.marker");
|
|
const BLOCKLOG = path.join(process.cwd(), "probes", "ext-blocked-calls.jsonl");
|
|
|
|
export default function (pi: any) {
|
|
pi.on("session_start", async (_event: any, _ctx: any) => {
|
|
fs.writeFileSync(MARKER, `session_start fired at ${new Date().toISOString()}\n`);
|
|
});
|
|
|
|
pi.on("tool_call", async (event: any, _ctx: any) => {
|
|
fs.appendFileSync(
|
|
BLOCKLOG,
|
|
JSON.stringify({ toolName: event.toolName, toolCallId: event.toolCallId, input: event.input }) + "\n",
|
|
);
|
|
if (event.toolName === "bash") {
|
|
return { block: true, reason: "bash disabled by PoC guard extension" };
|
|
}
|
|
});
|
|
}
|