@f5-sales-demo/pi-ai 20.3.0 → 20.3.2

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": "20.3.0",
4
+ "version": "20.3.2",
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": "20.3.0",
49
+ "@f5-sales-demo/pi-utils": "20.3.2",
50
50
  "@google/genai": "^2.15",
51
51
  "@sinclair/typebox": "^0.34",
52
52
  "@smithy/node-http-handler": "^4.4",
@@ -2,6 +2,7 @@
2
2
  * Antigravity OAuth flow (Gemini 3, Claude, GPT-OSS via Google Cloud)
3
3
  * Uses different OAuth credentials than google-gemini-cli for access to additional models.
4
4
  */
5
+ import { $env } from "@f5-sales-demo/pi-utils";
5
6
  import { getAntigravityAuthHeaders } from "../../providers/google-gemini-cli";
6
7
  import { OAuthCallbackFlow } from "./callback-server";
7
8
  import type { OAuthController, OAuthCredentials } from "./types";
@@ -48,6 +49,24 @@ export const ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA = Object.freeze({
48
49
  pluginType: "GEMINI",
49
50
  });
50
51
 
52
+ interface AntigravityProjectRequest {
53
+ cloudaicompanionProject?: string;
54
+ metadata: typeof ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA & { duetProject?: string };
55
+ }
56
+
57
+ function buildProjectRequest(configuredProjectId: string | undefined): AntigravityProjectRequest {
58
+ if (!configuredProjectId) {
59
+ return { metadata: ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA };
60
+ }
61
+ return {
62
+ cloudaicompanionProject: configuredProjectId,
63
+ metadata: {
64
+ ...ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA,
65
+ duetProject: configuredProjectId,
66
+ },
67
+ };
68
+ }
69
+
51
70
  function readProjectId(value: string | { id?: string } | undefined): string | undefined {
52
71
  if (typeof value === "string" && value.length > 0) {
53
72
  return value;
@@ -72,7 +91,7 @@ function getDefaultTierId(allowedTiers?: Array<{ id?: string; isDefault?: boolea
72
91
  async function onboardProjectWithRetries(
73
92
  endpoint: string,
74
93
  headers: Record<string, string>,
75
- onboardBody: { tierId: string; metadata: typeof ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA },
94
+ onboardBody: { tierId: string } & AntigravityProjectRequest,
76
95
  onProgress?: (message: string) => void,
77
96
  ): Promise<string> {
78
97
  for (let attempt = 1; attempt <= PROJECT_ONBOARD_MAX_ATTEMPTS; attempt += 1) {
@@ -109,6 +128,8 @@ async function onboardProjectWithRetries(
109
128
  }
110
129
 
111
130
  async function discoverProject(accessToken: string, onProgress?: (message: string) => void): Promise<string> {
131
+ const configuredProjectId = $env.GOOGLE_CLOUD_PROJECT || $env.GOOGLE_CLOUD_PROJECT_ID;
132
+ const projectRequest = buildProjectRequest(configuredProjectId);
112
133
  const headers = {
113
134
  Authorization: `Bearer ${accessToken}`,
114
135
  "Content-Type": "application/json",
@@ -121,9 +142,7 @@ async function discoverProject(accessToken: string, onProgress?: (message: strin
121
142
  const loadResponse = await fetch(`${endpoint}/v1internal:loadCodeAssist`, {
122
143
  method: "POST",
123
144
  headers,
124
- body: JSON.stringify({
125
- metadata: ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA,
126
- }),
145
+ body: JSON.stringify(projectRequest),
127
146
  });
128
147
 
129
148
  if (!loadResponse.ok) {
@@ -134,17 +153,17 @@ async function discoverProject(accessToken: string, onProgress?: (message: strin
134
153
  const loadPayload = (await loadResponse.json()) as LoadCodeAssistPayload;
135
154
  const existingProject = readProjectId(loadPayload.cloudaicompanionProject);
136
155
  if (existingProject) {
137
- return existingProject;
156
+ return configuredProjectId ?? existingProject;
138
157
  }
139
158
 
140
159
  const tierId = getDefaultTierId(loadPayload.allowedTiers);
141
160
  onProgress?.("Provisioning project...");
142
161
  const onboardBody = {
143
162
  tierId,
144
- metadata: ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA,
163
+ ...projectRequest,
145
164
  };
146
165
  const provisionedProject = await onboardProjectWithRetries(endpoint, headers, onboardBody, onProgress);
147
- return provisionedProject;
166
+ return configuredProjectId ?? provisionedProject;
148
167
  } catch (error) {
149
168
  throw new Error(
150
169
  `Could not discover or provision an Antigravity project. ${error instanceof Error ? error.message : String(error)}`,