@cortexkit/opencode-antigravity-auth 3.0.42 → 3.1.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 +11 -0
- package/dist/cli.js +191 -6
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +19 -19
- package/dist/index.js +725 -264
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +88 -80
- package/dist/server.js +778 -317
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +147 -2
- package/dist/src/common-auth-embedded/claustrum/hub.js +47 -1
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +34 -9
- package/dist/src/common-auth-embedded/routing-accessor/index.js +65 -8
- package/dist/src/common-auth-embedded/settings/edit.d.ts +1 -0
- package/dist/src/common-auth-embedded/settings/edit.js +48 -2
- package/dist/src/common-auth-embedded/settings/handle.d.ts +2 -1
- package/dist/src/common-auth-embedded/settings/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/settings/update.d.ts +14 -0
- package/dist/src/common-auth-embedded/settings/update.js +28 -9
- package/dist/src/common-auth-embedded/source-output.json +52 -43
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/src/plugin/account-access.js +1 -1
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts.map +1 -1
- package/dist/src/plugin/catalog.js +4 -2
- package/dist/src/plugin/catalog.js.map +1 -1
- package/dist/src/plugin/config/models.d.ts +9 -0
- package/dist/src/plugin/config/models.d.ts.map +1 -1
- package/dist/src/plugin/config/models.js +18 -0
- package/dist/src/plugin/config/models.js.map +1 -1
- package/dist/src/plugin/config/updater.js +2 -2
- package/dist/src/plugin/config/updater.js.map +1 -1
- package/dist/src/plugin/core/streaming/terminal-event.d.ts +14 -0
- package/dist/src/plugin/core/streaming/terminal-event.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/terminal-event.js +39 -0
- package/dist/src/plugin/core/streaming/terminal-event.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/src/plugin/core/streaming/transformer.js +1 -13
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
- package/dist/src/plugin/ga-location-services.js +1 -1
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.js +1 -1
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +101 -47
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/search.d.ts +7 -0
- package/dist/src/plugin/search.d.ts.map +1 -1
- package/dist/src/plugin/search.js +9 -15
- package/dist/src/plugin/search.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts +1 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +2 -5
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +59 -11
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing.d.ts +9 -1
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing.js +34 -12
- package/dist/src/plugin/shared/vault-routing.js.map +1 -1
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +34 -9
- package/dist/types/src/plugin/catalog.d.ts.map +1 -1
- package/dist/types/src/plugin/config/models.d.ts +9 -0
- package/dist/types/src/plugin/config/models.d.ts.map +1 -1
- package/dist/types/src/plugin/core/streaming/terminal-event.d.ts +14 -0
- package/dist/types/src/plugin/core/streaming/terminal-event.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/search.d.ts +7 -0
- package/dist/types/src/plugin/search.d.ts.map +1 -1
- package/dist/types/src/plugin/session-context.d.ts +1 -1
- package/dist/types/src/plugin/session-context.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts +9 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/src/common-auth-embedded/claustrum/custody.js +147 -2
- package/src/common-auth-embedded/claustrum/hub.js +47 -1
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/claustrum/index.js +1 -1
- package/src/common-auth-embedded/routing-accessor/index.d.ts +34 -9
- package/src/common-auth-embedded/routing-accessor/index.js +65 -8
- package/src/common-auth-embedded/settings/edit.d.ts +1 -0
- package/src/common-auth-embedded/settings/edit.js +48 -2
- package/src/common-auth-embedded/settings/handle.d.ts +2 -1
- package/src/common-auth-embedded/settings/index.d.ts +1 -0
- package/src/common-auth-embedded/settings/update.d.ts +14 -0
- package/src/common-auth-embedded/settings/update.js +28 -9
- package/src/common-auth-embedded/source-output.json +52 -43
package/dist/index.js
CHANGED
|
@@ -5873,8 +5873,8 @@ var AGY_CLI_VERSION, AGY_CLI_CHANGE_LIST, ANTIGRAVITY_API_CLIENT, MAX_FINGERPRIN
|
|
|
5873
5873
|
var init_fingerprint = __esm({
|
|
5874
5874
|
"../core/dist/fingerprint.js"() {
|
|
5875
5875
|
"use strict";
|
|
5876
|
-
AGY_CLI_VERSION = "1.
|
|
5877
|
-
AGY_CLI_CHANGE_LIST = "
|
|
5876
|
+
AGY_CLI_VERSION = "1.5.8";
|
|
5877
|
+
AGY_CLI_CHANGE_LIST = "1020628950";
|
|
5878
5878
|
ANTIGRAVITY_API_CLIENT = "antigravity-cli";
|
|
5879
5879
|
MAX_FINGERPRINT_HISTORY = 5;
|
|
5880
5880
|
sessionFingerprint = null;
|
|
@@ -5933,6 +5933,8 @@ function getGemini38FlashAntigravityModel(tier) {
|
|
|
5933
5933
|
}
|
|
5934
5934
|
function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
5935
5935
|
const normalized = modelId.toLowerCase();
|
|
5936
|
+
if (isGeminiHydrogenModel(normalized))
|
|
5937
|
+
return "gemini";
|
|
5936
5938
|
if (isGeminiCarbonModel(normalized))
|
|
5937
5939
|
return "gemini";
|
|
5938
5940
|
if (isGeminiArgonModel(normalized))
|
|
@@ -5950,6 +5952,20 @@ function isGeminiArgonModel(model) {
|
|
|
5950
5952
|
function isGeminiCarbonModel(model) {
|
|
5951
5953
|
return /^(?:antigravity-)?gemini-4-carbon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5952
5954
|
}
|
|
5955
|
+
function isGeminiHydrogenModel(model) {
|
|
5956
|
+
return /^(?:antigravity-)?gemini-4-hydrogen(?:-(?:low|medium|high|xhigh))?$/.test(model.toLowerCase());
|
|
5957
|
+
}
|
|
5958
|
+
function getGeminiHydrogenAntigravityModel(tier) {
|
|
5959
|
+
return getTieredAntigravityModel({
|
|
5960
|
+
defaultModel: "gemini-4-hydrogen-high",
|
|
5961
|
+
byTier: {
|
|
5962
|
+
low: "gemini-4-hydrogen-low",
|
|
5963
|
+
medium: "gemini-4-hydrogen-medium",
|
|
5964
|
+
high: "gemini-4-hydrogen-high",
|
|
5965
|
+
xhigh: "gemini-4-hydrogen-xhigh"
|
|
5966
|
+
}
|
|
5967
|
+
}, tier);
|
|
5968
|
+
}
|
|
5953
5969
|
function getGeminiCarbonAntigravityModel(tier) {
|
|
5954
5970
|
return getTieredAntigravityModel({
|
|
5955
5971
|
defaultModel: "gemini-4-carbon-medium",
|
|
@@ -5982,6 +5998,36 @@ var init_model_registry = __esm({
|
|
|
5982
5998
|
DEFAULT_COST = { input: 0, output: 0 };
|
|
5983
5999
|
DEFAULT_OPTIONS = {};
|
|
5984
6000
|
AGY_NATIVE_MODEL_DEFINITIONS = {
|
|
6001
|
+
// Context: Google's "Introducing Gemini 4 Hydrogen" announcement (12 Nov 2026).
|
|
6002
|
+
// Output caps and route enums: native CLI 1.5.5 capture (13 Nov 2026).
|
|
6003
|
+
"gemini-4-hydrogen-low": {
|
|
6004
|
+
displayName: "Gemini 4 Hydrogen (Low)",
|
|
6005
|
+
maxTokens: 1048576,
|
|
6006
|
+
maxOutputTokens: 262144,
|
|
6007
|
+
model: "MODEL_PLACEHOLDER_M527",
|
|
6008
|
+
supportsThinking: true
|
|
6009
|
+
},
|
|
6010
|
+
"gemini-4-hydrogen-medium": {
|
|
6011
|
+
displayName: "Gemini 4 Hydrogen (Medium)",
|
|
6012
|
+
maxTokens: 1048576,
|
|
6013
|
+
maxOutputTokens: 262144,
|
|
6014
|
+
model: "MODEL_PLACEHOLDER_M526",
|
|
6015
|
+
supportsThinking: true
|
|
6016
|
+
},
|
|
6017
|
+
"gemini-4-hydrogen-high": {
|
|
6018
|
+
displayName: "Gemini 4 Hydrogen (High)",
|
|
6019
|
+
maxTokens: 1048576,
|
|
6020
|
+
maxOutputTokens: 262144,
|
|
6021
|
+
model: "MODEL_PLACEHOLDER_M525",
|
|
6022
|
+
supportsThinking: true
|
|
6023
|
+
},
|
|
6024
|
+
"gemini-4-hydrogen-xhigh": {
|
|
6025
|
+
displayName: "Gemini 4 Hydrogen (XHigh)",
|
|
6026
|
+
maxTokens: 1048576,
|
|
6027
|
+
maxOutputTokens: 262144,
|
|
6028
|
+
model: "MODEL_PLACEHOLDER_M528",
|
|
6029
|
+
supportsThinking: true
|
|
6030
|
+
},
|
|
5985
6031
|
"gemini-4-carbon-low": {
|
|
5986
6032
|
displayName: "Gemini 4 Carbon (Low)",
|
|
5987
6033
|
maxTokens: 1048576,
|
|
@@ -6136,6 +6182,18 @@ var init_model_registry = __esm({
|
|
|
6136
6182
|
};
|
|
6137
6183
|
RETIRED_AGY_MODEL_MESSAGE = "This Antigravity model is no longer offered. Use Gemini 3.8 Flash, or Claude Sonnet 5.5 or Opus 5.5.";
|
|
6138
6184
|
ALL_MODEL_DEFINITIONS = {
|
|
6185
|
+
"antigravity-gemini-4-hydrogen": defineModel("antigravity-gemini-4-hydrogen", {
|
|
6186
|
+
name: "Gemini 4 Hydrogen (Antigravity)",
|
|
6187
|
+
reasoning: true,
|
|
6188
|
+
limit: { context: 1048576, output: 262144 },
|
|
6189
|
+
modalities: DEFAULT_MODALITIES,
|
|
6190
|
+
variants: {
|
|
6191
|
+
low: { thinkingLevel: "low" },
|
|
6192
|
+
medium: { thinkingLevel: "medium" },
|
|
6193
|
+
high: { thinkingLevel: "high" },
|
|
6194
|
+
xhigh: { thinkingLevel: "xhigh" }
|
|
6195
|
+
}
|
|
6196
|
+
}),
|
|
6139
6197
|
"antigravity-gemini-4-argon": defineModel("antigravity-gemini-4-argon", {
|
|
6140
6198
|
name: "Gemini 4 Argon (Antigravity)",
|
|
6141
6199
|
reasoning: true,
|
|
@@ -6304,6 +6362,7 @@ var init_model_registry = __esm({
|
|
|
6304
6362
|
ANTIGRAVITY_OPENCODE_MODEL_IDS = [
|
|
6305
6363
|
"antigravity-gemini-4-argon",
|
|
6306
6364
|
"antigravity-gemini-4-carbon",
|
|
6365
|
+
"antigravity-gemini-4-hydrogen",
|
|
6307
6366
|
"antigravity-gemini-3.8-flash",
|
|
6308
6367
|
"antigravity-gemini-3.1-flash-image",
|
|
6309
6368
|
"antigravity-claude-sonnet-5-5",
|
|
@@ -7942,7 +8001,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
7942
8001
|
});
|
|
7943
8002
|
}
|
|
7944
8003
|
async function sleep(ms) {
|
|
7945
|
-
await new Promise((
|
|
8004
|
+
await new Promise((resolve31) => setTimeout(resolve31, ms));
|
|
7946
8005
|
}
|
|
7947
8006
|
async function acquireFencedFileLock(options) {
|
|
7948
8007
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -8058,8 +8117,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
8058
8117
|
let released = false;
|
|
8059
8118
|
let lost = false;
|
|
8060
8119
|
let lostResolve = null;
|
|
8061
|
-
let lostPromise = new Promise((
|
|
8062
|
-
lostResolve =
|
|
8120
|
+
let lostPromise = new Promise((resolve31) => {
|
|
8121
|
+
lostResolve = resolve31;
|
|
8063
8122
|
});
|
|
8064
8123
|
const markLost = () => {
|
|
8065
8124
|
if (lost)
|
|
@@ -8069,9 +8128,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
8069
8128
|
clearInterval(renewTimer);
|
|
8070
8129
|
renewTimer = null;
|
|
8071
8130
|
}
|
|
8072
|
-
const
|
|
8131
|
+
const resolve31 = lostResolve;
|
|
8073
8132
|
lostResolve = null;
|
|
8074
|
-
|
|
8133
|
+
resolve31?.();
|
|
8075
8134
|
};
|
|
8076
8135
|
const setupRenew = () => {
|
|
8077
8136
|
if (options.renew === false)
|
|
@@ -8694,7 +8753,7 @@ async function saveAccountStorageReplace(path5, incoming) {
|
|
|
8694
8753
|
return mutateAccountStorage(path5, () => incoming);
|
|
8695
8754
|
}
|
|
8696
8755
|
async function clearAccountStorage(path5) {
|
|
8697
|
-
const sleep5 = (ms) => new Promise((
|
|
8756
|
+
const sleep5 = (ms) => new Promise((resolve31) => setTimeout(resolve31, ms));
|
|
8698
8757
|
const lock = await acquireWithRetry(path5, sleep5);
|
|
8699
8758
|
try {
|
|
8700
8759
|
await assertLegacyAccountStorageWritable(path5);
|
|
@@ -8742,7 +8801,7 @@ var init_account_storage = __esm({
|
|
|
8742
8801
|
}
|
|
8743
8802
|
};
|
|
8744
8803
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
8745
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
8804
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve31) => setTimeout(resolve31, ms));
|
|
8746
8805
|
DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
8747
8806
|
}
|
|
8748
8807
|
});
|
|
@@ -9960,8 +10019,8 @@ var init_account_manager = __esm({
|
|
|
9960
10019
|
await this.saveInFlight;
|
|
9961
10020
|
return;
|
|
9962
10021
|
}
|
|
9963
|
-
return new Promise((
|
|
9964
|
-
this.savePromiseResolvers.push({ resolve:
|
|
10022
|
+
return new Promise((resolve31, reject) => {
|
|
10023
|
+
this.savePromiseResolvers.push({ resolve: resolve31, reject });
|
|
9965
10024
|
});
|
|
9966
10025
|
}
|
|
9967
10026
|
async dispose() {
|
|
@@ -10004,8 +10063,8 @@ var init_account_manager = __esm({
|
|
|
10004
10063
|
reject(error);
|
|
10005
10064
|
throw error;
|
|
10006
10065
|
}
|
|
10007
|
-
for (const { resolve:
|
|
10008
|
-
|
|
10066
|
+
for (const { resolve: resolve31 } of resolvers)
|
|
10067
|
+
resolve31();
|
|
10009
10068
|
}
|
|
10010
10069
|
async executeSave() {
|
|
10011
10070
|
this.savePending = false;
|
|
@@ -10019,16 +10078,16 @@ var init_account_manager = __esm({
|
|
|
10019
10078
|
}
|
|
10020
10079
|
try {
|
|
10021
10080
|
await this.saveToDisk();
|
|
10022
|
-
for (const { resolve:
|
|
10023
|
-
|
|
10081
|
+
for (const { resolve: resolve31 } of resolvers) {
|
|
10082
|
+
resolve31();
|
|
10024
10083
|
}
|
|
10025
10084
|
} catch (error) {
|
|
10026
10085
|
if (isStorageLockContention(error)) {
|
|
10027
10086
|
this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
|
|
10028
10087
|
error: String(error)
|
|
10029
10088
|
});
|
|
10030
|
-
for (const { resolve:
|
|
10031
|
-
|
|
10089
|
+
for (const { resolve: resolve31 } of resolvers) {
|
|
10090
|
+
resolve31();
|
|
10032
10091
|
}
|
|
10033
10092
|
return;
|
|
10034
10093
|
}
|
|
@@ -10250,11 +10309,12 @@ function fnv1a64Signed(input2) {
|
|
|
10250
10309
|
}
|
|
10251
10310
|
return BigInt.asIntN(64, hash2).toString();
|
|
10252
10311
|
}
|
|
10253
|
-
function createAgyRequestSessionContext(
|
|
10312
|
+
function createAgyRequestSessionContext(ids = {}) {
|
|
10254
10313
|
return {
|
|
10255
10314
|
conversationId: ids.conversationId ?? randomUUID7(),
|
|
10256
10315
|
trajectoryId: ids.trajectoryId ?? randomUUID7(),
|
|
10257
|
-
|
|
10316
|
+
// Print-mode agy uses the empty-string offset basis in every workspace.
|
|
10317
|
+
numericSessionId: fnv1a64Signed("")
|
|
10258
10318
|
};
|
|
10259
10319
|
}
|
|
10260
10320
|
function getAgyModelEnum(model) {
|
|
@@ -10278,52 +10338,58 @@ function orderAgyRequestPayloadInPlace(payload) {
|
|
|
10278
10338
|
}
|
|
10279
10339
|
Object.assign(payload, ordered);
|
|
10280
10340
|
}
|
|
10281
|
-
function countAgyRequestSteps(payload
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
if (
|
|
10286
|
-
return
|
|
10287
|
-
let
|
|
10288
|
-
let
|
|
10289
|
-
for (const content of contents) {
|
|
10290
|
-
if (
|
|
10341
|
+
function countAgyRequestSteps(payload) {
|
|
10342
|
+
return Array.isArray(payload.contents) ? payload.contents.length : 0;
|
|
10343
|
+
}
|
|
10344
|
+
function hasSecondUserTurn(payload) {
|
|
10345
|
+
if (!Array.isArray(payload.contents))
|
|
10346
|
+
return false;
|
|
10347
|
+
let sawUser = false;
|
|
10348
|
+
let sawModelAfterUser = false;
|
|
10349
|
+
for (const content of payload.contents) {
|
|
10350
|
+
if (content?.role === "model" && sawUser)
|
|
10351
|
+
sawModelAfterUser = true;
|
|
10352
|
+
if (content?.role !== "user" || !Array.isArray(content.parts))
|
|
10291
10353
|
continue;
|
|
10292
|
-
const
|
|
10293
|
-
if (!
|
|
10354
|
+
const isPrompt = content.parts.some((part) => part !== null && typeof part === "object" && !("functionResponse" in part) && (!("text" in part) || part.text !== "[Continue]"));
|
|
10355
|
+
if (!isPrompt)
|
|
10294
10356
|
continue;
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
if (!part || typeof part !== "object" || Array.isArray(part))
|
|
10299
|
-
return false;
|
|
10300
|
-
return "functionResponse" in part;
|
|
10301
|
-
}).length;
|
|
10302
|
-
}
|
|
10303
|
-
}
|
|
10304
|
-
if (mode === "cli") {
|
|
10305
|
-
return Math.max(1, contents.length + functionResponseCount);
|
|
10357
|
+
if (sawModelAfterUser)
|
|
10358
|
+
return true;
|
|
10359
|
+
sawUser = true;
|
|
10306
10360
|
}
|
|
10307
|
-
return
|
|
10361
|
+
return false;
|
|
10308
10362
|
}
|
|
10309
|
-
function buildAgyAgentRequestMetadata(session, payload, model, timestamp
|
|
10310
|
-
const
|
|
10363
|
+
function buildAgyAgentRequestMetadata(session, payload, model, timestamp) {
|
|
10364
|
+
const requestTimestamp = timestamp ?? Math.max(Date.now(), (session.lastMetadataTimestamp ?? 0) + 1);
|
|
10365
|
+
const stepCount = countAgyRequestSteps(payload);
|
|
10366
|
+
const lastStepIndex = stepCount - 1;
|
|
10367
|
+
if (session.lastMetadataTimestamp !== requestTimestamp) {
|
|
10368
|
+
session.requestCount = (session.requestCount ?? 0) + 1;
|
|
10369
|
+
session.lastMetadataTimestamp = requestTimestamp;
|
|
10370
|
+
if (session.lastExecutionId || hasSecondUserTurn(payload)) {
|
|
10371
|
+
session.lastExecutionId = randomUUID7();
|
|
10372
|
+
}
|
|
10373
|
+
}
|
|
10311
10374
|
const isClaude = model.toLowerCase().startsWith("claude-");
|
|
10312
10375
|
const isNonGemini = isClaude || model.toLowerCase().startsWith("gpt-");
|
|
10313
10376
|
session.usedClaude = session.usedClaude === true || isClaude;
|
|
10314
10377
|
session.usedNonGeminiModel = session.usedNonGeminiModel === true || isNonGemini;
|
|
10315
10378
|
const modelEnum = getAgyModelEnum(model);
|
|
10316
10379
|
const labels = {
|
|
10380
|
+
cascade_id: session.conversationId,
|
|
10317
10381
|
...session.lastExecutionId ? { last_execution_id: session.lastExecutionId } : {},
|
|
10318
10382
|
last_step_index: String(lastStepIndex),
|
|
10319
10383
|
...modelEnum ? { model_enum: modelEnum } : {},
|
|
10384
|
+
request_id: `${session.trajectoryId}-${(session.requestCount ?? 1) - 1}`,
|
|
10385
|
+
root_cascade_id: session.conversationId,
|
|
10320
10386
|
trajectory_id: session.trajectoryId,
|
|
10321
10387
|
used_claude: session.usedClaude ? "true" : "false",
|
|
10322
10388
|
used_claude_conservative: session.usedClaude ? "true" : "false",
|
|
10323
10389
|
used_non_gemini_model: session.usedNonGeminiModel ? "true" : "false"
|
|
10324
10390
|
};
|
|
10325
10391
|
return {
|
|
10326
|
-
requestId: `agent/${session.conversationId}/${
|
|
10392
|
+
requestId: `agent/${session.conversationId}/${requestTimestamp}/${session.trajectoryId}/${stepCount}`,
|
|
10327
10393
|
sessionId: session.numericSessionId,
|
|
10328
10394
|
labels,
|
|
10329
10395
|
lastStepIndex
|
|
@@ -10342,19 +10408,16 @@ var init_agy_request_metadata = __esm({
|
|
|
10342
10408
|
"contents",
|
|
10343
10409
|
"systemInstruction",
|
|
10344
10410
|
"tools",
|
|
10345
|
-
"toolConfig",
|
|
10346
10411
|
"labels",
|
|
10347
10412
|
"generationConfig",
|
|
10348
10413
|
"sessionId"
|
|
10349
10414
|
];
|
|
10350
10415
|
AgyRequestSessionStore = class {
|
|
10351
10416
|
entries = /* @__PURE__ */ new Map();
|
|
10352
|
-
workspaceUri;
|
|
10353
10417
|
ttlMs;
|
|
10354
10418
|
maxEntries;
|
|
10355
10419
|
now;
|
|
10356
|
-
constructor(
|
|
10357
|
-
this.workspaceUri = workspaceUri;
|
|
10420
|
+
constructor(options = {}) {
|
|
10358
10421
|
this.ttlMs = options.ttlMs ?? DEFAULT_SESSION_STATE_TTL_MS;
|
|
10359
10422
|
this.maxEntries = options.maxEntries ?? DEFAULT_MAX_SESSION_STATES;
|
|
10360
10423
|
this.now = options.now ?? Date.now;
|
|
@@ -10367,7 +10430,7 @@ var init_agy_request_metadata = __esm({
|
|
|
10367
10430
|
existing.lastAccessedAt = timestamp;
|
|
10368
10431
|
return existing.context;
|
|
10369
10432
|
}
|
|
10370
|
-
const context = createAgyRequestSessionContext(
|
|
10433
|
+
const context = createAgyRequestSessionContext();
|
|
10371
10434
|
this.entries.set(key, {
|
|
10372
10435
|
context,
|
|
10373
10436
|
lastAccessedAt: timestamp,
|
|
@@ -10382,12 +10445,6 @@ var init_agy_request_metadata = __esm({
|
|
|
10382
10445
|
stored.lastRequestTimestamp = timestamp;
|
|
10383
10446
|
return { session, timestamp };
|
|
10384
10447
|
}
|
|
10385
|
-
completeExecution(key) {
|
|
10386
|
-
const stored = this.entries.get(key);
|
|
10387
|
-
if (stored) {
|
|
10388
|
-
stored.context.lastExecutionId = randomUUID7();
|
|
10389
|
-
}
|
|
10390
|
-
}
|
|
10391
10448
|
has(key) {
|
|
10392
10449
|
return this.entries.has(key);
|
|
10393
10450
|
}
|
|
@@ -10529,7 +10586,7 @@ function getHttpsProxy(url) {
|
|
|
10529
10586
|
}
|
|
10530
10587
|
}
|
|
10531
10588
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
10532
|
-
return new Promise((
|
|
10589
|
+
return new Promise((resolve31, reject) => {
|
|
10533
10590
|
let buffer = Buffer3.alloc(0);
|
|
10534
10591
|
const timeout = setTimeout(() => {
|
|
10535
10592
|
onTimeout();
|
|
@@ -10552,7 +10609,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
10552
10609
|
return;
|
|
10553
10610
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
10554
10611
|
const leftover = buffer.subarray(marker + 4);
|
|
10555
|
-
cleanup2(() =>
|
|
10612
|
+
cleanup2(() => resolve31({ head, leftover }));
|
|
10556
10613
|
};
|
|
10557
10614
|
socket.on("data", onData);
|
|
10558
10615
|
socket.once("error", onError);
|
|
@@ -10566,7 +10623,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10566
10623
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
10567
10624
|
signal: signal ?? void 0
|
|
10568
10625
|
});
|
|
10569
|
-
await new Promise((
|
|
10626
|
+
await new Promise((resolve31, reject) => {
|
|
10570
10627
|
const timeout = setTimeout(() => {
|
|
10571
10628
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
10572
10629
|
proxySocket.destroy();
|
|
@@ -10575,7 +10632,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10575
10632
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10576
10633
|
proxySocket.once("connect", () => {
|
|
10577
10634
|
cleanup2();
|
|
10578
|
-
|
|
10635
|
+
resolve31();
|
|
10579
10636
|
});
|
|
10580
10637
|
proxySocket.once("error", (error) => {
|
|
10581
10638
|
cleanup2();
|
|
@@ -10600,10 +10657,11 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10600
10657
|
if (leftover.length > 0) {
|
|
10601
10658
|
proxySocket.unshift(leftover);
|
|
10602
10659
|
}
|
|
10603
|
-
return await new Promise((
|
|
10660
|
+
return await new Promise((resolve31, reject) => {
|
|
10604
10661
|
const tlsOptions = {
|
|
10605
10662
|
socket: proxySocket,
|
|
10606
10663
|
servername: targetHost,
|
|
10664
|
+
ALPNProtocols: ["http/1.1"],
|
|
10607
10665
|
signal: signal ?? void 0
|
|
10608
10666
|
};
|
|
10609
10667
|
const tlsSocket = tls.connect(tlsOptions);
|
|
@@ -10615,7 +10673,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10615
10673
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10616
10674
|
tlsSocket.once("secureConnect", () => {
|
|
10617
10675
|
cleanup2();
|
|
10618
|
-
|
|
10676
|
+
resolve31(tlsSocket);
|
|
10619
10677
|
});
|
|
10620
10678
|
tlsSocket.once("error", (error) => {
|
|
10621
10679
|
cleanup2();
|
|
@@ -10624,11 +10682,12 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10624
10682
|
});
|
|
10625
10683
|
}
|
|
10626
10684
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
10627
|
-
return await new Promise((
|
|
10685
|
+
return await new Promise((resolve31, reject) => {
|
|
10628
10686
|
const tlsOptions = {
|
|
10629
10687
|
host: targetUrl.hostname,
|
|
10630
10688
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
10631
10689
|
servername: targetUrl.hostname,
|
|
10690
|
+
ALPNProtocols: ["http/1.1"],
|
|
10632
10691
|
signal: signal ?? void 0
|
|
10633
10692
|
};
|
|
10634
10693
|
const socket = tls.connect(tlsOptions);
|
|
@@ -10640,7 +10699,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
10640
10699
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10641
10700
|
socket.once("secureConnect", () => {
|
|
10642
10701
|
cleanup2();
|
|
10643
|
-
|
|
10702
|
+
resolve31(socket);
|
|
10644
10703
|
});
|
|
10645
10704
|
socket.once("error", (error) => {
|
|
10646
10705
|
cleanup2();
|
|
@@ -13422,8 +13481,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13422
13481
|
let releaseConfirmed = false;
|
|
13423
13482
|
let loss;
|
|
13424
13483
|
let resolveLoss;
|
|
13425
|
-
const lostPromise = new Promise((
|
|
13426
|
-
resolveLoss =
|
|
13484
|
+
const lostPromise = new Promise((resolve31) => {
|
|
13485
|
+
resolveLoss = resolve31;
|
|
13427
13486
|
});
|
|
13428
13487
|
function notifyTimerStep(event) {
|
|
13429
13488
|
try {
|
|
@@ -13587,7 +13646,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13587
13646
|
}
|
|
13588
13647
|
}
|
|
13589
13648
|
async function backoff() {
|
|
13590
|
-
await new Promise((
|
|
13649
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.floor(Math.random() * 4)));
|
|
13591
13650
|
}
|
|
13592
13651
|
async function readLockState(notifyReady = true) {
|
|
13593
13652
|
if (notifyReady && options.onStep)
|
|
@@ -13680,7 +13739,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13680
13739
|
const remainingMs = deadline - performance.now();
|
|
13681
13740
|
if (remainingMs <= 0)
|
|
13682
13741
|
throw original;
|
|
13683
|
-
await new Promise((
|
|
13742
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
13684
13743
|
if (performance.now() >= deadline)
|
|
13685
13744
|
throw original;
|
|
13686
13745
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -14183,7 +14242,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
14183
14242
|
const remainingMs = deadline - performance.now();
|
|
14184
14243
|
if (remainingMs <= 0)
|
|
14185
14244
|
break;
|
|
14186
|
-
await new Promise((
|
|
14245
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
14187
14246
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
14188
14247
|
break;
|
|
14189
14248
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -14268,7 +14327,7 @@ async function withLock(target, options, fn) {
|
|
|
14268
14327
|
timeoutMs: options.timeoutMs
|
|
14269
14328
|
});
|
|
14270
14329
|
}
|
|
14271
|
-
await new Promise((
|
|
14330
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(25, Math.ceil(remaining))));
|
|
14272
14331
|
}
|
|
14273
14332
|
}
|
|
14274
14333
|
var LockContentionError, LockOwnershipError;
|
|
@@ -14358,7 +14417,7 @@ async function acquirePoolLock(spec, defaults2, env3) {
|
|
|
14358
14417
|
});
|
|
14359
14418
|
}
|
|
14360
14419
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
14361
|
-
await new Promise((
|
|
14420
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(options.retryMs + jitter, remaining)));
|
|
14362
14421
|
}
|
|
14363
14422
|
}
|
|
14364
14423
|
function definedOnly(spec) {
|
|
@@ -17256,11 +17315,11 @@ var init_quota_writer = __esm({
|
|
|
17256
17315
|
const left = deadline - performance.now();
|
|
17257
17316
|
if (left <= 0)
|
|
17258
17317
|
throw refusal2("pull", id, "lock-contention", `pool quota queue for ${id} is full (${POOL_QUOTA_QUEUE_LIMIT} readings) and the store locks stayed held`, true);
|
|
17259
|
-
await new Promise((
|
|
17318
|
+
await new Promise((resolve31) => {
|
|
17260
17319
|
const done = () => {
|
|
17261
17320
|
clearTimeout(timer);
|
|
17262
17321
|
this.wake.delete(done);
|
|
17263
|
-
|
|
17322
|
+
resolve31();
|
|
17264
17323
|
};
|
|
17265
17324
|
const timer = setTimeout(done, left);
|
|
17266
17325
|
this.wake.add(done);
|
|
@@ -20324,7 +20383,7 @@ async function select(terminal, items, options) {
|
|
|
20324
20383
|
writeLine("");
|
|
20325
20384
|
renderedLines = lines;
|
|
20326
20385
|
};
|
|
20327
|
-
return new Promise((
|
|
20386
|
+
return new Promise((resolve31) => {
|
|
20328
20387
|
const wasRaw = stdin.isRaw ?? false;
|
|
20329
20388
|
const cleanup2 = () => {
|
|
20330
20389
|
if (cleaned)
|
|
@@ -20344,7 +20403,7 @@ async function select(terminal, items, options) {
|
|
|
20344
20403
|
};
|
|
20345
20404
|
const finish = (value) => {
|
|
20346
20405
|
cleanup2();
|
|
20347
|
-
|
|
20406
|
+
resolve31(value);
|
|
20348
20407
|
};
|
|
20349
20408
|
const onSignal = () => finish(null);
|
|
20350
20409
|
const onKey = (data) => {
|
|
@@ -20384,7 +20443,7 @@ async function select(terminal, items, options) {
|
|
|
20384
20443
|
stdin.setRawMode(true);
|
|
20385
20444
|
} catch {
|
|
20386
20445
|
cleanup2();
|
|
20387
|
-
|
|
20446
|
+
resolve31(null);
|
|
20388
20447
|
return;
|
|
20389
20448
|
}
|
|
20390
20449
|
stdin.resume();
|
|
@@ -22410,10 +22469,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
22410
22469
|
try {
|
|
22411
22470
|
await Promise.race([
|
|
22412
22471
|
drained,
|
|
22413
|
-
new Promise((
|
|
22472
|
+
new Promise((resolve31) => {
|
|
22414
22473
|
timer = setTimeout(() => {
|
|
22415
22474
|
expired = true;
|
|
22416
|
-
|
|
22475
|
+
resolve31();
|
|
22417
22476
|
}, 2e3);
|
|
22418
22477
|
})
|
|
22419
22478
|
]);
|
|
@@ -22686,7 +22745,7 @@ function grantReachOf(listed) {
|
|
|
22686
22745
|
tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
|
|
22687
22746
|
});
|
|
22688
22747
|
}
|
|
22689
|
-
var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
|
|
22748
|
+
var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, VAULT_RECEIPT_WAIT_MS, VAULT_YOUNG_OUTAGE_MS, ClaustrumScopedCustody;
|
|
22690
22749
|
var init_custody = __esm({
|
|
22691
22750
|
"../core/dist/common-auth-embedded/claustrum/custody.js"() {
|
|
22692
22751
|
"use strict";
|
|
@@ -22703,6 +22762,8 @@ var init_custody = __esm({
|
|
|
22703
22762
|
phaseDiagnostics = channel("common-auth.claustrum.phases");
|
|
22704
22763
|
SERVING_MARGIN_MS = 3e5;
|
|
22705
22764
|
KEPT_RECEIPT_MARGIN_MS = 6e4;
|
|
22765
|
+
VAULT_RECEIPT_WAIT_MS = 1e4;
|
|
22766
|
+
VAULT_YOUNG_OUTAGE_MS = 6e4;
|
|
22706
22767
|
ClaustrumScopedCustody = class {
|
|
22707
22768
|
#client;
|
|
22708
22769
|
#readToken;
|
|
@@ -22720,7 +22781,10 @@ var init_custody = __esm({
|
|
|
22720
22781
|
#setTimeout;
|
|
22721
22782
|
#clearTimeout;
|
|
22722
22783
|
#outage = false;
|
|
22784
|
+
#outageSince = 0;
|
|
22785
|
+
#outageWaitSpent = false;
|
|
22723
22786
|
#outageError = new ClaustrumUnreachableError();
|
|
22787
|
+
#receiptWaits = /* @__PURE__ */ new Map();
|
|
22724
22788
|
#probeTimer;
|
|
22725
22789
|
#probing = false;
|
|
22726
22790
|
#lastProbeAt = -Infinity;
|
|
@@ -22796,6 +22860,8 @@ var init_custody = __esm({
|
|
|
22796
22860
|
if (this.#closed || this.#outage)
|
|
22797
22861
|
return;
|
|
22798
22862
|
this.#outage = true;
|
|
22863
|
+
this.#outageSince = this.#now();
|
|
22864
|
+
this.#outageWaitSpent = false;
|
|
22799
22865
|
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22800
22866
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
22801
22867
|
this.#scheduleProbe();
|
|
@@ -23070,9 +23136,10 @@ var init_custody = __esm({
|
|
|
23070
23136
|
/** Ask the vault while reachable; retain one validated receipt in memory only. */
|
|
23071
23137
|
async authorize(identity4, signal, routeId = "vault") {
|
|
23072
23138
|
this.#check(signal);
|
|
23139
|
+
const startedAt = this.#now();
|
|
23073
23140
|
const { credentialId, credentialType, accountIdentity } = identity4;
|
|
23074
23141
|
let kept = this.#kept.get(credentialId);
|
|
23075
|
-
if (kept && (kept.attempt.credentialType !== credentialType || kept.attempt.expectedAccountIdentity !== accountIdentity)) {
|
|
23142
|
+
if (kept && (kept.attempt.credentialType !== credentialType || kept.attempt.expectedAccountIdentity !== accountIdentity || !this.#usable(kept.attempt))) {
|
|
23076
23143
|
this.forget(credentialId);
|
|
23077
23144
|
kept = void 0;
|
|
23078
23145
|
}
|
|
@@ -23089,7 +23156,18 @@ var init_custody = __esm({
|
|
|
23089
23156
|
return this.#serveKept(credentialId, kept, token, routeId);
|
|
23090
23157
|
}
|
|
23091
23158
|
try {
|
|
23092
|
-
|
|
23159
|
+
let attempt;
|
|
23160
|
+
try {
|
|
23161
|
+
const recovering = this.#outage && this.#receiptWaits.has(this.#receiptWaitKey({ credentialId, credentialType, accountIdentity }, token));
|
|
23162
|
+
if (recovering)
|
|
23163
|
+
throw this.#outageError;
|
|
23164
|
+
attempt = await this.#authorizeFresh({ credentialId, credentialType, accountIdentity }, token, signal);
|
|
23165
|
+
} catch (error) {
|
|
23166
|
+
this.#check(signal);
|
|
23167
|
+
if (classifyVaultFailure(error) !== "unreachable" || kept)
|
|
23168
|
+
throw error;
|
|
23169
|
+
attempt = await this.#waitForReceipt({ credentialId, credentialType, accountIdentity }, token, startedAt, error, signal);
|
|
23170
|
+
}
|
|
23093
23171
|
this.#kept.set(credentialId, { attempt, routeId, since: null });
|
|
23094
23172
|
this.#usageServed.set(credentialId, { ...identity4 });
|
|
23095
23173
|
return attempt;
|
|
@@ -23102,6 +23180,109 @@ var init_custody = __esm({
|
|
|
23102
23180
|
return this.#serveKept(credentialId, kept, token, routeId, error);
|
|
23103
23181
|
}
|
|
23104
23182
|
}
|
|
23183
|
+
#receiptWaitKey(identity4, token) {
|
|
23184
|
+
return JSON.stringify([
|
|
23185
|
+
identity4.credentialId,
|
|
23186
|
+
identity4.credentialType,
|
|
23187
|
+
identity4.accountIdentity,
|
|
23188
|
+
token
|
|
23189
|
+
]);
|
|
23190
|
+
}
|
|
23191
|
+
async #waitForReceipt(identity4, token, startedAt, error, signal) {
|
|
23192
|
+
const remaining = VAULT_RECEIPT_WAIT_MS - (this.#now() - startedAt);
|
|
23193
|
+
if (remaining <= 0 || this.#outageWaitSpent || this.#now() - this.#outageSince >= VAULT_YOUNG_OUTAGE_MS)
|
|
23194
|
+
throw error;
|
|
23195
|
+
const key = this.#receiptWaitKey(identity4, token);
|
|
23196
|
+
let wait2 = this.#receiptWaits.get(key);
|
|
23197
|
+
if (!wait2) {
|
|
23198
|
+
const controller = new AbortController();
|
|
23199
|
+
const created = {
|
|
23200
|
+
controller,
|
|
23201
|
+
users: 0,
|
|
23202
|
+
error,
|
|
23203
|
+
pending: Promise.resolve().then(async () => {
|
|
23204
|
+
let delay3 = 250;
|
|
23205
|
+
for (; ; ) {
|
|
23206
|
+
await this.#receiptBackoff(delay3, controller.signal);
|
|
23207
|
+
try {
|
|
23208
|
+
return await this.#authorizeFresh(identity4, token, controller.signal);
|
|
23209
|
+
} catch (failure2) {
|
|
23210
|
+
this.#check(controller.signal);
|
|
23211
|
+
if (classifyVaultFailure(failure2) !== "unreachable")
|
|
23212
|
+
throw failure2;
|
|
23213
|
+
created.error = failure2;
|
|
23214
|
+
delay3 = Math.min(delay3 * 2, 1e3);
|
|
23215
|
+
}
|
|
23216
|
+
}
|
|
23217
|
+
})
|
|
23218
|
+
};
|
|
23219
|
+
wait2 = created;
|
|
23220
|
+
this.#receiptWaits.set(key, wait2);
|
|
23221
|
+
const remove2 = () => {
|
|
23222
|
+
if (this.#receiptWaits.get(key) === created)
|
|
23223
|
+
this.#receiptWaits.delete(key);
|
|
23224
|
+
};
|
|
23225
|
+
void wait2.pending.then(remove2, remove2);
|
|
23226
|
+
}
|
|
23227
|
+
const shared3 = wait2;
|
|
23228
|
+
shared3.users++;
|
|
23229
|
+
let timer;
|
|
23230
|
+
let abort;
|
|
23231
|
+
try {
|
|
23232
|
+
const attempt = await Promise.race([
|
|
23233
|
+
shared3.pending,
|
|
23234
|
+
new Promise((_resolve, reject) => {
|
|
23235
|
+
timer = this.#setTimeout(() => {
|
|
23236
|
+
if (this.#outage)
|
|
23237
|
+
this.#outageWaitSpent = true;
|
|
23238
|
+
reject(shared3.error);
|
|
23239
|
+
}, remaining);
|
|
23240
|
+
timer.unref?.();
|
|
23241
|
+
if (signal) {
|
|
23242
|
+
abort = () => reject(signal.reason);
|
|
23243
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
23244
|
+
if (signal.aborted)
|
|
23245
|
+
abort();
|
|
23246
|
+
}
|
|
23247
|
+
})
|
|
23248
|
+
]);
|
|
23249
|
+
this.#check(signal);
|
|
23250
|
+
const receipt2 = Object.freeze(Object.defineProperty({ ...attempt }, "accessToken", {
|
|
23251
|
+
value: attempt.accessToken,
|
|
23252
|
+
enumerable: false
|
|
23253
|
+
}));
|
|
23254
|
+
this.#provenance.set(receipt2, { token });
|
|
23255
|
+
return receipt2;
|
|
23256
|
+
} finally {
|
|
23257
|
+
if (timer)
|
|
23258
|
+
this.#clearTimeout(timer);
|
|
23259
|
+
if (abort)
|
|
23260
|
+
signal?.removeEventListener("abort", abort);
|
|
23261
|
+
if (--shared3.users === 0) {
|
|
23262
|
+
shared3.controller.abort();
|
|
23263
|
+
if (this.#receiptWaits.get(key) === shared3)
|
|
23264
|
+
this.#receiptWaits.delete(key);
|
|
23265
|
+
}
|
|
23266
|
+
}
|
|
23267
|
+
}
|
|
23268
|
+
#receiptBackoff(delay3, signal) {
|
|
23269
|
+
this.#check(signal);
|
|
23270
|
+
return new Promise((resolve31, reject) => {
|
|
23271
|
+
const abort = () => {
|
|
23272
|
+
this.#clearTimeout(timer);
|
|
23273
|
+
signal.removeEventListener("abort", abort);
|
|
23274
|
+
reject(signal.reason);
|
|
23275
|
+
};
|
|
23276
|
+
const timer = this.#setTimeout(() => {
|
|
23277
|
+
signal.removeEventListener("abort", abort);
|
|
23278
|
+
resolve31();
|
|
23279
|
+
}, delay3);
|
|
23280
|
+
timer.unref?.();
|
|
23281
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
23282
|
+
if (signal.aborted)
|
|
23283
|
+
abort();
|
|
23284
|
+
});
|
|
23285
|
+
}
|
|
23105
23286
|
#serveKept(credentialId, kept, token, routeId, error = this.#outageError) {
|
|
23106
23287
|
if (!kept || this.#kept.get(credentialId) !== kept || !this.#usable(kept.attempt)) {
|
|
23107
23288
|
this.forget(credentialId);
|
|
@@ -23327,6 +23508,9 @@ var init_custody = __esm({
|
|
|
23327
23508
|
if (this.#closed)
|
|
23328
23509
|
return;
|
|
23329
23510
|
this.#closed = true;
|
|
23511
|
+
for (const wait2 of this.#receiptWaits.values())
|
|
23512
|
+
wait2.controller.abort();
|
|
23513
|
+
this.#receiptWaits.clear();
|
|
23330
23514
|
if (this.#probeTimer)
|
|
23331
23515
|
this.#clearTimeout(this.#probeTimer);
|
|
23332
23516
|
this.#probeTimer = void 0;
|
|
@@ -24327,7 +24511,7 @@ var init_consumer = __esm({
|
|
|
24327
24511
|
this.#shutdown.signal,
|
|
24328
24512
|
...signal ? [signal] : []
|
|
24329
24513
|
]);
|
|
24330
|
-
return new Promise((
|
|
24514
|
+
return new Promise((resolve31, reject) => {
|
|
24331
24515
|
const cleanup2 = () => {
|
|
24332
24516
|
combined.signal.removeEventListener("abort", abort);
|
|
24333
24517
|
combined.dispose();
|
|
@@ -24342,7 +24526,7 @@ var init_consumer = __esm({
|
|
|
24342
24526
|
if (combined.signal.aborted)
|
|
24343
24527
|
reject(combined.signal.reason);
|
|
24344
24528
|
else
|
|
24345
|
-
|
|
24529
|
+
resolve31(value);
|
|
24346
24530
|
}, (error) => {
|
|
24347
24531
|
cleanup2();
|
|
24348
24532
|
reject(error);
|
|
@@ -25148,12 +25332,12 @@ function unreachableConnect2() {
|
|
|
25148
25332
|
return new ClaustrumUnreachableError();
|
|
25149
25333
|
}
|
|
25150
25334
|
function untilAborted(pending, signal) {
|
|
25151
|
-
return new Promise((
|
|
25335
|
+
return new Promise((resolve31, reject) => {
|
|
25152
25336
|
const abort = () => reject(signal.reason);
|
|
25153
25337
|
signal.addEventListener("abort", abort, { once: true });
|
|
25154
25338
|
pending.then((value) => {
|
|
25155
25339
|
signal.removeEventListener("abort", abort);
|
|
25156
|
-
|
|
25340
|
+
resolve31(value);
|
|
25157
25341
|
}, (error) => {
|
|
25158
25342
|
signal.removeEventListener("abort", abort);
|
|
25159
25343
|
reject(error);
|
|
@@ -25200,6 +25384,13 @@ var init_hub = __esm({
|
|
|
25200
25384
|
#own;
|
|
25201
25385
|
#watch;
|
|
25202
25386
|
#run;
|
|
25387
|
+
/**
|
|
25388
|
+
* Member commit fan-outs still running, each until every one of its
|
|
25389
|
+
* commits has settled. Only a run whose generation ended can leave one
|
|
25390
|
+
* behind while another run starts; `#discover` waits for them before it
|
|
25391
|
+
* reads the files it lists over.
|
|
25392
|
+
*/
|
|
25393
|
+
#fanOuts = /* @__PURE__ */ new Set();
|
|
25203
25394
|
/** The hub's last authority read; undefined before the first one. */
|
|
25204
25395
|
#active;
|
|
25205
25396
|
/** Counts inactive transitions, so local work started before one stops. */
|
|
@@ -25673,6 +25864,9 @@ var init_hub = __esm({
|
|
|
25673
25864
|
if (!this.#live(generation))
|
|
25674
25865
|
return void 0;
|
|
25675
25866
|
const folders = await this.#ensureRosterDirectories().then(() => void 0, (error) => error instanceof Error ? error : new Error(String(error)));
|
|
25867
|
+
await this.#settleFanOuts();
|
|
25868
|
+
if (!this.#live(generation))
|
|
25869
|
+
return void 0;
|
|
25676
25870
|
const bases = new Map(await Promise.all([...this.#members.values()].map(async (entry) => [
|
|
25677
25871
|
entry,
|
|
25678
25872
|
await readVaultRoster(entry.path).then((file) => file ? { file } : {}, (error) => error instanceof Error ? error : new Error(String(error)))
|
|
@@ -25693,7 +25887,14 @@ var init_hub = __esm({
|
|
|
25693
25887
|
if (!this.#live(generation))
|
|
25694
25888
|
return void 0;
|
|
25695
25889
|
const members = this.#open();
|
|
25696
|
-
const
|
|
25890
|
+
const fanOut = Promise.all(members.map((entry) => entry.hooks && !entry.closed ? this.#commit(entry, entry.hooks, inventory, folders ?? bases.get(entry), generation) : void 0));
|
|
25891
|
+
this.#fanOuts.add(fanOut);
|
|
25892
|
+
let commits;
|
|
25893
|
+
try {
|
|
25894
|
+
commits = await fanOut;
|
|
25895
|
+
} finally {
|
|
25896
|
+
this.#fanOuts.delete(fanOut);
|
|
25897
|
+
}
|
|
25697
25898
|
if (!this.#live(generation))
|
|
25698
25899
|
return void 0;
|
|
25699
25900
|
const errors = /* @__PURE__ */ new Map();
|
|
@@ -25794,6 +25995,27 @@ var init_hub = __esm({
|
|
|
25794
25995
|
return { error };
|
|
25795
25996
|
}
|
|
25796
25997
|
}
|
|
25998
|
+
/**
|
|
25999
|
+
* Wait until no member commit fan-out of an earlier run is still running.
|
|
26000
|
+
* Each of them belongs to a generation that ended, so its commits fail or
|
|
26001
|
+
* finish at their next generation check and this wait stays short.
|
|
26002
|
+
*/
|
|
26003
|
+
async #settleFanOuts() {
|
|
26004
|
+
if (!this.#fanOuts.size)
|
|
26005
|
+
return;
|
|
26006
|
+
const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
|
|
26007
|
+
const phase = (name) => {
|
|
26008
|
+
if (phaseDiagnostics2.hasSubscribers)
|
|
26009
|
+
phaseDiagnostics2.publish({ logger: this.#logger, phase: name });
|
|
26010
|
+
};
|
|
26011
|
+
phase("earlier fan-out drain begin");
|
|
26012
|
+
try {
|
|
26013
|
+
while (this.#fanOuts.size)
|
|
26014
|
+
await Promise.allSettled([...this.#fanOuts]);
|
|
26015
|
+
} finally {
|
|
26016
|
+
phase("earlier fan-out drain end");
|
|
26017
|
+
}
|
|
26018
|
+
}
|
|
25797
26019
|
/**
|
|
25798
26020
|
* Create the roster folders under the state folder (`rosters`, this host
|
|
25799
26021
|
* generation and this key) owner-only, as every other Claustrum private
|
|
@@ -26106,6 +26328,8 @@ __export(claustrum_exports, {
|
|
|
26106
26328
|
VAULT_FAILURE_CLASSES: () => VAULT_FAILURE_CLASSES,
|
|
26107
26329
|
VAULT_HOST_CONNECT_REFUSAL: () => VAULT_HOST_CONNECT_REFUSAL,
|
|
26108
26330
|
VAULT_HOST_STATUS: () => VAULT_HOST_STATUS,
|
|
26331
|
+
VAULT_RECEIPT_WAIT_MS: () => VAULT_RECEIPT_WAIT_MS,
|
|
26332
|
+
VAULT_YOUNG_OUTAGE_MS: () => VAULT_YOUNG_OUTAGE_MS,
|
|
26109
26333
|
WATCH_RETRY_MS: () => WATCH_RETRY_MS,
|
|
26110
26334
|
acceptAccount: () => acceptAccount,
|
|
26111
26335
|
acceptVaultRoute: () => acceptVaultRoute,
|
|
@@ -27228,8 +27452,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
27228
27452
|
return allowedTiers[0]?.id;
|
|
27229
27453
|
}
|
|
27230
27454
|
function wait(ms) {
|
|
27231
|
-
return new Promise((
|
|
27232
|
-
setTimeout(
|
|
27455
|
+
return new Promise((resolve31) => {
|
|
27456
|
+
setTimeout(resolve31, ms);
|
|
27233
27457
|
});
|
|
27234
27458
|
}
|
|
27235
27459
|
function extractManagedProjectId(payload) {
|
|
@@ -28039,7 +28263,7 @@ var init_quota_manager = __esm({
|
|
|
28039
28263
|
});
|
|
28040
28264
|
|
|
28041
28265
|
// ../core/dist/transform/agy-generation.js
|
|
28042
|
-
function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
28266
|
+
function applyAgyNativeGenerationConfig(wireModel, generationConfig, options = {}) {
|
|
28043
28267
|
const native = getAgyNativeModel(wireModel);
|
|
28044
28268
|
if (!native)
|
|
28045
28269
|
return;
|
|
@@ -28048,7 +28272,21 @@ function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
|
28048
28272
|
generationConfig.maxOutputTokens = output2;
|
|
28049
28273
|
}
|
|
28050
28274
|
delete generationConfig.max_output_tokens;
|
|
28051
|
-
|
|
28275
|
+
const capturedTier = /^(?:gemini-3\.8-flash|claude-(?:sonnet|opus)-5-5)-(low|medium|high)$/i.exec(wireModel)?.[1];
|
|
28276
|
+
if (capturedTier) {
|
|
28277
|
+
const thinking = generationConfig.thinkingConfig;
|
|
28278
|
+
const budget = options.thinkingBudget ?? (options.preserveThinkingBudget === false ? void 0 : thinking?.thinkingBudget);
|
|
28279
|
+
generationConfig.thinkingConfig = {
|
|
28280
|
+
includeThoughts: true,
|
|
28281
|
+
...typeof budget === "number" ? { thinkingBudget: budget } : { thinkingLevel: capturedTier.toUpperCase() }
|
|
28282
|
+
};
|
|
28283
|
+
} else if (isGeminiHydrogenModel(wireModel)) {
|
|
28284
|
+
const tier = wireModel.toLowerCase().split("-").at(-1);
|
|
28285
|
+
generationConfig.thinkingConfig = {
|
|
28286
|
+
includeThoughts: true,
|
|
28287
|
+
thinkingLevel: tier === "xhigh" ? 100 : tier === "low" ? "LOW" : tier === "medium" ? "MEDIUM" : "HIGH"
|
|
28288
|
+
};
|
|
28289
|
+
} else if ((isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel)) && native.thinkingLevel !== void 0) {
|
|
28052
28290
|
generationConfig.thinkingConfig = {
|
|
28053
28291
|
includeThoughts: true,
|
|
28054
28292
|
thinkingLevel: ADAPTIVE_LEVELS[native.thinkingLevel]
|
|
@@ -28597,7 +28835,9 @@ function wrapToolsAsFunctionDeclarations(payload) {
|
|
|
28597
28835
|
}
|
|
28598
28836
|
const finalTools = [];
|
|
28599
28837
|
if (functionDeclarations.length > 0) {
|
|
28600
|
-
finalTools.push(
|
|
28838
|
+
finalTools.push(...functionDeclarations.map((declaration) => ({
|
|
28839
|
+
functionDeclarations: [declaration]
|
|
28840
|
+
})));
|
|
28601
28841
|
}
|
|
28602
28842
|
finalTools.push(...passthroughTools);
|
|
28603
28843
|
if (hasWebSearchTool && functionDeclarations.length === 0) {
|
|
@@ -28863,6 +29103,15 @@ function getAgyGemini31ProThinkingBudget(tier) {
|
|
|
28863
29103
|
function resolveModelWithTier(requestedModel) {
|
|
28864
29104
|
const isAntigravity = QUOTA_PREFIX_REGEX.test(requestedModel);
|
|
28865
29105
|
const modelWithoutQuota = requestedModel.replace(QUOTA_PREFIX_REGEX, "");
|
|
29106
|
+
if (isGeminiHydrogenModel(modelWithoutQuota)) {
|
|
29107
|
+
const tier2 = modelWithoutQuota.toLowerCase().match(HYDROGEN_TIER_REGEX)?.[1];
|
|
29108
|
+
return {
|
|
29109
|
+
actualModel: getGeminiHydrogenAntigravityModel(tier2),
|
|
29110
|
+
thinkingLevel: tier2 ?? "high",
|
|
29111
|
+
tier: tier2 ?? "high",
|
|
29112
|
+
isThinkingModel: true
|
|
29113
|
+
};
|
|
29114
|
+
}
|
|
28866
29115
|
const tier = extractThinkingTierFromModel(modelWithoutQuota);
|
|
28867
29116
|
const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
|
|
28868
29117
|
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
@@ -29035,7 +29284,7 @@ function resolveAntigravityModel(requestedModel) {
|
|
|
29035
29284
|
const prefixedModel = `antigravity-${transformedModel}`;
|
|
29036
29285
|
return resolveModelWithTier(prefixedModel);
|
|
29037
29286
|
}
|
|
29038
|
-
var THINKING_TIER_BUDGETS, MODEL_ALIASES, TIER_REGEX, QUOTA_PREFIX_REGEX, GEMINI_3_PRO_REGEX, GEMINI_3_FLASH_REGEX, IMAGE_GENERATION_MODELS;
|
|
29287
|
+
var THINKING_TIER_BUDGETS, MODEL_ALIASES, TIER_REGEX, HYDROGEN_TIER_REGEX, QUOTA_PREFIX_REGEX, GEMINI_3_PRO_REGEX, GEMINI_3_FLASH_REGEX, IMAGE_GENERATION_MODELS;
|
|
29039
29288
|
var init_model_resolver = __esm({
|
|
29040
29289
|
"../core/dist/transform/model-resolver.js"() {
|
|
29041
29290
|
"use strict";
|
|
@@ -29048,6 +29297,7 @@ var init_model_resolver = __esm({
|
|
|
29048
29297
|
};
|
|
29049
29298
|
MODEL_ALIASES = getResolverAliasMap();
|
|
29050
29299
|
TIER_REGEX = /-(minimal|low|medium|high)$/;
|
|
29300
|
+
HYDROGEN_TIER_REGEX = /-(low|medium|high|xhigh)$/i;
|
|
29051
29301
|
QUOTA_PREFIX_REGEX = /^antigravity-/i;
|
|
29052
29302
|
GEMINI_3_PRO_REGEX = /^gemini-3(?:\.\d+)?-pro/i;
|
|
29053
29303
|
GEMINI_3_FLASH_REGEX = /^gemini-3(?:\.\d+)?-flash/i;
|
|
@@ -29552,12 +29802,12 @@ var init_vault_provider_state = __esm({
|
|
|
29552
29802
|
function untilAborted2(pending, signal) {
|
|
29553
29803
|
if (!signal)
|
|
29554
29804
|
return pending;
|
|
29555
|
-
return new Promise((
|
|
29805
|
+
return new Promise((resolve31, reject) => {
|
|
29556
29806
|
const abort = () => reject(signal.reason);
|
|
29557
29807
|
signal.addEventListener("abort", abort, { once: true });
|
|
29558
29808
|
if (signal.aborted)
|
|
29559
29809
|
abort();
|
|
29560
|
-
pending.then(
|
|
29810
|
+
pending.then(resolve31, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
29561
29811
|
});
|
|
29562
29812
|
}
|
|
29563
29813
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -31059,12 +31309,12 @@ function createVaultAccountPool(options) {
|
|
|
31059
31309
|
try {
|
|
31060
31310
|
return await Promise.race([
|
|
31061
31311
|
read.then(() => true),
|
|
31062
|
-
new Promise((
|
|
31312
|
+
new Promise((resolve31, reject) => {
|
|
31063
31313
|
const abort = () => reject(signal?.reason);
|
|
31064
31314
|
signal?.addEventListener("abort", abort, { once: true });
|
|
31065
31315
|
detachAbort = () => signal?.removeEventListener("abort", abort);
|
|
31066
31316
|
if (remaining !== void 0)
|
|
31067
|
-
cancelTimer2 = schedule2(() =>
|
|
31317
|
+
cancelTimer2 = schedule2(() => resolve31(false), remaining);
|
|
31068
31318
|
if (signal?.aborted) abort();
|
|
31069
31319
|
})
|
|
31070
31320
|
]);
|
|
@@ -31569,11 +31819,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31569
31819
|
].join("\n");
|
|
31570
31820
|
const waitForApproval = async () => {
|
|
31571
31821
|
while (!closed2) {
|
|
31572
|
-
await new Promise((
|
|
31822
|
+
await new Promise((resolve31) => {
|
|
31573
31823
|
const done = () => {
|
|
31574
31824
|
clearTimeout(timer);
|
|
31575
31825
|
cancelWait = void 0;
|
|
31576
|
-
|
|
31826
|
+
resolve31();
|
|
31577
31827
|
};
|
|
31578
31828
|
const timer = setTimeout(done, 2e3);
|
|
31579
31829
|
timer.unref?.();
|
|
@@ -34655,13 +34905,13 @@ function closeDebugStream(state) {
|
|
|
34655
34905
|
state.logWriter = () => {
|
|
34656
34906
|
};
|
|
34657
34907
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34658
|
-
return new Promise((
|
|
34659
|
-
current.once("close", () =>
|
|
34660
|
-
current.once("error", () =>
|
|
34908
|
+
return new Promise((resolve31) => {
|
|
34909
|
+
current.once("close", () => resolve31());
|
|
34910
|
+
current.once("error", () => resolve31());
|
|
34661
34911
|
try {
|
|
34662
34912
|
current.end();
|
|
34663
34913
|
} catch {
|
|
34664
|
-
|
|
34914
|
+
resolve31();
|
|
34665
34915
|
}
|
|
34666
34916
|
});
|
|
34667
34917
|
}
|
|
@@ -34926,13 +35176,13 @@ function closeDebugLog() {
|
|
|
34926
35176
|
if (!state || !current) return Promise.resolve();
|
|
34927
35177
|
state.logStream = null;
|
|
34928
35178
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34929
|
-
return new Promise((
|
|
34930
|
-
current.once("close", () =>
|
|
34931
|
-
current.once("error", () =>
|
|
35179
|
+
return new Promise((resolve31) => {
|
|
35180
|
+
current.once("close", () => resolve31());
|
|
35181
|
+
current.once("error", () => resolve31());
|
|
34932
35182
|
try {
|
|
34933
35183
|
current.end();
|
|
34934
35184
|
} catch {
|
|
34935
|
-
|
|
35185
|
+
resolve31();
|
|
34936
35186
|
}
|
|
34937
35187
|
});
|
|
34938
35188
|
}
|
|
@@ -35154,8 +35404,8 @@ var init_logger4 = __esm({
|
|
|
35154
35404
|
|
|
35155
35405
|
// src/plugin/index.ts
|
|
35156
35406
|
init_dist();
|
|
35157
|
-
import { createHash as createHash24, randomUUID as
|
|
35158
|
-
import { join as join46, resolve as
|
|
35407
|
+
import { createHash as createHash24, randomUUID as randomUUID25 } from "node:crypto";
|
|
35408
|
+
import { join as join46, resolve as resolve30 } from "node:path";
|
|
35159
35409
|
|
|
35160
35410
|
// src/cli.ts
|
|
35161
35411
|
init_dist();
|
|
@@ -35812,7 +36062,7 @@ function drainSidebarWrites() {
|
|
|
35812
36062
|
return sidebarWriteChain;
|
|
35813
36063
|
}
|
|
35814
36064
|
async function sleep3(ms) {
|
|
35815
|
-
await new Promise((
|
|
36065
|
+
await new Promise((resolve31) => setTimeout(resolve31, ms));
|
|
35816
36066
|
}
|
|
35817
36067
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
35818
36068
|
const start = Date.now();
|
|
@@ -36664,14 +36914,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
36664
36914
|
name = "LocalQuotaGrantStaleError";
|
|
36665
36915
|
};
|
|
36666
36916
|
function untilQuotaAborted(pending, signal) {
|
|
36667
|
-
return new Promise((
|
|
36917
|
+
return new Promise((resolve31, reject) => {
|
|
36668
36918
|
const abort = () => reject(signal.reason);
|
|
36669
36919
|
if (signal.aborted) abort();
|
|
36670
36920
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36671
36921
|
void pending.then(
|
|
36672
36922
|
(value) => {
|
|
36673
36923
|
signal.removeEventListener("abort", abort);
|
|
36674
|
-
|
|
36924
|
+
resolve31(value);
|
|
36675
36925
|
},
|
|
36676
36926
|
(error) => {
|
|
36677
36927
|
signal.removeEventListener("abort", abort);
|
|
@@ -37292,12 +37542,12 @@ async function startOAuthListener({
|
|
|
37292
37542
|
let resolveCallback;
|
|
37293
37543
|
let rejectCallback;
|
|
37294
37544
|
let timeoutHandle;
|
|
37295
|
-
const callbackPromise = new Promise((
|
|
37545
|
+
const callbackPromise = new Promise((resolve31, reject) => {
|
|
37296
37546
|
resolveCallback = (url) => {
|
|
37297
37547
|
if (settled) return;
|
|
37298
37548
|
settled = true;
|
|
37299
37549
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
37300
|
-
|
|
37550
|
+
resolve31(url);
|
|
37301
37551
|
};
|
|
37302
37552
|
rejectCallback = (error) => {
|
|
37303
37553
|
if (settled) return;
|
|
@@ -37456,7 +37706,7 @@ async function startOAuthListener({
|
|
|
37456
37706
|
});
|
|
37457
37707
|
});
|
|
37458
37708
|
const bindAddress = getBindAddress();
|
|
37459
|
-
await new Promise((
|
|
37709
|
+
await new Promise((resolve31, reject) => {
|
|
37460
37710
|
const handleError = (error) => {
|
|
37461
37711
|
server.off("error", handleError);
|
|
37462
37712
|
if (error.code === "EADDRINUSE") {
|
|
@@ -37472,7 +37722,7 @@ async function startOAuthListener({
|
|
|
37472
37722
|
server.once("error", handleError);
|
|
37473
37723
|
server.listen(port, bindAddress, () => {
|
|
37474
37724
|
server.off("error", handleError);
|
|
37475
|
-
|
|
37725
|
+
resolve31();
|
|
37476
37726
|
});
|
|
37477
37727
|
});
|
|
37478
37728
|
server.on("error", (error) => {
|
|
@@ -37480,7 +37730,7 @@ async function startOAuthListener({
|
|
|
37480
37730
|
});
|
|
37481
37731
|
return {
|
|
37482
37732
|
waitForCallback: () => callbackPromise,
|
|
37483
|
-
close: () => new Promise((
|
|
37733
|
+
close: () => new Promise((resolve31, reject) => {
|
|
37484
37734
|
server.close((error) => {
|
|
37485
37735
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
37486
37736
|
reject(error);
|
|
@@ -37489,7 +37739,7 @@ async function startOAuthListener({
|
|
|
37489
37739
|
if (!settled) {
|
|
37490
37740
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
37491
37741
|
}
|
|
37492
|
-
|
|
37742
|
+
resolve31();
|
|
37493
37743
|
});
|
|
37494
37744
|
})
|
|
37495
37745
|
};
|
|
@@ -37681,7 +37931,7 @@ async function select2(terminal, items, options) {
|
|
|
37681
37931
|
writeLine("");
|
|
37682
37932
|
renderedLines = lines;
|
|
37683
37933
|
};
|
|
37684
|
-
return new Promise((
|
|
37934
|
+
return new Promise((resolve31) => {
|
|
37685
37935
|
const wasRaw = stdin.isRaw ?? false;
|
|
37686
37936
|
const cleanup2 = () => {
|
|
37687
37937
|
if (cleaned)
|
|
@@ -37701,7 +37951,7 @@ async function select2(terminal, items, options) {
|
|
|
37701
37951
|
};
|
|
37702
37952
|
const finish = (value) => {
|
|
37703
37953
|
cleanup2();
|
|
37704
|
-
|
|
37954
|
+
resolve31(value);
|
|
37705
37955
|
};
|
|
37706
37956
|
const onSignal = () => finish(null);
|
|
37707
37957
|
const onKey = (data) => {
|
|
@@ -37741,7 +37991,7 @@ async function select2(terminal, items, options) {
|
|
|
37741
37991
|
stdin.setRawMode(true);
|
|
37742
37992
|
} catch {
|
|
37743
37993
|
cleanup2();
|
|
37744
|
-
|
|
37994
|
+
resolve31(null);
|
|
37745
37995
|
return;
|
|
37746
37996
|
}
|
|
37747
37997
|
stdin.resume();
|
|
@@ -38053,8 +38303,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38053
38303
|
let releaseConfirmed = false;
|
|
38054
38304
|
let loss;
|
|
38055
38305
|
let resolveLoss;
|
|
38056
|
-
const lostPromise = new Promise((
|
|
38057
|
-
resolveLoss =
|
|
38306
|
+
const lostPromise = new Promise((resolve31) => {
|
|
38307
|
+
resolveLoss = resolve31;
|
|
38058
38308
|
});
|
|
38059
38309
|
function notifyTimerStep(event) {
|
|
38060
38310
|
try {
|
|
@@ -38218,7 +38468,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38218
38468
|
}
|
|
38219
38469
|
}
|
|
38220
38470
|
async function backoff() {
|
|
38221
|
-
await new Promise((
|
|
38471
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.floor(Math.random() * 4)));
|
|
38222
38472
|
}
|
|
38223
38473
|
async function readLockState(notifyReady = true) {
|
|
38224
38474
|
if (notifyReady && options.onStep)
|
|
@@ -38311,7 +38561,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38311
38561
|
const remainingMs = deadline - performance.now();
|
|
38312
38562
|
if (remainingMs <= 0)
|
|
38313
38563
|
throw original;
|
|
38314
|
-
await new Promise((
|
|
38564
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
38315
38565
|
if (performance.now() >= deadline)
|
|
38316
38566
|
throw original;
|
|
38317
38567
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -38814,7 +39064,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38814
39064
|
const remainingMs = deadline - performance.now();
|
|
38815
39065
|
if (remainingMs <= 0)
|
|
38816
39066
|
break;
|
|
38817
|
-
await new Promise((
|
|
39067
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
38818
39068
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
38819
39069
|
break;
|
|
38820
39070
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -39695,7 +39945,7 @@ var ByteTail = class {
|
|
|
39695
39945
|
};
|
|
39696
39946
|
var defaultCommandRunner = {
|
|
39697
39947
|
run(file, args, options = {}) {
|
|
39698
|
-
return new Promise((
|
|
39948
|
+
return new Promise((resolve31) => {
|
|
39699
39949
|
const started = performance.now();
|
|
39700
39950
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
39701
39951
|
const stderr = new ByteTail();
|
|
@@ -39713,7 +39963,7 @@ var defaultCommandRunner = {
|
|
|
39713
39963
|
stdio: ["ignore", "pipe", "pipe"]
|
|
39714
39964
|
});
|
|
39715
39965
|
} catch {
|
|
39716
|
-
|
|
39966
|
+
resolve31({
|
|
39717
39967
|
exitCode: 1,
|
|
39718
39968
|
stdout: "",
|
|
39719
39969
|
stderr: "",
|
|
@@ -39748,7 +39998,7 @@ var defaultCommandRunner = {
|
|
|
39748
39998
|
settled = true;
|
|
39749
39999
|
if (timer)
|
|
39750
40000
|
clearTimeout(timer);
|
|
39751
|
-
|
|
40001
|
+
resolve31({
|
|
39752
40002
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
39753
40003
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
39754
40004
|
stderr: stderr.toString(),
|
|
@@ -42956,7 +43206,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
42956
43206
|
}
|
|
42957
43207
|
};
|
|
42958
43208
|
function readBody(req) {
|
|
42959
|
-
return new Promise((
|
|
43209
|
+
return new Promise((resolve31, reject) => {
|
|
42960
43210
|
const tooLarge = (declaredOversize = false) => {
|
|
42961
43211
|
req.removeAllListeners("data");
|
|
42962
43212
|
req.on("data", () => {
|
|
@@ -42979,7 +43229,7 @@ function readBody(req) {
|
|
|
42979
43229
|
}
|
|
42980
43230
|
chunks.push(chunk);
|
|
42981
43231
|
});
|
|
42982
|
-
req.on("end", () =>
|
|
43232
|
+
req.on("end", () => resolve31(Buffer.concat(chunks).toString("utf8")));
|
|
42983
43233
|
req.on("error", reject);
|
|
42984
43234
|
});
|
|
42985
43235
|
}
|
|
@@ -43158,12 +43408,12 @@ async function startRpcServer(options) {
|
|
|
43158
43408
|
json(500, { error: "internal error" });
|
|
43159
43409
|
}
|
|
43160
43410
|
}
|
|
43161
|
-
const port = await new Promise((
|
|
43411
|
+
const port = await new Promise((resolve31, reject) => {
|
|
43162
43412
|
server.on("error", reject);
|
|
43163
43413
|
server.listen(0, "127.0.0.1", () => {
|
|
43164
43414
|
const addr = server.address();
|
|
43165
43415
|
if (addr && typeof addr === "object")
|
|
43166
|
-
|
|
43416
|
+
resolve31(addr.port);
|
|
43167
43417
|
else
|
|
43168
43418
|
reject(new Error("no port"));
|
|
43169
43419
|
});
|
|
@@ -43186,16 +43436,16 @@ async function startRpcServer(options) {
|
|
|
43186
43436
|
rpcPort: port
|
|
43187
43437
|
});
|
|
43188
43438
|
} catch (error) {
|
|
43189
|
-
await new Promise((
|
|
43439
|
+
await new Promise((resolve31) => server.close(() => resolve31()));
|
|
43190
43440
|
throw error;
|
|
43191
43441
|
}
|
|
43192
43442
|
return {
|
|
43193
43443
|
port,
|
|
43194
43444
|
token,
|
|
43195
43445
|
async stop() {
|
|
43196
|
-
await new Promise((
|
|
43446
|
+
await new Promise((resolve31) => {
|
|
43197
43447
|
server.closeAllConnections?.();
|
|
43198
|
-
server.close(() =>
|
|
43448
|
+
server.close(() => resolve31());
|
|
43199
43449
|
for (const socket of connections)
|
|
43200
43450
|
socket.destroy();
|
|
43201
43451
|
});
|
|
@@ -44593,7 +44843,10 @@ function descriptorAtPath(descriptor, path5) {
|
|
|
44593
44843
|
}
|
|
44594
44844
|
return current;
|
|
44595
44845
|
}
|
|
44596
|
-
function destination(declaration, setting, value, { host, model }) {
|
|
44846
|
+
function destination(declaration, setting, value, { host, model }, level) {
|
|
44847
|
+
if (level !== void 0) {
|
|
44848
|
+
return level === "default" && !isJsonObject(value) ? [setting] : [setting, level];
|
|
44849
|
+
}
|
|
44597
44850
|
if (declaration.overrides !== void 0 && isJsonObject(value)) {
|
|
44598
44851
|
if (declaration.overrides.model && model !== void 0 && model !== "default" && model !== "opencode" && model !== "pi" && Object.hasOwn(value, model)) {
|
|
44599
44852
|
return [setting, model];
|
|
@@ -44623,6 +44876,19 @@ function checkPath(parsed, path5) {
|
|
|
44623
44876
|
invalid();
|
|
44624
44877
|
}
|
|
44625
44878
|
}
|
|
44879
|
+
function preservePlainDefault(parsed, setting) {
|
|
44880
|
+
const node = parsed.tree && findNodeAtLocation2(parsed.tree, [setting]);
|
|
44881
|
+
if (!node)
|
|
44882
|
+
invalid();
|
|
44883
|
+
const value = parsed.text.slice(node.offset, node.offset + node.length);
|
|
44884
|
+
return parseForEdit(applyEdits2(parsed.text, [
|
|
44885
|
+
{
|
|
44886
|
+
offset: node.offset,
|
|
44887
|
+
length: node.length,
|
|
44888
|
+
content: `{ "default": ${value} }`
|
|
44889
|
+
}
|
|
44890
|
+
]));
|
|
44891
|
+
}
|
|
44626
44892
|
function removeMember(text2, tree, path5) {
|
|
44627
44893
|
const property = tree && findNodeAtLocation2(tree, path5)?.parent;
|
|
44628
44894
|
const parent = property?.parent;
|
|
@@ -44696,6 +44962,16 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
44696
44962
|
if (!Object.hasOwn(definition.settings, edit.setting))
|
|
44697
44963
|
invalid();
|
|
44698
44964
|
const declaration = definition.settings[edit.setting];
|
|
44965
|
+
if (edit.level !== void 0) {
|
|
44966
|
+
if (edit.path !== void 0)
|
|
44967
|
+
invalid();
|
|
44968
|
+
if (edit.level === "default") {
|
|
44969
|
+
if (declaration.overrides === void 0)
|
|
44970
|
+
invalid();
|
|
44971
|
+
} else if (edit.level !== "opencode" && edit.level !== "pi" || !declaration.overrides?.host) {
|
|
44972
|
+
invalid();
|
|
44973
|
+
}
|
|
44974
|
+
}
|
|
44699
44975
|
if (edit.path !== void 0 && declaration.value.kind !== "object" && declaration.value.kind !== "record")
|
|
44700
44976
|
invalid();
|
|
44701
44977
|
const descriptor = descriptorAtPath(declaration.value, edit.path ?? []);
|
|
@@ -44707,7 +44983,19 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
44707
44983
|
const units = [];
|
|
44708
44984
|
for (const edit of edits) {
|
|
44709
44985
|
const declaration = definition.settings[edit.setting];
|
|
44710
|
-
|
|
44986
|
+
if (edit.level !== void 0 && edit.level !== "default" && !isJsonObject(working.value[edit.setting])) {
|
|
44987
|
+
if (edit.remove === true)
|
|
44988
|
+
continue;
|
|
44989
|
+
if (Object.hasOwn(working.value, edit.setting)) {
|
|
44990
|
+
working = preservePlainDefault(working, edit.setting);
|
|
44991
|
+
}
|
|
44992
|
+
for (const unit of units) {
|
|
44993
|
+
if (unit.path.length === 1 && unit.path[0] === edit.setting) {
|
|
44994
|
+
unit.path.push("default");
|
|
44995
|
+
}
|
|
44996
|
+
}
|
|
44997
|
+
}
|
|
44998
|
+
const base = edit.path !== void 0 ? [edit.setting] : destination(declaration, edit.setting, working.value[edit.setting], context, edit.level);
|
|
44711
44999
|
const path5 = [...base, ...edit.path ?? []];
|
|
44712
45000
|
checkPath(working, path5);
|
|
44713
45001
|
units.push(resolutionUnit(declaration.value, base, edit.path ?? []));
|
|
@@ -44860,18 +45148,20 @@ async function writeTarget(file) {
|
|
|
44860
45148
|
} catch (error) {
|
|
44861
45149
|
if (error.code !== "ENOENT")
|
|
44862
45150
|
unavailable(file, error);
|
|
45151
|
+
let isSymlink = false;
|
|
44863
45152
|
try {
|
|
44864
|
-
await SettingsFs.lstat(file);
|
|
45153
|
+
isSymlink = (await SettingsFs.lstat(file)).isSymbolicLink();
|
|
44865
45154
|
} catch (lstatError) {
|
|
44866
45155
|
if (lstatError.code !== "ENOENT")
|
|
44867
45156
|
unavailable(file, lstatError);
|
|
44868
|
-
try {
|
|
44869
|
-
return join32(await SettingsFs.realpath(dirname24(file)), basename10(file));
|
|
44870
|
-
} catch (parentError) {
|
|
44871
|
-
unavailable(file, parentError);
|
|
44872
|
-
}
|
|
44873
45157
|
}
|
|
44874
|
-
|
|
45158
|
+
if (isSymlink)
|
|
45159
|
+
unavailable(file, error);
|
|
45160
|
+
try {
|
|
45161
|
+
return join32(await SettingsFs.realpath(dirname24(file)), basename10(file));
|
|
45162
|
+
} catch (parentError) {
|
|
45163
|
+
unavailable(file, parentError);
|
|
45164
|
+
}
|
|
44875
45165
|
}
|
|
44876
45166
|
}
|
|
44877
45167
|
async function updateSettings(definition, options, edits, context) {
|
|
@@ -44926,6 +45216,16 @@ async function updateSettings(definition, options, edits, context) {
|
|
|
44926
45216
|
if (Number.isInteger(version) && version > 1) {
|
|
44927
45217
|
throw new SettingsRefusal("settings-newer-version", "Settings were written by a newer version");
|
|
44928
45218
|
}
|
|
45219
|
+
if (typeof edits === "function") {
|
|
45220
|
+
const planned = edits(deepFreeze(missing ? { status: "missing" } : {
|
|
45221
|
+
status: "ready",
|
|
45222
|
+
document: structuredClone(parsed.value)
|
|
45223
|
+
}));
|
|
45224
|
+
if (planned !== null && (typeof planned === "object" || typeof planned === "function") && "then" in planned && typeof planned.then === "function") {
|
|
45225
|
+
throw new SettingsRefusal("settings-invalid-value", "Settings update plans must be synchronous");
|
|
45226
|
+
}
|
|
45227
|
+
edits = planned;
|
|
45228
|
+
}
|
|
44929
45229
|
if (!parsed.tree) {
|
|
44930
45230
|
source = `${parsed.hasBom ? "\uFEFF" : ""}// ${definition.plugin} settings
|
|
44931
45231
|
{
|
|
@@ -47230,7 +47530,7 @@ function buildAccountAccessProbeRequest(projectId) {
|
|
|
47230
47530
|
generationConfig: { maxOutputTokens: 1, temperature: 0 }
|
|
47231
47531
|
};
|
|
47232
47532
|
const requestMetadata = buildAgyAgentRequestMetadata(
|
|
47233
|
-
createAgyRequestSessionContext(
|
|
47533
|
+
createAgyRequestSessionContext(),
|
|
47234
47534
|
request2,
|
|
47235
47535
|
wireModel
|
|
47236
47536
|
);
|
|
@@ -47961,6 +48261,18 @@ import { dirname as dirname30, join as join39 } from "node:path";
|
|
|
47961
48261
|
// src/plugin/model-registry.ts
|
|
47962
48262
|
init_dist();
|
|
47963
48263
|
|
|
48264
|
+
// src/plugin/config/models.ts
|
|
48265
|
+
function getOpencode1ModelDefinitions() {
|
|
48266
|
+
const models = { ...OPENCODE_MODEL_DEFINITIONS };
|
|
48267
|
+
const hydrogen = models["antigravity-gemini-4-hydrogen"];
|
|
48268
|
+
if (hydrogen) {
|
|
48269
|
+
const variants = { ...hydrogen.variants };
|
|
48270
|
+
delete variants.xhigh;
|
|
48271
|
+
models[hydrogen.id] = { ...hydrogen, variants };
|
|
48272
|
+
}
|
|
48273
|
+
return models;
|
|
48274
|
+
}
|
|
48275
|
+
|
|
47964
48276
|
// src/plugin/config/updater.ts
|
|
47965
48277
|
var PLUGIN_NAME = "@cortexkit/opencode-antigravity-auth@latest";
|
|
47966
48278
|
var SCHEMA_URL = "https://opencode.ai/config.json";
|
|
@@ -48022,7 +48334,7 @@ async function updateOpencodeConfig(options = {}) {
|
|
|
48022
48334
|
if (!config.provider.google) {
|
|
48023
48335
|
config.provider.google = {};
|
|
48024
48336
|
}
|
|
48025
|
-
config.provider.google.models =
|
|
48337
|
+
config.provider.google.models = getOpencode1ModelDefinitions();
|
|
48026
48338
|
config.provider.google.whitelist = getAntigravityOpencodeModelIds();
|
|
48027
48339
|
const configDir = dirname30(configPath);
|
|
48028
48340
|
if (!existsSync12(configDir)) {
|
|
@@ -48238,7 +48550,7 @@ async function select3(items, options) {
|
|
|
48238
48550
|
}
|
|
48239
48551
|
renderedLines = linesWritten;
|
|
48240
48552
|
};
|
|
48241
|
-
return new Promise((
|
|
48553
|
+
return new Promise((resolve31) => {
|
|
48242
48554
|
const wasRaw = stdin.isRaw ?? false;
|
|
48243
48555
|
const cleanup2 = () => {
|
|
48244
48556
|
if (isCleanedUp) return;
|
|
@@ -48259,11 +48571,11 @@ async function select3(items, options) {
|
|
|
48259
48571
|
};
|
|
48260
48572
|
const onSignal = () => {
|
|
48261
48573
|
cleanup2();
|
|
48262
|
-
|
|
48574
|
+
resolve31(null);
|
|
48263
48575
|
};
|
|
48264
48576
|
const finishWithValue = (value) => {
|
|
48265
48577
|
cleanup2();
|
|
48266
|
-
|
|
48578
|
+
resolve31(value);
|
|
48267
48579
|
};
|
|
48268
48580
|
const findNextSelectable = (from, direction) => {
|
|
48269
48581
|
if (items.length === 0) return from;
|
|
@@ -48309,7 +48621,7 @@ async function select3(items, options) {
|
|
|
48309
48621
|
stdin.setRawMode(true);
|
|
48310
48622
|
} catch {
|
|
48311
48623
|
cleanup2();
|
|
48312
|
-
|
|
48624
|
+
resolve31(null);
|
|
48313
48625
|
return;
|
|
48314
48626
|
}
|
|
48315
48627
|
stdin.resume();
|
|
@@ -51410,6 +51722,30 @@ To view: \`open "${filePath}"\``;
|
|
|
51410
51722
|
return ``;
|
|
51411
51723
|
}
|
|
51412
51724
|
|
|
51725
|
+
// src/plugin/core/streaming/terminal-event.ts
|
|
51726
|
+
function responseHasFinishReason(response) {
|
|
51727
|
+
if (!response || typeof response !== "object") return false;
|
|
51728
|
+
const resp = response;
|
|
51729
|
+
if (Array.isArray(resp.candidates)) {
|
|
51730
|
+
return resp.candidates.some((candidate) => {
|
|
51731
|
+
const cand = candidate;
|
|
51732
|
+
return typeof cand?.finishReason === "string" && cand.finishReason.length > 0;
|
|
51733
|
+
});
|
|
51734
|
+
}
|
|
51735
|
+
const stopReason = resp.stopReason ?? resp.stop_reason;
|
|
51736
|
+
return typeof stopReason === "string" && stopReason.length > 0;
|
|
51737
|
+
}
|
|
51738
|
+
function isTerminalSseLine(line) {
|
|
51739
|
+
if (!line.startsWith("data:")) return false;
|
|
51740
|
+
if (!/"(?:finishReason|stopReason|stop_reason)"/.test(line)) return false;
|
|
51741
|
+
try {
|
|
51742
|
+
const parsed = JSON.parse(line.slice(5).trim());
|
|
51743
|
+
return parsed?.response !== void 0 && responseHasFinishReason(parsed.response);
|
|
51744
|
+
} catch {
|
|
51745
|
+
return false;
|
|
51746
|
+
}
|
|
51747
|
+
}
|
|
51748
|
+
|
|
51413
51749
|
// src/plugin/core/streaming/transformer.ts
|
|
51414
51750
|
function hashString(str) {
|
|
51415
51751
|
let hash2 = 5381;
|
|
@@ -51579,18 +51915,6 @@ function responseHasToolCall(response) {
|
|
|
51579
51915
|
}
|
|
51580
51916
|
return false;
|
|
51581
51917
|
}
|
|
51582
|
-
function responseHasFinishReason(response) {
|
|
51583
|
-
if (!response || typeof response !== "object") return false;
|
|
51584
|
-
const resp = response;
|
|
51585
|
-
if (Array.isArray(resp.candidates)) {
|
|
51586
|
-
return resp.candidates.some((candidate) => {
|
|
51587
|
-
const cand = candidate;
|
|
51588
|
-
return typeof cand?.finishReason === "string" && cand.finishReason.length > 0;
|
|
51589
|
-
});
|
|
51590
|
-
}
|
|
51591
|
-
const stopReason = resp.stopReason ?? resp.stop_reason;
|
|
51592
|
-
return typeof stopReason === "string" && stopReason.length > 0;
|
|
51593
|
-
}
|
|
51594
51918
|
function transformSseLineWithMetadata(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState2, usageState) {
|
|
51595
51919
|
if (!line.startsWith("data:")) {
|
|
51596
51920
|
return { line, hasToolCall: false, hasFinishReason: false };
|
|
@@ -54543,7 +54867,7 @@ init_dist();
|
|
|
54543
54867
|
// src/plugin/request.ts
|
|
54544
54868
|
var log13 = createLogger4("request");
|
|
54545
54869
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
54546
|
-
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext(
|
|
54870
|
+
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext();
|
|
54547
54871
|
var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
|
|
54548
54872
|
var MIN_SIGNATURE_LENGTH = 50;
|
|
54549
54873
|
var AGY_CLAUDE_THINKING_BUDGET = 1024;
|
|
@@ -54624,7 +54948,9 @@ function getAgyMaxOutputTokens(model) {
|
|
|
54624
54948
|
}
|
|
54625
54949
|
function applyAgyGenerationDefaults(model, generationConfig) {
|
|
54626
54950
|
if (getAgyNativeModel(model)) {
|
|
54627
|
-
applyAgyNativeGenerationConfig(model, generationConfig
|
|
54951
|
+
applyAgyNativeGenerationConfig(model, generationConfig, {
|
|
54952
|
+
preserveThinkingBudget: false
|
|
54953
|
+
});
|
|
54628
54954
|
return;
|
|
54629
54955
|
}
|
|
54630
54956
|
const maxOutputTokens = getAgyMaxOutputTokens(model);
|
|
@@ -54940,20 +55266,38 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
54940
55266
|
}
|
|
54941
55267
|
}
|
|
54942
55268
|
}
|
|
54943
|
-
function
|
|
54944
|
-
|
|
54945
|
-
|
|
54946
|
-
|
|
55269
|
+
function isGeminiFunctionResponseTurn(content, wireModel) {
|
|
55270
|
+
return wireModel.startsWith("gemini-") && content?.role === "model" && Array.isArray(content.parts) && content.parts.length > 0 && content.parts.every((part) => part?.functionResponse);
|
|
55271
|
+
}
|
|
55272
|
+
function configureAntigravityToolCalling(payload) {
|
|
55273
|
+
delete payload.toolConfig;
|
|
55274
|
+
if (Array.isArray(payload.tools)) {
|
|
55275
|
+
payload.tools = payload.tools.flatMap(
|
|
55276
|
+
(tool2) => Array.isArray(tool2?.functionDeclarations) ? tool2.functionDeclarations.map((declaration) => ({
|
|
55277
|
+
functionDeclarations: [declaration]
|
|
55278
|
+
})) : [tool2]
|
|
55279
|
+
);
|
|
54947
55280
|
}
|
|
54948
|
-
const toolConfig = payload.toolConfig && typeof payload.toolConfig === "object" && !Array.isArray(payload.toolConfig) ? payload.toolConfig : {};
|
|
54949
|
-
const functionCallingConfig = toolConfig.functionCallingConfig && typeof toolConfig.functionCallingConfig === "object" && !Array.isArray(toolConfig.functionCallingConfig) ? toolConfig.functionCallingConfig : {};
|
|
54950
|
-
functionCallingConfig.mode = "VALIDATED";
|
|
54951
|
-
toolConfig.functionCallingConfig = functionCallingConfig;
|
|
54952
|
-
payload.toolConfig = toolConfig;
|
|
54953
55281
|
}
|
|
54954
|
-
function normalizeNativeFunctionResponseRoles(payload) {
|
|
55282
|
+
function normalizeNativeFunctionResponseRoles(payload, wireModel) {
|
|
54955
55283
|
const contents = payload.contents;
|
|
54956
55284
|
if (!Array.isArray(contents)) return;
|
|
55285
|
+
if (wireModel.startsWith("claude-")) {
|
|
55286
|
+
for (const content of contents) {
|
|
55287
|
+
if (Array.isArray(content?.parts)) {
|
|
55288
|
+
for (const part of content.parts) {
|
|
55289
|
+
if (part?.functionCall) {
|
|
55290
|
+
delete part.thoughtSignature;
|
|
55291
|
+
delete part.thought_signature;
|
|
55292
|
+
}
|
|
55293
|
+
}
|
|
55294
|
+
}
|
|
55295
|
+
if (content?.role === "model" && Array.isArray(content.parts) && content.parts.length > 0 && content.parts.every((part) => part?.functionResponse)) {
|
|
55296
|
+
content.role = "user";
|
|
55297
|
+
}
|
|
55298
|
+
}
|
|
55299
|
+
return;
|
|
55300
|
+
}
|
|
54957
55301
|
const signedCalls = /* @__PURE__ */ new Set();
|
|
54958
55302
|
for (const content of contents) {
|
|
54959
55303
|
const parts = content?.parts;
|
|
@@ -55399,7 +55743,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55399
55743
|
}
|
|
55400
55744
|
const [, rawModel = "", rawAction = ""] = match;
|
|
55401
55745
|
const requestedModel = rawModel;
|
|
55402
|
-
const
|
|
55746
|
+
const hydrogenTier = isGeminiHydrogenModel(rawModel) ? options?.variant?.thinkingLevel : void 0;
|
|
55747
|
+
const resolved = resolveAntigravityModel(
|
|
55748
|
+
hydrogenTier ? `${rawModel.replace(/-(low|medium|high|xhigh)$/i, "")}-${hydrogenTier}` : rawModel
|
|
55749
|
+
);
|
|
55403
55750
|
let effectiveModel = resolved.actualModel;
|
|
55404
55751
|
const streaming = rawAction === STREAM_ACTION;
|
|
55405
55752
|
const defaultEndpoint = ANTIGRAVITY_ENDPOINT;
|
|
@@ -55488,14 +55835,14 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55488
55835
|
}
|
|
55489
55836
|
sanitizeRequestPayloadForAntigravity(req);
|
|
55490
55837
|
stripUnsupportedAntigravityFields(req);
|
|
55491
|
-
configureAntigravityToolCalling(req
|
|
55492
|
-
normalizeNativeFunctionResponseRoles(req);
|
|
55838
|
+
configureAntigravityToolCalling(req);
|
|
55839
|
+
normalizeNativeFunctionResponseRoles(req, effectiveModel);
|
|
55493
55840
|
}
|
|
55494
55841
|
for (const req of requestObjects) {
|
|
55495
55842
|
if (Array.isArray(req.contents)) {
|
|
55496
55843
|
const contents = req.contents;
|
|
55497
55844
|
const lastContent = contents[contents.length - 1];
|
|
55498
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
55845
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
55499
55846
|
contents.push({ role: "user", parts: [{ text: "[Continue]" }] });
|
|
55500
55847
|
}
|
|
55501
55848
|
}
|
|
@@ -55530,7 +55877,9 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55530
55877
|
{
|
|
55531
55878
|
const generationConfig = wireRequest.generationConfig;
|
|
55532
55879
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
55533
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
55880
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
55881
|
+
thinkingBudget: options?.variant?.thinkingBudget
|
|
55882
|
+
});
|
|
55534
55883
|
if (Object.keys(config).length > 0)
|
|
55535
55884
|
wireRequest.generationConfig = config;
|
|
55536
55885
|
const metadata = buildAgyAgentRequestMetadata(
|
|
@@ -55559,13 +55908,19 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55559
55908
|
requestPayload.providerOptions,
|
|
55560
55909
|
rawGenerationConfig
|
|
55561
55910
|
);
|
|
55911
|
+
const callerThinking = rawGenerationConfig?.thinkingConfig ?? extraBody?.thinkingConfig ?? requestPayload.thinkingConfig;
|
|
55912
|
+
const callerAnthropicThinking = extraBody?.thinking ?? requestPayload.thinking;
|
|
55913
|
+
const explicitThinkingBudget = variantConfig?.thinkingBudget ?? (typeof callerThinking?.thinkingBudget === "number" ? callerThinking.thinkingBudget : void 0) ?? (typeof callerAnthropicThinking?.budgetTokens === "number" ? callerAnthropicThinking.budgetTokens : void 0);
|
|
55562
55914
|
const isGemini3 = effectiveModel.toLowerCase().includes("gemini-3");
|
|
55563
55915
|
wire.logger.debug(
|
|
55564
55916
|
`[ThinkingResolution] rawModel=${rawModel} resolvedModel=${effectiveModel} resolvedTier=${tierThinkingLevel ?? "none"} variantLevel=${variantConfig?.thinkingLevel ?? "none"} variantBudget=${variantConfig?.thinkingBudget ?? "none"} providerOptions.google=${JSON.stringify(requestPayload.providerOptions?.google ?? null)} generationConfig.thinkingConfig=${JSON.stringify(rawGenerationConfig?.thinkingConfig ?? null)}`
|
|
55565
55917
|
);
|
|
55566
55918
|
delete requestPayload.providerOptions;
|
|
55567
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
55568
|
-
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(
|
|
55919
|
+
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || isGeminiHydrogenModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
55920
|
+
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(
|
|
55921
|
+
isGeminiHydrogenModel(effectiveModel) ? /-(low|medium|high|xhigh)$/i : /-(minimal|low|medium|high)$/i,
|
|
55922
|
+
""
|
|
55923
|
+
);
|
|
55569
55924
|
const variantResolved = resolveAntigravityModel(
|
|
55570
55925
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
55571
55926
|
);
|
|
@@ -55661,7 +56016,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55661
56016
|
if (rawGenerationConfig) {
|
|
55662
56017
|
rawGenerationConfig.thinkingConfig = thinkingConfig;
|
|
55663
56018
|
applyAgyGenerationDefaults(effectiveModel, rawGenerationConfig);
|
|
55664
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
56019
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
55665
56020
|
const currentMax = rawGenerationConfig.maxOutputTokens ?? rawGenerationConfig.max_output_tokens;
|
|
55666
56021
|
if (!currentMax) {
|
|
55667
56022
|
rawGenerationConfig.maxOutputTokens = 64e3;
|
|
@@ -55677,7 +56032,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55677
56032
|
const generationConfig = {
|
|
55678
56033
|
thinkingConfig
|
|
55679
56034
|
};
|
|
55680
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
56035
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
55681
56036
|
generationConfig.maxOutputTokens = 64e3;
|
|
55682
56037
|
}
|
|
55683
56038
|
applyAgyGenerationDefaults(effectiveModel, generationConfig);
|
|
@@ -55778,7 +56133,11 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55778
56133
|
});
|
|
55779
56134
|
const finalTools = [];
|
|
55780
56135
|
if (functionDeclarations.length > 0) {
|
|
55781
|
-
finalTools.push(
|
|
56136
|
+
finalTools.push(
|
|
56137
|
+
...functionDeclarations.map((declaration) => ({
|
|
56138
|
+
functionDeclarations: [declaration]
|
|
56139
|
+
}))
|
|
56140
|
+
);
|
|
55782
56141
|
}
|
|
55783
56142
|
requestPayload.tools = finalTools.concat(passthroughTools);
|
|
55784
56143
|
} else {
|
|
@@ -55910,7 +56269,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55910
56269
|
requestPayload.messages
|
|
55911
56270
|
);
|
|
55912
56271
|
}
|
|
55913
|
-
if (isClaudeThinking && Array.isArray(requestPayload.contents)) {
|
|
56272
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && Array.isArray(requestPayload.contents)) {
|
|
55914
56273
|
const conversationState = analyzeConversationState(
|
|
55915
56274
|
requestPayload.contents
|
|
55916
56275
|
);
|
|
@@ -55924,7 +56283,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55924
56283
|
}
|
|
55925
56284
|
if (Array.isArray(requestPayload.contents)) {
|
|
55926
56285
|
const lastContent = requestPayload.contents[requestPayload.contents.length - 1];
|
|
55927
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
56286
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
55928
56287
|
requestPayload.contents.push({
|
|
55929
56288
|
role: "user",
|
|
55930
56289
|
parts: [{ text: "[Continue]" }]
|
|
@@ -55949,15 +56308,18 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55949
56308
|
{
|
|
55950
56309
|
const generationConfig = requestPayload.generationConfig;
|
|
55951
56310
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
55952
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
56311
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
56312
|
+
thinkingBudget: explicitThinkingBudget,
|
|
56313
|
+
preserveThinkingBudget: false
|
|
56314
|
+
});
|
|
55953
56315
|
if (Object.keys(config).length > 0)
|
|
55954
56316
|
requestPayload.generationConfig = config;
|
|
55955
56317
|
stripUnsupportedAntigravityFields(requestPayload);
|
|
55956
|
-
configureAntigravityToolCalling(requestPayload
|
|
55957
|
-
normalizeNativeFunctionResponseRoles(requestPayload);
|
|
56318
|
+
configureAntigravityToolCalling(requestPayload);
|
|
56319
|
+
normalizeNativeFunctionResponseRoles(requestPayload, effectiveModel);
|
|
55958
56320
|
if (Array.isArray(requestPayload.contents)) {
|
|
55959
|
-
const lastContent = requestPayload.contents
|
|
55960
|
-
if (lastContent?.role === "model") {
|
|
56321
|
+
const lastContent = requestPayload.contents.at(-1);
|
|
56322
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel)) {
|
|
55961
56323
|
requestPayload.contents.push({
|
|
55962
56324
|
role: "user",
|
|
55963
56325
|
parts: [{ text: "[Continue]" }]
|
|
@@ -56063,7 +56425,9 @@ function buildThinkingWarmupBody(bodyText, isClaudeThinking) {
|
|
|
56063
56425
|
thinkingBudget: AGY_CLAUDE_THINKING_BUDGET
|
|
56064
56426
|
};
|
|
56065
56427
|
generationConfig.maxOutputTokens ??= generationConfig.max_output_tokens ?? getAgyMaxOutputTokens(wireModel) ?? computeClaudeMaxOutputTokens(AGY_CLAUDE_THINKING_BUDGET);
|
|
56066
|
-
applyAgyNativeGenerationConfig(wireModel, generationConfig
|
|
56428
|
+
applyAgyNativeGenerationConfig(wireModel, generationConfig, {
|
|
56429
|
+
preserveThinkingBudget: false
|
|
56430
|
+
});
|
|
56067
56431
|
req.generationConfig = generationConfig;
|
|
56068
56432
|
requestObjects.push(req);
|
|
56069
56433
|
};
|
|
@@ -56508,10 +56872,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
56508
56872
|
cancellation.release();
|
|
56509
56873
|
throw error;
|
|
56510
56874
|
}
|
|
56511
|
-
let
|
|
56875
|
+
let resolve31 = () => {
|
|
56512
56876
|
};
|
|
56513
56877
|
const settled = new Promise((done) => {
|
|
56514
|
-
|
|
56878
|
+
resolve31 = done;
|
|
56515
56879
|
});
|
|
56516
56880
|
let stopping = false;
|
|
56517
56881
|
let finished = false;
|
|
@@ -56521,7 +56885,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
56521
56885
|
finished = true;
|
|
56522
56886
|
cancellation.signal.removeEventListener("abort", abort);
|
|
56523
56887
|
cancellation.release();
|
|
56524
|
-
|
|
56888
|
+
resolve31();
|
|
56525
56889
|
};
|
|
56526
56890
|
const abort = () => {
|
|
56527
56891
|
if (finished || stopping) return;
|
|
@@ -56590,8 +56954,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
56590
56954
|
let running = false;
|
|
56591
56955
|
let resolveCompletion = () => {
|
|
56592
56956
|
};
|
|
56593
|
-
const completion = new Promise((
|
|
56594
|
-
resolveCompletion =
|
|
56957
|
+
const completion = new Promise((resolve31) => {
|
|
56958
|
+
resolveCompletion = resolve31;
|
|
56595
56959
|
});
|
|
56596
56960
|
const finish = () => {
|
|
56597
56961
|
if (finished) return;
|
|
@@ -56638,14 +57002,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
56638
57002
|
};
|
|
56639
57003
|
}
|
|
56640
57004
|
function publishResponse(dispatch) {
|
|
56641
|
-
return new Promise((
|
|
57005
|
+
return new Promise((resolve31, reject) => {
|
|
56642
57006
|
let acknowledge;
|
|
56643
57007
|
void Promise.resolve().then(
|
|
56644
57008
|
() => dispatch((callback) => {
|
|
56645
57009
|
acknowledge = callback;
|
|
56646
57010
|
})
|
|
56647
57011
|
).then((response) => {
|
|
56648
|
-
|
|
57012
|
+
resolve31(response);
|
|
56649
57013
|
acknowledge?.();
|
|
56650
57014
|
}, reject);
|
|
56651
57015
|
});
|
|
@@ -58186,9 +58550,10 @@ function applyAntigravityProviderCatalog(config, providerId) {
|
|
|
58186
58550
|
const mutableConfig = config;
|
|
58187
58551
|
mutableConfig.provider ??= {};
|
|
58188
58552
|
const providerConfig = mutableConfig.provider[providerId] ?? {};
|
|
58553
|
+
const models = getOpencode1ModelDefinitions();
|
|
58189
58554
|
providerConfig.models = {
|
|
58190
58555
|
...providerConfig.models ?? {},
|
|
58191
|
-
...
|
|
58556
|
+
...models
|
|
58192
58557
|
};
|
|
58193
58558
|
providerConfig.whitelist = getAntigravityOpencodeModelIds();
|
|
58194
58559
|
mutableConfig.provider[providerId] = providerConfig;
|
|
@@ -58325,10 +58690,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
58325
58690
|
}
|
|
58326
58691
|
async function defaultSleep(ms, signal) {
|
|
58327
58692
|
if (ms <= 0) return;
|
|
58328
|
-
await new Promise((
|
|
58693
|
+
await new Promise((resolve31, reject) => {
|
|
58329
58694
|
const timer = setTimeout(() => {
|
|
58330
58695
|
signal?.removeEventListener("abort", onAbort);
|
|
58331
|
-
|
|
58696
|
+
resolve31();
|
|
58332
58697
|
}, ms);
|
|
58333
58698
|
timer.unref?.();
|
|
58334
58699
|
const onAbort = () => {
|
|
@@ -58448,7 +58813,7 @@ init_logger4();
|
|
|
58448
58813
|
|
|
58449
58814
|
// src/plugin/shared/request-services.ts
|
|
58450
58815
|
init_dist();
|
|
58451
|
-
import { createHash as createHash23 } from "node:crypto";
|
|
58816
|
+
import { createHash as createHash23, randomUUID as randomUUID24 } from "node:crypto";
|
|
58452
58817
|
|
|
58453
58818
|
// src/common-auth-embedded/routing-accessor/handle.js
|
|
58454
58819
|
function routingHandle(sessionId) {
|
|
@@ -58472,6 +58837,14 @@ function isCacheWarmStopReason(value) {
|
|
|
58472
58837
|
}
|
|
58473
58838
|
|
|
58474
58839
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
58840
|
+
var PLUGIN_WAIT_REASONS = [
|
|
58841
|
+
"account_limit",
|
|
58842
|
+
"account_free",
|
|
58843
|
+
"rate_limited",
|
|
58844
|
+
"server_busy",
|
|
58845
|
+
"quota_reading",
|
|
58846
|
+
"routing_hold"
|
|
58847
|
+
];
|
|
58475
58848
|
function isObject2(value) {
|
|
58476
58849
|
return typeof value === "object" && value !== null;
|
|
58477
58850
|
}
|
|
@@ -58578,8 +58951,8 @@ async function askRouting(input2) {
|
|
|
58578
58951
|
return void 0;
|
|
58579
58952
|
const requested = input2.deadlineMs ?? 1500;
|
|
58580
58953
|
const deadlineMs = Number.isNaN(requested) ? 1500 : Math.min(2e3, Math.max(1, requested));
|
|
58581
|
-
const expired = new Promise((
|
|
58582
|
-
timer = setTimeout(() =>
|
|
58954
|
+
const expired = new Promise((resolve31) => {
|
|
58955
|
+
timer = setTimeout(() => resolve31(void 0), deadlineMs);
|
|
58583
58956
|
timer.unref();
|
|
58584
58957
|
});
|
|
58585
58958
|
const request2 = {
|
|
@@ -58592,6 +58965,10 @@ async function askRouting(input2) {
|
|
|
58592
58965
|
}
|
|
58593
58966
|
if (input2.refusals === true)
|
|
58594
58967
|
request2.refusals = true;
|
|
58968
|
+
const warmCredentialId = input2.warmCredentialId;
|
|
58969
|
+
if (isNonEmptyString(warmCredentialId) && warmCredentialId.length <= 256 && !/\p{Cc}/u.test(warmCredentialId) && input2.candidates.some((candidate) => candidate.credentialId === warmCredentialId)) {
|
|
58970
|
+
request2.warm_credential = warmCredentialId;
|
|
58971
|
+
}
|
|
58595
58972
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
58596
58973
|
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
58597
58974
|
return void 0;
|
|
@@ -58608,7 +58985,8 @@ async function askRouting(input2) {
|
|
|
58608
58985
|
}
|
|
58609
58986
|
function reportRouting(input2) {
|
|
58610
58987
|
try {
|
|
58611
|
-
const
|
|
58988
|
+
const sessionId = input2.sessionId;
|
|
58989
|
+
const handle = routingHandle(sessionId);
|
|
58612
58990
|
if (!handle)
|
|
58613
58991
|
return;
|
|
58614
58992
|
const report = handle.report;
|
|
@@ -58617,6 +58995,22 @@ function reportRouting(input2) {
|
|
|
58617
58995
|
let payload;
|
|
58618
58996
|
if ("kind" in input2) {
|
|
58619
58997
|
switch (input2.kind) {
|
|
58998
|
+
case "wait": {
|
|
58999
|
+
const { phase, waitId, reason, nextMs, attempt, message, outcome } = input2;
|
|
59000
|
+
if (!isNonEmptyString(sessionId) || phase !== "start" && phase !== "end" || !isNonEmptyString(waitId) || waitId.length > 64 || /[^A-Za-z0-9._:-]/.test(waitId) || !PLUGIN_WAIT_REASONS.includes(reason))
|
|
59001
|
+
return;
|
|
59002
|
+
payload = {
|
|
59003
|
+
kind: "wait",
|
|
59004
|
+
phase,
|
|
59005
|
+
wait_id: waitId,
|
|
59006
|
+
reason,
|
|
59007
|
+
...typeof nextMs === "number" && Number.isSafeInteger(nextMs) && nextMs > 0 ? { next_ms: nextMs } : {},
|
|
59008
|
+
...typeof attempt === "number" && Number.isInteger(attempt) && attempt >= 1 ? { attempt } : {},
|
|
59009
|
+
...typeof message === "string" && message.length >= 1 && message.length <= 160 && !/\p{Cc}/u.test(message) ? { message } : {},
|
|
59010
|
+
...phase === "end" && (outcome === "resumed" || outcome === "cancelled" || outcome === "abandoned") ? { outcome } : {}
|
|
59011
|
+
};
|
|
59012
|
+
break;
|
|
59013
|
+
}
|
|
58620
59014
|
case "billing": {
|
|
58621
59015
|
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
58622
59016
|
if (!isNonEmptyString(attemptId) || !isNonEmptyString(credentialId) || !isNonEmptyString(provider2) || !isNonEmptyString(model) || requestKind !== "primary" && requestKind !== "title" && requestKind !== "compaction" && requestKind !== "generate" && requestKind !== "keep_warm" && requestKind !== "prime" || outcome !== "completed" && outcome !== "cut" && outcome !== "failed")
|
|
@@ -59043,8 +59437,6 @@ function getModelFamilyFromUrl(urlString, debug) {
|
|
|
59043
59437
|
}
|
|
59044
59438
|
|
|
59045
59439
|
// src/plugin/session-context.ts
|
|
59046
|
-
import { resolve as resolve30 } from "node:path";
|
|
59047
|
-
import { pathToFileURL } from "node:url";
|
|
59048
59440
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
59049
59441
|
function extractOpenCodeSessionIdentity(headers) {
|
|
59050
59442
|
const normalized = new Headers(headers);
|
|
@@ -59056,9 +59448,8 @@ function extractOpenCodeSessionIdentity(headers) {
|
|
|
59056
59448
|
var AgySessionRegistry = class {
|
|
59057
59449
|
requestSessions;
|
|
59058
59450
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
59059
|
-
constructor(
|
|
59060
|
-
|
|
59061
|
-
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
59451
|
+
constructor(options = {}) {
|
|
59452
|
+
this.requestSessions = new AgyRequestSessionStore(options);
|
|
59062
59453
|
}
|
|
59063
59454
|
getOrCreate(identity4) {
|
|
59064
59455
|
const key = identity4.sessionId ?? FALLBACK_SESSION_KEY;
|
|
@@ -59340,9 +59731,13 @@ function observeVaultUpstream(response, signal) {
|
|
|
59340
59731
|
return void 0;
|
|
59341
59732
|
let completed = false;
|
|
59342
59733
|
return {
|
|
59343
|
-
response: observeBody(
|
|
59344
|
-
|
|
59345
|
-
|
|
59734
|
+
response: observeBody(
|
|
59735
|
+
response,
|
|
59736
|
+
() => {
|
|
59737
|
+
completed = !signal?.aborted;
|
|
59738
|
+
},
|
|
59739
|
+
isTerminalSseLine
|
|
59740
|
+
),
|
|
59346
59741
|
completedSuccessfully: () => completed
|
|
59347
59742
|
};
|
|
59348
59743
|
}
|
|
@@ -59361,29 +59756,36 @@ function observeVaultServed(identity4, response, signal, upstream) {
|
|
|
59361
59756
|
};
|
|
59362
59757
|
return observeBody(response, report);
|
|
59363
59758
|
}
|
|
59364
|
-
function observeBody(response, complete) {
|
|
59759
|
+
function observeBody(response, complete, terminal) {
|
|
59365
59760
|
if (!response.body) {
|
|
59366
59761
|
complete();
|
|
59367
59762
|
return response;
|
|
59368
59763
|
}
|
|
59369
59764
|
const sse = response.headers.get("content-type")?.includes("text/event-stream");
|
|
59765
|
+
const awaitsTerminal = sse && terminal !== void 0;
|
|
59370
59766
|
const reader = response.body.getReader();
|
|
59371
59767
|
const decoder = new TextDecoder();
|
|
59372
59768
|
let pending = "";
|
|
59373
59769
|
let failed = false;
|
|
59770
|
+
let terminated = false;
|
|
59374
59771
|
const inspect = (line) => {
|
|
59772
|
+
if (terminated) return;
|
|
59375
59773
|
if (line.length > 1024 * 1024) {
|
|
59376
59774
|
failed = true;
|
|
59377
59775
|
return;
|
|
59378
59776
|
}
|
|
59379
59777
|
if (line.startsWith("event:") && line.slice(6).trim() === "error")
|
|
59380
59778
|
failed = true;
|
|
59381
|
-
if (
|
|
59382
|
-
|
|
59383
|
-
|
|
59384
|
-
|
|
59385
|
-
|
|
59386
|
-
|
|
59779
|
+
if (line.startsWith("data:") && /"(?:error|response.failed|failed)"/.test(line)) {
|
|
59780
|
+
try {
|
|
59781
|
+
failed ||= streamFailure(JSON.parse(line.slice(5)));
|
|
59782
|
+
} catch {
|
|
59783
|
+
failed = true;
|
|
59784
|
+
}
|
|
59785
|
+
}
|
|
59786
|
+
if (awaitsTerminal && !failed && terminal?.(line)) {
|
|
59787
|
+
terminated = true;
|
|
59788
|
+
complete();
|
|
59387
59789
|
}
|
|
59388
59790
|
};
|
|
59389
59791
|
const body = new ReadableStream(
|
|
@@ -59400,12 +59802,12 @@ function observeBody(response, complete) {
|
|
|
59400
59802
|
failed = true;
|
|
59401
59803
|
}
|
|
59402
59804
|
}
|
|
59403
|
-
if (!failed) complete();
|
|
59805
|
+
if (!failed && !awaitsTerminal) complete();
|
|
59404
59806
|
controller.close();
|
|
59405
59807
|
reader.releaseLock();
|
|
59406
59808
|
return;
|
|
59407
59809
|
}
|
|
59408
|
-
if (!failed) {
|
|
59810
|
+
if (!failed && !terminated) {
|
|
59409
59811
|
pending += decoder.decode(chunk.value, { stream: true });
|
|
59410
59812
|
if (sse) {
|
|
59411
59813
|
let newline = pending.indexOf("\n");
|
|
@@ -59553,7 +59955,7 @@ function formatWaitTime(ms) {
|
|
|
59553
59955
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
59554
59956
|
}
|
|
59555
59957
|
function sleep4(ms, signal) {
|
|
59556
|
-
return new Promise((
|
|
59958
|
+
return new Promise((resolve31, reject) => {
|
|
59557
59959
|
if (signal?.aborted) {
|
|
59558
59960
|
reject(
|
|
59559
59961
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -59563,7 +59965,7 @@ function sleep4(ms, signal) {
|
|
|
59563
59965
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
59564
59966
|
const timeout = setTimeout(() => {
|
|
59565
59967
|
cleanup2();
|
|
59566
|
-
|
|
59968
|
+
resolve31();
|
|
59567
59969
|
}, timerMs);
|
|
59568
59970
|
const onAbort = () => {
|
|
59569
59971
|
cleanup2();
|
|
@@ -59578,6 +59980,44 @@ function sleep4(ms, signal) {
|
|
|
59578
59980
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
59579
59981
|
});
|
|
59580
59982
|
}
|
|
59983
|
+
var WAIT_MESSAGES = {
|
|
59984
|
+
account_free: "Waiting for an available account...",
|
|
59985
|
+
account_limit: "Waiting for the same account (prompt cache preserved)...",
|
|
59986
|
+
rate_limited: "Rate limited. Retrying...",
|
|
59987
|
+
server_busy: "Server busy. Retrying..."
|
|
59988
|
+
};
|
|
59989
|
+
async function withRoutingWaitReports(cancellation, run) {
|
|
59990
|
+
const pending = [];
|
|
59991
|
+
let closed2 = false;
|
|
59992
|
+
const finish = (outcome) => {
|
|
59993
|
+
for (const wait2 of pending.splice(0)) {
|
|
59994
|
+
reportRouting({ kind: "wait", phase: "end", ...wait2, outcome });
|
|
59995
|
+
}
|
|
59996
|
+
};
|
|
59997
|
+
try {
|
|
59998
|
+
return await run({
|
|
59999
|
+
sleep(ms, signal, sessionId, reason, attempt) {
|
|
60000
|
+
if (!closed2 && ms >= 2e3 && sessionId && hasVaultRoutingAccessor()) {
|
|
60001
|
+
const wait2 = {
|
|
60002
|
+
sessionId,
|
|
60003
|
+
waitId: randomUUID24(),
|
|
60004
|
+
reason,
|
|
60005
|
+
nextMs: Date.now() + ms,
|
|
60006
|
+
...attempt === void 0 ? {} : { attempt },
|
|
60007
|
+
message: WAIT_MESSAGES[reason]
|
|
60008
|
+
};
|
|
60009
|
+
pending.push(wait2);
|
|
60010
|
+
reportRouting({ kind: "wait", phase: "start", ...wait2 });
|
|
60011
|
+
}
|
|
60012
|
+
return sleep4(ms, signal);
|
|
60013
|
+
},
|
|
60014
|
+
resumed: () => finish("resumed")
|
|
60015
|
+
});
|
|
60016
|
+
} finally {
|
|
60017
|
+
closed2 = true;
|
|
60018
|
+
finish(cancellation.aborted ? "cancelled" : "abandoned");
|
|
60019
|
+
}
|
|
60020
|
+
}
|
|
59581
60021
|
function createLocalQuotaRefresh(accountManager, quotaManager, log18) {
|
|
59582
60022
|
return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
|
|
59583
60023
|
if (intervalMinutes <= 0) return;
|
|
@@ -59746,7 +60186,7 @@ function createRequestExecutor(deps) {
|
|
|
59746
60186
|
log18.debug("routing-report-failed", { sessionId, error: String(error) });
|
|
59747
60187
|
}
|
|
59748
60188
|
};
|
|
59749
|
-
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
|
|
60189
|
+
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy, waits) {
|
|
59750
60190
|
const assertAdmission = async () => {
|
|
59751
60191
|
await deadline.wait(() => deps.assertAdmission?.(deadline.signal));
|
|
59752
60192
|
};
|
|
@@ -59814,9 +60254,13 @@ function createRequestExecutor(deps) {
|
|
|
59814
60254
|
};
|
|
59815
60255
|
}
|
|
59816
60256
|
const sender = options.transport ?? defaultTransport2;
|
|
59817
|
-
const transport = (url, sendInit, sendOptions) => deadline.open(
|
|
59818
|
-
()
|
|
59819
|
-
|
|
60257
|
+
const transport = (url, sendInit, sendOptions) => deadline.open(() => {
|
|
60258
|
+
waits.resumed();
|
|
60259
|
+
return sender(url, sendInit, {
|
|
60260
|
+
...sendOptions,
|
|
60261
|
+
signal: deadline.signal
|
|
60262
|
+
});
|
|
60263
|
+
});
|
|
59820
60264
|
const requestSessionIdentity = options.session ?? extractOpenCodeSessionIdentity(init?.headers);
|
|
59821
60265
|
const agyRequestScope = agySessionRegistry.beginRequest(
|
|
59822
60266
|
agyMetadataIdentity(requestSessionIdentity, kind)
|
|
@@ -59866,6 +60310,13 @@ function createRequestExecutor(deps) {
|
|
|
59866
60310
|
let lastFailure = null;
|
|
59867
60311
|
let lastError = null;
|
|
59868
60312
|
const abortSignal = init?.signal ?? void 0;
|
|
60313
|
+
const routingSleep = (ms, reason, attempt) => waits.sleep(
|
|
60314
|
+
ms,
|
|
60315
|
+
abortSignal,
|
|
60316
|
+
credentials.domain === "vault" ? requestSessionIdentity.sessionId ?? void 0 : void 0,
|
|
60317
|
+
reason,
|
|
60318
|
+
attempt
|
|
60319
|
+
);
|
|
59869
60320
|
const checkAborted = () => {
|
|
59870
60321
|
deadline.check();
|
|
59871
60322
|
if (abortSignal?.aborted) {
|
|
@@ -60207,7 +60658,10 @@ function createRequestExecutor(deps) {
|
|
|
60207
60658
|
);
|
|
60208
60659
|
retryState.markSoftQuotaToastShown();
|
|
60209
60660
|
}
|
|
60210
|
-
await
|
|
60661
|
+
await routingSleep(
|
|
60662
|
+
Math.min(waitMs, remainingWaitMs()),
|
|
60663
|
+
"account_free"
|
|
60664
|
+
);
|
|
60211
60665
|
continue;
|
|
60212
60666
|
}
|
|
60213
60667
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
@@ -60250,7 +60704,7 @@ function createRequestExecutor(deps) {
|
|
|
60250
60704
|
);
|
|
60251
60705
|
retryState.markRateLimitToastShown();
|
|
60252
60706
|
}
|
|
60253
|
-
await
|
|
60707
|
+
await routingSleep(Math.min(waitMs, remainingWaitMs()), "account_free");
|
|
60254
60708
|
continue;
|
|
60255
60709
|
}
|
|
60256
60710
|
allAccountsBlockedAt = void 0;
|
|
@@ -60924,7 +61378,11 @@ function createRequestExecutor(deps) {
|
|
|
60924
61378
|
`\u23F3 Server busy (${response.status}). Retrying in ${waitSec}s...`,
|
|
60925
61379
|
"warning"
|
|
60926
61380
|
);
|
|
60927
|
-
await
|
|
61381
|
+
await routingSleep(
|
|
61382
|
+
waitMs,
|
|
61383
|
+
"server_busy",
|
|
61384
|
+
capacityRetryCount + 1
|
|
61385
|
+
);
|
|
60928
61386
|
if (capacityRetryCount < 1) {
|
|
60929
61387
|
capacityRetryCount++;
|
|
60930
61388
|
i -= 1;
|
|
@@ -60994,7 +61452,7 @@ function createRequestExecutor(deps) {
|
|
|
60994
61452
|
rateLimitReason,
|
|
60995
61453
|
serverRetryMs
|
|
60996
61454
|
);
|
|
60997
|
-
await
|
|
61455
|
+
await routingSleep(effectiveDelayMs, "account_limit");
|
|
60998
61456
|
i -= 1;
|
|
60999
61457
|
continue;
|
|
61000
61458
|
}
|
|
@@ -61044,7 +61502,11 @@ function createRequestExecutor(deps) {
|
|
|
61044
61502
|
`Rate limited. Retrying in ${expBackoffFormatted} (attempt ${backoff.attempt})...`,
|
|
61045
61503
|
"warning"
|
|
61046
61504
|
);
|
|
61047
|
-
await
|
|
61505
|
+
await routingSleep(
|
|
61506
|
+
expBackoffMs,
|
|
61507
|
+
"rate_limited",
|
|
61508
|
+
backoff.attempt
|
|
61509
|
+
);
|
|
61048
61510
|
}
|
|
61049
61511
|
lastFailure = createFailureContext(response);
|
|
61050
61512
|
shouldSwitchAccount = true;
|
|
@@ -61537,15 +61999,19 @@ function createRequestExecutor(deps) {
|
|
|
61537
61999
|
const waitPolicy = {};
|
|
61538
62000
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
61539
62001
|
const selectedProjectIds = /* @__PURE__ */ new Set();
|
|
61540
|
-
const pending =
|
|
61541
|
-
|
|
61542
|
-
|
|
61543
|
-
|
|
61544
|
-
|
|
61545
|
-
|
|
61546
|
-
|
|
61547
|
-
|
|
61548
|
-
|
|
62002
|
+
const pending = withRoutingWaitReports(
|
|
62003
|
+
cancellation.signal,
|
|
62004
|
+
(waits) => deadline.wait(
|
|
62005
|
+
() => execute(
|
|
62006
|
+
input2,
|
|
62007
|
+
{ ...init, signal: deadline.signal },
|
|
62008
|
+
requestOptions ?? {},
|
|
62009
|
+
selectedCredentials,
|
|
62010
|
+
selectedProjectIds,
|
|
62011
|
+
deadline,
|
|
62012
|
+
waitPolicy,
|
|
62013
|
+
waits
|
|
62014
|
+
)
|
|
61549
62015
|
)
|
|
61550
62016
|
).catch((error) => {
|
|
61551
62017
|
cancellation.signal.throwIfAborted();
|
|
@@ -61923,18 +62389,8 @@ tool.schema = z5;
|
|
|
61923
62389
|
init_logger4();
|
|
61924
62390
|
|
|
61925
62391
|
// src/plugin/search.ts
|
|
61926
|
-
import crypto3 from "node:crypto";
|
|
61927
62392
|
init_logger4();
|
|
61928
62393
|
var log16 = createLogger4("search");
|
|
61929
|
-
var sessionCounter = 0;
|
|
61930
|
-
var sessionPrefix = `search-${Date.now().toString(36)}`;
|
|
61931
|
-
function generateRequestId() {
|
|
61932
|
-
return `agent/${crypto3.randomUUID()}/${Date.now()}/${crypto3.randomUUID()}/2`;
|
|
61933
|
-
}
|
|
61934
|
-
function getSessionId() {
|
|
61935
|
-
sessionCounter++;
|
|
61936
|
-
return `${sessionPrefix}-${sessionCounter}`;
|
|
61937
|
-
}
|
|
61938
62394
|
function formatSearchResult(result) {
|
|
61939
62395
|
const lines = [];
|
|
61940
62396
|
lines.push("## Search Results\n");
|
|
@@ -62045,13 +62501,18 @@ ${urlList}`;
|
|
|
62045
62501
|
topP: 1
|
|
62046
62502
|
}
|
|
62047
62503
|
};
|
|
62504
|
+
const metadata = buildAgyAgentRequestMetadata(
|
|
62505
|
+
createAgyRequestSessionContext(),
|
|
62506
|
+
requestPayload,
|
|
62507
|
+
SEARCH_MODEL
|
|
62508
|
+
);
|
|
62509
|
+
requestPayload.labels = metadata.labels;
|
|
62510
|
+
requestPayload.sessionId = metadata.sessionId;
|
|
62511
|
+
orderAgyRequestPayloadInPlace(requestPayload);
|
|
62048
62512
|
const wrappedBody = {
|
|
62049
62513
|
project: projectId,
|
|
62050
|
-
requestId:
|
|
62051
|
-
request:
|
|
62052
|
-
...requestPayload,
|
|
62053
|
-
sessionId: getSessionId()
|
|
62054
|
-
},
|
|
62514
|
+
requestId: metadata.requestId,
|
|
62515
|
+
request: requestPayload,
|
|
62055
62516
|
model: SEARCH_MODEL,
|
|
62056
62517
|
userAgent: "antigravity",
|
|
62057
62518
|
requestType: "agent"
|
|
@@ -62295,8 +62756,8 @@ function createPluginLifecycle(options) {
|
|
|
62295
62756
|
};
|
|
62296
62757
|
let failDisposal = () => {
|
|
62297
62758
|
};
|
|
62298
|
-
disposal = new Promise((
|
|
62299
|
-
finishDisposal =
|
|
62759
|
+
disposal = new Promise((resolve31, reject) => {
|
|
62760
|
+
finishDisposal = resolve31;
|
|
62300
62761
|
failDisposal = reject;
|
|
62301
62762
|
});
|
|
62302
62763
|
void (async () => {
|
|
@@ -62521,7 +62982,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62521
62982
|
if (config.keep_thinking) {
|
|
62522
62983
|
initDiskSignatureCache(config.signature_cache);
|
|
62523
62984
|
}
|
|
62524
|
-
const sessionRegistry = new AgySessionRegistry(
|
|
62985
|
+
const sessionRegistry = new AgySessionRegistry();
|
|
62525
62986
|
let cachedGetAuth = null;
|
|
62526
62987
|
let stopSidebarPublisher;
|
|
62527
62988
|
const lifecycle = createPluginLifecycle({
|
|
@@ -62538,7 +62999,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62538
62999
|
await drainSidebarWrites();
|
|
62539
63000
|
}
|
|
62540
63001
|
});
|
|
62541
|
-
const accountFile =
|
|
63002
|
+
const accountFile = resolve30(accountFileForVault());
|
|
62542
63003
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
62543
63004
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
62544
63005
|
let vaultQuotaPoller;
|
|
@@ -62883,7 +63344,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62883
63344
|
const key = vaultAccountRowKey(row);
|
|
62884
63345
|
const existing = vaultSelectors.get(key);
|
|
62885
63346
|
if (existing) return existing;
|
|
62886
|
-
const selector =
|
|
63347
|
+
const selector = randomUUID25();
|
|
62887
63348
|
vaultSelectors.set(key, selector);
|
|
62888
63349
|
return selector;
|
|
62889
63350
|
},
|