Initial commit: Discord-Claude Gateway with event-driven agent runtime
This commit is contained in:
@@ -48,14 +48,24 @@ export class AgentRuntime {
|
||||
}
|
||||
|
||||
async processEvent(event: Event): Promise<EventResult> {
|
||||
// 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 {
|
||||
const result = await this.processEventCore(event);
|
||||
if (!isHookEvent) {
|
||||
await this.hookManager.fireInline("agent_stop", this);
|
||||
}
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (!isHookEvent) {
|
||||
await this.hookManager.fireInline("agent_stop", this);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user