import "reflect-metadata";
import { BaseEvent, RunAgentInput } from "@ag-ui/client";

//#region src/agent/converters/tanstack.d.ts
/**
 * Message format expected by TanStack AI's `chat()`.
 *
 * Content is typed as `any[]` for the multimodal case so messages are directly
 * passable to any adapter without casts — different adapters constrain which
 * modalities they accept (e.g. OpenAI only allows text + image).
 * Use `TanStackContentPart` to inspect individual parts if needed.
 */
interface TanStackChatMessage {
  role: "user" | "assistant" | "tool";
  content: string | null | any[];
  name?: string;
  toolCalls?: Array<{
    id: string;
    type: "function";
    function: {
      name: string;
      arguments: string;
    };
  }>;
  toolCallId?: string;
}
/**
 * A TanStack AI client-side tool, derived from a frontend-provided AG-UI tool.
 *
 * Shaped to match `@tanstack/ai`'s `ClientTool` (`__toolSide: "client"`, no
 * `execute`): the model may CALL it, but TanStack does not run it — it pauses
 * the run and hands the call back to the AG-UI client (the CopilotKit frontend
 * / bot) to execute, mirroring CopilotKit's client-tool round-trip. `chat()`
 * accepts a JSON Schema directly as `inputSchema`, so the AG-UI tool's
 * `parameters` pass through unchanged.
 */
interface TanStackClientTool {
  __toolSide: "client";
  name: string;
  description: string;
  inputSchema: any;
}
/**
 * Result of converting RunAgentInput to TanStack AI format.
 */
interface TanStackInputResult {
  /** Chat messages (only user/assistant/tool roles; all others excluded) */
  messages: TanStackChatMessage[];
  /** System prompts extracted from system/developer messages, context, and state */
  systemPrompts: string[];
  /**
   * Client-side tools derived from `input.tools` (the frontend-provided tools
   * the CopilotKit client forwards on every run). Pass these into `chat()`
   * alongside any server/provider tools so the model can call the frontend's
   * generative-UI and human-in-the-loop tools; TanStack pauses the run on a
   * client-tool call and the client executes it.
   */
  tools: TanStackClientTool[];
}
/**
 * Converts a RunAgentInput into the format expected by TanStack AI's `chat()`.
 *
 * - Keeps only user/assistant/tool messages (activity, reasoning, and other roles are also excluded)
 * - Extracts system/developer messages into `systemPrompts`
 * - Appends context entries and application state to `systemPrompts`
 * - Preserves tool calls on assistant messages and toolCallId on tool messages
 */
declare function convertInputToTanStackAI(input: RunAgentInput): TanStackInputResult;
/**
 * Converts a TanStack AI stream into AG-UI `BaseEvent` objects.
 *
 * This is a pure converter — it does NOT emit lifecycle events
 * (RUN_STARTED / RUN_FINISHED / RUN_ERROR). The caller (Agent class)
 * is responsible for those.
 */
declare function convertTanStackStream(stream: AsyncIterable<unknown>, abortSignal: AbortSignal): AsyncGenerator<BaseEvent>;
//#endregion
export { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream };
//# sourceMappingURL=tanstack.d.mts.map