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> {
|
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);
|
await this.hookManager.fireInline("agent_begin", this);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await this.processEventCore(event);
|
const result = await this.processEventCore(event);
|
||||||
|
if (!isHookEvent) {
|
||||||
await this.hookManager.fireInline("agent_stop", this);
|
await this.hookManager.fireInline("agent_stop", this);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (!isHookEvent) {
|
||||||
await this.hookManager.fireInline("agent_stop", this);
|
await this.hookManager.fireInline("agent_stop", this);
|
||||||
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user