import { AIMessage } from '@langchain/core/messages'; /** * A sane default cap on a single repaired call's serialized payload. A text blob larger than this * is never treated as a tool call. Overridable per call so a test can assert the cap with a small * value; production leaves it at the default. The single source of truth lives in `./payload.js` * and is re-exported here under its public name (EXT-43 unified the former duplicated literal). */ export { MAX_TEXT_EMITTED_TOOL_CALL_PAYLOAD_BYTES } from './payload.js'; /** LangChain native tool-call shape (structurally a `ToolCall` from `@langchain/core/messages`). */ type NativeToolCall = { id: string; name: string; args: Record; type: 'tool_call'; }; /** Gates for {@link textToNativeToolCalls} / {@link promoteTextEmittedToolCallMessage}. */ export interface TextToolCallRepairOptions { /** * The names of the tools bound to this run (the allow-list). Only a text-emitted call whose name * is one of these promotes; an unknown name is left as text. An EMPTY set promotes nothing — the * prose-safe default (no toolset ⇒ nothing is a call). */ allowedToolNames: Iterable; /** Payload-size cap; defaults to {@link MAX_TEXT_EMITTED_TOOL_CALL_PAYLOAD_BYTES}. */ maxPayloadBytes?: number; } /** * Parse assistant `text` as one-or-more STANDALONE text-emitted tool calls and return them as * native LangChain tool_calls, or `undefined` when the text is not a standalone call, names a tool * outside the allow-list, or exceeds the payload cap. Fresh `id`s are minted per call (the model * emitted none). Empty allow-list ⇒ `undefined` (never promote). */ export declare function textToNativeToolCalls(text: string | undefined, options: TextToolCallRepairOptions): NativeToolCall[] | undefined; /** * Repair one assistant `AIMessage`: if it has NO native tool_calls but its content is a * standalone text-emitted call (allow-listed, within the payload cap), return a NEW AIMessage that * carries the promoted native tool_calls; otherwise return `undefined` (the caller keeps the * original, so the native happy path is untouched). * * The returned message PRESERVES the original `id`. That is load-bearing: LangGraph's message-state * reducer merges by id, so a same-id message REPLACES the original in graph state (rather than * appending a duplicate/dangling assistant message). Content is cleared to '' since the raw * text-call is now represented natively as tool_calls. */ export declare function promoteTextEmittedToolCallMessage(message: AIMessage, options: TextToolCallRepairOptions): AIMessage | undefined;