feat: emit tool outputs for full verbose
This commit is contained in:
@@ -12,8 +12,6 @@ import {
|
||||
} from "./pi-embedded-subscribe.tools.js";
|
||||
import { inferToolMetaFromArgs } from "./pi-embedded-utils.js";
|
||||
|
||||
const TOOL_OUTPUT_ALLOWLIST = new Set(["exec", "bash", "process"]);
|
||||
|
||||
function extendExecMeta(toolName: string, args: unknown, meta?: string): string | undefined {
|
||||
const normalized = toolName.trim().toLowerCase();
|
||||
if (normalized !== "exec" && normalized !== "bash") return meta;
|
||||
@@ -202,11 +200,7 @@ export function handleToolExecutionEnd(
|
||||
`embedded run tool end: runId=${ctx.params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||
);
|
||||
|
||||
if (
|
||||
ctx.params.onToolResult &&
|
||||
ctx.shouldEmitToolOutput() &&
|
||||
TOOL_OUTPUT_ALLOWLIST.has(toolName.trim().toLowerCase())
|
||||
) {
|
||||
if (ctx.params.onToolResult && ctx.shouldEmitToolOutput()) {
|
||||
const outputText = extractToolResultText(sanitizedResult);
|
||||
if (outputText) {
|
||||
ctx.emitToolOutput(toolName, meta, outputText);
|
||||
|
||||
@@ -178,5 +178,19 @@ describe("subscribeEmbeddedPiSession", () => {
|
||||
const output = onToolResult.mock.calls[1][0];
|
||||
expect(output.text).toContain("hello");
|
||||
expect(output.text).toContain("```txt");
|
||||
|
||||
handler?.({
|
||||
type: "tool_execution_end",
|
||||
toolName: "read",
|
||||
toolCallId: "tool-read-1",
|
||||
isError: false,
|
||||
result: { content: [{ type: "text", text: "file data" }] },
|
||||
});
|
||||
|
||||
await Promise.resolve();
|
||||
|
||||
expect(onToolResult).toHaveBeenCalledTimes(3);
|
||||
const readOutput = onToolResult.mock.calls[2][0];
|
||||
expect(readOutput.text).toContain("file data");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user