@herbertgao/pi-extensions 2026.11.18 → 2026.11.20
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/CHANGELOG.md +18 -0
- package/README.md +5 -5
- package/THIRD_PARTY_NOTICES.md +3 -24
- package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +956 -0
- package/node_modules/{pi-antigravity → @estebanforge/pi-antigravity-bridge}/LICENSE +1 -1
- package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +240 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +2117 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +61 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/connection.ts +644 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/driver.ts +1043 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/events.ts +323 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/home.ts +145 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/jsonrpc.ts +243 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/setup.ts +107 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/usage-estimate.ts +61 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agents.ts +64 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-install.ts +93 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-paths.ts +30 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-setup.ts +81 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-version.ts +289 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-detect.ts +161 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-gate.ts +233 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-hook.ts +325 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts-ui.ts +88 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts.ts +144 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/ask-tool.ts +1221 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/background-watch.ts +225 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/bridge-catalog.ts +197 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +523 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/daily-log.ts +196 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/dialog-lock.ts +48 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/diff-render.ts +207 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver-types.ts +168 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver.ts +907 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/engine-picker.ts +160 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/frame-guard.ts +38 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/handoff-toast.ts +21 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-registration.ts +376 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-server.ts +618 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/models.ts +404 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/native-tools.ts +104 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/parked-turn.ts +125 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/patch-cleanup.ts +523 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/poll-fold.ts +55 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/prompt-images.ts +92 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +2214 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/queued-messages.ts +152 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/quota-notice.ts +40 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/redact.ts +27 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/sessions.ts +197 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/skills.ts +207 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-events.ts +161 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-sanitizer.ts +180 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/subagent-roster.ts +245 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/sysprompt-agent.ts +130 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks-ui.ts +90 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks.ts +174 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/usage.ts +174 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/web-tools.ts +320 -0
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +3 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +1 -1
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +317 -105
- package/node_modules/@herbertgao/pi-subagents/SECURITY.md +2 -2
- package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +240 -36
- package/node_modules/@herbertgao/pi-subagents/docs/translations.md +63 -0
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +2 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +89 -6
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +6 -2
- package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +20 -11
- package/node_modules/@herbertgao/pi-subagents/src/cache-retention.ts +39 -0
- package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +5 -0
- package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +185 -44
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +7 -0
- package/node_modules/@herbertgao/pi-subagents/src/group-join.ts +9 -0
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +126 -116
- package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +3 -2
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +21 -0
- package/node_modules/@herbertgao/pi-subagents/src/subagent-info.ts +115 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +11 -7
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -3
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +2 -2
- package/node_modules/@herbertgao/pi-subagents/src/workflow-info.ts +184 -0
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +10 -0
- package/node_modules/pi-commandcode-provider/README.md +3 -2
- package/node_modules/pi-commandcode-provider/index.ts +120 -13
- package/node_modules/pi-commandcode-provider/package.json +4 -3
- package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +11 -2
- package/node_modules/pi-commandcode-provider/src/pricing.ts +17 -1
- package/node_modules/pi-commandcode-provider/src/quota-command.ts +3 -2
- package/node_modules/pi-commandcode-provider/src/zdr.ts +163 -0
- package/node_modules/pi-typesafe/README.md +1 -1
- package/node_modules/pi-typesafe/dist/ask.js +6 -3
- package/node_modules/pi-typesafe/dist/auth.d.ts +31 -7
- package/node_modules/pi-typesafe/dist/auth.js +159 -55
- package/node_modules/pi-typesafe/dist/batch.d.ts +16 -2
- package/node_modules/pi-typesafe/dist/batch.js +62 -22
- package/node_modules/pi-typesafe/dist/calibrate.d.ts +38 -11
- package/node_modules/pi-typesafe/dist/calibrate.js +56 -24
- package/node_modules/pi-typesafe/dist/client.d.ts +13 -0
- package/node_modules/pi-typesafe/dist/client.js +67 -27
- package/node_modules/pi-typesafe/dist/errors.d.ts +20 -0
- package/node_modules/pi-typesafe/dist/errors.js +105 -2
- package/node_modules/pi-typesafe/dist/extension.d.ts +106 -0
- package/node_modules/pi-typesafe/dist/extension.js +206 -106
- package/node_modules/pi-typesafe/dist/index.d.ts +8 -8
- package/node_modules/pi-typesafe/dist/index.js +3 -3
- package/node_modules/pi-typesafe/dist/key-prompt.d.ts +20 -0
- package/node_modules/pi-typesafe/dist/key-prompt.js +23 -3
- package/node_modules/pi-typesafe/dist/login.d.ts +58 -1
- package/node_modules/pi-typesafe/dist/login.js +167 -13
- package/node_modules/pi-typesafe/dist/schema.d.ts +3 -0
- package/node_modules/pi-typesafe/dist/schema.js +47 -13
- package/node_modules/pi-typesafe/dist/ui.d.ts +2 -1
- package/node_modules/pi-typesafe/dist/usage.d.ts +53 -0
- package/node_modules/pi-typesafe/dist/usage.js +79 -40
- package/node_modules/pi-typesafe/package.json +3 -3
- package/package.json +12 -15
- package/node_modules/pi-antigravity/README.md +0 -298
- package/node_modules/pi-antigravity/docs/reader-guarantees.md +0 -35
- package/node_modules/pi-antigravity/package.json +0 -87
- package/node_modules/pi-antigravity/src/auth/accounts.ts +0 -327
- package/node_modules/pi-antigravity/src/auth/index.ts +0 -23
- package/node_modules/pi-antigravity/src/auth/oauth.ts +0 -445
- package/node_modules/pi-antigravity/src/client/client.ts +0 -602
- package/node_modules/pi-antigravity/src/client/enterprise.ts +0 -150
- package/node_modules/pi-antigravity/src/client/index.ts +0 -2
- package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +0 -104
- package/node_modules/pi-antigravity/src/diagnostics/index.ts +0 -1
- package/node_modules/pi-antigravity/src/features/generate-image.ts +0 -132
- package/node_modules/pi-antigravity/src/features/google-search.ts +0 -72
- package/node_modules/pi-antigravity/src/features/read-url-content.ts +0 -124
- package/node_modules/pi-antigravity/src/image/image.ts +0 -427
- package/node_modules/pi-antigravity/src/image/index.ts +0 -1
- package/node_modules/pi-antigravity/src/image/native.ts +0 -69
- package/node_modules/pi-antigravity/src/index.ts +0 -547
- package/node_modules/pi-antigravity/src/models/discovery.ts +0 -176
- package/node_modules/pi-antigravity/src/models/grouping.ts +0 -487
- package/node_modules/pi-antigravity/src/models/index.ts +0 -3
- package/node_modules/pi-antigravity/src/models/models.ts +0 -647
- package/node_modules/pi-antigravity/src/search/index.ts +0 -1
- package/node_modules/pi-antigravity/src/search/search.ts +0 -967
- package/node_modules/pi-antigravity/src/stream/index.ts +0 -1
- package/node_modules/pi-antigravity/src/stream/stream.ts +0 -1961
- package/node_modules/pi-antigravity/src/types/enums.ts +0 -52
- package/node_modules/pi-antigravity/src/types/index.ts +0 -2
- package/node_modules/pi-antigravity/src/types/types.ts +0 -329
- package/node_modules/pi-antigravity/src/usage/index.ts +0 -1
- package/node_modules/pi-antigravity/src/usage/usage.ts +0 -437
- package/node_modules/pi-antigravity/src/utils/address.ts +0 -180
- package/node_modules/pi-antigravity/src/utils/credits.ts +0 -149
- package/node_modules/pi-antigravity/src/utils/html.ts +0 -31
- package/node_modules/pi-antigravity/src/utils/http.ts +0 -96
- package/node_modules/pi-antigravity/src/utils/index.ts +0 -5
- package/node_modules/pi-antigravity/src/utils/security.ts +0 -278
- package/node_modules/pi-antigravity/src/utils/text.ts +0 -66
- package/node_modules/pi-antigravity/src/utils/util.ts +0 -217
- package/node_modules/pi-antigravity/src/web-fetch/document.ts +0 -83
- package/node_modules/pi-antigravity/src/web-fetch/fences.ts +0 -24
- package/node_modules/pi-antigravity/src/web-fetch/header.ts +0 -97
- package/node_modules/pi-antigravity/src/web-fetch/index.ts +0 -3
- package/node_modules/pi-antigravity/src/web-fetch/inspect.ts +0 -328
- package/node_modules/pi-antigravity/src/web-fetch/limits.ts +0 -4
- package/node_modules/pi-antigravity/src/web-fetch/markdown.ts +0 -744
- package/node_modules/pi-antigravity/src/web-fetch/mdn.ts +0 -164
- package/node_modules/pi-antigravity/src/web-fetch/media.ts +0 -11
- package/node_modules/pi-antigravity/src/web-fetch/metadata.ts +0 -9
- package/node_modules/pi-antigravity/src/web-fetch/representation.ts +0 -93
- package/node_modules/pi-antigravity/src/web-fetch/save.ts +0 -71
- package/node_modules/pi-antigravity/src/web-fetch/sites.ts +0 -138
- package/node_modules/pi-antigravity/src/web-fetch/vendor.d.ts +0 -9
- package/node_modules/pi-antigravity/src/web-fetch/web-fetch.ts +0 -957
- package/node_modules/pi-antigravity/tsconfig.json +0 -21
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
getCurrentAvailableModels,
|
|
4
|
-
getCurrentEndpoint,
|
|
5
|
-
getCurrentMatchedModelDebug,
|
|
6
|
-
setLastAvailableModels,
|
|
7
|
-
setLastEndpoint,
|
|
8
|
-
setLastError,
|
|
9
|
-
setLastMatchedModelDebug,
|
|
10
|
-
setLastStatus,
|
|
11
|
-
} from "../diagnostics/diagnostics.js";
|
|
12
|
-
import { assertSafeApiBaseUrl, safeError } from "../utils/security.js";
|
|
13
|
-
import type { AntigravityApiKey, AvailableModelsRaw, DynamicModelInfo } from "../types/types.js";
|
|
14
|
-
import { antigravityEnv, asString, isRecord } from "../utils/util.js";
|
|
15
|
-
import { antigravityFetch } from "../utils/http.js";
|
|
16
|
-
import { registerDiscoveredModelEnums, registerModelEnum } from "../models/models.js";
|
|
17
|
-
|
|
18
|
-
export const DEFAULT_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
|
|
19
|
-
export const ENDPOINT_FALLBACKS = [
|
|
20
|
-
DEFAULT_ENDPOINT,
|
|
21
|
-
"https://daily-cloudcode-pa.sandbox.googleapis.com",
|
|
22
|
-
"https://cloudcode-pa.googleapis.com",
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const PROJECT_CACHE_TTL_MS = 30 * 60 * 1000;
|
|
26
|
-
const projectCache = new Map<string, { projectId: string | undefined; expiresAt: number }>();
|
|
27
|
-
|
|
28
|
-
const MODEL_CACHE_TTL_MS = 30 * 60 * 1000;
|
|
29
|
-
const modelCache = new Map<string, { result: DynamicModelInfo | undefined; expiresAt: number }>();
|
|
30
|
-
|
|
31
|
-
/** Metadata lookups (project/model discovery) must be fast; a stalled endpoint should
|
|
32
|
-
* fall through to the next candidate instead of hanging the whole request. */
|
|
33
|
-
const DISCOVERY_TIMEOUT_MS = 8000;
|
|
34
|
-
|
|
35
|
-
/** In-flight de-dupe: concurrent requests for the same (token, project, model) share one probe. */
|
|
36
|
-
const inFlightModelLookups = new Map<string, Promise<DynamicModelInfo | undefined>>();
|
|
37
|
-
|
|
38
|
-
/** UUID-shaped stable id from a seed (account email preferred over cwd). */
|
|
39
|
-
export function stableProjectId(seed: string): string {
|
|
40
|
-
const bytes = createHash("sha1").update(`antigravity:${seed}`).digest().subarray(0, 16);
|
|
41
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x50;
|
|
42
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
43
|
-
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
44
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Fallback project id when discovery fails.
|
|
49
|
-
* Prefer ANTIGRAVITY_PROJECT_ID, then a stable seed (email), never process.cwd().
|
|
50
|
-
*/
|
|
51
|
-
export function defaultProjectId(seed = "antigravity-default"): string {
|
|
52
|
-
return antigravityEnv("PROJECT_ID")?.trim() || stableProjectId(seed);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @deprecated Use defaultProjectId(seed); kept for scripts that imported the old constant. */
|
|
56
|
-
export const DEFAULT_PROJECT_ID = defaultProjectId();
|
|
57
|
-
|
|
58
|
-
export function endpointCandidates(): string[] {
|
|
59
|
-
const explicit = antigravityEnv("BASE_URL")?.trim();
|
|
60
|
-
return explicit ? [assertSafeApiBaseUrl(explicit)] : ENDPOINT_FALLBACKS;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Catalog visibility is gated on this version. 1.2.4 hides Gemini 4 Argon.
|
|
64
|
-
// 1.5.5 matches the current official agy CLI release (#122, #123).
|
|
65
|
-
const DEFAULT_USER_AGENT =
|
|
66
|
-
"antigravity/cli/1.5.5 (aidev_client; os_type=linux; arch=amd64; cl=982146307; auth_method=consumer)";
|
|
67
|
-
|
|
68
|
-
/** Default User-Agent matching pure Antigravity CLI wire fingerprint. */
|
|
69
|
-
export function defaultUserAgent(): string {
|
|
70
|
-
return DEFAULT_USER_AGENT;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** HTTP headers for Antigravity API requests matching CLI wire traffic. */
|
|
74
|
-
export function antigravityHeaders(token: string): Record<string, string> {
|
|
75
|
-
return {
|
|
76
|
-
Authorization: `Bearer ${token}`,
|
|
77
|
-
"Content-Type": "application/json",
|
|
78
|
-
"User-Agent": antigravityEnv("USER_AGENT") || defaultUserAgent(),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function jsonOrTextError(text: string): string {
|
|
83
|
-
try {
|
|
84
|
-
const parsed = JSON.parse(text) as {
|
|
85
|
-
error?: { message?: string; status?: string; code?: number };
|
|
86
|
-
};
|
|
87
|
-
if (typeof parsed.error?.message === "string") return parsed.error.message;
|
|
88
|
-
} catch {
|
|
89
|
-
// not JSON
|
|
90
|
-
}
|
|
91
|
-
return text;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function parseApiKey(apiKeyRaw: string | undefined): AntigravityApiKey {
|
|
95
|
-
if (!apiKeyRaw) {
|
|
96
|
-
throw new Error("No Antigravity OAuth credentials. Run /login antigravity.");
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const parsed: unknown = JSON.parse(apiKeyRaw);
|
|
100
|
-
if (
|
|
101
|
-
!isRecord(parsed) ||
|
|
102
|
-
typeof parsed.token !== "string" ||
|
|
103
|
-
!/^[\x21-\x7e]+$/.test(parsed.token) ||
|
|
104
|
-
typeof parsed.projectId !== "string" ||
|
|
105
|
-
!/^[\x21-\x7e]+$/.test(parsed.projectId)
|
|
106
|
-
)
|
|
107
|
-
throw new Error("missing token or projectId");
|
|
108
|
-
return { token: parsed.token, projectId: parsed.projectId };
|
|
109
|
-
} catch {
|
|
110
|
-
// JSON parser errors can quote the credential input. Do not retain that cause.
|
|
111
|
-
throw new Error("Invalid Antigravity credentials. Run /login antigravity.");
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function extractProjectId(data: unknown): string | undefined {
|
|
116
|
-
if (!isRecord(data)) return undefined;
|
|
117
|
-
const direct =
|
|
118
|
-
data.antigravityProjectId ??
|
|
119
|
-
data.projectId ??
|
|
120
|
-
data.backendProjectId ??
|
|
121
|
-
data.userDefinedCloudaicompanionProject ??
|
|
122
|
-
data.cloudaicompanionProject ??
|
|
123
|
-
data.project;
|
|
124
|
-
const directId = asString(direct);
|
|
125
|
-
if (directId) return directId;
|
|
126
|
-
if (isRecord(direct)) {
|
|
127
|
-
const nestedId = asString(direct.id);
|
|
128
|
-
if (nestedId) return nestedId;
|
|
129
|
-
}
|
|
130
|
-
for (const key of ["projects", "projectIds", "cloudaicompanionProjects"]) {
|
|
131
|
-
const value = data[key];
|
|
132
|
-
if (Array.isArray(value)) {
|
|
133
|
-
for (const item of value) {
|
|
134
|
-
const nested = extractProjectId(item);
|
|
135
|
-
if (nested) return nested;
|
|
136
|
-
const itemId = asString(item);
|
|
137
|
-
if (itemId) return itemId;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function listCloudAICompanionProjects(token: string): Promise<string | undefined> {
|
|
145
|
-
for (const endpoint of endpointCandidates()) {
|
|
146
|
-
try {
|
|
147
|
-
const res = await antigravityFetch(`${endpoint}/v1internal:listCloudAICompanionProjects`, {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: antigravityHeaders(token),
|
|
150
|
-
body: JSON.stringify({}),
|
|
151
|
-
signal: AbortSignal.timeout(DISCOVERY_TIMEOUT_MS),
|
|
152
|
-
});
|
|
153
|
-
setLastStatus(res.status);
|
|
154
|
-
setLastEndpoint(endpoint);
|
|
155
|
-
if (!res.ok) continue;
|
|
156
|
-
return extractProjectId(await res.json());
|
|
157
|
-
} catch (error) {
|
|
158
|
-
setLastError(safeError(error));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function collectModelLabels(value: unknown, out: string[] = []): string[] {
|
|
165
|
-
if (!value || out.length > 50) return out;
|
|
166
|
-
if (typeof value === "string") {
|
|
167
|
-
if (/gemini|claude|gpt-oss/i.test(value)) out.push(value);
|
|
168
|
-
return out;
|
|
169
|
-
}
|
|
170
|
-
if (Array.isArray(value)) {
|
|
171
|
-
for (const item of value) collectModelLabels(item, out);
|
|
172
|
-
return out;
|
|
173
|
-
}
|
|
174
|
-
if (isRecord(value)) {
|
|
175
|
-
for (const key of ["id", "name", "label", "displayName", "model", "modelId"]) {
|
|
176
|
-
collectModelLabels(value[key], out);
|
|
177
|
-
}
|
|
178
|
-
for (const nested of Object.values(value)) {
|
|
179
|
-
if (nested && typeof nested === "object") collectModelLabels(nested, out);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return out;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function summarizeModelCandidate(value: unknown): string {
|
|
186
|
-
if (!isRecord(value)) return String(value ?? "none");
|
|
187
|
-
const out: Record<string, unknown> = {};
|
|
188
|
-
for (const [key, raw] of Object.entries(value)) {
|
|
189
|
-
if (/token|auth|credential|secret|email/i.test(key)) continue;
|
|
190
|
-
if (raw === null || ["string", "number", "boolean"].includes(typeof raw)) out[key] = raw;
|
|
191
|
-
else if (Array.isArray(raw)) out[key] = `[array:${String(raw.length)}]`;
|
|
192
|
-
else if (isRecord(raw)) {
|
|
193
|
-
out[key] = `{${Object.keys(raw).slice(0, 12).join(",")}}`;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return JSON.stringify(out).slice(0, 1200);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Runtime ids must not be internal placeholder enums, internal chats, or image endpoints. */
|
|
200
|
-
export function isUsableRuntimeModelId(id: string): boolean {
|
|
201
|
-
return (
|
|
202
|
-
/^[a-z0-9][a-z0-9_.-]*$/i.test(id) &&
|
|
203
|
-
!/\s/.test(id) &&
|
|
204
|
-
!/^MODEL_/i.test(id) &&
|
|
205
|
-
!/^(chat_|tab_)/i.test(id) &&
|
|
206
|
-
!/image/i.test(id)
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function dynamicModelFromInfo(modelId: string, info: unknown): DynamicModelInfo {
|
|
211
|
-
if (!isRecord(info)) return { id: modelId };
|
|
212
|
-
setLastMatchedModelDebug(summarizeModelCandidate({ modelId, ...info }));
|
|
213
|
-
const experiments = Array.isArray(info.modelExperiments)
|
|
214
|
-
? info.modelExperiments.filter((item): item is string => typeof item === "string")
|
|
215
|
-
: undefined;
|
|
216
|
-
const modelEnum = asString(info.model);
|
|
217
|
-
if (modelEnum) {
|
|
218
|
-
registerModelEnum(modelId, modelEnum);
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
id: modelId,
|
|
222
|
-
experiments,
|
|
223
|
-
apiProvider: asString(info.apiProvider),
|
|
224
|
-
modelProvider: asString(info.modelProvider),
|
|
225
|
-
model: modelEnum,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Resolve a requested runtime model against fetchAvailableModels payload.
|
|
231
|
-
* The real runtime ids are the keys of `data.models`; the nested `model` field is often
|
|
232
|
-
* a MODEL_PLACEHOLDER_* enum that 404s on streamGenerateContent.
|
|
233
|
-
*
|
|
234
|
-
* Uses deterministic key lookup (exact or case-insensitive) and exact display name match.
|
|
235
|
-
* Zero regexes, zero prefix wildcards, zero fuzzy guessing.
|
|
236
|
-
*/
|
|
237
|
-
function findDynamicModel(value: unknown, requestedId: string): DynamicModelInfo | undefined {
|
|
238
|
-
if (!value) return undefined;
|
|
239
|
-
|
|
240
|
-
if (isRecord(value) && isRecord(value.models)) {
|
|
241
|
-
const modelsMap = value.models;
|
|
242
|
-
// 1. Direct exact key lookup
|
|
243
|
-
if (isUsableRuntimeModelId(requestedId) && requestedId in modelsMap) {
|
|
244
|
-
return dynamicModelFromInfo(requestedId, modelsMap[requestedId]);
|
|
245
|
-
}
|
|
246
|
-
// 2. Case-insensitive exact key lookup
|
|
247
|
-
const lowerReq = requestedId.toLowerCase();
|
|
248
|
-
for (const [modelId, info] of Object.entries(modelsMap)) {
|
|
249
|
-
if (modelId.toLowerCase() === lowerReq && isUsableRuntimeModelId(modelId)) {
|
|
250
|
-
return dynamicModelFromInfo(modelId, info);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// 3. Exact display name lookup (for when a user references an exact model label)
|
|
254
|
-
for (const [modelId, info] of Object.entries(modelsMap)) {
|
|
255
|
-
if (!isUsableRuntimeModelId(modelId)) continue;
|
|
256
|
-
if (isRecord(info)) {
|
|
257
|
-
const label = info.label ?? info.displayName ?? info.name;
|
|
258
|
-
if (typeof label === "string" && label.toLowerCase() === lowerReq) {
|
|
259
|
-
return dynamicModelFromInfo(modelId, info);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (typeof value === "string") {
|
|
267
|
-
return value.toLowerCase() === requestedId.toLowerCase() && isUsableRuntimeModelId(value)
|
|
268
|
-
? { id: value }
|
|
269
|
-
: undefined;
|
|
270
|
-
}
|
|
271
|
-
if (Array.isArray(value)) {
|
|
272
|
-
for (const item of value) {
|
|
273
|
-
const found = findDynamicModel(item, requestedId);
|
|
274
|
-
if (found) return found;
|
|
275
|
-
}
|
|
276
|
-
return undefined;
|
|
277
|
-
}
|
|
278
|
-
if (isRecord(value)) {
|
|
279
|
-
for (const nested of Object.values(value)) {
|
|
280
|
-
if (nested && typeof nested === "object") {
|
|
281
|
-
const found = findDynamicModel(nested, requestedId);
|
|
282
|
-
if (found) return found;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
async function fetchAvailableRuntimeModelUncached(
|
|
290
|
-
token: string,
|
|
291
|
-
projectId: string,
|
|
292
|
-
requestedRuntimeModel: string,
|
|
293
|
-
): Promise<DynamicModelInfo | undefined> {
|
|
294
|
-
const body = JSON.stringify({ project: projectId });
|
|
295
|
-
const endpoints = endpointCandidates();
|
|
296
|
-
let lastLabels = "";
|
|
297
|
-
|
|
298
|
-
// Try endpoints in priority order (production first). If the primary endpoint
|
|
299
|
-
// resolves the model, return immediately without waiting on slower sandbox endpoints.
|
|
300
|
-
for (const endpoint of endpoints) {
|
|
301
|
-
try {
|
|
302
|
-
const res = await antigravityFetch(`${endpoint}/v1internal:fetchAvailableModels`, {
|
|
303
|
-
method: "POST",
|
|
304
|
-
headers: antigravityHeaders(token),
|
|
305
|
-
body,
|
|
306
|
-
signal: AbortSignal.timeout(DISCOVERY_TIMEOUT_MS),
|
|
307
|
-
});
|
|
308
|
-
setLastStatus(res.status);
|
|
309
|
-
if (!res.ok) continue;
|
|
310
|
-
setLastEndpoint(endpoint);
|
|
311
|
-
const data: unknown = await res.json();
|
|
312
|
-
if (isRecord(data) && isRecord(data.models)) {
|
|
313
|
-
registerDiscoveredModelEnums(data.models as Record<string, { model?: unknown }>);
|
|
314
|
-
}
|
|
315
|
-
const labels = [...new Set(collectModelLabels(data))].slice(0, 16);
|
|
316
|
-
if (labels.length) lastLabels = labels.join(",");
|
|
317
|
-
const found = findDynamicModel(data, requestedRuntimeModel);
|
|
318
|
-
if (found) {
|
|
319
|
-
if (lastLabels) setLastAvailableModels(lastLabels);
|
|
320
|
-
return found;
|
|
321
|
-
}
|
|
322
|
-
} catch (error) {
|
|
323
|
-
setLastError(safeError(error));
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (lastLabels) setLastAvailableModels(lastLabels);
|
|
328
|
-
return undefined;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export async function fetchAvailableRuntimeModel(
|
|
332
|
-
token: string,
|
|
333
|
-
projectId: string,
|
|
334
|
-
requestedRuntimeModel: string,
|
|
335
|
-
): Promise<DynamicModelInfo | undefined> {
|
|
336
|
-
const cacheKey = `${token}::${projectId}::${requestedRuntimeModel}`;
|
|
337
|
-
const cached = modelCache.get(cacheKey);
|
|
338
|
-
if (cached && cached.expiresAt > Date.now()) return cached.result;
|
|
339
|
-
|
|
340
|
-
// De-dupe concurrent lookups for the same key (e.g. parallel requests right after
|
|
341
|
-
// startup) so they share one probe instead of each firing their own round-trips.
|
|
342
|
-
const inFlight = inFlightModelLookups.get(cacheKey);
|
|
343
|
-
if (inFlight) return inFlight;
|
|
344
|
-
|
|
345
|
-
const promise = fetchAvailableRuntimeModelUncached(token, projectId, requestedRuntimeModel).then(
|
|
346
|
-
(result) => {
|
|
347
|
-
modelCache.set(cacheKey, { result, expiresAt: Date.now() + MODEL_CACHE_TTL_MS });
|
|
348
|
-
return result;
|
|
349
|
-
},
|
|
350
|
-
);
|
|
351
|
-
inFlightModelLookups.set(cacheKey, promise);
|
|
352
|
-
try {
|
|
353
|
-
return await promise;
|
|
354
|
-
} finally {
|
|
355
|
-
inFlightModelLookups.delete(cacheKey);
|
|
356
|
-
// Evict expired entries; bound map size to avoid unbounded growth.
|
|
357
|
-
if (modelCache.size > 64) {
|
|
358
|
-
const now = Date.now();
|
|
359
|
-
for (const [key, entry] of modelCache) {
|
|
360
|
-
if (entry.expiresAt <= now) modelCache.delete(key);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export function clearModelCache(): void {
|
|
367
|
-
modelCache.clear();
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async function fetchAvailableModelsFromEndpoint(
|
|
371
|
-
endpoint: string,
|
|
372
|
-
token: string,
|
|
373
|
-
projectId: string,
|
|
374
|
-
signal?: AbortSignal,
|
|
375
|
-
): Promise<{ endpoint: string; status: number; data: unknown } | undefined> {
|
|
376
|
-
try {
|
|
377
|
-
const res = await antigravityFetch(`${endpoint}/v1internal:fetchAvailableModels`, {
|
|
378
|
-
method: "POST",
|
|
379
|
-
headers: antigravityHeaders(token),
|
|
380
|
-
body: JSON.stringify({ project: projectId }),
|
|
381
|
-
signal: catalogSignal(signal),
|
|
382
|
-
});
|
|
383
|
-
const text = await res.text();
|
|
384
|
-
let data: unknown;
|
|
385
|
-
try {
|
|
386
|
-
data = JSON.parse(text) as unknown;
|
|
387
|
-
} catch {
|
|
388
|
-
data = { raw: text };
|
|
389
|
-
}
|
|
390
|
-
if (!res.ok) {
|
|
391
|
-
const message =
|
|
392
|
-
isRecord(data) && isRecord(data.error) && typeof data.error.message === "string"
|
|
393
|
-
? data.error.message
|
|
394
|
-
: text;
|
|
395
|
-
setLastError(message);
|
|
396
|
-
return undefined;
|
|
397
|
-
}
|
|
398
|
-
return { endpoint, status: res.status, data };
|
|
399
|
-
} catch (error) {
|
|
400
|
-
setLastError(safeError(error));
|
|
401
|
-
return undefined;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function catalogSignal(signal?: AbortSignal): AbortSignal {
|
|
406
|
-
const timeout = AbortSignal.timeout(DISCOVERY_TIMEOUT_MS);
|
|
407
|
-
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** Merge catalog payloads from one or more fetchAvailableModels responses. */
|
|
411
|
-
export function mergeAvailableModelsResults(
|
|
412
|
-
results: Array<{ endpoint: string; status: number; data: unknown } | undefined>,
|
|
413
|
-
): { endpoint: string; status: number; data: AvailableModelsRaw } {
|
|
414
|
-
const mergedModels: Record<string, unknown> = {};
|
|
415
|
-
let defaultAgentModelId: string | undefined;
|
|
416
|
-
let defaultAgentModel: string | undefined;
|
|
417
|
-
const agentModelSortsSources: Array<NonNullable<AvailableModelsRaw["agentModelSorts"]>> = [];
|
|
418
|
-
let lastEndpoint = "";
|
|
419
|
-
let lastStatus = 0;
|
|
420
|
-
|
|
421
|
-
for (const result of results) {
|
|
422
|
-
if (
|
|
423
|
-
!result ||
|
|
424
|
-
!isRecord(result.data) ||
|
|
425
|
-
!isRecord(result.data.models) ||
|
|
426
|
-
Object.keys(result.data.models).length === 0 ||
|
|
427
|
-
!Object.values(result.data.models).every(isRecord)
|
|
428
|
-
)
|
|
429
|
-
continue;
|
|
430
|
-
setLastEndpoint(result.endpoint);
|
|
431
|
-
setLastStatus(result.status);
|
|
432
|
-
lastEndpoint = result.endpoint;
|
|
433
|
-
lastStatus = result.status;
|
|
434
|
-
const data = result.data;
|
|
435
|
-
if (isRecord(data) && isRecord(data.models)) {
|
|
436
|
-
Object.assign(mergedModels, data.models);
|
|
437
|
-
registerDiscoveredModelEnums(data.models as Record<string, { model?: unknown }>);
|
|
438
|
-
}
|
|
439
|
-
if (isRecord(data) && typeof data.defaultAgentModelId === "string") {
|
|
440
|
-
defaultAgentModelId = data.defaultAgentModelId;
|
|
441
|
-
}
|
|
442
|
-
if (isRecord(data) && typeof data.defaultAgentModel === "string") {
|
|
443
|
-
defaultAgentModel = data.defaultAgentModel;
|
|
444
|
-
}
|
|
445
|
-
if (isRecord(data) && Array.isArray(data.agentModelSorts)) {
|
|
446
|
-
agentModelSortsSources.push(
|
|
447
|
-
data.agentModelSorts as NonNullable<AvailableModelsRaw["agentModelSorts"]>,
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
if (!lastEndpoint) {
|
|
453
|
-
throw new Error(
|
|
454
|
-
`/v1internal:fetchAvailableModels failed: no endpoint returned a valid non-empty catalog`,
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return {
|
|
459
|
-
endpoint: lastEndpoint,
|
|
460
|
-
status: lastStatus,
|
|
461
|
-
data: {
|
|
462
|
-
models: mergedModels as AvailableModelsRaw["models"],
|
|
463
|
-
defaultAgentModelId,
|
|
464
|
-
defaultAgentModel,
|
|
465
|
-
agentModelSorts: mergeAgentModelSorts(agentModelSortsSources),
|
|
466
|
-
},
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Union the curated `agentModelSorts` recommendation lists from every endpoint.
|
|
472
|
-
* New models roll out on the daily/sandbox endpoints before production (e.g.
|
|
473
|
-
* Gemini 4 Carbon, #123); a last-endpoint-wins merge lets the production list
|
|
474
|
-
* hide models the other endpoints already recommend, while the merged `models`
|
|
475
|
-
* dictionary above is a union. Sorts are matched by `displayName` and groups by
|
|
476
|
-
* position; first-seen order wins so the primary endpoint keeps its ranking.
|
|
477
|
-
*/
|
|
478
|
-
function mergeAgentModelSorts(
|
|
479
|
-
sources: Array<NonNullable<AvailableModelsRaw["agentModelSorts"]>>,
|
|
480
|
-
): AvailableModelsRaw["agentModelSorts"] {
|
|
481
|
-
if (sources.length === 0) return undefined;
|
|
482
|
-
const seen = new Set<string>();
|
|
483
|
-
const merged: Array<{ displayName?: unknown; groups: Array<{ modelIds: string[] }> }> = [];
|
|
484
|
-
for (const sorts of sources) {
|
|
485
|
-
for (const sort of sorts) {
|
|
486
|
-
if (!isRecord(sort)) continue;
|
|
487
|
-
const displayName = typeof sort.displayName === "string" ? sort.displayName : undefined;
|
|
488
|
-
let target = merged.find((entry) => entry.displayName === displayName);
|
|
489
|
-
if (!target) {
|
|
490
|
-
target = { ...(displayName !== undefined ? { displayName } : {}), groups: [] };
|
|
491
|
-
merged.push(target);
|
|
492
|
-
}
|
|
493
|
-
const groups = Array.isArray(sort.groups) ? sort.groups : [];
|
|
494
|
-
groups.forEach((group, index) => {
|
|
495
|
-
let targetGroup = target.groups[index];
|
|
496
|
-
if (!targetGroup) {
|
|
497
|
-
targetGroup = { modelIds: [] };
|
|
498
|
-
target.groups[index] = targetGroup;
|
|
499
|
-
}
|
|
500
|
-
const modelIds = isRecord(group) && Array.isArray(group.modelIds) ? group.modelIds : [];
|
|
501
|
-
for (const id of modelIds) {
|
|
502
|
-
if (typeof id !== "string" || !id || seen.has(id)) continue;
|
|
503
|
-
seen.add(id);
|
|
504
|
-
targetGroup.modelIds.push(id);
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return merged.length > 0 ? merged : undefined;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Merge fetchAvailableModels across endpoint candidates so daily/sandbox-only
|
|
514
|
-
* models appear alongside production catalog entries.
|
|
515
|
-
*/
|
|
516
|
-
export async function fetchAvailableModelsCatalog(
|
|
517
|
-
token: string,
|
|
518
|
-
projectId: string,
|
|
519
|
-
signal?: AbortSignal,
|
|
520
|
-
): Promise<{ endpoint: string; status: number; data: AvailableModelsRaw }> {
|
|
521
|
-
const results = await Promise.all(
|
|
522
|
-
endpointCandidates().map((endpoint) =>
|
|
523
|
-
fetchAvailableModelsFromEndpoint(endpoint, token, projectId, signal),
|
|
524
|
-
),
|
|
525
|
-
);
|
|
526
|
-
return mergeAvailableModelsResults(results);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
async function loadCodeAssistUncached(token: string): Promise<string | undefined> {
|
|
530
|
-
const body = JSON.stringify({
|
|
531
|
-
metadata: {
|
|
532
|
-
ideType: "ANTIGRAVITY",
|
|
533
|
-
},
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
for (const endpoint of endpointCandidates()) {
|
|
537
|
-
try {
|
|
538
|
-
const res = await antigravityFetch(`${endpoint}/v1internal:loadCodeAssist`, {
|
|
539
|
-
method: "POST",
|
|
540
|
-
headers: antigravityHeaders(token),
|
|
541
|
-
body,
|
|
542
|
-
signal: AbortSignal.timeout(DISCOVERY_TIMEOUT_MS),
|
|
543
|
-
});
|
|
544
|
-
setLastStatus(res.status);
|
|
545
|
-
setLastEndpoint(endpoint);
|
|
546
|
-
if (!res.ok) continue;
|
|
547
|
-
const project = extractProjectId(await res.json());
|
|
548
|
-
if (project) return project;
|
|
549
|
-
return await listCloudAICompanionProjects(token);
|
|
550
|
-
} catch (error) {
|
|
551
|
-
setLastError(safeError(error));
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return undefined;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/** Discover project id with a short in-memory LRU cache keyed by access token. */
|
|
558
|
-
export async function loadCodeAssist(token: string): Promise<string | undefined> {
|
|
559
|
-
const cached = projectCache.get(token);
|
|
560
|
-
if (cached && cached.expiresAt > Date.now()) {
|
|
561
|
-
// Refresh LRU order: delete and re-insert so newest is at the end.
|
|
562
|
-
projectCache.delete(token);
|
|
563
|
-
projectCache.set(token, cached);
|
|
564
|
-
return cached.projectId;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const projectId = await loadCodeAssistUncached(token);
|
|
568
|
-
projectCache.set(token, { projectId, expiresAt: Date.now() + PROJECT_CACHE_TTL_MS });
|
|
569
|
-
|
|
570
|
-
// Evict oldest entry when the cache exceeds 32 entries (O(1) — Map preserves insertion order).
|
|
571
|
-
if (projectCache.size > 32) {
|
|
572
|
-
const oldestKey = projectCache.keys().next().value;
|
|
573
|
-
if (oldestKey !== undefined) projectCache.delete(oldestKey);
|
|
574
|
-
}
|
|
575
|
-
return projectId;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export function clearProjectCache(): void {
|
|
579
|
-
projectCache.clear();
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
export function resolveProjectId(opts: {
|
|
583
|
-
token: string;
|
|
584
|
-
credentialProjectId?: string;
|
|
585
|
-
email?: string;
|
|
586
|
-
warmedProject?: string | null;
|
|
587
|
-
}): string {
|
|
588
|
-
return (
|
|
589
|
-
antigravityEnv("PROJECT_ID")?.trim() ||
|
|
590
|
-
opts.warmedProject ||
|
|
591
|
-
opts.credentialProjectId ||
|
|
592
|
-
defaultProjectId(opts.email || "antigravity-default")
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/** Build a diagnostic suffix using the active request bag. */
|
|
597
|
-
export function formatRequestDiagnostics(extra: {
|
|
598
|
-
projectId: string;
|
|
599
|
-
runtimeModel: string;
|
|
600
|
-
}): string {
|
|
601
|
-
return `endpoint=${getCurrentEndpoint() || "unknown"}, project=${extra.projectId}, runtimeModel=${extra.runtimeModel}, matched=${getCurrentMatchedModelDebug() || "none"}, available=${getCurrentAvailableModels() || "unknown"}`;
|
|
602
|
-
}
|