Initial commit: Discord-Claude Gateway with event-driven agent runtime

This commit is contained in:
2026-02-22 00:45:03 -05:00
parent bbcc9014f5
commit bc6494395e

View File

@@ -48,14 +48,24 @@ export class AgentRuntime {
} }
async processEvent(event: Event): Promise<EventResult> { async processEvent(event: Event): Promise<EventResult> {
await this.hookManager.fireInline("agent_begin", this); // Skip inline hooks for hook events to prevent infinite recursion
// (fireInline calls processEvent which would call fireInline again)
const isHookEvent = event.type === "hook";
if (!isHookEvent) {
await this.hookManager.fireInline("agent_begin", this);
}
try { try {
const result = await this.processEventCore(event); const result = await this.processEventCore(event);
await this.hookManager.fireInline("agent_stop", this); if (!isHookEvent) {
await this.hookManager.fireInline("agent_stop", this);
}
return result; return result;
} catch (error) { } catch (error) {
await this.hookManager.fireInline("agent_stop", this); if (!isHookEvent) {
await this.hookManager.fireInline("agent_stop", this);
}
throw error; throw error;
} }
} }