@f5-sales-demo/pi-ai 21.2.1 → 21.4.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/pi-ai",
4
- "version": "21.2.1",
4
+ "version": "21.4.0",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -46,7 +46,7 @@
46
46
  "@anthropic-ai/sdk": "^0.115",
47
47
  "@aws-sdk/client-bedrock-runtime": "^3",
48
48
  "@bufbuild/protobuf": "^2.11",
49
- "@f5-sales-demo/pi-utils": "21.2.1",
49
+ "@f5-sales-demo/pi-utils": "21.4.0",
50
50
  "@google/genai": "^2.15",
51
51
  "@sinclair/typebox": "^0.34",
52
52
  "@smithy/node-http-handler": "^4.4",
@@ -104,10 +104,11 @@ export const streamGoogleVertex: StreamFunction<"google-vertex"> = (
104
104
  let rawRequestDump: RawHttpRequestDump | undefined;
105
105
 
106
106
  try {
107
- const apiKey = resolveApiKey(options);
108
- const project = apiKey ? undefined : await resolveGoogleVertexProject(options);
109
- const location = apiKey ? undefined : resolveGoogleVertexLocation(options);
110
- const client = apiKey ? createClientWithApiKey(model, apiKey) : createClient(model, project!, location!);
107
+ // Corporate Vertex is deliberately ADC-only. In particular, do not let the
108
+ // generic agent API-key plumbing turn this route into Gemini consumer auth.
109
+ const project = await resolveGoogleVertexProject(options);
110
+ const location = resolveGoogleVertexLocation(options);
111
+ const client = createClient(model, project, location);
111
112
  const params = buildGoogleVertexParams(model, context, options);
112
113
  options?.onPayload?.(params);
113
114
  rawRequestDump = {
@@ -115,9 +116,7 @@ export const streamGoogleVertex: StreamFunction<"google-vertex"> = (
115
116
  api: output.api,
116
117
  model: model.id,
117
118
  method: "POST",
118
- url: apiKey
119
- ? `https://aiplatform.googleapis.com/${API_VERSION}/publishers/google/models/${model.id}:streamGenerateContent`
120
- : googleVertexRequestUrl(model.id, project!, location!),
119
+ url: googleVertexRequestUrl(model.id, project, location),
121
120
  body: params,
122
121
  };
123
122
  const googleStream = await client.models.generateContentStream(params);
@@ -342,23 +341,6 @@ function createClient(model: Model<"google-vertex">, project: string, location:
342
341
  });
343
342
  }
344
343
 
345
- function createClientWithApiKey(model: Model<"google-vertex">, apiKey: string): GoogleGenAI {
346
- return new GoogleGenAI({
347
- vertexai: true,
348
- apiKey,
349
- apiVersion: API_VERSION,
350
- httpOptions: buildHttpOptions(model),
351
- });
352
- }
353
-
354
- function resolveApiKey(options?: GoogleVertexOptions): string | undefined {
355
- // options.apiKey may contain sentinel values like "<authenticated>" or "N/A"
356
- // leaked from the agent loop — only use it if it looks like a real API key.
357
- const optKey = options?.apiKey;
358
- const realKey = optKey && !optKey.startsWith("<") && optKey !== "N/A" ? optKey : undefined;
359
- return realKey || $env.GOOGLE_CLOUD_API_KEY;
360
- }
361
-
362
344
  const defaultProjectRuntime: GoogleVertexProjectRuntime = {
363
345
  readAdcProject,
364
346
  readLocalConfigProject: readConfiguredGcloudProject,
@@ -442,7 +424,10 @@ export async function resolveGoogleVertexProject(
442
424
  }
443
425
 
444
426
  export function resolveGoogleVertexLocation(options?: GoogleVertexOptions): string {
445
- return options?.location || $env.GOOGLE_CLOUD_LOCATION || "global";
427
+ // Gemini 3.7 Flash Corporate is served through the global endpoint only.
428
+ // Ignore inherited provider/environment locations so a request cannot drift.
429
+ void options;
430
+ return "global";
446
431
  }
447
432
 
448
433
  async function readAdcProject(): Promise<string | undefined> {
package/src/stream.ts CHANGED
@@ -97,15 +97,8 @@ const serviceProviderMap: Record<string, KeyResolver> = {
97
97
  ? $pickenv("ANTHROPIC_FOUNDRY_API_KEY", "ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY")
98
98
  : $pickenv("ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"),
99
99
  "gitlab-duo": "GITLAB_TOKEN",
100
- // Vertex AI supports either GOOGLE_CLOUD_API_KEY or Application Default Credentials.
101
- "google-vertex": () => {
102
- if ($env.GOOGLE_CLOUD_API_KEY) {
103
- return $env.GOOGLE_CLOUD_API_KEY;
104
- }
105
- if (hasVertexAdcCredentials()) {
106
- return "<authenticated>";
107
- }
108
- },
100
+ // Corporate Vertex uses Application Default Credentials only.
101
+ "google-vertex": () => (hasVertexAdcCredentials() ? "<authenticated>" : undefined),
109
102
  // Amazon Bedrock supports multiple credential sources:
110
103
  // 1. AWS_PROFILE - named profile from ~/.aws/credentials
111
104
  // 2. AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY - standard IAM keys
@@ -199,14 +199,14 @@ const builtInOAuthProviders: OAuthProviderInfo[] = [
199
199
  {
200
200
  id: "google-antigravity",
201
201
  name: "Antigravity (Gemini 3, Claude, GPT-OSS)",
202
+ description: "Optional consumer or non-corporate route",
202
203
  available: true,
203
204
  },
204
205
  {
205
206
  id: "google-antigravity-enterprise",
206
- name: "Google Antigravity Enterprise (Gemini 3.6 Flash High)",
207
+ name: "Google Antigravity Enterprise (Advanced OAuth)",
208
+ description: "Advanced corporate OAuth route; entitlement-discovered models, not Vertex ADC",
207
209
  available: true,
208
- canonicalId: "google-antigravity",
209
- loginOnly: true,
210
210
  },
211
211
  {
212
212
  id: "cursor",
@@ -509,7 +509,10 @@ export async function getOAuthApiKey(
509
509
  }
510
510
  // For providers that need request-time credential metadata, return JSON.
511
511
  const needsStructuredApiKey =
512
- provider === "github-copilot" || provider === "google-gemini-cli" || provider === "google-antigravity";
512
+ provider === "github-copilot" ||
513
+ provider === "google-gemini-cli" ||
514
+ provider === "google-antigravity" ||
515
+ provider === "google-antigravity-enterprise";
513
516
  const apiKey = needsStructuredApiKey
514
517
  ? JSON.stringify({
515
518
  token: creds.access,
@@ -74,11 +74,14 @@ export interface OAuthProviderInfo {
74
74
  canonicalId?: OAuthProvider;
75
75
  /** Entry is offered for login but omitted from logout to avoid alias duplicates. */
76
76
  loginOnly?: boolean;
77
+ /** Short secondary text displayed by interactive login pickers. */
78
+ description?: string;
79
+ /** Stable login-menu order; lower values are shown first. */
80
+ loginOrder?: number;
77
81
  }
78
82
 
79
83
  /** Resolve login-only aliases to the provider ID used by credentials and models. */
80
84
  export function canonicalizeOAuthProviderId(provider: string): string {
81
- if (provider === "google-antigravity-enterprise") return "google-antigravity";
82
85
  return provider;
83
86
  }
84
87