From bc6494395efa3723069aaa65f4294a2e4e79dae4 Mon Sep 17 00:00:00 2001 From: tanmay11k Date: Sun, 22 Feb 2026 00:45:03 -0500 Subject: [PATCH] Initial commit: Discord-Claude Gateway with event-driven agent runtime --- src/agent-runtime.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/agent-runtime.ts b/src/agent-runtime.ts index 6be4187..717decd 100644 --- a/src/agent-runtime.ts +++ b/src/agent-runtime.ts @@ -48,14 +48,24 @@ export class AgentRuntime { } async processEvent(event: Event): Promise { - 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 { const result = await this.processEventCore(event); - await this.hookManager.fireInline("agent_stop", this); + if (!isHookEvent) { + await this.hookManager.fireInline("agent_stop", this); + } return result; } catch (error) { - await this.hookManager.fireInline("agent_stop", this); + if (!isHookEvent) { + await this.hookManager.fireInline("agent_stop", this); + } throw error; } }