feat(hooks): run boot.md on gateway startup
This commit is contained in:
@@ -47,6 +47,20 @@ Swaps injected `SOUL.md` content with `SOUL_EVIL.md` during a purge window or by
|
||||
clawdbot hooks enable soul-evil
|
||||
```
|
||||
|
||||
### 🚀 boot-md
|
||||
|
||||
Runs `BOOT.md` whenever the gateway starts (after channels start).
|
||||
|
||||
**Events**: `gateway:startup`
|
||||
**What it does**: Executes BOOT.md instructions via the agent runner.
|
||||
**Output**: Whatever the instructions request (for example, outbound messages).
|
||||
|
||||
**Enable**:
|
||||
|
||||
```bash
|
||||
clawdbot hooks enable boot-md
|
||||
```
|
||||
|
||||
## Hook Structure
|
||||
|
||||
Each hook is a directory containing:
|
||||
@@ -156,6 +170,7 @@ Currently supported events:
|
||||
- **command:reset**: `/reset` command
|
||||
- **command:stop**: `/stop` command
|
||||
- **agent:bootstrap**: Before workspace bootstrap files are injected
|
||||
- **gateway:startup**: Gateway startup (after channels start)
|
||||
|
||||
More event types coming soon (session lifecycle, agent errors, etc.).
|
||||
|
||||
@@ -165,7 +180,7 @@ Hook handlers receive an `InternalHookEvent` object:
|
||||
|
||||
```typescript
|
||||
interface InternalHookEvent {
|
||||
type: "command" | "session" | "agent";
|
||||
type: "command" | "session" | "agent" | "gateway";
|
||||
action: string; // e.g., 'new', 'reset', 'stop'
|
||||
sessionKey: string;
|
||||
context: Record<string, unknown>;
|
||||
|
||||
19
src/hooks/bundled/boot-md/HOOK.md
Normal file
19
src/hooks/bundled/boot-md/HOOK.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: boot-md
|
||||
description: "Run BOOT.md on gateway startup"
|
||||
homepage: https://docs.clawd.bot/hooks#boot-md
|
||||
metadata:
|
||||
{
|
||||
"clawdbot":
|
||||
{
|
||||
"emoji": "🚀",
|
||||
"events": ["gateway:startup"],
|
||||
"requires": { "config": ["workspace.dir"] },
|
||||
"install": [{ "id": "bundled", "kind": "bundled", "label": "Bundled with Clawdbot" }],
|
||||
},
|
||||
}
|
||||
---
|
||||
|
||||
# Boot Checklist Hook
|
||||
|
||||
Runs `BOOT.md` every time the gateway starts, if the file exists in the workspace.
|
||||
27
src/hooks/bundled/boot-md/handler.ts
Normal file
27
src/hooks/bundled/boot-md/handler.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { CliDeps } from "../../../cli/deps.js";
|
||||
import { createDefaultDeps } from "../../../cli/deps.js";
|
||||
import type { ClawdbotConfig } from "../../../config/config.js";
|
||||
import { runBootOnce } from "../../../gateway/boot.js";
|
||||
import type { HookHandler } from "../../hooks.js";
|
||||
|
||||
type BootHookContext = {
|
||||
cfg?: ClawdbotConfig;
|
||||
workspaceDir?: string;
|
||||
deps?: CliDeps;
|
||||
};
|
||||
|
||||
const runBootChecklist: HookHandler = async (event) => {
|
||||
if (event.type !== "gateway" || event.action !== "startup") {
|
||||
return;
|
||||
}
|
||||
|
||||
const context = (event.context ?? {}) as BootHookContext;
|
||||
if (!context.cfg || !context.workspaceDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deps = context.deps ?? createDefaultDeps();
|
||||
await runBootOnce({ cfg: context.cfg, deps, workspaceDir: context.workspaceDir });
|
||||
};
|
||||
|
||||
export default runBootChecklist;
|
||||
Reference in New Issue
Block a user