@cortexkit/antigravity-auth-core 1.0.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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/agy-transport.d.ts +15 -0
  4. package/dist/agy-transport.d.ts.map +1 -0
  5. package/dist/agy-transport.js +380 -0
  6. package/dist/agy-transport.js.map +1 -0
  7. package/dist/antigravity/oauth.d.ts +42 -0
  8. package/dist/antigravity/oauth.d.ts.map +1 -0
  9. package/dist/antigravity/oauth.js +179 -0
  10. package/dist/antigravity/oauth.js.map +1 -0
  11. package/dist/auth-types.d.ts +26 -0
  12. package/dist/auth-types.d.ts.map +1 -0
  13. package/dist/auth-types.js +3 -0
  14. package/dist/auth-types.js.map +1 -0
  15. package/dist/auth.d.ts +21 -0
  16. package/dist/auth.d.ts.map +1 -0
  17. package/dist/auth.js +46 -0
  18. package/dist/auth.js.map +1 -0
  19. package/dist/constants.d.ts +146 -0
  20. package/dist/constants.d.ts.map +1 -0
  21. package/dist/constants.js +214 -0
  22. package/dist/constants.js.map +1 -0
  23. package/dist/fingerprint.d.ts +73 -0
  24. package/dist/fingerprint.d.ts.map +1 -0
  25. package/dist/fingerprint.js +129 -0
  26. package/dist/fingerprint.js.map +1 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +15 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/logger.d.ts +32 -0
  32. package/dist/logger.d.ts.map +1 -0
  33. package/dist/logger.js +67 -0
  34. package/dist/logger.js.map +1 -0
  35. package/dist/model-registry.d.ts +47 -0
  36. package/dist/model-registry.d.ts.map +1 -0
  37. package/dist/model-registry.js +214 -0
  38. package/dist/model-registry.js.map +1 -0
  39. package/dist/model-types.d.ts +8 -0
  40. package/dist/model-types.d.ts.map +1 -0
  41. package/dist/model-types.js +3 -0
  42. package/dist/model-types.js.map +1 -0
  43. package/dist/project.d.ts +34 -0
  44. package/dist/project.d.ts.map +1 -0
  45. package/dist/project.js +236 -0
  46. package/dist/project.js.map +1 -0
  47. package/dist/transform/claude.d.ts +92 -0
  48. package/dist/transform/claude.d.ts.map +1 -0
  49. package/dist/transform/claude.js +280 -0
  50. package/dist/transform/claude.js.map +1 -0
  51. package/dist/transform/cross-model-sanitizer.d.ts +35 -0
  52. package/dist/transform/cross-model-sanitizer.d.ts.map +1 -0
  53. package/dist/transform/cross-model-sanitizer.js +225 -0
  54. package/dist/transform/cross-model-sanitizer.js.map +1 -0
  55. package/dist/transform/gemini.d.ts +100 -0
  56. package/dist/transform/gemini.d.ts.map +1 -0
  57. package/dist/transform/gemini.js +446 -0
  58. package/dist/transform/gemini.js.map +1 -0
  59. package/dist/transform/index.d.ts +15 -0
  60. package/dist/transform/index.d.ts.map +1 -0
  61. package/dist/transform/index.js +14 -0
  62. package/dist/transform/index.js.map +1 -0
  63. package/dist/transform/model-resolver.d.ts +95 -0
  64. package/dist/transform/model-resolver.d.ts.map +1 -0
  65. package/dist/transform/model-resolver.js +398 -0
  66. package/dist/transform/model-resolver.js.map +1 -0
  67. package/dist/transform/types.d.ts +111 -0
  68. package/dist/transform/types.d.ts.map +1 -0
  69. package/dist/transform/types.js +2 -0
  70. package/dist/transform/types.js.map +1 -0
  71. package/dist/version.d.ts +26 -0
  72. package/dist/version.d.ts.map +1 -0
  73. package/dist/version.js +87 -0
  74. package/dist/version.js.map +1 -0
  75. package/package.json +44 -0
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Constants used for Antigravity OAuth flows and Cloud Code Assist API integration.
3
+ */
4
+ export const ANTIGRAVITY_CLIENT_ID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
5
+ /**
6
+ * Client secret issued for the Antigravity OAuth application.
7
+ */
8
+ export const ANTIGRAVITY_CLIENT_SECRET = "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";
9
+ /**
10
+ * Scopes required for Antigravity integrations.
11
+ */
12
+ export const ANTIGRAVITY_SCOPES = [
13
+ "https://www.googleapis.com/auth/cloud-platform",
14
+ "https://www.googleapis.com/auth/userinfo.email",
15
+ "https://www.googleapis.com/auth/userinfo.profile",
16
+ "https://www.googleapis.com/auth/cclog",
17
+ "https://www.googleapis.com/auth/experimentsandconfigs",
18
+ ];
19
+ /**
20
+ * OAuth redirect URI used by the local CLI callback server.
21
+ */
22
+ export const ANTIGRAVITY_REDIRECT_URI = "http://localhost:51121/oauth-callback";
23
+ /**
24
+ * Root endpoints for the Antigravity API (in fallback order).
25
+ * Live agy CLI 1.0.4 traffic uses daily-cloudcode-pa.googleapis.com.
26
+ */
27
+ export const ANTIGRAVITY_ENDPOINT_DAILY = "https://daily-cloudcode-pa.googleapis.com";
28
+ export const ANTIGRAVITY_ENDPOINT_AUTOPUSH = "https://autopush-cloudcode-pa.sandbox.googleapis.com";
29
+ export const ANTIGRAVITY_ENDPOINT_PROD = "https://cloudcode-pa.googleapis.com";
30
+ /**
31
+ * Endpoint fallback order (daily → prod).
32
+ * Autopush removed to reduce unnecessary fallback API calls — it rarely works when daily fails.
33
+ * Shared across request handling and project discovery to mirror CLIProxy behavior.
34
+ */
35
+ export const ANTIGRAVITY_ENDPOINT_FALLBACKS = [
36
+ ANTIGRAVITY_ENDPOINT_DAILY,
37
+ ANTIGRAVITY_ENDPOINT_PROD,
38
+ ];
39
+ /**
40
+ * Preferred endpoint order for project discovery.
41
+ * agy CLI probes daily-cloudcode-pa.googleapis.com first.
42
+ */
43
+ export const ANTIGRAVITY_LOAD_ENDPOINTS = [
44
+ ANTIGRAVITY_ENDPOINT_DAILY,
45
+ ANTIGRAVITY_ENDPOINT_PROD,
46
+ ];
47
+ /**
48
+ * Primary endpoint to use (captured agy CLI daily endpoint).
49
+ */
50
+ export const ANTIGRAVITY_ENDPOINT = ANTIGRAVITY_ENDPOINT_DAILY;
51
+ /**
52
+ * Gemini CLI endpoint (production).
53
+ * Used for models without :antigravity suffix.
54
+ * Same as opencode-gemini-auth's GEMINI_CODE_ASSIST_ENDPOINT.
55
+ */
56
+ export const GEMINI_CLI_ENDPOINT = ANTIGRAVITY_ENDPOINT_PROD;
57
+ /**
58
+ * Hardcoded project id used when Antigravity does not return one (e.g., business/workspace accounts).
59
+ */
60
+ export const ANTIGRAVITY_DEFAULT_PROJECT_ID = "rising-fact-p41fc";
61
+ export const ANTIGRAVITY_VERSION_FALLBACK = "1.18.3";
62
+ let antigravityVersion = ANTIGRAVITY_VERSION_FALLBACK;
63
+ let versionLocked = false;
64
+ export function getAntigravityVersion() { return antigravityVersion; }
65
+ /**
66
+ * Set the runtime Antigravity version. Can only be called once (at startup).
67
+ * Subsequent calls are silently ignored to prevent accidental mutation.
68
+ */
69
+ export function setAntigravityVersion(version) {
70
+ if (versionLocked)
71
+ return;
72
+ antigravityVersion = version;
73
+ versionLocked = true;
74
+ }
75
+ /** @deprecated Use getAntigravityVersion() for runtime access. */
76
+ export const ANTIGRAVITY_VERSION = ANTIGRAVITY_VERSION_FALLBACK;
77
+ export function getAntigravityHeaders() {
78
+ return {
79
+ "User-Agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Antigravity/${getAntigravityVersion()} Chrome/138.0.7204.235 Electron/37.3.1 Safari/537.36`,
80
+ "X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
81
+ "Client-Metadata": `{"ideType":"ANTIGRAVITY","platform":"${process.platform === "win32" ? "WINDOWS" : "MACOS"}","pluginType":"GEMINI"}`,
82
+ };
83
+ }
84
+ /** @deprecated Use getAntigravityHeaders() for runtime access. */
85
+ export const ANTIGRAVITY_HEADERS = {
86
+ "User-Agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Antigravity/${ANTIGRAVITY_VERSION} Chrome/138.0.7204.235 Electron/37.3.1 Safari/537.36`,
87
+ "X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
88
+ "Client-Metadata": `{"ideType":"ANTIGRAVITY","platform":"${process.platform === "win32" ? "WINDOWS" : "MACOS"}","pluginType":"GEMINI"}`,
89
+ };
90
+ export const GEMINI_CLI_VERSION = "1.0.0";
91
+ /**
92
+ * Default model used in Gemini CLI User-Agent when no model is specified.
93
+ */
94
+ export const GEMINI_CLI_DEFAULT_MODEL = "gemini-2.5-pro";
95
+ /**
96
+ * Build Gemini CLI User-Agent string matching the official google-gemini/gemini-cli format.
97
+ * Format: `GeminiCLI/{version}/{model} ({platform}; {arch})`
98
+ *
99
+ * @see https://github.com/google-gemini/gemini-cli
100
+ */
101
+ export function buildGeminiCliUserAgent(model) {
102
+ const effectiveModel = model || GEMINI_CLI_DEFAULT_MODEL;
103
+ const platform = process.platform || "darwin";
104
+ const arch = process.arch || "arm64";
105
+ return `GeminiCLI/${GEMINI_CLI_VERSION}/${effectiveModel} (${platform}; ${arch})`;
106
+ }
107
+ /** @deprecated Use buildGeminiCliUserAgent() for runtime access. */
108
+ export const GEMINI_CLI_HEADERS = {
109
+ "User-Agent": "google-api-nodejs-client/9.15.1",
110
+ "X-Goog-Api-Client": "gl-node/22.17.0",
111
+ "Client-Metadata": "ideType=IDE_UNSPECIFIED,platform=PLATFORM_UNSPECIFIED,pluginType=GEMINI",
112
+ };
113
+ function buildAntigravityPlatformArch() {
114
+ const platform = process.platform === "win32" ? "windows" : process.platform || "unknown";
115
+ const arch = process.arch === "x64" ? "amd64" : process.arch === "ia32" ? "386" : process.arch || "unknown";
116
+ return `${platform}/${arch}`;
117
+ }
118
+ export function getRandomizedHeaders(style, model) {
119
+ if (style === "gemini-cli") {
120
+ return {
121
+ "User-Agent": buildGeminiCliUserAgent(model),
122
+ "X-Goog-Api-Client": GEMINI_CLI_HEADERS["X-Goog-Api-Client"],
123
+ "Client-Metadata": GEMINI_CLI_HEADERS["Client-Metadata"],
124
+ };
125
+ }
126
+ const platform = buildAntigravityPlatformArch();
127
+ return {
128
+ "User-Agent": `antigravity/cli/1.0.4 ${platform}`,
129
+ };
130
+ }
131
+ /**
132
+ * Provider identifier shared between the plugin loader and credential store.
133
+ */
134
+ export const ANTIGRAVITY_PROVIDER_ID = "google";
135
+ // ============================================================================
136
+ // TOOL HALLUCINATION PREVENTION (Ported from LLM-API-Key-Proxy)
137
+ // ============================================================================
138
+ /**
139
+ * System instruction for Claude tool usage hardening.
140
+ * Prevents hallucinated parameters by explicitly stating the rules.
141
+ *
142
+ * This is injected when tools are present to reduce cases where Claude
143
+ * uses parameter names from its training data instead of the actual schema.
144
+ */
145
+ export const CLAUDE_TOOL_SYSTEM_INSTRUCTION = `CRITICAL TOOL USAGE INSTRUCTIONS:
146
+ You are operating in a custom environment where tool definitions differ from your training data.
147
+ You MUST follow these rules strictly:
148
+
149
+ 1. DO NOT use your internal training data to guess tool parameters
150
+ 2. ONLY use the exact parameter structure defined in the tool schema
151
+ 3. Parameter names in schemas are EXACT - do not substitute with similar names from your training
152
+ 4. Array parameters have specific item types - check the schema's 'items' field for the exact structure
153
+ 5. When you see "STRICT PARAMETERS" in a tool description, those type definitions override any assumptions
154
+ 6. Tool use in agentic workflows is REQUIRED - you must call tools with the exact parameters specified
155
+
156
+ If you are unsure about a tool's parameters, YOU MUST read the schema definition carefully.`;
157
+ /**
158
+ * Template for parameter signature injection into tool descriptions.
159
+ * {params} will be replaced with the actual parameter list.
160
+ */
161
+ export const CLAUDE_DESCRIPTION_PROMPT = "\n\n⚠️ STRICT PARAMETERS: {params}.";
162
+ export const EMPTY_SCHEMA_PLACEHOLDER_NAME = "_placeholder";
163
+ export const EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION = "Placeholder. Always pass true.";
164
+ /**
165
+ * Sentinel value to bypass thought signature validation.
166
+ *
167
+ * When a thinking block has an invalid or missing signature (e.g., cache miss,
168
+ * session mismatch, plugin restart), this sentinel can be injected to skip
169
+ * validation instead of failing with "Invalid signature in thinking block".
170
+ *
171
+ * This is an officially supported Google API feature, used by:
172
+ * - gemini-cli: https://github.com/google-gemini/gemini-cli
173
+ * - Google .NET SDK: PredictionServiceChatClient.cs
174
+ *
175
+ * @see https://ai.google.dev/gemini-api/docs/thought-signatures
176
+ */
177
+ export const SKIP_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
178
+ // ============================================================================
179
+ // GOOGLE SEARCH TOOL CONSTANTS
180
+ // ============================================================================
181
+ /**
182
+ * Model used for Google Search grounding requests.
183
+ * Uses gemini-2.5-flash for fast, cost-effective search operations. (3-flash is always at capacity and doesn't support souce citation).
184
+ */
185
+ export const SEARCH_MODEL = "gemini-2.5-flash";
186
+ /**
187
+ * Thinking budget for deep search (more thorough analysis).
188
+ */
189
+ export const SEARCH_THINKING_BUDGET_DEEP = 16384;
190
+ /**
191
+ * Thinking budget for fast search (quick results).
192
+ */
193
+ export const SEARCH_THINKING_BUDGET_FAST = 4096;
194
+ /**
195
+ * Timeout for search requests in milliseconds (60 seconds).
196
+ */
197
+ export const SEARCH_TIMEOUT_MS = 60000;
198
+ /**
199
+ * System instruction for the Google Search tool.
200
+ */
201
+ export const SEARCH_SYSTEM_INSTRUCTION = `You are an expert web search assistant with access to Google Search and URL analysis tools.
202
+
203
+ Your capabilities:
204
+ - Use google_search to find real-time information from the web
205
+ - Use url_context to fetch and analyze content from specific URLs when provided
206
+
207
+ Guidelines:
208
+ - Always provide accurate, well-sourced information
209
+ - Cite your sources when presenting facts
210
+ - If analyzing URLs, extract the most relevant information
211
+ - Be concise but comprehensive in your responses
212
+ - If information is uncertain or conflicting, acknowledge it
213
+ - Focus on answering the user's question directly`;
214
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,2EAA2E,CAAC;AAEjH;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,qCAAqC,CAAC;AAE/E;;GAEG;AACH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AAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;kDAYS,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Device Fingerprint Generator for Rate Limit Mitigation
3
+ *
4
+ * Uses the agy CLI content-request identity captured with mitmproxy:
5
+ * a short Antigravity CLI User-Agent with a normalized runtime platform tuple.
6
+ * The stored deviceId/sessionToken fields are
7
+ * retained for account history, but content requests only send User-Agent.
8
+ */
9
+ export declare const AGY_CLI_VERSION = "1.0.4";
10
+ export interface ClientMetadata {
11
+ ideType: string;
12
+ platform: string;
13
+ pluginType: string;
14
+ }
15
+ export interface Fingerprint {
16
+ deviceId: string;
17
+ sessionToken: string;
18
+ userAgent: string;
19
+ apiClient: string;
20
+ clientMetadata: ClientMetadata;
21
+ createdAt: number;
22
+ }
23
+ /**
24
+ * Fingerprint version for history tracking.
25
+ * Stores a snapshot of a fingerprint with metadata about when/why it was saved.
26
+ */
27
+ export interface FingerprintVersion {
28
+ fingerprint: Fingerprint;
29
+ timestamp: number;
30
+ reason: 'initial' | 'regenerated' | 'restored';
31
+ }
32
+ /** Maximum number of fingerprint versions to keep per account */
33
+ export declare const MAX_FINGERPRINT_HISTORY = 5;
34
+ export interface FingerprintHeaders {
35
+ "User-Agent": string;
36
+ }
37
+ export declare function buildAntigravityHarnessPlatformArch(platform?: NodeJS.Platform, arch?: NodeJS.Architecture): string;
38
+ export declare function buildAntigravityHarnessUserAgent(version?: string, platform?: NodeJS.Platform, arch?: NodeJS.Architecture): string;
39
+ export declare function buildAntigravityHarnessLoadCodeAssistUserAgent(version?: string): string;
40
+ export declare function buildAntigravityLoadCodeAssistMetadata(): Record<string, string>;
41
+ export declare function buildAntigravityHarnessBootstrapHeaders(accessToken: string): Record<string, string>;
42
+ /**
43
+ * Generate the per-account content-request fingerprint.
44
+ * The outward HTTP identity is stable; deviceId/sessionToken remain unique for history.
45
+ */
46
+ export declare function generateFingerprint(): Fingerprint;
47
+ /**
48
+ * Collect the current content-request fingerprint.
49
+ */
50
+ export declare function collectCurrentFingerprint(): Fingerprint;
51
+ /**
52
+ * Update a saved fingerprint's User-Agent to the current Antigravity
53
+ * agy CLI identity. This migrates older randomized fingerprints such as
54
+ * win32/x64 to the captured CLI-compatible platform/arch form.
55
+ * Returns true if the User-Agent was changed.
56
+ */
57
+ export declare function updateFingerprintVersion(fingerprint: Fingerprint): boolean;
58
+ /**
59
+ * Build HTTP headers from a fingerprint object.
60
+ * These headers are used to identify the "device" making API requests.
61
+ */
62
+ export declare function buildFingerprintHeaders(fingerprint: Fingerprint | null): Partial<FingerprintHeaders>;
63
+ /**
64
+ * Get or create the session fingerprint.
65
+ * Returns the same fingerprint for all calls within a session.
66
+ */
67
+ export declare function getSessionFingerprint(): Fingerprint;
68
+ /**
69
+ * Regenerate the session fingerprint.
70
+ * Call this to get a fresh identity (e.g., after rate limiting).
71
+ */
72
+ export declare function regenerateSessionFingerprint(): Fingerprint;
73
+ //# sourceMappingURL=fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,eAAe,UAAU,CAAC;AAGvC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AACD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CAChD;AAED,iEAAiE;AACjE,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;CACtB;AAiBD,wBAAgB,mCAAmC,CACjD,QAAQ,kBAAmB,EAC3B,IAAI,sBAAe,GAClB,MAAM,CAER;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,SAAkB,EACzB,QAAQ,kBAAmB,EAC3B,IAAI,sBAAe,GAClB,MAAM,CAER;AAED,wBAAgB,8CAA8C,CAAC,OAAO,SAAkB,GAAG,MAAM,CAEhG;AAMD,wBAAgB,sCAAsC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE/E;AAED,wBAAgB,uCAAuC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOnG;AAUD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAajD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAQ1E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQpG;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAKnD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,WAAW,CAG1D"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Device Fingerprint Generator for Rate Limit Mitigation
3
+ *
4
+ * Uses the agy CLI content-request identity captured with mitmproxy:
5
+ * a short Antigravity CLI User-Agent with a normalized runtime platform tuple.
6
+ * The stored deviceId/sessionToken fields are
7
+ * retained for account history, but content requests only send User-Agent.
8
+ */
9
+ import * as crypto from "node:crypto";
10
+ export const AGY_CLI_VERSION = "1.0.4";
11
+ const ANTIGRAVITY_API_CLIENT = "antigravity-cli";
12
+ /** Maximum number of fingerprint versions to keep per account */
13
+ export const MAX_FINGERPRINT_HISTORY = 5;
14
+ function normalizeHarnessPlatform(platform = process.platform) {
15
+ return platform === "win32" ? "windows" : platform || "unknown";
16
+ }
17
+ function normalizeHarnessArch(arch = process.arch) {
18
+ switch (arch) {
19
+ case "x64":
20
+ return "amd64";
21
+ case "ia32":
22
+ return "386";
23
+ default:
24
+ return arch || "unknown";
25
+ }
26
+ }
27
+ export function buildAntigravityHarnessPlatformArch(platform = process.platform, arch = process.arch) {
28
+ return `${normalizeHarnessPlatform(platform)}/${normalizeHarnessArch(arch)}`;
29
+ }
30
+ export function buildAntigravityHarnessUserAgent(version = AGY_CLI_VERSION, platform = process.platform, arch = process.arch) {
31
+ return `antigravity/cli/${version} ${buildAntigravityHarnessPlatformArch(platform, arch)}`;
32
+ }
33
+ export function buildAntigravityHarnessLoadCodeAssistUserAgent(version = AGY_CLI_VERSION) {
34
+ return buildAntigravityHarnessUserAgent(version);
35
+ }
36
+ function platformToMetadataPlatform(platform = process.platform) {
37
+ return platform === "win32" ? "WINDOWS" : "MACOS";
38
+ }
39
+ export function buildAntigravityLoadCodeAssistMetadata() {
40
+ return { ideType: "ANTIGRAVITY" };
41
+ }
42
+ export function buildAntigravityHarnessBootstrapHeaders(accessToken) {
43
+ return {
44
+ "User-Agent": buildAntigravityHarnessLoadCodeAssistUserAgent(),
45
+ Authorization: `Bearer ${accessToken}`,
46
+ "Content-Type": "application/json",
47
+ "Accept-Encoding": "gzip",
48
+ };
49
+ }
50
+ function generateDeviceId() {
51
+ return crypto.randomUUID();
52
+ }
53
+ function generateSessionToken() {
54
+ return crypto.randomBytes(16).toString("hex");
55
+ }
56
+ /**
57
+ * Generate the per-account content-request fingerprint.
58
+ * The outward HTTP identity is stable; deviceId/sessionToken remain unique for history.
59
+ */
60
+ export function generateFingerprint() {
61
+ return {
62
+ deviceId: generateDeviceId(),
63
+ sessionToken: generateSessionToken(),
64
+ userAgent: buildAntigravityHarnessUserAgent(),
65
+ apiClient: ANTIGRAVITY_API_CLIENT,
66
+ clientMetadata: {
67
+ ideType: "ANTIGRAVITY",
68
+ platform: platformToMetadataPlatform(),
69
+ pluginType: "GEMINI",
70
+ },
71
+ createdAt: Date.now(),
72
+ };
73
+ }
74
+ /**
75
+ * Collect the current content-request fingerprint.
76
+ */
77
+ export function collectCurrentFingerprint() {
78
+ return generateFingerprint();
79
+ }
80
+ /**
81
+ * Update a saved fingerprint's User-Agent to the current Antigravity
82
+ * agy CLI identity. This migrates older randomized fingerprints such as
83
+ * win32/x64 to the captured CLI-compatible platform/arch form.
84
+ * Returns true if the User-Agent was changed.
85
+ */
86
+ export function updateFingerprintVersion(fingerprint) {
87
+ const userAgent = buildAntigravityHarnessUserAgent();
88
+ if (fingerprint.userAgent === userAgent) {
89
+ return false;
90
+ }
91
+ fingerprint.userAgent = userAgent;
92
+ return true;
93
+ }
94
+ /**
95
+ * Build HTTP headers from a fingerprint object.
96
+ * These headers are used to identify the "device" making API requests.
97
+ */
98
+ export function buildFingerprintHeaders(fingerprint) {
99
+ if (!fingerprint) {
100
+ return {};
101
+ }
102
+ return {
103
+ "User-Agent": fingerprint.userAgent,
104
+ };
105
+ }
106
+ /**
107
+ * Session-level fingerprint instance.
108
+ * Generated once at module load, persists for the lifetime of the process.
109
+ */
110
+ let sessionFingerprint = null;
111
+ /**
112
+ * Get or create the session fingerprint.
113
+ * Returns the same fingerprint for all calls within a session.
114
+ */
115
+ export function getSessionFingerprint() {
116
+ if (!sessionFingerprint) {
117
+ sessionFingerprint = generateFingerprint();
118
+ }
119
+ return sessionFingerprint;
120
+ }
121
+ /**
122
+ * Regenerate the session fingerprint.
123
+ * Call this to get a fresh identity (e.g., after rate limiting).
124
+ */
125
+ export function regenerateSessionFingerprint() {
126
+ sessionFingerprint = generateFingerprint();
127
+ return sessionFingerprint;
128
+ }
129
+ //# sourceMappingURL=fingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AA0BjD,iEAAiE;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAMzC,SAAS,wBAAwB,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ;IAC3D,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,SAAS,CAAC;AAClE,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IAC/C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,OAAO,OAAO,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,IAAI,SAAS,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mCAAmC,CACjD,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IAEnB,OAAO,GAAG,wBAAwB,CAAC,QAAQ,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,OAAO,GAAG,eAAe,EACzB,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IAEnB,OAAO,mBAAmB,OAAO,IAAI,mCAAmC,CAAC,QAAQ,EAA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,wBAAwB,CAAC,WAAwB;IAC/D,MAAM,SAAS,GAAG,gCAAgC,EAAE,CAAC;IACrD,IAAI,WAAW,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAA+B;IACrE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL,YAAY,EAAE,WAAW,CAAC,SAAS;KACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,IAAI,kBAAkB,GAAuB,IAAI,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,mBAAmB,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IAC1C,kBAAkB,GAAG,mBAAmB,EAAE,CAAC;IAC3C,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./logger.ts";
2
+ export * from "./constants.ts";
3
+ export * from "./auth-types.ts";
4
+ export * from "./auth.ts";
5
+ export * from "./fingerprint.ts";
6
+ export * from "./agy-transport.ts";
7
+ export * from "./version.ts";
8
+ export * from "./project.ts";
9
+ export * from "./model-types.ts";
10
+ export * from "./model-registry.ts";
11
+ export * from "./transform/index.ts";
12
+ export * from "./antigravity/oauth.ts";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // @cortexkit/antigravity-auth-core
2
+ // Harness-agnostic core surface. Modules are migrated here in stages.
3
+ export * from "./logger.js";
4
+ export * from "./constants.js";
5
+ export * from "./auth-types.js";
6
+ export * from "./auth.js";
7
+ export * from "./fingerprint.js";
8
+ export * from "./agy-transport.js";
9
+ export * from "./version.js";
10
+ export * from "./project.js";
11
+ export * from "./model-types.js";
12
+ export * from "./model-registry.js";
13
+ export * from "./transform/index.js";
14
+ export * from "./antigravity/oauth.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,sEAAsE;AACtE,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Harness-agnostic structured logger for the Antigravity core.
3
+ *
4
+ * Core code never talks to a specific harness UI. Instead it emits log
5
+ * records to a pluggable sink. Harnesses (OpenCode, pi) register their own
6
+ * sink via `setLogSink()` to route logs into their TUI/log panel. When no
7
+ * sink is registered, an env-gated console fallback is used.
8
+ */
9
+ export type LogLevel = "debug" | "info" | "warn" | "error";
10
+ export interface Logger {
11
+ debug(message: string, extra?: Record<string, unknown>): void;
12
+ info(message: string, extra?: Record<string, unknown>): void;
13
+ warn(message: string, extra?: Record<string, unknown>): void;
14
+ error(message: string, extra?: Record<string, unknown>): void;
15
+ }
16
+ export interface LogRecord {
17
+ service: string;
18
+ level: LogLevel;
19
+ message: string;
20
+ extra?: Record<string, unknown>;
21
+ }
22
+ export type LogSink = (record: LogRecord) => void;
23
+ /**
24
+ * Register the harness-specific log sink. Pass `null` to clear it.
25
+ */
26
+ export declare function setLogSink(sink: LogSink | null): void;
27
+ /**
28
+ * Create a logger for a specific module. Records are forwarded to the
29
+ * registered sink, with an env-gated console fallback.
30
+ */
31
+ export declare function createLogger(module: string): Logger;
32
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE1D,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC9D;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,QAAQ,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAA;AAMjD;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAErD;AA2BD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAyBnD"}
package/dist/logger.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Harness-agnostic structured logger for the Antigravity core.
3
+ *
4
+ * Core code never talks to a specific harness UI. Instead it emits log
5
+ * records to a pluggable sink. Harnesses (OpenCode, pi) register their own
6
+ * sink via `setLogSink()` to route logs into their TUI/log panel. When no
7
+ * sink is registered, an env-gated console fallback is used.
8
+ */
9
+ const ENV_CONSOLE_LOG = "ANTIGRAVITY_CORE_CONSOLE_LOG";
10
+ let _sink = null;
11
+ /**
12
+ * Register the harness-specific log sink. Pass `null` to clear it.
13
+ */
14
+ export function setLogSink(sink) {
15
+ _sink = sink;
16
+ }
17
+ function isTruthyFlag(flag) {
18
+ return flag === "1" || flag?.toLowerCase() === "true";
19
+ }
20
+ function isConsoleLogEnabled() {
21
+ return isTruthyFlag(process.env[ENV_CONSOLE_LOG]);
22
+ }
23
+ function writeConsoleLog(level, ...args) {
24
+ switch (level) {
25
+ case "debug":
26
+ console.debug(...args);
27
+ break;
28
+ case "info":
29
+ console.info(...args);
30
+ break;
31
+ case "warn":
32
+ console.warn(...args);
33
+ break;
34
+ case "error":
35
+ console.error(...args);
36
+ break;
37
+ }
38
+ }
39
+ /**
40
+ * Create a logger for a specific module. Records are forwarded to the
41
+ * registered sink, with an env-gated console fallback.
42
+ */
43
+ export function createLogger(module) {
44
+ const service = `antigravity.${module}`;
45
+ const log = (level, message, extra) => {
46
+ if (_sink) {
47
+ try {
48
+ _sink({ service, level, message, extra });
49
+ }
50
+ catch {
51
+ // Never let logging failures break core logic.
52
+ }
53
+ }
54
+ if (isConsoleLogEnabled()) {
55
+ const prefix = `[${service}]`;
56
+ const args = extra ? [prefix, message, extra] : [prefix, message];
57
+ writeConsoleLog(level, ...args);
58
+ }
59
+ };
60
+ return {
61
+ debug: (message, extra) => log("debug", message, extra),
62
+ info: (message, extra) => log("info", message, extra),
63
+ warn: (message, extra) => log("warn", message, extra),
64
+ error: (message, extra) => log("error", message, extra),
65
+ };
66
+ }
67
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoBH,MAAM,eAAe,GAAG,8BAA8B,CAAA;AAEtD,IAAI,KAAK,GAAmB,IAAI,CAAA;AAEhC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC7C,KAAK,GAAG,IAAI,CAAA;AACd,CAAC;AAED,SAAS,YAAY,CAAC,IAAa;IACjC,OAAO,IAAI,KAAK,GAAG,IAAI,IAAI,EAAE,WAAW,EAAE,KAAK,MAAM,CAAA;AACvD,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,SAAS,eAAe,CAAC,KAAe,EAAE,GAAG,IAAe;IAC1D,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;YACtB,MAAK;QACP,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;YACrB,MAAK;QACP,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;YACrB,MAAK;QAC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ACxD,CAAA;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ProviderModel } from "./model-types.ts";
2
+ import type { ThinkingTier } from "./transform/types.ts";
3
+ export type ModelThinkingLevel = "minimal" | "low" | "medium" | "high";
4
+ export interface ModelThinkingConfig {
5
+ thinkingBudget: number;
6
+ }
7
+ export interface ModelVariant {
8
+ thinkingLevel?: ModelThinkingLevel;
9
+ thinkingConfig?: ModelThinkingConfig;
10
+ disabled?: boolean;
11
+ }
12
+ export interface ModelLimit {
13
+ context: number;
14
+ output: number;
15
+ }
16
+ export type ModelModality = "text" | "image" | "pdf";
17
+ export type ModelQuotaGroup = "claude" | "gemini-pro" | "gemini-flash" | "gpt-oss";
18
+ export interface ModelModalities {
19
+ input: ModelModality[];
20
+ output: ModelModality[];
21
+ }
22
+ export interface OpencodeModelDefinition extends ProviderModel {
23
+ id: string;
24
+ name: string;
25
+ release_date: string;
26
+ attachment: boolean;
27
+ reasoning: boolean;
28
+ temperature: boolean;
29
+ tool_call: boolean;
30
+ limit: ModelLimit;
31
+ modalities: ModelModalities;
32
+ cost: {
33
+ input: number;
34
+ output: number;
35
+ };
36
+ options: Record<string, unknown>;
37
+ variants?: Record<string, ModelVariant>;
38
+ }
39
+ export type OpencodeModelDefinitions = Record<string, OpencodeModelDefinition>;
40
+ export declare const OPENCODE_MODEL_DEFINITIONS: OpencodeModelDefinitions;
41
+ export declare function getPublicModelDefinitions(): OpencodeModelDefinitions;
42
+ export declare function getAntigravityOpencodeModelIds(): string[];
43
+ export declare function getResolverAliasMap(): Record<string, string>;
44
+ export declare function getGemini35FlashAntigravityModel(tier?: ThinkingTier): string;
45
+ export declare function getGemini35FlashGeminiCliFallbackModel(): string;
46
+ export declare function getQuotaGroupForModel(modelId: string): ModelQuotaGroup | undefined;
47
+ //# sourceMappingURL=model-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../src/model-registry.ts"],"names":[],"mappings":"AAAA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