import type { JsonSchemaProperty, StreamTransformer } from "@b4run/core"; import { type B4Principal, type BuiltInModelProviderId, type GateDecision, type ToolDisplay, type ToolDisplayIcon } from "@b4run/sdk"; import { DynamicStructuredTool } from "@langchain/core/tools"; import { z } from "zod"; import { type ModalitySupport } from "./chat-model-factory.js"; interface B4ToolDefinition { /** Internal: a permission wrapper reports execution after all checks pass. */ readonly b4ExecutionGated?: true; readonly description?: string; readonly name: string; readonly run: (input: unknown, context: { readonly middleware?: Readonly>; readonly principal?: import("@b4run/sdk").B4Principal; readonly signal: AbortSignal; readonly threadId?: string; readonly params?: Readonly>; /** * The provider's id for this call, stable across LangGraph's re-execution * of an interrupted tool node. Absent when the tool is invoked outside a * model tool call. */ readonly toolCallId?: string; /** How this call reads while it runs (`display.icon`/`running`), for a gate that parks it. */ readonly step?: { readonly icon?: ToolDisplayIcon; readonly label?: string; }; /** * Receives how a permission gate answered this call (`once`, `always`, * `deny`) when one ran interactively; the runtime persists it on the * call's step. Absent outside the runtime's converter. */ readonly onGateDecision?: (decision: GateDecision) => void; /** Internal execution signal, awaited after policy checks and before the tool body. */ readonly onExecutionStart?: () => Promise; }) => Promise | unknown; readonly schema?: unknown; /** How a call reads to a person; evaluated per call and streamed as `b4.step`. */ readonly display?: ToolDisplay; /** End the run on this tool's successful result; see the core `B4ToolDefinition`. */ readonly returnDirect?: boolean; /** The server-side stub of a client-provided tool; it records itself. Never issued as a server call. */ readonly clientTool?: true; } export type OffloadFn = (content: string, toolName: string, toolCallId?: string, signal?: AbortSignal) => Promise; /** The root model's modality, for shaping a tool's media result. */ export interface ToolResultModality { readonly support: ModalitySupport; readonly provider: BuiltInModelProviderId | undefined; readonly model: string | undefined; } /** The `additional_kwargs` key under which a ToolMessage keeps every part the tool returned, for the UI. */ export declare const B4_CONTENT_PARTS_KEY = "b4_content_parts"; export declare function convertToolToLangChain(tool: B4ToolDefinition, middlewareContext?: Readonly>, offload?: OffloadFn, routeParamNames?: readonly string[], streamTransformers?: readonly StreamTransformer[], modality?: ToolResultModality, principal?: B4Principal): DynamicStructuredTool; export declare function jsonSchemaToZod(schema: JsonSchemaProperty): z.ZodObject; export {}; //# sourceMappingURL=tool-converter.d.ts.map