feat: forward tool/assistant events to agent bus
This commit is contained in:
@@ -161,6 +161,7 @@ type CommandReplyParams = {
|
||||
verboseLevel?: "off" | "on";
|
||||
onPartialReply?: (payload: ReplyPayload) => Promise<void> | void;
|
||||
runId?: string;
|
||||
onAgentEvent?: (evt: { stream: string; data: Record<string, unknown> }) => void;
|
||||
};
|
||||
|
||||
export type CommandReplyMeta = {
|
||||
@@ -596,6 +597,14 @@ export async function runCommandReply(
|
||||
args: ev.args,
|
||||
},
|
||||
});
|
||||
params.onAgentEvent?.({
|
||||
stream: "tool",
|
||||
data: {
|
||||
phase: "start",
|
||||
name: ev.toolName,
|
||||
toolCallId: ev.toolCallId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -620,6 +629,15 @@ export async function runCommandReply(
|
||||
meta,
|
||||
},
|
||||
});
|
||||
params.onAgentEvent?.({
|
||||
stream: "tool",
|
||||
data: {
|
||||
phase: "result",
|
||||
name: toolName,
|
||||
toolCallId,
|
||||
meta,
|
||||
},
|
||||
});
|
||||
|
||||
if (
|
||||
pendingToolName &&
|
||||
@@ -646,6 +664,13 @@ export async function runCommandReply(
|
||||
|
||||
if (ev.type === "message_end") {
|
||||
streamAssistantFinal(ev.message);
|
||||
const text = extractRpcAssistantText(line);
|
||||
if (text) {
|
||||
params.onAgentEvent?.({
|
||||
stream: "assistant",
|
||||
data: { text },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve existing partial reply hook when provided.
|
||||
|
||||
Reference in New Issue
Block a user