@anthonyhaussman/opencode-agy-auth 1.2.5-alpha.0 → 1.2.5

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/dist/index.js CHANGED
@@ -268,7 +268,7 @@ function createAgyActivityRequestId() {
268
268
  import os from "os";
269
269
 
270
270
  // src/sdk/agy-cli-version.ts
271
- var AGY_CLI_VERSION = "1.2.4";
271
+ var AGY_CLI_VERSION = "1.2.5";
272
272
 
273
273
  // src/sdk/user-agent.ts
274
274
  var cachedUserAgent = null;
@@ -579,12 +579,6 @@ async function resolveQuotaResetDelay(accessToken, projectId, model, userAgentMo
579
579
  return null;
580
580
  }
581
581
  }
582
- var retryInternals = {
583
- parseRetryDelayValue,
584
- parseRetryDelayFromMessage,
585
- findResetTimeForModel,
586
- resolveQuotaResetDelay
587
- };
588
582
 
589
583
  // src/sdk/retry/helpers.ts
590
584
  var DEFAULT_MAX_ATTEMPTS = 3;
@@ -1581,11 +1575,7 @@ function createOAuthAuthorizeMethod(options) {
1581
1575
  const isHeadless = !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS);
1582
1576
  const authorization = await authorizeAgy();
1583
1577
  if (!isHeadless) {
1584
- if (options?.openBrowser) {
1585
- options.openBrowser(authorization.url);
1586
- } else {
1587
- openBrowserUrl(authorization.url);
1588
- }
1578
+ openBrowserUrl(authorization.url);
1589
1579
  }
1590
1580
  return {
1591
1581
  url: authorization.url,
@@ -1639,23 +1629,16 @@ function parseOAuthCallbackInput(input) {
1639
1629
  }
1640
1630
  return { code: trimmed };
1641
1631
  }
1642
- function defaultOpenBrowserLauncher(command, args) {
1643
- const child = spawn(command, args, {
1644
- stdio: "ignore",
1645
- detached: true
1646
- });
1647
- child.unref?.();
1648
- }
1649
- var openBrowserLauncher = defaultOpenBrowserLauncher;
1650
1632
  function openBrowserUrl(url2) {
1651
- if ((process.env.NODE_ENV === "test" || process.env.VITEST) && openBrowserLauncher === defaultOpenBrowserLauncher) {
1652
- return;
1653
- }
1654
1633
  try {
1655
1634
  const platform2 = process.platform;
1656
1635
  const command = platform2 === "darwin" ? "open" : platform2 === "win32" ? "rundll32" : "xdg-open";
1657
1636
  const args = platform2 === "win32" ? ["url.dll,FileProtocolHandler", url2] : [url2];
1658
- openBrowserLauncher(command, args);
1637
+ const child = spawn(command, args, {
1638
+ stdio: "ignore",
1639
+ detached: true
1640
+ });
1641
+ child.unref?.();
1659
1642
  } catch {
1660
1643
  }
1661
1644
  }
@@ -16061,6 +16044,7 @@ var models_default = {
16061
16044
  },
16062
16045
  experimentIds: [
16063
16046
  106140402,
16047
+ 106519115,
16064
16048
  105979552,
16065
16049
  105979574,
16066
16050
  106015333,
@@ -16164,7 +16148,7 @@ var models_default = {
16164
16148
  modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16165
16149
  quotaInfo: {
16166
16150
  remainingFraction: 1,
16167
- resetTime: "2026-09-16T09:06:33Z"
16151
+ resetTime: "2026-09-17T11:40:46Z"
16168
16152
  },
16169
16153
  recommended: true,
16170
16154
  supportedMimeTypes: {
@@ -16203,7 +16187,7 @@ var models_default = {
16203
16187
  modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16204
16188
  quotaInfo: {
16205
16189
  remainingFraction: 1,
16206
- resetTime: "2026-09-16T09:06:33Z"
16190
+ resetTime: "2026-09-17T11:40:46Z"
16207
16191
  },
16208
16192
  recommended: true,
16209
16193
  supportedMimeTypes: {
@@ -16239,14 +16223,20 @@ var models_default = {
16239
16223
  },
16240
16224
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16241
16225
  quotaInfo: {
16242
- remainingFraction: 0.9615639,
16243
- resetTime: "2026-09-16T08:58:14Z"
16226
+ remainingFraction: 0.9790073,
16227
+ resetTime: "2026-09-17T09:29:22Z"
16244
16228
  },
16245
16229
  recommended: true,
16246
16230
  supportedMimeTypes: {
16247
16231
  "application/json": true,
16232
+ "application/msword": true,
16248
16233
  "application/pdf": true,
16249
16234
  "application/rtf": true,
16235
+ "application/vnd.ms-excel": true,
16236
+ "application/vnd.ms-powerpoint": true,
16237
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16238
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16239
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16250
16240
  "application/x-ipynb+json": true,
16251
16241
  "application/x-javascript": true,
16252
16242
  "application/x-python-code": true,
@@ -16316,14 +16306,20 @@ var models_default = {
16316
16306
  },
16317
16307
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16318
16308
  quotaInfo: {
16319
- remainingFraction: 0.9615639,
16320
- resetTime: "2026-09-16T08:58:14Z"
16309
+ remainingFraction: 0.9790073,
16310
+ resetTime: "2026-09-17T09:29:22Z"
16321
16311
  },
16322
16312
  recommended: true,
16323
16313
  supportedMimeTypes: {
16324
16314
  "application/json": true,
16315
+ "application/msword": true,
16325
16316
  "application/pdf": true,
16326
16317
  "application/rtf": true,
16318
+ "application/vnd.ms-excel": true,
16319
+ "application/vnd.ms-powerpoint": true,
16320
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16321
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16322
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16327
16323
  "application/x-ipynb+json": true,
16328
16324
  "application/x-javascript": true,
16329
16325
  "application/x-python-code": true,
@@ -16393,14 +16389,20 @@ var models_default = {
16393
16389
  },
16394
16390
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16395
16391
  quotaInfo: {
16396
- remainingFraction: 0.9615639,
16397
- resetTime: "2026-09-16T08:58:14Z"
16392
+ remainingFraction: 0.9790073,
16393
+ resetTime: "2026-09-17T09:29:22Z"
16398
16394
  },
16399
16395
  recommended: true,
16400
16396
  supportedMimeTypes: {
16401
16397
  "application/json": true,
16398
+ "application/msword": true,
16402
16399
  "application/pdf": true,
16403
16400
  "application/rtf": true,
16401
+ "application/vnd.ms-excel": true,
16402
+ "application/vnd.ms-powerpoint": true,
16403
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16404
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16405
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16404
16406
  "application/x-ipynb+json": true,
16405
16407
  "application/x-javascript": true,
16406
16408
  "application/x-python-code": true,
@@ -16467,15 +16469,21 @@ var models_default = {
16467
16469
  },
16468
16470
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16469
16471
  quotaInfo: {
16470
- remainingFraction: 0.9615639,
16471
- resetTime: "2026-09-16T08:58:14Z"
16472
+ remainingFraction: 0.9790073,
16473
+ resetTime: "2026-09-17T09:29:22Z"
16472
16474
  },
16473
16475
  recommended: true,
16474
16476
  requiresImageOutputOutsideFunctionResponses: true,
16475
16477
  supportedMimeTypes: {
16476
16478
  "application/json": true,
16479
+ "application/msword": true,
16477
16480
  "application/pdf": true,
16478
16481
  "application/rtf": true,
16482
+ "application/vnd.ms-excel": true,
16483
+ "application/vnd.ms-powerpoint": true,
16484
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16485
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16486
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16479
16487
  "application/x-ipynb+json": true,
16480
16488
  "application/x-javascript": true,
16481
16489
  "application/x-python-code": true,
@@ -16542,14 +16550,20 @@ var models_default = {
16542
16550
  },
16543
16551
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16544
16552
  quotaInfo: {
16545
- remainingFraction: 0.9615639,
16546
- resetTime: "2026-09-16T08:58:14Z"
16553
+ remainingFraction: 0.9790073,
16554
+ resetTime: "2026-09-17T09:29:22Z"
16547
16555
  },
16548
16556
  recommended: true,
16549
16557
  supportedMimeTypes: {
16550
16558
  "application/json": true,
16559
+ "application/msword": true,
16551
16560
  "application/pdf": true,
16552
16561
  "application/rtf": true,
16562
+ "application/vnd.ms-excel": true,
16563
+ "application/vnd.ms-powerpoint": true,
16564
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16565
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16566
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16553
16567
  "application/x-ipynb+json": true,
16554
16568
  "application/x-javascript": true,
16555
16569
  "application/x-python-code": true,
@@ -16641,14 +16655,20 @@ var models_default = {
16641
16655
  },
16642
16656
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16643
16657
  quotaInfo: {
16644
- remainingFraction: 0.9615639,
16645
- resetTime: "2026-09-16T08:58:14Z"
16658
+ remainingFraction: 0.9790073,
16659
+ resetTime: "2026-09-17T09:29:22Z"
16646
16660
  },
16647
16661
  recommended: true,
16648
16662
  supportedMimeTypes: {
16649
16663
  "application/json": true,
16664
+ "application/msword": true,
16650
16665
  "application/pdf": true,
16651
16666
  "application/rtf": true,
16667
+ "application/vnd.ms-excel": true,
16668
+ "application/vnd.ms-powerpoint": true,
16669
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16670
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16671
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16652
16672
  "application/x-ipynb+json": true,
16653
16673
  "application/x-javascript": true,
16654
16674
  "application/x-python-code": true,
@@ -16705,8 +16725,8 @@ var models_default = {
16705
16725
  model: "MODEL_PLACEHOLDER_M21",
16706
16726
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16707
16727
  quotaInfo: {
16708
- remainingFraction: 0.9615639,
16709
- resetTime: "2026-09-16T08:58:14Z"
16728
+ remainingFraction: 0.9790073,
16729
+ resetTime: "2026-09-17T09:29:22Z"
16710
16730
  }
16711
16731
  },
16712
16732
  "gemini-3.1-flash-lite": {
@@ -16724,8 +16744,8 @@ var models_default = {
16724
16744
  },
16725
16745
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16726
16746
  quotaInfo: {
16727
- remainingFraction: 0.9615639,
16728
- resetTime: "2026-09-16T08:58:14Z"
16747
+ remainingFraction: 0.9790073,
16748
+ resetTime: "2026-09-17T09:29:22Z"
16729
16749
  }
16730
16750
  },
16731
16751
  "gemini-3.1-pro-high": {
@@ -16756,14 +16776,20 @@ var models_default = {
16756
16776
  },
16757
16777
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16758
16778
  quotaInfo: {
16759
- remainingFraction: 0.9615639,
16760
- resetTime: "2026-09-16T08:58:14Z"
16779
+ remainingFraction: 0.9790073,
16780
+ resetTime: "2026-09-17T09:29:22Z"
16761
16781
  },
16762
16782
  recommended: true,
16763
16783
  supportedMimeTypes: {
16764
16784
  "application/json": true,
16785
+ "application/msword": true,
16765
16786
  "application/pdf": true,
16766
16787
  "application/rtf": true,
16788
+ "application/vnd.ms-excel": true,
16789
+ "application/vnd.ms-powerpoint": true,
16790
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16791
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16792
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16767
16793
  "application/x-ipynb+json": true,
16768
16794
  "application/x-javascript": true,
16769
16795
  "application/x-python-code": true,
@@ -16841,14 +16867,20 @@ var models_default = {
16841
16867
  },
16842
16868
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16843
16869
  quotaInfo: {
16844
- remainingFraction: 0.9615639,
16845
- resetTime: "2026-09-16T08:58:14Z"
16870
+ remainingFraction: 0.9790073,
16871
+ resetTime: "2026-09-17T09:29:22Z"
16846
16872
  },
16847
16873
  recommended: true,
16848
16874
  supportedMimeTypes: {
16849
16875
  "application/json": true,
16876
+ "application/msword": true,
16850
16877
  "application/pdf": true,
16851
16878
  "application/rtf": true,
16879
+ "application/vnd.ms-excel": true,
16880
+ "application/vnd.ms-powerpoint": true,
16881
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16882
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16883
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16852
16884
  "application/x-ipynb+json": true,
16853
16885
  "application/x-javascript": true,
16854
16886
  "application/x-python-code": true,
@@ -16940,14 +16972,20 @@ var models_default = {
16940
16972
  },
16941
16973
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16942
16974
  quotaInfo: {
16943
- remainingFraction: 0.9615639,
16944
- resetTime: "2026-09-16T08:58:14Z"
16975
+ remainingFraction: 0.9790073,
16976
+ resetTime: "2026-09-17T09:29:22Z"
16945
16977
  },
16946
16978
  recommended: true,
16947
16979
  supportedMimeTypes: {
16948
16980
  "application/json": true,
16981
+ "application/msword": true,
16949
16982
  "application/pdf": true,
16950
16983
  "application/rtf": true,
16984
+ "application/vnd.ms-excel": true,
16985
+ "application/vnd.ms-powerpoint": true,
16986
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
16987
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
16988
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
16951
16989
  "application/x-ipynb+json": true,
16952
16990
  "application/x-javascript": true,
16953
16991
  "application/x-python-code": true,
@@ -17017,14 +17055,20 @@ var models_default = {
17017
17055
  },
17018
17056
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17019
17057
  quotaInfo: {
17020
- remainingFraction: 0.9615639,
17021
- resetTime: "2026-09-16T08:58:14Z"
17058
+ remainingFraction: 0.9790073,
17059
+ resetTime: "2026-09-17T09:29:22Z"
17022
17060
  },
17023
17061
  recommended: true,
17024
17062
  supportedMimeTypes: {
17025
17063
  "application/json": true,
17064
+ "application/msword": true,
17026
17065
  "application/pdf": true,
17027
17066
  "application/rtf": true,
17067
+ "application/vnd.ms-excel": true,
17068
+ "application/vnd.ms-powerpoint": true,
17069
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17070
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17071
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17028
17072
  "application/x-ipynb+json": true,
17029
17073
  "application/x-javascript": true,
17030
17074
  "application/x-python-code": true,
@@ -17118,14 +17162,20 @@ var models_default = {
17118
17162
  },
17119
17163
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17120
17164
  quotaInfo: {
17121
- remainingFraction: 0.9615639,
17122
- resetTime: "2026-09-16T08:58:14Z"
17165
+ remainingFraction: 0.9790073,
17166
+ resetTime: "2026-09-17T09:29:22Z"
17123
17167
  },
17124
17168
  recommended: true,
17125
17169
  supportedMimeTypes: {
17126
17170
  "application/json": true,
17171
+ "application/msword": true,
17127
17172
  "application/pdf": true,
17128
17173
  "application/rtf": true,
17174
+ "application/vnd.ms-excel": true,
17175
+ "application/vnd.ms-powerpoint": true,
17176
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17177
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17178
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17129
17179
  "application/x-ipynb+json": true,
17130
17180
  "application/x-javascript": true,
17131
17181
  "application/x-python-code": true,
@@ -17231,14 +17281,20 @@ var models_default = {
17231
17281
  },
17232
17282
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17233
17283
  quotaInfo: {
17234
- remainingFraction: 0.9615639,
17235
- resetTime: "2026-09-16T08:58:14Z"
17284
+ remainingFraction: 0.9790073,
17285
+ resetTime: "2026-09-17T09:29:22Z"
17236
17286
  },
17237
17287
  recommended: true,
17238
17288
  supportedMimeTypes: {
17239
17289
  "application/json": true,
17290
+ "application/msword": true,
17240
17291
  "application/pdf": true,
17241
17292
  "application/rtf": true,
17293
+ "application/vnd.ms-excel": true,
17294
+ "application/vnd.ms-powerpoint": true,
17295
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17296
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17297
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17242
17298
  "application/x-ipynb+json": true,
17243
17299
  "application/x-javascript": true,
17244
17300
  "application/x-python-code": true,
@@ -17344,14 +17400,20 @@ var models_default = {
17344
17400
  },
17345
17401
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17346
17402
  quotaInfo: {
17347
- remainingFraction: 0.9615639,
17348
- resetTime: "2026-09-16T08:58:14Z"
17403
+ remainingFraction: 0.9790073,
17404
+ resetTime: "2026-09-17T09:29:22Z"
17349
17405
  },
17350
17406
  recommended: true,
17351
17407
  supportedMimeTypes: {
17352
17408
  "application/json": true,
17409
+ "application/msword": true,
17353
17410
  "application/pdf": true,
17354
17411
  "application/rtf": true,
17412
+ "application/vnd.ms-excel": true,
17413
+ "application/vnd.ms-powerpoint": true,
17414
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17415
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17416
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17355
17417
  "application/x-ipynb+json": true,
17356
17418
  "application/x-javascript": true,
17357
17419
  "application/x-python-code": true,
@@ -17457,14 +17519,20 @@ var models_default = {
17457
17519
  },
17458
17520
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17459
17521
  quotaInfo: {
17460
- remainingFraction: 0.9615639,
17461
- resetTime: "2026-09-16T08:58:14Z"
17522
+ remainingFraction: 0.9790073,
17523
+ resetTime: "2026-09-17T09:29:22Z"
17462
17524
  },
17463
17525
  recommended: true,
17464
17526
  supportedMimeTypes: {
17465
17527
  "application/json": true,
17528
+ "application/msword": true,
17466
17529
  "application/pdf": true,
17467
17530
  "application/rtf": true,
17531
+ "application/vnd.ms-excel": true,
17532
+ "application/vnd.ms-powerpoint": true,
17533
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17534
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17535
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17468
17536
  "application/x-ipynb+json": true,
17469
17537
  "application/x-javascript": true,
17470
17538
  "application/x-python-code": true,
@@ -17569,14 +17637,20 @@ var models_default = {
17569
17637
  },
17570
17638
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17571
17639
  quotaInfo: {
17572
- remainingFraction: 0.9615639,
17573
- resetTime: "2026-09-16T08:58:14Z"
17640
+ remainingFraction: 0.9790073,
17641
+ resetTime: "2026-09-17T09:29:22Z"
17574
17642
  },
17575
17643
  recommended: true,
17576
17644
  supportedMimeTypes: {
17577
17645
  "application/json": true,
17646
+ "application/msword": true,
17578
17647
  "application/pdf": true,
17579
17648
  "application/rtf": true,
17649
+ "application/vnd.ms-excel": true,
17650
+ "application/vnd.ms-powerpoint": true,
17651
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17652
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17653
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17580
17654
  "application/x-ipynb+json": true,
17581
17655
  "application/x-javascript": true,
17582
17656
  "application/x-python-code": true,
@@ -17674,14 +17748,20 @@ var models_default = {
17674
17748
  },
17675
17749
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17676
17750
  quotaInfo: {
17677
- remainingFraction: 0.9615639,
17678
- resetTime: "2026-09-16T08:58:14Z"
17751
+ remainingFraction: 0.9790073,
17752
+ resetTime: "2026-09-17T09:29:22Z"
17679
17753
  },
17680
17754
  recommended: true,
17681
17755
  supportedMimeTypes: {
17682
17756
  "application/json": true,
17757
+ "application/msword": true,
17683
17758
  "application/pdf": true,
17684
17759
  "application/rtf": true,
17760
+ "application/vnd.ms-excel": true,
17761
+ "application/vnd.ms-powerpoint": true,
17762
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17763
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17764
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17685
17765
  "application/x-ipynb+json": true,
17686
17766
  "application/x-javascript": true,
17687
17767
  "application/x-python-code": true,
@@ -17781,14 +17861,20 @@ var models_default = {
17781
17861
  },
17782
17862
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17783
17863
  quotaInfo: {
17784
- remainingFraction: 0.9615639,
17785
- resetTime: "2026-09-16T08:58:14Z"
17864
+ remainingFraction: 0.9790073,
17865
+ resetTime: "2026-09-17T09:29:22Z"
17786
17866
  },
17787
17867
  recommended: true,
17788
17868
  supportedMimeTypes: {
17789
17869
  "application/json": true,
17870
+ "application/msword": true,
17790
17871
  "application/pdf": true,
17791
17872
  "application/rtf": true,
17873
+ "application/vnd.ms-excel": true,
17874
+ "application/vnd.ms-powerpoint": true,
17875
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17876
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17877
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17792
17878
  "application/x-ipynb+json": true,
17793
17879
  "application/x-javascript": true,
17794
17880
  "application/x-python-code": true,
@@ -17888,14 +17974,20 @@ var models_default = {
17888
17974
  },
17889
17975
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17890
17976
  quotaInfo: {
17891
- remainingFraction: 0.9615639,
17892
- resetTime: "2026-09-16T08:58:14Z"
17977
+ remainingFraction: 0.9790073,
17978
+ resetTime: "2026-09-17T09:29:22Z"
17893
17979
  },
17894
17980
  recommended: true,
17895
17981
  supportedMimeTypes: {
17896
17982
  "application/json": true,
17983
+ "application/msword": true,
17897
17984
  "application/pdf": true,
17898
17985
  "application/rtf": true,
17986
+ "application/vnd.ms-excel": true,
17987
+ "application/vnd.ms-powerpoint": true,
17988
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
17989
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
17990
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
17899
17991
  "application/x-ipynb+json": true,
17900
17992
  "application/x-javascript": true,
17901
17993
  "application/x-python-code": true,
@@ -17994,14 +18086,20 @@ var models_default = {
17994
18086
  },
17995
18087
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17996
18088
  quotaInfo: {
17997
- remainingFraction: 0.9615639,
17998
- resetTime: "2026-09-16T08:58:14Z"
18089
+ remainingFraction: 0.9790073,
18090
+ resetTime: "2026-09-17T09:29:22Z"
17999
18091
  },
18000
18092
  recommended: true,
18001
18093
  supportedMimeTypes: {
18002
18094
  "application/json": true,
18095
+ "application/msword": true,
18003
18096
  "application/pdf": true,
18004
18097
  "application/rtf": true,
18098
+ "application/vnd.ms-excel": true,
18099
+ "application/vnd.ms-powerpoint": true,
18100
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18101
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18102
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18005
18103
  "application/x-ipynb+json": true,
18006
18104
  "application/x-javascript": true,
18007
18105
  "application/x-python-code": true,
@@ -18099,14 +18197,20 @@ var models_default = {
18099
18197
  },
18100
18198
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18101
18199
  quotaInfo: {
18102
- remainingFraction: 0.9615639,
18103
- resetTime: "2026-09-16T08:58:14Z"
18200
+ remainingFraction: 0.9790073,
18201
+ resetTime: "2026-09-17T09:29:22Z"
18104
18202
  },
18105
18203
  recommended: true,
18106
18204
  supportedMimeTypes: {
18107
18205
  "application/json": true,
18206
+ "application/msword": true,
18108
18207
  "application/pdf": true,
18109
18208
  "application/rtf": true,
18209
+ "application/vnd.ms-excel": true,
18210
+ "application/vnd.ms-powerpoint": true,
18211
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18212
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18213
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18110
18214
  "application/x-ipynb+json": true,
18111
18215
  "application/x-javascript": true,
18112
18216
  "application/x-python-code": true,
@@ -18206,14 +18310,20 @@ var models_default = {
18206
18310
  },
18207
18311
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18208
18312
  quotaInfo: {
18209
- remainingFraction: 0.9615639,
18210
- resetTime: "2026-09-16T08:58:14Z"
18313
+ remainingFraction: 0.9790073,
18314
+ resetTime: "2026-09-17T09:29:22Z"
18211
18315
  },
18212
18316
  recommended: true,
18213
18317
  supportedMimeTypes: {
18214
18318
  "application/json": true,
18319
+ "application/msword": true,
18215
18320
  "application/pdf": true,
18216
18321
  "application/rtf": true,
18322
+ "application/vnd.ms-excel": true,
18323
+ "application/vnd.ms-powerpoint": true,
18324
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18325
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18326
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18217
18327
  "application/x-ipynb+json": true,
18218
18328
  "application/x-javascript": true,
18219
18329
  "application/x-python-code": true,
@@ -18313,14 +18423,20 @@ var models_default = {
18313
18423
  },
18314
18424
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18315
18425
  quotaInfo: {
18316
- remainingFraction: 0.9615639,
18317
- resetTime: "2026-09-16T08:58:14Z"
18426
+ remainingFraction: 0.9790073,
18427
+ resetTime: "2026-09-17T09:29:22Z"
18318
18428
  },
18319
18429
  recommended: true,
18320
18430
  supportedMimeTypes: {
18321
18431
  "application/json": true,
18432
+ "application/msword": true,
18322
18433
  "application/pdf": true,
18323
18434
  "application/rtf": true,
18435
+ "application/vnd.ms-excel": true,
18436
+ "application/vnd.ms-powerpoint": true,
18437
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18438
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18439
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18324
18440
  "application/x-ipynb+json": true,
18325
18441
  "application/x-javascript": true,
18326
18442
  "application/x-python-code": true,
@@ -18419,14 +18535,20 @@ var models_default = {
18419
18535
  },
18420
18536
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18421
18537
  quotaInfo: {
18422
- remainingFraction: 0.9615639,
18423
- resetTime: "2026-09-16T08:58:14Z"
18538
+ remainingFraction: 0.9790073,
18539
+ resetTime: "2026-09-17T09:29:22Z"
18424
18540
  },
18425
18541
  recommended: true,
18426
18542
  supportedMimeTypes: {
18427
18543
  "application/json": true,
18544
+ "application/msword": true,
18428
18545
  "application/pdf": true,
18429
18546
  "application/rtf": true,
18547
+ "application/vnd.ms-excel": true,
18548
+ "application/vnd.ms-powerpoint": true,
18549
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18550
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18551
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18430
18552
  "application/x-ipynb+json": true,
18431
18553
  "application/x-javascript": true,
18432
18554
  "application/x-python-code": true,
@@ -18503,14 +18625,20 @@ var models_default = {
18503
18625
  },
18504
18626
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18505
18627
  quotaInfo: {
18506
- remainingFraction: 0.9615639,
18507
- resetTime: "2026-09-16T08:58:14Z"
18628
+ remainingFraction: 0.9790073,
18629
+ resetTime: "2026-09-17T09:29:22Z"
18508
18630
  },
18509
18631
  recommended: true,
18510
18632
  supportedMimeTypes: {
18511
18633
  "application/json": true,
18634
+ "application/msword": true,
18512
18635
  "application/pdf": true,
18513
18636
  "application/rtf": true,
18637
+ "application/vnd.ms-excel": true,
18638
+ "application/vnd.ms-powerpoint": true,
18639
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
18640
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
18641
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
18514
18642
  "application/x-ipynb+json": true,
18515
18643
  "application/x-javascript": true,
18516
18644
  "application/x-python-code": true,
@@ -18575,7 +18703,7 @@ var models_default = {
18575
18703
  modelProvider: "MODEL_PROVIDER_OPENAI",
18576
18704
  quotaInfo: {
18577
18705
  remainingFraction: 1,
18578
- resetTime: "2026-09-16T09:06:33Z"
18706
+ resetTime: "2026-09-17T11:40:46Z"
18579
18707
  },
18580
18708
  recommended: true,
18581
18709
  supportsThinking: true,
@@ -20685,799 +20813,14 @@ function toUrlString(value) {
20685
20813
  return value.toString();
20686
20814
  }
20687
20815
 
20688
- // src/plugin/types.ts
20689
- function defineOpenCodeV2Plugin(def) {
20690
- return def;
20691
- }
20692
-
20693
- // src/plugin/v2.ts
20694
- import { homedir as homedir4 } from "os";
20695
- import { join as join6 } from "path";
20696
- import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
20697
- import "http";
20698
- var AGY_V2_QUOTA_COMMAND = "agy-quota";
20699
- var AGY_V2_QUOTA_SUMMARY_COMMAND = "agy-quota-summary";
20700
- var AGY_V2_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
20701
-
20702
- Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
20703
- Do not call other tools.
20704
- `;
20705
- var AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
20706
-
20707
- Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
20708
- Do not call other tools.
20709
- `;
20710
- function getSafeHeader2(headers, key) {
20711
- if (!headers) {
20712
- return void 0;
20713
- }
20714
- const targetKey = key.toLowerCase();
20715
- if (typeof headers.get === "function") {
20716
- try {
20717
- return headers.get(targetKey) || void 0;
20718
- } catch {
20719
- }
20720
- }
20721
- if (Array.isArray(headers)) {
20722
- const found = headers.find((item) => {
20723
- if (Array.isArray(item) && typeof item[0] === "string") {
20724
- return item[0].toLowerCase() === targetKey;
20725
- }
20726
- return false;
20727
- });
20728
- return found ? String(found[1]) : void 0;
20729
- }
20730
- if (typeof headers === "object") {
20731
- const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
20732
- return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
20733
- }
20734
- return void 0;
20735
- }
20736
- function setSafeHeaders2(initHeaders, newHeaders) {
20737
- if (typeof globalThis.Headers !== "undefined") {
20738
- const headers = new globalThis.Headers(initHeaders ?? {});
20739
- for (const [k, v] of Object.entries(newHeaders)) {
20740
- headers.set(k, v);
20741
- }
20742
- return headers;
20743
- }
20744
- if (Array.isArray(initHeaders)) {
20745
- const nextHeaders2 = [...initHeaders];
20746
- for (const [k, v] of Object.entries(newHeaders)) {
20747
- const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
20748
- if (idx !== -1) {
20749
- nextHeaders2[idx] = [k, v];
20750
- } else {
20751
- nextHeaders2.push([k, v]);
20752
- }
20753
- }
20754
- return nextHeaders2;
20755
- }
20756
- const nextHeaders = {};
20757
- if (initHeaders && typeof initHeaders === "object") {
20758
- for (const [k, v] of Object.entries(initHeaders)) {
20759
- nextHeaders[k] = String(v);
20760
- }
20761
- }
20762
- for (const [k, v] of Object.entries(newHeaders)) {
20763
- const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
20764
- if (existingKey) {
20765
- nextHeaders[existingKey] = v;
20766
- } else {
20767
- nextHeaders[k] = v;
20768
- }
20769
- }
20770
- return nextHeaders;
20771
- }
20772
- function toUrlString2(value) {
20773
- if (typeof value === "string") {
20774
- return value;
20775
- }
20776
- const candidate = value.url;
20777
- if (candidate) {
20778
- return candidate;
20779
- }
20780
- return value.toString();
20781
- }
20782
- function resolveModelTier2(baseModelId, init) {
20783
- const parts = baseModelId.split("@");
20784
- const base = parts[0] || "";
20785
- const suffixTier = parts[1]?.toLowerCase();
20786
- const mapping = TIER_MAPPING[base];
20787
- if (!mapping) {
20788
- return baseModelId;
20789
- }
20790
- const headerTier = getSafeHeader2(init?.headers, "x-agy-tier")?.toLowerCase() || null;
20791
- const requestedTier = headerTier || suffixTier;
20792
- if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
20793
- return mapping[requestedTier] || baseModelId;
20794
- }
20795
- return mapping["medium"] ?? mapping["high"];
20796
- }
20797
- var storedAuthOverrideForTesting = void 0;
20798
- function loadStoredAuthFromJson() {
20799
- if (storedAuthOverrideForTesting !== void 0) {
20800
- return storedAuthOverrideForTesting;
20801
- }
20802
- const authPath = join6(homedir4(), ".local", "share", "opencode", "auth.json");
20803
- try {
20804
- if (existsSync6(authPath)) {
20805
- const content = readFileSync5(authPath, "utf8");
20806
- const data = JSON.parse(content);
20807
- return data?.[AGY_PROVIDER_ID];
20808
- }
20809
- } catch {
20810
- }
20811
- return void 0;
20812
- }
20813
- function saveStoredAuthToJson(authRecord) {
20814
- if (process.env.NODE_ENV === "test" || process.env.VITEST || storedAuthOverrideForTesting !== void 0) {
20815
- return;
20816
- }
20817
- try {
20818
- const dirPath = join6(homedir4(), ".local", "share", "opencode");
20819
- if (!existsSync6(dirPath)) {
20820
- mkdirSync5(dirPath, { recursive: true });
20821
- }
20822
- const authPath = join6(dirPath, "auth.json");
20823
- let data = {};
20824
- if (existsSync6(authPath)) {
20825
- try {
20826
- data = JSON.parse(readFileSync5(authPath, "utf8")) || {};
20827
- } catch {
20828
- data = {};
20829
- }
20830
- }
20831
- data[AGY_PROVIDER_ID] = {
20832
- type: "oauth",
20833
- refresh: authRecord.refresh,
20834
- access: authRecord.access,
20835
- expires: authRecord.expires
20836
- };
20837
- writeFileSync5(authPath, JSON.stringify(data, null, 2), "utf8");
20838
- } catch {
20839
- }
20840
- }
20841
- function createV2FetchInterceptor(getAuthSnapshot) {
20842
- return async function agyV2Fetch(input, init) {
20843
- const isGL = isGenerativeLanguageRequest(input);
20844
- const isInternal = toUrlString2(input).includes("cloudcode-pa.googleapis.com");
20845
- if (!isGL && !isInternal) {
20846
- return agyFetch(input, init);
20847
- }
20848
- let rawAuth = getAuthSnapshot ? await getAuthSnapshot() : void 0;
20849
- if (!rawAuth) {
20850
- rawAuth = loadStoredAuthFromJson();
20851
- }
20852
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
20853
- return agyFetch(input, init);
20854
- }
20855
- let authRecord = resolveCachedAuth(rawAuth);
20856
- if (accessTokenExpired(authRecord)) {
20857
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
20858
- } } });
20859
- if (refreshed) {
20860
- authRecord = refreshed;
20861
- }
20862
- }
20863
- if (!authRecord.access) {
20864
- return agyFetch(input, init);
20865
- }
20866
- if (isInternal) {
20867
- const hasAuth = getSafeHeader2(init?.headers, "Authorization") !== void 0;
20868
- if (hasAuth) {
20869
- return agyFetch(input, init);
20870
- }
20871
- const userAgent = buildAgyCliUserAgent();
20872
- const headers = setSafeHeaders2(init?.headers, {
20873
- Authorization: `Bearer ${authRecord.access}`,
20874
- "User-Agent": userAgent
20875
- });
20876
- return agyFetch(input, {
20877
- ...init,
20878
- headers
20879
- });
20880
- }
20881
- const requestTarget = parseGenerativeLanguageRequest(input);
20882
- const requestUserAgentModel = requestTarget?.effectiveModel;
20883
- let projectContext;
20884
- try {
20885
- projectContext = await ensureProjectContext(
20886
- authRecord,
20887
- { auth: { set: async () => {
20888
- } } },
20889
- void 0,
20890
- requestUserAgentModel
20891
- );
20892
- } catch {
20893
- projectContext = {
20894
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
20895
- auth: authRecord
20896
- };
20897
- }
20898
- const originalRequestedModel = parseGenerativeLanguageRequest(input)?.effectiveModel;
20899
- let modifiedInput = input;
20900
- if (isGL && originalRequestedModel) {
20901
- const originalBase = originalRequestedModel.replace("google-agy/", "");
20902
- const resolvedBase = resolveModelTier2(originalBase, init);
20903
- if (originalBase !== resolvedBase) {
20904
- if (typeof modifiedInput === "string") {
20905
- modifiedInput = modifiedInput.replace(`models/${originalBase}`, `models/${resolvedBase}`);
20906
- } else if (typeof Request !== "undefined" && modifiedInput instanceof Request) {
20907
- const newUrl = modifiedInput.url.replace(`models/${originalBase}`, `models/${resolvedBase}`);
20908
- modifiedInput = new Request(newUrl, modifiedInput);
20909
- }
20910
- }
20911
- }
20912
- const transformed = prepareAgyRequest(
20913
- modifiedInput,
20914
- init,
20915
- authRecord.access,
20916
- projectContext.effectiveProjectId,
20917
- void 0
20918
- );
20919
- const chatLogger = createChatLogger();
20920
- if (chatLogger) {
20921
- chatLogger.logRequest(
20922
- toUrlString2(transformed.request),
20923
- transformed.init.method || "GET",
20924
- transformed.init.headers,
20925
- transformed.init.body
20926
- );
20927
- }
20928
- const response = await fetchWithRetry(transformed.request, transformed.init);
20929
- return transformAgyResponse(
20930
- response,
20931
- transformed.streaming,
20932
- null,
20933
- transformed.requestedModel,
20934
- transformed.sessionId,
20935
- chatLogger
20936
- );
20937
- };
20938
- }
20939
- async function setupOpenCodeV2(ctx) {
20940
- ctx.catalog.transform(async (editor) => {
20941
- if (!editor) return;
20942
- const resolveVariants = (modelId) => {
20943
- const mapping = TIER_MAPPING[modelId];
20944
- if (!mapping) return void 0;
20945
- const variants = [];
20946
- if (mapping.minimal !== void 0) variants.push({ id: "minimal" });
20947
- if (mapping.low !== void 0) variants.push({ id: "low" });
20948
- if (mapping.medium !== void 0) variants.push({ id: "medium" });
20949
- if (mapping.high !== void 0) variants.push({ id: "high" });
20950
- return variants.length > 0 ? variants : void 0;
20951
- };
20952
- if (typeof editor?.provider?.update === "function") {
20953
- editor.provider.update(AGY_PROVIDER_ID, (p) => {
20954
- p.name = "Antigravity CLI";
20955
- p.activation = "enabled";
20956
- p.package = "aisdk:@ai-sdk/google";
20957
- p.description = "Google Gemini Antigravity Code Assist OAuth provider";
20958
- p.settings = { ...p.settings || {}, apiKey: "dummy" };
20959
- p.integrationID = AGY_PROVIDER_ID;
20960
- });
20961
- if (typeof editor?.model?.update === "function") {
20962
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
20963
- editor.model.update(AGY_PROVIDER_ID, modelId, (m) => {
20964
- m.name = simple.name;
20965
- m.capabilities = {
20966
- tools: true,
20967
- input: ["text", "image"],
20968
- output: ["text"]
20969
- };
20970
- m.limit = {
20971
- context: simple.maxTokens,
20972
- output: simple.maxOutputTokens
20973
- };
20974
- m.family = "gemini";
20975
- if (simple.cost) {
20976
- m.cost = simple.cost;
20977
- }
20978
- const variants = resolveVariants(modelId);
20979
- if (variants) {
20980
- m.variants = variants;
20981
- }
20982
- });
20983
- }
20984
- }
20985
- return;
20986
- }
20987
- const catalog = editor;
20988
- catalog.providers = catalog.providers || {};
20989
- catalog.providers[AGY_PROVIDER_ID] = {
20990
- id: AGY_PROVIDER_ID,
20991
- name: "Antigravity CLI",
20992
- npm: "aisdk:@ai-sdk/google",
20993
- settings: { apiKey: "dummy" },
20994
- integrationID: AGY_PROVIDER_ID,
20995
- models: { ...catalog.providers[AGY_PROVIDER_ID]?.models || {} },
20996
- ...catalog.providers[AGY_PROVIDER_ID]
20997
- };
20998
- if (catalog.providers[AGY_PROVIDER_ID].settings) {
20999
- catalog.providers[AGY_PROVIDER_ID].settings = {
21000
- ...catalog.providers[AGY_PROVIDER_ID].settings,
21001
- apiKey: "dummy"
21002
- };
21003
- } else {
21004
- catalog.providers[AGY_PROVIDER_ID].settings = { apiKey: "dummy" };
21005
- }
21006
- catalog.providers[AGY_PROVIDER_ID].integrationID = AGY_PROVIDER_ID;
21007
- const targetModels = catalog.providers[AGY_PROVIDER_ID].models;
21008
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21009
- const isClaude = modelId.startsWith("claude-");
21010
- const isGpt = modelId.startsWith("gpt-");
21011
- const variants = resolveVariants(modelId);
21012
- targetModels[modelId] = {
21013
- id: modelId,
21014
- providerID: AGY_PROVIDER_ID,
21015
- name: simple.name,
21016
- description: simple.description,
21017
- family: modelId.includes("gemini") ? "gemini" : isClaude ? "claude" : isGpt ? "gpt" : "unknown",
21018
- reasoning: simple.reasoning,
21019
- attachment: simple.attachment,
21020
- tool_call: simple.toolCall,
21021
- limit: {
21022
- context: simple.maxTokens,
21023
- output: simple.maxOutputTokens
21024
- },
21025
- cost: simple.cost || { input: 0, output: 0 },
21026
- ...variants ? { variants } : {},
21027
- ...targetModels[modelId] || {}
21028
- };
21029
- }
21030
- });
21031
- ctx.tool.transform(async (editor) => {
21032
- if (!editor) return;
21033
- const quotaTool = createAgyQuotaTool({
21034
- client: void 0,
21035
- getAuthResolver: () => void 0,
21036
- getConfiguredProjectId: () => void 0,
21037
- getUserAgentModel: () => void 0
21038
- });
21039
- const quotaSummaryTool = createAgyQuotaSummaryTool({
21040
- client: void 0,
21041
- getAuthResolver: () => void 0,
21042
- getConfiguredProjectId: () => void 0,
21043
- getUserAgentModel: () => void 0
21044
- });
21045
- if (typeof editor.add === "function") {
21046
- editor.add({
21047
- name: AGY_QUOTA_TOOL_NAME,
21048
- description: quotaTool.description,
21049
- input: {},
21050
- execute: async (args, context) => quotaTool.execute(args, context)
21051
- });
21052
- editor.add({
21053
- name: AGY_QUOTA_SUMMARY_TOOL_NAME,
21054
- description: quotaSummaryTool.description,
21055
- input: {},
21056
- execute: async (args, context) => quotaSummaryTool.execute(args, context)
21057
- });
21058
- } else if (typeof editor.set === "function") {
21059
- editor.set(AGY_QUOTA_TOOL_NAME, quotaTool);
21060
- editor.set(AGY_QUOTA_SUMMARY_TOOL_NAME, quotaSummaryTool);
21061
- } else if (editor.tools && typeof editor.tools === "object") {
21062
- editor.tools[AGY_QUOTA_TOOL_NAME] = quotaTool;
21063
- editor.tools[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21064
- } else if (typeof editor === "object") {
21065
- editor[AGY_QUOTA_TOOL_NAME] = quotaTool;
21066
- editor[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21067
- }
21068
- });
21069
- ctx.command.transform(async (editor) => {
21070
- if (!editor) return;
21071
- const commands = {
21072
- [AGY_V2_QUOTA_COMMAND]: {
21073
- description: "Show Agy Code Assist quota usage",
21074
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21075
- },
21076
- [AGY_V2_QUOTA_SUMMARY_COMMAND]: {
21077
- description: "Show Agy Code Assist quota summary with weekly and 5-hour limits",
21078
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21079
- }
21080
- };
21081
- if (typeof editor.add === "function") {
21082
- editor.add({
21083
- name: AGY_V2_QUOTA_COMMAND,
21084
- description: "Display current Antigravity quota usage",
21085
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21086
- });
21087
- editor.add({
21088
- name: AGY_V2_QUOTA_SUMMARY_COMMAND,
21089
- description: "Display Antigravity quota summary grouped by model family",
21090
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21091
- });
21092
- } else if (typeof editor.set === "function") {
21093
- editor.set(AGY_V2_QUOTA_COMMAND, commands[AGY_V2_QUOTA_COMMAND]);
21094
- editor.set(AGY_V2_QUOTA_SUMMARY_COMMAND, commands[AGY_V2_QUOTA_SUMMARY_COMMAND]);
21095
- } else if (editor.commands && typeof editor.commands === "object") {
21096
- editor.commands[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21097
- editor.commands[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21098
- } else if (typeof editor === "object") {
21099
- editor[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21100
- editor[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21101
- }
21102
- });
21103
- ctx.integration?.transform?.((editor) => {
21104
- if (!editor) return;
21105
- editor.update?.(AGY_PROVIDER_ID, (integration) => {
21106
- integration.name = "Antigravity CLI (plugin)";
21107
- });
21108
- editor.method?.update?.({
21109
- integrationID: AGY_PROVIDER_ID,
21110
- method: {
21111
- id: "oauth",
21112
- type: "oauth",
21113
- label: "Antigravity CLI (OAuth)"
21114
- },
21115
- authorize: async () => {
21116
- const authorization = await authorizeAgy();
21117
- return {
21118
- mode: "code",
21119
- url: authorization.url,
21120
- instructions: "Please complete Google account authorization in your browser. After authorization, copy the full redirect URL or code and paste it below:",
21121
- callback: async (code) => {
21122
- const trimmed = code.trim();
21123
- const parsed = parseOAuthCallbackInput(trimmed);
21124
- const authCode = parsed.code || trimmed;
21125
- if (!authCode) {
21126
- return { type: "failed", error: "Missing authorization code in callback input" };
21127
- }
21128
- if (parsed.state && parsed.state !== authorization.state) {
21129
- return { type: "failed", error: "State mismatch in callback input (possible CSRF attempt)" };
21130
- }
21131
- const exchangeResult = await exchangeAgyWithVerifier(authCode, authorization.verifier);
21132
- if (exchangeResult.type !== "success") {
21133
- return exchangeResult;
21134
- }
21135
- const initialRefresh = formatRefreshParts({
21136
- refreshToken: exchangeResult.refresh
21137
- });
21138
- let authRecord = {
21139
- type: "oauth",
21140
- refresh: initialRefresh,
21141
- access: exchangeResult.access,
21142
- expires: exchangeResult.expires
21143
- };
21144
- try {
21145
- const projectContext = await ensureProjectContext(
21146
- authRecord,
21147
- { auth: { set: async () => {
21148
- } } }
21149
- );
21150
- authRecord = {
21151
- ...authRecord,
21152
- refresh: projectContext.auth.refresh
21153
- };
21154
- } catch {
21155
- }
21156
- saveStoredAuthToJson(authRecord);
21157
- return {
21158
- type: "oauth",
21159
- methodID: "oauth",
21160
- refresh: authRecord.refresh,
21161
- access: authRecord.access,
21162
- expires: authRecord.expires
21163
- };
21164
- }
21165
- };
21166
- }
21167
- });
21168
- });
21169
- ctx.aisdk?.hook("sdk", async (event) => {
21170
- if (!event) return;
21171
- const isMatchingProvider = event.providerID === AGY_PROVIDER_ID || event.model?.providerID === AGY_PROVIDER_ID;
21172
- if (!isMatchingProvider) return;
21173
- event.options = event.options || {};
21174
- event.options.apiKey = "dummy";
21175
- event.options.fetch = createV2FetchInterceptor();
21176
- });
21177
- let lastInterceptedModel;
21178
- ctx.session.hook(
21179
- "http.request",
21180
- async (event) => {
21181
- if (!event) return;
21182
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21183
- const isGL = isGenerativeLanguageRequest(rawUrl);
21184
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21185
- if (!isGL && !isInternal) {
21186
- return;
21187
- }
21188
- event.headers = event.headers || {};
21189
- let modelName;
21190
- let rawAuth = event.auth;
21191
- if (rawAuth && !rawAuth.type) {
21192
- const tokenVal = rawAuth.access || rawAuth.token;
21193
- if (tokenVal || rawAuth.refresh) {
21194
- rawAuth = { type: "oauth", access: tokenVal, ...rawAuth };
21195
- }
21196
- }
21197
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
21198
- rawAuth = loadStoredAuthFromJson();
21199
- }
21200
- let authRecord = rawAuth && isOAuthAuth(rawAuth) ? resolveCachedAuth(rawAuth) : void 0;
21201
- if (authRecord && accessTokenExpired(authRecord)) {
21202
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
21203
- } } });
21204
- if (refreshed) {
21205
- authRecord = refreshed;
21206
- saveStoredAuthToJson(refreshed);
21207
- }
21208
- }
21209
- if (isGL) {
21210
- const parsed = parseGenerativeLanguageRequest(rawUrl);
21211
- modelName = parsed?.effectiveModel;
21212
- if (modelName) {
21213
- lastInterceptedModel = modelName;
21214
- }
21215
- if (typeof event.headers.delete === "function") {
21216
- event.headers.delete("x-goog-api-key");
21217
- event.headers.delete("api-key");
21218
- } else {
21219
- for (const key of Object.keys(event.headers)) {
21220
- const lower = key.toLowerCase();
21221
- if (lower === "x-goog-api-key" || lower === "api-key") {
21222
- delete event.headers[key];
21223
- }
21224
- }
21225
- }
21226
- if (event.request?.headers) {
21227
- if (typeof event.request.headers.delete === "function") {
21228
- event.request.headers.delete("x-goog-api-key");
21229
- event.request.headers.delete("api-key");
21230
- } else {
21231
- for (const key of Object.keys(event.request.headers)) {
21232
- const lower = key.toLowerCase();
21233
- if (lower === "x-goog-api-key" || lower === "api-key") {
21234
- delete event.request.headers[key];
21235
- }
21236
- }
21237
- }
21238
- }
21239
- let cleanUrl = rawUrl;
21240
- try {
21241
- const parsedUrl = new URL(rawUrl);
21242
- let urlChanged = false;
21243
- for (const param of ["key", "x-goog-api-key", "api-key"]) {
21244
- if (parsedUrl.searchParams.has(param)) {
21245
- parsedUrl.searchParams.delete(param);
21246
- urlChanged = true;
21247
- }
21248
- }
21249
- if (urlChanged) {
21250
- cleanUrl = parsedUrl.toString();
21251
- }
21252
- } catch {
21253
- }
21254
- if (authRecord && authRecord.access) {
21255
- let projectContext;
21256
- try {
21257
- projectContext = await ensureProjectContext(
21258
- authRecord,
21259
- { auth: { set: async () => {
21260
- } } },
21261
- void 0,
21262
- modelName
21263
- );
21264
- } catch {
21265
- projectContext = {
21266
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
21267
- auth: authRecord
21268
- };
21269
- }
21270
- const originalRequestedModel = modelName;
21271
- let modifiedUrl = cleanUrl;
21272
- if (originalRequestedModel) {
21273
- const originalBase = originalRequestedModel.replace("google-agy/", "");
21274
- const initHeaders = event.headers instanceof Headers ? event.headers : event.request?.headers;
21275
- const resolvedBase = resolveModelTier2(originalBase, { headers: initHeaders });
21276
- if (originalBase !== resolvedBase) {
21277
- modifiedUrl = modifiedUrl.replace(`models/${originalBase}`, `models/${resolvedBase}`);
21278
- }
21279
- }
21280
- let bodyPayload = event.body;
21281
- if (bodyPayload === void 0 && event.request) {
21282
- if (typeof event.request.clone === "function") {
21283
- try {
21284
- bodyPayload = await event.request.clone().text();
21285
- } catch {
21286
- }
21287
- } else if (event.request.body !== void 0) {
21288
- bodyPayload = event.request.body;
21289
- }
21290
- }
21291
- let preExistingUserAgent;
21292
- if (typeof event.headers?.get === "function") {
21293
- preExistingUserAgent = event.headers.get("user-agent") || event.headers.get("User-Agent") || void 0;
21294
- } else if (event.headers && typeof event.headers === "object") {
21295
- preExistingUserAgent = event.headers["user-agent"] || event.headers["User-Agent"] || void 0;
21296
- }
21297
- if (!preExistingUserAgent && typeof event.request?.headers?.get === "function") {
21298
- preExistingUserAgent = event.request.headers.get("user-agent") || event.request.headers.get("User-Agent") || void 0;
21299
- } else if (!preExistingUserAgent && event.request?.headers && typeof event.request.headers === "object") {
21300
- preExistingUserAgent = event.request.headers["user-agent"] || event.request.headers["User-Agent"] || void 0;
21301
- }
21302
- const method = event.method || event.request?.method || "POST";
21303
- const requestHeaders = event.headers || event.request?.headers;
21304
- const transformed = prepareAgyRequest(
21305
- modifiedUrl,
21306
- {
21307
- method,
21308
- headers: requestHeaders,
21309
- body: bodyPayload
21310
- },
21311
- authRecord.access,
21312
- projectContext.effectiveProjectId
21313
- );
21314
- const targetUrl = toUrlString2(transformed.request);
21315
- if (typeof event.url === "string") {
21316
- event.url = targetUrl;
21317
- }
21318
- if (event.request && typeof event.request === "object") {
21319
- if (typeof Request !== "undefined" && event.request instanceof Request) {
21320
- event.request = new Request(targetUrl, {
21321
- method: transformed.init.method,
21322
- headers: transformed.init.headers,
21323
- body: transformed.init.body
21324
- });
21325
- } else if (typeof event.request.url === "string") {
21326
- try {
21327
- event.request.url = targetUrl;
21328
- } catch {
21329
- }
21330
- }
21331
- }
21332
- const headerEntries = transformed.init.headers instanceof Headers ? Array.from(transformed.init.headers.entries()) : Object.entries(transformed.init.headers || {});
21333
- for (const [k, v] of headerEntries) {
21334
- const lowerK = k.toLowerCase();
21335
- if (lowerK === "user-agent") {
21336
- if (preExistingUserAgent) {
21337
- continue;
21338
- }
21339
- if (typeof event.headers?.set === "function") {
21340
- event.headers.set("User-Agent", v);
21341
- } else if (event.headers) {
21342
- event.headers["User-Agent"] = v;
21343
- }
21344
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21345
- event.request.headers.set("User-Agent", v);
21346
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21347
- event.request.headers["User-Agent"] = v;
21348
- }
21349
- continue;
21350
- }
21351
- if (typeof event.headers?.set === "function") {
21352
- event.headers.set(k, v);
21353
- } else if (event.headers) {
21354
- event.headers[k] = v;
21355
- }
21356
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21357
- event.request.headers.set(k, v);
21358
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21359
- event.request.headers[k] = v;
21360
- }
21361
- }
21362
- if (transformed.init.body !== void 0) {
21363
- event.body = transformed.init.body;
21364
- if (event.request && typeof event.request === "object" && !(event.request instanceof Request)) {
21365
- event.request.body = transformed.init.body;
21366
- }
21367
- }
21368
- } else {
21369
- if (typeof event.url === "string") {
21370
- event.url = cleanUrl;
21371
- }
21372
- if (event.request && typeof event.request === "object") {
21373
- if (typeof event.request.url === "string") {
21374
- event.request.url = cleanUrl;
21375
- }
21376
- }
21377
- }
21378
- }
21379
- if (authRecord && authRecord.access) {
21380
- if (typeof event.headers?.set === "function") {
21381
- event.headers.set("Authorization", `Bearer ${authRecord.access}`);
21382
- } else if (event.headers) {
21383
- event.headers["Authorization"] = `Bearer ${authRecord.access}`;
21384
- }
21385
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21386
- event.request.headers.set("Authorization", `Bearer ${authRecord.access}`);
21387
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21388
- event.request.headers["Authorization"] = `Bearer ${authRecord.access}`;
21389
- }
21390
- }
21391
- const userAgent = buildAgyCliUserAgent(modelName);
21392
- if (typeof event.headers?.set === "function") {
21393
- if (!event.headers.get("User-Agent") && !event.headers.get("user-agent")) {
21394
- event.headers.set("User-Agent", userAgent);
21395
- }
21396
- } else if (event.headers) {
21397
- if (!event.headers["User-Agent"] && !event.headers["user-agent"]) {
21398
- event.headers["User-Agent"] = userAgent;
21399
- }
21400
- }
21401
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21402
- if (!event.request.headers.get("User-Agent") && !event.request.headers.get("user-agent")) {
21403
- event.request.headers.set("User-Agent", userAgent);
21404
- }
21405
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21406
- if (!event.request.headers["User-Agent"] && !event.request.headers["user-agent"]) {
21407
- event.request.headers["User-Agent"] = userAgent;
21408
- }
21409
- }
21410
- },
21411
- { providerID: AGY_PROVIDER_ID }
21412
- );
21413
- ctx.session.hook(
21414
- "http.response",
21415
- async (event) => {
21416
- if (!event || !event.response) return;
21417
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21418
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21419
- if (isInternal && event.response instanceof Response) {
21420
- const isStreaming = rawUrl.includes(":streamGenerateCode") || event.response.headers.get("content-type")?.includes("text/event-stream");
21421
- const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel || lastInterceptedModel;
21422
- const transformed = await transformAgyResponse(
21423
- event.response,
21424
- !!isStreaming,
21425
- null,
21426
- parsedModel,
21427
- void 0,
21428
- void 0
21429
- );
21430
- event.response = transformed;
21431
- }
21432
- },
21433
- { providerID: AGY_PROVIDER_ID }
21434
- );
21435
- ctx.session.hook(
21436
- "retry",
21437
- async (event) => {
21438
- if (!event) return;
21439
- const response = event.response;
21440
- if (response instanceof Response) {
21441
- if (response.status === 429 || response.status === 503) {
21442
- const quota = await classifyQuotaResponse(response);
21443
- if (quota?.retryDelayMs) {
21444
- event.retryDelayMs = quota.retryDelayMs;
21445
- } else {
21446
- event.retryDelayMs = await resolveRetryDelayMs(response, event.attempt || 1);
21447
- }
21448
- }
21449
- } else if (event.details && Array.isArray(event.details)) {
21450
- const retryInfo = event.details.find(
21451
- (d) => d && d["@type"] === "type.googleapis.com/google.rpc.RetryInfo"
21452
- );
21453
- if (retryInfo?.retryDelay) {
21454
- const delayMs = retryInternals.parseRetryDelayValue(retryInfo.retryDelay);
21455
- if (delayMs !== null) {
21456
- event.retryDelayMs = delayMs;
21457
- }
21458
- }
21459
- }
21460
- },
21461
- { providerID: AGY_PROVIDER_ID }
21462
- );
21463
- }
21464
- var v2PluginDefinition = defineOpenCodeV2Plugin({
21465
- id: AGY_PROVIDER_ID,
21466
- setup: setupOpenCodeV2
21467
- });
21468
-
21469
20816
  // index.ts
21470
- var dualPlugin = {
21471
- ...v2PluginDefinition,
20817
+ var index_default = {
20818
+ id: "@anthonyhaussman/opencode-agy-auth",
21472
20819
  server: AgyCLIOAuthPlugin
21473
20820
  };
21474
- var index_default = dualPlugin;
21475
20821
  export {
21476
20822
  AgyCLIOAuthPlugin,
21477
20823
  GoogleOAuthPlugin,
21478
- index_default as default,
21479
- defineOpenCodeV2Plugin,
21480
- setupOpenCodeV2,
21481
- v2PluginDefinition
20824
+ index_default as default
21482
20825
  };
21483
20826
  //# sourceMappingURL=index.js.map