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