fix: 保留 Code Agent 最终回复全文
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { AgentRunError } from "./errors.js";
|
||||
import type { EventType, JsonRecord, RunEvent, TerminalStatus } from "./types.js";
|
||||
import { boundedTextSummary, commandOutputPayload } from "./output.js";
|
||||
import { redactJson } from "./redaction.js";
|
||||
import { redactJson, redactText } from "./redaction.js";
|
||||
|
||||
export const eventTypes = ["backend_status", "assistant_message", "tool_call", "command_output", "diff", "error", "terminal_status"] as const satisfies readonly EventType[];
|
||||
export const terminalStatuses = ["completed", "failed", "blocked", "cancelled"] as const satisfies readonly TerminalStatus[];
|
||||
@@ -70,10 +70,16 @@ function normalizeCommandOutputPayload(payload: JsonRecord): JsonRecord {
|
||||
}
|
||||
|
||||
function normalizeTextPayload(payload: JsonRecord): JsonRecord {
|
||||
const { text: _text, delta: _delta, content: _content, summary: _summary, ...rest } = payload;
|
||||
const { text: _text, delta: _delta, content: _content, summary: _summary, textBytes: _textBytes, textTruncated: _textTruncated, outputBytes: _outputBytes, outputTruncated: _outputTruncated, ...rest } = payload;
|
||||
const value = typeof payload.text === "string" ? payload.text : typeof payload.delta === "string" ? payload.delta : typeof payload.content === "string" ? payload.content : "";
|
||||
if (payload.replyAuthority === true || payload.final === true) {
|
||||
const text = redactText(value);
|
||||
const outputBytes = Buffer.byteLength(text, "utf8");
|
||||
const summary = { text, textChars: text.length, textBytes: outputBytes, outputBytes, textTruncated: false, outputTruncated: false } satisfies JsonRecord;
|
||||
return { ...rest, text, summary, textBytes: outputBytes, textTruncated: false, outputBytes, outputTruncated: false };
|
||||
}
|
||||
const summary = boundedTextSummary(value);
|
||||
return { ...rest, text: summary.text, summary, textBytes: summary.textBytes, textTruncated: summary.textTruncated };
|
||||
return { ...rest, text: summary.text, summary, textBytes: summary.textBytes, textTruncated: summary.textTruncated, outputBytes: summary.outputBytes, outputTruncated: summary.outputTruncated };
|
||||
}
|
||||
|
||||
function normalizeToolCallPayload(payload: JsonRecord): JsonRecord {
|
||||
|
||||
Reference in New Issue
Block a user