@tanstack/ai-gemini 0.10.10 → 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/adapters/text.d.ts +7 -0
- package/dist/esm/adapters/text.js +17 -1
- package/dist/esm/adapters/text.js.map +1 -1
- 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/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/model-meta.d.ts +8 -0
- package/dist/esm/model-meta.js +8 -0
- package/dist/esm/model-meta.js.map +1 -1
- package/package.json +8 -4
- package/src/adapters/text.ts +31 -0
- 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
- package/src/index.ts +4 -1
- package/src/model-meta.ts +15 -0
package/src/adapters/text.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
generateId,
|
|
8
8
|
getGeminiApiKeyFromEnv,
|
|
9
9
|
} from '../utils'
|
|
10
|
+
import { GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS } from '../model-meta'
|
|
10
11
|
import type {
|
|
11
12
|
GEMINI_MODELS,
|
|
12
13
|
GeminiChatModelProviderOptionsByName,
|
|
@@ -857,6 +858,25 @@ export class GeminiTextAdapter<
|
|
|
857
858
|
? normalizedPrompts.map((p) => p.content).join('\n')
|
|
858
859
|
: undefined
|
|
859
860
|
|
|
861
|
+
// Native combined mode (issue #605): when the engine threads
|
|
862
|
+
// `outputSchema` through TextOptions, the adapter declared
|
|
863
|
+
// `supportsCombinedToolsAndSchema` (Gemini 3.x only). The schema is
|
|
864
|
+
// already JSON Schema (pre-converted at the activity boundary). Wire
|
|
865
|
+
// it into `config.responseSchema` + `responseMimeType: 'application/json'`
|
|
866
|
+
// alongside any `tools` — the model emits function calls during the
|
|
867
|
+
// agent loop and the schema-constrained JSON on its natural final
|
|
868
|
+
// turn, so the engine can harvest it without the separate
|
|
869
|
+
// `structuredOutput` finalization round-trip.
|
|
870
|
+
const combinedSchema = options.outputSchema as
|
|
871
|
+
| Record<string, unknown>
|
|
872
|
+
| undefined
|
|
873
|
+
const combinedSchemaConfig = combinedSchema
|
|
874
|
+
? {
|
|
875
|
+
responseMimeType: 'application/json' as const,
|
|
876
|
+
responseSchema: combinedSchema,
|
|
877
|
+
}
|
|
878
|
+
: undefined
|
|
879
|
+
|
|
860
880
|
// Vendor `GenerateContentConfig` fields are `field?: T` (no `| undefined`)
|
|
861
881
|
// under EOPT, so spread each common option only when present rather than
|
|
862
882
|
// emitting `field: undefined`s into the wire payload.
|
|
@@ -877,11 +897,22 @@ export class GeminiTextAdapter<
|
|
|
877
897
|
}),
|
|
878
898
|
...(systemInstruction !== undefined && { systemInstruction }),
|
|
879
899
|
tools: convertToolsToProviderFormat(options.tools),
|
|
900
|
+
...(combinedSchemaConfig ?? {}),
|
|
880
901
|
},
|
|
881
902
|
}
|
|
882
903
|
|
|
883
904
|
return requestOptions
|
|
884
905
|
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Gemini 3.x natively combines `tools` + `responseSchema` in a single
|
|
909
|
+
* streaming `generateContentStream` call (issue #605). Gemini 2.x is
|
|
910
|
+
* documented as brittle for the combination and keeps the engine's
|
|
911
|
+
* legacy finalization path.
|
|
912
|
+
*/
|
|
913
|
+
supportsCombinedToolsAndSchema(): boolean {
|
|
914
|
+
return GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS.has(this.model)
|
|
915
|
+
}
|
|
885
916
|
}
|
|
886
917
|
|
|
887
918
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
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 {
|
|
6
|
+
GeminiTextInteractionsAdapter,
|
|
7
|
+
createGeminiTextInteractions,
|
|
8
|
+
geminiTextInteractions,
|
|
9
|
+
type GeminiTextInteractionsConfig,
|
|
10
|
+
type GeminiTextInteractionsProviderOptions,
|
|
11
|
+
type GeminiInteractionsStream,
|
|
12
|
+
} from './text-interactions/adapter'
|
|
13
|
+
export type {
|
|
14
|
+
GeminiInteractionsCustomEvent,
|
|
15
|
+
GeminiInteractionsCustomEventName,
|
|
16
|
+
GeminiInteractionsCustomEventValue,
|
|
17
|
+
} from './text-interactions/events'
|