UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

29 lines (28 loc) • 1.59 kB
import { a as resolveAgentAssistantTurnId } from "./tool-execution-context-D0eUSg2-.mjs"; import { i as extractToolAuthoredSourceReplyPayload } from "./embedded-agent-messaging-extraction-C5OCu-VM.mjs"; //#region src/agents/embedded-agent-tool-authored-source-reply.ts /** * Reads the final reply a `canDeliverSourceReply` tool authored and keys it to its * tool call. The host delivers the payload and writes its transcript row after a * successful send, so nothing is persisted here. Callers must already have verified * the tool's capability, that the result is not an error, and that the call is a * direct model call rather than a nested program call. Returns undefined when the * result carries no deliverable reply. */ function captureToolAuthoredSourceReply(e) { const t = extractToolAuthoredSourceReplyPayload(e.result); if (!t) return; return { ...t, idempotencyKey: t.idempotencyKey ?? `${e.idempotencyScope}:tool-source-reply:${e.toolCallId}`, sourceReplyFinal: true, toolAuthored: true, toolAuthoredForToolCallId: e.toolCallId }; } /** Matches the final assistant for one input, never an attempt-wide presence flag. */ function isToolAuthoredSourceReplyForAssistant(e, t) { return e.toolAuthored === true && Boolean(t && t.stopReason !== "error" && t.stopReason !== "aborted" && (e.toolAuthoredForTurnId ? e.toolAuthoredForTurnId === resolveAgentAssistantTurnId(t) : t.content.some((t) => t.type === "toolCall" && t.id === e.toolAuthoredForToolCallId))); } //#endregion export { isToolAuthoredSourceReplyForAssistant as n, captureToolAuthoredSourceReply as t };