import { C as CanvasTransport, S as StreamEvent } from '../types-CRfW09Y2.js'; export { w as withSelections } from '../types-CRfW09Y2.js'; /** * `langgraphTransport` — speak to a LangGraph server without a translator * in between. * * Built on the official `@langchain/langgraph-sdk` (the server's wire format * belongs to LangGraph and evolves with it — we ride the official client * rather than hand-parse it). Verified against `langgraph dev` (local); * hosted LangGraph Platform is untested — open an issue if you need it. * * Per user turn it: maps the canvas thread id to the UUID LangGraph requires, * makes sure the thread exists, frames any element selections into the * message (targeted edits), then streams the run with * `streamMode: ["messages-tuple", "custom"]` through the translation in * `translate.ts`. */ interface LangGraphTransportOptions { /** LangGraph server URL, e.g. `http://127.0.0.1:2024` (`langgraph dev`). */ url: string; /** Graph/assistant to run, e.g. `"canvas_agent"`. */ assistantId: string; /** Extra headers (e.g. auth) passed to the SDK client. */ headers?: Record; } /** * LangGraph requires UUID thread ids; the canvas allows any string. Non-UUID * ids map deterministically (RFC 4122 v5 over `canvas-thread:`), matching * the mapping the Python bridge example uses — same id in, same UUID out. */ declare function threadUuid(threadId: string): Promise; declare function langgraphTransport(options: LangGraphTransportOptions): CanvasTransport; /** * Translate a LangGraph run stream into Canvas Wire Protocol events. * * Input: the `{event, data}` chunks the LangGraph SDK yields for a run * streamed with `streamMode: ["messages-tuple", "custom"]`. Output: the * `StreamEvent`s the canvas applies. The mapping: * * - `messages` AIMessageChunk text → `message.delta` * - `messages` AIMessageChunk tool chunks → `tool.start` (once per call id) * - `messages` tool result → `tool.end` * - `custom` `canvas.*` → passed through untouched * - `error` → `error` * - stream end → `message.end` + `done` * * The chunk shapes are pinned by a captured fixture from a real * `langgraph dev` run (`__fixtures__/langgraph-run.json`) — notably, model * content arrives as block arrays (`{type: "text" | "tool_use"}`), not plain * strings. */ /** One chunk from `client.runs.stream(...)` — the SDK's `{event, data}` pair. */ interface LangGraphStreamChunk { event: string; data: unknown; } /** Text of a message chunk — models may stream content as block lists. */ declare function chunkText(content: unknown): string; declare function translateLangGraphStream(chunks: AsyncIterable | Iterable, options?: { messageId?: string; }): AsyncGenerator; export { type LangGraphStreamChunk, type LangGraphTransportOptions, chunkText, langgraphTransport, threadUuid, translateLangGraphStream };