mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:19:35 +00:00
refactor: add hook guards and test helpers
This commit is contained in:
@@ -19,6 +19,12 @@ export type AgentBootstrapHookContext = {
|
||||
agentId?: string;
|
||||
};
|
||||
|
||||
export type AgentBootstrapHookEvent = InternalHookEvent & {
|
||||
type: "agent";
|
||||
action: "bootstrap";
|
||||
context: AgentBootstrapHookContext;
|
||||
};
|
||||
|
||||
export interface InternalHookEvent {
|
||||
/** The type of event (command, session, agent, etc.) */
|
||||
type: InternalHookEventType;
|
||||
@@ -159,3 +165,11 @@ export function createInternalHookEvent(
|
||||
messages: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function isAgentBootstrapEvent(event: InternalHookEvent): event is AgentBootstrapHookEvent {
|
||||
if (event.type !== "agent" || event.action !== "bootstrap") return false;
|
||||
const context = event.context as Partial<AgentBootstrapHookContext> | null;
|
||||
if (!context || typeof context !== "object") return false;
|
||||
if (typeof context.workspaceDir !== "string") return false;
|
||||
return Array.isArray(context.bootstrapFiles);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user