Skip to content

Commit d75613e

Browse files
committed
chore(deadcode): reuse tool result details reader
1 parent beb8897 commit d75613e

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/agents/embedded-agent-subscribe.handlers.tools.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { parseExecApprovalResultText } from "./exec-approval-result.js";
8080
import type { AgentEvent } from "./runtime/index.js";
8181
import { buildToolMutationState, isSameToolMutationAction } from "./tool-mutation.js";
8282
import { normalizeToolName } from "./tool-policy.js";
83+
import { readToolResultDetails } from "./tool-result-error.js";
8384

8485
type ExecApprovalReplyModule = typeof import("../infra/exec-approval-reply.js");
8586
type HookRunnerGlobalModule = typeof import("../plugins/hook-runner-global.js");
@@ -336,10 +337,6 @@ function emitAgentEventCallbackBestEffort(
336337
}
337338
}
338339

339-
function readToolResultDetailsRecord(result: unknown): Record<string, unknown> | undefined {
340-
return readRecordField(asOptionalObjectRecord(result)?.details);
341-
}
342-
343340
function applyCurrentMessageProvider(
344341
toolName: string,
345342
args: Record<string, unknown>,
@@ -357,29 +354,29 @@ function applyCurrentMessageProvider(
357354
}
358355

359356
function applyToolSendReceiptForExtraction(result: unknown, receiptResult: unknown): unknown {
360-
const toolSend = readToolResultDetailsRecord(receiptResult)?.toolSend;
357+
const toolSend = readToolResultDetails(receiptResult)?.toolSend;
361358
if (toolSend === undefined) {
362359
return result;
363360
}
364361
return {
365362
...readRecordField(result),
366363
details: {
367-
...readToolResultDetailsRecord(result),
364+
...readToolResultDetails(result),
368365
toolSend,
369366
},
370367
};
371368
}
372369

373370
function isAsyncStartedToolResult(result: unknown): boolean {
374-
const details = readToolResultDetailsRecord(result);
371+
const details = readToolResultDetails(result);
375372
return details?.async === true && details.status === "started";
376373
}
377374

378375
function readAsyncStartedTaskIds(result: unknown): {
379376
asyncTaskRunId?: string;
380377
asyncTaskId?: string;
381378
} {
382-
const details = readToolResultDetailsRecord(result);
379+
const details = readToolResultDetails(result);
383380
if (!details) {
384381
return {};
385382
}
@@ -393,7 +390,7 @@ function readAsyncStartedTaskIds(result: unknown): {
393390
}
394391

395392
function readExecToolDetails(result: unknown): ExecToolDetails | null {
396-
const details = readToolResultDetailsRecord(result);
393+
const details = readToolResultDetails(result);
397394
if (!details || typeof details.status !== "string") {
398395
return null;
399396
}
@@ -423,7 +420,7 @@ function capLiveExecResult(result: unknown): unknown {
423420
if (!result || typeof result !== "object" || Array.isArray(result)) {
424421
return result;
425422
}
426-
const details = readToolResultDetailsRecord(result);
423+
const details = readToolResultDetails(result);
427424
return {
428425
...(result as Record<string, unknown>),
429426
details: {
@@ -474,7 +471,7 @@ function shouldEmitLiveExecUpdate(ctx: ToolHandlerContext, toolCallId: string):
474471
}
475472

476473
function readApplyPatchSummary(result: unknown): ApplyPatchSummary | null {
477-
const details = readToolResultDetailsRecord(result);
474+
const details = readToolResultDetails(result);
478475
const summary =
479476
details?.summary && typeof details.summary === "object" && !Array.isArray(details.summary)
480477
? (details.summary as Record<string, unknown>)

0 commit comments

Comments
 (0)