refactor(agents): split tools + PI subscribe
This commit is contained in:
61
src/agents/pi-embedded-subscribe.handlers.ts
Normal file
61
src/agents/pi-embedded-subscribe.handlers.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
handleAgentEnd,
|
||||
handleAgentStart,
|
||||
handleAutoCompactionEnd,
|
||||
handleAutoCompactionStart,
|
||||
} from "./pi-embedded-subscribe.handlers.lifecycle.js";
|
||||
import {
|
||||
handleMessageEnd,
|
||||
handleMessageStart,
|
||||
handleMessageUpdate,
|
||||
} from "./pi-embedded-subscribe.handlers.messages.js";
|
||||
import {
|
||||
handleToolExecutionEnd,
|
||||
handleToolExecutionStart,
|
||||
handleToolExecutionUpdate,
|
||||
} from "./pi-embedded-subscribe.handlers.tools.js";
|
||||
import type {
|
||||
EmbeddedPiSubscribeContext,
|
||||
EmbeddedPiSubscribeEvent,
|
||||
} from "./pi-embedded-subscribe.handlers.types.js";
|
||||
|
||||
export function createEmbeddedPiSessionEventHandler(
|
||||
ctx: EmbeddedPiSubscribeContext,
|
||||
) {
|
||||
return (evt: EmbeddedPiSubscribeEvent) => {
|
||||
switch (evt.type) {
|
||||
case "message_start":
|
||||
handleMessageStart(ctx, evt as never);
|
||||
return;
|
||||
case "message_update":
|
||||
handleMessageUpdate(ctx, evt as never);
|
||||
return;
|
||||
case "message_end":
|
||||
handleMessageEnd(ctx, evt as never);
|
||||
return;
|
||||
case "tool_execution_start":
|
||||
handleToolExecutionStart(ctx, evt as never);
|
||||
return;
|
||||
case "tool_execution_update":
|
||||
handleToolExecutionUpdate(ctx, evt as never);
|
||||
return;
|
||||
case "tool_execution_end":
|
||||
handleToolExecutionEnd(ctx, evt as never);
|
||||
return;
|
||||
case "agent_start":
|
||||
handleAgentStart(ctx);
|
||||
return;
|
||||
case "auto_compaction_start":
|
||||
handleAutoCompactionStart(ctx);
|
||||
return;
|
||||
case "auto_compaction_end":
|
||||
handleAutoCompactionEnd(ctx, evt as never);
|
||||
return;
|
||||
case "agent_end":
|
||||
handleAgentEnd(ctx);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user