@tanstack/ai-gemini 0.11.0 → 0.12.0
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/dist/esm/experimental/index.d.ts +6 -0
- package/dist/esm/experimental/index.js +7 -0
- package/dist/esm/experimental/index.js.map +1 -0
- package/dist/esm/experimental/text-interactions/adapter.d.ts +75 -0
- package/dist/esm/experimental/text-interactions/adapter.js +907 -0
- package/dist/esm/experimental/text-interactions/adapter.js.map +1 -0
- package/dist/esm/experimental/text-interactions/events.d.ts +141 -0
- package/dist/esm/experimental/text-interactions/provider-options.d.ts +15 -0
- package/package.json +6 -2
- package/src/experimental/index.ts +17 -0
- package/src/experimental/text-interactions/adapter.ts +1392 -0
- package/src/experimental/text-interactions/events.ts +191 -0
- package/src/experimental/text-interactions/provider-options.ts +26 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @experimental Gemini's Interactions API is in Beta per Google. Shapes and
|
|
3
|
+
* behavior may change between minor releases of `@tanstack/ai-gemini`.
|
|
4
|
+
*/
|
|
5
|
+
export { GeminiTextInteractionsAdapter, createGeminiTextInteractions, geminiTextInteractions, type GeminiTextInteractionsConfig, type GeminiTextInteractionsProviderOptions, type GeminiInteractionsStream, } from './text-interactions/adapter.js';
|
|
6
|
+
export type { GeminiInteractionsCustomEvent, GeminiInteractionsCustomEventName, GeminiInteractionsCustomEventValue, } from './text-interactions/events.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GeminiTextInteractionsAdapter, createGeminiTextInteractions, geminiTextInteractions } from "./text-interactions/adapter.js";
|
|
2
|
+
export {
|
|
3
|
+
GeminiTextInteractionsAdapter,
|
|
4
|
+
createGeminiTextInteractions,
|
|
5
|
+
geminiTextInteractions
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BaseTextAdapter, StructuredOutputOptions, StructuredOutputResult } from '@tanstack/ai/adapters';
|
|
2
|
+
import { GeminiChatModelToolCapabilitiesByName, GeminiModelInputModalitiesByName, GeminiModels } from '../../model-meta.js';
|
|
3
|
+
import { Modality, StreamChunk, TextOptions } from '@tanstack/ai';
|
|
4
|
+
import { GeminiInteractionsStream } from './events.js';
|
|
5
|
+
import { ExternalTextInteractionsProviderOptions } from './provider-options.js';
|
|
6
|
+
import { GeminiMessageMetadataByModality } from '../../message-types.js';
|
|
7
|
+
import { GeminiClientConfig } from '../../utils.js';
|
|
8
|
+
export type GeminiTextInteractionsConfig = GeminiClientConfig;
|
|
9
|
+
export type GeminiTextInteractionsProviderOptions = ExternalTextInteractionsProviderOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve provider options for a specific model. The Interactions API's
|
|
12
|
+
* request shape is the same across all chat-capable Gemini models — the
|
|
13
|
+
* SDK doesn't expose a per-model param union — so this currently falls
|
|
14
|
+
* through to the flat `GeminiTextInteractionsProviderOptions` for every
|
|
15
|
+
* model. The alias exists for parity with `GeminiTextAdapter`, so a
|
|
16
|
+
* per-model map can be slotted in later without changing the adapter
|
|
17
|
+
* signature.
|
|
18
|
+
*/
|
|
19
|
+
type ResolveProviderOptions = GeminiTextInteractionsProviderOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve input modalities for a specific model. Reuses the chat-model
|
|
22
|
+
* modality map from `model-meta.ts`: passing a `document` content block
|
|
23
|
+
* to a model that doesn't support it is a compile error, matching the
|
|
24
|
+
* sibling `GeminiTextAdapter`.
|
|
25
|
+
*/
|
|
26
|
+
type ResolveInputModalities<TModel extends string> = TModel extends keyof GeminiModelInputModalitiesByName ? GeminiModelInputModalitiesByName[TModel] : readonly ['text', 'image', 'audio', 'video', 'document'];
|
|
27
|
+
/**
|
|
28
|
+
* Resolve tool capabilities for a specific model. Reuses the chat-model
|
|
29
|
+
* capability map: `google_maps` / `google_search_retrieval` /
|
|
30
|
+
* `mcp_server` are rejected at runtime by `convertToolsToInteractionsFormat`,
|
|
31
|
+
* but per-model gating happens here at compile time.
|
|
32
|
+
*/
|
|
33
|
+
type ResolveToolCapabilities<TModel extends string> = TModel extends keyof GeminiChatModelToolCapabilitiesByName ? NonNullable<GeminiChatModelToolCapabilitiesByName[TModel]> : readonly [];
|
|
34
|
+
/**
|
|
35
|
+
* Tree-shakeable adapter for Gemini's stateful Interactions API. Routes
|
|
36
|
+
* through `client.interactions.create` and surfaces the server-assigned
|
|
37
|
+
* `interactionId` via an AG-UI `CUSTOM` event with
|
|
38
|
+
* `name: 'gemini.interactionId'` emitted just before `RUN_FINISHED`; pass
|
|
39
|
+
* that id back on the next turn via `modelOptions.previous_interaction_id`
|
|
40
|
+
* to continue the conversation without resending history.
|
|
41
|
+
*
|
|
42
|
+
* The Interactions API does NOT support stateless multi-turn replay —
|
|
43
|
+
* passing more than one message in `messages` without a
|
|
44
|
+
* `previous_interaction_id` throws. For a chat UI that maintains local
|
|
45
|
+
* history (e.g. `useChat`), see the "Wiring with `useChat`" section of
|
|
46
|
+
* `docs/adapters/gemini.md` for the canonical client/server pattern.
|
|
47
|
+
*
|
|
48
|
+
* Supports user-defined function tools and the built-in tools
|
|
49
|
+
* `google_search`, `code_execution`, `url_context`, `file_search`, and
|
|
50
|
+
* `computer_use`. Built-in tool *activity* for the four search/exec
|
|
51
|
+
* variants is surfaced via `CUSTOM` events
|
|
52
|
+
* (`gemini.googleSearchCall` / `gemini.googleSearchResult` and the
|
|
53
|
+
* corresponding per-tool variants) carrying the raw Interactions delta;
|
|
54
|
+
* see {@link GeminiInteractionsCustomEvent}. `computer_use` is accepted
|
|
55
|
+
* in the request but the Interactions API does not currently stream
|
|
56
|
+
* per-delta CUSTOM events for it. `google_search_retrieval`,
|
|
57
|
+
* `google_maps`, and `mcp_server` are not supported on this adapter.
|
|
58
|
+
*
|
|
59
|
+
* @experimental Interactions API is in Beta per Google; shapes may change.
|
|
60
|
+
* @see https://ai.google.dev/gemini-api/docs/interactions
|
|
61
|
+
*/
|
|
62
|
+
export declare class GeminiTextInteractionsAdapter<TModel extends GeminiModels, TProviderOptions extends Record<string, any> = ResolveProviderOptions, TInputModalities extends ReadonlyArray<Modality> = ResolveInputModalities<TModel>, TToolCapabilities extends ReadonlyArray<string> = ResolveToolCapabilities<TModel>> extends BaseTextAdapter<TModel, TProviderOptions, TInputModalities, GeminiMessageMetadataByModality, TToolCapabilities> {
|
|
63
|
+
readonly kind: "text";
|
|
64
|
+
readonly name: "gemini-text-interactions";
|
|
65
|
+
private readonly client;
|
|
66
|
+
private readonly interactionIdByThread;
|
|
67
|
+
constructor(config: GeminiTextInteractionsConfig, model: TModel);
|
|
68
|
+
chatStream(options: TextOptions<GeminiTextInteractionsProviderOptions>): AsyncIterable<StreamChunk>;
|
|
69
|
+
structuredOutput(options: StructuredOutputOptions<GeminiTextInteractionsProviderOptions>): Promise<StructuredOutputResult<unknown>>;
|
|
70
|
+
}
|
|
71
|
+
/** @experimental Interactions API is in Beta. */
|
|
72
|
+
export declare function createGeminiTextInteractions<TModel extends GeminiModels>(model: TModel, apiKey: string, config?: Omit<GeminiTextInteractionsConfig, 'apiKey'>): GeminiTextInteractionsAdapter<TModel, ResolveProviderOptions, ResolveInputModalities<TModel>, ResolveToolCapabilities<TModel>>;
|
|
73
|
+
/** @experimental Interactions API is in Beta. */
|
|
74
|
+
export declare function geminiTextInteractions<TModel extends GeminiModels>(model: TModel, config?: Omit<GeminiTextInteractionsConfig, 'apiKey'>): GeminiTextInteractionsAdapter<TModel, ResolveProviderOptions, ResolveInputModalities<TModel>, ResolveToolCapabilities<TModel>>;
|
|
75
|
+
export type { GeminiInteractionsStream };
|