@tanstack/ai-gemini 0.17.3 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/experimental/text-interactions/adapter.ts +304 -100
- package/src/experimental/text-interactions/events.ts +29 -23
- package/src/experimental/text-interactions/provider-options.ts +0 -1
- package/dist/esm/adapters/audio.d.ts +0 -92
- package/dist/esm/adapters/audio.js +0 -66
- package/dist/esm/adapters/audio.js.map +0 -1
- package/dist/esm/adapters/image.d.ts +0 -101
- package/dist/esm/adapters/image.js +0 -253
- package/dist/esm/adapters/image.js.map +0 -1
- package/dist/esm/adapters/summarize.d.ts +0 -33
- package/dist/esm/adapters/summarize.js +0 -18
- package/dist/esm/adapters/summarize.js.map +0 -1
- package/dist/esm/adapters/text.d.ts +0 -85
- package/dist/esm/adapters/text.js +0 -658
- package/dist/esm/adapters/text.js.map +0 -1
- package/dist/esm/adapters/tts.d.ts +0 -165
- package/dist/esm/adapters/tts.js +0 -192
- package/dist/esm/adapters/tts.js.map +0 -1
- package/dist/esm/adapters/video.d.ts +0 -108
- package/dist/esm/adapters/video.js +0 -227
- package/dist/esm/adapters/video.js.map +0 -1
- package/dist/esm/experimental/index.d.ts +0 -6
- package/dist/esm/experimental/index.js +0 -7
- package/dist/esm/experimental/index.js.map +0 -1
- package/dist/esm/experimental/text-interactions/adapter.d.ts +0 -75
- package/dist/esm/experimental/text-interactions/adapter.js +0 -899
- package/dist/esm/experimental/text-interactions/adapter.js.map +0 -1
- package/dist/esm/experimental/text-interactions/events.d.ts +0 -141
- package/dist/esm/experimental/text-interactions/provider-options.d.ts +0 -15
- package/dist/esm/image/image-provider-options.d.ts +0 -181
- package/dist/esm/image/image-provider-options.js +0 -67
- package/dist/esm/image/image-provider-options.js.map +0 -1
- package/dist/esm/index.d.ts +0 -33
- package/dist/esm/index.js +0 -38
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/message-types.d.ts +0 -104
- package/dist/esm/model-meta.d.ts +0 -242
- package/dist/esm/model-meta.js +0 -159
- package/dist/esm/model-meta.js.map +0 -1
- package/dist/esm/text/text-provider-options.d.ts +0 -196
- package/dist/esm/tools/code-execution-tool.d.ts +0 -10
- package/dist/esm/tools/code-execution-tool.js +0 -18
- package/dist/esm/tools/code-execution-tool.js.map +0 -1
- package/dist/esm/tools/computer-use-tool.d.ts +0 -13
- package/dist/esm/tools/computer-use-tool.js +0 -33
- package/dist/esm/tools/computer-use-tool.js.map +0 -1
- package/dist/esm/tools/file-search-tool.d.ts +0 -10
- package/dist/esm/tools/file-search-tool.js +0 -19
- package/dist/esm/tools/file-search-tool.js.map +0 -1
- package/dist/esm/tools/function-declaration-tool.d.ts +0 -5
- package/dist/esm/tools/function-declaration-tool.js +0 -28
- package/dist/esm/tools/function-declaration-tool.js.map +0 -1
- package/dist/esm/tools/google-maps-tool.d.ts +0 -10
- package/dist/esm/tools/google-maps-tool.js +0 -19
- package/dist/esm/tools/google-maps-tool.js.map +0 -1
- package/dist/esm/tools/google-search-retriveal-tool.d.ts +0 -10
- package/dist/esm/tools/google-search-retriveal-tool.js +0 -19
- package/dist/esm/tools/google-search-retriveal-tool.js.map +0 -1
- package/dist/esm/tools/google-search-tool.d.ts +0 -10
- package/dist/esm/tools/google-search-tool.js +0 -19
- package/dist/esm/tools/google-search-tool.js.map +0 -1
- package/dist/esm/tools/index.d.ts +0 -18
- package/dist/esm/tools/index.js +0 -21
- package/dist/esm/tools/index.js.map +0 -1
- package/dist/esm/tools/tool-converter.d.ts +0 -22
- package/dist/esm/tools/tool-converter.js +0 -66
- package/dist/esm/tools/tool-converter.js.map +0 -1
- package/dist/esm/tools/url-context-tool.d.ts +0 -10
- package/dist/esm/tools/url-context-tool.js +0 -18
- package/dist/esm/tools/url-context-tool.js.map +0 -1
- package/dist/esm/usage.d.ts +0 -67
- package/dist/esm/usage.js +0 -94
- package/dist/esm/usage.js.map +0 -1
- package/dist/esm/utils/client.d.ts +0 -17
- package/dist/esm/utils/client.js +0 -30
- package/dist/esm/utils/client.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/video/video-provider-options.d.ts +0 -90
- package/dist/esm/video/video-provider-options.js +0 -15
- package/dist/esm/video/video-provider-options.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sources":["../../../../src/experimental/text-interactions/adapter.ts"],"sourcesContent":["import { EventType } from '@tanstack/ai'\nimport { BaseTextAdapter } from '@tanstack/ai/adapters'\nimport {\n createGeminiClient,\n generateId,\n getGeminiApiKeyFromEnv,\n} from '../../utils'\nimport type { InternalLogger } from '@tanstack/ai/adapter-internals'\nimport type {\n GeminiChatModelToolCapabilitiesByName,\n GeminiModelInputModalitiesByName,\n GeminiModels,\n} from '../../model-meta'\nimport type {\n StructuredOutputOptions,\n StructuredOutputResult,\n} from '@tanstack/ai/adapters'\nimport type { GoogleGenAI, Interactions } from '@google/genai'\nimport type {\n ContentPart,\n Modality,\n ModelMessage,\n StreamChunk,\n TextOptions,\n Tool,\n} from '@tanstack/ai'\n\nimport type {\n GeminiInteractionsCustomEvent,\n GeminiInteractionsCustomEventValue,\n GeminiInteractionsStream,\n} from './events'\nimport type { ExternalTextInteractionsProviderOptions } from './provider-options'\nimport type { GeminiMessageMetadataByModality } from '../../message-types'\nimport type { GeminiClientConfig } from '../../utils'\n\ntype Interaction = Interactions.Interaction\ntype InteractionSSEEvent = Interactions.InteractionSSEEvent\n\nexport type GeminiTextInteractionsConfig = GeminiClientConfig\n\nexport type GeminiTextInteractionsProviderOptions =\n ExternalTextInteractionsProviderOptions\n\ntype InteractionsTool = NonNullable<\n Interactions.CreateModelInteractionParamsStreaming['tools']\n>[number]\n\ntype ContentBlock = Interactions.Content\n\n// The Interactions API takes `input` as a list of *Steps* (not a list of\n// content blocks, and not a list of `Turn`s — the SDK's type union is\n// misleading on both counts). The live API enforces the Step envelope —\n// raw content arrays produce `invalid_request` / \"value at top-level\n// must be a list\". The wire discriminator is snake_case\n// (`user_input` / `function_result`); see\n// https://ai.google.dev/api/interactions-api for the full Step union.\ntype UserInputStep = {\n type: 'user_input'\n content: Array<ContentBlock>\n}\ntype FunctionResultStep = {\n type: 'function_result'\n call_id: string\n name?: string\n result: string\n}\ntype InteractionsStep = UserInputStep | FunctionResultStep\ntype InteractionsRequestInput = Array<InteractionsStep>\n\n// Concrete wire shape we send to `client.interactions.create`. The SDK's\n// own param union types `input` as `string | Content[] | Turn[] | ...`\n// which is wrong for the live API (see the InteractionsRequestInput\n// comment above), so we type `input` ourselves and cast just once at the\n// SDK boundary instead of casting every field through.\ntype GeminiInteractionsRequestBody = Omit<\n Interactions.CreateModelInteractionParamsStreaming,\n 'input' | 'stream'\n> & {\n input: InteractionsRequestInput\n stream?: boolean\n}\n\ntype ToolCallState = {\n name: string\n // Accumulated args as a parsed object. Kept here in object form so a\n // garbled delta can't corrupt previously-merged fragments (the prior\n // string-then-reparse pipeline replaced the whole accumulator on any\n // parse failure). Stringified only when emitting AG-UI events.\n args: Record<string, unknown>\n index: number\n started: boolean\n ended: boolean\n}\n\n// ===========================\n// Type Resolution Helpers\n// ===========================\n\n/**\n * Resolve provider options for a specific model. The Interactions API's\n * request shape is the same across all chat-capable Gemini models — the\n * SDK doesn't expose a per-model param union — so this currently falls\n * through to the flat `GeminiTextInteractionsProviderOptions` for every\n * model. The alias exists for parity with `GeminiTextAdapter`, so a\n * per-model map can be slotted in later without changing the adapter\n * signature.\n */\ntype ResolveProviderOptions = GeminiTextInteractionsProviderOptions\n\n/**\n * Resolve input modalities for a specific model. Reuses the chat-model\n * modality map from `model-meta.ts`: passing a `document` content block\n * to a model that doesn't support it is a compile error, matching the\n * sibling `GeminiTextAdapter`.\n */\ntype ResolveInputModalities<TModel extends string> =\n TModel extends keyof GeminiModelInputModalitiesByName\n ? GeminiModelInputModalitiesByName[TModel]\n : readonly ['text', 'image', 'audio', 'video', 'document']\n\n/**\n * Resolve tool capabilities for a specific model. Reuses the chat-model\n * capability map: `google_maps` / `google_search_retrieval` /\n * `mcp_server` are rejected at runtime by `convertToolsToInteractionsFormat`,\n * but per-model gating happens here at compile time.\n */\ntype ResolveToolCapabilities<TModel extends string> =\n TModel extends keyof GeminiChatModelToolCapabilitiesByName\n ? NonNullable<GeminiChatModelToolCapabilitiesByName[TModel]>\n : readonly []\n\n/**\n * Tree-shakeable adapter for Gemini's stateful Interactions API. Routes\n * through `client.interactions.create` and surfaces the server-assigned\n * `interactionId` via an AG-UI `CUSTOM` event with\n * `name: 'gemini.interactionId'` emitted just before `RUN_FINISHED`; pass\n * that id back on the next turn via `modelOptions.previous_interaction_id`\n * to continue the conversation without resending history.\n *\n * The Interactions API does NOT support stateless multi-turn replay —\n * passing more than one message in `messages` without a\n * `previous_interaction_id` throws. For a chat UI that maintains local\n * history (e.g. `useChat`), see the \"Wiring with `useChat`\" section of\n * `docs/adapters/gemini.md` for the canonical client/server pattern.\n *\n * Supports user-defined function tools and the built-in tools\n * `google_search`, `code_execution`, `url_context`, `file_search`, and\n * `computer_use`. Built-in tool *activity* for the four search/exec\n * variants is surfaced via `CUSTOM` events\n * (`gemini.googleSearchCall` / `gemini.googleSearchResult` and the\n * corresponding per-tool variants) carrying the raw Interactions delta;\n * see {@link GeminiInteractionsCustomEvent}. `computer_use` is accepted\n * in the request but the Interactions API does not currently stream\n * per-delta CUSTOM events for it. `google_search_retrieval`,\n * `google_maps`, and `mcp_server` are not supported on this adapter.\n *\n * @experimental Interactions API is in Beta per Google; shapes may change.\n * @see https://ai.google.dev/gemini-api/docs/interactions\n */\nexport class GeminiTextInteractionsAdapter<\n TModel extends GeminiModels,\n TProviderOptions extends Record<string, any> = ResolveProviderOptions,\n TInputModalities extends ReadonlyArray<Modality> =\n ResolveInputModalities<TModel>,\n TToolCapabilities extends ReadonlyArray<string> =\n ResolveToolCapabilities<TModel>,\n> extends BaseTextAdapter<\n TModel,\n TProviderOptions,\n TInputModalities,\n GeminiMessageMetadataByModality,\n TToolCapabilities\n> {\n override readonly kind = 'text' as const\n override readonly name = 'gemini-text-interactions' as const\n\n private readonly client: GoogleGenAI\n // Tracks the most recent server-assigned interaction id per threadId\n // so the adapter can chain follow-up calls on the same thread without\n // the caller having to thread the id manually. Two callers rely on\n // this:\n // 1. The agent loop's tool-call iterations (each iteration is a new\n // `chatStream` call with accumulated tool messages).\n // 2. The agentic-structured composition: a `chatStream` run followed\n // by `structuredOutput` on the accumulated messages.\n // Cross-request chaining is the caller's job via\n // `modelOptions.previous_interaction_id`. To keep stale ids from\n // chaining a brand-new turn, `chatStream` evicts at the START when\n // the caller signals fresh-turn intent (no caller-provided id AND a\n // single user message — anything else is a follow-up). Errors evict\n // immediately so a failed turn never chains into the next one.\n private readonly interactionIdByThread = new Map<string, string>()\n\n constructor(config: GeminiTextInteractionsConfig, model: TModel) {\n super({}, model)\n this.client = createGeminiClient(config)\n }\n\n async *chatStream(\n options: TextOptions<GeminiTextInteractionsProviderOptions>,\n ): AsyncIterable<StreamChunk> {\n const runId = options.runId ?? generateId(this.name)\n const threadId = options.threadId ?? generateId(this.name)\n const timestamp = Date.now()\n const { logger } = options\n\n // Fresh-turn intent: caller didn't thread an id AND only a single\n // user message is queued. Drop any stale captured id so we don't\n // silently chain off a prior turn the caller doesn't know about.\n // Multi-message inputs are follow-ups (agent-loop iteration or\n // structuredOutput composition) and keep the Map entry.\n if (\n !options.modelOptions?.previous_interaction_id &&\n options.messages.length === 1 &&\n options.messages[0]?.role === 'user'\n ) {\n this.interactionIdByThread.delete(threadId)\n }\n\n // Resolve `previous_interaction_id`. Caller-provided wins; otherwise\n // fall back to the id we captured during a prior iteration of this\n // same agent-loop run (matched by threadId).\n const effectivePreviousInteractionId =\n options.modelOptions?.previous_interaction_id ??\n this.interactionIdByThread.get(threadId)\n\n let sawTerminalEvent = false\n // Sentinel for the `.return()` abandonment path. Set to `true` only at\n // the bottom of the `try` block — so a consumer-initiated close (via\n // upstream `break` or abort) leaves it `false`, distinguishing\n // abandonment from normal completion. This is the only signal that\n // catches abandonment AFTER a `RUN_FINISHED(tool_calls)`, where\n // `sawTerminalEvent` is `true` but the in-loop deliberately kept the\n // map entry for an agent-loop iteration that will now never run.\n let completedTryBlock = false\n try {\n const request = buildInteractionsRequest({\n ...options,\n modelOptions: {\n ...options.modelOptions,\n previous_interaction_id: effectivePreviousInteractionId,\n },\n })\n logger.request(\n `activity=chat provider=gemini-text-interactions model=${this.model} messages=${options.messages.length} tools=${options.tools?.length ?? 0} stream=true`,\n {\n provider: 'gemini-text-interactions',\n model: this.model,\n request,\n },\n )\n const stream = (await this.client.interactions.create(\n { ...request, stream: true } as GeminiInteractionsRequestBody &\n Parameters<typeof this.client.interactions.create>[0],\n { signal: options.abortController?.signal },\n )) as AsyncIterable<InteractionSSEEvent>\n\n for await (const chunk of translateInteractionEvents(\n stream,\n options.model,\n runId,\n threadId,\n options.parentRunId,\n timestamp,\n this.name,\n logger,\n )) {\n // Capture the server-assigned id so the next agent-loop\n // iteration on this thread can chain off it. The CUSTOM event\n // is also yielded downstream as usual — callers consume it via\n // `onCustomEvent` for cross-request chaining.\n //\n // The yield type can't be narrowed to GeminiInteractionsStream\n // here without fighting zod-passthrough variance (StreamChunk's\n // CustomEvent variant carries `[k: string]: unknown`), so we\n // narrow via the literal `name` and trust the typed\n // construction inside `translateInteractionEvents`.\n if (\n chunk.type === EventType.CUSTOM &&\n chunk.name === 'gemini.interactionId'\n ) {\n const value =\n chunk.value as GeminiInteractionsCustomEventValue<'gemini.interactionId'>\n this.interactionIdByThread.set(threadId, value.interactionId)\n }\n if (chunk.type === EventType.RUN_FINISHED) {\n sawTerminalEvent = true\n // Keep the captured id for follow-ups (next agent-loop\n // iteration OR a structuredOutput call composing this turn).\n // The next *fresh* chatStream call evicts at the top via the\n // fresh-turn guard.\n } else if (chunk.type === EventType.RUN_ERROR) {\n sawTerminalEvent = true\n this.interactionIdByThread.delete(threadId)\n }\n yield chunk\n }\n\n if (!sawTerminalEvent) {\n // SDK stream ended without either `interaction.complete` or\n // `error` — surface the truncation rather than silently leaving\n // downstream consumers waiting on a `RUN_FINISHED` that will\n // never come.\n this.interactionIdByThread.delete(threadId)\n const message =\n 'Gemini Interactions stream ended without a terminal event (no interaction.complete or error)'\n logger.errors('gemini-text-interactions.chatStream truncated', {\n source: 'gemini-text-interactions.chatStream',\n runId,\n threadId,\n })\n yield {\n type: EventType.RUN_ERROR,\n runId,\n model: options.model,\n timestamp,\n message,\n error: { message },\n }\n }\n completedTryBlock = true\n } catch (error) {\n this.interactionIdByThread.delete(threadId)\n const message =\n error instanceof Error\n ? error.message\n : 'An unknown error occurred during the interactions stream.'\n logger.errors('gemini-text-interactions.chatStream fatal', {\n error,\n source: 'gemini-text-interactions.chatStream',\n })\n yield {\n type: EventType.RUN_ERROR,\n runId,\n model: options.model,\n timestamp,\n message,\n error: { message },\n }\n } finally {\n // Abandonment cleanup — consumer `.return()` (upstream `break` /\n // abort) bypasses both the truncation guard and the catch handler.\n // `completedTryBlock` is the sentinel that distinguishes natural\n // completion from abandonment; on abandonment we evict so a stale\n // id from a half-finished turn can't chain into a follow-up. The\n // catch handler also lands here with the flag false; its explicit\n // delete is harmless to repeat.\n if (!completedTryBlock) {\n this.interactionIdByThread.delete(threadId)\n }\n }\n }\n\n async structuredOutput(\n options: StructuredOutputOptions<GeminiTextInteractionsProviderOptions>,\n ): Promise<StructuredOutputResult<unknown>> {\n const { chatOptions, outputSchema } = options\n const { logger } = chatOptions\n const threadId = chatOptions.threadId\n\n // Mirror the chatStream fallback: the agentic-structured flow runs\n // the chat loop first and then calls structuredOutput with the\n // accumulated `messages`. If any tool ran during the loop, the\n // messages include assistant/tool turns; without a chained\n // previous_interaction_id those would throw \"cannot send prior\n // conversation history on a fresh interaction\".\n const effectivePreviousInteractionId =\n chatOptions.modelOptions?.previous_interaction_id ??\n (threadId ? this.interactionIdByThread.get(threadId) : undefined)\n\n const baseRequest = buildInteractionsRequest({\n ...chatOptions,\n modelOptions: {\n ...chatOptions.modelOptions,\n previous_interaction_id: effectivePreviousInteractionId,\n },\n })\n\n const request: GeminiInteractionsRequestBody = {\n ...baseRequest,\n response_mime_type: 'application/json',\n response_format: outputSchema,\n }\n\n try {\n logger.request(\n `activity=chat provider=gemini-text-interactions model=${this.model} messages=${chatOptions.messages.length} tools=${chatOptions.tools?.length ?? 0} stream=false`,\n {\n provider: 'gemini-text-interactions',\n model: this.model,\n request,\n },\n )\n const result = (await this.client.interactions.create(\n request as Parameters<typeof this.client.interactions.create>[0],\n { signal: chatOptions.abortController?.signal },\n )) as Interaction\n\n const rawText = extractTextFromInteraction(result)\n\n if (!rawText) {\n throw new Error(\n `Gemini Interactions returned no text output for structured-output request (status: ${result.status}). The model may have produced only tool calls or non-text content.`,\n )\n }\n\n let parsed: unknown\n try {\n parsed = JSON.parse(rawText)\n } catch {\n throw new Error(\n `Failed to parse structured output as JSON. Content: ${rawText.slice(0, 200)}${rawText.length > 200 ? '...' : ''}`,\n )\n }\n\n return { data: parsed, rawText }\n } catch (error) {\n logger.errors('gemini-text-interactions.structuredOutput fatal', {\n error,\n source: 'gemini-text-interactions.structuredOutput',\n })\n // Preserve the original error as `cause` so the stack trace and any\n // SDK-attached status/code/headers survive for Sentry dedup.\n throw new Error(\n error instanceof Error\n ? error.message\n : 'An unknown error occurred during structured output generation.',\n { cause: error },\n )\n }\n }\n}\n\n/** @experimental Interactions API is in Beta. */\nexport function createGeminiTextInteractions<TModel extends GeminiModels>(\n model: TModel,\n apiKey: string,\n config?: Omit<GeminiTextInteractionsConfig, 'apiKey'>,\n): GeminiTextInteractionsAdapter<\n TModel,\n ResolveProviderOptions,\n ResolveInputModalities<TModel>,\n ResolveToolCapabilities<TModel>\n> {\n return new GeminiTextInteractionsAdapter({ apiKey, ...config }, model)\n}\n\n/** @experimental Interactions API is in Beta. */\nexport function geminiTextInteractions<TModel extends GeminiModels>(\n model: TModel,\n config?: Omit<GeminiTextInteractionsConfig, 'apiKey'>,\n): GeminiTextInteractionsAdapter<\n TModel,\n ResolveProviderOptions,\n ResolveInputModalities<TModel>,\n ResolveToolCapabilities<TModel>\n> {\n const apiKey = getGeminiApiKeyFromEnv()\n return createGeminiTextInteractions(model, apiKey, config)\n}\n\nfunction buildInteractionsRequest(\n options: TextOptions<GeminiTextInteractionsProviderOptions>,\n): GeminiInteractionsRequestBody {\n const modelOpts = options.modelOptions\n\n const systemInstruction =\n modelOpts?.system_instruction ?? options.systemPrompts?.join('\\n')\n\n const generationConfig: Interactions.GenerationConfig = {\n ...modelOpts?.generation_config,\n }\n\n const hasGenerationConfig = Object.keys(generationConfig).length > 0\n\n const input = convertMessagesToInteractionsInput(\n options.messages,\n modelOpts?.previous_interaction_id !== undefined,\n )\n\n return {\n model: options.model,\n input,\n previous_interaction_id: modelOpts?.previous_interaction_id,\n system_instruction: systemInstruction,\n tools: convertToolsToInteractionsFormat(options.tools),\n generation_config: hasGenerationConfig ? generationConfig : undefined,\n store: modelOpts?.store,\n background: modelOpts?.background,\n response_modalities: modelOpts?.response_modalities,\n response_format: modelOpts?.response_format,\n response_mime_type: modelOpts?.response_mime_type,\n }\n}\n\n// Google's Interactions API takes `input` as `Array<Step>`. Each Step\n// is `{type: 'user_input' | 'function_result' | ..., ...}` — content\n// blocks (text/image/etc.) live nested inside a Step's `content` array,\n// they are NOT valid at the top level. Sending raw `Array<Content>`\n// produces `invalid_request` / \"value at top-level must be a list\",\n// because the API is looking for a Step list at the top level and\n// gets content objects instead. The SDK's type union\n// (`string | Array<Content> | Array<Turn> | ...`) is misleading; see\n// https://ai.google.dev/api/interactions-api for the real Step union.\n//\n// When `hasPreviousInteraction` is true the server holds the transcript\n// up through the last assistant turn, so we only send the steps that\n// come after it (a new `user_input`, one or more `function_result`s\n// continuing a tool call, etc.). Otherwise the conversation is fresh\n// and only the latest user turn is supported — multi-turn replay\n// without `previous_interaction_id` is not part of the API contract.\nfunction convertMessagesToInteractionsInput(\n messages: Array<ModelMessage>,\n hasPreviousInteraction: boolean,\n): InteractionsRequestInput {\n const toolCallIdToName = new Map<string, string>()\n for (const msg of messages) {\n if (msg.role === 'assistant' && msg.toolCalls) {\n for (const tc of msg.toolCalls) {\n toolCallIdToName.set(tc.id, tc.function.name)\n }\n }\n }\n\n const source = hasPreviousInteraction\n ? messagesAfterLastAssistant(messages)\n : messages\n\n if (hasPreviousInteraction && source.length === 0) {\n throw new Error(\n 'Gemini Interactions adapter: modelOptions.previous_interaction_id was provided but no new messages were found after the last assistant turn. Append at least one user or tool message before chaining.',\n )\n }\n\n if (!hasPreviousInteraction) {\n const [only, ...rest] = source\n if (!only) {\n throw new Error('Gemini Interactions adapter: no messages to send.')\n }\n if (rest.length > 0) {\n throw new Error(\n 'Gemini Interactions adapter: cannot send prior conversation history on a fresh interaction. Either set modelOptions.previous_interaction_id to chain prior turns server-side, or trim the message list to a single new user turn. See docs/adapters/gemini.md (\"Wiring with useChat\") for the canonical client/server pattern.',\n )\n }\n if (only.role !== 'user') {\n throw new Error(\n `Gemini Interactions adapter: the first message of a fresh interaction must be a user turn (got role=\"${only.role}\"). Set modelOptions.previous_interaction_id to continue an existing interaction.`,\n )\n }\n const content = messageToContentBlocks(only)\n if (content.length === 0) {\n throw new Error(\n 'Gemini Interactions adapter: the user message produced no content blocks to send.',\n )\n }\n return [{ type: 'user_input', content }]\n }\n\n // Chained path: each post-assistant message becomes one Step. A user\n // reply maps to `user_input`; a tool reply maps to `function_result`.\n // Assistant turns shouldn't appear here (sliced off above) — if one\n // somehow does we skip it rather than letting it shape the wire.\n const steps: Array<InteractionsStep> = []\n for (const msg of source) {\n if (msg.role === 'tool' && msg.toolCallId) {\n const result = serializeToolResultContent(msg.content)\n steps.push({\n type: 'function_result',\n call_id: msg.toolCallId,\n name: toolCallIdToName.get(msg.toolCallId),\n result,\n })\n } else if (msg.role === 'user') {\n const content = messageToContentBlocks(msg)\n if (content.length > 0) {\n steps.push({ type: 'user_input', content })\n }\n }\n }\n if (steps.length === 0) {\n throw new Error(\n 'Gemini Interactions adapter: messages after the last assistant turn produced no steps to send.',\n )\n }\n return steps\n}\n\n// The Interactions API's `function_result.result` field is a string. We\n// fail loudly on non-string tool content rather than silently coercing\n// to `''` — silent coercion meant the model lost the entire tool\n// output for callers that returned content as an array (e.g. image +\n// text) or `null`. If you need to send structured tool output, encode\n// it yourself before passing.\nfunction serializeToolResultContent(\n content: ModelMessage['content'] | undefined,\n): string {\n if (typeof content === 'string') return content\n if (content === null || content === undefined) {\n throw new Error(\n 'Gemini Interactions adapter: tool message has no content. The Interactions API requires a string `result` on function_result steps — return a string from your tool implementation (encode JSON/multimodal output yourself).',\n )\n }\n throw new Error(\n 'Gemini Interactions adapter: tool message content must be a string (got an array of content parts). The Interactions API requires a string `result` on function_result steps — stringify multimodal tool output before returning it from your tool.',\n )\n}\n\n// Extracts the content blocks (text / image / audio / video / document)\n// from a single message. Tool calls and tool results live one level up\n// as Steps, not as content, so they are NOT emitted here.\nfunction messageToContentBlocks(msg: ModelMessage): Array<ContentBlock> {\n const blocks: Array<ContentBlock> = []\n\n if (Array.isArray(msg.content)) {\n for (const part of msg.content) {\n blocks.push(contentPartToBlock(part))\n }\n } else if (\n typeof msg.content === 'string' &&\n msg.content &&\n msg.role !== 'tool'\n ) {\n blocks.push({ type: 'text', text: msg.content })\n }\n\n return blocks\n}\n\nfunction messagesAfterLastAssistant(\n messages: Array<ModelMessage>,\n): Array<ModelMessage> {\n for (let i = messages.length - 1; i >= 0; i--) {\n if (messages[i]?.role === 'assistant') {\n return messages.slice(i + 1)\n }\n }\n return messages\n}\n\nfunction safeParseToolArguments(\n raw: string | undefined,\n logger: InternalLogger,\n): Record<string, unknown> {\n if (!raw) return {}\n try {\n const parsed = JSON.parse(raw)\n return parsed && typeof parsed === 'object' ? parsed : {}\n } catch (error) {\n logger.errors(\n 'gemini-text-interactions.safeParseToolArguments parse failed',\n {\n error,\n raw,\n source: 'gemini-text-interactions.chatStream',\n },\n )\n return {}\n }\n}\n\n// `satisfies` pins these arrays to the SDK's narrow mime-type unions: if\n// Google removes a format the build breaks, and if they add one ours keeps\n// working (we just won't accept the new one until added here).\nconst IMAGE_MIME_TYPES = [\n 'image/png',\n 'image/jpeg',\n 'image/webp',\n 'image/heic',\n 'image/heif',\n] as const satisfies ReadonlyArray<\n NonNullable<Interactions.ImageContent['mime_type']>\n>\n\nconst AUDIO_MIME_TYPES = [\n 'audio/wav',\n 'audio/mp3',\n 'audio/aiff',\n 'audio/aac',\n 'audio/ogg',\n 'audio/flac',\n] as const satisfies ReadonlyArray<\n NonNullable<Interactions.AudioContent['mime_type']>\n>\n\nconst VIDEO_MIME_TYPES = [\n 'video/mp4',\n 'video/mpeg',\n 'video/mpg',\n 'video/mov',\n 'video/avi',\n 'video/x-flv',\n 'video/webm',\n 'video/wmv',\n 'video/3gpp',\n] as const satisfies ReadonlyArray<\n NonNullable<Interactions.VideoContent['mime_type']>\n>\n\nconst DOCUMENT_MIME_TYPES = [\n 'application/pdf',\n] as const satisfies ReadonlyArray<\n NonNullable<Interactions.DocumentContent['mime_type']>\n>\n\nfunction validateMime<T extends string>(\n allowed: ReadonlyArray<T>,\n value: string | undefined,\n kind: string,\n): T | undefined {\n if (value === undefined) return undefined\n if ((allowed as ReadonlyArray<string>).includes(value)) {\n return value as T\n }\n throw new Error(\n `Unsupported ${kind} mime type \"${value}\" for the Gemini Interactions API. Allowed: ${allowed.join(', ')}.`,\n )\n}\n\nfunction contentPartToBlock(part: ContentPart): ContentBlock {\n if (part.type === 'text') {\n return { type: 'text', text: part.content }\n }\n const isData = part.source.type === 'data'\n switch (part.type) {\n case 'image': {\n const mime_type = validateMime(\n IMAGE_MIME_TYPES,\n part.source.mimeType,\n 'image',\n )\n return isData\n ? { type: 'image', data: part.source.value, mime_type }\n : { type: 'image', uri: part.source.value, mime_type }\n }\n case 'audio': {\n const mime_type = validateMime(\n AUDIO_MIME_TYPES,\n part.source.mimeType,\n 'audio',\n )\n return isData\n ? { type: 'audio', data: part.source.value, mime_type }\n : { type: 'audio', uri: part.source.value, mime_type }\n }\n case 'video': {\n const mime_type = validateMime(\n VIDEO_MIME_TYPES,\n part.source.mimeType,\n 'video',\n )\n return isData\n ? { type: 'video', data: part.source.value, mime_type }\n : { type: 'video', uri: part.source.value, mime_type }\n }\n case 'document': {\n const mime_type = validateMime(\n DOCUMENT_MIME_TYPES,\n part.source.mimeType,\n 'document',\n )\n return isData\n ? { type: 'document', data: part.source.value, mime_type }\n : { type: 'document', uri: part.source.value, mime_type }\n }\n }\n}\n\n// Built-in Gemini tools use snake_case field names in the Interactions API\n// that differ from the camelCase fields used on `client.models.generateContent`\n// (e.g. `fileSearchStoreNames` vs `file_search_store_names`). Translate\n// explicitly so callers keep using the same tool factories across adapters.\nfunction convertToolsToInteractionsFormat<TTool extends Tool>(\n tools: Array<TTool> | undefined,\n): Array<InteractionsTool> | undefined {\n if (!tools || tools.length === 0) return undefined\n\n const result: Array<InteractionsTool> = []\n\n for (const tool of tools) {\n switch (tool.name) {\n case 'google_search': {\n const metadata = (tool.metadata ?? {}) as {\n search_types?: Array<'web_search' | 'image_search'>\n }\n result.push({\n type: 'google_search',\n ...(metadata.search_types\n ? { search_types: metadata.search_types }\n : {}),\n })\n break\n }\n case 'code_execution': {\n result.push({ type: 'code_execution' })\n break\n }\n case 'url_context': {\n result.push({ type: 'url_context' })\n break\n }\n case 'file_search': {\n const metadata = (tool.metadata ?? {}) as {\n fileSearchStoreNames?: Array<string>\n topK?: number\n metadataFilter?: string\n }\n result.push({\n type: 'file_search',\n ...(metadata.fileSearchStoreNames\n ? { file_search_store_names: metadata.fileSearchStoreNames }\n : {}),\n ...(metadata.topK !== undefined ? { top_k: metadata.topK } : {}),\n ...(metadata.metadataFilter !== undefined\n ? { metadata_filter: metadata.metadataFilter }\n : {}),\n })\n break\n }\n case 'computer_use': {\n const metadata = (tool.metadata ?? {}) as {\n environment?: string\n excludedPredefinedFunctions?: Array<string>\n }\n if (metadata.environment && metadata.environment !== 'browser') {\n throw new Error(\n `computer_use environment \"${metadata.environment}\" is not supported on the Gemini Interactions API. Only \"browser\" is accepted.`,\n )\n }\n result.push({\n type: 'computer_use',\n ...(metadata.environment\n ? { environment: metadata.environment as 'browser' }\n : {}),\n ...(metadata.excludedPredefinedFunctions\n ? {\n excludedPredefinedFunctions:\n metadata.excludedPredefinedFunctions,\n }\n : {}),\n })\n break\n }\n case 'google_search_retrieval':\n throw new Error(\n '`google_search_retrieval` is not supported on the Gemini Interactions API. Use `googleSearchTool()` (`google_search`) with `geminiTextInteractions()`, or call `geminiText()` for the legacy retrieval tool.',\n )\n case 'google_maps':\n throw new Error(\n '`google_maps` is not yet supported on the Gemini Interactions API. Use `geminiText()` for Google Maps grounding.',\n )\n case 'mcp_server':\n throw new Error(\n '`mcp_server` is not yet supported on the `geminiTextInteractions()` adapter.',\n )\n default: {\n if (!tool.description) {\n throw new Error(\n `Tool ${tool.name} requires a description for the Gemini Interactions adapter`,\n )\n }\n result.push({\n type: 'function',\n name: tool.name,\n description: tool.description,\n parameters: sanitizeToolParameters(\n tool.inputSchema ?? { type: 'object', properties: {} },\n ),\n })\n }\n }\n }\n\n return result\n}\n\n// Map of API-level status values onto the AG-UI `finishReason` field.\n// `requires_action` is the Interactions API's signal that the model\n// produced one or more function calls and is waiting for results — we\n// always map that to 'tool_calls' regardless of whether deltas were\n// observed (a function_call may have arrived in a single delta with no\n// other content). `incomplete` is the truncation signal (max_tokens\n// exceeded etc.) — map to 'length'. `completed` is normal stop.\nfunction statusToFinishReason(\n status: Interaction['status'] | undefined,\n sawFunctionCall: boolean,\n): 'stop' | 'length' | 'tool_calls' | null {\n if (status === 'requires_action') return 'tool_calls'\n if (status === 'incomplete') return 'length'\n if (sawFunctionCall) return 'tool_calls'\n return 'stop'\n}\n\n// Statuses that mean the interaction did not produce a usable result.\n// `failed`/`cancelled` map to RUN_ERROR. `incomplete` is the model\n// hitting a stop condition (max_tokens etc.) and is reported via\n// `finishReason: 'length'` on RUN_FINISHED so callers can decide how to\n// react without it looking like a hard error.\nfunction statusIsError(\n status: Interaction['status'] | undefined,\n): status is 'failed' | 'cancelled' {\n return status === 'failed' || status === 'cancelled'\n}\n\nasync function* translateInteractionEvents(\n stream: AsyncIterable<InteractionSSEEvent>,\n model: string,\n runId: string,\n threadId: string,\n parentRunId: string | undefined,\n timestamp: number,\n adapterName: string,\n logger: InternalLogger,\n): AsyncIterable<StreamChunk> {\n const messageId = generateId(adapterName)\n let hasEmittedRunStarted = false\n let hasEmittedTextMessageStart = false\n let textAccumulated = ''\n let interactionId: string | undefined\n let sawFunctionCall = false\n const toolCalls = new Map<string, ToolCallState>()\n let nextToolIndex = 0\n let thinkingStepId: string | null = null\n let thinkingAccumulated = ''\n let reasoningMessageId: string | null = null\n let hasClosedReasoning = false\n\n const closeReasoningIfNeeded = function* (): Generator<StreamChunk> {\n if (reasoningMessageId && !hasClosedReasoning) {\n hasClosedReasoning = true\n yield {\n type: EventType.REASONING_MESSAGE_END,\n messageId: reasoningMessageId,\n model,\n timestamp,\n }\n yield {\n type: EventType.REASONING_END,\n messageId: reasoningMessageId,\n model,\n timestamp,\n }\n // Reset so that a later `thought_summary` delta (the API\n // interleaves text → thought → text on some models) opens a\n // fresh reasoning block instead of re-using an already-ended\n // messageId, which would violate AG-UI ordering.\n thinkingStepId = null\n reasoningMessageId = null\n hasClosedReasoning = false\n }\n }\n\n // Seals any in-flight messages and tool calls. Called both on the\n // normal terminal path (`interaction.complete`) and on the error path\n // (`error` SSE event + premature EOF) so the StreamProcessor never\n // sees orphan TEXT_MESSAGE_START / TOOL_CALL_START / REASONING_*\n // events on RUN_ERROR.\n const closeOpenState = function* (): Generator<StreamChunk> {\n yield* closeReasoningIfNeeded()\n for (const [toolCallId, state] of toolCalls) {\n if (state.ended) continue\n state.ended = true\n yield {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n toolName: state.name,\n model,\n timestamp,\n input: state.args,\n }\n }\n if (hasEmittedTextMessageStart) {\n hasEmittedTextMessageStart = false\n yield {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n model,\n timestamp,\n }\n }\n }\n\n const emitRunStartedIfNeeded = function* (): Generator<StreamChunk> {\n if (!hasEmittedRunStarted) {\n hasEmittedRunStarted = true\n yield {\n type: EventType.RUN_STARTED,\n runId,\n threadId,\n model,\n timestamp,\n parentRunId,\n }\n }\n }\n\n for await (const event of stream) {\n logger.provider(`provider=gemini-text-interactions`, { event })\n switch (event.event_type) {\n case 'interaction.start': {\n interactionId = event.interaction.id\n yield* emitRunStartedIfNeeded()\n break\n }\n\n case 'content.start': {\n yield* emitRunStartedIfNeeded()\n break\n }\n\n case 'content.delta': {\n yield* emitRunStartedIfNeeded()\n const delta = event.delta\n switch (delta.type) {\n case 'text': {\n yield* closeReasoningIfNeeded()\n if (!hasEmittedTextMessageStart) {\n hasEmittedTextMessageStart = true\n yield {\n type: EventType.TEXT_MESSAGE_START,\n messageId,\n model,\n timestamp,\n role: 'assistant',\n }\n }\n textAccumulated += delta.text\n yield {\n type: EventType.TEXT_MESSAGE_CONTENT,\n messageId,\n model,\n timestamp,\n delta: delta.text,\n content: textAccumulated,\n }\n break\n }\n case 'function_call': {\n yield* closeReasoningIfNeeded()\n sawFunctionCall = true\n const toolCallId = delta.id\n const deltaArgs: Record<string, unknown> =\n typeof delta.arguments === 'string'\n ? safeParseToolArguments(delta.arguments, logger)\n : delta.arguments\n let state = toolCalls.get(toolCallId)\n if (!state) {\n state = {\n name: delta.name,\n args: { ...deltaArgs },\n index: nextToolIndex++,\n started: false,\n ended: false,\n }\n toolCalls.set(toolCallId, state)\n } else {\n state.args = { ...state.args, ...deltaArgs }\n if (delta.name) state.name = delta.name\n }\n if (!state.started) {\n state.started = true\n yield {\n type: EventType.TOOL_CALL_START,\n toolCallId,\n toolCallName: state.name,\n toolName: state.name,\n parentMessageId: messageId,\n model,\n timestamp,\n index: state.index,\n }\n }\n yield {\n type: EventType.TOOL_CALL_ARGS,\n toolCallId,\n model,\n timestamp,\n delta: JSON.stringify(deltaArgs),\n args: JSON.stringify(state.args),\n }\n break\n }\n case 'google_search_call': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.googleSearchCall',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'google_search_result': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.googleSearchResult',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'code_execution_call': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.codeExecutionCall',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'code_execution_result': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.codeExecutionResult',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'url_context_call': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.urlContextCall',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'url_context_result': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.urlContextResult',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'file_search_call': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.fileSearchCall',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'file_search_result': {\n yield* closeReasoningIfNeeded()\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.fileSearchResult',\n value: delta,\n model,\n timestamp,\n }\n break\n }\n case 'thought_summary': {\n const thoughtText =\n delta.content && 'text' in delta.content ? delta.content.text : ''\n if (!thoughtText) break\n if (thinkingStepId === null || reasoningMessageId === null) {\n thinkingStepId = generateId(adapterName)\n reasoningMessageId = generateId(adapterName)\n yield {\n type: EventType.REASONING_START,\n messageId: reasoningMessageId,\n model,\n timestamp,\n }\n yield {\n type: EventType.REASONING_MESSAGE_START,\n messageId: reasoningMessageId,\n role: 'reasoning',\n model,\n timestamp,\n }\n yield {\n type: EventType.STEP_STARTED,\n stepName: thinkingStepId,\n stepId: thinkingStepId,\n model,\n timestamp,\n stepType: 'thinking',\n }\n }\n thinkingAccumulated += thoughtText\n yield {\n type: EventType.REASONING_MESSAGE_CONTENT,\n messageId: reasoningMessageId,\n delta: thoughtText,\n model,\n timestamp,\n }\n yield {\n type: EventType.STEP_FINISHED,\n stepName: thinkingStepId,\n stepId: thinkingStepId,\n model,\n timestamp,\n delta: thoughtText,\n content: thinkingAccumulated,\n }\n break\n }\n // The following delta types are valid per the SDK type union\n // but aren't yet translated by this adapter (output modalities\n // text-only adapter shouldn't see, response-side function_result\n // / mcp_server_*, thought_signature). Falling through to the\n // observability default so SDK drift is visible.\n case 'image':\n case 'audio':\n case 'video':\n case 'document':\n case 'function_result':\n case 'mcp_server_tool_call':\n case 'mcp_server_tool_result':\n case 'thought_signature':\n default:\n logger.provider(\n `gemini-text-interactions unhandled content.delta type`,\n { delta },\n )\n break\n }\n break\n }\n\n case 'content.stop':\n case 'interaction.status_update': {\n break\n }\n\n case 'interaction.complete': {\n if (event.interaction.id) {\n interactionId = event.interaction.id\n }\n\n yield* closeOpenState()\n\n const status = event.interaction.status\n if (statusIsError(status)) {\n const message = `Gemini Interactions ${status}: the interaction ended without a usable response.`\n logger.errors(\n 'gemini-text-interactions.translateInteractionEvents non-success status',\n {\n source: 'gemini-text-interactions.chatStream',\n status,\n interactionId,\n },\n )\n yield {\n type: EventType.RUN_ERROR,\n runId,\n model,\n timestamp,\n message,\n code: status,\n error: { message, code: status },\n }\n return\n }\n\n const usage = event.interaction.usage\n const finishReason = statusToFinishReason(status, sawFunctionCall)\n\n if (interactionId) {\n yield {\n type: EventType.CUSTOM,\n name: 'gemini.interactionId',\n value: { interactionId },\n model,\n timestamp,\n }\n }\n\n yield {\n type: EventType.RUN_FINISHED,\n runId,\n threadId,\n model,\n timestamp,\n finishReason,\n usage: usage\n ? {\n promptTokens: usage.total_input_tokens ?? 0,\n completionTokens: usage.total_output_tokens ?? 0,\n totalTokens: usage.total_tokens ?? 0,\n }\n : undefined,\n }\n return\n }\n\n case 'error': {\n // Close any in-flight TEXT_MESSAGE_START / TOOL_CALL_START /\n // REASONING_* so downstream consumers don't see orphan open\n // state after RUN_ERROR.\n yield* closeOpenState()\n const rawMessage = event.error?.message\n const message =\n typeof rawMessage === 'string' && rawMessage.length > 0\n ? rawMessage\n : `Gemini Interactions error (no message): ${JSON.stringify(event.error ?? {})}`\n const rawCode = event.error?.code\n const code =\n typeof rawCode === 'string' || typeof rawCode === 'number'\n ? String(rawCode)\n : undefined\n yield {\n type: EventType.RUN_ERROR,\n runId,\n model,\n timestamp,\n message,\n code,\n error: { message, code },\n }\n return\n }\n\n default:\n logger.provider(`gemini-text-interactions unhandled event_type`, {\n event,\n })\n break\n }\n }\n\n // Stream ended without `interaction.complete` or `error` (both `return`\n // out of the loop). Seal any in-flight TEXT/TOOL/REASONING blocks here\n // so the truncation-fallback RUN_ERROR yielded by `chatStream` doesn't\n // leave orphan `*_START` events open downstream.\n yield* closeOpenState()\n}\n\nfunction extractTextFromInteraction(interaction: Interaction): string {\n let text = ''\n for (const output of interaction.outputs ?? []) {\n if (output.type === 'text') {\n text += output.text\n }\n }\n return text\n}\n\n// The live Interactions API rejects tool parameter schemas that contain\n// an empty `required: []` array with the misleading top-level error\n// `\"value at top-level must be a list\"`. Empty `properties: {}` and\n// `parameters: {}` are both fine — only the empty `required` array is\n// poison. The Zod -> JSON Schema converter (and many hand-written\n// schemas) emit `required: []` whenever a tool has zero required\n// parameters, so we strip those instances recursively before sending.\n// Non-empty `required` arrays are passed through unchanged.\nfunction sanitizeToolParameters(schema: unknown): unknown {\n if (!schema || typeof schema !== 'object') return schema\n if (Array.isArray(schema)) return schema.map(sanitizeToolParameters)\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(schema)) {\n if (key === 'required' && Array.isArray(value) && value.length === 0) {\n continue\n }\n out[key] = sanitizeToolParameters(value)\n }\n return out\n}\n\n// Re-export the stream type so consumers can import it alongside the\n// adapter from a single path: `import type { GeminiInteractions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M,UACJ,OAAO,eAAe,YAAY,WAAW,SAAS,IAClD,aACA,2CAA2C,KAAK,UAAU,MAAM,SAAS,CAAA,CAAE,CAAC;AAClF,cAAM,UAAU,MAAM,OAAO;AAC7B,cAAM,OACJ,OAAO,YAAY,YAAY,OAAO,YAAY,WAC9C,OAAO,OAAO,IACd;AACN,cAAM;AAAA,UACJ,MAAM,UAAU;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO,EAAE,SAAS,KAAA;AAAA,QAAK;AAEzB;AAAA,MACF;AAAA,MAEA;AACE,eAAO,SAAS,iDAAiD;AAAA,UAC/D;AAAA,QAAA,CACD;AACD;AAAA,IAAA;AAAA,EAEN;AAMA,SAAO,eAAA;AACT;AAEA,SAAS,2BAA2B,aAAkC;AACpE,MAAI,OAAO;AACX,aAAW,UAAU,YAAY,WAAW,CAAA,GAAI;AAC9C,QAAI,OAAO,SAAS,QAAQ;AAC1B,cAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAUA,SAAS,uBAAuB,QAA0B;AACxD,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,MAAI,MAAM,QAAQ,MAAM,EAAG,QAAO,OAAO,IAAI,sBAAsB;AACnE,QAAM,MAA+B,CAAA;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,QAAQ,cAAc,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG;AACpE;AAAA,IACF;AACA,QAAI,GAAG,IAAI,uBAAuB,KAAK;AAAA,EACzC;AACA,SAAO;AACT;"}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Interactions } from '@google/genai';
|
|
2
|
-
import { CustomEvent, StreamChunk } from '@tanstack/ai';
|
|
3
|
-
/**
|
|
4
|
-
* `CUSTOM` event carrying the server-assigned Interactions API id. Emitted
|
|
5
|
-
* immediately before `RUN_FINISHED` on a successful run; pass `interactionId`
|
|
6
|
-
* back as `modelOptions.previous_interaction_id` to continue the conversation.
|
|
7
|
-
*/
|
|
8
|
-
export interface GeminiInteractionIdEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
9
|
-
name: 'gemini.interactionId';
|
|
10
|
-
value: {
|
|
11
|
-
interactionId: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* `CUSTOM` event carrying a raw `google_search_call` content delta from the
|
|
16
|
-
* Interactions API. Payload shape is owned by `@google/genai`.
|
|
17
|
-
*/
|
|
18
|
-
export interface GeminiGoogleSearchCallEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
19
|
-
name: 'gemini.googleSearchCall';
|
|
20
|
-
value: Interactions.ContentDelta.GoogleSearchCallDelta;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* `CUSTOM` event carrying a raw `google_search_result` content delta from
|
|
24
|
-
* the Interactions API.
|
|
25
|
-
*/
|
|
26
|
-
export interface GeminiGoogleSearchResultEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
27
|
-
name: 'gemini.googleSearchResult';
|
|
28
|
-
value: Interactions.ContentDelta.GoogleSearchResultDelta;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* `CUSTOM` event carrying a raw `code_execution_call` content delta from
|
|
32
|
-
* the Interactions API.
|
|
33
|
-
*/
|
|
34
|
-
export interface GeminiCodeExecutionCallEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
35
|
-
name: 'gemini.codeExecutionCall';
|
|
36
|
-
value: Interactions.ContentDelta.CodeExecutionCallDelta;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* `CUSTOM` event carrying a raw `code_execution_result` content delta from
|
|
40
|
-
* the Interactions API.
|
|
41
|
-
*/
|
|
42
|
-
export interface GeminiCodeExecutionResultEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
43
|
-
name: 'gemini.codeExecutionResult';
|
|
44
|
-
value: Interactions.ContentDelta.CodeExecutionResultDelta;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* `CUSTOM` event carrying a raw `url_context_call` content delta from the
|
|
48
|
-
* Interactions API.
|
|
49
|
-
*/
|
|
50
|
-
export interface GeminiUrlContextCallEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
51
|
-
name: 'gemini.urlContextCall';
|
|
52
|
-
value: Interactions.ContentDelta.URLContextCallDelta;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* `CUSTOM` event carrying a raw `url_context_result` content delta from the
|
|
56
|
-
* Interactions API.
|
|
57
|
-
*/
|
|
58
|
-
export interface GeminiUrlContextResultEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
59
|
-
name: 'gemini.urlContextResult';
|
|
60
|
-
value: Interactions.ContentDelta.URLContextResultDelta;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* `CUSTOM` event carrying a raw `file_search_call` content delta from the
|
|
64
|
-
* Interactions API.
|
|
65
|
-
*/
|
|
66
|
-
export interface GeminiFileSearchCallEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
67
|
-
name: 'gemini.fileSearchCall';
|
|
68
|
-
value: Interactions.ContentDelta.FileSearchCallDelta;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* `CUSTOM` event carrying a raw `file_search_result` content delta from the
|
|
72
|
-
* Interactions API.
|
|
73
|
-
*/
|
|
74
|
-
export interface GeminiFileSearchResultEvent extends Omit<CustomEvent, 'name' | 'value'> {
|
|
75
|
-
name: 'gemini.fileSearchResult';
|
|
76
|
-
value: Interactions.ContentDelta.FileSearchResultDelta;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Discriminated union of every `CUSTOM` event the
|
|
80
|
-
* `geminiTextInteractions()` adapter emits.
|
|
81
|
-
*
|
|
82
|
-
* Each variant carries the lifecycle fields `model?` / `timestamp?` /
|
|
83
|
-
* `rawEvent?` from {@link CustomEvent} so a single narrow against the
|
|
84
|
-
* `StreamChunk` union yields a fully typed payload — no helper or `as`
|
|
85
|
-
* cast required:
|
|
86
|
-
*
|
|
87
|
-
* ```ts
|
|
88
|
-
* for await (const chunk of stream as GeminiInteractionsStream) {
|
|
89
|
-
* if (chunk.type === 'CUSTOM' && chunk.name === 'gemini.interactionId') {
|
|
90
|
-
* chunk.value.interactionId // string
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* The four tool-delta variant pairs (`google_search`, `code_execution`,
|
|
96
|
-
* `url_context`, `file_search`) forward the raw
|
|
97
|
-
* `Interactions.ContentDelta.*Delta` payload from `@google/genai` so
|
|
98
|
-
* consumers stay in sync with SDK shape changes automatically.
|
|
99
|
-
* `computer_use` is accepted as a request tool but the API does not
|
|
100
|
-
* stream per-delta CUSTOM events for it.
|
|
101
|
-
*/
|
|
102
|
-
export type GeminiInteractionsCustomEvent = GeminiInteractionIdEvent | GeminiGoogleSearchCallEvent | GeminiGoogleSearchResultEvent | GeminiCodeExecutionCallEvent | GeminiCodeExecutionResultEvent | GeminiUrlContextCallEvent | GeminiUrlContextResultEvent | GeminiFileSearchCallEvent | GeminiFileSearchResultEvent;
|
|
103
|
-
/** String-literal union of the event names in {@link GeminiInteractionsCustomEvent}. */
|
|
104
|
-
export type GeminiInteractionsCustomEventName = GeminiInteractionsCustomEvent['name'];
|
|
105
|
-
/**
|
|
106
|
-
* Look up the typed `value` payload for a specific event name.
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* const v: GeminiInteractionsCustomEventValue<'gemini.interactionId'>
|
|
110
|
-
* // ^? { interactionId: string }
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export type GeminiInteractionsCustomEventValue<TName extends GeminiInteractionsCustomEventName> = Extract<GeminiInteractionsCustomEvent, {
|
|
114
|
-
name: TName;
|
|
115
|
-
}>['value'];
|
|
116
|
-
/**
|
|
117
|
-
* Public stream type for `chatStream` results from the
|
|
118
|
-
* `geminiTextInteractions()` adapter. Yields the standard
|
|
119
|
-
* {@link StreamChunk} lifecycle events plus the Gemini-specific
|
|
120
|
-
* `CUSTOM` events declared in {@link GeminiInteractionsCustomEvent},
|
|
121
|
-
* so a single discriminated narrow on `chunk.name` gives a typed
|
|
122
|
-
* `chunk.value`:
|
|
123
|
-
*
|
|
124
|
-
* ```ts
|
|
125
|
-
* import type { GeminiInteractionsStream } from '@tanstack/ai-gemini/experimental'
|
|
126
|
-
*
|
|
127
|
-
* for await (const chunk of stream as GeminiInteractionsStream) {
|
|
128
|
-
* if (chunk.type === 'CUSTOM' && chunk.name === 'gemini.interactionId') {
|
|
129
|
-
* chunk.value.interactionId // typed as string
|
|
130
|
-
* }
|
|
131
|
-
* }
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* Caveat: server tools may emit arbitrary user-defined custom events via
|
|
135
|
-
* `emitCustomEvent(name, value)`. Those flow through the stream at
|
|
136
|
-
* runtime but are intentionally absent from this union — including a
|
|
137
|
-
* bare {@link CustomEvent} would collapse `chunk.value` back to `any`
|
|
138
|
-
* after the narrow. Branch on `CUSTOM` outside the literal-`name`
|
|
139
|
-
* narrows or cast explicitly if you rely on `emitCustomEvent`.
|
|
140
|
-
*/
|
|
141
|
-
export type GeminiInteractionsStream = AsyncIterable<Exclude<StreamChunk, CustomEvent> | GeminiInteractionsCustomEvent>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Interactions } from '@google/genai';
|
|
2
|
-
/**
|
|
3
|
-
* Provider options for `geminiTextInteractions()`. Derived from the SDK's
|
|
4
|
-
* own `interactions.create` param shape so field types (including the
|
|
5
|
-
* allowed `response_modalities` values and the `generation_config` schema)
|
|
6
|
-
* stay in sync with `@google/genai` automatically.
|
|
7
|
-
*
|
|
8
|
-
* `input`, `model`, `tools`, `stream`, and `api_version` are intentionally
|
|
9
|
-
* omitted — the adapter derives those from its constructor args and the
|
|
10
|
-
* chat options.
|
|
11
|
-
*
|
|
12
|
-
* @see https://ai.google.dev/gemini-api/docs/interactions
|
|
13
|
-
* @experimental Interactions API is in Beta.
|
|
14
|
-
*/
|
|
15
|
-
export type ExternalTextInteractionsProviderOptions = Pick<Interactions.CreateModelInteractionParamsStreaming, 'previous_interaction_id' | 'store' | 'background' | 'system_instruction' | 'response_modalities' | 'response_format' | 'response_mime_type' | 'generation_config'>;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { GeminiImageModels } from '../model-meta.js';
|
|
2
|
-
import { ImagePromptLanguage, PersonGeneration, SafetyFilterLevel } from '@google/genai';
|
|
3
|
-
export type { ImagePromptLanguage, PersonGeneration, SafetyFilterLevel };
|
|
4
|
-
/**
|
|
5
|
-
* Gemini Imagen aspect ratio options
|
|
6
|
-
* Controls the aspect ratio of generated images
|
|
7
|
-
*/
|
|
8
|
-
export type GeminiAspectRatio = '1:1' | '3:4' | '4:3' | '9:16' | '16:9' | '9:21' | '21:9';
|
|
9
|
-
/**
|
|
10
|
-
* Provider options for Gemini image generation
|
|
11
|
-
* These options match the @google/genai GenerateImagesConfig interface
|
|
12
|
-
* and can be spread directly into the API request.
|
|
13
|
-
*/
|
|
14
|
-
export interface GeminiImageProviderOptions {
|
|
15
|
-
/**
|
|
16
|
-
* The aspect ratio of generated images
|
|
17
|
-
* @default '1:1'
|
|
18
|
-
*/
|
|
19
|
-
aspectRatio?: GeminiAspectRatio;
|
|
20
|
-
/**
|
|
21
|
-
* Controls whether people can appear in generated images
|
|
22
|
-
* Use PersonGeneration enum values: DONT_ALLOW, ALLOW_ADULT, ALLOW_ALL
|
|
23
|
-
* @default 'ALLOW_ADULT'
|
|
24
|
-
*/
|
|
25
|
-
personGeneration?: PersonGeneration;
|
|
26
|
-
/**
|
|
27
|
-
* Safety filter level for content filtering
|
|
28
|
-
* Use SafetyFilterLevel enum values
|
|
29
|
-
*/
|
|
30
|
-
safetyFilterLevel?: SafetyFilterLevel;
|
|
31
|
-
/**
|
|
32
|
-
* Optional seed for reproducible image generation
|
|
33
|
-
* When the same seed is used with the same prompt and settings,
|
|
34
|
-
* you should get similar (though not identical) results
|
|
35
|
-
*/
|
|
36
|
-
seed?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to add a SynthID watermark to generated images
|
|
39
|
-
* SynthID helps identify AI-generated content
|
|
40
|
-
* @default true
|
|
41
|
-
*/
|
|
42
|
-
addWatermark?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Language of the prompt
|
|
45
|
-
* Use ImagePromptLanguage enum values
|
|
46
|
-
*/
|
|
47
|
-
language?: ImagePromptLanguage;
|
|
48
|
-
/**
|
|
49
|
-
* Negative prompt - what to avoid in the generated image
|
|
50
|
-
* Not all models support negative prompts
|
|
51
|
-
*/
|
|
52
|
-
negativePrompt?: string;
|
|
53
|
-
/**
|
|
54
|
-
* Output MIME type for the generated image
|
|
55
|
-
* @default 'image/png'
|
|
56
|
-
*/
|
|
57
|
-
outputMimeType?: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
58
|
-
/**
|
|
59
|
-
* Compression quality for JPEG outputs (0-100)
|
|
60
|
-
* Higher values mean better quality but larger file sizes
|
|
61
|
-
* @default 75
|
|
62
|
-
*/
|
|
63
|
-
outputCompressionQuality?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Controls how much the model adheres to the text prompt
|
|
66
|
-
* Large values increase output and prompt alignment,
|
|
67
|
-
* but may compromise image quality
|
|
68
|
-
*/
|
|
69
|
-
guidanceScale?: number;
|
|
70
|
-
/**
|
|
71
|
-
* Whether to use the prompt rewriting logic
|
|
72
|
-
*/
|
|
73
|
-
enhancePrompt?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Whether to report the safety scores of each generated image
|
|
76
|
-
* and the positive prompt in the response
|
|
77
|
-
*/
|
|
78
|
-
includeSafetyAttributes?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Whether to include the Responsible AI filter reason
|
|
81
|
-
* if the image is filtered out of the response
|
|
82
|
-
*/
|
|
83
|
-
includeRaiReason?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Cloud Storage URI used to store the generated images
|
|
86
|
-
*/
|
|
87
|
-
outputGcsUri?: string;
|
|
88
|
-
/**
|
|
89
|
-
* User specified labels to track billing usage
|
|
90
|
-
*/
|
|
91
|
-
labels?: Record<string, string>;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Model-specific provider options mapping
|
|
95
|
-
* Currently all Imagen models use the same options structure
|
|
96
|
-
*/
|
|
97
|
-
export type GeminiImageModelProviderOptionsByName = {
|
|
98
|
-
[K in GeminiImageModels]: GeminiImageProviderOptions;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Supported size strings for Gemini Imagen models
|
|
102
|
-
* These map to aspect ratios internally
|
|
103
|
-
*/
|
|
104
|
-
export type GeminiImageSize = '1024x1024' | '512x512' | '1024x768' | '1536x1024' | '1792x1024' | '1920x1080' | '768x1024' | '1024x1536' | '1024x1792' | '1080x1920';
|
|
105
|
-
/**
|
|
106
|
-
* Aspect ratios supported by Gemini native image models (via generateContent API).
|
|
107
|
-
* Matches the SDK's ImageConfig.aspectRatio values.
|
|
108
|
-
*/
|
|
109
|
-
export type GeminiNativeImageAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '9:16' | '16:9' | '21:9';
|
|
110
|
-
/**
|
|
111
|
-
* Resolution tiers for Gemini native image models.
|
|
112
|
-
* Matches the SDK's ImageConfig.imageSize values.
|
|
113
|
-
*/
|
|
114
|
-
export type GeminiNativeImageResolution = '1K' | '2K' | '4K';
|
|
115
|
-
/**
|
|
116
|
-
* Template literal size type for Gemini native image models: "16:9_4K", "1:1_2K", etc.
|
|
117
|
-
*/
|
|
118
|
-
export type GeminiNativeImageSize = `${GeminiNativeImageAspectRatio}_${GeminiNativeImageResolution}`;
|
|
119
|
-
/**
|
|
120
|
-
* Gemini native image models that use the generateContent API path.
|
|
121
|
-
* These models support template literal sizes (aspectRatio_resolution).
|
|
122
|
-
*/
|
|
123
|
-
export type GeminiNativeImageModels = 'gemini-3.1-flash-image-preview' | 'gemini-3-pro-image-preview' | 'gemini-2.5-flash-image';
|
|
124
|
-
/**
|
|
125
|
-
* Model-specific size options mapping.
|
|
126
|
-
* Gemini native image models use template literal sizes, Imagen models use pixel sizes.
|
|
127
|
-
*/
|
|
128
|
-
export type GeminiImageModelSizeByName = {
|
|
129
|
-
[K in GeminiNativeImageModels]: GeminiNativeImageSize;
|
|
130
|
-
} & {
|
|
131
|
-
[K in Exclude<GeminiImageModels, GeminiNativeImageModels>]: GeminiImageSize;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Per-model prompt input modalities. Gemini-native image models accept image
|
|
135
|
-
* parts in the multimodal prompt (image-conditioned generation via
|
|
136
|
-
* generateContent); Imagen models are strictly text-to-image, so their
|
|
137
|
-
* `prompt` is constrained to text at compile time.
|
|
138
|
-
*/
|
|
139
|
-
export type GeminiImageModelInputModalitiesByName = {
|
|
140
|
-
[K in GeminiNativeImageModels]: readonly ['image'];
|
|
141
|
-
} & {
|
|
142
|
-
[K in Exclude<GeminiImageModels, GeminiNativeImageModels>]: readonly [];
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Valid sizes for Gemini Imagen models
|
|
146
|
-
* Gemini uses aspect ratios, but we map common WIDTHxHEIGHT formats to aspect ratios
|
|
147
|
-
* These are approximate mappings based on common image dimensions
|
|
148
|
-
*/
|
|
149
|
-
export declare const GEMINI_SIZE_TO_ASPECT_RATIO: Record<string, GeminiAspectRatio>;
|
|
150
|
-
/**
|
|
151
|
-
* Maps a WIDTHxHEIGHT size string to a Gemini aspect ratio
|
|
152
|
-
* Returns undefined if the size cannot be mapped
|
|
153
|
-
*/
|
|
154
|
-
export declare function sizeToAspectRatio(size: string | undefined): GeminiAspectRatio | undefined;
|
|
155
|
-
/**
|
|
156
|
-
* Validates that the provided size can be mapped to an aspect ratio
|
|
157
|
-
* Throws an error if the size is invalid
|
|
158
|
-
*/
|
|
159
|
-
export declare function validateImageSize(model: string, size: string | undefined): void;
|
|
160
|
-
/**
|
|
161
|
-
* Validates the number of images requested against the model's known cap.
|
|
162
|
-
* Uses a per-model table where available and falls back to the shared
|
|
163
|
-
* default otherwise — no more "some support up to 8" comments that don't
|
|
164
|
-
* match the error message.
|
|
165
|
-
*/
|
|
166
|
-
export declare function validateNumberOfImages(model: string, numberOfImages: number | undefined): void;
|
|
167
|
-
/**
|
|
168
|
-
* Validates the prompt is not empty
|
|
169
|
-
*/
|
|
170
|
-
export declare function validatePrompt(options: {
|
|
171
|
-
prompt: string;
|
|
172
|
-
model: string;
|
|
173
|
-
}): void;
|
|
174
|
-
/**
|
|
175
|
-
* Parses a Gemini native image size string into its components.
|
|
176
|
-
* Format: "aspectRatio_resolution" e.g. "16:9_4K" → { aspectRatio: "16:9", resolution: "4K" }
|
|
177
|
-
*/
|
|
178
|
-
export declare function parseNativeImageSize(size: string): {
|
|
179
|
-
aspectRatio: string;
|
|
180
|
-
resolution: string;
|
|
181
|
-
} | undefined;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const GEMINI_SIZE_TO_ASPECT_RATIO = {
|
|
2
|
-
// Square
|
|
3
|
-
"1024x1024": "1:1",
|
|
4
|
-
"512x512": "1:1",
|
|
5
|
-
// Landscape
|
|
6
|
-
"1024x768": "4:3",
|
|
7
|
-
"1536x1024": "4:3",
|
|
8
|
-
"1792x1024": "16:9",
|
|
9
|
-
"1920x1080": "16:9",
|
|
10
|
-
// Portrait
|
|
11
|
-
"768x1024": "3:4",
|
|
12
|
-
"1024x1536": "3:4",
|
|
13
|
-
// Inverted
|
|
14
|
-
"1024x1792": "9:16",
|
|
15
|
-
"1080x1920": "9:16"
|
|
16
|
-
};
|
|
17
|
-
function sizeToAspectRatio(size) {
|
|
18
|
-
if (!size) return void 0;
|
|
19
|
-
return GEMINI_SIZE_TO_ASPECT_RATIO[size];
|
|
20
|
-
}
|
|
21
|
-
function validateImageSize(model, size) {
|
|
22
|
-
if (!size) return;
|
|
23
|
-
const aspectRatio = sizeToAspectRatio(size);
|
|
24
|
-
if (!aspectRatio) {
|
|
25
|
-
const validSizes = Object.keys(GEMINI_SIZE_TO_ASPECT_RATIO);
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Invalid size "${size}" for model "${model}". Gemini Imagen uses aspect ratios. Valid sizes that map to aspect ratios: ${validSizes.join(", ")}. Alternatively, use providerOptions.aspectRatio directly with values: 1:1, 3:4, 4:3, 9:16, 16:9, 9:21, 21:9`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const IMAGEN_MAX_IMAGES_BY_MODEL = {
|
|
32
|
-
"imagen-3.0-generate-002": 4,
|
|
33
|
-
"imagen-4.0-generate-001": 4,
|
|
34
|
-
"imagen-4.0-ultra-generate-001": 4,
|
|
35
|
-
"imagen-4.0-fast-generate-001": 4
|
|
36
|
-
};
|
|
37
|
-
const DEFAULT_IMAGEN_MAX_IMAGES = 4;
|
|
38
|
-
function validateNumberOfImages(model, numberOfImages) {
|
|
39
|
-
if (numberOfImages === void 0) return;
|
|
40
|
-
const maxImages = IMAGEN_MAX_IMAGES_BY_MODEL[model] ?? DEFAULT_IMAGEN_MAX_IMAGES;
|
|
41
|
-
if (numberOfImages < 1 || numberOfImages > maxImages) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`Invalid numberOfImages "${numberOfImages}" for model "${model}". Must be between 1 and ${maxImages}.`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function validatePrompt(options) {
|
|
48
|
-
const { prompt, model } = options;
|
|
49
|
-
if (!prompt || prompt.trim().length === 0) {
|
|
50
|
-
throw new Error(`Prompt cannot be empty for model "${model}".`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function parseNativeImageSize(size) {
|
|
54
|
-
const match = size.match(/^(\d+:\d+)_(.+)$/);
|
|
55
|
-
const [, aspectRatio, resolution] = match ?? [];
|
|
56
|
-
if (aspectRatio === void 0 || resolution === void 0) return void 0;
|
|
57
|
-
return { aspectRatio, resolution };
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
GEMINI_SIZE_TO_ASPECT_RATIO,
|
|
61
|
-
parseNativeImageSize,
|
|
62
|
-
sizeToAspectRatio,
|
|
63
|
-
validateImageSize,
|
|
64
|
-
validateNumberOfImages,
|
|
65
|
-
validatePrompt
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=image-provider-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-provider-options.js","sources":["../../../src/image/image-provider-options.ts"],"sourcesContent":["import type { GeminiImageModels } from '../model-meta'\nimport type {\n ImagePromptLanguage,\n PersonGeneration,\n SafetyFilterLevel,\n} from '@google/genai'\n\n// Re-export SDK types so users can use them directly\nexport type { ImagePromptLanguage, PersonGeneration, SafetyFilterLevel }\n\n/**\n * Gemini Imagen aspect ratio options\n * Controls the aspect ratio of generated images\n */\nexport type GeminiAspectRatio =\n | '1:1'\n | '3:4'\n | '4:3'\n | '9:16'\n | '16:9'\n | '9:21'\n | '21:9'\n\n/**\n * Provider options for Gemini image generation\n * These options match the @google/genai GenerateImagesConfig interface\n * and can be spread directly into the API request.\n */\nexport interface GeminiImageProviderOptions {\n /**\n * The aspect ratio of generated images\n * @default '1:1'\n */\n aspectRatio?: GeminiAspectRatio\n\n /**\n * Controls whether people can appear in generated images\n * Use PersonGeneration enum values: DONT_ALLOW, ALLOW_ADULT, ALLOW_ALL\n * @default 'ALLOW_ADULT'\n */\n personGeneration?: PersonGeneration\n\n /**\n * Safety filter level for content filtering\n * Use SafetyFilterLevel enum values\n */\n safetyFilterLevel?: SafetyFilterLevel\n\n /**\n * Optional seed for reproducible image generation\n * When the same seed is used with the same prompt and settings,\n * you should get similar (though not identical) results\n */\n seed?: number\n\n /**\n * Whether to add a SynthID watermark to generated images\n * SynthID helps identify AI-generated content\n * @default true\n */\n addWatermark?: boolean\n\n /**\n * Language of the prompt\n * Use ImagePromptLanguage enum values\n */\n language?: ImagePromptLanguage\n\n /**\n * Negative prompt - what to avoid in the generated image\n * Not all models support negative prompts\n */\n negativePrompt?: string\n\n /**\n * Output MIME type for the generated image\n * @default 'image/png'\n */\n outputMimeType?: 'image/png' | 'image/jpeg' | 'image/webp'\n\n /**\n * Compression quality for JPEG outputs (0-100)\n * Higher values mean better quality but larger file sizes\n * @default 75\n */\n outputCompressionQuality?: number\n\n /**\n * Controls how much the model adheres to the text prompt\n * Large values increase output and prompt alignment,\n * but may compromise image quality\n */\n guidanceScale?: number\n\n /**\n * Whether to use the prompt rewriting logic\n */\n enhancePrompt?: boolean\n\n /**\n * Whether to report the safety scores of each generated image\n * and the positive prompt in the response\n */\n includeSafetyAttributes?: boolean\n\n /**\n * Whether to include the Responsible AI filter reason\n * if the image is filtered out of the response\n */\n includeRaiReason?: boolean\n\n /**\n * Cloud Storage URI used to store the generated images\n */\n outputGcsUri?: string\n\n /**\n * User specified labels to track billing usage\n */\n labels?: Record<string, string>\n}\n\n/**\n * Model-specific provider options mapping\n * Currently all Imagen models use the same options structure\n */\nexport type GeminiImageModelProviderOptionsByName = {\n [K in GeminiImageModels]: GeminiImageProviderOptions\n}\n\n/**\n * Supported size strings for Gemini Imagen models\n * These map to aspect ratios internally\n */\nexport type GeminiImageSize =\n | '1024x1024'\n | '512x512'\n | '1024x768'\n | '1536x1024'\n | '1792x1024'\n | '1920x1080'\n | '768x1024'\n | '1024x1536'\n | '1024x1792'\n | '1080x1920'\n\n/**\n * Aspect ratios supported by Gemini native image models (via generateContent API).\n * Matches the SDK's ImageConfig.aspectRatio values.\n */\nexport type GeminiNativeImageAspectRatio =\n | '1:1'\n | '2:3'\n | '3:2'\n | '3:4'\n | '4:3'\n | '9:16'\n | '16:9'\n | '21:9'\n\n/**\n * Resolution tiers for Gemini native image models.\n * Matches the SDK's ImageConfig.imageSize values.\n */\nexport type GeminiNativeImageResolution = '1K' | '2K' | '4K'\n\n/**\n * Template literal size type for Gemini native image models: \"16:9_4K\", \"1:1_2K\", etc.\n */\nexport type GeminiNativeImageSize =\n `${GeminiNativeImageAspectRatio}_${GeminiNativeImageResolution}`\n\n/**\n * Gemini native image models that use the generateContent API path.\n * These models support template literal sizes (aspectRatio_resolution).\n */\nexport type GeminiNativeImageModels =\n | 'gemini-3.1-flash-image-preview'\n | 'gemini-3-pro-image-preview'\n | 'gemini-2.5-flash-image'\n\n/**\n * Model-specific size options mapping.\n * Gemini native image models use template literal sizes, Imagen models use pixel sizes.\n */\nexport type GeminiImageModelSizeByName = {\n [K in GeminiNativeImageModels]: GeminiNativeImageSize\n} & {\n [K in Exclude<GeminiImageModels, GeminiNativeImageModels>]: GeminiImageSize\n}\n\n/**\n * Per-model prompt input modalities. Gemini-native image models accept image\n * parts in the multimodal prompt (image-conditioned generation via\n * generateContent); Imagen models are strictly text-to-image, so their\n * `prompt` is constrained to text at compile time.\n */\nexport type GeminiImageModelInputModalitiesByName = {\n [K in GeminiNativeImageModels]: readonly ['image']\n} & {\n [K in Exclude<GeminiImageModels, GeminiNativeImageModels>]: readonly []\n}\n\n/**\n * Valid sizes for Gemini Imagen models\n * Gemini uses aspect ratios, but we map common WIDTHxHEIGHT formats to aspect ratios\n * These are approximate mappings based on common image dimensions\n */\nexport const GEMINI_SIZE_TO_ASPECT_RATIO: Record<string, GeminiAspectRatio> = {\n // Square\n '1024x1024': '1:1',\n '512x512': '1:1',\n // Landscape\n '1024x768': '4:3',\n '1536x1024': '4:3',\n '1792x1024': '16:9',\n '1920x1080': '16:9',\n // Portrait\n '768x1024': '3:4',\n '1024x1536': '3:4', // Inverted\n '1024x1792': '9:16',\n '1080x1920': '9:16',\n}\n\n/**\n * Maps a WIDTHxHEIGHT size string to a Gemini aspect ratio\n * Returns undefined if the size cannot be mapped\n */\nexport function sizeToAspectRatio(\n size: string | undefined,\n): GeminiAspectRatio | undefined {\n if (!size) return undefined\n return GEMINI_SIZE_TO_ASPECT_RATIO[size]\n}\n\n/**\n * Validates that the provided size can be mapped to an aspect ratio\n * Throws an error if the size is invalid\n */\nexport function validateImageSize(\n model: string,\n size: string | undefined,\n): void {\n if (!size) return\n\n const aspectRatio = sizeToAspectRatio(size)\n if (!aspectRatio) {\n const validSizes = Object.keys(GEMINI_SIZE_TO_ASPECT_RATIO)\n throw new Error(\n `Invalid size \"${size}\" for model \"${model}\". ` +\n `Gemini Imagen uses aspect ratios. Valid sizes that map to aspect ratios: ${validSizes.join(', ')}. ` +\n `Alternatively, use providerOptions.aspectRatio directly with values: 1:1, 3:4, 4:3, 9:16, 16:9, 9:21, 21:9`,\n )\n }\n}\n\n/**\n * Per-model caps on images per request.\n * Imagen 3 and the Imagen 4 family all support up to 4 images per request\n * via the Gemini API (the rumored 8-image tier is Vertex-only and isn't\n * reachable through @google/genai today). Unknown models fall through to\n * the shared cap defined below.\n *\n * @see https://ai.google.dev/gemini-api/docs/imagen\n */\nconst IMAGEN_MAX_IMAGES_BY_MODEL: Record<string, number> = {\n 'imagen-3.0-generate-002': 4,\n 'imagen-4.0-generate-001': 4,\n 'imagen-4.0-ultra-generate-001': 4,\n 'imagen-4.0-fast-generate-001': 4,\n}\n\nconst DEFAULT_IMAGEN_MAX_IMAGES = 4\n\n/**\n * Validates the number of images requested against the model's known cap.\n * Uses a per-model table where available and falls back to the shared\n * default otherwise — no more \"some support up to 8\" comments that don't\n * match the error message.\n */\nexport function validateNumberOfImages(\n model: string,\n numberOfImages: number | undefined,\n): void {\n if (numberOfImages === undefined) return\n\n const maxImages =\n IMAGEN_MAX_IMAGES_BY_MODEL[model] ?? DEFAULT_IMAGEN_MAX_IMAGES\n if (numberOfImages < 1 || numberOfImages > maxImages) {\n throw new Error(\n `Invalid numberOfImages \"${numberOfImages}\" for model \"${model}\". ` +\n `Must be between 1 and ${maxImages}.`,\n )\n }\n}\n\n/**\n * Validates the prompt is not empty\n */\nexport function validatePrompt(options: {\n prompt: string\n model: string\n}): void {\n const { prompt, model } = options\n if (!prompt || prompt.trim().length === 0) {\n throw new Error(`Prompt cannot be empty for model \"${model}\".`)\n }\n}\n\n/**\n * Parses a Gemini native image size string into its components.\n * Format: \"aspectRatio_resolution\" e.g. \"16:9_4K\" → { aspectRatio: \"16:9\", resolution: \"4K\" }\n */\nexport function parseNativeImageSize(\n size: string,\n): { aspectRatio: string; resolution: string } | undefined {\n const match = size.match(/^(\\d+:\\d+)_(.+)$/)\n const [, aspectRatio, resolution] = match ?? []\n if (aspectRatio === undefined || resolution === undefined) return undefined\n return { aspectRatio, resolution }\n}\n"],"names":[],"mappings":"AAgNO,MAAM,8BAAiE;AAAA;AAAA,EAE5E,aAAa;AAAA,EACb,WAAW;AAAA;AAAA,EAEX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AAAA;AAAA,EAEb,YAAY;AAAA,EACZ,aAAa;AAAA;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AACf;AAMO,SAAS,kBACd,MAC+B;AAC/B,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,4BAA4B,IAAI;AACzC;AAMO,SAAS,kBACd,OACA,MACM;AACN,MAAI,CAAC,KAAM;AAEX,QAAM,cAAc,kBAAkB,IAAI;AAC1C,MAAI,CAAC,aAAa;AAChB,UAAM,aAAa,OAAO,KAAK,2BAA2B;AAC1D,UAAM,IAAI;AAAA,MACR,iBAAiB,IAAI,gBAAgB,KAAK,+EACoC,WAAW,KAAK,IAAI,CAAC;AAAA,IAAA;AAAA,EAGvG;AACF;AAWA,MAAM,6BAAqD;AAAA,EACzD,2BAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,iCAAiC;AAAA,EACjC,gCAAgC;AAClC;AAEA,MAAM,4BAA4B;AAQ3B,SAAS,uBACd,OACA,gBACM;AACN,MAAI,mBAAmB,OAAW;AAElC,QAAM,YACJ,2BAA2B,KAAK,KAAK;AACvC,MAAI,iBAAiB,KAAK,iBAAiB,WAAW;AACpD,UAAM,IAAI;AAAA,MACR,2BAA2B,cAAc,gBAAgB,KAAK,4BACnC,SAAS;AAAA,IAAA;AAAA,EAExC;AACF;AAKO,SAAS,eAAe,SAGtB;AACP,QAAM,EAAE,QAAQ,MAAA,IAAU;AAC1B,MAAI,CAAC,UAAU,OAAO,KAAA,EAAO,WAAW,GAAG;AACzC,UAAM,IAAI,MAAM,qCAAqC,KAAK,IAAI;AAAA,EAChE;AACF;AAMO,SAAS,qBACd,MACyD;AACzD,QAAM,QAAQ,KAAK,MAAM,kBAAkB;AAC3C,QAAM,GAAG,aAAa,UAAU,IAAI,SAAS,CAAA;AAC7C,MAAI,gBAAgB,UAAa,eAAe,OAAW,QAAO;AAClE,SAAO,EAAE,aAAa,WAAA;AACxB;"}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export { GeminiTextAdapter, createGeminiChat, geminiText, type GeminiTextConfig, type GeminiTextProviderOptions, } from './adapters/text.js';
|
|
2
|
-
export { createGeminiSummarize, geminiSummarize, type GeminiSummarizeConfig, type GeminiSummarizeModel, } from './adapters/summarize.js';
|
|
3
|
-
export { GeminiImageAdapter, createGeminiImage, geminiImage, type GeminiImageConfig, } from './adapters/image.js';
|
|
4
|
-
export type { GeminiImageProviderOptions, GeminiImageModelProviderOptionsByName, GeminiAspectRatio, PersonGeneration, SafetyFilterLevel, ImagePromptLanguage, } from './image/image-provider-options.js';
|
|
5
|
-
/**
|
|
6
|
-
* @experimental Gemini TTS is an experimental feature and may change.
|
|
7
|
-
*/
|
|
8
|
-
export { GeminiTTSAdapter, createGeminiSpeech, geminiSpeech, type GeminiTTSConfig, type GeminiTTSProviderOptions, } from './adapters/tts.js';
|
|
9
|
-
/**
|
|
10
|
-
* @experimental Gemini Lyria music generation is an experimental feature and may change.
|
|
11
|
-
*/
|
|
12
|
-
export { GeminiAudioAdapter, createGeminiAudio, geminiAudio, type GeminiAudioConfig, type GeminiAudioModel, type GeminiAudioProviderOptions, } from './adapters/audio.js';
|
|
13
|
-
/**
|
|
14
|
-
* @experimental Veo video generation is an experimental feature and may change.
|
|
15
|
-
*/
|
|
16
|
-
export { GeminiVideoAdapter, createGeminiVideo, geminiVideo, type GeminiVideoConfig, } from './adapters/video.js';
|
|
17
|
-
export { GEMINI_VIDEO_DURATIONS, getGeminiVideoDurationOptions, } from './video/video-provider-options.js';
|
|
18
|
-
export type { GeminiVideoModel, GeminiVideoModelDurationByName, GeminiVideoModelInputModalitiesByName, GeminiVideoModelProviderOptionsByName, GeminiVideoModelSizeByName, GeminiVideoProviderOptions, GeminiVideoSize, } from './video/video-provider-options.js';
|
|
19
|
-
export { GEMINI_MODELS, GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS, } from './model-meta.js';
|
|
20
|
-
export { GEMINI_MODELS as GeminiTextModels } from './model-meta.js';
|
|
21
|
-
export { GEMINI_IMAGE_MODELS as GeminiImageModels } from './model-meta.js';
|
|
22
|
-
export { GEMINI_TTS_MODELS as GeminiTTSModels } from './model-meta.js';
|
|
23
|
-
export { GEMINI_TTS_VOICES as GeminiTTSVoices } from './model-meta.js';
|
|
24
|
-
export { GEMINI_AUDIO_MODELS as GeminiAudioModels } from './model-meta.js';
|
|
25
|
-
export { GEMINI_VIDEO_MODELS as GeminiVideoModels } from './model-meta.js';
|
|
26
|
-
export type { GeminiModels as GeminiTextModel } from './model-meta.js';
|
|
27
|
-
export type { GeminiImageModels as GeminiImageModel } from './model-meta.js';
|
|
28
|
-
export type { GeminiTTSVoice } from './model-meta.js';
|
|
29
|
-
export type { GeminiChatModelProviderOptionsByName, GeminiChatModelToolCapabilitiesByName, GeminiModelInputModalitiesByName, } from './model-meta.js';
|
|
30
|
-
export type { GeminiStructuredOutputOptions, GeminiThinkingOptions, } from './text/text-provider-options.js';
|
|
31
|
-
export type { GoogleGeminiTool } from './tools/index.js';
|
|
32
|
-
export type { GeminiTextMetadata, GeminiImageMetadata, GeminiAudioMetadata, GeminiVideoMetadata, GeminiDocumentMetadata, GeminiMessageMetadataByModality, } from './message-types.js';
|
|
33
|
-
export type { GeminiProviderUsageDetails } from './usage.js';
|