



























@@ -80,6 +80,7 @@ import { parseExecApprovalResultText } from "./exec-approval-result.js";
8080import type { AgentEvent } from "./runtime/index.js";
8181import { buildToolMutationState, isSameToolMutationAction } from "./tool-mutation.js";
8282import { normalizeToolName } from "./tool-policy.js";
83+import { readToolResultDetails } from "./tool-result-error.js";
83848485type ExecApprovalReplyModule = typeof import("../infra/exec-approval-reply.js");
8586type HookRunnerGlobalModule = typeof import("../plugins/hook-runner-global.js");
@@ -336,10 +337,6 @@ function emitAgentEventCallbackBestEffort(
336337}
337338}
338339339-function readToolResultDetailsRecord(result: unknown): Record<string, unknown> | undefined {
340-return readRecordField(asOptionalObjectRecord(result)?.details);
341-}
342-343340function applyCurrentMessageProvider(
344341toolName: string,
345342args: Record<string, unknown>,
@@ -357,29 +354,29 @@ function applyCurrentMessageProvider(
357354}
358355359356function applyToolSendReceiptForExtraction(result: unknown, receiptResult: unknown): unknown {
360-const toolSend = readToolResultDetailsRecord(receiptResult)?.toolSend;
357+const toolSend = readToolResultDetails(receiptResult)?.toolSend;
361358if (toolSend === undefined) {
362359return result;
363360}
364361return {
365362 ...readRecordField(result),
366363details: {
367- ...readToolResultDetailsRecord(result),
364+ ...readToolResultDetails(result),
368365 toolSend,
369366},
370367};
371368}
372369373370function isAsyncStartedToolResult(result: unknown): boolean {
374-const details = readToolResultDetailsRecord(result);
371+const details = readToolResultDetails(result);
375372return details?.async === true && details.status === "started";
376373}
377374378375function readAsyncStartedTaskIds(result: unknown): {
379376asyncTaskRunId?: string;
380377asyncTaskId?: string;
381378} {
382-const details = readToolResultDetailsRecord(result);
379+const details = readToolResultDetails(result);
383380if (!details) {
384381return {};
385382}
@@ -393,7 +390,7 @@ function readAsyncStartedTaskIds(result: unknown): {
393390}
394391395392function readExecToolDetails(result: unknown): ExecToolDetails | null {
396-const details = readToolResultDetailsRecord(result);
393+const details = readToolResultDetails(result);
397394if (!details || typeof details.status !== "string") {
398395return null;
399396}
@@ -423,7 +420,7 @@ function capLiveExecResult(result: unknown): unknown {
423420if (!result || typeof result !== "object" || Array.isArray(result)) {
424421return result;
425422}
426-const details = readToolResultDetailsRecord(result);
423+const details = readToolResultDetails(result);
427424return {
428425 ...(result as Record<string, unknown>),
429426details: {
@@ -474,7 +471,7 @@ function shouldEmitLiveExecUpdate(ctx: ToolHandlerContext, toolCallId: string):
474471}
475472476473function readApplyPatchSummary(result: unknown): ApplyPatchSummary | null {
477-const details = readToolResultDetailsRecord(result);
474+const details = readToolResultDetails(result);
478475const summary =
479476details?.summary && typeof details.summary === "object" && !Array.isArray(details.summary)
480477 ? (details.summary as Record<string, unknown>)
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。