/** * AG-UI content parts → LangChain standard content blocks, under what the * route's model can take. Pure: the one place that decides a part is dropped, * so the capability document (once sub-project 3's PR 2 adds the `multimodal` * section) and the run agree. * * Spec (AG-UI 1.0, run-input): a producer handed a part it cannot use MUST NOT * fail the run; it skips the part, continues, and warns. The drops come back * as data for the caller to announce (`formatDroppedPartsWarning`, and the * `content_parts_dropped` chunk). */ import type { B4MessageContent, BuiltInModelProviderId } from "@b4run/sdk"; import type { ModalitySupport } from "./chat-model-factory.js"; export type DropReason = "modality_unsupported" | "url_source_unsupported" | "file_source_unsupported" | "foreign_file_provider" | "document_not_pdf" | "tool_result_media_unsupported" /** * The entry is not a structurally valid part; the AG-UI handler's schema parse * rejects these with a 400 before they get here, so this is reached only from * the Agent Protocol path or a direct caller. */ | "malformed_part"; export interface DroppedPart { /** Position in the message's part list. */ readonly index: number; readonly type: string; readonly source?: "data" | "url" | "file"; readonly reason: DropReason; } /** A LangChain standard content block (`@langchain/core` `Multimodal.Standard` or a text block). */ export type LangChainContentBlock = Readonly> & { readonly type: string; }; /** * Hand block `content` to LangChain as `content:` together with * `response_metadata: V1_RESPONSE_METADATA`. `@langchain/core` recognises only * legacy `source_type` blocks unless the message is marked v1, and the v1 mark * is what makes the provider converters translate these blocks. Not * `contentBlocks:` — that form serializes without `kwargs.content`. A string * `content` needs no mark. */ export interface ConvertedContent { readonly content: string | readonly LangChainContentBlock[]; readonly dropped: readonly DroppedPart[]; } export declare function toLangChainContent(content: B4MessageContent, support: ModalitySupport, provider: BuiltInModelProviderId | undefined, position: "user" | "tool"): ConvertedContent; /** * Set on a message built with standard blocks under `content:`. The v1 mark is * what makes the provider converters translate standard blocks; `content:` * (not `contentBlocks:`) keeps `kwargs.content` in the serialized message. */ export declare const V1_RESPONSE_METADATA: Readonly<{ output_version: "v1"; }>; export interface DroppedPartsReport { readonly provider?: string; readonly model?: string; readonly routeId?: string; readonly messageId?: string; readonly toolCallId?: string; readonly parts: readonly DroppedPart[]; } /** * The data of a `content_parts_dropped` announcement — the agent stream chunk * and the tool converter's `b4.capability` event share this one shape, so the * two cannot drift. Unknown provider/model are omitted, never `undefined`. */ export declare function droppedPartsData(modality: { readonly provider?: string | undefined; readonly model?: string | undefined; } | undefined, parts: readonly DroppedPart[], toolCallId?: string): Omit; /** * The report fields of a `content_parts_dropped` or * `subagent.content_parts_dropped` chunk's data. A subagent's chunk carries the * child's identity fields (`call_id`, `subagent`, `route_id`, `depth`) beside * the report, so only the report's own fields are picked out. Every caller * that logs a drop goes through this, so the paths cannot drift. Undefined * when the data carries no parts list. */ export declare function pickDroppedPartsReport(data: unknown): Omit | undefined; /** The spec's developer warning: what was dropped, why, on which route, and from which tool result. */ export declare function formatDroppedPartsWarning(report: DroppedPartsReport): string; //# sourceMappingURL=content-parts.d.ts.map