feat: Implement bootstrap hook for role instruction injection (#183)
Replaces the file-read-network pattern in dispatch.ts with an OpenClaw agent:bootstrap hook that injects role instructions at agent init time. Changes: - Add lib/bootstrap-hook.ts with hook registration, session key parsing, and role instruction loading (extracted from dispatch.ts) - Register agent:bootstrap hook in index.ts - Remove file I/O from dispatch.ts (no more fs/path imports) - Remove role instructions from task message body (now injected via system prompt as WORKER_INSTRUCTIONS.md) - Add 13 tests for session key parsing and instruction loading - Remove obsolete docs/poc-bootstrap-hook.ts The bootstrap hook intercepts DevClaw worker session startup, parses the session key to extract project name and role, loads the appropriate instructions from workspace, and injects them as a virtual bootstrap file that OpenClaw automatically includes in the agent's system prompt. This eliminates the security audit's potential-exfiltration warning since dispatch.ts no longer performs any file reads.
This commit is contained in:
6
index.ts
6
index.ts
@@ -12,6 +12,7 @@ import { createOnboardTool } from "./lib/tools/onboard.js";
|
||||
import { createAutoConfigureModelsTool } from "./lib/tools/autoconfigure-models.js";
|
||||
import { registerCli } from "./lib/cli.js";
|
||||
import { registerHeartbeatService } from "./lib/services/heartbeat.js";
|
||||
import { registerBootstrapHook } from "./lib/bootstrap-hook.js";
|
||||
import { initRunCommand } from "./lib/run-command.js";
|
||||
|
||||
const plugin = {
|
||||
@@ -119,8 +120,11 @@ const plugin = {
|
||||
// Services
|
||||
registerHeartbeatService(api);
|
||||
|
||||
// Bootstrap hook for worker instruction injection
|
||||
registerBootstrapHook(api);
|
||||
|
||||
api.logger.info(
|
||||
"DevClaw plugin registered (11 tools, 1 CLI command group, 1 service)",
|
||||
"DevClaw plugin registered (11 tools, 1 CLI command group, 1 service, 1 hook)",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user