@anthonyhaussman/opencode-agy-auth 1.2.16 → 1.2.17-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1006 -194
- package/dist/index.js.map +1 -1
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/plugin/headers.d.ts +7 -0
- package/dist/src/plugin/oauth-authorize.d.ts +9 -0
- package/dist/src/plugin/quota-summary.d.ts +2 -0
- package/dist/src/plugin/quota.d.ts +2 -0
- package/dist/src/plugin/tier.d.ts +28 -0
- package/dist/src/plugin/types.d.ts +35 -0
- package/dist/src/plugin/v2-fetch.d.ts +1 -0
- package/dist/src/plugin/v2-session.d.ts +7 -0
- package/dist/src/plugin/v2-storage.d.ts +3 -0
- package/dist/src/plugin/v2.d.ts +14 -0
- package/dist/src/plugin.d.ts +2 -0
- package/dist/src/sdk/agy-cli-version.d.ts +1 -1
- package/dist/src/sdk/request/prepare.d.ts +2 -0
- package/package.json +2 -2
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.
|
|
271
|
+
var AGY_CLI_VERSION = "1.2.17";
|
|
272
272
|
|
|
273
273
|
// src/sdk/user-agent.ts
|
|
274
274
|
var cachedUserAgent = null;
|
|
@@ -579,6 +579,12 @@ 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
|
+
};
|
|
582
588
|
|
|
583
589
|
// src/sdk/retry/helpers.ts
|
|
584
590
|
var DEFAULT_MAX_ATTEMPTS = 3;
|
|
@@ -1575,7 +1581,11 @@ function createOAuthAuthorizeMethod(options) {
|
|
|
1575
1581
|
const isHeadless = !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS);
|
|
1576
1582
|
const authorization = await authorizeAgy();
|
|
1577
1583
|
if (!isHeadless) {
|
|
1578
|
-
|
|
1584
|
+
if (options?.openBrowser) {
|
|
1585
|
+
options.openBrowser(authorization.url);
|
|
1586
|
+
} else {
|
|
1587
|
+
openBrowserUrl(authorization.url);
|
|
1588
|
+
}
|
|
1579
1589
|
}
|
|
1580
1590
|
return {
|
|
1581
1591
|
url: authorization.url,
|
|
@@ -1629,16 +1639,23 @@ function parseOAuthCallbackInput(input) {
|
|
|
1629
1639
|
}
|
|
1630
1640
|
return { code: trimmed };
|
|
1631
1641
|
}
|
|
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;
|
|
1632
1650
|
function openBrowserUrl(url2) {
|
|
1651
|
+
if ((process.env.NODE_ENV === "test" || process.env.VITEST) && openBrowserLauncher === defaultOpenBrowserLauncher) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1633
1654
|
try {
|
|
1634
1655
|
const platform2 = process.platform;
|
|
1635
1656
|
const command = platform2 === "darwin" ? "open" : platform2 === "win32" ? "rundll32" : "xdg-open";
|
|
1636
1657
|
const args = platform2 === "win32" ? ["url.dll,FileProtocolHandler", url2] : [url2];
|
|
1637
|
-
|
|
1638
|
-
stdio: "ignore",
|
|
1639
|
-
detached: true
|
|
1640
|
-
});
|
|
1641
|
-
child.unref?.();
|
|
1658
|
+
openBrowserLauncher(command, args);
|
|
1642
1659
|
} catch {
|
|
1643
1660
|
}
|
|
1644
1661
|
}
|
|
@@ -15320,6 +15337,12 @@ function formatRelativeResetTime(resetTime) {
|
|
|
15320
15337
|
|
|
15321
15338
|
// src/plugin/quota.ts
|
|
15322
15339
|
var AGY_QUOTA_TOOL_NAME = "agy_quota";
|
|
15340
|
+
var AGY_V2_QUOTA_COMMAND = "agy-quota";
|
|
15341
|
+
var AGY_V2_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
|
|
15342
|
+
|
|
15343
|
+
Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
|
|
15344
|
+
Do not call other tools.
|
|
15345
|
+
`;
|
|
15323
15346
|
function createAgyQuotaTool({
|
|
15324
15347
|
client,
|
|
15325
15348
|
getAuthResolver,
|
|
@@ -15559,6 +15582,12 @@ function splitModelVariant(modelId) {
|
|
|
15559
15582
|
|
|
15560
15583
|
// src/plugin/quota-summary.ts
|
|
15561
15584
|
var AGY_QUOTA_SUMMARY_TOOL_NAME = "agy_quota_summary";
|
|
15585
|
+
var AGY_V2_QUOTA_SUMMARY_COMMAND = "agy-quota-summary";
|
|
15586
|
+
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.
|
|
15587
|
+
|
|
15588
|
+
Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
|
|
15589
|
+
Do not call other tools.
|
|
15590
|
+
`;
|
|
15562
15591
|
function createAgyQuotaSummaryTool({
|
|
15563
15592
|
client,
|
|
15564
15593
|
getAuthResolver,
|
|
@@ -16146,7 +16175,7 @@ var models_default = {
|
|
|
16146
16175
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16147
16176
|
quotaInfo: {
|
|
16148
16177
|
remainingFraction: 1,
|
|
16149
|
-
resetTime: "2026-10-
|
|
16178
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16150
16179
|
},
|
|
16151
16180
|
recommended: true,
|
|
16152
16181
|
supportedMimeTypes: {
|
|
@@ -16184,7 +16213,7 @@ var models_default = {
|
|
|
16184
16213
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16185
16214
|
quotaInfo: {
|
|
16186
16215
|
remainingFraction: 1,
|
|
16187
|
-
resetTime: "2026-10-
|
|
16216
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16188
16217
|
},
|
|
16189
16218
|
recommended: true,
|
|
16190
16219
|
supportedMimeTypes: {
|
|
@@ -16222,7 +16251,7 @@ var models_default = {
|
|
|
16222
16251
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16223
16252
|
quotaInfo: {
|
|
16224
16253
|
remainingFraction: 1,
|
|
16225
|
-
resetTime: "2026-10-
|
|
16254
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16226
16255
|
},
|
|
16227
16256
|
recommended: true,
|
|
16228
16257
|
supportedMimeTypes: {
|
|
@@ -16260,7 +16289,7 @@ var models_default = {
|
|
|
16260
16289
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16261
16290
|
quotaInfo: {
|
|
16262
16291
|
remainingFraction: 1,
|
|
16263
|
-
resetTime: "2026-10-
|
|
16292
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16264
16293
|
},
|
|
16265
16294
|
recommended: true,
|
|
16266
16295
|
supportedMimeTypes: {
|
|
@@ -16298,7 +16327,7 @@ var models_default = {
|
|
|
16298
16327
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16299
16328
|
quotaInfo: {
|
|
16300
16329
|
remainingFraction: 1,
|
|
16301
|
-
resetTime: "2026-10-
|
|
16330
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16302
16331
|
},
|
|
16303
16332
|
recommended: true,
|
|
16304
16333
|
supportedMimeTypes: {
|
|
@@ -16336,7 +16365,7 @@ var models_default = {
|
|
|
16336
16365
|
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
|
|
16337
16366
|
quotaInfo: {
|
|
16338
16367
|
remainingFraction: 1,
|
|
16339
|
-
resetTime: "2026-10-
|
|
16368
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
16340
16369
|
},
|
|
16341
16370
|
recommended: true,
|
|
16342
16371
|
supportedMimeTypes: {
|
|
@@ -16374,8 +16403,8 @@ var models_default = {
|
|
|
16374
16403
|
},
|
|
16375
16404
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16376
16405
|
quotaInfo: {
|
|
16377
|
-
remainingFraction: 0.
|
|
16378
|
-
resetTime: "2026-10-
|
|
16406
|
+
remainingFraction: 0.9418832,
|
|
16407
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16379
16408
|
},
|
|
16380
16409
|
recommended: true,
|
|
16381
16410
|
supportedMimeTypes: {
|
|
@@ -16457,8 +16486,8 @@ var models_default = {
|
|
|
16457
16486
|
},
|
|
16458
16487
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16459
16488
|
quotaInfo: {
|
|
16460
|
-
remainingFraction: 0.
|
|
16461
|
-
resetTime: "2026-10-
|
|
16489
|
+
remainingFraction: 0.9418832,
|
|
16490
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16462
16491
|
},
|
|
16463
16492
|
recommended: true,
|
|
16464
16493
|
supportedMimeTypes: {
|
|
@@ -16540,8 +16569,8 @@ var models_default = {
|
|
|
16540
16569
|
},
|
|
16541
16570
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16542
16571
|
quotaInfo: {
|
|
16543
|
-
remainingFraction: 0.
|
|
16544
|
-
resetTime: "2026-10-
|
|
16572
|
+
remainingFraction: 0.9418832,
|
|
16573
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16545
16574
|
},
|
|
16546
16575
|
recommended: true,
|
|
16547
16576
|
supportedMimeTypes: {
|
|
@@ -16620,8 +16649,8 @@ var models_default = {
|
|
|
16620
16649
|
},
|
|
16621
16650
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16622
16651
|
quotaInfo: {
|
|
16623
|
-
remainingFraction: 0.
|
|
16624
|
-
resetTime: "2026-10-
|
|
16652
|
+
remainingFraction: 0.9418832,
|
|
16653
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16625
16654
|
},
|
|
16626
16655
|
recommended: true,
|
|
16627
16656
|
requiresImageOutputOutsideFunctionResponses: true,
|
|
@@ -16701,8 +16730,8 @@ var models_default = {
|
|
|
16701
16730
|
},
|
|
16702
16731
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16703
16732
|
quotaInfo: {
|
|
16704
|
-
remainingFraction: 0.
|
|
16705
|
-
resetTime: "2026-10-
|
|
16733
|
+
remainingFraction: 0.9418832,
|
|
16734
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16706
16735
|
},
|
|
16707
16736
|
recommended: true,
|
|
16708
16737
|
supportedMimeTypes: {
|
|
@@ -16806,8 +16835,8 @@ var models_default = {
|
|
|
16806
16835
|
},
|
|
16807
16836
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16808
16837
|
quotaInfo: {
|
|
16809
|
-
remainingFraction: 0.
|
|
16810
|
-
resetTime: "2026-10-
|
|
16838
|
+
remainingFraction: 0.9418832,
|
|
16839
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16811
16840
|
},
|
|
16812
16841
|
recommended: true,
|
|
16813
16842
|
supportedMimeTypes: {
|
|
@@ -16866,8 +16895,6 @@ var models_default = {
|
|
|
16866
16895
|
supportsImages: true,
|
|
16867
16896
|
supportsThinking: true,
|
|
16868
16897
|
supportsVideo: true,
|
|
16869
|
-
tagDescription: "Limited time",
|
|
16870
|
-
tagTitle: "Fast",
|
|
16871
16898
|
thinkingBudget: -1
|
|
16872
16899
|
},
|
|
16873
16900
|
"gemini-3.1-flash-image": {
|
|
@@ -16876,8 +16903,8 @@ var models_default = {
|
|
|
16876
16903
|
model: "MODEL_PLACEHOLDER_M21",
|
|
16877
16904
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16878
16905
|
quotaInfo: {
|
|
16879
|
-
remainingFraction: 0.
|
|
16880
|
-
resetTime: "2026-10-
|
|
16906
|
+
remainingFraction: 0.9418832,
|
|
16907
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16881
16908
|
}
|
|
16882
16909
|
},
|
|
16883
16910
|
"gemini-3.1-flash-lite": {
|
|
@@ -16895,8 +16922,8 @@ var models_default = {
|
|
|
16895
16922
|
},
|
|
16896
16923
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16897
16924
|
quotaInfo: {
|
|
16898
|
-
remainingFraction: 0.
|
|
16899
|
-
resetTime: "2026-10-
|
|
16925
|
+
remainingFraction: 0.9418832,
|
|
16926
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16900
16927
|
}
|
|
16901
16928
|
},
|
|
16902
16929
|
"gemini-3.1-pro-high": {
|
|
@@ -16927,8 +16954,8 @@ var models_default = {
|
|
|
16927
16954
|
},
|
|
16928
16955
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
16929
16956
|
quotaInfo: {
|
|
16930
|
-
remainingFraction: 0.
|
|
16931
|
-
resetTime: "2026-10-
|
|
16957
|
+
remainingFraction: 0.9418832,
|
|
16958
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
16932
16959
|
},
|
|
16933
16960
|
recommended: true,
|
|
16934
16961
|
supportedMimeTypes: {
|
|
@@ -17018,8 +17045,8 @@ var models_default = {
|
|
|
17018
17045
|
},
|
|
17019
17046
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17020
17047
|
quotaInfo: {
|
|
17021
|
-
remainingFraction: 0.
|
|
17022
|
-
resetTime: "2026-10-
|
|
17048
|
+
remainingFraction: 0.9418832,
|
|
17049
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17023
17050
|
},
|
|
17024
17051
|
recommended: true,
|
|
17025
17052
|
supportedMimeTypes: {
|
|
@@ -17123,8 +17150,8 @@ var models_default = {
|
|
|
17123
17150
|
},
|
|
17124
17151
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17125
17152
|
quotaInfo: {
|
|
17126
|
-
remainingFraction: 0.
|
|
17127
|
-
resetTime: "2026-10-
|
|
17153
|
+
remainingFraction: 0.9418832,
|
|
17154
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17128
17155
|
},
|
|
17129
17156
|
recommended: true,
|
|
17130
17157
|
supportedMimeTypes: {
|
|
@@ -17183,8 +17210,6 @@ var models_default = {
|
|
|
17183
17210
|
supportsImages: true,
|
|
17184
17211
|
supportsThinking: true,
|
|
17185
17212
|
supportsVideo: true,
|
|
17186
|
-
tagDescription: "Limited time",
|
|
17187
|
-
tagTitle: "Fast",
|
|
17188
17213
|
thinkingBudget: 1e3
|
|
17189
17214
|
},
|
|
17190
17215
|
"gemini-3.5-flash-lite": {
|
|
@@ -17206,8 +17231,8 @@ var models_default = {
|
|
|
17206
17231
|
},
|
|
17207
17232
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17208
17233
|
quotaInfo: {
|
|
17209
|
-
remainingFraction: 0.
|
|
17210
|
-
resetTime: "2026-10-
|
|
17234
|
+
remainingFraction: 0.9418832,
|
|
17235
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17211
17236
|
},
|
|
17212
17237
|
recommended: true,
|
|
17213
17238
|
supportedMimeTypes: {
|
|
@@ -17313,8 +17338,8 @@ var models_default = {
|
|
|
17313
17338
|
},
|
|
17314
17339
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17315
17340
|
quotaInfo: {
|
|
17316
|
-
remainingFraction: 0.
|
|
17317
|
-
resetTime: "2026-10-
|
|
17341
|
+
remainingFraction: 0.9418832,
|
|
17342
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17318
17343
|
},
|
|
17319
17344
|
recommended: true,
|
|
17320
17345
|
supportedMimeTypes: {
|
|
@@ -17373,8 +17398,6 @@ var models_default = {
|
|
|
17373
17398
|
supportsImages: true,
|
|
17374
17399
|
supportsThinking: true,
|
|
17375
17400
|
supportsVideo: true,
|
|
17376
|
-
tagDescription: "Limited time",
|
|
17377
|
-
tagTitle: "Fast",
|
|
17378
17401
|
thinkingBudget: 4e3
|
|
17379
17402
|
},
|
|
17380
17403
|
"gemini-3.6-flash-high": {
|
|
@@ -17432,8 +17455,8 @@ var models_default = {
|
|
|
17432
17455
|
},
|
|
17433
17456
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17434
17457
|
quotaInfo: {
|
|
17435
|
-
remainingFraction: 0.
|
|
17436
|
-
resetTime: "2026-10-
|
|
17458
|
+
remainingFraction: 0.9418832,
|
|
17459
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17437
17460
|
},
|
|
17438
17461
|
recommended: true,
|
|
17439
17462
|
supportedMimeTypes: {
|
|
@@ -17492,8 +17515,6 @@ var models_default = {
|
|
|
17492
17515
|
supportsImages: true,
|
|
17493
17516
|
supportsThinking: true,
|
|
17494
17517
|
supportsVideo: true,
|
|
17495
|
-
tagDescription: "Limited time",
|
|
17496
|
-
tagTitle: "Fast",
|
|
17497
17518
|
thinkingBudget: -1
|
|
17498
17519
|
},
|
|
17499
17520
|
"gemini-3.6-flash-low": {
|
|
@@ -17551,8 +17572,8 @@ var models_default = {
|
|
|
17551
17572
|
},
|
|
17552
17573
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17553
17574
|
quotaInfo: {
|
|
17554
|
-
remainingFraction: 0.
|
|
17555
|
-
resetTime: "2026-10-
|
|
17575
|
+
remainingFraction: 0.9418832,
|
|
17576
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17556
17577
|
},
|
|
17557
17578
|
recommended: true,
|
|
17558
17579
|
supportedMimeTypes: {
|
|
@@ -17611,8 +17632,6 @@ var models_default = {
|
|
|
17611
17632
|
supportsImages: true,
|
|
17612
17633
|
supportsThinking: true,
|
|
17613
17634
|
supportsVideo: true,
|
|
17614
|
-
tagDescription: "Limited time",
|
|
17615
|
-
tagTitle: "Fast",
|
|
17616
17635
|
thinkingBudget: 1e3
|
|
17617
17636
|
},
|
|
17618
17637
|
"gemini-3.6-flash-medium": {
|
|
@@ -17670,8 +17689,8 @@ var models_default = {
|
|
|
17670
17689
|
},
|
|
17671
17690
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17672
17691
|
quotaInfo: {
|
|
17673
|
-
remainingFraction: 0.
|
|
17674
|
-
resetTime: "2026-10-
|
|
17692
|
+
remainingFraction: 0.9418832,
|
|
17693
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17675
17694
|
},
|
|
17676
17695
|
recommended: true,
|
|
17677
17696
|
supportedMimeTypes: {
|
|
@@ -17730,8 +17749,6 @@ var models_default = {
|
|
|
17730
17749
|
supportsImages: true,
|
|
17731
17750
|
supportsThinking: true,
|
|
17732
17751
|
supportsVideo: true,
|
|
17733
|
-
tagDescription: "Limited time",
|
|
17734
|
-
tagTitle: "Fast",
|
|
17735
17752
|
thinkingBudget: 4e3
|
|
17736
17753
|
},
|
|
17737
17754
|
"gemini-3.6-flash-tiered": {
|
|
@@ -17788,8 +17805,8 @@ var models_default = {
|
|
|
17788
17805
|
},
|
|
17789
17806
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17790
17807
|
quotaInfo: {
|
|
17791
|
-
remainingFraction: 0.
|
|
17792
|
-
resetTime: "2026-10-
|
|
17808
|
+
remainingFraction: 0.9418832,
|
|
17809
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17793
17810
|
},
|
|
17794
17811
|
recommended: true,
|
|
17795
17812
|
supportedMimeTypes: {
|
|
@@ -17899,8 +17916,8 @@ var models_default = {
|
|
|
17899
17916
|
},
|
|
17900
17917
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
17901
17918
|
quotaInfo: {
|
|
17902
|
-
remainingFraction: 0.
|
|
17903
|
-
resetTime: "2026-10-
|
|
17919
|
+
remainingFraction: 0.9418832,
|
|
17920
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
17904
17921
|
},
|
|
17905
17922
|
recommended: true,
|
|
17906
17923
|
supportedMimeTypes: {
|
|
@@ -17959,8 +17976,6 @@ var models_default = {
|
|
|
17959
17976
|
supportsImages: true,
|
|
17960
17977
|
supportsThinking: true,
|
|
17961
17978
|
supportsVideo: true,
|
|
17962
|
-
tagDescription: "Limited time",
|
|
17963
|
-
tagTitle: "Fast",
|
|
17964
17979
|
thinkingBudget: -1
|
|
17965
17980
|
},
|
|
17966
17981
|
"gemini-3.7-flash-low": {
|
|
@@ -18012,8 +18027,8 @@ var models_default = {
|
|
|
18012
18027
|
},
|
|
18013
18028
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18014
18029
|
quotaInfo: {
|
|
18015
|
-
remainingFraction: 0.
|
|
18016
|
-
resetTime: "2026-10-
|
|
18030
|
+
remainingFraction: 0.9418832,
|
|
18031
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18017
18032
|
},
|
|
18018
18033
|
recommended: true,
|
|
18019
18034
|
supportedMimeTypes: {
|
|
@@ -18072,8 +18087,6 @@ var models_default = {
|
|
|
18072
18087
|
supportsImages: true,
|
|
18073
18088
|
supportsThinking: true,
|
|
18074
18089
|
supportsVideo: true,
|
|
18075
|
-
tagDescription: "Limited time",
|
|
18076
|
-
tagTitle: "Fast",
|
|
18077
18090
|
thinkingBudget: 1e3
|
|
18078
18091
|
},
|
|
18079
18092
|
"gemini-3.7-flash-medium": {
|
|
@@ -18125,8 +18138,8 @@ var models_default = {
|
|
|
18125
18138
|
},
|
|
18126
18139
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18127
18140
|
quotaInfo: {
|
|
18128
|
-
remainingFraction: 0.
|
|
18129
|
-
resetTime: "2026-10-
|
|
18141
|
+
remainingFraction: 0.9418832,
|
|
18142
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18130
18143
|
},
|
|
18131
18144
|
recommended: true,
|
|
18132
18145
|
supportedMimeTypes: {
|
|
@@ -18185,8 +18198,6 @@ var models_default = {
|
|
|
18185
18198
|
supportsImages: true,
|
|
18186
18199
|
supportsThinking: true,
|
|
18187
18200
|
supportsVideo: true,
|
|
18188
|
-
tagDescription: "Limited time",
|
|
18189
|
-
tagTitle: "Fast",
|
|
18190
18201
|
thinkingBudget: 4e3
|
|
18191
18202
|
},
|
|
18192
18203
|
"gemini-3.7-flash-tiered": {
|
|
@@ -18237,8 +18248,8 @@ var models_default = {
|
|
|
18237
18248
|
},
|
|
18238
18249
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18239
18250
|
quotaInfo: {
|
|
18240
|
-
remainingFraction: 0.
|
|
18241
|
-
resetTime: "2026-10-
|
|
18251
|
+
remainingFraction: 0.9418832,
|
|
18252
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18242
18253
|
},
|
|
18243
18254
|
recommended: true,
|
|
18244
18255
|
supportedMimeTypes: {
|
|
@@ -18348,8 +18359,8 @@ var models_default = {
|
|
|
18348
18359
|
},
|
|
18349
18360
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18350
18361
|
quotaInfo: {
|
|
18351
|
-
remainingFraction: 0.
|
|
18352
|
-
resetTime: "2026-10-
|
|
18362
|
+
remainingFraction: 0.9418832,
|
|
18363
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18353
18364
|
},
|
|
18354
18365
|
recommended: true,
|
|
18355
18366
|
supportedMimeTypes: {
|
|
@@ -18408,8 +18419,6 @@ var models_default = {
|
|
|
18408
18419
|
supportsImages: true,
|
|
18409
18420
|
supportsThinking: true,
|
|
18410
18421
|
supportsVideo: true,
|
|
18411
|
-
tagDescription: "Limited time",
|
|
18412
|
-
tagTitle: "Fast",
|
|
18413
18422
|
thinkingBudget: -1
|
|
18414
18423
|
},
|
|
18415
18424
|
"gemini-3.8-flash-low": {
|
|
@@ -18461,8 +18470,8 @@ var models_default = {
|
|
|
18461
18470
|
},
|
|
18462
18471
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18463
18472
|
quotaInfo: {
|
|
18464
|
-
remainingFraction: 0.
|
|
18465
|
-
resetTime: "2026-10-
|
|
18473
|
+
remainingFraction: 0.9418832,
|
|
18474
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18466
18475
|
},
|
|
18467
18476
|
recommended: true,
|
|
18468
18477
|
supportedMimeTypes: {
|
|
@@ -18521,8 +18530,6 @@ var models_default = {
|
|
|
18521
18530
|
supportsImages: true,
|
|
18522
18531
|
supportsThinking: true,
|
|
18523
18532
|
supportsVideo: true,
|
|
18524
|
-
tagDescription: "Limited time",
|
|
18525
|
-
tagTitle: "Fast",
|
|
18526
18533
|
thinkingBudget: 1e3
|
|
18527
18534
|
},
|
|
18528
18535
|
"gemini-3.8-flash-medium": {
|
|
@@ -18574,8 +18581,8 @@ var models_default = {
|
|
|
18574
18581
|
},
|
|
18575
18582
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18576
18583
|
quotaInfo: {
|
|
18577
|
-
remainingFraction: 0.
|
|
18578
|
-
resetTime: "2026-10-
|
|
18584
|
+
remainingFraction: 0.9418832,
|
|
18585
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18579
18586
|
},
|
|
18580
18587
|
recommended: true,
|
|
18581
18588
|
supportedMimeTypes: {
|
|
@@ -18634,8 +18641,6 @@ var models_default = {
|
|
|
18634
18641
|
supportsImages: true,
|
|
18635
18642
|
supportsThinking: true,
|
|
18636
18643
|
supportsVideo: true,
|
|
18637
|
-
tagDescription: "Limited time",
|
|
18638
|
-
tagTitle: "Fast",
|
|
18639
18644
|
thinkingBudget: 4e3
|
|
18640
18645
|
},
|
|
18641
18646
|
"gemini-3.8-flash-tiered": {
|
|
@@ -18686,8 +18691,8 @@ var models_default = {
|
|
|
18686
18691
|
},
|
|
18687
18692
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18688
18693
|
quotaInfo: {
|
|
18689
|
-
remainingFraction: 0.
|
|
18690
|
-
resetTime: "2026-10-
|
|
18694
|
+
remainingFraction: 0.9418832,
|
|
18695
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18691
18696
|
},
|
|
18692
18697
|
recommended: true,
|
|
18693
18698
|
supportedMimeTypes: {
|
|
@@ -18776,8 +18781,8 @@ var models_default = {
|
|
|
18776
18781
|
},
|
|
18777
18782
|
modelProvider: "MODEL_PROVIDER_GOOGLE",
|
|
18778
18783
|
quotaInfo: {
|
|
18779
|
-
remainingFraction: 0.
|
|
18780
|
-
resetTime: "2026-10-
|
|
18784
|
+
remainingFraction: 0.9418832,
|
|
18785
|
+
resetTime: "2026-10-05T19:38:35Z"
|
|
18781
18786
|
},
|
|
18782
18787
|
recommended: true,
|
|
18783
18788
|
supportedMimeTypes: {
|
|
@@ -18854,7 +18859,7 @@ var models_default = {
|
|
|
18854
18859
|
modelProvider: "MODEL_PROVIDER_OPENAI",
|
|
18855
18860
|
quotaInfo: {
|
|
18856
18861
|
remainingFraction: 1,
|
|
18857
|
-
resetTime: "2026-10-
|
|
18862
|
+
resetTime: "2026-10-06T00:32:08Z"
|
|
18858
18863
|
},
|
|
18859
18864
|
recommended: true,
|
|
18860
18865
|
supportsThinking: true,
|
|
@@ -19656,6 +19661,34 @@ function getModelEnum(modelName) {
|
|
|
19656
19661
|
}
|
|
19657
19662
|
return "MODEL_PLACEHOLDER_M16";
|
|
19658
19663
|
}
|
|
19664
|
+
function isClaudeModel(model) {
|
|
19665
|
+
return model.toLowerCase().includes("claude");
|
|
19666
|
+
}
|
|
19667
|
+
function sanitizeClaudeThinkingParts(contents, model) {
|
|
19668
|
+
if (!isClaudeModel(model) || !Array.isArray(contents)) {
|
|
19669
|
+
return;
|
|
19670
|
+
}
|
|
19671
|
+
for (const turn of contents) {
|
|
19672
|
+
if (!turn || typeof turn !== "object") continue;
|
|
19673
|
+
if (turn.role !== "model" && turn.role !== "assistant") continue;
|
|
19674
|
+
if (!Array.isArray(turn.parts)) continue;
|
|
19675
|
+
const filteredParts = turn.parts.filter((part) => {
|
|
19676
|
+
if (!part || typeof part !== "object") return true;
|
|
19677
|
+
const isThinking = part.thought === true || part.type === "thinking" || typeof part.thinking === "string";
|
|
19678
|
+
if (!isThinking) {
|
|
19679
|
+
return true;
|
|
19680
|
+
}
|
|
19681
|
+
const sig = typeof part.signature === "string" ? part.signature : typeof part.thoughtSignature === "string" ? part.thoughtSignature : void 0;
|
|
19682
|
+
const isValidSig = typeof sig === "string" && sig.length > 0 && sig !== "skip_thought_signature_validator";
|
|
19683
|
+
return isValidSig;
|
|
19684
|
+
});
|
|
19685
|
+
if (filteredParts.length === 0) {
|
|
19686
|
+
turn.parts = [{ text: "" }];
|
|
19687
|
+
} else {
|
|
19688
|
+
turn.parts = filteredParts;
|
|
19689
|
+
}
|
|
19690
|
+
}
|
|
19691
|
+
}
|
|
19659
19692
|
function transformRequestBody(body, projectId, effectiveModel, requestedModel, thinkingConfigDefaults) {
|
|
19660
19693
|
const fallbackId = randomUUID3();
|
|
19661
19694
|
try {
|
|
@@ -19689,7 +19722,7 @@ function transformRequestBody(body, projectId, effectiveModel, requestedModel, t
|
|
|
19689
19722
|
last_step_index: "0",
|
|
19690
19723
|
model_enum: getModelEnum(effectiveModel),
|
|
19691
19724
|
trajectory_id: randomUUID3(),
|
|
19692
|
-
used_claude: "false",
|
|
19725
|
+
used_claude: isClaudeModel(effectiveModel) || isClaudeModel(requestedModel) ? "true" : "false",
|
|
19693
19726
|
used_claude_conservative: "false"
|
|
19694
19727
|
};
|
|
19695
19728
|
}
|
|
@@ -19717,6 +19750,7 @@ function transformRequestBody(body, projectId, effectiveModel, requestedModel, t
|
|
|
19717
19750
|
contents2 = ensureTrailingUserTurn(contents2);
|
|
19718
19751
|
const latestSig = getLatestSignature(sessionId2);
|
|
19719
19752
|
applyLatestSignature(contents2, latestSig);
|
|
19753
|
+
sanitizeClaudeThinkingParts(contents2, effectiveModel || requestedModel);
|
|
19720
19754
|
requestPayloadInside.contents = contents2;
|
|
19721
19755
|
}
|
|
19722
19756
|
return { body: JSON.stringify(wrappedBody2), userPromptId: userPromptId2, sessionId: sessionId2 };
|
|
@@ -19758,6 +19792,7 @@ function transformRequestBody(body, projectId, effectiveModel, requestedModel, t
|
|
|
19758
19792
|
contents = ensureTrailingUserTurn(contents);
|
|
19759
19793
|
const latestSig = getLatestSignature(sessionId);
|
|
19760
19794
|
applyLatestSignature(contents, latestSig);
|
|
19795
|
+
sanitizeClaudeThinkingParts(contents, effectiveModel || requestedModel);
|
|
19761
19796
|
requestPayload.contents = contents;
|
|
19762
19797
|
}
|
|
19763
19798
|
if ("model" in requestPayload) {
|
|
@@ -19769,7 +19804,7 @@ function transformRequestBody(body, projectId, effectiveModel, requestedModel, t
|
|
|
19769
19804
|
last_step_index: "0",
|
|
19770
19805
|
model_enum: getModelEnum(effectiveModel),
|
|
19771
19806
|
trajectory_id: randomUUID3(),
|
|
19772
|
-
used_claude: "false",
|
|
19807
|
+
used_claude: isClaudeModel(effectiveModel) || isClaudeModel(requestedModel) ? "true" : "false",
|
|
19773
19808
|
used_claude_conservative: "false"
|
|
19774
19809
|
};
|
|
19775
19810
|
}
|
|
@@ -19928,9 +19963,14 @@ function normalizeToolSchemaTypes(tools, toolMapper) {
|
|
|
19928
19963
|
fn.name = toolMapper ? toolMapper.toGemini(fn.name) : sanitizeToolName(fn.name);
|
|
19929
19964
|
}
|
|
19930
19965
|
if (fn) {
|
|
19966
|
+
if (!fn.parameters) {
|
|
19967
|
+
fn.parameters = fn.parameters_json_schema ?? fn.parametersJsonSchema;
|
|
19968
|
+
}
|
|
19931
19969
|
if (!fn.parameters) {
|
|
19932
19970
|
fn.parameters = { type: "OBJECT", properties: {} };
|
|
19933
19971
|
}
|
|
19972
|
+
delete fn.parameters_json_schema;
|
|
19973
|
+
delete fn.parametersJsonSchema;
|
|
19934
19974
|
sanitizeSchema(fn.parameters);
|
|
19935
19975
|
}
|
|
19936
19976
|
}
|
|
@@ -20355,22 +20395,81 @@ var ChatLoggerImpl = class {
|
|
|
20355
20395
|
}
|
|
20356
20396
|
};
|
|
20357
20397
|
|
|
20358
|
-
// src/plugin.ts
|
|
20359
|
-
|
|
20360
|
-
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20398
|
+
// src/plugin/headers.ts
|
|
20399
|
+
function getSafeHeader(headers, key) {
|
|
20400
|
+
if (!headers) {
|
|
20401
|
+
return void 0;
|
|
20402
|
+
}
|
|
20403
|
+
const targetKey = key.toLowerCase();
|
|
20404
|
+
if (typeof headers.get === "function") {
|
|
20405
|
+
try {
|
|
20406
|
+
return headers.get(targetKey) || void 0;
|
|
20407
|
+
} catch {
|
|
20408
|
+
}
|
|
20409
|
+
}
|
|
20410
|
+
if (Array.isArray(headers)) {
|
|
20411
|
+
const found = headers.find((item) => {
|
|
20412
|
+
if (Array.isArray(item) && typeof item[0] === "string") {
|
|
20413
|
+
return item[0].toLowerCase() === targetKey;
|
|
20414
|
+
}
|
|
20415
|
+
return false;
|
|
20416
|
+
});
|
|
20417
|
+
return found ? String(found[1]) : void 0;
|
|
20418
|
+
}
|
|
20419
|
+
if (typeof headers === "object") {
|
|
20420
|
+
const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
|
|
20421
|
+
return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
|
|
20422
|
+
}
|
|
20423
|
+
return void 0;
|
|
20424
|
+
}
|
|
20425
|
+
function setSafeHeaders(initHeaders, newHeaders) {
|
|
20426
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
20427
|
+
const headers = new globalThis.Headers(initHeaders ?? {});
|
|
20428
|
+
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20429
|
+
headers.set(k, v);
|
|
20430
|
+
}
|
|
20431
|
+
return headers;
|
|
20432
|
+
}
|
|
20433
|
+
if (Array.isArray(initHeaders)) {
|
|
20434
|
+
const nextHeaders2 = [...initHeaders];
|
|
20435
|
+
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20436
|
+
const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
|
|
20437
|
+
if (idx !== -1) {
|
|
20438
|
+
nextHeaders2[idx] = [k, v];
|
|
20439
|
+
} else {
|
|
20440
|
+
nextHeaders2.push([k, v]);
|
|
20441
|
+
}
|
|
20442
|
+
}
|
|
20443
|
+
return nextHeaders2;
|
|
20444
|
+
}
|
|
20445
|
+
const nextHeaders = {};
|
|
20446
|
+
if (initHeaders && typeof initHeaders === "object") {
|
|
20447
|
+
for (const [k, v] of Object.entries(initHeaders)) {
|
|
20448
|
+
nextHeaders[k] = String(v);
|
|
20449
|
+
}
|
|
20450
|
+
}
|
|
20451
|
+
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20452
|
+
const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
|
|
20453
|
+
if (existingKey) {
|
|
20454
|
+
nextHeaders[existingKey] = v;
|
|
20455
|
+
} else {
|
|
20456
|
+
nextHeaders[k] = v;
|
|
20457
|
+
}
|
|
20458
|
+
}
|
|
20459
|
+
return nextHeaders;
|
|
20460
|
+
}
|
|
20461
|
+
function toUrlString(value) {
|
|
20462
|
+
if (typeof value === "string") {
|
|
20463
|
+
return value;
|
|
20464
|
+
}
|
|
20465
|
+
const candidate = value.url;
|
|
20466
|
+
if (candidate) {
|
|
20467
|
+
return candidate;
|
|
20468
|
+
}
|
|
20469
|
+
return value.toString();
|
|
20470
|
+
}
|
|
20367
20471
|
|
|
20368
|
-
|
|
20369
|
-
Do not call other tools.
|
|
20370
|
-
`;
|
|
20371
|
-
var latestAgyAuthResolver;
|
|
20372
|
-
var latestAgyConfiguredProjectId;
|
|
20373
|
-
var latestAgyUserAgentModel;
|
|
20472
|
+
// src/plugin/tier.ts
|
|
20374
20473
|
var STATIC_MODELS_SIMPLE = {
|
|
20375
20474
|
"gemini-3.8-flash": {
|
|
20376
20475
|
name: "Gemini 3.8 Flash",
|
|
@@ -20468,6 +20567,39 @@ var TIER_MAPPING = {
|
|
|
20468
20567
|
high: "claude-sonnet-5-5-high"
|
|
20469
20568
|
}
|
|
20470
20569
|
};
|
|
20570
|
+
function resolveModelTier(baseModelId, headersOrInit) {
|
|
20571
|
+
const parts = baseModelId.split("@");
|
|
20572
|
+
const base = parts[0] || "";
|
|
20573
|
+
const suffixTier = parts[1]?.toLowerCase();
|
|
20574
|
+
const mapping = TIER_MAPPING[base];
|
|
20575
|
+
if (!mapping) {
|
|
20576
|
+
return baseModelId;
|
|
20577
|
+
}
|
|
20578
|
+
const rawHeaders = headersOrInit && typeof headersOrInit === "object" && "headers" in headersOrInit ? headersOrInit.headers : headersOrInit;
|
|
20579
|
+
const headerTier = getSafeHeader(rawHeaders, "x-agy-tier")?.toLowerCase() || null;
|
|
20580
|
+
const requestedTier = headerTier || suffixTier;
|
|
20581
|
+
if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
|
|
20582
|
+
return mapping[requestedTier] || baseModelId;
|
|
20583
|
+
}
|
|
20584
|
+
return mapping["medium"] ?? mapping["high"] ?? baseModelId;
|
|
20585
|
+
}
|
|
20586
|
+
|
|
20587
|
+
// src/plugin.ts
|
|
20588
|
+
var AGY_QUOTA_COMMAND = "agyquota";
|
|
20589
|
+
var AGY_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
|
|
20590
|
+
|
|
20591
|
+
Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
|
|
20592
|
+
Do not call other tools.
|
|
20593
|
+
`;
|
|
20594
|
+
var AGY_QUOTA_SUMMARY_COMMAND = "agyquotasummary";
|
|
20595
|
+
var AGY_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
|
|
20596
|
+
|
|
20597
|
+
Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
|
|
20598
|
+
Do not call other tools.
|
|
20599
|
+
`;
|
|
20600
|
+
var latestAgyAuthResolver;
|
|
20601
|
+
var latestAgyConfiguredProjectId;
|
|
20602
|
+
var latestAgyUserAgentModel;
|
|
20471
20603
|
var buildModelFromSimple = (modelId, simple) => {
|
|
20472
20604
|
const isClaude = modelId.startsWith("claude-");
|
|
20473
20605
|
const isGpt = modelId.startsWith("gpt-");
|
|
@@ -20561,83 +20693,6 @@ var STATIC_MODELS = {};
|
|
|
20561
20693
|
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
20562
20694
|
STATIC_MODELS[modelId] = buildModelFromSimple(modelId, simple);
|
|
20563
20695
|
}
|
|
20564
|
-
function getSafeHeader(headers, key) {
|
|
20565
|
-
if (!headers) {
|
|
20566
|
-
return void 0;
|
|
20567
|
-
}
|
|
20568
|
-
const targetKey = key.toLowerCase();
|
|
20569
|
-
if (typeof headers.get === "function") {
|
|
20570
|
-
try {
|
|
20571
|
-
return headers.get(targetKey) || void 0;
|
|
20572
|
-
} catch {
|
|
20573
|
-
}
|
|
20574
|
-
}
|
|
20575
|
-
if (Array.isArray(headers)) {
|
|
20576
|
-
const found = headers.find((item) => {
|
|
20577
|
-
if (Array.isArray(item) && typeof item[0] === "string") {
|
|
20578
|
-
return item[0].toLowerCase() === targetKey;
|
|
20579
|
-
}
|
|
20580
|
-
return false;
|
|
20581
|
-
});
|
|
20582
|
-
return found ? String(found[1]) : void 0;
|
|
20583
|
-
}
|
|
20584
|
-
if (typeof headers === "object") {
|
|
20585
|
-
const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
|
|
20586
|
-
return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
|
|
20587
|
-
}
|
|
20588
|
-
return void 0;
|
|
20589
|
-
}
|
|
20590
|
-
function setSafeHeaders(initHeaders, newHeaders) {
|
|
20591
|
-
if (typeof globalThis.Headers !== "undefined") {
|
|
20592
|
-
const headers = new globalThis.Headers(initHeaders ?? {});
|
|
20593
|
-
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20594
|
-
headers.set(k, v);
|
|
20595
|
-
}
|
|
20596
|
-
return headers;
|
|
20597
|
-
}
|
|
20598
|
-
if (Array.isArray(initHeaders)) {
|
|
20599
|
-
const nextHeaders2 = [...initHeaders];
|
|
20600
|
-
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20601
|
-
const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
|
|
20602
|
-
if (idx !== -1) {
|
|
20603
|
-
nextHeaders2[idx] = [k, v];
|
|
20604
|
-
} else {
|
|
20605
|
-
nextHeaders2.push([k, v]);
|
|
20606
|
-
}
|
|
20607
|
-
}
|
|
20608
|
-
return nextHeaders2;
|
|
20609
|
-
}
|
|
20610
|
-
const nextHeaders = {};
|
|
20611
|
-
if (initHeaders && typeof initHeaders === "object") {
|
|
20612
|
-
for (const [k, v] of Object.entries(initHeaders)) {
|
|
20613
|
-
nextHeaders[k] = String(v);
|
|
20614
|
-
}
|
|
20615
|
-
}
|
|
20616
|
-
for (const [k, v] of Object.entries(newHeaders)) {
|
|
20617
|
-
const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
|
|
20618
|
-
if (existingKey) {
|
|
20619
|
-
nextHeaders[existingKey] = v;
|
|
20620
|
-
} else {
|
|
20621
|
-
nextHeaders[k] = v;
|
|
20622
|
-
}
|
|
20623
|
-
}
|
|
20624
|
-
return nextHeaders;
|
|
20625
|
-
}
|
|
20626
|
-
function resolveModelTier(baseModelId, init) {
|
|
20627
|
-
const parts = baseModelId.split("@");
|
|
20628
|
-
const base = parts[0] || "";
|
|
20629
|
-
const suffixTier = parts[1]?.toLowerCase();
|
|
20630
|
-
const mapping = TIER_MAPPING[base];
|
|
20631
|
-
if (!mapping) {
|
|
20632
|
-
return baseModelId;
|
|
20633
|
-
}
|
|
20634
|
-
const headerTier = getSafeHeader(init?.headers, "x-agy-tier")?.toLowerCase() || null;
|
|
20635
|
-
const requestedTier = headerTier || suffixTier;
|
|
20636
|
-
if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
|
|
20637
|
-
return mapping[requestedTier] || baseModelId;
|
|
20638
|
-
}
|
|
20639
|
-
return mapping["medium"] ?? mapping["high"];
|
|
20640
|
-
}
|
|
20641
20696
|
var AgyCLIOAuthPlugin = async ({ client }) => {
|
|
20642
20697
|
let latestConfig;
|
|
20643
20698
|
updateStaticModelsWithPricing(STATIC_MODELS);
|
|
@@ -20965,25 +21020,782 @@ async function ensureProjectContextOrThrow(authRecord, client, configuredProject
|
|
|
20965
21020
|
throw error45;
|
|
20966
21021
|
}
|
|
20967
21022
|
}
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
21023
|
+
|
|
21024
|
+
// src/plugin/types.ts
|
|
21025
|
+
function defineOpenCodeV2Plugin(def) {
|
|
21026
|
+
return def;
|
|
21027
|
+
}
|
|
21028
|
+
|
|
21029
|
+
// src/plugin/v2-storage.ts
|
|
21030
|
+
import { closeSync, existsSync as existsSync6, mkdirSync as mkdirSync5, openSync, readFileSync as readFileSync5, renameSync as renameSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
21031
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
21032
|
+
import { homedir as homedir4 } from "os";
|
|
21033
|
+
import { join as join6 } from "path";
|
|
21034
|
+
var storedAuthOverrideForTesting = void 0;
|
|
21035
|
+
function loadStoredAuthFromJson() {
|
|
21036
|
+
if (storedAuthOverrideForTesting !== void 0) {
|
|
21037
|
+
return storedAuthOverrideForTesting;
|
|
21038
|
+
}
|
|
21039
|
+
const authPath = join6(homedir4(), ".local", "share", "opencode", "auth.json");
|
|
21040
|
+
try {
|
|
21041
|
+
if (existsSync6(authPath)) {
|
|
21042
|
+
const content = readFileSync5(authPath, "utf8");
|
|
21043
|
+
const data = JSON.parse(content);
|
|
21044
|
+
return data?.[AGY_PROVIDER_ID];
|
|
21045
|
+
}
|
|
21046
|
+
} catch {
|
|
20971
21047
|
}
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
21048
|
+
return void 0;
|
|
21049
|
+
}
|
|
21050
|
+
function saveStoredAuthToJson(authRecord) {
|
|
21051
|
+
if (process.env.NODE_ENV === "test" || process.env.VITEST || storedAuthOverrideForTesting !== void 0) {
|
|
21052
|
+
return;
|
|
20975
21053
|
}
|
|
20976
|
-
|
|
21054
|
+
const dirPath = join6(homedir4(), ".local", "share", "opencode");
|
|
21055
|
+
if (!existsSync6(dirPath)) {
|
|
21056
|
+
mkdirSync5(dirPath, { recursive: true });
|
|
21057
|
+
}
|
|
21058
|
+
const authPath = join6(dirPath, "auth.json");
|
|
21059
|
+
const data = existsSync6(authPath) ? JSON.parse(readFileSync5(authPath, "utf8")) : {};
|
|
21060
|
+
data[AGY_PROVIDER_ID] = {
|
|
21061
|
+
type: "oauth",
|
|
21062
|
+
refresh: authRecord.refresh,
|
|
21063
|
+
access: authRecord.access,
|
|
21064
|
+
expires: authRecord.expires
|
|
21065
|
+
};
|
|
21066
|
+
const tempPath = `${authPath}.${process.pid}.${randomUUID4()}.tmp`;
|
|
21067
|
+
let tempFileDescriptor;
|
|
21068
|
+
let ownsTempFile = false;
|
|
21069
|
+
try {
|
|
21070
|
+
tempFileDescriptor = openSync(tempPath, "wx", 384);
|
|
21071
|
+
ownsTempFile = true;
|
|
21072
|
+
writeFileSync5(tempFileDescriptor, JSON.stringify(data, null, 2), {
|
|
21073
|
+
encoding: "utf8"
|
|
21074
|
+
});
|
|
21075
|
+
closeSync(tempFileDescriptor);
|
|
21076
|
+
tempFileDescriptor = void 0;
|
|
21077
|
+
renameSync4(tempPath, authPath);
|
|
21078
|
+
} catch (error45) {
|
|
21079
|
+
if (tempFileDescriptor !== void 0) {
|
|
21080
|
+
try {
|
|
21081
|
+
closeSync(tempFileDescriptor);
|
|
21082
|
+
} catch {
|
|
21083
|
+
}
|
|
21084
|
+
}
|
|
21085
|
+
if (ownsTempFile) {
|
|
21086
|
+
try {
|
|
21087
|
+
unlinkSync4(tempPath);
|
|
21088
|
+
} catch {
|
|
21089
|
+
}
|
|
21090
|
+
}
|
|
21091
|
+
throw error45;
|
|
21092
|
+
}
|
|
21093
|
+
}
|
|
21094
|
+
|
|
21095
|
+
// src/plugin/v2-fetch.ts
|
|
21096
|
+
function createV2FetchInterceptor(getAuthSnapshot) {
|
|
21097
|
+
return async function agyV2Fetch(input, init) {
|
|
21098
|
+
const isGL = isGenerativeLanguageRequest(input);
|
|
21099
|
+
const isInternal = toUrlString(input).includes("cloudcode-pa.googleapis.com");
|
|
21100
|
+
if (!isGL && !isInternal) {
|
|
21101
|
+
return (globalThis.fetch || fetch)(input, init);
|
|
21102
|
+
}
|
|
21103
|
+
let rawAuth = getAuthSnapshot ? await getAuthSnapshot() : void 0;
|
|
21104
|
+
if (!rawAuth) {
|
|
21105
|
+
rawAuth = loadStoredAuthFromJson();
|
|
21106
|
+
}
|
|
21107
|
+
if (!rawAuth || !isOAuthAuth(rawAuth)) {
|
|
21108
|
+
return (globalThis.fetch || fetch)(input, init);
|
|
21109
|
+
}
|
|
21110
|
+
let authRecord = resolveCachedAuth(rawAuth);
|
|
21111
|
+
if (accessTokenExpired(authRecord)) {
|
|
21112
|
+
const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
|
|
21113
|
+
} } });
|
|
21114
|
+
if (refreshed) {
|
|
21115
|
+
authRecord = refreshed;
|
|
21116
|
+
}
|
|
21117
|
+
}
|
|
21118
|
+
if (!authRecord.access) {
|
|
21119
|
+
return (globalThis.fetch || fetch)(input, init);
|
|
21120
|
+
}
|
|
21121
|
+
if (isInternal) {
|
|
21122
|
+
const hasAuth = getSafeHeader(init?.headers, "Authorization") !== void 0;
|
|
21123
|
+
if (hasAuth) {
|
|
21124
|
+
return (globalThis.fetch || fetch)(input, init);
|
|
21125
|
+
}
|
|
21126
|
+
const userAgent = buildAgyCliUserAgent();
|
|
21127
|
+
const headers = setSafeHeaders(init?.headers, {
|
|
21128
|
+
Authorization: `Bearer ${authRecord.access}`,
|
|
21129
|
+
"User-Agent": userAgent
|
|
21130
|
+
});
|
|
21131
|
+
return (globalThis.fetch || fetch)(input, {
|
|
21132
|
+
...init,
|
|
21133
|
+
headers
|
|
21134
|
+
});
|
|
21135
|
+
}
|
|
21136
|
+
const requestTarget = parseGenerativeLanguageRequest(input);
|
|
21137
|
+
const requestUserAgentModel = requestTarget?.effectiveModel;
|
|
21138
|
+
let projectContext;
|
|
21139
|
+
try {
|
|
21140
|
+
projectContext = await ensureProjectContext(
|
|
21141
|
+
authRecord,
|
|
21142
|
+
{ auth: { set: async () => {
|
|
21143
|
+
} } },
|
|
21144
|
+
void 0,
|
|
21145
|
+
requestUserAgentModel
|
|
21146
|
+
);
|
|
21147
|
+
} catch {
|
|
21148
|
+
projectContext = {
|
|
21149
|
+
effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
|
|
21150
|
+
auth: authRecord
|
|
21151
|
+
};
|
|
21152
|
+
}
|
|
21153
|
+
const originalRequestedModel = parseGenerativeLanguageRequest(input)?.effectiveModel;
|
|
21154
|
+
let modifiedInput = input;
|
|
21155
|
+
if (isGL && originalRequestedModel) {
|
|
21156
|
+
const originalBase = originalRequestedModel.replace("google-agy/", "");
|
|
21157
|
+
const resolvedBase = resolveModelTier(originalBase, init);
|
|
21158
|
+
if (originalBase !== resolvedBase) {
|
|
21159
|
+
if (typeof modifiedInput === "string") {
|
|
21160
|
+
modifiedInput = modifiedInput.replace(`models/${originalBase}`, `models/${resolvedBase}`);
|
|
21161
|
+
} else if (typeof Request !== "undefined" && modifiedInput instanceof Request) {
|
|
21162
|
+
const newUrl = modifiedInput.url.replace(`models/${originalBase}`, `models/${resolvedBase}`);
|
|
21163
|
+
modifiedInput = new Request(newUrl, modifiedInput);
|
|
21164
|
+
}
|
|
21165
|
+
}
|
|
21166
|
+
}
|
|
21167
|
+
const transformed = prepareAgyRequest(
|
|
21168
|
+
modifiedInput,
|
|
21169
|
+
init,
|
|
21170
|
+
authRecord.access,
|
|
21171
|
+
projectContext.effectiveProjectId,
|
|
21172
|
+
void 0
|
|
21173
|
+
);
|
|
21174
|
+
const chatLogger = createChatLogger();
|
|
21175
|
+
if (chatLogger) {
|
|
21176
|
+
chatLogger.logRequest(
|
|
21177
|
+
toUrlString(transformed.request),
|
|
21178
|
+
transformed.init.method || "GET",
|
|
21179
|
+
transformed.init.headers,
|
|
21180
|
+
transformed.init.body
|
|
21181
|
+
);
|
|
21182
|
+
}
|
|
21183
|
+
const response = await fetchWithRetry(transformed.request, transformed.init);
|
|
21184
|
+
return transformAgyResponse(
|
|
21185
|
+
response,
|
|
21186
|
+
transformed.streaming,
|
|
21187
|
+
null,
|
|
21188
|
+
transformed.requestedModel,
|
|
21189
|
+
transformed.sessionId,
|
|
21190
|
+
chatLogger
|
|
21191
|
+
);
|
|
21192
|
+
};
|
|
21193
|
+
}
|
|
21194
|
+
|
|
21195
|
+
// src/plugin/v2-session.ts
|
|
21196
|
+
function createV2HttpRequestHook(state = {}) {
|
|
21197
|
+
return async (event) => {
|
|
21198
|
+
if (!event) return;
|
|
21199
|
+
const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
|
|
21200
|
+
const isGL = isGenerativeLanguageRequest(rawUrl);
|
|
21201
|
+
const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
|
|
21202
|
+
if (!isGL && !isInternal) {
|
|
21203
|
+
return;
|
|
21204
|
+
}
|
|
21205
|
+
event.headers = event.headers || {};
|
|
21206
|
+
let modelName;
|
|
21207
|
+
let rawAuth = event.auth;
|
|
21208
|
+
if (rawAuth && !rawAuth.type) {
|
|
21209
|
+
const tokenVal = rawAuth.access || rawAuth.token;
|
|
21210
|
+
if (tokenVal || rawAuth.refresh) {
|
|
21211
|
+
rawAuth = { type: "oauth", access: tokenVal, ...rawAuth };
|
|
21212
|
+
}
|
|
21213
|
+
}
|
|
21214
|
+
if (!rawAuth || !isOAuthAuth(rawAuth)) {
|
|
21215
|
+
rawAuth = loadStoredAuthFromJson();
|
|
21216
|
+
}
|
|
21217
|
+
let authRecord = rawAuth && isOAuthAuth(rawAuth) ? resolveCachedAuth(rawAuth) : void 0;
|
|
21218
|
+
if (authRecord && accessTokenExpired(authRecord)) {
|
|
21219
|
+
const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
|
|
21220
|
+
} } });
|
|
21221
|
+
if (refreshed) {
|
|
21222
|
+
authRecord = refreshed;
|
|
21223
|
+
try {
|
|
21224
|
+
saveStoredAuthToJson(refreshed);
|
|
21225
|
+
} catch {
|
|
21226
|
+
console.warn("[Agy Auth] Refreshed credentials could not be persisted; the current request will continue.");
|
|
21227
|
+
}
|
|
21228
|
+
}
|
|
21229
|
+
}
|
|
21230
|
+
if (isGL) {
|
|
21231
|
+
const parsed = parseGenerativeLanguageRequest(rawUrl);
|
|
21232
|
+
modelName = parsed?.effectiveModel;
|
|
21233
|
+
if (modelName) {
|
|
21234
|
+
state.lastInterceptedModel = modelName;
|
|
21235
|
+
}
|
|
21236
|
+
if (typeof event.headers.delete === "function") {
|
|
21237
|
+
event.headers.delete("x-goog-api-key");
|
|
21238
|
+
event.headers.delete("api-key");
|
|
21239
|
+
} else {
|
|
21240
|
+
for (const key of Object.keys(event.headers)) {
|
|
21241
|
+
const lower = key.toLowerCase();
|
|
21242
|
+
if (lower === "x-goog-api-key" || lower === "api-key") {
|
|
21243
|
+
delete event.headers[key];
|
|
21244
|
+
}
|
|
21245
|
+
}
|
|
21246
|
+
}
|
|
21247
|
+
if (event.request?.headers) {
|
|
21248
|
+
if (typeof event.request.headers.delete === "function") {
|
|
21249
|
+
event.request.headers.delete("x-goog-api-key");
|
|
21250
|
+
event.request.headers.delete("api-key");
|
|
21251
|
+
} else {
|
|
21252
|
+
for (const key of Object.keys(event.request.headers)) {
|
|
21253
|
+
const lower = key.toLowerCase();
|
|
21254
|
+
if (lower === "x-goog-api-key" || lower === "api-key") {
|
|
21255
|
+
delete event.request.headers[key];
|
|
21256
|
+
}
|
|
21257
|
+
}
|
|
21258
|
+
}
|
|
21259
|
+
}
|
|
21260
|
+
let cleanUrl = rawUrl;
|
|
21261
|
+
try {
|
|
21262
|
+
const parsedUrl = new URL(rawUrl);
|
|
21263
|
+
let urlChanged = false;
|
|
21264
|
+
for (const param of ["key", "x-goog-api-key", "api-key"]) {
|
|
21265
|
+
if (parsedUrl.searchParams.has(param)) {
|
|
21266
|
+
parsedUrl.searchParams.delete(param);
|
|
21267
|
+
urlChanged = true;
|
|
21268
|
+
}
|
|
21269
|
+
}
|
|
21270
|
+
if (urlChanged) {
|
|
21271
|
+
cleanUrl = parsedUrl.toString();
|
|
21272
|
+
}
|
|
21273
|
+
} catch {
|
|
21274
|
+
}
|
|
21275
|
+
if (authRecord && authRecord.access) {
|
|
21276
|
+
let projectContext;
|
|
21277
|
+
try {
|
|
21278
|
+
projectContext = await ensureProjectContext(
|
|
21279
|
+
authRecord,
|
|
21280
|
+
{ auth: { set: async () => {
|
|
21281
|
+
} } },
|
|
21282
|
+
void 0,
|
|
21283
|
+
modelName
|
|
21284
|
+
);
|
|
21285
|
+
} catch {
|
|
21286
|
+
projectContext = {
|
|
21287
|
+
effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
|
|
21288
|
+
auth: authRecord
|
|
21289
|
+
};
|
|
21290
|
+
}
|
|
21291
|
+
const originalRequestedModel = modelName;
|
|
21292
|
+
let modifiedUrl = cleanUrl;
|
|
21293
|
+
if (originalRequestedModel) {
|
|
21294
|
+
const originalBase = originalRequestedModel.replace("google-agy/", "");
|
|
21295
|
+
const initHeaders = event.headers instanceof Headers ? event.headers : event.request?.headers;
|
|
21296
|
+
const resolvedBase = resolveModelTier(originalBase, { headers: initHeaders });
|
|
21297
|
+
if (originalBase !== resolvedBase) {
|
|
21298
|
+
modifiedUrl = modifiedUrl.replace(`models/${originalBase}`, `models/${resolvedBase}`);
|
|
21299
|
+
}
|
|
21300
|
+
}
|
|
21301
|
+
let bodyPayload = event.body;
|
|
21302
|
+
if (bodyPayload === void 0 && event.request) {
|
|
21303
|
+
if (typeof event.request.clone === "function") {
|
|
21304
|
+
try {
|
|
21305
|
+
bodyPayload = await event.request.clone().text();
|
|
21306
|
+
} catch {
|
|
21307
|
+
}
|
|
21308
|
+
} else if (event.request.body !== void 0) {
|
|
21309
|
+
bodyPayload = event.request.body;
|
|
21310
|
+
}
|
|
21311
|
+
}
|
|
21312
|
+
let preExistingUserAgent;
|
|
21313
|
+
if (typeof event.headers?.get === "function") {
|
|
21314
|
+
preExistingUserAgent = event.headers.get("user-agent") || event.headers.get("User-Agent") || void 0;
|
|
21315
|
+
} else if (event.headers && typeof event.headers === "object") {
|
|
21316
|
+
preExistingUserAgent = event.headers["user-agent"] || event.headers["User-Agent"] || void 0;
|
|
21317
|
+
}
|
|
21318
|
+
if (!preExistingUserAgent && typeof event.request?.headers?.get === "function") {
|
|
21319
|
+
preExistingUserAgent = event.request.headers.get("user-agent") || event.request.headers.get("User-Agent") || void 0;
|
|
21320
|
+
} else if (!preExistingUserAgent && event.request?.headers && typeof event.request.headers === "object") {
|
|
21321
|
+
preExistingUserAgent = event.request.headers["user-agent"] || event.request.headers["User-Agent"] || void 0;
|
|
21322
|
+
}
|
|
21323
|
+
const method = event.method || event.request?.method || "POST";
|
|
21324
|
+
const requestHeaders = event.headers || event.request?.headers;
|
|
21325
|
+
const transformed = prepareAgyRequest(
|
|
21326
|
+
modifiedUrl,
|
|
21327
|
+
{
|
|
21328
|
+
method,
|
|
21329
|
+
headers: requestHeaders,
|
|
21330
|
+
body: bodyPayload
|
|
21331
|
+
},
|
|
21332
|
+
authRecord.access,
|
|
21333
|
+
projectContext.effectiveProjectId
|
|
21334
|
+
);
|
|
21335
|
+
const targetUrl = toUrlString(transformed.request);
|
|
21336
|
+
if (typeof event.url === "string") {
|
|
21337
|
+
event.url = targetUrl;
|
|
21338
|
+
}
|
|
21339
|
+
if (event.request && typeof event.request === "object") {
|
|
21340
|
+
if (typeof Request !== "undefined" && event.request instanceof Request) {
|
|
21341
|
+
event.request = new Request(targetUrl, {
|
|
21342
|
+
method: transformed.init.method,
|
|
21343
|
+
headers: transformed.init.headers,
|
|
21344
|
+
body: transformed.init.body
|
|
21345
|
+
});
|
|
21346
|
+
} else if (typeof event.request.url === "string") {
|
|
21347
|
+
try {
|
|
21348
|
+
event.request.url = targetUrl;
|
|
21349
|
+
} catch {
|
|
21350
|
+
}
|
|
21351
|
+
}
|
|
21352
|
+
}
|
|
21353
|
+
const headerEntries = transformed.init.headers instanceof Headers ? Array.from(transformed.init.headers.entries()) : Object.entries(transformed.init.headers || {});
|
|
21354
|
+
for (const [k, v] of headerEntries) {
|
|
21355
|
+
const lowerK = k.toLowerCase();
|
|
21356
|
+
if (lowerK === "user-agent") {
|
|
21357
|
+
if (preExistingUserAgent) {
|
|
21358
|
+
continue;
|
|
21359
|
+
}
|
|
21360
|
+
if (typeof event.headers?.set === "function") {
|
|
21361
|
+
event.headers.set("User-Agent", v);
|
|
21362
|
+
} else if (event.headers) {
|
|
21363
|
+
event.headers["User-Agent"] = v;
|
|
21364
|
+
}
|
|
21365
|
+
if (event.request?.headers && typeof event.request.headers.set === "function") {
|
|
21366
|
+
event.request.headers.set("User-Agent", v);
|
|
21367
|
+
} else if (event.request?.headers && typeof event.request.headers === "object") {
|
|
21368
|
+
event.request.headers["User-Agent"] = v;
|
|
21369
|
+
}
|
|
21370
|
+
continue;
|
|
21371
|
+
}
|
|
21372
|
+
if (typeof event.headers?.set === "function") {
|
|
21373
|
+
event.headers.set(k, v);
|
|
21374
|
+
} else if (event.headers) {
|
|
21375
|
+
event.headers[k] = v;
|
|
21376
|
+
}
|
|
21377
|
+
if (event.request?.headers && typeof event.request.headers.set === "function") {
|
|
21378
|
+
event.request.headers.set(k, v);
|
|
21379
|
+
} else if (event.request?.headers && typeof event.request.headers === "object") {
|
|
21380
|
+
event.request.headers[k] = v;
|
|
21381
|
+
}
|
|
21382
|
+
}
|
|
21383
|
+
if (transformed.init.body !== void 0) {
|
|
21384
|
+
event.body = transformed.init.body;
|
|
21385
|
+
if (event.request && typeof event.request === "object" && !(event.request instanceof Request)) {
|
|
21386
|
+
event.request.body = transformed.init.body;
|
|
21387
|
+
}
|
|
21388
|
+
}
|
|
21389
|
+
} else {
|
|
21390
|
+
if (typeof event.url === "string") {
|
|
21391
|
+
event.url = cleanUrl;
|
|
21392
|
+
}
|
|
21393
|
+
if (event.request && typeof event.request === "object") {
|
|
21394
|
+
if (typeof Request !== "undefined" && event.request instanceof Request) {
|
|
21395
|
+
event.request = new Request(cleanUrl, event.request);
|
|
21396
|
+
} else if (typeof event.request.url === "string") {
|
|
21397
|
+
try {
|
|
21398
|
+
event.request.url = cleanUrl;
|
|
21399
|
+
} catch {
|
|
21400
|
+
}
|
|
21401
|
+
}
|
|
21402
|
+
}
|
|
21403
|
+
}
|
|
21404
|
+
}
|
|
21405
|
+
if (authRecord && authRecord.access) {
|
|
21406
|
+
if (typeof event.headers?.set === "function") {
|
|
21407
|
+
event.headers.set("Authorization", `Bearer ${authRecord.access}`);
|
|
21408
|
+
} else if (event.headers) {
|
|
21409
|
+
event.headers["Authorization"] = `Bearer ${authRecord.access}`;
|
|
21410
|
+
}
|
|
21411
|
+
if (event.request?.headers && typeof event.request.headers.set === "function") {
|
|
21412
|
+
event.request.headers.set("Authorization", `Bearer ${authRecord.access}`);
|
|
21413
|
+
} else if (event.request?.headers && typeof event.request.headers === "object") {
|
|
21414
|
+
event.request.headers["Authorization"] = `Bearer ${authRecord.access}`;
|
|
21415
|
+
}
|
|
21416
|
+
}
|
|
21417
|
+
const userAgent = buildAgyCliUserAgent(modelName);
|
|
21418
|
+
if (typeof event.headers?.set === "function") {
|
|
21419
|
+
if (!event.headers.get("User-Agent") && !event.headers.get("user-agent")) {
|
|
21420
|
+
event.headers.set("User-Agent", userAgent);
|
|
21421
|
+
}
|
|
21422
|
+
} else if (event.headers) {
|
|
21423
|
+
if (!event.headers["User-Agent"] && !event.headers["user-agent"]) {
|
|
21424
|
+
event.headers["User-Agent"] = userAgent;
|
|
21425
|
+
}
|
|
21426
|
+
}
|
|
21427
|
+
if (event.request?.headers && typeof event.request.headers.set === "function") {
|
|
21428
|
+
if (!event.request.headers.get("User-Agent") && !event.request.headers.get("user-agent")) {
|
|
21429
|
+
event.request.headers.set("User-Agent", userAgent);
|
|
21430
|
+
}
|
|
21431
|
+
} else if (event.request?.headers && typeof event.request.headers === "object") {
|
|
21432
|
+
if (!event.request.headers["User-Agent"] && !event.request.headers["user-agent"]) {
|
|
21433
|
+
event.request.headers["User-Agent"] = userAgent;
|
|
21434
|
+
}
|
|
21435
|
+
}
|
|
21436
|
+
};
|
|
20977
21437
|
}
|
|
21438
|
+
function createV2HttpResponseHook(state = {}) {
|
|
21439
|
+
return async (event) => {
|
|
21440
|
+
if (!event || !event.response) return;
|
|
21441
|
+
const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
|
|
21442
|
+
const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
|
|
21443
|
+
if (isInternal && event.response instanceof Response) {
|
|
21444
|
+
const isStreaming = rawUrl.includes(":streamGenerateCode") || event.response.headers.get("content-type")?.includes("text/event-stream");
|
|
21445
|
+
const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel || state.lastInterceptedModel;
|
|
21446
|
+
const transformed = await transformAgyResponse(
|
|
21447
|
+
event.response,
|
|
21448
|
+
!!isStreaming,
|
|
21449
|
+
null,
|
|
21450
|
+
parsedModel,
|
|
21451
|
+
void 0,
|
|
21452
|
+
void 0
|
|
21453
|
+
);
|
|
21454
|
+
event.response = transformed;
|
|
21455
|
+
}
|
|
21456
|
+
};
|
|
21457
|
+
}
|
|
21458
|
+
function createV2RetryHook() {
|
|
21459
|
+
return async (event) => {
|
|
21460
|
+
if (!event) return;
|
|
21461
|
+
const response = event.response;
|
|
21462
|
+
if (response instanceof Response) {
|
|
21463
|
+
if (response.status === 429 || response.status === 503) {
|
|
21464
|
+
const quota = await classifyQuotaResponse(response);
|
|
21465
|
+
if (quota?.retryDelayMs) {
|
|
21466
|
+
event.retryDelayMs = quota.retryDelayMs;
|
|
21467
|
+
} else {
|
|
21468
|
+
event.retryDelayMs = await resolveRetryDelayMs(response, event.attempt || 1);
|
|
21469
|
+
}
|
|
21470
|
+
}
|
|
21471
|
+
} else if (event.details && Array.isArray(event.details)) {
|
|
21472
|
+
const retryInfo = event.details.find(
|
|
21473
|
+
(d) => d && d["@type"] === "type.googleapis.com/google.rpc.RetryInfo"
|
|
21474
|
+
);
|
|
21475
|
+
if (retryInfo?.retryDelay) {
|
|
21476
|
+
const delayMs = retryInternals.parseRetryDelayValue(retryInfo.retryDelay);
|
|
21477
|
+
if (delayMs !== null) {
|
|
21478
|
+
event.retryDelayMs = delayMs;
|
|
21479
|
+
}
|
|
21480
|
+
}
|
|
21481
|
+
}
|
|
21482
|
+
};
|
|
21483
|
+
}
|
|
21484
|
+
function registerV2SessionHooks(ctx) {
|
|
21485
|
+
const state = {};
|
|
21486
|
+
ctx.session.hook("http.request", createV2HttpRequestHook(state), { providerID: AGY_PROVIDER_ID });
|
|
21487
|
+
ctx.session.hook("http.response", createV2HttpResponseHook(state), { providerID: AGY_PROVIDER_ID });
|
|
21488
|
+
ctx.session.hook("retry", createV2RetryHook(), { providerID: AGY_PROVIDER_ID });
|
|
21489
|
+
}
|
|
21490
|
+
|
|
21491
|
+
// src/plugin/v2.ts
|
|
21492
|
+
async function setupOpenCodeV2(ctx) {
|
|
21493
|
+
const resolveVariants = (modelId) => {
|
|
21494
|
+
const mapping = TIER_MAPPING[modelId];
|
|
21495
|
+
if (!mapping) return void 0;
|
|
21496
|
+
const variants = [];
|
|
21497
|
+
if (mapping.minimal !== void 0) variants.push({ id: "minimal" });
|
|
21498
|
+
if (mapping.low !== void 0) variants.push({ id: "low" });
|
|
21499
|
+
if (mapping.medium !== void 0) variants.push({ id: "medium" });
|
|
21500
|
+
if (mapping.high !== void 0) variants.push({ id: "high" });
|
|
21501
|
+
return variants.length > 0 ? variants : void 0;
|
|
21502
|
+
};
|
|
21503
|
+
const updateProviderRecord = (p) => {
|
|
21504
|
+
p.name = "Antigravity CLI";
|
|
21505
|
+
p.activation = "enabled";
|
|
21506
|
+
p.package = "aisdk:@ai-sdk/google";
|
|
21507
|
+
p.description = "Google Gemini Antigravity Code Assist OAuth provider";
|
|
21508
|
+
p.settings = { ...p.settings || {}, apiKey: "dummy" };
|
|
21509
|
+
p.integrationID = AGY_PROVIDER_ID;
|
|
21510
|
+
};
|
|
21511
|
+
const buildModelRecord = (modelId, simple, existingModel) => {
|
|
21512
|
+
const isClaude = modelId.startsWith("claude-");
|
|
21513
|
+
const isGpt = modelId.startsWith("gpt-");
|
|
21514
|
+
const variants = resolveVariants(modelId);
|
|
21515
|
+
return {
|
|
21516
|
+
id: modelId,
|
|
21517
|
+
providerID: AGY_PROVIDER_ID,
|
|
21518
|
+
name: simple.name,
|
|
21519
|
+
description: simple.description,
|
|
21520
|
+
family: modelId.includes("gemini") ? "gemini" : isClaude ? "claude" : isGpt ? "gpt" : "unknown",
|
|
21521
|
+
reasoning: simple.reasoning,
|
|
21522
|
+
attachment: simple.attachment,
|
|
21523
|
+
tool_call: simple.toolCall,
|
|
21524
|
+
limit: {
|
|
21525
|
+
context: simple.maxTokens,
|
|
21526
|
+
output: simple.maxOutputTokens
|
|
21527
|
+
},
|
|
21528
|
+
cost: simple.cost || { input: 0, output: 0 },
|
|
21529
|
+
...variants ? { variants } : {},
|
|
21530
|
+
...existingModel || {}
|
|
21531
|
+
};
|
|
21532
|
+
};
|
|
21533
|
+
const updateModelRecord = (m, modelId, simple) => {
|
|
21534
|
+
m.name = simple.name;
|
|
21535
|
+
m.capabilities = {
|
|
21536
|
+
tools: true,
|
|
21537
|
+
input: ["text", "image"],
|
|
21538
|
+
output: ["text"]
|
|
21539
|
+
};
|
|
21540
|
+
m.limit = {
|
|
21541
|
+
context: simple.maxTokens,
|
|
21542
|
+
output: simple.maxOutputTokens
|
|
21543
|
+
};
|
|
21544
|
+
m.family = "gemini";
|
|
21545
|
+
if (simple.cost) {
|
|
21546
|
+
m.cost = simple.cost;
|
|
21547
|
+
}
|
|
21548
|
+
const variants = resolveVariants(modelId);
|
|
21549
|
+
if (variants) {
|
|
21550
|
+
m.variants = variants;
|
|
21551
|
+
}
|
|
21552
|
+
};
|
|
21553
|
+
if (ctx.provider?.transform) {
|
|
21554
|
+
ctx.provider.transform(async (editor) => {
|
|
21555
|
+
if (!editor) return;
|
|
21556
|
+
if (typeof editor.update === "function") {
|
|
21557
|
+
editor.update(AGY_PROVIDER_ID, updateProviderRecord);
|
|
21558
|
+
} else if (typeof editor.set === "function") {
|
|
21559
|
+
const p = { id: AGY_PROVIDER_ID };
|
|
21560
|
+
updateProviderRecord(p);
|
|
21561
|
+
editor.set(AGY_PROVIDER_ID, p);
|
|
21562
|
+
} else if (typeof editor === "object") {
|
|
21563
|
+
const p = editor[AGY_PROVIDER_ID] || { id: AGY_PROVIDER_ID };
|
|
21564
|
+
updateProviderRecord(p);
|
|
21565
|
+
editor[AGY_PROVIDER_ID] = p;
|
|
21566
|
+
}
|
|
21567
|
+
});
|
|
21568
|
+
}
|
|
21569
|
+
if (ctx.model?.transform) {
|
|
21570
|
+
ctx.model.transform(async (editor) => {
|
|
21571
|
+
if (!editor) return;
|
|
21572
|
+
if (typeof editor.update === "function") {
|
|
21573
|
+
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
21574
|
+
editor.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
|
|
21575
|
+
}
|
|
21576
|
+
} else if (typeof editor.set === "function") {
|
|
21577
|
+
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
21578
|
+
const m = buildModelRecord(modelId, simple);
|
|
21579
|
+
editor.set(`${AGY_PROVIDER_ID}:${modelId}`, m);
|
|
21580
|
+
}
|
|
21581
|
+
} else if (typeof editor === "object") {
|
|
21582
|
+
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
21583
|
+
const key = `${AGY_PROVIDER_ID}:${modelId}`;
|
|
21584
|
+
editor[key] = buildModelRecord(modelId, simple, editor[key]);
|
|
21585
|
+
}
|
|
21586
|
+
}
|
|
21587
|
+
});
|
|
21588
|
+
}
|
|
21589
|
+
if (ctx.catalog?.transform) {
|
|
21590
|
+
ctx.catalog.transform(async (editor) => {
|
|
21591
|
+
if (!editor) return;
|
|
21592
|
+
if (typeof editor?.provider?.update === "function") {
|
|
21593
|
+
editor.provider.update(AGY_PROVIDER_ID, updateProviderRecord);
|
|
21594
|
+
if (typeof editor?.model?.update === "function") {
|
|
21595
|
+
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
21596
|
+
editor.model.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
|
|
21597
|
+
}
|
|
21598
|
+
}
|
|
21599
|
+
return;
|
|
21600
|
+
}
|
|
21601
|
+
const catalog = editor;
|
|
21602
|
+
catalog.providers = catalog.providers || {};
|
|
21603
|
+
catalog.providers[AGY_PROVIDER_ID] = {
|
|
21604
|
+
id: AGY_PROVIDER_ID,
|
|
21605
|
+
name: "Antigravity CLI",
|
|
21606
|
+
npm: "aisdk:@ai-sdk/google",
|
|
21607
|
+
settings: { apiKey: "dummy" },
|
|
21608
|
+
integrationID: AGY_PROVIDER_ID,
|
|
21609
|
+
models: { ...catalog.providers[AGY_PROVIDER_ID]?.models || {} },
|
|
21610
|
+
...catalog.providers[AGY_PROVIDER_ID]
|
|
21611
|
+
};
|
|
21612
|
+
if (catalog.providers[AGY_PROVIDER_ID].settings) {
|
|
21613
|
+
catalog.providers[AGY_PROVIDER_ID].settings = {
|
|
21614
|
+
...catalog.providers[AGY_PROVIDER_ID].settings,
|
|
21615
|
+
apiKey: "dummy"
|
|
21616
|
+
};
|
|
21617
|
+
} else {
|
|
21618
|
+
catalog.providers[AGY_PROVIDER_ID].settings = { apiKey: "dummy" };
|
|
21619
|
+
}
|
|
21620
|
+
catalog.providers[AGY_PROVIDER_ID].integrationID = AGY_PROVIDER_ID;
|
|
21621
|
+
const targetModels = catalog.providers[AGY_PROVIDER_ID].models;
|
|
21622
|
+
for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
|
|
21623
|
+
targetModels[modelId] = buildModelRecord(modelId, simple, targetModels[modelId]);
|
|
21624
|
+
}
|
|
21625
|
+
});
|
|
21626
|
+
}
|
|
21627
|
+
ctx.tool.transform(async (editor) => {
|
|
21628
|
+
if (!editor) return;
|
|
21629
|
+
const quotaTool = createAgyQuotaTool({
|
|
21630
|
+
client: void 0,
|
|
21631
|
+
getAuthResolver: () => void 0,
|
|
21632
|
+
getConfiguredProjectId: () => void 0,
|
|
21633
|
+
getUserAgentModel: () => void 0
|
|
21634
|
+
});
|
|
21635
|
+
const quotaSummaryTool = createAgyQuotaSummaryTool({
|
|
21636
|
+
client: void 0,
|
|
21637
|
+
getAuthResolver: () => void 0,
|
|
21638
|
+
getConfiguredProjectId: () => void 0,
|
|
21639
|
+
getUserAgentModel: () => void 0
|
|
21640
|
+
});
|
|
21641
|
+
if (typeof editor.add === "function") {
|
|
21642
|
+
editor.add({
|
|
21643
|
+
name: AGY_QUOTA_TOOL_NAME,
|
|
21644
|
+
description: quotaTool.description,
|
|
21645
|
+
input: {},
|
|
21646
|
+
execute: async (args, context) => quotaTool.execute(args, context)
|
|
21647
|
+
});
|
|
21648
|
+
editor.add({
|
|
21649
|
+
name: AGY_QUOTA_SUMMARY_TOOL_NAME,
|
|
21650
|
+
description: quotaSummaryTool.description,
|
|
21651
|
+
input: {},
|
|
21652
|
+
execute: async (args, context) => quotaSummaryTool.execute(args, context)
|
|
21653
|
+
});
|
|
21654
|
+
} else if (typeof editor.set === "function") {
|
|
21655
|
+
editor.set(AGY_QUOTA_TOOL_NAME, quotaTool);
|
|
21656
|
+
editor.set(AGY_QUOTA_SUMMARY_TOOL_NAME, quotaSummaryTool);
|
|
21657
|
+
} else if (editor.tools && typeof editor.tools === "object") {
|
|
21658
|
+
editor.tools[AGY_QUOTA_TOOL_NAME] = quotaTool;
|
|
21659
|
+
editor.tools[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
|
|
21660
|
+
} else if (typeof editor === "object") {
|
|
21661
|
+
editor[AGY_QUOTA_TOOL_NAME] = quotaTool;
|
|
21662
|
+
editor[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
|
|
21663
|
+
}
|
|
21664
|
+
});
|
|
21665
|
+
ctx.command.transform(async (editor) => {
|
|
21666
|
+
if (!editor) return;
|
|
21667
|
+
const commands = {
|
|
21668
|
+
[AGY_V2_QUOTA_COMMAND]: {
|
|
21669
|
+
description: "Show Agy Code Assist quota usage",
|
|
21670
|
+
template: AGY_V2_QUOTA_COMMAND_TEMPLATE
|
|
21671
|
+
},
|
|
21672
|
+
[AGY_V2_QUOTA_SUMMARY_COMMAND]: {
|
|
21673
|
+
description: "Show Agy Code Assist quota summary with weekly and 5-hour limits",
|
|
21674
|
+
template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
|
|
21675
|
+
}
|
|
21676
|
+
};
|
|
21677
|
+
if (typeof editor.add === "function") {
|
|
21678
|
+
editor.add({
|
|
21679
|
+
name: AGY_V2_QUOTA_COMMAND,
|
|
21680
|
+
description: "Display current Antigravity quota usage",
|
|
21681
|
+
template: AGY_V2_QUOTA_COMMAND_TEMPLATE
|
|
21682
|
+
});
|
|
21683
|
+
editor.add({
|
|
21684
|
+
name: AGY_V2_QUOTA_SUMMARY_COMMAND,
|
|
21685
|
+
description: "Display Antigravity quota summary grouped by model family",
|
|
21686
|
+
template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
|
|
21687
|
+
});
|
|
21688
|
+
} else if (typeof editor.set === "function") {
|
|
21689
|
+
editor.set(AGY_V2_QUOTA_COMMAND, commands[AGY_V2_QUOTA_COMMAND]);
|
|
21690
|
+
editor.set(AGY_V2_QUOTA_SUMMARY_COMMAND, commands[AGY_V2_QUOTA_SUMMARY_COMMAND]);
|
|
21691
|
+
} else if (editor.commands && typeof editor.commands === "object") {
|
|
21692
|
+
editor.commands[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
|
|
21693
|
+
editor.commands[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
|
|
21694
|
+
} else if (typeof editor === "object") {
|
|
21695
|
+
editor[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
|
|
21696
|
+
editor[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
|
|
21697
|
+
}
|
|
21698
|
+
});
|
|
21699
|
+
ctx.integration?.transform?.((editor) => {
|
|
21700
|
+
if (!editor) return;
|
|
21701
|
+
editor.update?.(AGY_PROVIDER_ID, (integration) => {
|
|
21702
|
+
integration.name = "Antigravity CLI (plugin)";
|
|
21703
|
+
});
|
|
21704
|
+
editor.method?.update?.({
|
|
21705
|
+
integrationID: AGY_PROVIDER_ID,
|
|
21706
|
+
method: {
|
|
21707
|
+
id: "oauth",
|
|
21708
|
+
type: "oauth",
|
|
21709
|
+
label: "Antigravity CLI (OAuth)"
|
|
21710
|
+
},
|
|
21711
|
+
authorize: async () => {
|
|
21712
|
+
const authorization = await authorizeAgy();
|
|
21713
|
+
return {
|
|
21714
|
+
mode: "code",
|
|
21715
|
+
url: authorization.url,
|
|
21716
|
+
instructions: "Please complete Google account authorization in your browser. After authorization, copy the full redirect URL or code and paste it below:",
|
|
21717
|
+
callback: async (code) => {
|
|
21718
|
+
const trimmed = code.trim();
|
|
21719
|
+
const parsed = parseOAuthCallbackInput(trimmed);
|
|
21720
|
+
const authCode = parsed.code || trimmed;
|
|
21721
|
+
if (!authCode) {
|
|
21722
|
+
return { type: "failed", error: "Missing authorization code in callback input" };
|
|
21723
|
+
}
|
|
21724
|
+
if (parsed.state && parsed.state !== authorization.state) {
|
|
21725
|
+
return { type: "failed", error: "State mismatch in callback input (possible CSRF attempt)" };
|
|
21726
|
+
}
|
|
21727
|
+
const exchangeResult = await exchangeAgyWithVerifier(authCode, authorization.verifier);
|
|
21728
|
+
if (exchangeResult.type !== "success") {
|
|
21729
|
+
return exchangeResult;
|
|
21730
|
+
}
|
|
21731
|
+
const initialRefresh = formatRefreshParts({
|
|
21732
|
+
refreshToken: exchangeResult.refresh
|
|
21733
|
+
});
|
|
21734
|
+
let authRecord = {
|
|
21735
|
+
type: "oauth",
|
|
21736
|
+
refresh: initialRefresh,
|
|
21737
|
+
access: exchangeResult.access,
|
|
21738
|
+
expires: exchangeResult.expires
|
|
21739
|
+
};
|
|
21740
|
+
try {
|
|
21741
|
+
const projectContext = await ensureProjectContext(
|
|
21742
|
+
authRecord,
|
|
21743
|
+
{ auth: { set: async () => {
|
|
21744
|
+
} } }
|
|
21745
|
+
);
|
|
21746
|
+
authRecord = {
|
|
21747
|
+
...authRecord,
|
|
21748
|
+
refresh: projectContext.auth.refresh
|
|
21749
|
+
};
|
|
21750
|
+
} catch {
|
|
21751
|
+
}
|
|
21752
|
+
try {
|
|
21753
|
+
saveStoredAuthToJson(authRecord);
|
|
21754
|
+
} catch {
|
|
21755
|
+
return {
|
|
21756
|
+
type: "failed",
|
|
21757
|
+
error: "Google authentication succeeded but AGY credentials could not be stored. Check filesystem access and retry."
|
|
21758
|
+
};
|
|
21759
|
+
}
|
|
21760
|
+
return {
|
|
21761
|
+
type: "oauth",
|
|
21762
|
+
methodID: "oauth",
|
|
21763
|
+
refresh: authRecord.refresh,
|
|
21764
|
+
access: authRecord.access,
|
|
21765
|
+
expires: authRecord.expires
|
|
21766
|
+
};
|
|
21767
|
+
}
|
|
21768
|
+
};
|
|
21769
|
+
}
|
|
21770
|
+
});
|
|
21771
|
+
});
|
|
21772
|
+
ctx.aisdk?.hook("sdk", async (event) => {
|
|
21773
|
+
if (!event) return;
|
|
21774
|
+
const isMatchingProvider = event.providerID === AGY_PROVIDER_ID || event.model?.providerID === AGY_PROVIDER_ID;
|
|
21775
|
+
if (!isMatchingProvider) return;
|
|
21776
|
+
event.options = event.options || {};
|
|
21777
|
+
event.options.apiKey = "dummy";
|
|
21778
|
+
event.options.fetch = createV2FetchInterceptor();
|
|
21779
|
+
});
|
|
21780
|
+
registerV2SessionHooks(ctx);
|
|
21781
|
+
}
|
|
21782
|
+
var v2PluginDefinition = defineOpenCodeV2Plugin({
|
|
21783
|
+
id: AGY_PROVIDER_ID,
|
|
21784
|
+
setup: setupOpenCodeV2
|
|
21785
|
+
});
|
|
20978
21786
|
|
|
20979
21787
|
// index.ts
|
|
20980
|
-
var
|
|
20981
|
-
|
|
21788
|
+
var dualPlugin = {
|
|
21789
|
+
...v2PluginDefinition,
|
|
20982
21790
|
server: AgyCLIOAuthPlugin
|
|
20983
21791
|
};
|
|
21792
|
+
var index_default = dualPlugin;
|
|
20984
21793
|
export {
|
|
20985
21794
|
AgyCLIOAuthPlugin,
|
|
20986
21795
|
GoogleOAuthPlugin,
|
|
20987
|
-
index_default as default
|
|
21796
|
+
index_default as default,
|
|
21797
|
+
defineOpenCodeV2Plugin,
|
|
21798
|
+
setupOpenCodeV2,
|
|
21799
|
+
v2PluginDefinition
|
|
20988
21800
|
};
|
|
20989
21801
|
//# sourceMappingURL=index.js.map
|