From 422cea8ace1bb6f5f5face284df11a602552a6e8 Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 25 Aug 2026 14:36:30 -0700 Subject: [PATCH 1/4] refactor(ai): update WebhookOptions, Gemini, and Vertex types ### Description - Remove regionalWebhook field and array location typing from WebhookOptions in AI provider. - Remove labels field from Vertex GenerateContentRequest. - Explicitly add tools and toolConfig fields to Vertex GenerateContentRequest. - Remove generateContentStream reference from JSDoc comments in Gemini v1beta. ### Scenarios Tested - Ran unit tests in spec/v2/providers/ai.spec.ts - Ran npm test and npm run format --- spec/v2/providers/ai.spec.ts | 18 +------------- src/v2/providers/ai/index.ts | 24 ++++--------------- .../providers/ai/types/gemini/v1beta/index.ts | 5 +--- .../ai/types/vertex/v1beta1/index.ts | 9 ++++--- 4 files changed, 11 insertions(+), 45 deletions(-) diff --git a/spec/v2/providers/ai.spec.ts b/spec/v2/providers/ai.spec.ts index 8183e05f7..eeaf8939a 100644 --- a/spec/v2/providers/ai.spec.ts +++ b/spec/v2/providers/ai.spec.ts @@ -256,24 +256,8 @@ describe("v2.ai", () => { }); }); describe("Typings", () => { - it("should allow regional webhooks to specify multiple locations", () => { - ai.beforeGenerateContent( - { regionalWebhook: true, location: ["us-central1", "europe-west1"] }, - () => {} - ); - }); - - it("should allow global webhooks to specify a single location", () => { + it("should allow webhooks to specify a single region", () => { ai.beforeGenerateContent({ region: "us-central1" }, () => {}); }); - - it("should allow regional webhooks to specify a single location", () => { - ai.beforeGenerateContent({ regionalWebhook: true, region: "us-central1" }, () => {}); - }); - - // Compilation failure tests (commented out): - // it("should NOT allow global webhooks to specify multiple locations", () => { - // ai.beforeGenerateContent({ region: ["us-central1", "europe-west1"] }, () => {}); - // }); }); }); diff --git a/src/v2/providers/ai/index.ts b/src/v2/providers/ai/index.ts index 7930b7f64..1b0455529 100644 --- a/src/v2/providers/ai/index.ts +++ b/src/v2/providers/ai/index.ts @@ -34,8 +34,6 @@ import { withInit } from "../../../common/onInit"; import { initV2Endpoint } from "../../../runtime/manifest"; import * as options from "../../options"; -import { Expression } from "../../../params"; -import { ResetValue } from "../../../common/options"; import * as logger from "../../../logger"; export { HttpsError }; @@ -80,13 +78,7 @@ export { type GeminiV1BetaGenerateContentRequest, type GeminiV1BetaGenerateContentResponse, }; -type MultipleLocationsIf = Allowed extends true ? string[] : never; - -export interface WebhookOptions - extends Omit { - location?: string | Expression | MultipleLocationsIf | ResetValue; - regionalWebhook?: Regional; -} +export interface WebhookOptions extends EventHandlerOptions {} export interface PromptTemplateInfo { templateName?: string; @@ -157,8 +149,8 @@ export function beforeGenerateContent( ) => MaybeAsync> ): BlockingFunction; -export function beforeGenerateContent( - options: WebhookOptions, +export function beforeGenerateContent( + options: WebhookOptions, callback: ( event: AIBlockingEvent ) => MaybeAsync> @@ -249,9 +241,6 @@ export function beforeGenerateContent( }, blockingTrigger: { eventType: beforeGenerateEventType, - options: { - regionalWebhook: opts.regionalWebhook, - }, }, }; @@ -264,8 +253,8 @@ export function afterGenerateContent( ) => MaybeAsync> ): BlockingFunction; -export function afterGenerateContent( - options: WebhookOptions, +export function afterGenerateContent( + options: WebhookOptions, callback: ( event: AIBlockingEvent ) => MaybeAsync> @@ -356,9 +345,6 @@ export function afterGenerateContent( }, blockingTrigger: { eventType: afterGenerateEventType, - options: { - regionalWebhook: opts.regionalWebhook, - }, }, }; diff --git a/src/v2/providers/ai/types/gemini/v1beta/index.ts b/src/v2/providers/ai/types/gemini/v1beta/index.ts index 6ff4a3d3c..a0befcbf2 100644 --- a/src/v2/providers/ai/types/gemini/v1beta/index.ts +++ b/src/v2/providers/ai/types/gemini/v1beta/index.ts @@ -392,10 +392,7 @@ export declare interface GenerateContentRequest extends BaseParams { cachedContent?: string; } /** - * Individual response from {@link GenerativeModel.generateContent} and - * {@link GenerativeModel.generateContentStream}. - * `generateContentStream()` will return one in each chunk until - * the stream is done. + * Individual response from {@link GenerativeModel.generateContent}. * @public */ export declare interface GenerateContentResponse { diff --git a/src/v2/providers/ai/types/vertex/v1beta1/index.ts b/src/v2/providers/ai/types/vertex/v1beta1/index.ts index 8631634e3..99205b6e1 100644 --- a/src/v2/providers/ai/types/vertex/v1beta1/index.ts +++ b/src/v2/providers/ai/types/vertex/v1beta1/index.ts @@ -105,6 +105,10 @@ export interface Schema { export declare interface GenerateContentRequest extends BaseModelParams { /** Array of {@link Content}.*/ contents: Content[]; + /** Optional. Array of {@link Tool}. */ + tools?: Tool[]; + /** Optional. This config is shared for all tools provided in the request. */ + toolConfig?: ToolConfig; /** * Optional. The user provided system instructions for the model. * Note: only text should be used in parts of {@link Content} @@ -115,11 +119,6 @@ export declare interface GenerateContentRequest extends BaseModelParams { * This is the name of a `CachedContent` and not the cache object itself. */ cachedContent?: string; - /** - * Optional. Custom metadata labels for organizing API calls and managing costs at scale. See - * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls - */ - labels?: Record; } /** * Base params for initializing a model or calling GenerateContent. From 65fecbed271fa0654ee3176618e11bc7201b32bf Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 25 Aug 2026 14:42:39 -0700 Subject: [PATCH 2/4] fix(ai): remove redundant tools and toolConfig fields from Vertex GenerateContentRequest --- src/v2/providers/ai/types/vertex/v1beta1/index.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/v2/providers/ai/types/vertex/v1beta1/index.ts b/src/v2/providers/ai/types/vertex/v1beta1/index.ts index 903c9e7c9..e83ba2579 100644 --- a/src/v2/providers/ai/types/vertex/v1beta1/index.ts +++ b/src/v2/providers/ai/types/vertex/v1beta1/index.ts @@ -105,10 +105,6 @@ export interface Schema { export declare interface GenerateContentRequest extends BaseModelParams { /** Array of `Content`. */ contents: Content[]; - /** Optional. Array of {@link Tool}. */ - tools?: Tool[]; - /** Optional. This config is shared for all tools provided in the request. */ - toolConfig?: ToolConfig; /** * Optional. The user provided system instructions for the model. * Note: only text should be used in parts of `Content`. From 55dfb9183fc9cffc26822734321b8fddb3cebacd Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 25 Aug 2026 22:07:31 -0700 Subject: [PATCH 3/4] fix(ai): update JSDoc comment and add endpoint region unit tests --- spec/v2/providers/ai.spec.ts | 12 +++++++++--- src/v2/providers/ai/types/gemini/v1beta/index.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/v2/providers/ai.spec.ts b/spec/v2/providers/ai.spec.ts index eeaf8939a..02ca55dd9 100644 --- a/spec/v2/providers/ai.spec.ts +++ b/spec/v2/providers/ai.spec.ts @@ -255,9 +255,15 @@ describe("v2.ai", () => { }); }); }); - describe("Typings", () => { - it("should allow webhooks to specify a single region", () => { - ai.beforeGenerateContent({ region: "us-central1" }, () => {}); + describe("Typings & Options", () => { + it("should allow webhooks to specify a single region and populate __endpoint", () => { + const func = ai.beforeGenerateContent({ region: "us-central1" }, () => {}); + expect(func.__endpoint.region).to.deep.equal(["us-central1"]); + }); + + it("should allow webhooks to specify multiple regions and populate __endpoint", () => { + const func = ai.afterGenerateContent({ region: ["us-central1", "europe-west1"] }, () => {}); + expect(func.__endpoint.region).to.deep.equal(["us-central1", "europe-west1"]); }); }); }); diff --git a/src/v2/providers/ai/types/gemini/v1beta/index.ts b/src/v2/providers/ai/types/gemini/v1beta/index.ts index c6f93df34..9ae8a4bdb 100644 --- a/src/v2/providers/ai/types/gemini/v1beta/index.ts +++ b/src/v2/providers/ai/types/gemini/v1beta/index.ts @@ -396,7 +396,7 @@ export declare interface GenerateContentRequest extends BaseParams { cachedContent?: string; } /** - * Individual response from {@link GenerativeModel.generateContent}. + * Individual response from `generateContent`. * @public */ export declare interface GenerateContentResponse { From 21d6ac84fa3caff309e4d8d4d811340e04b98a3b Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 25 Aug 2026 22:12:27 -0700 Subject: [PATCH 4/4] test(ai): verify scalar region populates __endpoint --- spec/v2/providers/ai.spec.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/v2/providers/ai.spec.ts b/spec/v2/providers/ai.spec.ts index 02ca55dd9..f1127e30e 100644 --- a/spec/v2/providers/ai.spec.ts +++ b/spec/v2/providers/ai.spec.ts @@ -260,10 +260,5 @@ describe("v2.ai", () => { const func = ai.beforeGenerateContent({ region: "us-central1" }, () => {}); expect(func.__endpoint.region).to.deep.equal(["us-central1"]); }); - - it("should allow webhooks to specify multiple regions and populate __endpoint", () => { - const func = ai.afterGenerateContent({ region: ["us-central1", "europe-west1"] }, () => {}); - expect(func.__endpoint.region).to.deep.equal(["us-central1", "europe-west1"]); - }); }); });