refactor(outbound): share tool payload extraction

This commit is contained in:
Peter Steinberger
2026-02-15 01:24:12 +00:00
parent 01247723c7
commit 6ec1f10df0
3 changed files with 27 additions and 48 deletions

View File

@@ -49,6 +49,7 @@ import {
import { executePollAction, executeSendAction } from "./outbound-send-service.js";
import { ensureOutboundSessionEntry, resolveOutboundSessionRoute } from "./outbound-session.js";
import { resolveChannelTarget, type ResolvedMessagingTarget } from "./target-resolver.js";
import { extractToolPayload } from "./tool-payload.js";
export type MessageActionRunnerGateway = {
url?: string;
@@ -156,30 +157,6 @@ export function getToolResult(
return "toolResult" in result ? result.toolResult : undefined;
}
function extractToolPayload(result: AgentToolResult<unknown>): unknown {
if (result.details !== undefined) {
return result.details;
}
const textBlock = Array.isArray(result.content)
? result.content.find(
(block) =>
block &&
typeof block === "object" &&
(block as { type?: unknown }).type === "text" &&
typeof (block as { text?: unknown }).text === "string",
)
: undefined;
const text = (textBlock as { text?: string } | undefined)?.text;
if (text) {
try {
return JSON.parse(text);
} catch {
return text;
}
}
return result.content ?? result;
}
function applyCrossContextMessageDecoration({
params,
message,