feat: add bootstrap hook and soul-evil hook

This commit is contained in:
Peter Steinberger
2026-01-18 05:24:47 +00:00
parent 7e2d91f3b7
commit ad3c12a43a
15 changed files with 678 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
import type { ClawdbotConfig } from "../config/config.js";
import { createInternalHookEvent, triggerInternalHook } from "../hooks/internal-hooks.js";
import type { AgentBootstrapHookContext } from "../hooks/internal-hooks.js";
import { resolveAgentIdFromSessionKey } from "../routing/session-key.js";
import type { WorkspaceBootstrapFile } from "./workspace.js";
export async function applyBootstrapHookOverrides(params: {
files: WorkspaceBootstrapFile[];
workspaceDir: string;
config?: ClawdbotConfig;
sessionKey?: string;
sessionId?: string;
agentId?: string;
}): Promise<WorkspaceBootstrapFile[]> {
const sessionKey = params.sessionKey ?? params.sessionId ?? "unknown";
const agentId =
params.agentId ??
(params.sessionKey ? resolveAgentIdFromSessionKey(params.sessionKey) : undefined);
const context: AgentBootstrapHookContext = {
workspaceDir: params.workspaceDir,
bootstrapFiles: params.files,
cfg: params.config,
sessionKey: params.sessionKey,
sessionId: params.sessionId,
agentId,
};
const event = createInternalHookEvent("agent", "bootstrap", sessionKey, context);
await triggerInternalHook(event);
const updated = (event.context as AgentBootstrapHookContext).bootstrapFiles;
return Array.isArray(updated) ? updated : params.files;
}