@omnicross/core 0.4.2 → 0.4.3

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 (147) hide show
  1. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +11 -184
  2. package/dist/auth/GeminiCodeAssistProjectResolver.d.cts +41 -3
  3. package/dist/auth/GeminiCodeAssistProjectResolver.d.ts +41 -3
  4. package/dist/auth/GeminiCodeAssistProjectResolver.js +12 -185
  5. package/dist/{chunk-POUTD5AM.cjs → chunk-47E3I5PF.cjs} +10 -3
  6. package/dist/{chunk-WX2E2G7H.cjs → chunk-4NAMH4UE.cjs} +79 -51
  7. package/dist/{chunk-LQYS2N47.js → chunk-4RM22ETG.js} +14 -2
  8. package/dist/{chunk-YEVWA4C7.cjs → chunk-57Y2EA2G.cjs} +6 -5
  9. package/dist/chunk-6I4SAWCN.js +24 -0
  10. package/dist/chunk-AFH5CEMF.cjs +38 -0
  11. package/dist/{chunk-KIQ2HA2A.cjs → chunk-BTSADEX4.cjs} +5 -5
  12. package/dist/chunk-CGEZQC2G.cjs +67 -0
  13. package/dist/chunk-E5RCCGE7.cjs +95 -0
  14. package/dist/chunk-EE7VP4O3.js +230 -0
  15. package/dist/chunk-F6P4DIBL.js +95 -0
  16. package/dist/{chunk-BKXC4XM6.cjs → chunk-FORICQ5U.cjs} +15 -11
  17. package/dist/{chunk-PF7YQBKX.js → chunk-FYPKKMB3.js} +6 -2
  18. package/dist/chunk-HRBXQ5AC.js +44 -0
  19. package/dist/{chunk-LFEH7CEO.js → chunk-IDPMD4B7.js} +22 -0
  20. package/dist/{chunk-UPQIWJIE.cjs → chunk-INY54AYX.cjs} +14 -2
  21. package/dist/{chunk-QEOV6Y4E.cjs → chunk-J5XMB5KY.cjs} +359 -170
  22. package/dist/{chunk-C3NPMQTK.js → chunk-JHJRZ75C.js} +14 -10
  23. package/dist/chunk-K6J2RIEX.js +67 -0
  24. package/dist/chunk-KSMK45RD.cjs +45 -0
  25. package/dist/chunk-LL3MZ7O5.cjs +24 -0
  26. package/dist/{chunk-ECZ3ZE2C.js → chunk-M6PKXP6T.js} +4 -29
  27. package/dist/{chunk-PAXJGABW.js → chunk-MPFOC7AT.js} +10 -5
  28. package/dist/{chunk-DKBXDV5U.cjs → chunk-N3MGNLCU.cjs} +49 -44
  29. package/dist/chunk-NDIBVTBZ.cjs +230 -0
  30. package/dist/{chunk-5DJSOFEP.js → chunk-NTF7TLT7.js} +1 -1
  31. package/dist/chunk-ONTTXSRL.js +32 -0
  32. package/dist/{chunk-HN74IGEO.js → chunk-OXBGNEYR.js} +1 -1
  33. package/dist/{chunk-5GXOYVLB.js → chunk-QSOHEDKO.js} +44 -39
  34. package/dist/{chunk-TX3AEV6H.cjs → chunk-RXMF7GNF.cjs} +4 -3
  35. package/dist/{chunk-5TEWZN5J.js → chunk-SWY2LTMR.js} +277 -88
  36. package/dist/{chunk-EUZRH544.js → chunk-TKZ3DZS5.js} +10 -3
  37. package/dist/{chunk-MXI2PWIC.cjs → chunk-UKQHBK4Q.cjs} +1 -32
  38. package/dist/{chunk-3XVDFRCQ.cjs → chunk-UOOLU64V.cjs} +13 -8
  39. package/dist/{chunk-ZSA44G7J.cjs → chunk-VFFCV4J6.cjs} +3 -3
  40. package/dist/{chunk-6DDYNS2B.cjs → chunk-VGBJPHHD.cjs} +36 -14
  41. package/dist/{chunk-2T6D7LWE.cjs → chunk-VYOBVPNB.cjs} +6 -2
  42. package/dist/chunk-WYECWQ3J.cjs +44 -0
  43. package/dist/chunk-X6GHTNDL.cjs +482 -0
  44. package/dist/chunk-XBQTVRMK.js +45 -0
  45. package/dist/{chunk-R4VCO2CB.js → chunk-YEHQ5FXZ.js} +28 -0
  46. package/dist/{chunk-HDXSPXIN.js → chunk-ZBDDPWVQ.js} +4 -3
  47. package/dist/chunk-ZJJBITUN.js +482 -0
  48. package/dist/{chunk-QRXOLINS.js → chunk-ZMERU7D3.js} +3 -2
  49. package/dist/completion/CompletionService.cjs +29 -22
  50. package/dist/completion/CompletionService.js +28 -21
  51. package/dist/completion.cjs +29 -22
  52. package/dist/completion.js +28 -21
  53. package/dist/image-generation.cjs +2 -2
  54. package/dist/image-generation.d.cts +2 -2
  55. package/dist/image-generation.d.ts +2 -2
  56. package/dist/image-generation.js +1 -1
  57. package/dist/index.cjs +40 -29
  58. package/dist/index.d.cts +6 -3
  59. package/dist/index.d.ts +6 -3
  60. package/dist/index.js +40 -29
  61. package/dist/outbound-api/routeResolver.cjs +3 -3
  62. package/dist/outbound-api/routeResolver.d.cts +3 -3
  63. package/dist/outbound-api/routeResolver.d.ts +3 -3
  64. package/dist/outbound-api/routeResolver.js +2 -2
  65. package/dist/outbound-api/types.cjs +6 -2
  66. package/dist/outbound-api/types.d.cts +2 -2
  67. package/dist/outbound-api/types.d.ts +2 -2
  68. package/dist/outbound-api/types.js +7 -3
  69. package/dist/outbound-api.cjs +33 -22
  70. package/dist/outbound-api.d.cts +4 -4
  71. package/dist/outbound-api.d.ts +4 -4
  72. package/dist/outbound-api.js +33 -22
  73. package/dist/pipeline/AccountAllowanceScheduling.cjs +4 -3
  74. package/dist/pipeline/AccountAllowanceScheduling.d.cts +4 -4
  75. package/dist/pipeline/AccountAllowanceScheduling.d.ts +4 -4
  76. package/dist/pipeline/AccountAllowanceScheduling.js +3 -2
  77. package/dist/pipeline/AccountAllowanceStore.cjs +2 -2
  78. package/dist/pipeline/AccountAllowanceStore.js +1 -1
  79. package/dist/pipeline/AuthSource.d.cts +6 -0
  80. package/dist/pipeline/AuthSource.d.ts +6 -0
  81. package/dist/pipeline/SubscriptionAuthSource.cjs +5 -4
  82. package/dist/pipeline/SubscriptionAuthSource.js +4 -3
  83. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +7 -0
  84. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +7 -0
  85. package/dist/pipeline/antigravityQuotaFamily.cjs +16 -0
  86. package/dist/pipeline/antigravityQuotaFamily.d.cts +52 -0
  87. package/dist/pipeline/antigravityQuotaFamily.d.ts +52 -0
  88. package/dist/pipeline/antigravityQuotaFamily.js +16 -0
  89. package/dist/pipeline/upstreamFetch.cjs +3 -3
  90. package/dist/pipeline/upstreamFetch.js +2 -2
  91. package/dist/ports.d.cts +2 -2
  92. package/dist/ports.d.ts +2 -2
  93. package/dist/provider-proxy/ProviderProxy.cjs +29 -22
  94. package/dist/provider-proxy/ProviderProxy.js +28 -21
  95. package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
  96. package/dist/provider-proxy/identity/codexCliHeaders.js +4 -2
  97. package/dist/provider-proxy/identity/openCodeGoHeaders.cjs +17 -0
  98. package/dist/provider-proxy/identity/openCodeGoHeaders.d.cts +71 -0
  99. package/dist/provider-proxy/identity/openCodeGoHeaders.d.ts +71 -0
  100. package/dist/provider-proxy/identity/openCodeGoHeaders.js +17 -0
  101. package/dist/provider-proxy/ingress/providerProxyShared.cjs +29 -22
  102. package/dist/provider-proxy/ingress/providerProxyShared.js +28 -21
  103. package/dist/provider-proxy.cjs +29 -22
  104. package/dist/provider-proxy.d.cts +2 -2
  105. package/dist/provider-proxy.d.ts +2 -2
  106. package/dist/provider-proxy.js +28 -21
  107. package/dist/{routeResolver-STwMz_G4.d.ts → routeResolver-BLTleO4H.d.ts} +1 -1
  108. package/dist/{routeResolver-Da0yvkL1.d.cts → routeResolver-C2z0pp-q.d.cts} +1 -1
  109. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +2 -2
  110. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +1 -1
  111. package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -3
  112. package/dist/transformer/transformers/AnthropicTransformer.js +2 -2
  113. package/dist/transformer/transformers/AntigravityTransformer.cjs +31 -0
  114. package/dist/transformer/transformers/AntigravityTransformer.d.cts +104 -0
  115. package/dist/transformer/transformers/AntigravityTransformer.d.ts +104 -0
  116. package/dist/transformer/transformers/AntigravityTransformer.js +31 -0
  117. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  118. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +2 -1
  119. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +2 -1
  120. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  121. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  122. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  123. package/dist/transformer/transformers/antigravityFailover.cjs +30 -0
  124. package/dist/transformer/transformers/antigravityFailover.d.cts +52 -0
  125. package/dist/transformer/transformers/antigravityFailover.d.ts +52 -0
  126. package/dist/transformer/transformers/antigravityFailover.js +30 -0
  127. package/dist/transformer/transformers/antigravityIdentity.cjs +24 -0
  128. package/dist/transformer/transformers/antigravityIdentity.d.cts +76 -0
  129. package/dist/transformer/transformers/antigravityIdentity.d.ts +76 -0
  130. package/dist/transformer/transformers/antigravityIdentity.js +24 -0
  131. package/dist/transformer/transformers.cjs +61 -9
  132. package/dist/transformer/transformers.d.cts +7 -2
  133. package/dist/transformer/transformers.d.ts +7 -2
  134. package/dist/transformer/transformers.js +61 -9
  135. package/dist/transformer/types.d.cts +11 -0
  136. package/dist/transformer/types.d.ts +11 -0
  137. package/dist/transformer.cjs +21 -12
  138. package/dist/transformer.d.cts +3 -0
  139. package/dist/transformer.d.ts +3 -0
  140. package/dist/transformer.js +20 -11
  141. package/dist/{types-Be-yt_6T.d.cts → types-BVwJQ9ZS.d.cts} +3 -0
  142. package/dist/{types-D-oHYusb.d.cts → types-C6m-Db26.d.cts} +25 -4
  143. package/dist/{types-Dvlpjn0d.d.ts → types-Da735j2d.d.ts} +25 -4
  144. package/dist/{types-Dm4_36V4.d.ts → types-VAHRysdP.d.ts} +3 -0
  145. package/package.json +2 -2
  146. package/dist/chunk-4IH4EL7M.cjs +0 -9
  147. package/dist/chunk-XEKD23J5.js +0 -9
@@ -1,195 +1,22 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
2
3
 
3
4
 
4
- var _chunkDKBXDV5Ucjs = require('../chunk-DKBXDV5U.cjs');
5
- require('../chunk-WX2E2G7H.cjs');
6
- require('../chunk-77USGNRW.cjs');
7
- require('../chunk-IUL4VWNU.cjs');
8
5
 
9
6
 
10
- var _chunkZSA44G7Jcjs = require('../chunk-ZSA44G7J.cjs');
7
+ var _chunkNDIBVTBZcjs = require('../chunk-NDIBVTBZ.cjs');
8
+ require('../chunk-N3MGNLCU.cjs');
9
+ require('../chunk-4NAMH4UE.cjs');
10
+ require('../chunk-77USGNRW.cjs');
11
+ require('../chunk-IUL4VWNU.cjs');
12
+ require('../chunk-VFFCV4J6.cjs');
11
13
  require('../chunk-235MXAGX.cjs');
12
- require('../chunk-2T6D7LWE.cjs');
14
+ require('../chunk-VYOBVPNB.cjs');
13
15
  require('../chunk-NKVZ6Z3Y.cjs');
14
16
 
15
- // src/auth/GeminiCodeAssistProjectResolver.ts
16
- var FREE_TIER_ID = "free-tier";
17
- var LEGACY_TIER_ID = "legacy-tier";
18
- var ONBOARD_POLL_INTERVAL_MS = 5e3;
19
- var ONBOARD_MAX_POLLS = 24;
20
- var GeminiCodeAssistHandshakeError = class extends Error {
21
- constructor(message, status, code) {
22
- super(message);
23
- this.status = status;
24
- this.code = code;
25
- this.name = "GeminiCodeAssistHandshakeError";
26
- }
27
-
28
-
29
- };
30
- var GeminiCodeAssistProjectResolver = (_class = class {
31
- // upstream-proxy: the Code Assist handshake is upstream egress → honor the
32
- // gemini proxy by default (still injectable for tests).
33
- constructor(fetchImpl = (url, init) => _chunkZSA44G7Jcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
34
- this.fetchImpl = fetchImpl;
35
- }
36
-
37
- /** account access token → resolved project id (undefined = free-tier, no project). */
38
- __init() {this.cache = /* @__PURE__ */ new Map()}
39
- /** In-flight handshakes so concurrent callers share one round-trip. */
40
- __init2() {this.inflight = /* @__PURE__ */ new Map()}
41
- /** Test/diagnostic helper — clear the cached resolution for an account. */
42
- clearCache() {
43
- this.cache.clear();
44
- this.inflight.clear();
45
- }
46
- /**
47
- * Resolve (and cache) the Code Assist project for the given access token.
48
- * Runs the handshake at most once per token. Returns `undefined` for a
49
- * brand-new free-tier account (valid — the envelope sends no project).
50
- */
51
- async resolveProject(accessToken) {
52
- if (this.cache.has(accessToken)) {
53
- return this.cache.get(accessToken);
54
- }
55
- const existing = this.inflight.get(accessToken);
56
- if (existing) return existing;
57
- const run = this.runHandshake(accessToken).then((project) => {
58
- this.cache.set(accessToken, project);
59
- return project;
60
- }).finally(() => {
61
- this.inflight.delete(accessToken);
62
- });
63
- this.inflight.set(accessToken, run);
64
- return run;
65
- }
66
- codeAssistUrl(method) {
67
- return `${_chunkDKBXDV5Ucjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkDKBXDV5Ucjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
68
- }
69
- /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
70
- seedProjectId() {
71
- const seed = process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT_ID || "";
72
- if (seed && /^\d+$/.test(seed.trim())) return "";
73
- return seed.trim();
74
- }
75
- async runHandshake(accessToken) {
76
- const seededProject = this.seedProjectId();
77
- const load = await this.postCodeAssist("loadCodeAssist", accessToken, {
78
- cloudaicompanionProject: seededProject || void 0,
79
- metadata: {
80
- ideType: "IDE_UNSPECIFIED",
81
- platform: "PLATFORM_UNSPECIFIED",
82
- pluginType: "GEMINI",
83
- duetProject: seededProject || void 0
84
- }
85
- });
86
- if (_optionalChain([load, 'access', _ => _.currentTier, 'optionalAccess', _2 => _2.id])) {
87
- return load.cloudaicompanionProject || void 0;
88
- }
89
- const defaultTier = _optionalChain([load, 'access', _3 => _3.allowedTiers, 'optionalAccess', _4 => _4.find, 'call', _5 => _5((t) => t.isDefault)]);
90
- const tierId = _nullishCoalesce(_optionalChain([defaultTier, 'optionalAccess', _6 => _6.id]), () => ( LEGACY_TIER_ID));
91
- const isFreeish = tierId === FREE_TIER_ID || tierId === LEGACY_TIER_ID;
92
- const onboardProject = isFreeish ? void 0 : seededProject || void 0;
93
- let lro = await this.postCodeAssist("onboardUser", accessToken, {
94
- tierId,
95
- cloudaicompanionProject: onboardProject,
96
- metadata: {
97
- ideType: "IDE_UNSPECIFIED",
98
- platform: "PLATFORM_UNSPECIFIED",
99
- pluginType: "GEMINI",
100
- duetProject: onboardProject
101
- }
102
- });
103
- let polls = 0;
104
- while (!lro.done && polls < ONBOARD_MAX_POLLS) {
105
- await delay(ONBOARD_POLL_INTERVAL_MS);
106
- polls++;
107
- lro = await this.getOperation(accessToken, lro.name);
108
- }
109
- if (lro.error) {
110
- throw new GeminiCodeAssistHandshakeError(
111
- `Code Assist onboardUser failed: ${_nullishCoalesce(lro.error.message, () => ( "unknown"))}`,
112
- _nullishCoalesce(lro.error.code, () => ( 500))
113
- );
114
- }
115
- return _optionalChain([lro, 'access', _7 => _7.response, 'optionalAccess', _8 => _8.cloudaicompanionProject, 'optionalAccess', _9 => _9.id]) || void 0;
116
- }
117
- /** POST a Code Assist method, surfacing the documented hard failures clearly. */
118
- async postCodeAssist(method, accessToken, body) {
119
- const url = this.codeAssistUrl(method);
120
- const res = await this.fetchImpl(url, {
121
- method: "POST",
122
- headers: {
123
- Authorization: `Bearer ${accessToken}`,
124
- "Content-Type": "application/json"
125
- },
126
- body: JSON.stringify(body)
127
- });
128
- if (!res.ok) {
129
- await this.throwForStatus(res, method);
130
- }
131
- return await res.json();
132
- }
133
- async getOperation(accessToken, name) {
134
- const url = this.codeAssistUrl("getOperation");
135
- const res = await this.fetchImpl(url, {
136
- method: "POST",
137
- headers: {
138
- Authorization: `Bearer ${accessToken}`,
139
- "Content-Type": "application/json"
140
- },
141
- body: JSON.stringify({ name })
142
- });
143
- if (!res.ok) {
144
- await this.throwForStatus(res, "getOperation");
145
- }
146
- return await res.json();
147
- }
148
- /** Map a non-2xx Code Assist response to a clear, surfaced error. */
149
- async throwForStatus(res, method) {
150
- let detailCode;
151
- let detailMessage = "";
152
- try {
153
- const errBody = await res.json();
154
- detailCode = _optionalChain([errBody, 'access', _10 => _10.error, 'optionalAccess', _11 => _11.status]);
155
- detailMessage = _nullishCoalesce(_optionalChain([errBody, 'access', _12 => _12.error, 'optionalAccess', _13 => _13.message]), () => ( ""));
156
- } catch (e) {
157
- }
158
- if (res.status === 403) {
159
- throw new GeminiCodeAssistHandshakeError(
160
- `Code Assist ${method} denied (403 ${_nullishCoalesce(detailCode, () => ( "PERMISSION_DENIED"))}): ${detailMessage || "enable the Cloud AI Companion API and grant the required role"}`,
161
- 403,
162
- detailCode
163
- );
164
- }
165
- if (res.status === 429) {
166
- throw new GeminiCodeAssistHandshakeError(
167
- `Code Assist ${method} rate-limited (429): ${detailMessage || "quota exceeded, retry later"}`,
168
- 429,
169
- detailCode
170
- );
171
- }
172
- throw new GeminiCodeAssistHandshakeError(
173
- `Code Assist ${method} failed (${res.status}): ${detailMessage || res.statusText}`,
174
- res.status,
175
- detailCode
176
- );
177
- }
178
- }, _class);
179
- function delay(ms) {
180
- return new Promise((resolve) => {
181
- setTimeout(resolve, ms);
182
- });
183
- }
184
- var _resolverSingleton = null;
185
- function getGeminiCodeAssistProjectResolver() {
186
- if (!_resolverSingleton) {
187
- _resolverSingleton = new GeminiCodeAssistProjectResolver();
188
- }
189
- return _resolverSingleton;
190
- }
191
17
 
192
18
 
193
19
 
194
20
 
195
- exports.GeminiCodeAssistHandshakeError = GeminiCodeAssistHandshakeError; exports.GeminiCodeAssistProjectResolver = GeminiCodeAssistProjectResolver; exports.getGeminiCodeAssistProjectResolver = getGeminiCodeAssistProjectResolver;
21
+
22
+ exports.ANTIGRAVITY_CODE_ASSIST_ENDPOINT = _chunkNDIBVTBZcjs.ANTIGRAVITY_CODE_ASSIST_ENDPOINT; exports.GeminiCodeAssistHandshakeError = _chunkNDIBVTBZcjs.GeminiCodeAssistHandshakeError; exports.GeminiCodeAssistProjectResolver = _chunkNDIBVTBZcjs.GeminiCodeAssistProjectResolver; exports.getAntigravityProjectResolver = _chunkNDIBVTBZcjs.getAntigravityProjectResolver; exports.getGeminiCodeAssistProjectResolver = _chunkNDIBVTBZcjs.getGeminiCodeAssistProjectResolver;
@@ -38,13 +38,40 @@ declare class GeminiCodeAssistHandshakeError extends Error {
38
38
  }
39
39
  /** Injectable fetch so tests can mock the network without a live endpoint. */
40
40
  type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
41
+ /**
42
+ * Per-dialect handshake parameters. The Cloud Code Assist project handshake is
43
+ * SHARED between the gemini-cli subscription (`cloudcode-pa`) and the
44
+ * antigravity subscription (`daily-cloudcode-pa`) — same `:loadCodeAssist` /
45
+ * `:onboardUser` LRO dance, different endpoint, client metadata, and fallback
46
+ * onboarding tier. The defaults preserve the gemini-cli behavior byte-identically.
47
+ */
48
+ interface CodeAssistResolverOptions {
49
+ /**
50
+ * Endpoint base override. Absent ⇒ the gemini-cli `cloudcode-pa` endpoint
51
+ * (env-overridable). The antigravity dialect pins `daily-cloudcode-pa`.
52
+ */
53
+ endpoint?: string;
54
+ /**
55
+ * Handshake dialect: `'gemini-cli'` (default — the GEMINI plugin metadata
56
+ * + `legacy-tier` fallback) or `'antigravity'` (the ANTIGRAVITY ideType
57
+ * metadata + `free-tier` fallback; a resolved `undefined` project is a HARD
58
+ * error — the antigravity envelope always carries a project).
59
+ */
60
+ dialect?: 'gemini-cli' | 'antigravity';
61
+ /** upstream-proxy provider id for the default fetch seam (default `'gemini'`). */
62
+ proxyProviderId?: string;
63
+ }
64
+ /** The antigravity dialect's handshake endpoint (`daily-cloudcode-pa`). */
65
+ declare const ANTIGRAVITY_CODE_ASSIST_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
41
66
  declare class GeminiCodeAssistProjectResolver {
42
- private readonly fetchImpl;
43
67
  /** account access token → resolved project id (undefined = free-tier, no project). */
44
68
  private readonly cache;
45
69
  /** In-flight handshakes so concurrent callers share one round-trip. */
46
70
  private readonly inflight;
47
- constructor(fetchImpl?: FetchLike);
71
+ private readonly dialect;
72
+ private readonly endpoint;
73
+ constructor(fetchImpl?: FetchLike, options?: CodeAssistResolverOptions);
74
+ private readonly fetchImpl;
48
75
  /** Test/diagnostic helper — clear the cached resolution for an account. */
49
76
  clearCache(): void;
50
77
  /**
@@ -54,9 +81,19 @@ declare class GeminiCodeAssistProjectResolver {
54
81
  */
55
82
  resolveProject(accessToken: string): Promise<string | undefined>;
56
83
  private codeAssistUrl;
84
+ /** The client metadata the dialect's upstream expects on the handshake calls. */
85
+ private handshakeMetadata;
86
+ /** The tier id used when `allowedTiers` carries no default. */
87
+ private get fallbackTierId();
57
88
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
58
89
  private seedProjectId;
59
90
  private runHandshake;
91
+ /**
92
+ * Final project settlement per dialect: gemini-cli treats `undefined` as the
93
+ * valid fresh free-tier value; antigravity ALWAYS carries a project (its
94
+ * envelope is rejected without one), so an absent project is a hard error.
95
+ */
96
+ private settleProject;
60
97
  /** POST a Code Assist method, surfacing the documented hard failures clearly. */
61
98
  private postCodeAssist;
62
99
  private getOperation;
@@ -64,5 +101,6 @@ declare class GeminiCodeAssistProjectResolver {
64
101
  private throwForStatus;
65
102
  }
66
103
  declare function getGeminiCodeAssistProjectResolver(): GeminiCodeAssistProjectResolver;
104
+ declare function getAntigravityProjectResolver(): GeminiCodeAssistProjectResolver;
67
105
 
68
- export { type FetchLike, GeminiCodeAssistHandshakeError, GeminiCodeAssistProjectResolver, getGeminiCodeAssistProjectResolver };
106
+ export { ANTIGRAVITY_CODE_ASSIST_ENDPOINT, type CodeAssistResolverOptions, type FetchLike, GeminiCodeAssistHandshakeError, GeminiCodeAssistProjectResolver, getAntigravityProjectResolver, getGeminiCodeAssistProjectResolver };
@@ -38,13 +38,40 @@ declare class GeminiCodeAssistHandshakeError extends Error {
38
38
  }
39
39
  /** Injectable fetch so tests can mock the network without a live endpoint. */
40
40
  type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
41
+ /**
42
+ * Per-dialect handshake parameters. The Cloud Code Assist project handshake is
43
+ * SHARED between the gemini-cli subscription (`cloudcode-pa`) and the
44
+ * antigravity subscription (`daily-cloudcode-pa`) — same `:loadCodeAssist` /
45
+ * `:onboardUser` LRO dance, different endpoint, client metadata, and fallback
46
+ * onboarding tier. The defaults preserve the gemini-cli behavior byte-identically.
47
+ */
48
+ interface CodeAssistResolverOptions {
49
+ /**
50
+ * Endpoint base override. Absent ⇒ the gemini-cli `cloudcode-pa` endpoint
51
+ * (env-overridable). The antigravity dialect pins `daily-cloudcode-pa`.
52
+ */
53
+ endpoint?: string;
54
+ /**
55
+ * Handshake dialect: `'gemini-cli'` (default — the GEMINI plugin metadata
56
+ * + `legacy-tier` fallback) or `'antigravity'` (the ANTIGRAVITY ideType
57
+ * metadata + `free-tier` fallback; a resolved `undefined` project is a HARD
58
+ * error — the antigravity envelope always carries a project).
59
+ */
60
+ dialect?: 'gemini-cli' | 'antigravity';
61
+ /** upstream-proxy provider id for the default fetch seam (default `'gemini'`). */
62
+ proxyProviderId?: string;
63
+ }
64
+ /** The antigravity dialect's handshake endpoint (`daily-cloudcode-pa`). */
65
+ declare const ANTIGRAVITY_CODE_ASSIST_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
41
66
  declare class GeminiCodeAssistProjectResolver {
42
- private readonly fetchImpl;
43
67
  /** account access token → resolved project id (undefined = free-tier, no project). */
44
68
  private readonly cache;
45
69
  /** In-flight handshakes so concurrent callers share one round-trip. */
46
70
  private readonly inflight;
47
- constructor(fetchImpl?: FetchLike);
71
+ private readonly dialect;
72
+ private readonly endpoint;
73
+ constructor(fetchImpl?: FetchLike, options?: CodeAssistResolverOptions);
74
+ private readonly fetchImpl;
48
75
  /** Test/diagnostic helper — clear the cached resolution for an account. */
49
76
  clearCache(): void;
50
77
  /**
@@ -54,9 +81,19 @@ declare class GeminiCodeAssistProjectResolver {
54
81
  */
55
82
  resolveProject(accessToken: string): Promise<string | undefined>;
56
83
  private codeAssistUrl;
84
+ /** The client metadata the dialect's upstream expects on the handshake calls. */
85
+ private handshakeMetadata;
86
+ /** The tier id used when `allowedTiers` carries no default. */
87
+ private get fallbackTierId();
57
88
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
58
89
  private seedProjectId;
59
90
  private runHandshake;
91
+ /**
92
+ * Final project settlement per dialect: gemini-cli treats `undefined` as the
93
+ * valid fresh free-tier value; antigravity ALWAYS carries a project (its
94
+ * envelope is rejected without one), so an absent project is a hard error.
95
+ */
96
+ private settleProject;
60
97
  /** POST a Code Assist method, surfacing the documented hard failures clearly. */
61
98
  private postCodeAssist;
62
99
  private getOperation;
@@ -64,5 +101,6 @@ declare class GeminiCodeAssistProjectResolver {
64
101
  private throwForStatus;
65
102
  }
66
103
  declare function getGeminiCodeAssistProjectResolver(): GeminiCodeAssistProjectResolver;
104
+ declare function getAntigravityProjectResolver(): GeminiCodeAssistProjectResolver;
67
105
 
68
- export { type FetchLike, GeminiCodeAssistHandshakeError, GeminiCodeAssistProjectResolver, getGeminiCodeAssistProjectResolver };
106
+ export { ANTIGRAVITY_CODE_ASSIST_ENDPOINT, type CodeAssistResolverOptions, type FetchLike, GeminiCodeAssistHandshakeError, GeminiCodeAssistProjectResolver, getAntigravityProjectResolver, getGeminiCodeAssistProjectResolver };
@@ -1,195 +1,22 @@
1
1
  import {
2
- resolveCodeAssistApiVersion,
3
- resolveCodeAssistEndpoint
4
- } from "../chunk-5GXOYVLB.js";
5
- import "../chunk-R4VCO2CB.js";
2
+ ANTIGRAVITY_CODE_ASSIST_ENDPOINT,
3
+ GeminiCodeAssistHandshakeError,
4
+ GeminiCodeAssistProjectResolver,
5
+ getAntigravityProjectResolver,
6
+ getGeminiCodeAssistProjectResolver
7
+ } from "../chunk-EE7VP4O3.js";
8
+ import "../chunk-QSOHEDKO.js";
9
+ import "../chunk-YEHQ5FXZ.js";
6
10
  import "../chunk-WYVGULTQ.js";
7
11
  import "../chunk-ZLNHPUFA.js";
8
- import {
9
- fetchUpstream
10
- } from "../chunk-5DJSOFEP.js";
12
+ import "../chunk-NTF7TLT7.js";
11
13
  import "../chunk-3WD4HTR2.js";
12
- import "../chunk-PF7YQBKX.js";
14
+ import "../chunk-FYPKKMB3.js";
13
15
  import "../chunk-GL6XM527.js";
14
-
15
- // src/auth/GeminiCodeAssistProjectResolver.ts
16
- var FREE_TIER_ID = "free-tier";
17
- var LEGACY_TIER_ID = "legacy-tier";
18
- var ONBOARD_POLL_INTERVAL_MS = 5e3;
19
- var ONBOARD_MAX_POLLS = 24;
20
- var GeminiCodeAssistHandshakeError = class extends Error {
21
- constructor(message, status, code) {
22
- super(message);
23
- this.status = status;
24
- this.code = code;
25
- this.name = "GeminiCodeAssistHandshakeError";
26
- }
27
- status;
28
- code;
29
- };
30
- var GeminiCodeAssistProjectResolver = class {
31
- // upstream-proxy: the Code Assist handshake is upstream egress → honor the
32
- // gemini proxy by default (still injectable for tests).
33
- constructor(fetchImpl = (url, init) => fetchUpstream(url, init, { providerId: "gemini" })) {
34
- this.fetchImpl = fetchImpl;
35
- }
36
- fetchImpl;
37
- /** account access token → resolved project id (undefined = free-tier, no project). */
38
- cache = /* @__PURE__ */ new Map();
39
- /** In-flight handshakes so concurrent callers share one round-trip. */
40
- inflight = /* @__PURE__ */ new Map();
41
- /** Test/diagnostic helper — clear the cached resolution for an account. */
42
- clearCache() {
43
- this.cache.clear();
44
- this.inflight.clear();
45
- }
46
- /**
47
- * Resolve (and cache) the Code Assist project for the given access token.
48
- * Runs the handshake at most once per token. Returns `undefined` for a
49
- * brand-new free-tier account (valid — the envelope sends no project).
50
- */
51
- async resolveProject(accessToken) {
52
- if (this.cache.has(accessToken)) {
53
- return this.cache.get(accessToken);
54
- }
55
- const existing = this.inflight.get(accessToken);
56
- if (existing) return existing;
57
- const run = this.runHandshake(accessToken).then((project) => {
58
- this.cache.set(accessToken, project);
59
- return project;
60
- }).finally(() => {
61
- this.inflight.delete(accessToken);
62
- });
63
- this.inflight.set(accessToken, run);
64
- return run;
65
- }
66
- codeAssistUrl(method) {
67
- return `${resolveCodeAssistEndpoint()}/${resolveCodeAssistApiVersion()}:${method}`;
68
- }
69
- /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
70
- seedProjectId() {
71
- const seed = process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT_ID || "";
72
- if (seed && /^\d+$/.test(seed.trim())) return "";
73
- return seed.trim();
74
- }
75
- async runHandshake(accessToken) {
76
- const seededProject = this.seedProjectId();
77
- const load = await this.postCodeAssist("loadCodeAssist", accessToken, {
78
- cloudaicompanionProject: seededProject || void 0,
79
- metadata: {
80
- ideType: "IDE_UNSPECIFIED",
81
- platform: "PLATFORM_UNSPECIFIED",
82
- pluginType: "GEMINI",
83
- duetProject: seededProject || void 0
84
- }
85
- });
86
- if (load.currentTier?.id) {
87
- return load.cloudaicompanionProject || void 0;
88
- }
89
- const defaultTier = load.allowedTiers?.find((t) => t.isDefault);
90
- const tierId = defaultTier?.id ?? LEGACY_TIER_ID;
91
- const isFreeish = tierId === FREE_TIER_ID || tierId === LEGACY_TIER_ID;
92
- const onboardProject = isFreeish ? void 0 : seededProject || void 0;
93
- let lro = await this.postCodeAssist("onboardUser", accessToken, {
94
- tierId,
95
- cloudaicompanionProject: onboardProject,
96
- metadata: {
97
- ideType: "IDE_UNSPECIFIED",
98
- platform: "PLATFORM_UNSPECIFIED",
99
- pluginType: "GEMINI",
100
- duetProject: onboardProject
101
- }
102
- });
103
- let polls = 0;
104
- while (!lro.done && polls < ONBOARD_MAX_POLLS) {
105
- await delay(ONBOARD_POLL_INTERVAL_MS);
106
- polls++;
107
- lro = await this.getOperation(accessToken, lro.name);
108
- }
109
- if (lro.error) {
110
- throw new GeminiCodeAssistHandshakeError(
111
- `Code Assist onboardUser failed: ${lro.error.message ?? "unknown"}`,
112
- lro.error.code ?? 500
113
- );
114
- }
115
- return lro.response?.cloudaicompanionProject?.id || void 0;
116
- }
117
- /** POST a Code Assist method, surfacing the documented hard failures clearly. */
118
- async postCodeAssist(method, accessToken, body) {
119
- const url = this.codeAssistUrl(method);
120
- const res = await this.fetchImpl(url, {
121
- method: "POST",
122
- headers: {
123
- Authorization: `Bearer ${accessToken}`,
124
- "Content-Type": "application/json"
125
- },
126
- body: JSON.stringify(body)
127
- });
128
- if (!res.ok) {
129
- await this.throwForStatus(res, method);
130
- }
131
- return await res.json();
132
- }
133
- async getOperation(accessToken, name) {
134
- const url = this.codeAssistUrl("getOperation");
135
- const res = await this.fetchImpl(url, {
136
- method: "POST",
137
- headers: {
138
- Authorization: `Bearer ${accessToken}`,
139
- "Content-Type": "application/json"
140
- },
141
- body: JSON.stringify({ name })
142
- });
143
- if (!res.ok) {
144
- await this.throwForStatus(res, "getOperation");
145
- }
146
- return await res.json();
147
- }
148
- /** Map a non-2xx Code Assist response to a clear, surfaced error. */
149
- async throwForStatus(res, method) {
150
- let detailCode;
151
- let detailMessage = "";
152
- try {
153
- const errBody = await res.json();
154
- detailCode = errBody.error?.status;
155
- detailMessage = errBody.error?.message ?? "";
156
- } catch {
157
- }
158
- if (res.status === 403) {
159
- throw new GeminiCodeAssistHandshakeError(
160
- `Code Assist ${method} denied (403 ${detailCode ?? "PERMISSION_DENIED"}): ${detailMessage || "enable the Cloud AI Companion API and grant the required role"}`,
161
- 403,
162
- detailCode
163
- );
164
- }
165
- if (res.status === 429) {
166
- throw new GeminiCodeAssistHandshakeError(
167
- `Code Assist ${method} rate-limited (429): ${detailMessage || "quota exceeded, retry later"}`,
168
- 429,
169
- detailCode
170
- );
171
- }
172
- throw new GeminiCodeAssistHandshakeError(
173
- `Code Assist ${method} failed (${res.status}): ${detailMessage || res.statusText}`,
174
- res.status,
175
- detailCode
176
- );
177
- }
178
- };
179
- function delay(ms) {
180
- return new Promise((resolve) => {
181
- setTimeout(resolve, ms);
182
- });
183
- }
184
- var _resolverSingleton = null;
185
- function getGeminiCodeAssistProjectResolver() {
186
- if (!_resolverSingleton) {
187
- _resolverSingleton = new GeminiCodeAssistProjectResolver();
188
- }
189
- return _resolverSingleton;
190
- }
191
16
  export {
17
+ ANTIGRAVITY_CODE_ASSIST_ENDPOINT,
192
18
  GeminiCodeAssistHandshakeError,
193
19
  GeminiCodeAssistProjectResolver,
20
+ getAntigravityProjectResolver,
194
21
  getGeminiCodeAssistProjectResolver
195
22
  };
@@ -1,9 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
- var _chunk6DDYNS2Bcjs = require('./chunk-6DDYNS2B.cjs');
3
+ var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
4
+
4
5
 
5
6
 
6
- var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
7
+
8
+ var _chunkVGBJPHHDcjs = require('./chunk-VGBJPHHD.cjs');
7
9
 
8
10
 
9
11
 
@@ -275,6 +277,11 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
275
277
  }
276
278
  const message = choice.message;
277
279
  const content = [];
280
+ const images = message.images;
281
+ if (Array.isArray(images) && images.length > 0) {
282
+ _chunkVGBJPHHDcjs.beginAnthropicImageDropScope.call(void 0, );
283
+ _chunkVGBJPHHDcjs.noteDroppedInlineImages.call(void 0, images.length);
284
+ }
278
285
  const thinking = message.thinking;
279
286
  if (_optionalChain([thinking, 'optionalAccess', _14 => _14.content])) {
280
287
  content.push({
@@ -735,7 +742,7 @@ var AnthropicTransformer = (_class = class {
735
742
  if (!response.body) {
736
743
  throw new Error("Stream response body is null");
737
744
  }
738
- const convertedStream = _chunk6DDYNS2Bcjs.convertOpenAIStreamToAnthropic.call(void 0, response.body, context, this.logger);
745
+ const convertedStream = _chunkVGBJPHHDcjs.convertOpenAIStreamToAnthropic.call(void 0, response.body, context, this.logger);
739
746
  return new Response(convertedStream, {
740
747
  headers: {
741
748
  "Content-Type": "text/event-stream",