@alvin0/ai-agent-sdk-provider-gemini 0.1.1 → 0.1.3
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/README.md +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Runtime: **Universal** (Edge/Worker, browser, Deno, Bun, and Node).
|
|
4
4
|
|
|
5
|
+
Compatible gateways can configure `baseUrl`, `models`, `fetch`, and `headers`
|
|
6
|
+
(a string record or synchronous function returning one per operation).
|
|
7
|
+
Generation uses Interactions; embedding uses batchEmbedContents.
|
|
8
|
+
The embedding adapter/plugin also supports custom headers.
|
|
9
|
+
Header names are case-insensitive; collisions and reserved auth/transport headers
|
|
10
|
+
are rejected. Supply credentials with `apiKey`. Static records are copied;
|
|
11
|
+
prepared embedding calls keep the same header snapshot across all batches.
|
|
12
|
+
Trusted local HTTP gateways require `allowInsecureHttp: true`.
|
|
13
|
+
|
|
5
14
|
```sh
|
|
6
15
|
pnpm add @alvin0/ai-agent-sdk-core @alvin0/ai-agent-sdk-provider-gemini
|
|
7
16
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ interface GeminiAdapterOptions {
|
|
|
12
12
|
apiKey: GeminiCredential;
|
|
13
13
|
/** Endpoint base; defaults to {@link GEMINI_BASE_URL}. */
|
|
14
14
|
baseUrl?: string;
|
|
15
|
+
/** Extra endpoint headers, captured once per operation. Reserved names and collisions fail. */
|
|
16
|
+
headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
|
|
17
|
+
/** Permit cleartext HTTP explicitly for trusted local gateways. */
|
|
18
|
+
allowInsecureHttp?: boolean;
|
|
15
19
|
/** Advisory catalog; built-in context policies do not advertise model availability. */
|
|
16
20
|
models?: readonly ProviderCatalogModel[];
|
|
17
21
|
/** Whether Google may retain interactions. Defaults to false. */
|
|
@@ -65,6 +69,8 @@ declare const GEMINI_EMBEDDING_MODELS: readonly EmbeddingCatalogModel[];
|
|
|
65
69
|
interface GeminiEmbeddingProviderOptions {
|
|
66
70
|
/** Injected key or credential source; universal packages never read the environment. */
|
|
67
71
|
readonly apiKey: CredentialInput;
|
|
72
|
+
/** Extra endpoint headers, captured once per logical call; reserved names fail. */
|
|
73
|
+
readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
|
|
68
74
|
/** Endpoint base; defaults to {@link GEMINI_EMBEDDING_BASE_URL}. */
|
|
69
75
|
readonly baseUrl?: string;
|
|
70
76
|
/** Plugin id; defaults to `'gemini-embedding'`. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapter.ts","../src/embedding.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapter.ts","../src/embedding.ts"],"mappings":";;;;;;;cAyBa;KAED,mBAAmB;UAEd;;EAEf,QAAQ;;EAER;;EAEA,UAAU,SAAS,iCAAiC,SAAS;;EAE7D;;EAEA,kBAAkB;;EAElB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd,gBAAgB;EAChB,eAAe,WAAW;;iBAGZ,cAAc,SAAS,uBAAuB;UAqB7C,4BAA4B;;WAElC;;UAGM,8BAA8B,KAAK;WACzC,wBAAwB;WACxB,QAAQ;WACR;WACA;;iBAGK,aACd,SAAS,wBACR;WAA2C;;iBAC9B,aAAa,SAAS,sBAAsB;;;;cCjB/C;;;;;;;;;;;cA6CA,kCAAkC;;UAe9B;;WAEN,QAAQ;;WAER,UAAU,SAAS,iCAAiC,SAAS;;WAE7D;;WAEA;;WAEA;;WAEA,wBAAwB;;WAExB,kBAAkB;;WAElB;WACA;WACA;WACA;WACA;WACA;WACA;WACA,cAAc;WACd,eAAe,WAAW;;;;;;;;;;iBA6OrB,uBACd,SAAS,iCACR;;;;;;;;;;iBAaa,sBACd,SAAS,iCACR;WAA+C"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEmbeddingProviderPlugin, defineModelProviderPlugin } from "@alvin0/ai-agent-sdk-core/provider";
|
|
2
|
-
import { captureTransportConnection, createHttpProvider, createModelContextPolicy, createRuntimeHttpProvider, embeddingCatalogModelInfo, resolvedEmbeddingCatalogModelInfo, transportJson } from "@alvin0/ai-agent-sdk-provider-http";
|
|
2
|
+
import { captureTransportConnection, createHttpProvider, createModelContextPolicy, createRuntimeHttpProvider, embeddingCatalogModelInfo, endpointHeaders, resolvedEmbeddingCatalogModelInfo, transportJson } from "@alvin0/ai-agent-sdk-provider-http";
|
|
3
3
|
import { geminiInteractionsProtocol, geminiInteractionsProtocol as geminiInteractionsProtocol$1 } from "@alvin0/ai-agent-sdk-protocol-gemini-interactions";
|
|
4
4
|
import { assertUsableApiKey, resolveRetryPolicy } from "@alvin0/ai-agent-sdk-core";
|
|
5
5
|
import { EMBEDDING_ERROR_CODES, EmbeddingAdapter, EmbeddingError, defaultEmbeddingProfile, deriveSpaceId, resolveBatchLimits, validateBatchResult } from "@alvin0/ai-agent-sdk-core/embedding";
|
|
@@ -116,6 +116,8 @@ function runtimeDefaultModel(value, routes) {
|
|
|
116
116
|
}
|
|
117
117
|
function transportLimits(options) {
|
|
118
118
|
return {
|
|
119
|
+
...options.allowInsecureHttp === void 0 ? {} : { allowInsecureHttp: options.allowInsecureHttp },
|
|
120
|
+
headers: endpointHeaders(options.headers),
|
|
119
121
|
...options.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: options.requestTimeoutMs },
|
|
120
122
|
...options.maxRequestBytes === void 0 ? {} : { maxRequestBytes: options.maxRequestBytes },
|
|
121
123
|
...options.maxResponseBytes === void 0 ? {} : { maxResponseBytes: options.maxResponseBytes },
|
|
@@ -226,11 +228,13 @@ const GEMINI_EMBEDDING_MODELS = Object.freeze([Object.freeze({
|
|
|
226
228
|
*/
|
|
227
229
|
var GeminiEmbeddingAdapter = class extends EmbeddingAdapter {
|
|
228
230
|
#options;
|
|
231
|
+
#headers;
|
|
229
232
|
#models;
|
|
230
233
|
#retryPolicy;
|
|
231
234
|
constructor(options) {
|
|
232
235
|
super();
|
|
233
236
|
this.#options = Object.freeze({ ...options });
|
|
237
|
+
this.#headers = endpointHeaders(options.headers);
|
|
234
238
|
this.#models = Object.freeze([...options.models ?? GEMINI_EMBEDDING_MODELS]);
|
|
235
239
|
this.#retryPolicy = resolveRetryPolicy(options.retryPolicy, "retryPolicy");
|
|
236
240
|
}
|
|
@@ -303,10 +307,14 @@ var GeminiEmbeddingAdapter = class extends EmbeddingAdapter {
|
|
|
303
307
|
/** Resolve the credential and bounds into one frozen snapshot. */
|
|
304
308
|
async #connect(signal, context) {
|
|
305
309
|
const options = this.#options;
|
|
310
|
+
const extraHeaders = this.#headers();
|
|
306
311
|
const apiKey = assertUsableApiKey(await resolveCredential(options.apiKey, signal, context), DISPLAY_NAME, "the `apiKey` option");
|
|
307
312
|
return captureTransportConnection({
|
|
308
313
|
baseUrl: options.baseUrl ?? "https://generativelanguage.googleapis.com/v1beta",
|
|
309
|
-
headers: Object.freeze({
|
|
314
|
+
headers: Object.freeze({
|
|
315
|
+
...extraHeaders,
|
|
316
|
+
"x-goog-api-key": apiKey
|
|
317
|
+
}),
|
|
310
318
|
models: this.#models,
|
|
311
319
|
retryPolicy: this.#retryPolicy,
|
|
312
320
|
...options.allowInsecureHttp === void 0 ? {} : { allowInsecureHttp: options.allowInsecureHttp },
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["geminiInteractionsProtocol"],"sources":["../src/context-policy.ts","../src/adapter.ts","../src/embedding.ts"],"sourcesContent":["import { createModelContextPolicy } from '@alvin0/ai-agent-sdk-provider-http'\nimport type { ModelContextPolicyOptions } from '@alvin0/ai-agent-sdk-provider-http'\n\n// Verified 2026-09-13: https://ai.google.dev/gemini-api/docs/pricing\n// Google publishes separate input/output limits; do not invent a combined ceiling.\nconst PRO = { defaultContextWindow: 200_000, standardPriceInputTokens: 200_000 }\nexport function geminiContextPolicy(options: ModelContextPolicyOptions) {\n return createModelContextPolicy(\n options.baseUrl === undefined || options.baseUrl.replace(/\\/$/, '') === 'https://generativelanguage.googleapis.com/v1beta'\n ? {\n 'gemini-3.1-pro-preview': PRO, 'gemini-3.1-pro-preview-customtools': PRO, 'gemini-2.5-pro': PRO,\n 'gemini-2.5-flash': { defaultContextWindow: 1_000_000 },\n 'gemini-3-flash-preview': { defaultContextWindow: 1_000_000 },\n }\n : {}, options.models, options.defaultContextWindow)\n}\n","import type { ModelProviderPlugin, ModelProviderRegistrar, RetryPolicyConfig } from '@alvin0/ai-agent-sdk-core'\nimport {\n defineModelProviderPlugin,\n type ComposableModelProviderPlugin,\n type CredentialInput,\n type ModelTarget,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n HttpModelAdapter,\n ProviderCatalogModel,\n ProviderRequestLogger,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n createHttpProvider,\n createRuntimeHttpProvider,\n type CredentialSource,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n geminiInteractionsProtocol,\n type GeminiInteractionsDialect,\n} from '@alvin0/ai-agent-sdk-protocol-gemini-interactions'\nimport { geminiContextPolicy } from './context-policy.ts'\n\n/** Google Gemini API v1beta base. The protocol appends only `/interactions`. */\nexport const GEMINI_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n\nexport type GeminiCredential = CredentialSource\n\nexport interface GeminiAdapterOptions {\n /** Injected API key or resolver. Universal packages never read environment variables. */\n apiKey: GeminiCredential\n /** Endpoint base; defaults to {@link GEMINI_BASE_URL}. */\n baseUrl?: string\n /** Advisory catalog; built-in context policies do not advertise model availability. */\n models?: readonly ProviderCatalogModel[]\n /** Whether Google may retain interactions. Defaults to false. */\n store?: boolean\n defaultMaxTokens?: number\n defaultContextWindow?: number\n streamIdleTimeoutMs?: number\n requestTimeoutMs?: number\n maxRequestBytes?: number\n maxResponseBytes?: number\n maxResponseChunks?: number\n maxSseEvents?: number\n maxSseEventChars?: number\n maxErrorBodyBytes?: number\n requestLoggerTimeoutMs?: number\n retryPolicy?: RetryPolicyConfig\n requestLogger?: ProviderRequestLogger\n fetch?: typeof globalThis.fetch\n}\n\nexport function geminiAdapter(options: GeminiAdapterOptions): HttpModelAdapter {\n return createHttpProvider({\n displayName: 'Gemini',\n describeModel: geminiContextPolicy(options),\n protocol: geminiInteractionsProtocol,\n baseUrl: options.baseUrl ?? GEMINI_BASE_URL,\n auth: {\n kind: 'header', name: 'x-goog-api-key', value: options.apiKey,\n label: 'the `apiKey` option',\n },\n dialect: dialectOf(options),\n ...(options.models === undefined ? {} : { models: options.models }),\n defaultMaxTokens: options.defaultMaxTokens ?? 8_192,\n defaultContextWindow: options.defaultContextWindow ?? 200_000,\n ...(options.streamIdleTimeoutMs === undefined ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs }),\n ...transportLimits(options),\n ...(options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy }),\n ...(options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger }),\n })\n}\n\nexport interface GeminiPluginOptions extends GeminiAdapterOptions {\n /** Registry routes installed by the plugin. Defaults to `['gemini']`. */\n readonly routes?: readonly string[]\n}\n\nexport interface GeminiProviderOptions extends Omit<GeminiAdapterOptions, 'apiKey'> {\n readonly defaultModel?: string | ModelTarget\n readonly apiKey: CredentialInput\n readonly id?: string\n readonly routes?: readonly string[]\n}\n\nexport function geminiPlugin(\n options: GeminiProviderOptions,\n): ComposableModelProviderPlugin & { readonly family: 'gemini' }\nexport function geminiPlugin(options: GeminiPluginOptions): ModelProviderPlugin\nexport function geminiPlugin(\n options: GeminiProviderOptions | GeminiPluginOptions,\n): ModelProviderPlugin | (ComposableModelProviderPlugin & { readonly family: 'gemini' }) {\n if (!usesRuntimeComposition(options)) return legacyGeminiPlugin(options)\n const id = options.id ?? 'gemini'\n const routes = Object.freeze([...(options.routes ?? [id])])\n return defineModelProviderPlugin({\n id,\n family: 'gemini',\n displayName: 'Gemini',\n routes,\n ...runtimeDefaultModel(options.defaultModel, routes),\n setup(registrar) {\n const remove = registrar.registerAdapter(createRuntimeGeminiAdapter(options))\n return () => { remove(); return undefined }\n },\n }) as ComposableModelProviderPlugin & { readonly family: 'gemini' }\n}\n\nfunction legacyGeminiPlugin(options: GeminiPluginOptions): ModelProviderPlugin {\n const routes = Object.freeze([...(options.routes ?? ['gemini'])])\n const adapter = geminiAdapter(options)\n return Object.freeze({\n id: 'gemini',\n displayName: 'Gemini',\n setup(registrar: ModelProviderRegistrar) {\n registrar.registerAdapter(routes, adapter)\n },\n })\n}\n\nfunction createRuntimeGeminiAdapter(options: GeminiProviderOptions): HttpModelAdapter {\n return createRuntimeHttpProvider({\n describeModel: geminiContextPolicy(options),\n displayName: 'Gemini',\n protocol: geminiInteractionsProtocol,\n baseUrl: options.baseUrl ?? GEMINI_BASE_URL,\n auth: {\n kind: 'header', name: 'x-goog-api-key', value: options.apiKey,\n label: 'the `apiKey` option',\n },\n dialect: dialectOf(options),\n ...(options.models === undefined ? {} : { models: options.models }),\n defaultMaxTokens: options.defaultMaxTokens ?? 8_192,\n defaultContextWindow: options.defaultContextWindow ?? 200_000,\n ...(options.streamIdleTimeoutMs === undefined ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs }),\n ...transportLimits(options),\n ...(options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy }),\n ...(options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger }),\n })\n}\n\nfunction dialectOf(options: Pick<GeminiAdapterOptions, 'store'>): Partial<GeminiInteractionsDialect> {\n return options.store === undefined ? {} : { store: options.store }\n}\n\nfunction usesRuntimeComposition(\n options: GeminiProviderOptions | GeminiPluginOptions,\n): options is GeminiProviderOptions {\n if ('id' in options || 'defaultModel' in options) return true\n if (typeof options.apiKey === 'object' && options.apiKey !== null) return true\n if (typeof options.apiKey !== 'function') return true\n // Node's envCredential keeps a backwards-compatible callable surface while\n // also carrying the versioned CredentialSource marker used by composition.\n return 'kind' in options.apiKey && options.apiKey.kind === 'credential-source'\n}\n\nfunction runtimeDefaultModel(\n value: string | ModelTarget | undefined,\n routes: readonly string[],\n): { readonly defaultModel?: ModelTarget } {\n if (value === undefined) return {}\n if (typeof value !== 'string') return { defaultModel: value }\n if (routes.length !== 1) throw new TypeError('A string defaultModel requires exactly one Gemini route')\n return { defaultModel: Object.freeze({ provider: routes[0]!, id: value }) }\n}\n\nfunction transportLimits(options: GeminiAdapterOptions | GeminiProviderOptions) {\n return {\n ...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n ...(options.maxRequestBytes === undefined ? {} : { maxRequestBytes: options.maxRequestBytes }),\n ...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n ...(options.maxResponseChunks === undefined ? {} : { maxResponseChunks: options.maxResponseChunks }),\n ...(options.maxSseEvents === undefined ? {} : { maxSseEvents: options.maxSseEvents }),\n ...(options.maxSseEventChars === undefined ? {} : { maxSseEventChars: options.maxSseEventChars }),\n ...(options.maxErrorBodyBytes === undefined ? {} : { maxErrorBodyBytes: options.maxErrorBodyBytes }),\n ...(options.requestLoggerTimeoutMs === undefined ? {} : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n }\n}\n","/**\n * `Gemini_Embedding_Adapter`: Gemini's `batchEmbedContents` endpoint expressed as\n * an `Embedding_Adapter`.\n *\n * Deliberately separate from `./adapter.ts`: nothing here imports\n * `geminiInteractionsProtocol`, and nothing there imports this module. Generation\n * and embedding share the same credential shape and the same HTTP transport, and\n * that is all they share — a request vocabulary in common would be the conflation\n * Requirement 14.2 rules out.\n *\n * Three Gemini specifics shape this file, and each one is stated rather than\n * inferred:\n *\n * - **Purpose is a wire parameter.** `taskType` exists, so `purpose` translates\n * into it — but only when the route DECLARES that mechanism. A route that\n * declares nothing gets the text sent verbatim and no invented parameter\n * (Requirement 7.3).\n * - **A narrower vector is a model mechanism plus a recorded step.**\n * `outputDimensionality` asks the model for a narrower vector; Gemini\n * documents that a narrower vector is no longer unit-length, so the profile\n * declares `postProcessing: { kind: 'l2-renormalize', revision: '1' }` and this\n * adapter performs exactly that step. Nothing here slices or pads a vector\n * (Requirement 9.8).\n * - **Mapping is positional.** `batchEmbedContents` returns\n * `{ embeddings: [{ values }] }` with no index, so the index is assigned by\n * this adapter from request order, and the count is checked rather than\n * assumed.\n *\n * @module ai-agent-sdk/providers/gemini/embedding\n */\n\nimport {\n assertUsableApiKey,\n resolveRetryPolicy,\n type ModelInvocationContext,\n type ProviderInfo,\n type ResolvedRetryPolicy,\n type RetryPolicyConfig,\n type SdkLogger,\n} from '@alvin0/ai-agent-sdk-core'\nimport {\n EMBEDDING_ERROR_CODES,\n EmbeddingAdapter,\n EmbeddingError,\n defaultEmbeddingProfile,\n deriveSpaceId,\n resolveBatchLimits,\n validateBatchResult,\n type EmbeddingBatchRequest,\n type EmbeddingBatchResult,\n type EmbeddingModelInfo,\n type EmbeddingPostProcessing,\n type EmbeddingProfile,\n type EmbeddingProfileInput,\n type EmbeddingPurpose,\n type EmbeddingVector,\n type PrepareEmbeddingOptions,\n type PreparedEmbeddingCall,\n type ResolvedEmbeddingModelInfo,\n} from '@alvin0/ai-agent-sdk-core/embedding'\nimport {\n defineEmbeddingProviderPlugin,\n type ComposableEmbeddingProviderPlugin,\n type CredentialInput,\n type ModelTarget,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n captureTransportConnection,\n embeddingCatalogModelInfo,\n resolvedEmbeddingCatalogModelInfo,\n transportJson,\n type EmbeddingCatalogModel,\n type EmbeddingHttpConnection,\n} from '@alvin0/ai-agent-sdk-provider-http'\n\n/** Google Generative Language API v1beta base; the adapter appends the model path. */\nexport const GEMINI_EMBEDDING_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n\n/** Name used in every diagnostic this module raises. */\nconst DISPLAY_NAME = 'Gemini'\n\n/** Header layer the JSON pipeline owns for this route. */\nconst TRANSPORT_HEADERS = Object.freeze({\n 'content-type': 'application/json',\n accept: 'application/json',\n})\n\n/** Revision of the `l2-renormalize` step this adapter performs. */\nconst POST_PROCESSING_REVISION = '1'\n\n/** Applied when neither the caller nor the catalog says otherwise. */\nconst DEFAULT_RECIPE_REVISION = '1'\n\n/** The one mapping from this SDK's purpose vocabulary to Gemini's `taskType`. */\nconst TASK_TYPES: Readonly<Record<EmbeddingPurpose, string>> = Object.freeze({\n 'retrieval-query': 'RETRIEVAL_QUERY',\n 'retrieval-document': 'RETRIEVAL_DOCUMENT',\n})\n\nconst NEVER_ABORTED_SIGNAL = new AbortController().signal\n\nconst NULL_LOGGER: SdkLogger = Object.freeze({\n child: () => NULL_LOGGER,\n trace: () => undefined,\n debug: () => undefined,\n info: () => undefined,\n warn: () => undefined,\n error: () => undefined,\n fatal: () => undefined,\n})\n\n/**\n * The Gemini embedding generations this package declares.\n *\n * Unlike the generation catalog, an embedding catalog entry cannot be omitted\n * entirely: `compatibilityIdentity` is a claim about an embedding space that only\n * the route can make, and Requirement 14.6 puts that claim on this adapter. The\n * identity names the GENERATION, so `gemini-embedding-001` and a future\n * `gemini-embedding-2` are detected as incompatible even at equal width. Pass\n * `models` to override or extend this list.\n */\nexport const GEMINI_EMBEDDING_MODELS: readonly EmbeddingCatalogModel[] = Object.freeze([\n Object.freeze({\n id: 'gemini-embedding-001',\n name: 'Gemini Embedding 001',\n description: 'Gemini text embedding with selectable output dimensionality.',\n dimensions: Object.freeze([3072, 1536, 768]),\n defaultDimensions: 3072,\n maxInputTokens: 2048,\n maxBatchItems: 100,\n purposeHandling: Object.freeze({ kind: 'wire-parameter' as const, parameter: 'taskType' }),\n compatibilityIdentity: 'google:gemini-embedding-001',\n }),\n])\n\n/** Configuration for {@link geminiEmbeddingAdapter} and {@link geminiEmbeddingPlugin}. */\nexport interface GeminiEmbeddingProviderOptions {\n /** Injected key or credential source; universal packages never read the environment. */\n readonly apiKey: CredentialInput\n /** Endpoint base; defaults to {@link GEMINI_EMBEDDING_BASE_URL}. */\n readonly baseUrl?: string\n /** Plugin id; defaults to `'gemini-embedding'`. */\n readonly id?: string\n /** Routes the plugin claims; defaults to `[id]`. */\n readonly routes?: readonly string[]\n /** Default model for the claimed route. */\n readonly defaultModel?: string | ModelTarget\n /** Declared embedding catalog; defaults to {@link GEMINI_EMBEDDING_MODELS}. */\n readonly models?: readonly EmbeddingCatalogModel[]\n /** Permit cleartext HTTP explicitly, for a trusted local endpoint only. */\n readonly allowInsecureHttp?: boolean\n readonly requestTimeoutMs?: number\n readonly maxRequestBytes?: number\n readonly maxResponseBytes?: number\n readonly maxResponseChunks?: number\n readonly maxErrorBodyBytes?: number\n readonly requestLoggerTimeoutMs?: number\n readonly retryPolicy?: RetryPolicyConfig\n readonly fetch?: typeof globalThis.fetch\n}\n\n/** What the JSON pipeline hands back: the parsed body plus its correlation id. */\ninterface GeminiEmbedResponse {\n readonly payload: unknown\n readonly providerRequestId?: string\n}\n\n/** One request element of Gemini's `batchEmbedContents` body. */\ninterface GeminiEmbedRequest {\n readonly model: string\n readonly content: { readonly parts: readonly { readonly text: string }[] }\n readonly outputDimensionality?: number\n readonly [parameter: string]: unknown\n}\n\n/**\n * The Gemini `batchEmbedContents` adapter.\n *\n * Every metadata method takes the route key, so one instance serves every route\n * the plugin claims. Connection facts are captured once per operation in\n * {@link prepareEmbeddingCall}, which is what keeps a credential from travelling\n * to a URL from a different configuration generation.\n */\nclass GeminiEmbeddingAdapter extends EmbeddingAdapter {\n readonly #options: GeminiEmbeddingProviderOptions\n readonly #models: readonly EmbeddingCatalogModel[]\n readonly #retryPolicy: ResolvedRetryPolicy\n\n constructor(options: GeminiEmbeddingProviderOptions) {\n super()\n this.#options = Object.freeze({ ...options })\n this.#models = Object.freeze([...(options.models ?? GEMINI_EMBEDDING_MODELS)])\n this.#retryPolicy = resolveRetryPolicy(options.retryPolicy, 'retryPolicy')\n }\n\n override providerInfo(provider: string): ProviderInfo {\n return { id: provider, name: DISPLAY_NAME }\n }\n\n override providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined {\n return this.#retryPolicy\n }\n\n override listEmbeddingModels(\n provider: string,\n _signal?: AbortSignal,\n ): Promise<readonly EmbeddingModelInfo[]> {\n return Promise.resolve(Object.freeze(\n this.#models.map(model => embeddingCatalogModelInfo(provider, model)),\n ))\n }\n\n override resolveEmbeddingModel(\n provider: string,\n model: string,\n _signal?: AbortSignal,\n ): Promise<ResolvedEmbeddingModelInfo> {\n return Promise.resolve(resolvedEmbeddingCatalogModelInfo(provider, model, this.#models))\n }\n\n /**\n * Declare the real Gemini profile instead of accepting the generic default.\n *\n * Two statements the default cannot make: the compatibility identity is the\n * route's declaration about a GENERATION, and asking for a narrower vector adds\n * a recorded `l2-renormalize` step which this adapter then actually performs.\n */\n override embeddingProfile(\n model: ResolvedEmbeddingModelInfo,\n request: EmbeddingProfileInput,\n ): EmbeddingProfile {\n const base = defaultEmbeddingProfile(model, request)\n const postProcessing = postProcessingFor(model, base.dimensions)\n return Object.freeze({\n ...base,\n compatibilityIdentity: model.compatibilityIdentity.state === 'supported'\n ? model.compatibilityIdentity.value\n : `google:${model.id}`,\n // Truthful either way: `unit-l2` only where this adapter normalizes, and\n // otherwise whatever the route declared — never inferred from the width.\n normalization: postProcessing !== undefined\n ? 'unit-l2'\n : model.normalization.state === 'supported'\n ? model.normalization.value\n : 'unknown',\n documentRecipeRevision: request.documentRecipeRevision ?? DEFAULT_RECIPE_REVISION,\n queryRecipeRevision: request.queryRecipeRevision ?? DEFAULT_RECIPE_REVISION,\n ...(postProcessing === undefined ? {} : { postProcessing }),\n })\n }\n\n /**\n * Capture the endpoint, the credential and the catalog together, once.\n *\n * The connection is read here and never re-read per batch, so every batch of\n * one `Logical_Call` goes out through the same generation of configuration\n * that its dimensions were checked against.\n */\n override async prepareEmbeddingCall(\n provider: string,\n model: string,\n options: PrepareEmbeddingOptions,\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n ): Promise<PreparedEmbeddingCall> {\n const resolved = await this.resolveEmbeddingModel(provider, model, signal)\n const profile = this.embeddingProfile(resolved, options)\n const connection = await this.#connect(signal, context)\n return Object.freeze({\n model: resolved,\n profile,\n spaceId: deriveSpaceId(profile),\n limits: resolveBatchLimits(resolved, options.limits),\n embedBatch: (batch: EmbeddingBatchRequest, invocation = context) =>\n this.#dispatch(connection, resolved, profile, batch, invocation),\n })\n }\n\n /**\n * Perform exactly one `batchEmbedContents` request.\n *\n * Usable directly, in which case the catalog and connection are resolved for\n * this batch alone; `prepareEmbeddingCall` is the path that binds one snapshot\n * to a whole logical call.\n */\n override async embedBatch(\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult> {\n const resolved = await this.resolveEmbeddingModel(batch.provider, batch.model, batch.signal)\n const profile = this.embeddingProfile(resolved, {\n ...(batch.dimensions === undefined ? {} : { dimensions: batch.dimensions }),\n })\n const connection = await this.#connect(batch.signal, context)\n return await this.#dispatch(connection, resolved, profile, batch, context)\n }\n\n /** Resolve the credential and bounds into one frozen snapshot. */\n async #connect(\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingHttpConnection> {\n const options = this.#options\n const apiKey = assertUsableApiKey(\n await resolveCredential(options.apiKey, signal, context),\n DISPLAY_NAME,\n 'the `apiKey` option',\n )\n // Attribution headers are merged by the transport, so no embedding adapter\n // can forget them (Requirement 14.7).\n return captureTransportConnection<EmbeddingHttpConnection>({\n baseUrl: options.baseUrl ?? GEMINI_EMBEDDING_BASE_URL,\n headers: Object.freeze({ 'x-goog-api-key': apiKey }),\n models: this.#models,\n retryPolicy: this.#retryPolicy,\n ...(options.allowInsecureHttp === undefined\n ? {}\n : { allowInsecureHttp: options.allowInsecureHttp }),\n ...(options.requestTimeoutMs === undefined\n ? {}\n : { requestTimeoutMs: options.requestTimeoutMs }),\n ...(options.maxRequestBytes === undefined ? {} : { maxRequestBytes: options.maxRequestBytes }),\n ...(options.maxResponseBytes === undefined\n ? {}\n : { maxResponseBytes: options.maxResponseBytes }),\n ...(options.maxResponseChunks === undefined\n ? {}\n : { maxResponseChunks: options.maxResponseChunks }),\n ...(options.maxErrorBodyBytes === undefined\n ? {}\n : { maxErrorBodyBytes: options.maxErrorBodyBytes }),\n ...(options.requestLoggerTimeoutMs === undefined\n ? {}\n : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n }, TRANSPORT_HEADERS)\n }\n\n /** One `Provider_Attempt`: build the body, send it, decode the response. */\n async #dispatch(\n connection: EmbeddingHttpConnection,\n model: ResolvedEmbeddingModelInfo,\n profile: EmbeddingProfile,\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult> {\n if (batch.truncation === 'allow') {\n throw new EmbeddingError(\n 'Gemini batchEmbedContents exposes no truncation parameter',\n EMBEDDING_ERROR_CODES.TRUNCATION_UNSUPPORTED,\n { provider: batch.provider, model: batch.model },\n )\n }\n const modelId = bareModelId(batch.model)\n const body = { requests: batch.items.map(item => embedRequest(item, model, batch, modelId)) }\n const encoded = JSON.stringify(body)\n // The transport chain owns transport failures and normalizes anything thrown\n // inside `decode` into a ModelError, which would flatten this adapter's\n // embedding codes. So `decode` only extracts the payload, and contract\n // validation runs here, where an EmbeddingError reaches the caller intact.\n const received = await transportJson({\n connection,\n displayName: DISPLAY_NAME,\n provider: batch.provider,\n model: batch.model,\n path: `/models/${encodeURIComponent(modelId)}:batchEmbedContents`,\n accept: 'application/json',\n body: {\n value: body,\n encoded,\n bytes: new TextEncoder().encode(encoded).length,\n },\n ...(batch.signal === undefined ? {} : { signal: batch.signal }),\n ...(context === undefined ? {} : { context }),\n }, (session, payload) => Object.freeze({\n payload,\n ...(session.providerRequestId === undefined\n ? {}\n : { providerRequestId: session.providerRequestId }),\n }))\n return decodeBatch(batch, profile, received)\n }\n}\n\n/**\n * Create the Gemini embedding adapter.\n *\n * No I/O happens here: the credential is resolved per operation, not at\n * construction.\n * @param options - route configuration.\n * @returns an adapter registrable under any number of routes.\n */\nexport function geminiEmbeddingAdapter(\n options: GeminiEmbeddingProviderOptions,\n): EmbeddingAdapter {\n return new GeminiEmbeddingAdapter(options)\n}\n\n/**\n * Create the Gemini `Embedding_Provider_Plugin`.\n *\n * Its `kind` is `'embedding-provider-plugin'`, so a generation host never\n * mistakes it for {@link geminiPlugin} and neither plugin needs a version bump\n * because of the other (Requirement 11.1).\n * @param options - route configuration.\n * @returns an inert plugin; registration happens during runtime activation.\n */\nexport function geminiEmbeddingPlugin(\n options: GeminiEmbeddingProviderOptions,\n): ComposableEmbeddingProviderPlugin & { readonly family: 'gemini' } {\n const id = options.id ?? 'gemini-embedding'\n const routes = Object.freeze([...(options.routes ?? [id])])\n const adapter = geminiEmbeddingAdapter(options)\n return defineEmbeddingProviderPlugin({\n id,\n family: 'gemini',\n displayName: DISPLAY_NAME,\n routes,\n ...defaultModelTarget(options.defaultModel, routes),\n setup(registrar) {\n const remove = registrar.registerEmbeddingAdapter(adapter)\n return () => {\n remove()\n return undefined\n }\n },\n }) as ComposableEmbeddingProviderPlugin & { readonly family: 'gemini' }\n}\n\n/** Resolve a literal key or a credential source, without caching the secret. */\nasync function resolveCredential(\n apiKey: CredentialInput,\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n): Promise<string> {\n if (typeof apiKey === 'string') return apiKey\n return await apiKey.resolve({\n signal: signal ?? NEVER_ABORTED_SIGNAL,\n logger: context?.logger ?? NULL_LOGGER,\n })\n}\n\n/** Accept both `gemini-embedding-001` and the `models/`-prefixed resource name. */\nfunction bareModelId(model: string): string {\n return model.startsWith('models/') ? model.slice('models/'.length) : model\n}\n\n/**\n * Build one request element.\n *\n * `taskType` appears only when the route DECLARES a wire parameter for purpose,\n * and it is spelled with the declared parameter name. A route that declares\n * nothing gets the text verbatim — an undeclared parameter would be this adapter\n * inventing a mechanism (Requirement 7.3).\n */\nfunction embedRequest(\n item: EmbeddingBatchRequest['items'][number],\n model: ResolvedEmbeddingModelInfo,\n batch: EmbeddingBatchRequest,\n modelId: string,\n): GeminiEmbedRequest {\n const purposeHandling = model.purposeHandling\n const wireParameter = purposeHandling.state === 'supported'\n && purposeHandling.value.kind === 'wire-parameter'\n ? purposeHandling.value.parameter\n : undefined\n const width = outputDimensionality(model, batch)\n return {\n model: `models/${modelId}`,\n content: {\n parts: item.contentParts.map(part => ({ text: part.text })),\n },\n ...(wireParameter === undefined ? {} : { [wireParameter]: TASK_TYPES[batch.purpose] }),\n ...(width === undefined ? {} : { outputDimensionality: width }),\n }\n}\n\n/**\n * `outputDimensionality` travels only when the route declares selectable widths.\n *\n * With an `unknown` declaration there is nothing saying the parameter exists, and\n * sending it anyway would make a capability claim on the route's behalf\n * (Requirement 14.4).\n */\nfunction outputDimensionality(\n model: ResolvedEmbeddingModelInfo,\n batch: EmbeddingBatchRequest,\n): number | undefined {\n if (batch.dimensions === undefined) return undefined\n return model.dimensions.state === 'supported' ? batch.dimensions : undefined\n}\n\n/**\n * The recorded step a narrower-than-native vector needs.\n *\n * Gemini documents that only the native width comes back unit-length, so a\n * narrower request declares `l2-renormalize` in the profile and this adapter\n * performs exactly that. It is NOT a slice or a pad: the model produced the\n * narrower vector itself (Requirement 9.8).\n */\nfunction postProcessingFor(\n model: ResolvedEmbeddingModelInfo,\n dimensions: number,\n): EmbeddingPostProcessing | undefined {\n if (model.defaultDimensions.state !== 'supported') return undefined\n const native = model.defaultDimensions.value\n if (dimensions <= 0 || dimensions >= native) return undefined\n return Object.freeze({ kind: 'l2-renormalize' as const, revision: POST_PROCESSING_REVISION })\n}\n\n/**\n * Turn one response into vectors, positionally, with the count checked.\n *\n * Order: structural shape, then count, then the SHARED\n * {@link validateBatchResult} — so the same malformed response yields the same\n * code here as it does for any other provider — and only then the recorded\n * post-processing step.\n */\nfunction decodeBatch(\n batch: EmbeddingBatchRequest,\n profile: EmbeddingProfile,\n received: GeminiEmbedResponse,\n): EmbeddingBatchResult {\n const embeddings = readEmbeddings(batch, received.payload)\n if (embeddings.length !== batch.items.length) {\n throw new EmbeddingError(\n `Gemini returned ${embeddings.length} embeddings for ${batch.items.length} inputs`,\n EMBEDDING_ERROR_CODES.VECTOR_COUNT_MISMATCH,\n { provider: batch.provider, model: batch.model },\n )\n }\n // Positional mapping: the response carries no index, so the index comes from\n // request order — which is only sound because the length was just checked.\n const vectors = embeddings.map((embedding, position) => Object.freeze<EmbeddingVector>({\n index: batch.items[position]!.index,\n values: readValues(batch, embedding, batch.items[position]!.index),\n }))\n const raw: EmbeddingBatchResult = Object.freeze({\n vectors: Object.freeze(vectors),\n ...(received.providerRequestId === undefined\n ? {}\n : { providerRequestId: received.providerRequestId }),\n })\n validateBatchResult(batch, raw)\n // `batchEmbedContents` reports no usage at all, so no `usage` field is set on\n // the result — not an empty object and not a zero. The absence is what the\n // runtime aggregator reads to report `status: 'missing'` plus a\n // `usage-unreported` warning, and stating it here as well would double the\n // warning for one batch (Requirement 16.2).\n return applyPostProcessing(raw, profile)\n}\n\n/** Read `embeddings[]`, refusing any other shape rather than guessing at it. */\nfunction readEmbeddings(batch: EmbeddingBatchRequest, payload: unknown): readonly unknown[] {\n if (typeof payload !== 'object' || payload === null) {\n throw malformed(batch, 'Gemini response is not a JSON object')\n }\n const embeddings = Reflect.get(payload, 'embeddings')\n if (!Array.isArray(embeddings)) {\n throw malformed(batch, 'Gemini response carries no embeddings array')\n }\n return embeddings as readonly unknown[]\n}\n\n/** Read one `values[]`, leaving every number exactly as the provider sent it. */\nfunction readValues(\n batch: EmbeddingBatchRequest,\n embedding: unknown,\n index: number,\n): readonly number[] {\n if (typeof embedding !== 'object' || embedding === null) {\n throw malformed(batch, 'Gemini embedding entry is not an object', index)\n }\n const values = Reflect.get(embedding, 'values')\n if (!Array.isArray(values)) {\n throw malformed(batch, 'Gemini embedding entry carries no values array', index)\n }\n return Object.freeze([...values as readonly number[]])\n}\n\n/** One place the structural-failure code is spelled. */\nfunction malformed(\n batch: EmbeddingBatchRequest,\n message: string,\n index?: number,\n): EmbeddingError {\n return new EmbeddingError(message, EMBEDDING_ERROR_CODES.RESPONSE_MALFORMED, {\n provider: batch.provider,\n model: batch.model,\n ...(index === undefined ? {} : { itemIndexes: [index] }),\n })\n}\n\n/**\n * Perform the step the profile declares, and nothing else.\n *\n * A profile with no `postProcessing` returns the provider's values untouched, so\n * the vectors a caller receives are faithful to what came back (Property 22). A\n * zero vector has no direction to preserve, so it is passed through rather than\n * turned into `NaN`.\n */\nfunction applyPostProcessing(\n result: EmbeddingBatchResult,\n profile: EmbeddingProfile,\n): EmbeddingBatchResult {\n if (profile.postProcessing?.kind !== 'l2-renormalize') return result\n return Object.freeze({\n ...result,\n vectors: Object.freeze(result.vectors.map(vector => Object.freeze<EmbeddingVector>({\n ...vector,\n values: l2Renormalize(vector.values),\n }))),\n })\n}\n\n/** Scale a vector to unit L2 length. */\nfunction l2Renormalize(values: readonly number[]): readonly number[] {\n let sum = 0\n for (const value of values) sum += value * value\n const norm = Math.sqrt(sum)\n if (!Number.isFinite(norm) || norm === 0) return values\n return Object.freeze(values.map(value => value / norm))\n}\n\n/** A string default model needs exactly one route to belong to. */\nfunction defaultModelTarget(\n value: string | ModelTarget | undefined,\n routes: readonly string[],\n): { readonly defaultModel?: ModelTarget } {\n if (value === undefined) return {}\n if (typeof value !== 'string') return { defaultModel: value }\n if (routes.length !== 1) {\n throw new TypeError('A string defaultModel requires exactly one Gemini embedding route')\n }\n return { defaultModel: Object.freeze({ provider: routes[0]!, id: value }) }\n}\n"],"mappings":";;;;;;;AAKA,MAAM,MAAM;CAAE,sBAAsB;CAAS,0BAA0B;AAAQ;AAC/E,SAAgB,oBAAoB,SAAoC;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;CAC3C,MAAM,OAAO,KAAK,KAAK,GAAG;CAC1B,IAAI,CAAC,OAAO,SAAS,IAAI,KAAK,SAAS,GAAG,OAAO;CACjD,OAAO,OAAO,OAAO,OAAO,KAAI,UAAS,QAAQ,IAAI,CAAC;AACxD;;AAGA,SAAS,mBACP,OACA,QACyC;CACzC,IAAI,UAAU,QAAW,OAAO,CAAC;CACjC,IAAI,OAAO,UAAU,UAAU,OAAO,EAAE,cAAc,MAAM;CAC5D,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,UAAU,mEAAmE;CAEzF,OAAO,EAAE,cAAc,OAAO,OAAO;EAAE,UAAU,OAAO;EAAK,IAAI;CAAM,CAAC,EAAE;AAC5E"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["geminiInteractionsProtocol"],"sources":["../src/context-policy.ts","../src/adapter.ts","../src/embedding.ts"],"sourcesContent":["import { createModelContextPolicy } from '@alvin0/ai-agent-sdk-provider-http'\nimport type { ModelContextPolicyOptions } from '@alvin0/ai-agent-sdk-provider-http'\n\n// Verified 2026-09-13: https://ai.google.dev/gemini-api/docs/pricing\n// Google publishes separate input/output limits; do not invent a combined ceiling.\nconst PRO = { defaultContextWindow: 200_000, standardPriceInputTokens: 200_000 }\nexport function geminiContextPolicy(options: ModelContextPolicyOptions) {\n return createModelContextPolicy(\n options.baseUrl === undefined || options.baseUrl.replace(/\\/$/, '') === 'https://generativelanguage.googleapis.com/v1beta'\n ? {\n 'gemini-3.1-pro-preview': PRO, 'gemini-3.1-pro-preview-customtools': PRO, 'gemini-2.5-pro': PRO,\n 'gemini-2.5-flash': { defaultContextWindow: 1_000_000 },\n 'gemini-3-flash-preview': { defaultContextWindow: 1_000_000 },\n }\n : {}, options.models, options.defaultContextWindow)\n}\n","import type { ModelProviderPlugin, ModelProviderRegistrar, RetryPolicyConfig } from '@alvin0/ai-agent-sdk-core'\nimport {\n defineModelProviderPlugin,\n type ComposableModelProviderPlugin,\n type CredentialInput,\n type ModelTarget,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n HttpModelAdapter,\n ProviderCatalogModel,\n ProviderRequestLogger,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n createHttpProvider,\n endpointHeaders,\n createRuntimeHttpProvider,\n type CredentialSource,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n geminiInteractionsProtocol,\n type GeminiInteractionsDialect,\n} from '@alvin0/ai-agent-sdk-protocol-gemini-interactions'\nimport { geminiContextPolicy } from './context-policy.ts'\n\n/** Google Gemini API v1beta base. The protocol appends only `/interactions`. */\nexport const GEMINI_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n\nexport type GeminiCredential = CredentialSource\n\nexport interface GeminiAdapterOptions {\n /** Injected API key or resolver. Universal packages never read environment variables. */\n apiKey: GeminiCredential\n /** Endpoint base; defaults to {@link GEMINI_BASE_URL}. */\n baseUrl?: string\n /** Extra endpoint headers, captured once per operation. Reserved names and collisions fail. */\n headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>)\n /** Permit cleartext HTTP explicitly for trusted local gateways. */\n allowInsecureHttp?: boolean\n /** Advisory catalog; built-in context policies do not advertise model availability. */\n models?: readonly ProviderCatalogModel[]\n /** Whether Google may retain interactions. Defaults to false. */\n store?: boolean\n defaultMaxTokens?: number\n defaultContextWindow?: number\n streamIdleTimeoutMs?: number\n requestTimeoutMs?: number\n maxRequestBytes?: number\n maxResponseBytes?: number\n maxResponseChunks?: number\n maxSseEvents?: number\n maxSseEventChars?: number\n maxErrorBodyBytes?: number\n requestLoggerTimeoutMs?: number\n retryPolicy?: RetryPolicyConfig\n requestLogger?: ProviderRequestLogger\n fetch?: typeof globalThis.fetch\n}\n\nexport function geminiAdapter(options: GeminiAdapterOptions): HttpModelAdapter {\n return createHttpProvider({\n displayName: 'Gemini',\n describeModel: geminiContextPolicy(options),\n protocol: geminiInteractionsProtocol,\n baseUrl: options.baseUrl ?? GEMINI_BASE_URL,\n auth: {\n kind: 'header', name: 'x-goog-api-key', value: options.apiKey,\n label: 'the `apiKey` option',\n },\n dialect: dialectOf(options),\n ...(options.models === undefined ? {} : { models: options.models }),\n defaultMaxTokens: options.defaultMaxTokens ?? 8_192,\n defaultContextWindow: options.defaultContextWindow ?? 200_000,\n ...(options.streamIdleTimeoutMs === undefined ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs }),\n ...transportLimits(options),\n ...(options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy }),\n ...(options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger }),\n })\n}\n\nexport interface GeminiPluginOptions extends GeminiAdapterOptions {\n /** Registry routes installed by the plugin. Defaults to `['gemini']`. */\n readonly routes?: readonly string[]\n}\n\nexport interface GeminiProviderOptions extends Omit<GeminiAdapterOptions, 'apiKey'> {\n readonly defaultModel?: string | ModelTarget\n readonly apiKey: CredentialInput\n readonly id?: string\n readonly routes?: readonly string[]\n}\n\nexport function geminiPlugin(\n options: GeminiProviderOptions,\n): ComposableModelProviderPlugin & { readonly family: 'gemini' }\nexport function geminiPlugin(options: GeminiPluginOptions): ModelProviderPlugin\nexport function geminiPlugin(\n options: GeminiProviderOptions | GeminiPluginOptions,\n): ModelProviderPlugin | (ComposableModelProviderPlugin & { readonly family: 'gemini' }) {\n if (!usesRuntimeComposition(options)) return legacyGeminiPlugin(options)\n const id = options.id ?? 'gemini'\n const routes = Object.freeze([...(options.routes ?? [id])])\n return defineModelProviderPlugin({\n id,\n family: 'gemini',\n displayName: 'Gemini',\n routes,\n ...runtimeDefaultModel(options.defaultModel, routes),\n setup(registrar) {\n const remove = registrar.registerAdapter(createRuntimeGeminiAdapter(options))\n return () => { remove(); return undefined }\n },\n }) as ComposableModelProviderPlugin & { readonly family: 'gemini' }\n}\n\nfunction legacyGeminiPlugin(options: GeminiPluginOptions): ModelProviderPlugin {\n const routes = Object.freeze([...(options.routes ?? ['gemini'])])\n const adapter = geminiAdapter(options)\n return Object.freeze({\n id: 'gemini',\n displayName: 'Gemini',\n setup(registrar: ModelProviderRegistrar) {\n registrar.registerAdapter(routes, adapter)\n },\n })\n}\n\nfunction createRuntimeGeminiAdapter(options: GeminiProviderOptions): HttpModelAdapter {\n return createRuntimeHttpProvider({\n describeModel: geminiContextPolicy(options),\n displayName: 'Gemini',\n protocol: geminiInteractionsProtocol,\n baseUrl: options.baseUrl ?? GEMINI_BASE_URL,\n auth: {\n kind: 'header', name: 'x-goog-api-key', value: options.apiKey,\n label: 'the `apiKey` option',\n },\n dialect: dialectOf(options),\n ...(options.models === undefined ? {} : { models: options.models }),\n defaultMaxTokens: options.defaultMaxTokens ?? 8_192,\n defaultContextWindow: options.defaultContextWindow ?? 200_000,\n ...(options.streamIdleTimeoutMs === undefined ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs }),\n ...transportLimits(options),\n ...(options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy }),\n ...(options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger }),\n })\n}\n\nfunction dialectOf(options: Pick<GeminiAdapterOptions, 'store'>): Partial<GeminiInteractionsDialect> {\n return options.store === undefined ? {} : { store: options.store }\n}\n\nfunction usesRuntimeComposition(\n options: GeminiProviderOptions | GeminiPluginOptions,\n): options is GeminiProviderOptions {\n if ('id' in options || 'defaultModel' in options) return true\n if (typeof options.apiKey === 'object' && options.apiKey !== null) return true\n if (typeof options.apiKey !== 'function') return true\n // Node's envCredential keeps a backwards-compatible callable surface while\n // also carrying the versioned CredentialSource marker used by composition.\n return 'kind' in options.apiKey && options.apiKey.kind === 'credential-source'\n}\n\nfunction runtimeDefaultModel(\n value: string | ModelTarget | undefined,\n routes: readonly string[],\n): { readonly defaultModel?: ModelTarget } {\n if (value === undefined) return {}\n if (typeof value !== 'string') return { defaultModel: value }\n if (routes.length !== 1) throw new TypeError('A string defaultModel requires exactly one Gemini route')\n return { defaultModel: Object.freeze({ provider: routes[0]!, id: value }) }\n}\n\nfunction transportLimits(options: GeminiAdapterOptions | GeminiProviderOptions) {\n return {\n ...(options.allowInsecureHttp === undefined ? {} : { allowInsecureHttp: options.allowInsecureHttp }),\n headers: endpointHeaders(options.headers),\n ...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n ...(options.maxRequestBytes === undefined ? {} : { maxRequestBytes: options.maxRequestBytes }),\n ...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n ...(options.maxResponseChunks === undefined ? {} : { maxResponseChunks: options.maxResponseChunks }),\n ...(options.maxSseEvents === undefined ? {} : { maxSseEvents: options.maxSseEvents }),\n ...(options.maxSseEventChars === undefined ? {} : { maxSseEventChars: options.maxSseEventChars }),\n ...(options.maxErrorBodyBytes === undefined ? {} : { maxErrorBodyBytes: options.maxErrorBodyBytes }),\n ...(options.requestLoggerTimeoutMs === undefined ? {} : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n }\n}\n","/**\n * `Gemini_Embedding_Adapter`: Gemini's `batchEmbedContents` endpoint expressed as\n * an `Embedding_Adapter`.\n *\n * Deliberately separate from `./adapter.ts`: nothing here imports\n * `geminiInteractionsProtocol`, and nothing there imports this module. Generation\n * and embedding share the same credential shape and the same HTTP transport, and\n * that is all they share — a request vocabulary in common would be the conflation\n * Requirement 14.2 rules out.\n *\n * Three Gemini specifics shape this file, and each one is stated rather than\n * inferred:\n *\n * - **Purpose is a wire parameter.** `taskType` exists, so `purpose` translates\n * into it — but only when the route DECLARES that mechanism. A route that\n * declares nothing gets the text sent verbatim and no invented parameter\n * (Requirement 7.3).\n * - **A narrower vector is a model mechanism plus a recorded step.**\n * `outputDimensionality` asks the model for a narrower vector; Gemini\n * documents that a narrower vector is no longer unit-length, so the profile\n * declares `postProcessing: { kind: 'l2-renormalize', revision: '1' }` and this\n * adapter performs exactly that step. Nothing here slices or pads a vector\n * (Requirement 9.8).\n * - **Mapping is positional.** `batchEmbedContents` returns\n * `{ embeddings: [{ values }] }` with no index, so the index is assigned by\n * this adapter from request order, and the count is checked rather than\n * assumed.\n *\n * @module ai-agent-sdk/providers/gemini/embedding\n */\n\nimport {\n assertUsableApiKey,\n resolveRetryPolicy,\n type ModelInvocationContext,\n type ProviderInfo,\n type ResolvedRetryPolicy,\n type RetryPolicyConfig,\n type SdkLogger,\n} from '@alvin0/ai-agent-sdk-core'\nimport {\n EMBEDDING_ERROR_CODES,\n EmbeddingAdapter,\n EmbeddingError,\n defaultEmbeddingProfile,\n deriveSpaceId,\n resolveBatchLimits,\n validateBatchResult,\n type EmbeddingBatchRequest,\n type EmbeddingBatchResult,\n type EmbeddingModelInfo,\n type EmbeddingPostProcessing,\n type EmbeddingProfile,\n type EmbeddingProfileInput,\n type EmbeddingPurpose,\n type EmbeddingVector,\n type PrepareEmbeddingOptions,\n type PreparedEmbeddingCall,\n type ResolvedEmbeddingModelInfo,\n} from '@alvin0/ai-agent-sdk-core/embedding'\nimport {\n defineEmbeddingProviderPlugin,\n type ComposableEmbeddingProviderPlugin,\n type CredentialInput,\n type ModelTarget,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n captureTransportConnection,\n endpointHeaders,\n embeddingCatalogModelInfo,\n resolvedEmbeddingCatalogModelInfo,\n transportJson,\n type EmbeddingCatalogModel,\n type EmbeddingHttpConnection,\n} from '@alvin0/ai-agent-sdk-provider-http'\n\n/** Google Generative Language API v1beta base; the adapter appends the model path. */\nexport const GEMINI_EMBEDDING_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n\n/** Name used in every diagnostic this module raises. */\nconst DISPLAY_NAME = 'Gemini'\n\n/** Header layer the JSON pipeline owns for this route. */\nconst TRANSPORT_HEADERS = Object.freeze({\n 'content-type': 'application/json',\n accept: 'application/json',\n})\n\n/** Revision of the `l2-renormalize` step this adapter performs. */\nconst POST_PROCESSING_REVISION = '1'\n\n/** Applied when neither the caller nor the catalog says otherwise. */\nconst DEFAULT_RECIPE_REVISION = '1'\n\n/** The one mapping from this SDK's purpose vocabulary to Gemini's `taskType`. */\nconst TASK_TYPES: Readonly<Record<EmbeddingPurpose, string>> = Object.freeze({\n 'retrieval-query': 'RETRIEVAL_QUERY',\n 'retrieval-document': 'RETRIEVAL_DOCUMENT',\n})\n\nconst NEVER_ABORTED_SIGNAL = new AbortController().signal\n\nconst NULL_LOGGER: SdkLogger = Object.freeze({\n child: () => NULL_LOGGER,\n trace: () => undefined,\n debug: () => undefined,\n info: () => undefined,\n warn: () => undefined,\n error: () => undefined,\n fatal: () => undefined,\n})\n\n/**\n * The Gemini embedding generations this package declares.\n *\n * Unlike the generation catalog, an embedding catalog entry cannot be omitted\n * entirely: `compatibilityIdentity` is a claim about an embedding space that only\n * the route can make, and Requirement 14.6 puts that claim on this adapter. The\n * identity names the GENERATION, so `gemini-embedding-001` and a future\n * `gemini-embedding-2` are detected as incompatible even at equal width. Pass\n * `models` to override or extend this list.\n */\nexport const GEMINI_EMBEDDING_MODELS: readonly EmbeddingCatalogModel[] = Object.freeze([\n Object.freeze({\n id: 'gemini-embedding-001',\n name: 'Gemini Embedding 001',\n description: 'Gemini text embedding with selectable output dimensionality.',\n dimensions: Object.freeze([3072, 1536, 768]),\n defaultDimensions: 3072,\n maxInputTokens: 2048,\n maxBatchItems: 100,\n purposeHandling: Object.freeze({ kind: 'wire-parameter' as const, parameter: 'taskType' }),\n compatibilityIdentity: 'google:gemini-embedding-001',\n }),\n])\n\n/** Configuration for {@link geminiEmbeddingAdapter} and {@link geminiEmbeddingPlugin}. */\nexport interface GeminiEmbeddingProviderOptions {\n /** Injected key or credential source; universal packages never read the environment. */\n readonly apiKey: CredentialInput\n /** Extra endpoint headers, captured once per logical call; reserved names fail. */\n readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>)\n /** Endpoint base; defaults to {@link GEMINI_EMBEDDING_BASE_URL}. */\n readonly baseUrl?: string\n /** Plugin id; defaults to `'gemini-embedding'`. */\n readonly id?: string\n /** Routes the plugin claims; defaults to `[id]`. */\n readonly routes?: readonly string[]\n /** Default model for the claimed route. */\n readonly defaultModel?: string | ModelTarget\n /** Declared embedding catalog; defaults to {@link GEMINI_EMBEDDING_MODELS}. */\n readonly models?: readonly EmbeddingCatalogModel[]\n /** Permit cleartext HTTP explicitly, for a trusted local endpoint only. */\n readonly allowInsecureHttp?: boolean\n readonly requestTimeoutMs?: number\n readonly maxRequestBytes?: number\n readonly maxResponseBytes?: number\n readonly maxResponseChunks?: number\n readonly maxErrorBodyBytes?: number\n readonly requestLoggerTimeoutMs?: number\n readonly retryPolicy?: RetryPolicyConfig\n readonly fetch?: typeof globalThis.fetch\n}\n\n/** What the JSON pipeline hands back: the parsed body plus its correlation id. */\ninterface GeminiEmbedResponse {\n readonly payload: unknown\n readonly providerRequestId?: string\n}\n\n/** One request element of Gemini's `batchEmbedContents` body. */\ninterface GeminiEmbedRequest {\n readonly model: string\n readonly content: { readonly parts: readonly { readonly text: string }[] }\n readonly outputDimensionality?: number\n readonly [parameter: string]: unknown\n}\n\n/**\n * The Gemini `batchEmbedContents` adapter.\n *\n * Every metadata method takes the route key, so one instance serves every route\n * the plugin claims. Connection facts are captured once per operation in\n * {@link prepareEmbeddingCall}, which is what keeps a credential from travelling\n * to a URL from a different configuration generation.\n */\nclass GeminiEmbeddingAdapter extends EmbeddingAdapter {\n readonly #options: GeminiEmbeddingProviderOptions\n readonly #headers: () => Readonly<Record<string, string>>\n readonly #models: readonly EmbeddingCatalogModel[]\n readonly #retryPolicy: ResolvedRetryPolicy\n\n constructor(options: GeminiEmbeddingProviderOptions) {\n super()\n this.#options = Object.freeze({ ...options })\n this.#headers = endpointHeaders(options.headers)\n this.#models = Object.freeze([...(options.models ?? GEMINI_EMBEDDING_MODELS)])\n this.#retryPolicy = resolveRetryPolicy(options.retryPolicy, 'retryPolicy')\n }\n\n override providerInfo(provider: string): ProviderInfo {\n return { id: provider, name: DISPLAY_NAME }\n }\n\n override providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined {\n return this.#retryPolicy\n }\n\n override listEmbeddingModels(\n provider: string,\n _signal?: AbortSignal,\n ): Promise<readonly EmbeddingModelInfo[]> {\n return Promise.resolve(Object.freeze(\n this.#models.map(model => embeddingCatalogModelInfo(provider, model)),\n ))\n }\n\n override resolveEmbeddingModel(\n provider: string,\n model: string,\n _signal?: AbortSignal,\n ): Promise<ResolvedEmbeddingModelInfo> {\n return Promise.resolve(resolvedEmbeddingCatalogModelInfo(provider, model, this.#models))\n }\n\n /**\n * Declare the real Gemini profile instead of accepting the generic default.\n *\n * Two statements the default cannot make: the compatibility identity is the\n * route's declaration about a GENERATION, and asking for a narrower vector adds\n * a recorded `l2-renormalize` step which this adapter then actually performs.\n */\n override embeddingProfile(\n model: ResolvedEmbeddingModelInfo,\n request: EmbeddingProfileInput,\n ): EmbeddingProfile {\n const base = defaultEmbeddingProfile(model, request)\n const postProcessing = postProcessingFor(model, base.dimensions)\n return Object.freeze({\n ...base,\n compatibilityIdentity: model.compatibilityIdentity.state === 'supported'\n ? model.compatibilityIdentity.value\n : `google:${model.id}`,\n // Truthful either way: `unit-l2` only where this adapter normalizes, and\n // otherwise whatever the route declared — never inferred from the width.\n normalization: postProcessing !== undefined\n ? 'unit-l2'\n : model.normalization.state === 'supported'\n ? model.normalization.value\n : 'unknown',\n documentRecipeRevision: request.documentRecipeRevision ?? DEFAULT_RECIPE_REVISION,\n queryRecipeRevision: request.queryRecipeRevision ?? DEFAULT_RECIPE_REVISION,\n ...(postProcessing === undefined ? {} : { postProcessing }),\n })\n }\n\n /**\n * Capture the endpoint, the credential and the catalog together, once.\n *\n * The connection is read here and never re-read per batch, so every batch of\n * one `Logical_Call` goes out through the same generation of configuration\n * that its dimensions were checked against.\n */\n override async prepareEmbeddingCall(\n provider: string,\n model: string,\n options: PrepareEmbeddingOptions,\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n ): Promise<PreparedEmbeddingCall> {\n const resolved = await this.resolveEmbeddingModel(provider, model, signal)\n const profile = this.embeddingProfile(resolved, options)\n const connection = await this.#connect(signal, context)\n return Object.freeze({\n model: resolved,\n profile,\n spaceId: deriveSpaceId(profile),\n limits: resolveBatchLimits(resolved, options.limits),\n embedBatch: (batch: EmbeddingBatchRequest, invocation = context) =>\n this.#dispatch(connection, resolved, profile, batch, invocation),\n })\n }\n\n /**\n * Perform exactly one `batchEmbedContents` request.\n *\n * Usable directly, in which case the catalog and connection are resolved for\n * this batch alone; `prepareEmbeddingCall` is the path that binds one snapshot\n * to a whole logical call.\n */\n override async embedBatch(\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult> {\n const resolved = await this.resolveEmbeddingModel(batch.provider, batch.model, batch.signal)\n const profile = this.embeddingProfile(resolved, {\n ...(batch.dimensions === undefined ? {} : { dimensions: batch.dimensions }),\n })\n const connection = await this.#connect(batch.signal, context)\n return await this.#dispatch(connection, resolved, profile, batch, context)\n }\n\n /** Resolve the credential and bounds into one frozen snapshot. */\n async #connect(\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingHttpConnection> {\n const options = this.#options\n const extraHeaders = this.#headers()\n const apiKey = assertUsableApiKey(\n await resolveCredential(options.apiKey, signal, context),\n DISPLAY_NAME,\n 'the `apiKey` option',\n )\n // Attribution headers are merged by the transport, so no embedding adapter\n // can forget them (Requirement 14.7).\n return captureTransportConnection<EmbeddingHttpConnection>({\n baseUrl: options.baseUrl ?? GEMINI_EMBEDDING_BASE_URL,\n headers: Object.freeze({ ...extraHeaders, 'x-goog-api-key': apiKey }),\n models: this.#models,\n retryPolicy: this.#retryPolicy,\n ...(options.allowInsecureHttp === undefined\n ? {}\n : { allowInsecureHttp: options.allowInsecureHttp }),\n ...(options.requestTimeoutMs === undefined\n ? {}\n : { requestTimeoutMs: options.requestTimeoutMs }),\n ...(options.maxRequestBytes === undefined ? {} : { maxRequestBytes: options.maxRequestBytes }),\n ...(options.maxResponseBytes === undefined\n ? {}\n : { maxResponseBytes: options.maxResponseBytes }),\n ...(options.maxResponseChunks === undefined\n ? {}\n : { maxResponseChunks: options.maxResponseChunks }),\n ...(options.maxErrorBodyBytes === undefined\n ? {}\n : { maxErrorBodyBytes: options.maxErrorBodyBytes }),\n ...(options.requestLoggerTimeoutMs === undefined\n ? {}\n : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n }, TRANSPORT_HEADERS)\n }\n\n /** One `Provider_Attempt`: build the body, send it, decode the response. */\n async #dispatch(\n connection: EmbeddingHttpConnection,\n model: ResolvedEmbeddingModelInfo,\n profile: EmbeddingProfile,\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult> {\n if (batch.truncation === 'allow') {\n throw new EmbeddingError(\n 'Gemini batchEmbedContents exposes no truncation parameter',\n EMBEDDING_ERROR_CODES.TRUNCATION_UNSUPPORTED,\n { provider: batch.provider, model: batch.model },\n )\n }\n const modelId = bareModelId(batch.model)\n const body = { requests: batch.items.map(item => embedRequest(item, model, batch, modelId)) }\n const encoded = JSON.stringify(body)\n // The transport chain owns transport failures and normalizes anything thrown\n // inside `decode` into a ModelError, which would flatten this adapter's\n // embedding codes. So `decode` only extracts the payload, and contract\n // validation runs here, where an EmbeddingError reaches the caller intact.\n const received = await transportJson({\n connection,\n displayName: DISPLAY_NAME,\n provider: batch.provider,\n model: batch.model,\n path: `/models/${encodeURIComponent(modelId)}:batchEmbedContents`,\n accept: 'application/json',\n body: {\n value: body,\n encoded,\n bytes: new TextEncoder().encode(encoded).length,\n },\n ...(batch.signal === undefined ? {} : { signal: batch.signal }),\n ...(context === undefined ? {} : { context }),\n }, (session, payload) => Object.freeze({\n payload,\n ...(session.providerRequestId === undefined\n ? {}\n : { providerRequestId: session.providerRequestId }),\n }))\n return decodeBatch(batch, profile, received)\n }\n}\n\n/**\n * Create the Gemini embedding adapter.\n *\n * No I/O happens here: the credential is resolved per operation, not at\n * construction.\n * @param options - route configuration.\n * @returns an adapter registrable under any number of routes.\n */\nexport function geminiEmbeddingAdapter(\n options: GeminiEmbeddingProviderOptions,\n): EmbeddingAdapter {\n return new GeminiEmbeddingAdapter(options)\n}\n\n/**\n * Create the Gemini `Embedding_Provider_Plugin`.\n *\n * Its `kind` is `'embedding-provider-plugin'`, so a generation host never\n * mistakes it for {@link geminiPlugin} and neither plugin needs a version bump\n * because of the other (Requirement 11.1).\n * @param options - route configuration.\n * @returns an inert plugin; registration happens during runtime activation.\n */\nexport function geminiEmbeddingPlugin(\n options: GeminiEmbeddingProviderOptions,\n): ComposableEmbeddingProviderPlugin & { readonly family: 'gemini' } {\n const id = options.id ?? 'gemini-embedding'\n const routes = Object.freeze([...(options.routes ?? [id])])\n const adapter = geminiEmbeddingAdapter(options)\n return defineEmbeddingProviderPlugin({\n id,\n family: 'gemini',\n displayName: DISPLAY_NAME,\n routes,\n ...defaultModelTarget(options.defaultModel, routes),\n setup(registrar) {\n const remove = registrar.registerEmbeddingAdapter(adapter)\n return () => {\n remove()\n return undefined\n }\n },\n }) as ComposableEmbeddingProviderPlugin & { readonly family: 'gemini' }\n}\n\n/** Resolve a literal key or a credential source, without caching the secret. */\nasync function resolveCredential(\n apiKey: CredentialInput,\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n): Promise<string> {\n if (typeof apiKey === 'string') return apiKey\n return await apiKey.resolve({\n signal: signal ?? NEVER_ABORTED_SIGNAL,\n logger: context?.logger ?? NULL_LOGGER,\n })\n}\n\n/** Accept both `gemini-embedding-001` and the `models/`-prefixed resource name. */\nfunction bareModelId(model: string): string {\n return model.startsWith('models/') ? model.slice('models/'.length) : model\n}\n\n/**\n * Build one request element.\n *\n * `taskType` appears only when the route DECLARES a wire parameter for purpose,\n * and it is spelled with the declared parameter name. A route that declares\n * nothing gets the text verbatim — an undeclared parameter would be this adapter\n * inventing a mechanism (Requirement 7.3).\n */\nfunction embedRequest(\n item: EmbeddingBatchRequest['items'][number],\n model: ResolvedEmbeddingModelInfo,\n batch: EmbeddingBatchRequest,\n modelId: string,\n): GeminiEmbedRequest {\n const purposeHandling = model.purposeHandling\n const wireParameter = purposeHandling.state === 'supported'\n && purposeHandling.value.kind === 'wire-parameter'\n ? purposeHandling.value.parameter\n : undefined\n const width = outputDimensionality(model, batch)\n return {\n model: `models/${modelId}`,\n content: {\n parts: item.contentParts.map(part => ({ text: part.text })),\n },\n ...(wireParameter === undefined ? {} : { [wireParameter]: TASK_TYPES[batch.purpose] }),\n ...(width === undefined ? {} : { outputDimensionality: width }),\n }\n}\n\n/**\n * `outputDimensionality` travels only when the route declares selectable widths.\n *\n * With an `unknown` declaration there is nothing saying the parameter exists, and\n * sending it anyway would make a capability claim on the route's behalf\n * (Requirement 14.4).\n */\nfunction outputDimensionality(\n model: ResolvedEmbeddingModelInfo,\n batch: EmbeddingBatchRequest,\n): number | undefined {\n if (batch.dimensions === undefined) return undefined\n return model.dimensions.state === 'supported' ? batch.dimensions : undefined\n}\n\n/**\n * The recorded step a narrower-than-native vector needs.\n *\n * Gemini documents that only the native width comes back unit-length, so a\n * narrower request declares `l2-renormalize` in the profile and this adapter\n * performs exactly that. It is NOT a slice or a pad: the model produced the\n * narrower vector itself (Requirement 9.8).\n */\nfunction postProcessingFor(\n model: ResolvedEmbeddingModelInfo,\n dimensions: number,\n): EmbeddingPostProcessing | undefined {\n if (model.defaultDimensions.state !== 'supported') return undefined\n const native = model.defaultDimensions.value\n if (dimensions <= 0 || dimensions >= native) return undefined\n return Object.freeze({ kind: 'l2-renormalize' as const, revision: POST_PROCESSING_REVISION })\n}\n\n/**\n * Turn one response into vectors, positionally, with the count checked.\n *\n * Order: structural shape, then count, then the SHARED\n * {@link validateBatchResult} — so the same malformed response yields the same\n * code here as it does for any other provider — and only then the recorded\n * post-processing step.\n */\nfunction decodeBatch(\n batch: EmbeddingBatchRequest,\n profile: EmbeddingProfile,\n received: GeminiEmbedResponse,\n): EmbeddingBatchResult {\n const embeddings = readEmbeddings(batch, received.payload)\n if (embeddings.length !== batch.items.length) {\n throw new EmbeddingError(\n `Gemini returned ${embeddings.length} embeddings for ${batch.items.length} inputs`,\n EMBEDDING_ERROR_CODES.VECTOR_COUNT_MISMATCH,\n { provider: batch.provider, model: batch.model },\n )\n }\n // Positional mapping: the response carries no index, so the index comes from\n // request order — which is only sound because the length was just checked.\n const vectors = embeddings.map((embedding, position) => Object.freeze<EmbeddingVector>({\n index: batch.items[position]!.index,\n values: readValues(batch, embedding, batch.items[position]!.index),\n }))\n const raw: EmbeddingBatchResult = Object.freeze({\n vectors: Object.freeze(vectors),\n ...(received.providerRequestId === undefined\n ? {}\n : { providerRequestId: received.providerRequestId }),\n })\n validateBatchResult(batch, raw)\n // `batchEmbedContents` reports no usage at all, so no `usage` field is set on\n // the result — not an empty object and not a zero. The absence is what the\n // runtime aggregator reads to report `status: 'missing'` plus a\n // `usage-unreported` warning, and stating it here as well would double the\n // warning for one batch (Requirement 16.2).\n return applyPostProcessing(raw, profile)\n}\n\n/** Read `embeddings[]`, refusing any other shape rather than guessing at it. */\nfunction readEmbeddings(batch: EmbeddingBatchRequest, payload: unknown): readonly unknown[] {\n if (typeof payload !== 'object' || payload === null) {\n throw malformed(batch, 'Gemini response is not a JSON object')\n }\n const embeddings = Reflect.get(payload, 'embeddings')\n if (!Array.isArray(embeddings)) {\n throw malformed(batch, 'Gemini response carries no embeddings array')\n }\n return embeddings as readonly unknown[]\n}\n\n/** Read one `values[]`, leaving every number exactly as the provider sent it. */\nfunction readValues(\n batch: EmbeddingBatchRequest,\n embedding: unknown,\n index: number,\n): readonly number[] {\n if (typeof embedding !== 'object' || embedding === null) {\n throw malformed(batch, 'Gemini embedding entry is not an object', index)\n }\n const values = Reflect.get(embedding, 'values')\n if (!Array.isArray(values)) {\n throw malformed(batch, 'Gemini embedding entry carries no values array', index)\n }\n return Object.freeze([...values as readonly number[]])\n}\n\n/** One place the structural-failure code is spelled. */\nfunction malformed(\n batch: EmbeddingBatchRequest,\n message: string,\n index?: number,\n): EmbeddingError {\n return new EmbeddingError(message, EMBEDDING_ERROR_CODES.RESPONSE_MALFORMED, {\n provider: batch.provider,\n model: batch.model,\n ...(index === undefined ? {} : { itemIndexes: [index] }),\n })\n}\n\n/**\n * Perform the step the profile declares, and nothing else.\n *\n * A profile with no `postProcessing` returns the provider's values untouched, so\n * the vectors a caller receives are faithful to what came back (Property 22). A\n * zero vector has no direction to preserve, so it is passed through rather than\n * turned into `NaN`.\n */\nfunction applyPostProcessing(\n result: EmbeddingBatchResult,\n profile: EmbeddingProfile,\n): EmbeddingBatchResult {\n if (profile.postProcessing?.kind !== 'l2-renormalize') return result\n return Object.freeze({\n ...result,\n vectors: Object.freeze(result.vectors.map(vector => Object.freeze<EmbeddingVector>({\n ...vector,\n values: l2Renormalize(vector.values),\n }))),\n })\n}\n\n/** Scale a vector to unit L2 length. */\nfunction l2Renormalize(values: readonly number[]): readonly number[] {\n let sum = 0\n for (const value of values) sum += value * value\n const norm = Math.sqrt(sum)\n if (!Number.isFinite(norm) || norm === 0) return values\n return Object.freeze(values.map(value => value / norm))\n}\n\n/** A string default model needs exactly one route to belong to. */\nfunction defaultModelTarget(\n value: string | ModelTarget | undefined,\n routes: readonly string[],\n): { readonly defaultModel?: ModelTarget } {\n if (value === undefined) return {}\n if (typeof value !== 'string') return { defaultModel: value }\n if (routes.length !== 1) {\n throw new TypeError('A string defaultModel requires exactly one Gemini embedding route')\n }\n return { defaultModel: Object.freeze({ provider: routes[0]!, id: value }) }\n}\n"],"mappings":";;;;;;;AAKA,MAAM,MAAM;CAAE,sBAAsB;CAAS,0BAA0B;AAAQ;AAC/E,SAAgB,oBAAoB,SAAoC;CACtE,OAAO,yBACL,QAAQ,YAAY,UAAa,QAAQ,QAAQ,QAAQ,OAAO,EAAE,MAAM,qDACpE;EACE,0BAA0B;EAAK,sCAAsC;EAAK,kBAAkB;EAC5F,oBAAoB,EAAE,sBAAsB,IAAU;EACtD,0BAA0B,EAAE,sBAAsB,IAAU;CAC9D,IACA,CAAC,GAAG,QAAQ,QAAQ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,GAAG;CAC1B,IAAI,CAAC,OAAO,SAAS,IAAI,KAAK,SAAS,GAAG,OAAO;CACjD,OAAO,OAAO,OAAO,OAAO,KAAI,UAAS,QAAQ,IAAI,CAAC;AACxD;;AAGA,SAAS,mBACP,OACA,QACyC;CACzC,IAAI,UAAU,QAAW,OAAO,CAAC;CACjC,IAAI,OAAO,UAAU,UAAU,OAAO,EAAE,cAAc,MAAM;CAC5D,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,UAAU,mEAAmE;CAEzF,OAAO,EAAE,cAAc,OAAO,OAAO;EAAE,UAAU,OAAO;EAAK,IAAI;CAAM,CAAC,EAAE;AAC5E"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "alvin0 - chaulamdinhai",
|
|
5
5
|
"email": "chaulamdinhai@gmail.com"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.3",
|
|
8
8
|
"description": "Universal Gemini Interactions adapter and provider plugin for ai-agent-sdk",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"provenance": true
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@alvin0/ai-agent-sdk-provider-http": "^0.1.
|
|
42
|
-
"@alvin0/ai-agent-sdk-protocol-gemini-interactions": "^0.1.
|
|
41
|
+
"@alvin0/ai-agent-sdk-provider-http": "^0.1.3",
|
|
42
|
+
"@alvin0/ai-agent-sdk-protocol-gemini-interactions": "^0.1.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@alvin0/ai-agent-sdk-core": "^0.1.
|
|
45
|
+
"@alvin0/ai-agent-sdk-core": "^0.1.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@alvin0/ai-agent-sdk-core": "^0.1.
|
|
49
|
-
"@alvin0/ai-agent-sdk-testkit": "^0.1.
|
|
48
|
+
"@alvin0/ai-agent-sdk-core": "^0.1.3",
|
|
49
|
+
"@alvin0/ai-agent-sdk-testkit": "^0.1.3",
|
|
50
50
|
"@arethetypeswrong/cli": "0.18.5",
|
|
51
51
|
"playwright": "1.62.1",
|
|
52
52
|
"publint": "0.3.24",
|