feat: 补齐 HWLAB 基线 AgentRun 执行元语
This commit is contained in:
@@ -7,6 +7,7 @@ import * as readline from "node:readline";
|
||||
import type { BackendEvent, BackendProfile, BackendTurnResult, FailureKind, JsonRecord, JsonValue, TerminalStatus } from "../common/types.js";
|
||||
import { redactJson, redactText } from "../common/redaction.js";
|
||||
import { backendProfileSpec } from "../common/backend-profiles.js";
|
||||
import { boundedTextSummary, commandOutputPayload } from "../common/output.js";
|
||||
|
||||
const codexProtocol = "codex-app-server-jsonrpc-stdio";
|
||||
const defaultCodexArgs = ["app-server", "--listen", "stdio://"];
|
||||
@@ -437,8 +438,8 @@ function normalizeCodexNotification(message: JsonRecord): { events: BackendEvent
|
||||
return { events: [{ type: "backend_status", payload: { phase: method, turnId } }], ...(turnId ? { turnId } : {}) };
|
||||
}
|
||||
if (method === "item/agentMessage/delta") return { events: [], assistantDelta: typeof params.delta === "string" ? params.delta : "" };
|
||||
if (method === "item/commandExecution/outputDelta") return { events: [{ type: "command_output", payload: { stream: "stdout", text: typeof params.delta === "string" ? params.delta : "" } }] };
|
||||
if (method === "item/started" || method === "item/completed") return { events: [{ type: "tool_call", payload: { method, item: redactJson(asRecordAt(params, "item")) } }] };
|
||||
if (method === "item/commandExecution/outputDelta") return { events: [{ type: "command_output", payload: commandOutputPayload("stdout", typeof params.delta === "string" ? params.delta : "") }] };
|
||||
if (method === "item/started" || method === "item/completed") return { events: [{ type: "tool_call", payload: toolCallPayload(method, asRecordAt(params, "item")) }] };
|
||||
if (method === "error") {
|
||||
const error = asRecordAt(params, "error");
|
||||
const messageText = typeof error.message === "string" ? error.message : "Codex app-server error";
|
||||
@@ -469,6 +470,13 @@ function terminalStatusFromValue(value: unknown): TerminalStatus {
|
||||
return "failed";
|
||||
}
|
||||
|
||||
function toolCallPayload(method: string, item: JsonRecord): JsonRecord {
|
||||
const redacted = redactJson(item);
|
||||
const summary = boundedTextSummary(JSON.stringify(redacted));
|
||||
if (summary.outputTruncated !== true) return { method, item: redacted, summary, outputBytes: summary.outputBytes, outputTruncated: false };
|
||||
return { method, itemPreview: summary.text, summary, outputBytes: summary.outputBytes, outputTruncated: true };
|
||||
}
|
||||
|
||||
function withOptionalModel(params: JsonRecord, model: string | undefined): JsonRecord {
|
||||
const value = typeof model === "string" ? model.trim() : "";
|
||||
if (!value) return params;
|
||||
|
||||
Reference in New Issue
Block a user