@cortexkit/opencode-antigravity-auth 3.0.41 → 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 +1316 -1124
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +116 -106
- package/dist/index.js +1257 -720
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +187 -169
- package/dist/server.js +1310 -773
- 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/fs/refresh-file-lock.js +13 -9
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +65 -12
- package/dist/src/common-auth-embedded/routing-accessor/index.js +114 -15
- 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 +55 -46
- 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-helpers.d.ts +10 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +6 -0
- package/dist/src/plugin/request-helpers.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 +8 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +98 -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 +65 -12
- 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-helpers.d.ts +10 -0
- package/dist/types/src/plugin/request-helpers.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 +8 -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/fs/refresh-file-lock.js +13 -9
- package/src/common-auth-embedded/routing-accessor/index.d.ts +65 -12
- package/src/common-auth-embedded/routing-accessor/index.js +114 -15
- 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 +55 -46
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();
|
|
@@ -12840,15 +12899,438 @@ var init_lock_record = __esm({
|
|
|
12840
12899
|
}
|
|
12841
12900
|
});
|
|
12842
12901
|
|
|
12902
|
+
// ../core/dist/common-auth-embedded/logger/capture-sink.js
|
|
12903
|
+
function createCaptureSink() {
|
|
12904
|
+
const records = [];
|
|
12905
|
+
const sink = (record5) => {
|
|
12906
|
+
records.push(record5);
|
|
12907
|
+
};
|
|
12908
|
+
return {
|
|
12909
|
+
records,
|
|
12910
|
+
sink,
|
|
12911
|
+
clear: () => {
|
|
12912
|
+
records.length = 0;
|
|
12913
|
+
}
|
|
12914
|
+
};
|
|
12915
|
+
}
|
|
12916
|
+
var init_capture_sink = __esm({
|
|
12917
|
+
"../core/dist/common-auth-embedded/logger/capture-sink.js"() {
|
|
12918
|
+
"use strict";
|
|
12919
|
+
}
|
|
12920
|
+
});
|
|
12921
|
+
|
|
12922
|
+
// ../core/dist/common-auth-embedded/logger/redact.js
|
|
12923
|
+
function isError(value) {
|
|
12924
|
+
return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
|
|
12925
|
+
}
|
|
12926
|
+
function createRedactor(options = {}) {
|
|
12927
|
+
const patterns = [TOKEN_VALUE, ...options.extraValuePatterns ?? []].map((pattern) => new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`));
|
|
12928
|
+
function isSecretKey(key) {
|
|
12929
|
+
const normalized = key.toLowerCase().replace(/[-_]/g, "");
|
|
12930
|
+
return SECRET_KEY_EXACT.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
|
|
12931
|
+
}
|
|
12932
|
+
function errorEntries(error) {
|
|
12933
|
+
const fields2 = error;
|
|
12934
|
+
const entries = [
|
|
12935
|
+
["name", error.name],
|
|
12936
|
+
["message", error.message],
|
|
12937
|
+
["stack", error.stack]
|
|
12938
|
+
];
|
|
12939
|
+
for (const key of ["code", "status", "cause"])
|
|
12940
|
+
if (fields2[key] !== void 0)
|
|
12941
|
+
entries.push([key, fields2[key]]);
|
|
12942
|
+
const listed = new Set(entries.map(([key]) => key));
|
|
12943
|
+
for (const entry of Object.entries(error))
|
|
12944
|
+
if (!listed.has(entry[0]))
|
|
12945
|
+
entries.push(entry);
|
|
12946
|
+
return entries;
|
|
12947
|
+
}
|
|
12948
|
+
function walk(value, keys, seen, errorDepth = 0) {
|
|
12949
|
+
if (typeof value === "string") {
|
|
12950
|
+
return patterns.reduce((text2, pattern) => text2.replace(pattern, MASK), value);
|
|
12951
|
+
}
|
|
12952
|
+
if (!value || typeof value !== "object")
|
|
12953
|
+
return value;
|
|
12954
|
+
if (seen.has(value))
|
|
12955
|
+
return "[Circular]";
|
|
12956
|
+
seen.add(value);
|
|
12957
|
+
try {
|
|
12958
|
+
if (Array.isArray(value))
|
|
12959
|
+
return value.map((item) => walk(item, keys, seen, errorDepth));
|
|
12960
|
+
const error = isError(value);
|
|
12961
|
+
if (error && errorDepth >= MAX_ERROR_DEPTH)
|
|
12962
|
+
return "[Truncated]";
|
|
12963
|
+
const childDepth = error ? errorDepth + 1 : errorDepth;
|
|
12964
|
+
return Object.fromEntries((error ? errorEntries(value) : Object.entries(value)).map(([key, item]) => [
|
|
12965
|
+
key,
|
|
12966
|
+
keys && isSecretKey(key) ? MASK : walk(item, keys, seen, childDepth)
|
|
12967
|
+
]));
|
|
12968
|
+
} finally {
|
|
12969
|
+
seen.delete(value);
|
|
12970
|
+
}
|
|
12971
|
+
}
|
|
12972
|
+
return {
|
|
12973
|
+
redact: (value) => walk(value, true, /* @__PURE__ */ new WeakSet()),
|
|
12974
|
+
// Schema keys describe arguments, not credentials; only their string values are scrubbed.
|
|
12975
|
+
redactStrings: (value) => walk(value, false, /* @__PURE__ */ new WeakSet())
|
|
12976
|
+
};
|
|
12977
|
+
}
|
|
12978
|
+
var SECRET_KEY_EXACT, TOKEN_VALUE, MASK, MAX_ERROR_DEPTH, defaultRedactor, redact, redactStrings;
|
|
12979
|
+
var init_redact = __esm({
|
|
12980
|
+
"../core/dist/common-auth-embedded/logger/redact.js"() {
|
|
12981
|
+
"use strict";
|
|
12982
|
+
SECRET_KEY_EXACT = /^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i;
|
|
12983
|
+
TOKEN_VALUE = /\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b|ckh_[A-Za-z0-9_-]{20,}/g;
|
|
12984
|
+
MASK = "***REDACTED***";
|
|
12985
|
+
MAX_ERROR_DEPTH = 8;
|
|
12986
|
+
defaultRedactor = createRedactor();
|
|
12987
|
+
redact = defaultRedactor.redact;
|
|
12988
|
+
redactStrings = defaultRedactor.redactStrings;
|
|
12989
|
+
}
|
|
12990
|
+
});
|
|
12991
|
+
|
|
12992
|
+
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
12993
|
+
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
12994
|
+
import { open as open4 } from "node:fs/promises";
|
|
12995
|
+
import { dirname as dirname7, resolve as resolve4 } from "node:path";
|
|
12996
|
+
function chmodPrivate(path5) {
|
|
12997
|
+
try {
|
|
12998
|
+
chmodSync(path5, 384);
|
|
12999
|
+
} catch {
|
|
13000
|
+
}
|
|
13001
|
+
}
|
|
13002
|
+
function rotateIfNeeded(f) {
|
|
13003
|
+
try {
|
|
13004
|
+
if (!(existsSync(f) && statSync(f).size >= MAX_BYTES))
|
|
13005
|
+
return;
|
|
13006
|
+
for (let i = ROTATE_KEEP - 1; i >= 1; i--) {
|
|
13007
|
+
if (existsSync(`${f}.${i}`)) {
|
|
13008
|
+
const rotated2 = `${f}.${i + 1}`;
|
|
13009
|
+
renameSync(`${f}.${i}`, rotated2);
|
|
13010
|
+
chmodPrivate(rotated2);
|
|
13011
|
+
}
|
|
13012
|
+
}
|
|
13013
|
+
const rotated = `${f}.1`;
|
|
13014
|
+
renameSync(f, rotated);
|
|
13015
|
+
chmodPrivate(rotated);
|
|
13016
|
+
} catch {
|
|
13017
|
+
}
|
|
13018
|
+
}
|
|
13019
|
+
async function closeWindowsFile(sink) {
|
|
13020
|
+
const { file, handle } = sink;
|
|
13021
|
+
sink.file = void 0;
|
|
13022
|
+
sink.handle = void 0;
|
|
13023
|
+
if (file && handle)
|
|
13024
|
+
await privateOperation(file, "log-close", () => handle.close());
|
|
13025
|
+
}
|
|
13026
|
+
async function openWindowsFile(sink, file) {
|
|
13027
|
+
await ensurePrivateDirectory(dirname7(file));
|
|
13028
|
+
try {
|
|
13029
|
+
await verifyPrivate(file, "file", true);
|
|
13030
|
+
} catch (error) {
|
|
13031
|
+
if (error.code !== "ENOENT")
|
|
13032
|
+
throw error;
|
|
13033
|
+
try {
|
|
13034
|
+
await createPrivateBytes(file, "");
|
|
13035
|
+
} catch (creationError) {
|
|
13036
|
+
if (creationError.code !== "EEXIST")
|
|
13037
|
+
throw creationError;
|
|
13038
|
+
await verifyPrivate(file, "file", true);
|
|
13039
|
+
}
|
|
13040
|
+
}
|
|
13041
|
+
sink.handle = await privateOperation(file, "log-open", () => open4(file, "a"));
|
|
13042
|
+
sink.file = file;
|
|
13043
|
+
return sink.handle;
|
|
13044
|
+
}
|
|
13045
|
+
async function flushWindowsFile(sink, file, text2) {
|
|
13046
|
+
file = resolve4(file);
|
|
13047
|
+
try {
|
|
13048
|
+
if (sink.file !== file)
|
|
13049
|
+
await closeWindowsFile(sink);
|
|
13050
|
+
let handle = sink.handle ?? await openWindowsFile(sink, file);
|
|
13051
|
+
const info = await privateOperation(file, "log-stat", () => handle.stat());
|
|
13052
|
+
if (info.size >= MAX_BYTES) {
|
|
13053
|
+
await closeWindowsFile(sink);
|
|
13054
|
+
for (let i = ROTATE_KEEP - 1; i >= 0; i--) {
|
|
13055
|
+
const source = i === 0 ? file : `${file}.${i}`;
|
|
13056
|
+
const target = `${file}.${i + 1}`;
|
|
13057
|
+
try {
|
|
13058
|
+
await verifyPrivate(source, "file", true);
|
|
13059
|
+
} catch (error) {
|
|
13060
|
+
if (error.code === "ENOENT")
|
|
13061
|
+
continue;
|
|
13062
|
+
throw error;
|
|
13063
|
+
}
|
|
13064
|
+
try {
|
|
13065
|
+
await verifyPrivate(target, "file", true);
|
|
13066
|
+
} catch (error) {
|
|
13067
|
+
if (error.code !== "ENOENT")
|
|
13068
|
+
throw error;
|
|
13069
|
+
}
|
|
13070
|
+
await replaceWindowsFile(source, target);
|
|
13071
|
+
await verifyPrivate(target, "file");
|
|
13072
|
+
}
|
|
13073
|
+
handle = await openWindowsFile(sink, file);
|
|
13074
|
+
}
|
|
13075
|
+
await privateOperation(file, "log-append", () => handle.appendFile(text2, "utf8"));
|
|
13076
|
+
} catch (error) {
|
|
13077
|
+
await closeWindowsFile(sink).catch(() => {
|
|
13078
|
+
});
|
|
13079
|
+
throw error;
|
|
13080
|
+
}
|
|
13081
|
+
}
|
|
13082
|
+
function safeSerialize(data) {
|
|
13083
|
+
try {
|
|
13084
|
+
return ` ${JSON.stringify(data)}`;
|
|
13085
|
+
} catch {
|
|
13086
|
+
return " [unserializable]";
|
|
13087
|
+
}
|
|
13088
|
+
}
|
|
13089
|
+
function createEngine(options) {
|
|
13090
|
+
let logFileSource;
|
|
13091
|
+
let initLevelSource;
|
|
13092
|
+
let runtimeLevel;
|
|
13093
|
+
let redactor = createRedactor();
|
|
13094
|
+
let captureSink;
|
|
13095
|
+
let buffer = [];
|
|
13096
|
+
let timer;
|
|
13097
|
+
let orderedSink = Promise.resolve();
|
|
13098
|
+
let sinkError;
|
|
13099
|
+
const windowsFile = {};
|
|
13100
|
+
function queueWindows(operation) {
|
|
13101
|
+
const next = orderedSink.then(operation);
|
|
13102
|
+
orderedSink = next.catch((error) => {
|
|
13103
|
+
sinkError = error;
|
|
13104
|
+
});
|
|
13105
|
+
return next;
|
|
13106
|
+
}
|
|
13107
|
+
function configure(next) {
|
|
13108
|
+
if (windowsPrivateFiles && next.file !== logFileSource)
|
|
13109
|
+
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => {
|
|
13110
|
+
});
|
|
13111
|
+
logFileSource = next.file;
|
|
13112
|
+
initLevelSource = next.level;
|
|
13113
|
+
redactor = createRedactor(next);
|
|
13114
|
+
captureSink = next.captureSink;
|
|
13115
|
+
}
|
|
13116
|
+
function setLogLevel3(l) {
|
|
13117
|
+
if (l === void 0 || l in ORDER)
|
|
13118
|
+
runtimeLevel = l;
|
|
13119
|
+
}
|
|
13120
|
+
function logFilePath() {
|
|
13121
|
+
if (logFileSource === void 0)
|
|
13122
|
+
return void 0;
|
|
13123
|
+
const resolved = typeof logFileSource === "function" ? logFileSource() : logFileSource;
|
|
13124
|
+
return resolved || void 0;
|
|
13125
|
+
}
|
|
13126
|
+
function configuredLevel() {
|
|
13127
|
+
if (runtimeLevel)
|
|
13128
|
+
return runtimeLevel;
|
|
13129
|
+
const floor = typeof initLevelSource === "function" ? initLevelSource() : initLevelSource;
|
|
13130
|
+
if (floor && floor in ORDER)
|
|
13131
|
+
return floor;
|
|
13132
|
+
return "info";
|
|
13133
|
+
}
|
|
13134
|
+
function flushLogs3(close = true) {
|
|
13135
|
+
if (timer) {
|
|
13136
|
+
clearTimeout(timer);
|
|
13137
|
+
timer = void 0;
|
|
13138
|
+
}
|
|
13139
|
+
if (!buffer.length) {
|
|
13140
|
+
if (windowsPrivateFiles)
|
|
13141
|
+
return queueWindows(async () => {
|
|
13142
|
+
if (close)
|
|
13143
|
+
await closeWindowsFile(windowsFile);
|
|
13144
|
+
if (sinkError)
|
|
13145
|
+
throw sinkError;
|
|
13146
|
+
});
|
|
13147
|
+
return;
|
|
13148
|
+
}
|
|
13149
|
+
let file;
|
|
13150
|
+
try {
|
|
13151
|
+
file = logFilePath();
|
|
13152
|
+
} catch {
|
|
13153
|
+
buffer = [];
|
|
13154
|
+
if (windowsPrivateFiles && close)
|
|
13155
|
+
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
13156
|
+
return;
|
|
13157
|
+
}
|
|
13158
|
+
const text2 = buffer.join("");
|
|
13159
|
+
buffer = [];
|
|
13160
|
+
if (!file) {
|
|
13161
|
+
if (windowsPrivateFiles && close)
|
|
13162
|
+
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
13163
|
+
return;
|
|
13164
|
+
}
|
|
13165
|
+
if (windowsPrivateFiles) {
|
|
13166
|
+
return queueWindows(async () => {
|
|
13167
|
+
try {
|
|
13168
|
+
await flushWindowsFile(windowsFile, file, text2);
|
|
13169
|
+
} finally {
|
|
13170
|
+
if (close)
|
|
13171
|
+
await closeWindowsFile(windowsFile);
|
|
13172
|
+
}
|
|
13173
|
+
});
|
|
13174
|
+
}
|
|
13175
|
+
try {
|
|
13176
|
+
rotateIfNeeded(file);
|
|
13177
|
+
if (existsSync(file))
|
|
13178
|
+
chmodPrivate(file);
|
|
13179
|
+
appendFileSync(file, text2, { encoding: "utf8", mode: 384 });
|
|
13180
|
+
} catch {
|
|
13181
|
+
}
|
|
13182
|
+
}
|
|
13183
|
+
function schedule2() {
|
|
13184
|
+
if (!timer)
|
|
13185
|
+
timer = setTimeout(() => {
|
|
13186
|
+
timer = void 0;
|
|
13187
|
+
const flushed = flushLogs3(false);
|
|
13188
|
+
if (flushed instanceof Promise)
|
|
13189
|
+
void flushed.catch(() => {
|
|
13190
|
+
});
|
|
13191
|
+
}, 500);
|
|
13192
|
+
}
|
|
13193
|
+
function emit(channel3, level, message, data) {
|
|
13194
|
+
if (logFileSource === void 0 && captureSink === void 0)
|
|
13195
|
+
return;
|
|
13196
|
+
try {
|
|
13197
|
+
if (ORDER[level] > ORDER[configuredLevel()])
|
|
13198
|
+
return;
|
|
13199
|
+
const scrubbedMessage = redactor.redactStrings(message);
|
|
13200
|
+
let scrubbedData;
|
|
13201
|
+
try {
|
|
13202
|
+
scrubbedData = redactor.redact(data);
|
|
13203
|
+
} catch {
|
|
13204
|
+
scrubbedData = "[unserializable]";
|
|
13205
|
+
}
|
|
13206
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
|
|
13207
|
+
try {
|
|
13208
|
+
captureSink?.({
|
|
13209
|
+
channel: channel3,
|
|
13210
|
+
level,
|
|
13211
|
+
message: scrubbedMessage,
|
|
13212
|
+
data: scrubbedData
|
|
13213
|
+
});
|
|
13214
|
+
} catch {
|
|
13215
|
+
}
|
|
13216
|
+
if (logFileSource === void 0)
|
|
13217
|
+
return;
|
|
13218
|
+
buffer.push(line);
|
|
13219
|
+
if (buffer.length >= 50) {
|
|
13220
|
+
const flushed = flushLogs3(false);
|
|
13221
|
+
if (flushed instanceof Promise)
|
|
13222
|
+
void flushed.catch(() => {
|
|
13223
|
+
});
|
|
13224
|
+
} else
|
|
13225
|
+
schedule2();
|
|
13226
|
+
} catch {
|
|
13227
|
+
}
|
|
13228
|
+
}
|
|
13229
|
+
function createLogger5(channel3) {
|
|
13230
|
+
return {
|
|
13231
|
+
error: (m, d) => emit(channel3, "error", m, d),
|
|
13232
|
+
warn: (m, d) => emit(channel3, "warn", m, d),
|
|
13233
|
+
info: (m, d) => emit(channel3, "info", m, d),
|
|
13234
|
+
debug: (m, d) => emit(channel3, "debug", m, d),
|
|
13235
|
+
trace: (m, d) => emit(channel3, "trace", m, d)
|
|
13236
|
+
};
|
|
13237
|
+
}
|
|
13238
|
+
function reset() {
|
|
13239
|
+
if (windowsPrivateFiles)
|
|
13240
|
+
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => {
|
|
13241
|
+
});
|
|
13242
|
+
sinkError = void 0;
|
|
13243
|
+
buffer = [];
|
|
13244
|
+
if (timer) {
|
|
13245
|
+
clearTimeout(timer);
|
|
13246
|
+
timer = void 0;
|
|
13247
|
+
}
|
|
13248
|
+
logFileSource = void 0;
|
|
13249
|
+
initLevelSource = void 0;
|
|
13250
|
+
runtimeLevel = void 0;
|
|
13251
|
+
redactor = createRedactor();
|
|
13252
|
+
captureSink = void 0;
|
|
13253
|
+
}
|
|
13254
|
+
if (options)
|
|
13255
|
+
configure(options);
|
|
13256
|
+
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3, reset };
|
|
13257
|
+
}
|
|
13258
|
+
function createLoggerInstance(options) {
|
|
13259
|
+
const { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 } = createEngine(options);
|
|
13260
|
+
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 };
|
|
13261
|
+
}
|
|
13262
|
+
function initLogger(options) {
|
|
13263
|
+
defaultEngine.configure(options);
|
|
13264
|
+
const { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 } = defaultEngine;
|
|
13265
|
+
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 };
|
|
13266
|
+
}
|
|
13267
|
+
function setLogLevel(l) {
|
|
13268
|
+
defaultEngine.setLogLevel(l);
|
|
13269
|
+
}
|
|
13270
|
+
function flushLogs() {
|
|
13271
|
+
return defaultEngine.flushLogs();
|
|
13272
|
+
}
|
|
13273
|
+
function createLogger2(channel3) {
|
|
13274
|
+
return defaultEngine.createLogger(channel3);
|
|
13275
|
+
}
|
|
13276
|
+
async function flushForTest() {
|
|
13277
|
+
return defaultEngine.flushLogs();
|
|
13278
|
+
}
|
|
13279
|
+
function resetLoggerForTest() {
|
|
13280
|
+
defaultEngine.reset();
|
|
13281
|
+
}
|
|
13282
|
+
var ORDER, MAX_BYTES, ROTATE_KEEP, defaultEngine;
|
|
13283
|
+
var init_engine = __esm({
|
|
13284
|
+
"../core/dist/common-auth-embedded/logger/engine.js"() {
|
|
13285
|
+
"use strict";
|
|
13286
|
+
init_private_files();
|
|
13287
|
+
init_redact();
|
|
13288
|
+
ORDER = {
|
|
13289
|
+
error: 0,
|
|
13290
|
+
warn: 1,
|
|
13291
|
+
info: 2,
|
|
13292
|
+
debug: 3,
|
|
13293
|
+
trace: 4
|
|
13294
|
+
};
|
|
13295
|
+
MAX_BYTES = 5 * 1024 * 1024;
|
|
13296
|
+
ROTATE_KEEP = 3;
|
|
13297
|
+
defaultEngine = createEngine();
|
|
13298
|
+
}
|
|
13299
|
+
});
|
|
13300
|
+
|
|
13301
|
+
// ../core/dist/common-auth-embedded/logger/index.js
|
|
13302
|
+
var logger_exports = {};
|
|
13303
|
+
__export(logger_exports, {
|
|
13304
|
+
createCaptureSink: () => createCaptureSink,
|
|
13305
|
+
createLogger: () => createLogger2,
|
|
13306
|
+
createLoggerInstance: () => createLoggerInstance,
|
|
13307
|
+
createRedactor: () => createRedactor,
|
|
13308
|
+
flushForTest: () => flushForTest,
|
|
13309
|
+
flushLogs: () => flushLogs,
|
|
13310
|
+
initLogger: () => initLogger,
|
|
13311
|
+
redact: () => redact,
|
|
13312
|
+
redactStrings: () => redactStrings,
|
|
13313
|
+
resetLoggerForTest: () => resetLoggerForTest,
|
|
13314
|
+
setLogLevel: () => setLogLevel
|
|
13315
|
+
});
|
|
13316
|
+
var init_logger2 = __esm({
|
|
13317
|
+
"../core/dist/common-auth-embedded/logger/index.js"() {
|
|
13318
|
+
"use strict";
|
|
13319
|
+
init_capture_sink();
|
|
13320
|
+
init_engine();
|
|
13321
|
+
init_redact();
|
|
13322
|
+
}
|
|
13323
|
+
});
|
|
13324
|
+
|
|
12843
13325
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
12844
13326
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
12845
|
-
import { link as link2, lstat as lstat3, mkdir as mkdir7, open as
|
|
12846
|
-
import { basename as basename3, dirname as
|
|
13327
|
+
import { link as link2, lstat as lstat3, mkdir as mkdir7, open as open5, readdir, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3, unlink as unlink6 } from "node:fs/promises";
|
|
13328
|
+
import { basename as basename3, dirname as dirname8, join as join5 } from "node:path";
|
|
12847
13329
|
async function createExclusiveText(path5, text2) {
|
|
12848
13330
|
const tempPath = `${path5}.${randomUUID9()}.tmp`;
|
|
12849
13331
|
let handle;
|
|
12850
13332
|
try {
|
|
12851
|
-
handle = await
|
|
13333
|
+
handle = await open5(tempPath, "wx", 384);
|
|
12852
13334
|
try {
|
|
12853
13335
|
if (leaseCreationTestHooks?.beforeWrite)
|
|
12854
13336
|
await leaseCreationTestHooks.beforeWrite(tempPath);
|
|
@@ -12873,7 +13355,7 @@ async function createExclusiveText(path5, text2) {
|
|
|
12873
13355
|
}
|
|
12874
13356
|
}
|
|
12875
13357
|
async function writeExclusiveText(path5, text2) {
|
|
12876
|
-
const handle = await
|
|
13358
|
+
const handle = await open5(path5, "wx", 384);
|
|
12877
13359
|
let createdStat;
|
|
12878
13360
|
try {
|
|
12879
13361
|
createdStat = await handle.stat();
|
|
@@ -12914,7 +13396,7 @@ async function readStagedOwner(path5) {
|
|
|
12914
13396
|
return void 0;
|
|
12915
13397
|
if (before.size > STAGING_SWEEP_MAX_BYTES)
|
|
12916
13398
|
return void 0;
|
|
12917
|
-
const handle = await
|
|
13399
|
+
const handle = await open5(path5, "r");
|
|
12918
13400
|
let text2;
|
|
12919
13401
|
try {
|
|
12920
13402
|
if (!sameStagingFile(before, await handle.stat()))
|
|
@@ -12942,7 +13424,7 @@ async function readStagedOwner(path5) {
|
|
|
12942
13424
|
return { identity: before, expiresAt };
|
|
12943
13425
|
}
|
|
12944
13426
|
async function sweepAbandonedStaging(lockPath, ttlMs, now) {
|
|
12945
|
-
const directory =
|
|
13427
|
+
const directory = dirname8(lockPath);
|
|
12946
13428
|
const lockName = basename3(lockPath);
|
|
12947
13429
|
const hooks = stagingSweepTestHooks;
|
|
12948
13430
|
const names = await (hooks?.readdir ?? readdir)(directory);
|
|
@@ -12999,8 +13481,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12999
13481
|
let releaseConfirmed = false;
|
|
13000
13482
|
let loss;
|
|
13001
13483
|
let resolveLoss;
|
|
13002
|
-
const lostPromise = new Promise((
|
|
13003
|
-
resolveLoss =
|
|
13484
|
+
const lostPromise = new Promise((resolve31) => {
|
|
13485
|
+
resolveLoss = resolve31;
|
|
13004
13486
|
});
|
|
13005
13487
|
function notifyTimerStep(event) {
|
|
13006
13488
|
try {
|
|
@@ -13084,7 +13566,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13084
13566
|
let handle;
|
|
13085
13567
|
let created = false;
|
|
13086
13568
|
try {
|
|
13087
|
-
handle = await
|
|
13569
|
+
handle = await open5(tempPath, "wx", 384);
|
|
13088
13570
|
created = true;
|
|
13089
13571
|
await handle.writeFile(`${JSON.stringify({ ownerId, expiresAt: now() + options.ttlMs })}
|
|
13090
13572
|
`, "utf8");
|
|
@@ -13138,7 +13620,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13138
13620
|
}
|
|
13139
13621
|
async function tryAcquire() {
|
|
13140
13622
|
if (windowsPrivateFiles)
|
|
13141
|
-
await ensurePrivateDirectory(
|
|
13623
|
+
await ensurePrivateDirectory(dirname8(lockPath));
|
|
13142
13624
|
try {
|
|
13143
13625
|
await createLease();
|
|
13144
13626
|
return true;
|
|
@@ -13148,9 +13630,9 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13148
13630
|
return false;
|
|
13149
13631
|
if (code2 === "ENOENT") {
|
|
13150
13632
|
if (windowsPrivateFiles)
|
|
13151
|
-
await ensurePrivateDirectory(
|
|
13633
|
+
await ensurePrivateDirectory(dirname8(lockPath));
|
|
13152
13634
|
else
|
|
13153
|
-
await mkdir7(
|
|
13635
|
+
await mkdir7(dirname8(lockPath), { recursive: true });
|
|
13154
13636
|
try {
|
|
13155
13637
|
await createLease();
|
|
13156
13638
|
return true;
|
|
@@ -13164,7 +13646,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13164
13646
|
}
|
|
13165
13647
|
}
|
|
13166
13648
|
async function backoff() {
|
|
13167
|
-
await new Promise((
|
|
13649
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.floor(Math.random() * 4)));
|
|
13168
13650
|
}
|
|
13169
13651
|
async function readLockState(notifyReady = true) {
|
|
13170
13652
|
if (notifyReady && options.onStep)
|
|
@@ -13257,7 +13739,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13257
13739
|
const remainingMs = deadline - performance.now();
|
|
13258
13740
|
if (remainingMs <= 0)
|
|
13259
13741
|
throw original;
|
|
13260
|
-
await new Promise((
|
|
13742
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
13261
13743
|
if (performance.now() >= deadline)
|
|
13262
13744
|
throw original;
|
|
13263
13745
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -13731,17 +14213,15 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13731
14213
|
removalConfirmed = true;
|
|
13732
14214
|
}, deadline);
|
|
13733
14215
|
changingRecordError = void 0;
|
|
13734
|
-
if (markerAcquired) {
|
|
13735
|
-
|
|
13736
|
-
throw new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13737
|
-
code: "EIO"
|
|
13738
|
-
});
|
|
13739
|
-
releaseConfirmed = removalConfirmed;
|
|
14216
|
+
if (markerAcquired && removalConfirmed) {
|
|
14217
|
+
releaseConfirmed = true;
|
|
13740
14218
|
return;
|
|
13741
14219
|
}
|
|
13742
|
-
if (
|
|
13743
|
-
|
|
13744
|
-
|
|
14220
|
+
if (!markerAcquired) {
|
|
14221
|
+
if (signal?.aborted)
|
|
14222
|
+
return;
|
|
14223
|
+
await recoverStaleEvictionMarker(deadline);
|
|
14224
|
+
}
|
|
13745
14225
|
} catch (error) {
|
|
13746
14226
|
const changingRecord = windowsPrivateFiles && (isChangingLockCreate(error) || isWindowsAccessDeniedRead(error, [
|
|
13747
14227
|
lockPath,
|
|
@@ -13762,7 +14242,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13762
14242
|
const remainingMs = deadline - performance.now();
|
|
13763
14243
|
if (remainingMs <= 0)
|
|
13764
14244
|
break;
|
|
13765
|
-
await new Promise((
|
|
14245
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
13766
14246
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
13767
14247
|
break;
|
|
13768
14248
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -13771,6 +14251,9 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13771
14251
|
throw changingRecordError ?? removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13772
14252
|
code: "ETIMEDOUT"
|
|
13773
14253
|
});
|
|
14254
|
+
createLogger2("fs").warn("File lock release deadline expired", {
|
|
14255
|
+
lockPath
|
|
14256
|
+
});
|
|
13774
14257
|
}
|
|
13775
14258
|
};
|
|
13776
14259
|
}
|
|
@@ -13778,6 +14261,7 @@ var leaseCreationTestHooks, STAGING_UUID, STAGING_SWEEP_MIN_AGE_MS, STAGING_SWEE
|
|
|
13778
14261
|
var init_refresh_file_lock = __esm({
|
|
13779
14262
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
|
|
13780
14263
|
"use strict";
|
|
14264
|
+
init_logger2();
|
|
13781
14265
|
init_lock_record();
|
|
13782
14266
|
init_private_files();
|
|
13783
14267
|
init_with_lock();
|
|
@@ -13794,12 +14278,12 @@ var init_refresh_file_lock = __esm({
|
|
|
13794
14278
|
});
|
|
13795
14279
|
|
|
13796
14280
|
// ../core/dist/common-auth-embedded/fs/with-lock.js
|
|
13797
|
-
import { join as join6, resolve as
|
|
14281
|
+
import { join as join6, resolve as resolve5 } from "node:path";
|
|
13798
14282
|
function lockPathFor(target, name) {
|
|
13799
14283
|
return `${target}.${name}.lock`;
|
|
13800
14284
|
}
|
|
13801
14285
|
function isChangingLockRecord(error, target, name) {
|
|
13802
|
-
const path5 =
|
|
14286
|
+
const path5 = resolve5(lockPathFor(target, name));
|
|
13803
14287
|
const paths = [path5, join6(path5, "owner.json")];
|
|
13804
14288
|
return (isWindowsSharingViolation(error) || isWindowsAccessDeniedRead(error, paths)) && (error.stage === "read" || error.stage === "verify") && paths.includes(error.path) || windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [path5], "create") || isWindowsAccessDeniedCreate(error, [`${path5}.evicting`], "directory-create"));
|
|
13805
14289
|
}
|
|
@@ -13843,7 +14327,7 @@ async function withLock(target, options, fn) {
|
|
|
13843
14327
|
timeoutMs: options.timeoutMs
|
|
13844
14328
|
});
|
|
13845
14329
|
}
|
|
13846
|
-
await new Promise((
|
|
14330
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(25, Math.ceil(remaining))));
|
|
13847
14331
|
}
|
|
13848
14332
|
}
|
|
13849
14333
|
var LockContentionError, LockOwnershipError;
|
|
@@ -13933,7 +14417,7 @@ async function acquirePoolLock(spec, defaults2, env3) {
|
|
|
13933
14417
|
});
|
|
13934
14418
|
}
|
|
13935
14419
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
13936
|
-
await new Promise((
|
|
14420
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(options.retryMs + jitter, remaining)));
|
|
13937
14421
|
}
|
|
13938
14422
|
}
|
|
13939
14423
|
function definedOnly(spec) {
|
|
@@ -16734,429 +17218,6 @@ var init_pull = __esm({
|
|
|
16734
17218
|
}
|
|
16735
17219
|
});
|
|
16736
17220
|
|
|
16737
|
-
// ../core/dist/common-auth-embedded/logger/capture-sink.js
|
|
16738
|
-
function createCaptureSink() {
|
|
16739
|
-
const records = [];
|
|
16740
|
-
const sink = (record5) => {
|
|
16741
|
-
records.push(record5);
|
|
16742
|
-
};
|
|
16743
|
-
return {
|
|
16744
|
-
records,
|
|
16745
|
-
sink,
|
|
16746
|
-
clear: () => {
|
|
16747
|
-
records.length = 0;
|
|
16748
|
-
}
|
|
16749
|
-
};
|
|
16750
|
-
}
|
|
16751
|
-
var init_capture_sink = __esm({
|
|
16752
|
-
"../core/dist/common-auth-embedded/logger/capture-sink.js"() {
|
|
16753
|
-
"use strict";
|
|
16754
|
-
}
|
|
16755
|
-
});
|
|
16756
|
-
|
|
16757
|
-
// ../core/dist/common-auth-embedded/logger/redact.js
|
|
16758
|
-
function isError(value) {
|
|
16759
|
-
return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
|
|
16760
|
-
}
|
|
16761
|
-
function createRedactor(options = {}) {
|
|
16762
|
-
const patterns = [TOKEN_VALUE, ...options.extraValuePatterns ?? []].map((pattern) => new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`));
|
|
16763
|
-
function isSecretKey(key) {
|
|
16764
|
-
const normalized = key.toLowerCase().replace(/[-_]/g, "");
|
|
16765
|
-
return SECRET_KEY_EXACT.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
|
|
16766
|
-
}
|
|
16767
|
-
function errorEntries(error) {
|
|
16768
|
-
const fields2 = error;
|
|
16769
|
-
const entries = [
|
|
16770
|
-
["name", error.name],
|
|
16771
|
-
["message", error.message],
|
|
16772
|
-
["stack", error.stack]
|
|
16773
|
-
];
|
|
16774
|
-
for (const key of ["code", "status", "cause"])
|
|
16775
|
-
if (fields2[key] !== void 0)
|
|
16776
|
-
entries.push([key, fields2[key]]);
|
|
16777
|
-
const listed = new Set(entries.map(([key]) => key));
|
|
16778
|
-
for (const entry of Object.entries(error))
|
|
16779
|
-
if (!listed.has(entry[0]))
|
|
16780
|
-
entries.push(entry);
|
|
16781
|
-
return entries;
|
|
16782
|
-
}
|
|
16783
|
-
function walk(value, keys, seen, errorDepth = 0) {
|
|
16784
|
-
if (typeof value === "string") {
|
|
16785
|
-
return patterns.reduce((text2, pattern) => text2.replace(pattern, MASK), value);
|
|
16786
|
-
}
|
|
16787
|
-
if (!value || typeof value !== "object")
|
|
16788
|
-
return value;
|
|
16789
|
-
if (seen.has(value))
|
|
16790
|
-
return "[Circular]";
|
|
16791
|
-
seen.add(value);
|
|
16792
|
-
try {
|
|
16793
|
-
if (Array.isArray(value))
|
|
16794
|
-
return value.map((item) => walk(item, keys, seen, errorDepth));
|
|
16795
|
-
const error = isError(value);
|
|
16796
|
-
if (error && errorDepth >= MAX_ERROR_DEPTH)
|
|
16797
|
-
return "[Truncated]";
|
|
16798
|
-
const childDepth = error ? errorDepth + 1 : errorDepth;
|
|
16799
|
-
return Object.fromEntries((error ? errorEntries(value) : Object.entries(value)).map(([key, item]) => [
|
|
16800
|
-
key,
|
|
16801
|
-
keys && isSecretKey(key) ? MASK : walk(item, keys, seen, childDepth)
|
|
16802
|
-
]));
|
|
16803
|
-
} finally {
|
|
16804
|
-
seen.delete(value);
|
|
16805
|
-
}
|
|
16806
|
-
}
|
|
16807
|
-
return {
|
|
16808
|
-
redact: (value) => walk(value, true, /* @__PURE__ */ new WeakSet()),
|
|
16809
|
-
// Schema keys describe arguments, not credentials; only their string values are scrubbed.
|
|
16810
|
-
redactStrings: (value) => walk(value, false, /* @__PURE__ */ new WeakSet())
|
|
16811
|
-
};
|
|
16812
|
-
}
|
|
16813
|
-
var SECRET_KEY_EXACT, TOKEN_VALUE, MASK, MAX_ERROR_DEPTH, defaultRedactor, redact, redactStrings;
|
|
16814
|
-
var init_redact = __esm({
|
|
16815
|
-
"../core/dist/common-auth-embedded/logger/redact.js"() {
|
|
16816
|
-
"use strict";
|
|
16817
|
-
SECRET_KEY_EXACT = /^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i;
|
|
16818
|
-
TOKEN_VALUE = /\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b|ckh_[A-Za-z0-9_-]{20,}/g;
|
|
16819
|
-
MASK = "***REDACTED***";
|
|
16820
|
-
MAX_ERROR_DEPTH = 8;
|
|
16821
|
-
defaultRedactor = createRedactor();
|
|
16822
|
-
redact = defaultRedactor.redact;
|
|
16823
|
-
redactStrings = defaultRedactor.redactStrings;
|
|
16824
|
-
}
|
|
16825
|
-
});
|
|
16826
|
-
|
|
16827
|
-
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
16828
|
-
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
16829
|
-
import { open as open5 } from "node:fs/promises";
|
|
16830
|
-
import { dirname as dirname8, resolve as resolve5 } from "node:path";
|
|
16831
|
-
function chmodPrivate(path5) {
|
|
16832
|
-
try {
|
|
16833
|
-
chmodSync(path5, 384);
|
|
16834
|
-
} catch {
|
|
16835
|
-
}
|
|
16836
|
-
}
|
|
16837
|
-
function rotateIfNeeded(f) {
|
|
16838
|
-
try {
|
|
16839
|
-
if (!(existsSync(f) && statSync(f).size >= MAX_BYTES))
|
|
16840
|
-
return;
|
|
16841
|
-
for (let i = ROTATE_KEEP - 1; i >= 1; i--) {
|
|
16842
|
-
if (existsSync(`${f}.${i}`)) {
|
|
16843
|
-
const rotated2 = `${f}.${i + 1}`;
|
|
16844
|
-
renameSync(`${f}.${i}`, rotated2);
|
|
16845
|
-
chmodPrivate(rotated2);
|
|
16846
|
-
}
|
|
16847
|
-
}
|
|
16848
|
-
const rotated = `${f}.1`;
|
|
16849
|
-
renameSync(f, rotated);
|
|
16850
|
-
chmodPrivate(rotated);
|
|
16851
|
-
} catch {
|
|
16852
|
-
}
|
|
16853
|
-
}
|
|
16854
|
-
async function closeWindowsFile(sink) {
|
|
16855
|
-
const { file, handle } = sink;
|
|
16856
|
-
sink.file = void 0;
|
|
16857
|
-
sink.handle = void 0;
|
|
16858
|
-
if (file && handle)
|
|
16859
|
-
await privateOperation(file, "log-close", () => handle.close());
|
|
16860
|
-
}
|
|
16861
|
-
async function openWindowsFile(sink, file) {
|
|
16862
|
-
await ensurePrivateDirectory(dirname8(file));
|
|
16863
|
-
try {
|
|
16864
|
-
await verifyPrivate(file, "file", true);
|
|
16865
|
-
} catch (error) {
|
|
16866
|
-
if (error.code !== "ENOENT")
|
|
16867
|
-
throw error;
|
|
16868
|
-
try {
|
|
16869
|
-
await createPrivateBytes(file, "");
|
|
16870
|
-
} catch (creationError) {
|
|
16871
|
-
if (creationError.code !== "EEXIST")
|
|
16872
|
-
throw creationError;
|
|
16873
|
-
await verifyPrivate(file, "file", true);
|
|
16874
|
-
}
|
|
16875
|
-
}
|
|
16876
|
-
sink.handle = await privateOperation(file, "log-open", () => open5(file, "a"));
|
|
16877
|
-
sink.file = file;
|
|
16878
|
-
return sink.handle;
|
|
16879
|
-
}
|
|
16880
|
-
async function flushWindowsFile(sink, file, text2) {
|
|
16881
|
-
file = resolve5(file);
|
|
16882
|
-
try {
|
|
16883
|
-
if (sink.file !== file)
|
|
16884
|
-
await closeWindowsFile(sink);
|
|
16885
|
-
let handle = sink.handle ?? await openWindowsFile(sink, file);
|
|
16886
|
-
const info = await privateOperation(file, "log-stat", () => handle.stat());
|
|
16887
|
-
if (info.size >= MAX_BYTES) {
|
|
16888
|
-
await closeWindowsFile(sink);
|
|
16889
|
-
for (let i = ROTATE_KEEP - 1; i >= 0; i--) {
|
|
16890
|
-
const source = i === 0 ? file : `${file}.${i}`;
|
|
16891
|
-
const target = `${file}.${i + 1}`;
|
|
16892
|
-
try {
|
|
16893
|
-
await verifyPrivate(source, "file", true);
|
|
16894
|
-
} catch (error) {
|
|
16895
|
-
if (error.code === "ENOENT")
|
|
16896
|
-
continue;
|
|
16897
|
-
throw error;
|
|
16898
|
-
}
|
|
16899
|
-
try {
|
|
16900
|
-
await verifyPrivate(target, "file", true);
|
|
16901
|
-
} catch (error) {
|
|
16902
|
-
if (error.code !== "ENOENT")
|
|
16903
|
-
throw error;
|
|
16904
|
-
}
|
|
16905
|
-
await replaceWindowsFile(source, target);
|
|
16906
|
-
await verifyPrivate(target, "file");
|
|
16907
|
-
}
|
|
16908
|
-
handle = await openWindowsFile(sink, file);
|
|
16909
|
-
}
|
|
16910
|
-
await privateOperation(file, "log-append", () => handle.appendFile(text2, "utf8"));
|
|
16911
|
-
} catch (error) {
|
|
16912
|
-
await closeWindowsFile(sink).catch(() => {
|
|
16913
|
-
});
|
|
16914
|
-
throw error;
|
|
16915
|
-
}
|
|
16916
|
-
}
|
|
16917
|
-
function safeSerialize(data) {
|
|
16918
|
-
try {
|
|
16919
|
-
return ` ${JSON.stringify(data)}`;
|
|
16920
|
-
} catch {
|
|
16921
|
-
return " [unserializable]";
|
|
16922
|
-
}
|
|
16923
|
-
}
|
|
16924
|
-
function createEngine(options) {
|
|
16925
|
-
let logFileSource;
|
|
16926
|
-
let initLevelSource;
|
|
16927
|
-
let runtimeLevel;
|
|
16928
|
-
let redactor = createRedactor();
|
|
16929
|
-
let captureSink;
|
|
16930
|
-
let buffer = [];
|
|
16931
|
-
let timer;
|
|
16932
|
-
let orderedSink = Promise.resolve();
|
|
16933
|
-
let sinkError;
|
|
16934
|
-
const windowsFile = {};
|
|
16935
|
-
function queueWindows(operation) {
|
|
16936
|
-
const next = orderedSink.then(operation);
|
|
16937
|
-
orderedSink = next.catch((error) => {
|
|
16938
|
-
sinkError = error;
|
|
16939
|
-
});
|
|
16940
|
-
return next;
|
|
16941
|
-
}
|
|
16942
|
-
function configure(next) {
|
|
16943
|
-
if (windowsPrivateFiles && next.file !== logFileSource)
|
|
16944
|
-
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => {
|
|
16945
|
-
});
|
|
16946
|
-
logFileSource = next.file;
|
|
16947
|
-
initLevelSource = next.level;
|
|
16948
|
-
redactor = createRedactor(next);
|
|
16949
|
-
captureSink = next.captureSink;
|
|
16950
|
-
}
|
|
16951
|
-
function setLogLevel3(l) {
|
|
16952
|
-
if (l === void 0 || l in ORDER)
|
|
16953
|
-
runtimeLevel = l;
|
|
16954
|
-
}
|
|
16955
|
-
function logFilePath() {
|
|
16956
|
-
if (logFileSource === void 0)
|
|
16957
|
-
return void 0;
|
|
16958
|
-
const resolved = typeof logFileSource === "function" ? logFileSource() : logFileSource;
|
|
16959
|
-
return resolved || void 0;
|
|
16960
|
-
}
|
|
16961
|
-
function configuredLevel() {
|
|
16962
|
-
if (runtimeLevel)
|
|
16963
|
-
return runtimeLevel;
|
|
16964
|
-
const floor = typeof initLevelSource === "function" ? initLevelSource() : initLevelSource;
|
|
16965
|
-
if (floor && floor in ORDER)
|
|
16966
|
-
return floor;
|
|
16967
|
-
return "info";
|
|
16968
|
-
}
|
|
16969
|
-
function flushLogs3(close = true) {
|
|
16970
|
-
if (timer) {
|
|
16971
|
-
clearTimeout(timer);
|
|
16972
|
-
timer = void 0;
|
|
16973
|
-
}
|
|
16974
|
-
if (!buffer.length) {
|
|
16975
|
-
if (windowsPrivateFiles)
|
|
16976
|
-
return queueWindows(async () => {
|
|
16977
|
-
if (close)
|
|
16978
|
-
await closeWindowsFile(windowsFile);
|
|
16979
|
-
if (sinkError)
|
|
16980
|
-
throw sinkError;
|
|
16981
|
-
});
|
|
16982
|
-
return;
|
|
16983
|
-
}
|
|
16984
|
-
let file;
|
|
16985
|
-
try {
|
|
16986
|
-
file = logFilePath();
|
|
16987
|
-
} catch {
|
|
16988
|
-
buffer = [];
|
|
16989
|
-
if (windowsPrivateFiles && close)
|
|
16990
|
-
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
16991
|
-
return;
|
|
16992
|
-
}
|
|
16993
|
-
const text2 = buffer.join("");
|
|
16994
|
-
buffer = [];
|
|
16995
|
-
if (!file) {
|
|
16996
|
-
if (windowsPrivateFiles && close)
|
|
16997
|
-
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
16998
|
-
return;
|
|
16999
|
-
}
|
|
17000
|
-
if (windowsPrivateFiles) {
|
|
17001
|
-
return queueWindows(async () => {
|
|
17002
|
-
try {
|
|
17003
|
-
await flushWindowsFile(windowsFile, file, text2);
|
|
17004
|
-
} finally {
|
|
17005
|
-
if (close)
|
|
17006
|
-
await closeWindowsFile(windowsFile);
|
|
17007
|
-
}
|
|
17008
|
-
});
|
|
17009
|
-
}
|
|
17010
|
-
try {
|
|
17011
|
-
rotateIfNeeded(file);
|
|
17012
|
-
if (existsSync(file))
|
|
17013
|
-
chmodPrivate(file);
|
|
17014
|
-
appendFileSync(file, text2, { encoding: "utf8", mode: 384 });
|
|
17015
|
-
} catch {
|
|
17016
|
-
}
|
|
17017
|
-
}
|
|
17018
|
-
function schedule2() {
|
|
17019
|
-
if (!timer)
|
|
17020
|
-
timer = setTimeout(() => {
|
|
17021
|
-
timer = void 0;
|
|
17022
|
-
const flushed = flushLogs3(false);
|
|
17023
|
-
if (flushed instanceof Promise)
|
|
17024
|
-
void flushed.catch(() => {
|
|
17025
|
-
});
|
|
17026
|
-
}, 500);
|
|
17027
|
-
}
|
|
17028
|
-
function emit(channel3, level, message, data) {
|
|
17029
|
-
if (logFileSource === void 0 && captureSink === void 0)
|
|
17030
|
-
return;
|
|
17031
|
-
try {
|
|
17032
|
-
if (ORDER[level] > ORDER[configuredLevel()])
|
|
17033
|
-
return;
|
|
17034
|
-
const scrubbedMessage = redactor.redactStrings(message);
|
|
17035
|
-
let scrubbedData;
|
|
17036
|
-
try {
|
|
17037
|
-
scrubbedData = redactor.redact(data);
|
|
17038
|
-
} catch {
|
|
17039
|
-
scrubbedData = "[unserializable]";
|
|
17040
|
-
}
|
|
17041
|
-
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
|
|
17042
|
-
try {
|
|
17043
|
-
captureSink?.({
|
|
17044
|
-
channel: channel3,
|
|
17045
|
-
level,
|
|
17046
|
-
message: scrubbedMessage,
|
|
17047
|
-
data: scrubbedData
|
|
17048
|
-
});
|
|
17049
|
-
} catch {
|
|
17050
|
-
}
|
|
17051
|
-
if (logFileSource === void 0)
|
|
17052
|
-
return;
|
|
17053
|
-
buffer.push(line);
|
|
17054
|
-
if (buffer.length >= 50) {
|
|
17055
|
-
const flushed = flushLogs3(false);
|
|
17056
|
-
if (flushed instanceof Promise)
|
|
17057
|
-
void flushed.catch(() => {
|
|
17058
|
-
});
|
|
17059
|
-
} else
|
|
17060
|
-
schedule2();
|
|
17061
|
-
} catch {
|
|
17062
|
-
}
|
|
17063
|
-
}
|
|
17064
|
-
function createLogger5(channel3) {
|
|
17065
|
-
return {
|
|
17066
|
-
error: (m, d) => emit(channel3, "error", m, d),
|
|
17067
|
-
warn: (m, d) => emit(channel3, "warn", m, d),
|
|
17068
|
-
info: (m, d) => emit(channel3, "info", m, d),
|
|
17069
|
-
debug: (m, d) => emit(channel3, "debug", m, d),
|
|
17070
|
-
trace: (m, d) => emit(channel3, "trace", m, d)
|
|
17071
|
-
};
|
|
17072
|
-
}
|
|
17073
|
-
function reset() {
|
|
17074
|
-
if (windowsPrivateFiles)
|
|
17075
|
-
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => {
|
|
17076
|
-
});
|
|
17077
|
-
sinkError = void 0;
|
|
17078
|
-
buffer = [];
|
|
17079
|
-
if (timer) {
|
|
17080
|
-
clearTimeout(timer);
|
|
17081
|
-
timer = void 0;
|
|
17082
|
-
}
|
|
17083
|
-
logFileSource = void 0;
|
|
17084
|
-
initLevelSource = void 0;
|
|
17085
|
-
runtimeLevel = void 0;
|
|
17086
|
-
redactor = createRedactor();
|
|
17087
|
-
captureSink = void 0;
|
|
17088
|
-
}
|
|
17089
|
-
if (options)
|
|
17090
|
-
configure(options);
|
|
17091
|
-
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3, reset };
|
|
17092
|
-
}
|
|
17093
|
-
function createLoggerInstance(options) {
|
|
17094
|
-
const { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 } = createEngine(options);
|
|
17095
|
-
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 };
|
|
17096
|
-
}
|
|
17097
|
-
function initLogger(options) {
|
|
17098
|
-
defaultEngine.configure(options);
|
|
17099
|
-
const { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 } = defaultEngine;
|
|
17100
|
-
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 };
|
|
17101
|
-
}
|
|
17102
|
-
function setLogLevel(l) {
|
|
17103
|
-
defaultEngine.setLogLevel(l);
|
|
17104
|
-
}
|
|
17105
|
-
function flushLogs() {
|
|
17106
|
-
return defaultEngine.flushLogs();
|
|
17107
|
-
}
|
|
17108
|
-
function createLogger2(channel3) {
|
|
17109
|
-
return defaultEngine.createLogger(channel3);
|
|
17110
|
-
}
|
|
17111
|
-
async function flushForTest() {
|
|
17112
|
-
return defaultEngine.flushLogs();
|
|
17113
|
-
}
|
|
17114
|
-
function resetLoggerForTest() {
|
|
17115
|
-
defaultEngine.reset();
|
|
17116
|
-
}
|
|
17117
|
-
var ORDER, MAX_BYTES, ROTATE_KEEP, defaultEngine;
|
|
17118
|
-
var init_engine = __esm({
|
|
17119
|
-
"../core/dist/common-auth-embedded/logger/engine.js"() {
|
|
17120
|
-
"use strict";
|
|
17121
|
-
init_private_files();
|
|
17122
|
-
init_redact();
|
|
17123
|
-
ORDER = {
|
|
17124
|
-
error: 0,
|
|
17125
|
-
warn: 1,
|
|
17126
|
-
info: 2,
|
|
17127
|
-
debug: 3,
|
|
17128
|
-
trace: 4
|
|
17129
|
-
};
|
|
17130
|
-
MAX_BYTES = 5 * 1024 * 1024;
|
|
17131
|
-
ROTATE_KEEP = 3;
|
|
17132
|
-
defaultEngine = createEngine();
|
|
17133
|
-
}
|
|
17134
|
-
});
|
|
17135
|
-
|
|
17136
|
-
// ../core/dist/common-auth-embedded/logger/index.js
|
|
17137
|
-
var logger_exports = {};
|
|
17138
|
-
__export(logger_exports, {
|
|
17139
|
-
createCaptureSink: () => createCaptureSink,
|
|
17140
|
-
createLogger: () => createLogger2,
|
|
17141
|
-
createLoggerInstance: () => createLoggerInstance,
|
|
17142
|
-
createRedactor: () => createRedactor,
|
|
17143
|
-
flushForTest: () => flushForTest,
|
|
17144
|
-
flushLogs: () => flushLogs,
|
|
17145
|
-
initLogger: () => initLogger,
|
|
17146
|
-
redact: () => redact,
|
|
17147
|
-
redactStrings: () => redactStrings,
|
|
17148
|
-
resetLoggerForTest: () => resetLoggerForTest,
|
|
17149
|
-
setLogLevel: () => setLogLevel
|
|
17150
|
-
});
|
|
17151
|
-
var init_logger2 = __esm({
|
|
17152
|
-
"../core/dist/common-auth-embedded/logger/index.js"() {
|
|
17153
|
-
"use strict";
|
|
17154
|
-
init_capture_sink();
|
|
17155
|
-
init_engine();
|
|
17156
|
-
init_redact();
|
|
17157
|
-
}
|
|
17158
|
-
});
|
|
17159
|
-
|
|
17160
17221
|
// ../core/dist/common-auth-embedded/quota/commit-interval.js
|
|
17161
17222
|
var QUOTA_COMMIT_INTERVAL_MS, quotaCommitTimer;
|
|
17162
17223
|
var init_commit_interval = __esm({
|
|
@@ -17254,11 +17315,11 @@ var init_quota_writer = __esm({
|
|
|
17254
17315
|
const left = deadline - performance.now();
|
|
17255
17316
|
if (left <= 0)
|
|
17256
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);
|
|
17257
|
-
await new Promise((
|
|
17318
|
+
await new Promise((resolve31) => {
|
|
17258
17319
|
const done = () => {
|
|
17259
17320
|
clearTimeout(timer);
|
|
17260
17321
|
this.wake.delete(done);
|
|
17261
|
-
|
|
17322
|
+
resolve31();
|
|
17262
17323
|
};
|
|
17263
17324
|
const timer = setTimeout(done, left);
|
|
17264
17325
|
this.wake.add(done);
|
|
@@ -20322,7 +20383,7 @@ async function select(terminal, items, options) {
|
|
|
20322
20383
|
writeLine("");
|
|
20323
20384
|
renderedLines = lines;
|
|
20324
20385
|
};
|
|
20325
|
-
return new Promise((
|
|
20386
|
+
return new Promise((resolve31) => {
|
|
20326
20387
|
const wasRaw = stdin.isRaw ?? false;
|
|
20327
20388
|
const cleanup2 = () => {
|
|
20328
20389
|
if (cleaned)
|
|
@@ -20342,7 +20403,7 @@ async function select(terminal, items, options) {
|
|
|
20342
20403
|
};
|
|
20343
20404
|
const finish = (value) => {
|
|
20344
20405
|
cleanup2();
|
|
20345
|
-
|
|
20406
|
+
resolve31(value);
|
|
20346
20407
|
};
|
|
20347
20408
|
const onSignal = () => finish(null);
|
|
20348
20409
|
const onKey = (data) => {
|
|
@@ -20382,7 +20443,7 @@ async function select(terminal, items, options) {
|
|
|
20382
20443
|
stdin.setRawMode(true);
|
|
20383
20444
|
} catch {
|
|
20384
20445
|
cleanup2();
|
|
20385
|
-
|
|
20446
|
+
resolve31(null);
|
|
20386
20447
|
return;
|
|
20387
20448
|
}
|
|
20388
20449
|
stdin.resume();
|
|
@@ -22408,10 +22469,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
22408
22469
|
try {
|
|
22409
22470
|
await Promise.race([
|
|
22410
22471
|
drained,
|
|
22411
|
-
new Promise((
|
|
22472
|
+
new Promise((resolve31) => {
|
|
22412
22473
|
timer = setTimeout(() => {
|
|
22413
22474
|
expired = true;
|
|
22414
|
-
|
|
22475
|
+
resolve31();
|
|
22415
22476
|
}, 2e3);
|
|
22416
22477
|
})
|
|
22417
22478
|
]);
|
|
@@ -22684,7 +22745,7 @@ function grantReachOf(listed) {
|
|
|
22684
22745
|
tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
|
|
22685
22746
|
});
|
|
22686
22747
|
}
|
|
22687
|
-
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;
|
|
22688
22749
|
var init_custody = __esm({
|
|
22689
22750
|
"../core/dist/common-auth-embedded/claustrum/custody.js"() {
|
|
22690
22751
|
"use strict";
|
|
@@ -22701,6 +22762,8 @@ var init_custody = __esm({
|
|
|
22701
22762
|
phaseDiagnostics = channel("common-auth.claustrum.phases");
|
|
22702
22763
|
SERVING_MARGIN_MS = 3e5;
|
|
22703
22764
|
KEPT_RECEIPT_MARGIN_MS = 6e4;
|
|
22765
|
+
VAULT_RECEIPT_WAIT_MS = 1e4;
|
|
22766
|
+
VAULT_YOUNG_OUTAGE_MS = 6e4;
|
|
22704
22767
|
ClaustrumScopedCustody = class {
|
|
22705
22768
|
#client;
|
|
22706
22769
|
#readToken;
|
|
@@ -22718,7 +22781,10 @@ var init_custody = __esm({
|
|
|
22718
22781
|
#setTimeout;
|
|
22719
22782
|
#clearTimeout;
|
|
22720
22783
|
#outage = false;
|
|
22784
|
+
#outageSince = 0;
|
|
22785
|
+
#outageWaitSpent = false;
|
|
22721
22786
|
#outageError = new ClaustrumUnreachableError();
|
|
22787
|
+
#receiptWaits = /* @__PURE__ */ new Map();
|
|
22722
22788
|
#probeTimer;
|
|
22723
22789
|
#probing = false;
|
|
22724
22790
|
#lastProbeAt = -Infinity;
|
|
@@ -22794,6 +22860,8 @@ var init_custody = __esm({
|
|
|
22794
22860
|
if (this.#closed || this.#outage)
|
|
22795
22861
|
return;
|
|
22796
22862
|
this.#outage = true;
|
|
22863
|
+
this.#outageSince = this.#now();
|
|
22864
|
+
this.#outageWaitSpent = false;
|
|
22797
22865
|
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22798
22866
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
22799
22867
|
this.#scheduleProbe();
|
|
@@ -23068,9 +23136,10 @@ var init_custody = __esm({
|
|
|
23068
23136
|
/** Ask the vault while reachable; retain one validated receipt in memory only. */
|
|
23069
23137
|
async authorize(identity4, signal, routeId = "vault") {
|
|
23070
23138
|
this.#check(signal);
|
|
23139
|
+
const startedAt = this.#now();
|
|
23071
23140
|
const { credentialId, credentialType, accountIdentity } = identity4;
|
|
23072
23141
|
let kept = this.#kept.get(credentialId);
|
|
23073
|
-
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))) {
|
|
23074
23143
|
this.forget(credentialId);
|
|
23075
23144
|
kept = void 0;
|
|
23076
23145
|
}
|
|
@@ -23087,7 +23156,18 @@ var init_custody = __esm({
|
|
|
23087
23156
|
return this.#serveKept(credentialId, kept, token, routeId);
|
|
23088
23157
|
}
|
|
23089
23158
|
try {
|
|
23090
|
-
|
|
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
|
+
}
|
|
23091
23171
|
this.#kept.set(credentialId, { attempt, routeId, since: null });
|
|
23092
23172
|
this.#usageServed.set(credentialId, { ...identity4 });
|
|
23093
23173
|
return attempt;
|
|
@@ -23100,6 +23180,109 @@ var init_custody = __esm({
|
|
|
23100
23180
|
return this.#serveKept(credentialId, kept, token, routeId, error);
|
|
23101
23181
|
}
|
|
23102
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
|
+
}
|
|
23103
23286
|
#serveKept(credentialId, kept, token, routeId, error = this.#outageError) {
|
|
23104
23287
|
if (!kept || this.#kept.get(credentialId) !== kept || !this.#usable(kept.attempt)) {
|
|
23105
23288
|
this.forget(credentialId);
|
|
@@ -23325,6 +23508,9 @@ var init_custody = __esm({
|
|
|
23325
23508
|
if (this.#closed)
|
|
23326
23509
|
return;
|
|
23327
23510
|
this.#closed = true;
|
|
23511
|
+
for (const wait2 of this.#receiptWaits.values())
|
|
23512
|
+
wait2.controller.abort();
|
|
23513
|
+
this.#receiptWaits.clear();
|
|
23328
23514
|
if (this.#probeTimer)
|
|
23329
23515
|
this.#clearTimeout(this.#probeTimer);
|
|
23330
23516
|
this.#probeTimer = void 0;
|
|
@@ -24325,7 +24511,7 @@ var init_consumer = __esm({
|
|
|
24325
24511
|
this.#shutdown.signal,
|
|
24326
24512
|
...signal ? [signal] : []
|
|
24327
24513
|
]);
|
|
24328
|
-
return new Promise((
|
|
24514
|
+
return new Promise((resolve31, reject) => {
|
|
24329
24515
|
const cleanup2 = () => {
|
|
24330
24516
|
combined.signal.removeEventListener("abort", abort);
|
|
24331
24517
|
combined.dispose();
|
|
@@ -24340,7 +24526,7 @@ var init_consumer = __esm({
|
|
|
24340
24526
|
if (combined.signal.aborted)
|
|
24341
24527
|
reject(combined.signal.reason);
|
|
24342
24528
|
else
|
|
24343
|
-
|
|
24529
|
+
resolve31(value);
|
|
24344
24530
|
}, (error) => {
|
|
24345
24531
|
cleanup2();
|
|
24346
24532
|
reject(error);
|
|
@@ -25146,12 +25332,12 @@ function unreachableConnect2() {
|
|
|
25146
25332
|
return new ClaustrumUnreachableError();
|
|
25147
25333
|
}
|
|
25148
25334
|
function untilAborted(pending, signal) {
|
|
25149
|
-
return new Promise((
|
|
25335
|
+
return new Promise((resolve31, reject) => {
|
|
25150
25336
|
const abort = () => reject(signal.reason);
|
|
25151
25337
|
signal.addEventListener("abort", abort, { once: true });
|
|
25152
25338
|
pending.then((value) => {
|
|
25153
25339
|
signal.removeEventListener("abort", abort);
|
|
25154
|
-
|
|
25340
|
+
resolve31(value);
|
|
25155
25341
|
}, (error) => {
|
|
25156
25342
|
signal.removeEventListener("abort", abort);
|
|
25157
25343
|
reject(error);
|
|
@@ -25198,6 +25384,13 @@ var init_hub = __esm({
|
|
|
25198
25384
|
#own;
|
|
25199
25385
|
#watch;
|
|
25200
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();
|
|
25201
25394
|
/** The hub's last authority read; undefined before the first one. */
|
|
25202
25395
|
#active;
|
|
25203
25396
|
/** Counts inactive transitions, so local work started before one stops. */
|
|
@@ -25671,6 +25864,9 @@ var init_hub = __esm({
|
|
|
25671
25864
|
if (!this.#live(generation))
|
|
25672
25865
|
return void 0;
|
|
25673
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;
|
|
25674
25870
|
const bases = new Map(await Promise.all([...this.#members.values()].map(async (entry) => [
|
|
25675
25871
|
entry,
|
|
25676
25872
|
await readVaultRoster(entry.path).then((file) => file ? { file } : {}, (error) => error instanceof Error ? error : new Error(String(error)))
|
|
@@ -25691,7 +25887,14 @@ var init_hub = __esm({
|
|
|
25691
25887
|
if (!this.#live(generation))
|
|
25692
25888
|
return void 0;
|
|
25693
25889
|
const members = this.#open();
|
|
25694
|
-
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
|
+
}
|
|
25695
25898
|
if (!this.#live(generation))
|
|
25696
25899
|
return void 0;
|
|
25697
25900
|
const errors = /* @__PURE__ */ new Map();
|
|
@@ -25792,6 +25995,27 @@ var init_hub = __esm({
|
|
|
25792
25995
|
return { error };
|
|
25793
25996
|
}
|
|
25794
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
|
+
}
|
|
25795
26019
|
/**
|
|
25796
26020
|
* Create the roster folders under the state folder (`rosters`, this host
|
|
25797
26021
|
* generation and this key) owner-only, as every other Claustrum private
|
|
@@ -26104,6 +26328,8 @@ __export(claustrum_exports, {
|
|
|
26104
26328
|
VAULT_FAILURE_CLASSES: () => VAULT_FAILURE_CLASSES,
|
|
26105
26329
|
VAULT_HOST_CONNECT_REFUSAL: () => VAULT_HOST_CONNECT_REFUSAL,
|
|
26106
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,
|
|
26107
26333
|
WATCH_RETRY_MS: () => WATCH_RETRY_MS,
|
|
26108
26334
|
acceptAccount: () => acceptAccount,
|
|
26109
26335
|
acceptVaultRoute: () => acceptVaultRoute,
|
|
@@ -27226,8 +27452,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
27226
27452
|
return allowedTiers[0]?.id;
|
|
27227
27453
|
}
|
|
27228
27454
|
function wait(ms) {
|
|
27229
|
-
return new Promise((
|
|
27230
|
-
setTimeout(
|
|
27455
|
+
return new Promise((resolve31) => {
|
|
27456
|
+
setTimeout(resolve31, ms);
|
|
27231
27457
|
});
|
|
27232
27458
|
}
|
|
27233
27459
|
function extractManagedProjectId(payload) {
|
|
@@ -28037,7 +28263,7 @@ var init_quota_manager = __esm({
|
|
|
28037
28263
|
});
|
|
28038
28264
|
|
|
28039
28265
|
// ../core/dist/transform/agy-generation.js
|
|
28040
|
-
function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
28266
|
+
function applyAgyNativeGenerationConfig(wireModel, generationConfig, options = {}) {
|
|
28041
28267
|
const native = getAgyNativeModel(wireModel);
|
|
28042
28268
|
if (!native)
|
|
28043
28269
|
return;
|
|
@@ -28046,7 +28272,21 @@ function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
|
28046
28272
|
generationConfig.maxOutputTokens = output2;
|
|
28047
28273
|
}
|
|
28048
28274
|
delete generationConfig.max_output_tokens;
|
|
28049
|
-
|
|
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) {
|
|
28050
28290
|
generationConfig.thinkingConfig = {
|
|
28051
28291
|
includeThoughts: true,
|
|
28052
28292
|
thinkingLevel: ADAPTIVE_LEVELS[native.thinkingLevel]
|
|
@@ -28595,7 +28835,9 @@ function wrapToolsAsFunctionDeclarations(payload) {
|
|
|
28595
28835
|
}
|
|
28596
28836
|
const finalTools = [];
|
|
28597
28837
|
if (functionDeclarations.length > 0) {
|
|
28598
|
-
finalTools.push(
|
|
28838
|
+
finalTools.push(...functionDeclarations.map((declaration) => ({
|
|
28839
|
+
functionDeclarations: [declaration]
|
|
28840
|
+
})));
|
|
28599
28841
|
}
|
|
28600
28842
|
finalTools.push(...passthroughTools);
|
|
28601
28843
|
if (hasWebSearchTool && functionDeclarations.length === 0) {
|
|
@@ -28861,6 +29103,15 @@ function getAgyGemini31ProThinkingBudget(tier) {
|
|
|
28861
29103
|
function resolveModelWithTier(requestedModel) {
|
|
28862
29104
|
const isAntigravity = QUOTA_PREFIX_REGEX.test(requestedModel);
|
|
28863
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
|
+
}
|
|
28864
29115
|
const tier = extractThinkingTierFromModel(modelWithoutQuota);
|
|
28865
29116
|
const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
|
|
28866
29117
|
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
@@ -29033,7 +29284,7 @@ function resolveAntigravityModel(requestedModel) {
|
|
|
29033
29284
|
const prefixedModel = `antigravity-${transformedModel}`;
|
|
29034
29285
|
return resolveModelWithTier(prefixedModel);
|
|
29035
29286
|
}
|
|
29036
|
-
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;
|
|
29037
29288
|
var init_model_resolver = __esm({
|
|
29038
29289
|
"../core/dist/transform/model-resolver.js"() {
|
|
29039
29290
|
"use strict";
|
|
@@ -29046,6 +29297,7 @@ var init_model_resolver = __esm({
|
|
|
29046
29297
|
};
|
|
29047
29298
|
MODEL_ALIASES = getResolverAliasMap();
|
|
29048
29299
|
TIER_REGEX = /-(minimal|low|medium|high)$/;
|
|
29300
|
+
HYDROGEN_TIER_REGEX = /-(low|medium|high|xhigh)$/i;
|
|
29049
29301
|
QUOTA_PREFIX_REGEX = /^antigravity-/i;
|
|
29050
29302
|
GEMINI_3_PRO_REGEX = /^gemini-3(?:\.\d+)?-pro/i;
|
|
29051
29303
|
GEMINI_3_FLASH_REGEX = /^gemini-3(?:\.\d+)?-flash/i;
|
|
@@ -29550,12 +29802,12 @@ var init_vault_provider_state = __esm({
|
|
|
29550
29802
|
function untilAborted2(pending, signal) {
|
|
29551
29803
|
if (!signal)
|
|
29552
29804
|
return pending;
|
|
29553
|
-
return new Promise((
|
|
29805
|
+
return new Promise((resolve31, reject) => {
|
|
29554
29806
|
const abort = () => reject(signal.reason);
|
|
29555
29807
|
signal.addEventListener("abort", abort, { once: true });
|
|
29556
29808
|
if (signal.aborted)
|
|
29557
29809
|
abort();
|
|
29558
|
-
pending.then(
|
|
29810
|
+
pending.then(resolve31, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
29559
29811
|
});
|
|
29560
29812
|
}
|
|
29561
29813
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -30666,6 +30918,9 @@ function createLoggerInstance2(options) {
|
|
|
30666
30918
|
const { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 } = createEngine2(options);
|
|
30667
30919
|
return { configure, createLogger: createLogger5, setLogLevel: setLogLevel3, flushLogs: flushLogs3 };
|
|
30668
30920
|
}
|
|
30921
|
+
function createLogger3(channel3) {
|
|
30922
|
+
return defaultEngine2.createLogger(channel3);
|
|
30923
|
+
}
|
|
30669
30924
|
var ORDER2, MAX_BYTES2, ROTATE_KEEP2, defaultEngine2;
|
|
30670
30925
|
var init_engine2 = __esm({
|
|
30671
30926
|
"src/common-auth-embedded/logger/engine.js"() {
|
|
@@ -31054,12 +31309,12 @@ function createVaultAccountPool(options) {
|
|
|
31054
31309
|
try {
|
|
31055
31310
|
return await Promise.race([
|
|
31056
31311
|
read.then(() => true),
|
|
31057
|
-
new Promise((
|
|
31312
|
+
new Promise((resolve31, reject) => {
|
|
31058
31313
|
const abort = () => reject(signal?.reason);
|
|
31059
31314
|
signal?.addEventListener("abort", abort, { once: true });
|
|
31060
31315
|
detachAbort = () => signal?.removeEventListener("abort", abort);
|
|
31061
31316
|
if (remaining !== void 0)
|
|
31062
|
-
cancelTimer2 = schedule2(() =>
|
|
31317
|
+
cancelTimer2 = schedule2(() => resolve31(false), remaining);
|
|
31063
31318
|
if (signal?.aborted) abort();
|
|
31064
31319
|
})
|
|
31065
31320
|
]);
|
|
@@ -31564,11 +31819,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31564
31819
|
].join("\n");
|
|
31565
31820
|
const waitForApproval = async () => {
|
|
31566
31821
|
while (!closed2) {
|
|
31567
|
-
await new Promise((
|
|
31822
|
+
await new Promise((resolve31) => {
|
|
31568
31823
|
const done = () => {
|
|
31569
31824
|
clearTimeout(timer);
|
|
31570
31825
|
cancelWait = void 0;
|
|
31571
|
-
|
|
31826
|
+
resolve31();
|
|
31572
31827
|
};
|
|
31573
31828
|
const timer = setTimeout(done, 2e3);
|
|
31574
31829
|
timer.unref?.();
|
|
@@ -34650,13 +34905,13 @@ function closeDebugStream(state) {
|
|
|
34650
34905
|
state.logWriter = () => {
|
|
34651
34906
|
};
|
|
34652
34907
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34653
|
-
return new Promise((
|
|
34654
|
-
current.once("close", () =>
|
|
34655
|
-
current.once("error", () =>
|
|
34908
|
+
return new Promise((resolve31) => {
|
|
34909
|
+
current.once("close", () => resolve31());
|
|
34910
|
+
current.once("error", () => resolve31());
|
|
34656
34911
|
try {
|
|
34657
34912
|
current.end();
|
|
34658
34913
|
} catch {
|
|
34659
|
-
|
|
34914
|
+
resolve31();
|
|
34660
34915
|
}
|
|
34661
34916
|
});
|
|
34662
34917
|
}
|
|
@@ -34921,13 +35176,13 @@ function closeDebugLog() {
|
|
|
34921
35176
|
if (!state || !current) return Promise.resolve();
|
|
34922
35177
|
state.logStream = null;
|
|
34923
35178
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34924
|
-
return new Promise((
|
|
34925
|
-
current.once("close", () =>
|
|
34926
|
-
current.once("error", () =>
|
|
35179
|
+
return new Promise((resolve31) => {
|
|
35180
|
+
current.once("close", () => resolve31());
|
|
35181
|
+
current.once("error", () => resolve31());
|
|
34927
35182
|
try {
|
|
34928
35183
|
current.end();
|
|
34929
35184
|
} catch {
|
|
34930
|
-
|
|
35185
|
+
resolve31();
|
|
34931
35186
|
}
|
|
34932
35187
|
});
|
|
34933
35188
|
}
|
|
@@ -35149,8 +35404,8 @@ var init_logger4 = __esm({
|
|
|
35149
35404
|
|
|
35150
35405
|
// src/plugin/index.ts
|
|
35151
35406
|
init_dist();
|
|
35152
|
-
import { createHash as createHash24, randomUUID as
|
|
35153
|
-
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";
|
|
35154
35409
|
|
|
35155
35410
|
// src/cli.ts
|
|
35156
35411
|
init_dist();
|
|
@@ -35807,7 +36062,7 @@ function drainSidebarWrites() {
|
|
|
35807
36062
|
return sidebarWriteChain;
|
|
35808
36063
|
}
|
|
35809
36064
|
async function sleep3(ms) {
|
|
35810
|
-
await new Promise((
|
|
36065
|
+
await new Promise((resolve31) => setTimeout(resolve31, ms));
|
|
35811
36066
|
}
|
|
35812
36067
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
35813
36068
|
const start = Date.now();
|
|
@@ -36659,14 +36914,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
36659
36914
|
name = "LocalQuotaGrantStaleError";
|
|
36660
36915
|
};
|
|
36661
36916
|
function untilQuotaAborted(pending, signal) {
|
|
36662
|
-
return new Promise((
|
|
36917
|
+
return new Promise((resolve31, reject) => {
|
|
36663
36918
|
const abort = () => reject(signal.reason);
|
|
36664
36919
|
if (signal.aborted) abort();
|
|
36665
36920
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36666
36921
|
void pending.then(
|
|
36667
36922
|
(value) => {
|
|
36668
36923
|
signal.removeEventListener("abort", abort);
|
|
36669
|
-
|
|
36924
|
+
resolve31(value);
|
|
36670
36925
|
},
|
|
36671
36926
|
(error) => {
|
|
36672
36927
|
signal.removeEventListener("abort", abort);
|
|
@@ -37287,12 +37542,12 @@ async function startOAuthListener({
|
|
|
37287
37542
|
let resolveCallback;
|
|
37288
37543
|
let rejectCallback;
|
|
37289
37544
|
let timeoutHandle;
|
|
37290
|
-
const callbackPromise = new Promise((
|
|
37545
|
+
const callbackPromise = new Promise((resolve31, reject) => {
|
|
37291
37546
|
resolveCallback = (url) => {
|
|
37292
37547
|
if (settled) return;
|
|
37293
37548
|
settled = true;
|
|
37294
37549
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
37295
|
-
|
|
37550
|
+
resolve31(url);
|
|
37296
37551
|
};
|
|
37297
37552
|
rejectCallback = (error) => {
|
|
37298
37553
|
if (settled) return;
|
|
@@ -37451,7 +37706,7 @@ async function startOAuthListener({
|
|
|
37451
37706
|
});
|
|
37452
37707
|
});
|
|
37453
37708
|
const bindAddress = getBindAddress();
|
|
37454
|
-
await new Promise((
|
|
37709
|
+
await new Promise((resolve31, reject) => {
|
|
37455
37710
|
const handleError = (error) => {
|
|
37456
37711
|
server.off("error", handleError);
|
|
37457
37712
|
if (error.code === "EADDRINUSE") {
|
|
@@ -37467,7 +37722,7 @@ async function startOAuthListener({
|
|
|
37467
37722
|
server.once("error", handleError);
|
|
37468
37723
|
server.listen(port, bindAddress, () => {
|
|
37469
37724
|
server.off("error", handleError);
|
|
37470
|
-
|
|
37725
|
+
resolve31();
|
|
37471
37726
|
});
|
|
37472
37727
|
});
|
|
37473
37728
|
server.on("error", (error) => {
|
|
@@ -37475,7 +37730,7 @@ async function startOAuthListener({
|
|
|
37475
37730
|
});
|
|
37476
37731
|
return {
|
|
37477
37732
|
waitForCallback: () => callbackPromise,
|
|
37478
|
-
close: () => new Promise((
|
|
37733
|
+
close: () => new Promise((resolve31, reject) => {
|
|
37479
37734
|
server.close((error) => {
|
|
37480
37735
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
37481
37736
|
reject(error);
|
|
@@ -37484,7 +37739,7 @@ async function startOAuthListener({
|
|
|
37484
37739
|
if (!settled) {
|
|
37485
37740
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
37486
37741
|
}
|
|
37487
|
-
|
|
37742
|
+
resolve31();
|
|
37488
37743
|
});
|
|
37489
37744
|
})
|
|
37490
37745
|
};
|
|
@@ -37676,7 +37931,7 @@ async function select2(terminal, items, options) {
|
|
|
37676
37931
|
writeLine("");
|
|
37677
37932
|
renderedLines = lines;
|
|
37678
37933
|
};
|
|
37679
|
-
return new Promise((
|
|
37934
|
+
return new Promise((resolve31) => {
|
|
37680
37935
|
const wasRaw = stdin.isRaw ?? false;
|
|
37681
37936
|
const cleanup2 = () => {
|
|
37682
37937
|
if (cleaned)
|
|
@@ -37696,7 +37951,7 @@ async function select2(terminal, items, options) {
|
|
|
37696
37951
|
};
|
|
37697
37952
|
const finish = (value) => {
|
|
37698
37953
|
cleanup2();
|
|
37699
|
-
|
|
37954
|
+
resolve31(value);
|
|
37700
37955
|
};
|
|
37701
37956
|
const onSignal = () => finish(null);
|
|
37702
37957
|
const onKey = (data) => {
|
|
@@ -37736,7 +37991,7 @@ async function select2(terminal, items, options) {
|
|
|
37736
37991
|
stdin.setRawMode(true);
|
|
37737
37992
|
} catch {
|
|
37738
37993
|
cleanup2();
|
|
37739
|
-
|
|
37994
|
+
resolve31(null);
|
|
37740
37995
|
return;
|
|
37741
37996
|
}
|
|
37742
37997
|
stdin.resume();
|
|
@@ -37825,6 +38080,7 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
37825
38080
|
init_private_files2();
|
|
37826
38081
|
|
|
37827
38082
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
38083
|
+
init_logger3();
|
|
37828
38084
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
37829
38085
|
import { link as link3, lstat as lstat8, mkdir as mkdir14, open as open9, readdir as readdir5, readFile as readFile13, rename as rename11, rm as rm6, stat as stat13, unlink as unlink12 } from "node:fs/promises";
|
|
37830
38086
|
import { basename as basename6, dirname as dirname19, join as join19 } from "node:path";
|
|
@@ -38047,8 +38303,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38047
38303
|
let releaseConfirmed = false;
|
|
38048
38304
|
let loss;
|
|
38049
38305
|
let resolveLoss;
|
|
38050
|
-
const lostPromise = new Promise((
|
|
38051
|
-
resolveLoss =
|
|
38306
|
+
const lostPromise = new Promise((resolve31) => {
|
|
38307
|
+
resolveLoss = resolve31;
|
|
38052
38308
|
});
|
|
38053
38309
|
function notifyTimerStep(event) {
|
|
38054
38310
|
try {
|
|
@@ -38212,7 +38468,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38212
38468
|
}
|
|
38213
38469
|
}
|
|
38214
38470
|
async function backoff() {
|
|
38215
|
-
await new Promise((
|
|
38471
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.floor(Math.random() * 4)));
|
|
38216
38472
|
}
|
|
38217
38473
|
async function readLockState(notifyReady = true) {
|
|
38218
38474
|
if (notifyReady && options.onStep)
|
|
@@ -38305,7 +38561,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38305
38561
|
const remainingMs = deadline - performance.now();
|
|
38306
38562
|
if (remainingMs <= 0)
|
|
38307
38563
|
throw original;
|
|
38308
|
-
await new Promise((
|
|
38564
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
38309
38565
|
if (performance.now() >= deadline)
|
|
38310
38566
|
throw original;
|
|
38311
38567
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -38779,17 +39035,15 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38779
39035
|
removalConfirmed = true;
|
|
38780
39036
|
}, deadline);
|
|
38781
39037
|
changingRecordError = void 0;
|
|
38782
|
-
if (markerAcquired) {
|
|
38783
|
-
|
|
38784
|
-
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
38785
|
-
code: "EIO"
|
|
38786
|
-
});
|
|
38787
|
-
releaseConfirmed = removalConfirmed;
|
|
39038
|
+
if (markerAcquired && removalConfirmed) {
|
|
39039
|
+
releaseConfirmed = true;
|
|
38788
39040
|
return;
|
|
38789
39041
|
}
|
|
38790
|
-
if (
|
|
38791
|
-
|
|
38792
|
-
|
|
39042
|
+
if (!markerAcquired) {
|
|
39043
|
+
if (signal?.aborted)
|
|
39044
|
+
return;
|
|
39045
|
+
await recoverStaleEvictionMarker(deadline);
|
|
39046
|
+
}
|
|
38793
39047
|
} catch (error) {
|
|
38794
39048
|
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
38795
39049
|
lockPath,
|
|
@@ -38810,7 +39064,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38810
39064
|
const remainingMs = deadline - performance.now();
|
|
38811
39065
|
if (remainingMs <= 0)
|
|
38812
39066
|
break;
|
|
38813
|
-
await new Promise((
|
|
39067
|
+
await new Promise((resolve31) => setTimeout(resolve31, Math.min(delayMs, remainingMs)));
|
|
38814
39068
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
38815
39069
|
break;
|
|
38816
39070
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -38819,6 +39073,9 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38819
39073
|
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
38820
39074
|
code: "ETIMEDOUT"
|
|
38821
39075
|
});
|
|
39076
|
+
createLogger3("fs").warn("File lock release deadline expired", {
|
|
39077
|
+
lockPath
|
|
39078
|
+
});
|
|
38822
39079
|
}
|
|
38823
39080
|
};
|
|
38824
39081
|
}
|
|
@@ -39688,7 +39945,7 @@ var ByteTail = class {
|
|
|
39688
39945
|
};
|
|
39689
39946
|
var defaultCommandRunner = {
|
|
39690
39947
|
run(file, args, options = {}) {
|
|
39691
|
-
return new Promise((
|
|
39948
|
+
return new Promise((resolve31) => {
|
|
39692
39949
|
const started = performance.now();
|
|
39693
39950
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
39694
39951
|
const stderr = new ByteTail();
|
|
@@ -39706,7 +39963,7 @@ var defaultCommandRunner = {
|
|
|
39706
39963
|
stdio: ["ignore", "pipe", "pipe"]
|
|
39707
39964
|
});
|
|
39708
39965
|
} catch {
|
|
39709
|
-
|
|
39966
|
+
resolve31({
|
|
39710
39967
|
exitCode: 1,
|
|
39711
39968
|
stdout: "",
|
|
39712
39969
|
stderr: "",
|
|
@@ -39741,7 +39998,7 @@ var defaultCommandRunner = {
|
|
|
39741
39998
|
settled = true;
|
|
39742
39999
|
if (timer)
|
|
39743
40000
|
clearTimeout(timer);
|
|
39744
|
-
|
|
40001
|
+
resolve31({
|
|
39745
40002
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
39746
40003
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
39747
40004
|
stderr: stderr.toString(),
|
|
@@ -42949,7 +43206,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
42949
43206
|
}
|
|
42950
43207
|
};
|
|
42951
43208
|
function readBody(req) {
|
|
42952
|
-
return new Promise((
|
|
43209
|
+
return new Promise((resolve31, reject) => {
|
|
42953
43210
|
const tooLarge = (declaredOversize = false) => {
|
|
42954
43211
|
req.removeAllListeners("data");
|
|
42955
43212
|
req.on("data", () => {
|
|
@@ -42972,7 +43229,7 @@ function readBody(req) {
|
|
|
42972
43229
|
}
|
|
42973
43230
|
chunks.push(chunk);
|
|
42974
43231
|
});
|
|
42975
|
-
req.on("end", () =>
|
|
43232
|
+
req.on("end", () => resolve31(Buffer.concat(chunks).toString("utf8")));
|
|
42976
43233
|
req.on("error", reject);
|
|
42977
43234
|
});
|
|
42978
43235
|
}
|
|
@@ -43151,12 +43408,12 @@ async function startRpcServer(options) {
|
|
|
43151
43408
|
json(500, { error: "internal error" });
|
|
43152
43409
|
}
|
|
43153
43410
|
}
|
|
43154
|
-
const port = await new Promise((
|
|
43411
|
+
const port = await new Promise((resolve31, reject) => {
|
|
43155
43412
|
server.on("error", reject);
|
|
43156
43413
|
server.listen(0, "127.0.0.1", () => {
|
|
43157
43414
|
const addr = server.address();
|
|
43158
43415
|
if (addr && typeof addr === "object")
|
|
43159
|
-
|
|
43416
|
+
resolve31(addr.port);
|
|
43160
43417
|
else
|
|
43161
43418
|
reject(new Error("no port"));
|
|
43162
43419
|
});
|
|
@@ -43179,16 +43436,16 @@ async function startRpcServer(options) {
|
|
|
43179
43436
|
rpcPort: port
|
|
43180
43437
|
});
|
|
43181
43438
|
} catch (error) {
|
|
43182
|
-
await new Promise((
|
|
43439
|
+
await new Promise((resolve31) => server.close(() => resolve31()));
|
|
43183
43440
|
throw error;
|
|
43184
43441
|
}
|
|
43185
43442
|
return {
|
|
43186
43443
|
port,
|
|
43187
43444
|
token,
|
|
43188
43445
|
async stop() {
|
|
43189
|
-
await new Promise((
|
|
43446
|
+
await new Promise((resolve31) => {
|
|
43190
43447
|
server.closeAllConnections?.();
|
|
43191
|
-
server.close(() =>
|
|
43448
|
+
server.close(() => resolve31());
|
|
43192
43449
|
for (const socket of connections)
|
|
43193
43450
|
socket.destroy();
|
|
43194
43451
|
});
|
|
@@ -44586,7 +44843,10 @@ function descriptorAtPath(descriptor, path5) {
|
|
|
44586
44843
|
}
|
|
44587
44844
|
return current;
|
|
44588
44845
|
}
|
|
44589
|
-
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
|
+
}
|
|
44590
44850
|
if (declaration.overrides !== void 0 && isJsonObject(value)) {
|
|
44591
44851
|
if (declaration.overrides.model && model !== void 0 && model !== "default" && model !== "opencode" && model !== "pi" && Object.hasOwn(value, model)) {
|
|
44592
44852
|
return [setting, model];
|
|
@@ -44616,6 +44876,19 @@ function checkPath(parsed, path5) {
|
|
|
44616
44876
|
invalid();
|
|
44617
44877
|
}
|
|
44618
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
|
+
}
|
|
44619
44892
|
function removeMember(text2, tree, path5) {
|
|
44620
44893
|
const property = tree && findNodeAtLocation2(tree, path5)?.parent;
|
|
44621
44894
|
const parent = property?.parent;
|
|
@@ -44689,6 +44962,16 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
44689
44962
|
if (!Object.hasOwn(definition.settings, edit.setting))
|
|
44690
44963
|
invalid();
|
|
44691
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
|
+
}
|
|
44692
44975
|
if (edit.path !== void 0 && declaration.value.kind !== "object" && declaration.value.kind !== "record")
|
|
44693
44976
|
invalid();
|
|
44694
44977
|
const descriptor = descriptorAtPath(declaration.value, edit.path ?? []);
|
|
@@ -44700,7 +44983,19 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
44700
44983
|
const units = [];
|
|
44701
44984
|
for (const edit of edits) {
|
|
44702
44985
|
const declaration = definition.settings[edit.setting];
|
|
44703
|
-
|
|
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);
|
|
44704
44999
|
const path5 = [...base, ...edit.path ?? []];
|
|
44705
45000
|
checkPath(working, path5);
|
|
44706
45001
|
units.push(resolutionUnit(declaration.value, base, edit.path ?? []));
|
|
@@ -44853,18 +45148,20 @@ async function writeTarget(file) {
|
|
|
44853
45148
|
} catch (error) {
|
|
44854
45149
|
if (error.code !== "ENOENT")
|
|
44855
45150
|
unavailable(file, error);
|
|
45151
|
+
let isSymlink = false;
|
|
44856
45152
|
try {
|
|
44857
|
-
await SettingsFs.lstat(file);
|
|
45153
|
+
isSymlink = (await SettingsFs.lstat(file)).isSymbolicLink();
|
|
44858
45154
|
} catch (lstatError) {
|
|
44859
45155
|
if (lstatError.code !== "ENOENT")
|
|
44860
45156
|
unavailable(file, lstatError);
|
|
44861
|
-
try {
|
|
44862
|
-
return join32(await SettingsFs.realpath(dirname24(file)), basename10(file));
|
|
44863
|
-
} catch (parentError) {
|
|
44864
|
-
unavailable(file, parentError);
|
|
44865
|
-
}
|
|
44866
45157
|
}
|
|
44867
|
-
|
|
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
|
+
}
|
|
44868
45165
|
}
|
|
44869
45166
|
}
|
|
44870
45167
|
async function updateSettings(definition, options, edits, context) {
|
|
@@ -44919,6 +45216,16 @@ async function updateSettings(definition, options, edits, context) {
|
|
|
44919
45216
|
if (Number.isInteger(version) && version > 1) {
|
|
44920
45217
|
throw new SettingsRefusal("settings-newer-version", "Settings were written by a newer version");
|
|
44921
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
|
+
}
|
|
44922
45229
|
if (!parsed.tree) {
|
|
44923
45230
|
source = `${parsed.hasBom ? "\uFEFF" : ""}// ${definition.plugin} settings
|
|
44924
45231
|
{
|
|
@@ -47223,7 +47530,7 @@ function buildAccountAccessProbeRequest(projectId) {
|
|
|
47223
47530
|
generationConfig: { maxOutputTokens: 1, temperature: 0 }
|
|
47224
47531
|
};
|
|
47225
47532
|
const requestMetadata = buildAgyAgentRequestMetadata(
|
|
47226
|
-
createAgyRequestSessionContext(
|
|
47533
|
+
createAgyRequestSessionContext(),
|
|
47227
47534
|
request2,
|
|
47228
47535
|
wireModel
|
|
47229
47536
|
);
|
|
@@ -47954,6 +48261,18 @@ import { dirname as dirname30, join as join39 } from "node:path";
|
|
|
47954
48261
|
// src/plugin/model-registry.ts
|
|
47955
48262
|
init_dist();
|
|
47956
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
|
+
|
|
47957
48276
|
// src/plugin/config/updater.ts
|
|
47958
48277
|
var PLUGIN_NAME = "@cortexkit/opencode-antigravity-auth@latest";
|
|
47959
48278
|
var SCHEMA_URL = "https://opencode.ai/config.json";
|
|
@@ -48015,7 +48334,7 @@ async function updateOpencodeConfig(options = {}) {
|
|
|
48015
48334
|
if (!config.provider.google) {
|
|
48016
48335
|
config.provider.google = {};
|
|
48017
48336
|
}
|
|
48018
|
-
config.provider.google.models =
|
|
48337
|
+
config.provider.google.models = getOpencode1ModelDefinitions();
|
|
48019
48338
|
config.provider.google.whitelist = getAntigravityOpencodeModelIds();
|
|
48020
48339
|
const configDir = dirname30(configPath);
|
|
48021
48340
|
if (!existsSync12(configDir)) {
|
|
@@ -48231,7 +48550,7 @@ async function select3(items, options) {
|
|
|
48231
48550
|
}
|
|
48232
48551
|
renderedLines = linesWritten;
|
|
48233
48552
|
};
|
|
48234
|
-
return new Promise((
|
|
48553
|
+
return new Promise((resolve31) => {
|
|
48235
48554
|
const wasRaw = stdin.isRaw ?? false;
|
|
48236
48555
|
const cleanup2 = () => {
|
|
48237
48556
|
if (isCleanedUp) return;
|
|
@@ -48252,11 +48571,11 @@ async function select3(items, options) {
|
|
|
48252
48571
|
};
|
|
48253
48572
|
const onSignal = () => {
|
|
48254
48573
|
cleanup2();
|
|
48255
|
-
|
|
48574
|
+
resolve31(null);
|
|
48256
48575
|
};
|
|
48257
48576
|
const finishWithValue = (value) => {
|
|
48258
48577
|
cleanup2();
|
|
48259
|
-
|
|
48578
|
+
resolve31(value);
|
|
48260
48579
|
};
|
|
48261
48580
|
const findNextSelectable = (from, direction) => {
|
|
48262
48581
|
if (items.length === 0) return from;
|
|
@@ -48302,7 +48621,7 @@ async function select3(items, options) {
|
|
|
48302
48621
|
stdin.setRawMode(true);
|
|
48303
48622
|
} catch {
|
|
48304
48623
|
cleanup2();
|
|
48305
|
-
|
|
48624
|
+
resolve31(null);
|
|
48306
48625
|
return;
|
|
48307
48626
|
}
|
|
48308
48627
|
stdin.resume();
|
|
@@ -51403,6 +51722,30 @@ To view: \`open "${filePath}"\``;
|
|
|
51403
51722
|
return ``;
|
|
51404
51723
|
}
|
|
51405
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
|
+
|
|
51406
51749
|
// src/plugin/core/streaming/transformer.ts
|
|
51407
51750
|
function hashString(str) {
|
|
51408
51751
|
let hash2 = 5381;
|
|
@@ -51572,18 +51915,6 @@ function responseHasToolCall(response) {
|
|
|
51572
51915
|
}
|
|
51573
51916
|
return false;
|
|
51574
51917
|
}
|
|
51575
|
-
function responseHasFinishReason(response) {
|
|
51576
|
-
if (!response || typeof response !== "object") return false;
|
|
51577
|
-
const resp = response;
|
|
51578
|
-
if (Array.isArray(resp.candidates)) {
|
|
51579
|
-
return resp.candidates.some((candidate) => {
|
|
51580
|
-
const cand = candidate;
|
|
51581
|
-
return typeof cand?.finishReason === "string" && cand.finishReason.length > 0;
|
|
51582
|
-
});
|
|
51583
|
-
}
|
|
51584
|
-
const stopReason = resp.stopReason ?? resp.stop_reason;
|
|
51585
|
-
return typeof stopReason === "string" && stopReason.length > 0;
|
|
51586
|
-
}
|
|
51587
51918
|
function transformSseLineWithMetadata(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState2, usageState) {
|
|
51588
51919
|
if (!line.startsWith("data:")) {
|
|
51589
51920
|
return { line, hasToolCall: false, hasFinishReason: false };
|
|
@@ -53977,6 +54308,7 @@ var NATIVE_GOOGLE_ERROR_MESSAGES = {
|
|
|
53977
54308
|
soft_quota: 'Antigravity account pool is unavailable under the quota protection policy. Add accounts, wait for quota reset, or turn off soft quota protection with `"soft_quota_threshold_percent": 100` in antigravity-auth.jsonc.',
|
|
53978
54309
|
pool_unavailable: "Antigravity account pool has no account available within the configured wait limit. Add accounts with `opencode auth login` or wait for quota reset.",
|
|
53979
54310
|
model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
|
|
54311
|
+
routing_refused: "Routing has no Antigravity account available for this request right now; try again later.",
|
|
53980
54312
|
missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
|
|
53981
54313
|
empty_response: "Antigravity returned an empty response after the internal retry attempts."
|
|
53982
54314
|
};
|
|
@@ -54003,6 +54335,9 @@ function createNativeGoogleErrorResponse(options) {
|
|
|
54003
54335
|
let body = JSON.stringify({
|
|
54004
54336
|
error: { code: options.status, status, message }
|
|
54005
54337
|
});
|
|
54338
|
+
if (options.reason === "routing_refused" && options.retryAfterSeconds !== void 0 && options.retryAfterSeconds >= 0n) {
|
|
54339
|
+
headers.set("Retry-After", options.retryAfterSeconds.toString());
|
|
54340
|
+
}
|
|
54006
54341
|
if (options.status === 412 && typeof options.resetAfterMs === "number" && Number.isFinite(options.resetAfterMs) && options.resetAfterMs >= 0) {
|
|
54007
54342
|
const delaySeconds = (BigInt(Math.ceil(options.resetAfterMs)) + 999n) / 1000n;
|
|
54008
54343
|
headers.set("Retry-After", delaySeconds.toString());
|
|
@@ -54532,7 +54867,7 @@ init_dist();
|
|
|
54532
54867
|
// src/plugin/request.ts
|
|
54533
54868
|
var log13 = createLogger4("request");
|
|
54534
54869
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
54535
|
-
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext(
|
|
54870
|
+
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext();
|
|
54536
54871
|
var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
|
|
54537
54872
|
var MIN_SIGNATURE_LENGTH = 50;
|
|
54538
54873
|
var AGY_CLAUDE_THINKING_BUDGET = 1024;
|
|
@@ -54613,7 +54948,9 @@ function getAgyMaxOutputTokens(model) {
|
|
|
54613
54948
|
}
|
|
54614
54949
|
function applyAgyGenerationDefaults(model, generationConfig) {
|
|
54615
54950
|
if (getAgyNativeModel(model)) {
|
|
54616
|
-
applyAgyNativeGenerationConfig(model, generationConfig
|
|
54951
|
+
applyAgyNativeGenerationConfig(model, generationConfig, {
|
|
54952
|
+
preserveThinkingBudget: false
|
|
54953
|
+
});
|
|
54617
54954
|
return;
|
|
54618
54955
|
}
|
|
54619
54956
|
const maxOutputTokens = getAgyMaxOutputTokens(model);
|
|
@@ -54929,20 +55266,38 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
54929
55266
|
}
|
|
54930
55267
|
}
|
|
54931
55268
|
}
|
|
54932
|
-
function
|
|
54933
|
-
|
|
54934
|
-
|
|
54935
|
-
|
|
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
|
+
);
|
|
54936
55280
|
}
|
|
54937
|
-
const toolConfig = payload.toolConfig && typeof payload.toolConfig === "object" && !Array.isArray(payload.toolConfig) ? payload.toolConfig : {};
|
|
54938
|
-
const functionCallingConfig = toolConfig.functionCallingConfig && typeof toolConfig.functionCallingConfig === "object" && !Array.isArray(toolConfig.functionCallingConfig) ? toolConfig.functionCallingConfig : {};
|
|
54939
|
-
functionCallingConfig.mode = "VALIDATED";
|
|
54940
|
-
toolConfig.functionCallingConfig = functionCallingConfig;
|
|
54941
|
-
payload.toolConfig = toolConfig;
|
|
54942
55281
|
}
|
|
54943
|
-
function normalizeNativeFunctionResponseRoles(payload) {
|
|
55282
|
+
function normalizeNativeFunctionResponseRoles(payload, wireModel) {
|
|
54944
55283
|
const contents = payload.contents;
|
|
54945
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
|
+
}
|
|
54946
55301
|
const signedCalls = /* @__PURE__ */ new Set();
|
|
54947
55302
|
for (const content of contents) {
|
|
54948
55303
|
const parts = content?.parts;
|
|
@@ -55388,7 +55743,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55388
55743
|
}
|
|
55389
55744
|
const [, rawModel = "", rawAction = ""] = match;
|
|
55390
55745
|
const requestedModel = rawModel;
|
|
55391
|
-
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
|
+
);
|
|
55392
55750
|
let effectiveModel = resolved.actualModel;
|
|
55393
55751
|
const streaming = rawAction === STREAM_ACTION;
|
|
55394
55752
|
const defaultEndpoint = ANTIGRAVITY_ENDPOINT;
|
|
@@ -55477,14 +55835,14 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55477
55835
|
}
|
|
55478
55836
|
sanitizeRequestPayloadForAntigravity(req);
|
|
55479
55837
|
stripUnsupportedAntigravityFields(req);
|
|
55480
|
-
configureAntigravityToolCalling(req
|
|
55481
|
-
normalizeNativeFunctionResponseRoles(req);
|
|
55838
|
+
configureAntigravityToolCalling(req);
|
|
55839
|
+
normalizeNativeFunctionResponseRoles(req, effectiveModel);
|
|
55482
55840
|
}
|
|
55483
55841
|
for (const req of requestObjects) {
|
|
55484
55842
|
if (Array.isArray(req.contents)) {
|
|
55485
55843
|
const contents = req.contents;
|
|
55486
55844
|
const lastContent = contents[contents.length - 1];
|
|
55487
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
55845
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
55488
55846
|
contents.push({ role: "user", parts: [{ text: "[Continue]" }] });
|
|
55489
55847
|
}
|
|
55490
55848
|
}
|
|
@@ -55519,7 +55877,9 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55519
55877
|
{
|
|
55520
55878
|
const generationConfig = wireRequest.generationConfig;
|
|
55521
55879
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
55522
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
55880
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
55881
|
+
thinkingBudget: options?.variant?.thinkingBudget
|
|
55882
|
+
});
|
|
55523
55883
|
if (Object.keys(config).length > 0)
|
|
55524
55884
|
wireRequest.generationConfig = config;
|
|
55525
55885
|
const metadata = buildAgyAgentRequestMetadata(
|
|
@@ -55548,13 +55908,19 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55548
55908
|
requestPayload.providerOptions,
|
|
55549
55909
|
rawGenerationConfig
|
|
55550
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);
|
|
55551
55914
|
const isGemini3 = effectiveModel.toLowerCase().includes("gemini-3");
|
|
55552
55915
|
wire.logger.debug(
|
|
55553
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)}`
|
|
55554
55917
|
);
|
|
55555
55918
|
delete requestPayload.providerOptions;
|
|
55556
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
55557
|
-
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
|
+
);
|
|
55558
55924
|
const variantResolved = resolveAntigravityModel(
|
|
55559
55925
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
55560
55926
|
);
|
|
@@ -55650,7 +56016,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55650
56016
|
if (rawGenerationConfig) {
|
|
55651
56017
|
rawGenerationConfig.thinkingConfig = thinkingConfig;
|
|
55652
56018
|
applyAgyGenerationDefaults(effectiveModel, rawGenerationConfig);
|
|
55653
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
56019
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
55654
56020
|
const currentMax = rawGenerationConfig.maxOutputTokens ?? rawGenerationConfig.max_output_tokens;
|
|
55655
56021
|
if (!currentMax) {
|
|
55656
56022
|
rawGenerationConfig.maxOutputTokens = 64e3;
|
|
@@ -55666,7 +56032,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55666
56032
|
const generationConfig = {
|
|
55667
56033
|
thinkingConfig
|
|
55668
56034
|
};
|
|
55669
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
56035
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
55670
56036
|
generationConfig.maxOutputTokens = 64e3;
|
|
55671
56037
|
}
|
|
55672
56038
|
applyAgyGenerationDefaults(effectiveModel, generationConfig);
|
|
@@ -55767,7 +56133,11 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55767
56133
|
});
|
|
55768
56134
|
const finalTools = [];
|
|
55769
56135
|
if (functionDeclarations.length > 0) {
|
|
55770
|
-
finalTools.push(
|
|
56136
|
+
finalTools.push(
|
|
56137
|
+
...functionDeclarations.map((declaration) => ({
|
|
56138
|
+
functionDeclarations: [declaration]
|
|
56139
|
+
}))
|
|
56140
|
+
);
|
|
55771
56141
|
}
|
|
55772
56142
|
requestPayload.tools = finalTools.concat(passthroughTools);
|
|
55773
56143
|
} else {
|
|
@@ -55899,7 +56269,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55899
56269
|
requestPayload.messages
|
|
55900
56270
|
);
|
|
55901
56271
|
}
|
|
55902
|
-
if (isClaudeThinking && Array.isArray(requestPayload.contents)) {
|
|
56272
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && Array.isArray(requestPayload.contents)) {
|
|
55903
56273
|
const conversationState = analyzeConversationState(
|
|
55904
56274
|
requestPayload.contents
|
|
55905
56275
|
);
|
|
@@ -55913,7 +56283,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55913
56283
|
}
|
|
55914
56284
|
if (Array.isArray(requestPayload.contents)) {
|
|
55915
56285
|
const lastContent = requestPayload.contents[requestPayload.contents.length - 1];
|
|
55916
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
56286
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
55917
56287
|
requestPayload.contents.push({
|
|
55918
56288
|
role: "user",
|
|
55919
56289
|
parts: [{ text: "[Continue]" }]
|
|
@@ -55938,15 +56308,18 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
55938
56308
|
{
|
|
55939
56309
|
const generationConfig = requestPayload.generationConfig;
|
|
55940
56310
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
55941
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
56311
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
56312
|
+
thinkingBudget: explicitThinkingBudget,
|
|
56313
|
+
preserveThinkingBudget: false
|
|
56314
|
+
});
|
|
55942
56315
|
if (Object.keys(config).length > 0)
|
|
55943
56316
|
requestPayload.generationConfig = config;
|
|
55944
56317
|
stripUnsupportedAntigravityFields(requestPayload);
|
|
55945
|
-
configureAntigravityToolCalling(requestPayload
|
|
55946
|
-
normalizeNativeFunctionResponseRoles(requestPayload);
|
|
56318
|
+
configureAntigravityToolCalling(requestPayload);
|
|
56319
|
+
normalizeNativeFunctionResponseRoles(requestPayload, effectiveModel);
|
|
55947
56320
|
if (Array.isArray(requestPayload.contents)) {
|
|
55948
|
-
const lastContent = requestPayload.contents
|
|
55949
|
-
if (lastContent?.role === "model") {
|
|
56321
|
+
const lastContent = requestPayload.contents.at(-1);
|
|
56322
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel)) {
|
|
55950
56323
|
requestPayload.contents.push({
|
|
55951
56324
|
role: "user",
|
|
55952
56325
|
parts: [{ text: "[Continue]" }]
|
|
@@ -56052,7 +56425,9 @@ function buildThinkingWarmupBody(bodyText, isClaudeThinking) {
|
|
|
56052
56425
|
thinkingBudget: AGY_CLAUDE_THINKING_BUDGET
|
|
56053
56426
|
};
|
|
56054
56427
|
generationConfig.maxOutputTokens ??= generationConfig.max_output_tokens ?? getAgyMaxOutputTokens(wireModel) ?? computeClaudeMaxOutputTokens(AGY_CLAUDE_THINKING_BUDGET);
|
|
56055
|
-
applyAgyNativeGenerationConfig(wireModel, generationConfig
|
|
56428
|
+
applyAgyNativeGenerationConfig(wireModel, generationConfig, {
|
|
56429
|
+
preserveThinkingBudget: false
|
|
56430
|
+
});
|
|
56056
56431
|
req.generationConfig = generationConfig;
|
|
56057
56432
|
requestObjects.push(req);
|
|
56058
56433
|
};
|
|
@@ -56497,10 +56872,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
56497
56872
|
cancellation.release();
|
|
56498
56873
|
throw error;
|
|
56499
56874
|
}
|
|
56500
|
-
let
|
|
56875
|
+
let resolve31 = () => {
|
|
56501
56876
|
};
|
|
56502
56877
|
const settled = new Promise((done) => {
|
|
56503
|
-
|
|
56878
|
+
resolve31 = done;
|
|
56504
56879
|
});
|
|
56505
56880
|
let stopping = false;
|
|
56506
56881
|
let finished = false;
|
|
@@ -56510,7 +56885,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
56510
56885
|
finished = true;
|
|
56511
56886
|
cancellation.signal.removeEventListener("abort", abort);
|
|
56512
56887
|
cancellation.release();
|
|
56513
|
-
|
|
56888
|
+
resolve31();
|
|
56514
56889
|
};
|
|
56515
56890
|
const abort = () => {
|
|
56516
56891
|
if (finished || stopping) return;
|
|
@@ -56579,8 +56954,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
56579
56954
|
let running = false;
|
|
56580
56955
|
let resolveCompletion = () => {
|
|
56581
56956
|
};
|
|
56582
|
-
const completion = new Promise((
|
|
56583
|
-
resolveCompletion =
|
|
56957
|
+
const completion = new Promise((resolve31) => {
|
|
56958
|
+
resolveCompletion = resolve31;
|
|
56584
56959
|
});
|
|
56585
56960
|
const finish = () => {
|
|
56586
56961
|
if (finished) return;
|
|
@@ -56627,14 +57002,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
56627
57002
|
};
|
|
56628
57003
|
}
|
|
56629
57004
|
function publishResponse(dispatch) {
|
|
56630
|
-
return new Promise((
|
|
57005
|
+
return new Promise((resolve31, reject) => {
|
|
56631
57006
|
let acknowledge;
|
|
56632
57007
|
void Promise.resolve().then(
|
|
56633
57008
|
() => dispatch((callback) => {
|
|
56634
57009
|
acknowledge = callback;
|
|
56635
57010
|
})
|
|
56636
57011
|
).then((response) => {
|
|
56637
|
-
|
|
57012
|
+
resolve31(response);
|
|
56638
57013
|
acknowledge?.();
|
|
56639
57014
|
}, reject);
|
|
56640
57015
|
});
|
|
@@ -58175,9 +58550,10 @@ function applyAntigravityProviderCatalog(config, providerId) {
|
|
|
58175
58550
|
const mutableConfig = config;
|
|
58176
58551
|
mutableConfig.provider ??= {};
|
|
58177
58552
|
const providerConfig = mutableConfig.provider[providerId] ?? {};
|
|
58553
|
+
const models = getOpencode1ModelDefinitions();
|
|
58178
58554
|
providerConfig.models = {
|
|
58179
58555
|
...providerConfig.models ?? {},
|
|
58180
|
-
...
|
|
58556
|
+
...models
|
|
58181
58557
|
};
|
|
58182
58558
|
providerConfig.whitelist = getAntigravityOpencodeModelIds();
|
|
58183
58559
|
mutableConfig.provider[providerId] = providerConfig;
|
|
@@ -58314,10 +58690,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
58314
58690
|
}
|
|
58315
58691
|
async function defaultSleep(ms, signal) {
|
|
58316
58692
|
if (ms <= 0) return;
|
|
58317
|
-
await new Promise((
|
|
58693
|
+
await new Promise((resolve31, reject) => {
|
|
58318
58694
|
const timer = setTimeout(() => {
|
|
58319
58695
|
signal?.removeEventListener("abort", onAbort);
|
|
58320
|
-
|
|
58696
|
+
resolve31();
|
|
58321
58697
|
}, ms);
|
|
58322
58698
|
timer.unref?.();
|
|
58323
58699
|
const onAbort = () => {
|
|
@@ -58437,7 +58813,7 @@ init_logger4();
|
|
|
58437
58813
|
|
|
58438
58814
|
// src/plugin/shared/request-services.ts
|
|
58439
58815
|
init_dist();
|
|
58440
|
-
import { createHash as createHash23 } from "node:crypto";
|
|
58816
|
+
import { createHash as createHash23, randomUUID as randomUUID24 } from "node:crypto";
|
|
58441
58817
|
|
|
58442
58818
|
// src/common-auth-embedded/routing-accessor/handle.js
|
|
58443
58819
|
function routingHandle(sessionId) {
|
|
@@ -58461,6 +58837,14 @@ function isCacheWarmStopReason(value) {
|
|
|
58461
58837
|
}
|
|
58462
58838
|
|
|
58463
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
|
+
];
|
|
58464
58848
|
function isObject2(value) {
|
|
58465
58849
|
return typeof value === "object" && value !== null;
|
|
58466
58850
|
}
|
|
@@ -58534,6 +58918,28 @@ function selectionFor(answer, candidates) {
|
|
|
58534
58918
|
}
|
|
58535
58919
|
return { candidate };
|
|
58536
58920
|
}
|
|
58921
|
+
function refusalFor(value) {
|
|
58922
|
+
if (!isObject2(value))
|
|
58923
|
+
return void 0;
|
|
58924
|
+
const code2 = value.code;
|
|
58925
|
+
if (code2 !== "account_limit_exhausted" && code2 !== "account_selection_refused" && code2 !== "account_selection_final") {
|
|
58926
|
+
return void 0;
|
|
58927
|
+
}
|
|
58928
|
+
const refused2 = { code: code2 };
|
|
58929
|
+
const routingCode = value.routing_code;
|
|
58930
|
+
if (typeof routingCode === "string" && /^[a-z0-9._-]{1,64}$/.test(routingCode)) {
|
|
58931
|
+
refused2.routingCode = routingCode;
|
|
58932
|
+
}
|
|
58933
|
+
const retryAfterSecs = value.retry_after_secs;
|
|
58934
|
+
if (typeof retryAfterSecs === "number" && Number.isFinite(retryAfterSecs) && retryAfterSecs >= 0) {
|
|
58935
|
+
refused2.retryAfterSecs = retryAfterSecs;
|
|
58936
|
+
}
|
|
58937
|
+
const resetsAtMs = value.resets_at_ms;
|
|
58938
|
+
if (typeof resetsAtMs === "number" && Number.isSafeInteger(resetsAtMs) && resetsAtMs > 0) {
|
|
58939
|
+
refused2.resetsAtMs = resetsAtMs;
|
|
58940
|
+
}
|
|
58941
|
+
return { refused: refused2 };
|
|
58942
|
+
}
|
|
58537
58943
|
async function askRouting(input2) {
|
|
58538
58944
|
let timer;
|
|
58539
58945
|
try {
|
|
@@ -58543,10 +58949,10 @@ async function askRouting(input2) {
|
|
|
58543
58949
|
const accountFor = handle.accountFor;
|
|
58544
58950
|
if (typeof accountFor !== "function")
|
|
58545
58951
|
return void 0;
|
|
58546
|
-
const requested = input2.deadlineMs ??
|
|
58547
|
-
const deadlineMs = Number.isNaN(requested) ?
|
|
58548
|
-
const expired = new Promise((
|
|
58549
|
-
timer = setTimeout(() =>
|
|
58952
|
+
const requested = input2.deadlineMs ?? 1500;
|
|
58953
|
+
const deadlineMs = Number.isNaN(requested) ? 1500 : Math.min(2e3, Math.max(1, requested));
|
|
58954
|
+
const expired = new Promise((resolve31) => {
|
|
58955
|
+
timer = setTimeout(() => resolve31(void 0), deadlineMs);
|
|
58550
58956
|
timer.unref();
|
|
58551
58957
|
});
|
|
58552
58958
|
const request2 = {
|
|
@@ -58557,10 +58963,19 @@ async function askRouting(input2) {
|
|
|
58557
58963
|
if (typeof cap === "number" && Number.isFinite(cap)) {
|
|
58558
58964
|
request2.hold_wait_max_s = Math.max(0, Math.floor(cap));
|
|
58559
58965
|
}
|
|
58966
|
+
if (input2.refusals === true)
|
|
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
|
+
}
|
|
58560
58972
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
58561
58973
|
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
58562
58974
|
return void 0;
|
|
58563
58975
|
const answer = await Promise.race([pending, expired]);
|
|
58976
|
+
if (input2.refusals === true && isObject2(answer) && "refused" in answer) {
|
|
58977
|
+
return refusalFor(answer.refused);
|
|
58978
|
+
}
|
|
58564
58979
|
return selectionFor(answer, input2.candidates);
|
|
58565
58980
|
} catch {
|
|
58566
58981
|
return void 0;
|
|
@@ -58570,7 +58985,8 @@ async function askRouting(input2) {
|
|
|
58570
58985
|
}
|
|
58571
58986
|
function reportRouting(input2) {
|
|
58572
58987
|
try {
|
|
58573
|
-
const
|
|
58988
|
+
const sessionId = input2.sessionId;
|
|
58989
|
+
const handle = routingHandle(sessionId);
|
|
58574
58990
|
if (!handle)
|
|
58575
58991
|
return;
|
|
58576
58992
|
const report = handle.report;
|
|
@@ -58579,6 +58995,22 @@ function reportRouting(input2) {
|
|
|
58579
58995
|
let payload;
|
|
58580
58996
|
if ("kind" in input2) {
|
|
58581
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
|
+
}
|
|
58582
59014
|
case "billing": {
|
|
58583
59015
|
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
58584
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")
|
|
@@ -58669,6 +59101,17 @@ function reportRouting(input2) {
|
|
|
58669
59101
|
};
|
|
58670
59102
|
break;
|
|
58671
59103
|
}
|
|
59104
|
+
case "credential_refused": {
|
|
59105
|
+
const { credentialId, providerCode } = input2;
|
|
59106
|
+
if (!isNonEmptyString(credentialId) || typeof providerCode !== "string" || !/^[a-z0-9._-]{1,64}$/.test(providerCode))
|
|
59107
|
+
return;
|
|
59108
|
+
payload = {
|
|
59109
|
+
...identity4,
|
|
59110
|
+
outcome: "credential_refused",
|
|
59111
|
+
provider_code: providerCode
|
|
59112
|
+
};
|
|
59113
|
+
break;
|
|
59114
|
+
}
|
|
58672
59115
|
default:
|
|
58673
59116
|
return;
|
|
58674
59117
|
}
|
|
@@ -58994,8 +59437,6 @@ function getModelFamilyFromUrl(urlString, debug) {
|
|
|
58994
59437
|
}
|
|
58995
59438
|
|
|
58996
59439
|
// src/plugin/session-context.ts
|
|
58997
|
-
import { resolve as resolve30 } from "node:path";
|
|
58998
|
-
import { pathToFileURL } from "node:url";
|
|
58999
59440
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
59000
59441
|
function extractOpenCodeSessionIdentity(headers) {
|
|
59001
59442
|
const normalized = new Headers(headers);
|
|
@@ -59007,9 +59448,8 @@ function extractOpenCodeSessionIdentity(headers) {
|
|
|
59007
59448
|
var AgySessionRegistry = class {
|
|
59008
59449
|
requestSessions;
|
|
59009
59450
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
59010
|
-
constructor(
|
|
59011
|
-
|
|
59012
|
-
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
59451
|
+
constructor(options = {}) {
|
|
59452
|
+
this.requestSessions = new AgyRequestSessionStore(options);
|
|
59013
59453
|
}
|
|
59014
59454
|
getOrCreate(identity4) {
|
|
59015
59455
|
const key = identity4.sessionId ?? FALLBACK_SESSION_KEY;
|
|
@@ -59291,9 +59731,13 @@ function observeVaultUpstream(response, signal) {
|
|
|
59291
59731
|
return void 0;
|
|
59292
59732
|
let completed = false;
|
|
59293
59733
|
return {
|
|
59294
|
-
response: observeBody(
|
|
59295
|
-
|
|
59296
|
-
|
|
59734
|
+
response: observeBody(
|
|
59735
|
+
response,
|
|
59736
|
+
() => {
|
|
59737
|
+
completed = !signal?.aborted;
|
|
59738
|
+
},
|
|
59739
|
+
isTerminalSseLine
|
|
59740
|
+
),
|
|
59297
59741
|
completedSuccessfully: () => completed
|
|
59298
59742
|
};
|
|
59299
59743
|
}
|
|
@@ -59312,29 +59756,36 @@ function observeVaultServed(identity4, response, signal, upstream) {
|
|
|
59312
59756
|
};
|
|
59313
59757
|
return observeBody(response, report);
|
|
59314
59758
|
}
|
|
59315
|
-
function observeBody(response, complete) {
|
|
59759
|
+
function observeBody(response, complete, terminal) {
|
|
59316
59760
|
if (!response.body) {
|
|
59317
59761
|
complete();
|
|
59318
59762
|
return response;
|
|
59319
59763
|
}
|
|
59320
59764
|
const sse = response.headers.get("content-type")?.includes("text/event-stream");
|
|
59765
|
+
const awaitsTerminal = sse && terminal !== void 0;
|
|
59321
59766
|
const reader = response.body.getReader();
|
|
59322
59767
|
const decoder = new TextDecoder();
|
|
59323
59768
|
let pending = "";
|
|
59324
59769
|
let failed = false;
|
|
59770
|
+
let terminated = false;
|
|
59325
59771
|
const inspect = (line) => {
|
|
59772
|
+
if (terminated) return;
|
|
59326
59773
|
if (line.length > 1024 * 1024) {
|
|
59327
59774
|
failed = true;
|
|
59328
59775
|
return;
|
|
59329
59776
|
}
|
|
59330
59777
|
if (line.startsWith("event:") && line.slice(6).trim() === "error")
|
|
59331
59778
|
failed = true;
|
|
59332
|
-
if (
|
|
59333
|
-
|
|
59334
|
-
|
|
59335
|
-
|
|
59336
|
-
|
|
59337
|
-
|
|
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();
|
|
59338
59789
|
}
|
|
59339
59790
|
};
|
|
59340
59791
|
const body = new ReadableStream(
|
|
@@ -59351,12 +59802,12 @@ function observeBody(response, complete) {
|
|
|
59351
59802
|
failed = true;
|
|
59352
59803
|
}
|
|
59353
59804
|
}
|
|
59354
|
-
if (!failed) complete();
|
|
59805
|
+
if (!failed && !awaitsTerminal) complete();
|
|
59355
59806
|
controller.close();
|
|
59356
59807
|
reader.releaseLock();
|
|
59357
59808
|
return;
|
|
59358
59809
|
}
|
|
59359
|
-
if (!failed) {
|
|
59810
|
+
if (!failed && !terminated) {
|
|
59360
59811
|
pending += decoder.decode(chunk.value, { stream: true });
|
|
59361
59812
|
if (sse) {
|
|
59362
59813
|
let newline = pending.indexOf("\n");
|
|
@@ -59417,6 +59868,16 @@ function isPrimaryVaultRequest(kind, headers) {
|
|
|
59417
59868
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
59418
59869
|
var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
|
|
59419
59870
|
var ROUTING_ASK_DEADLINE_MS = 2e3;
|
|
59871
|
+
function routingRefusalRetryAfterSeconds(refused2, now) {
|
|
59872
|
+
const { retryAfterSecs, resetsAtMs } = refused2;
|
|
59873
|
+
if (typeof retryAfterSecs === "number" && Number.isFinite(retryAfterSecs) && retryAfterSecs > 0) {
|
|
59874
|
+
return BigInt(Math.ceil(retryAfterSecs));
|
|
59875
|
+
}
|
|
59876
|
+
if (typeof resetsAtMs === "number" && Number.isFinite(resetsAtMs) && resetsAtMs > now) {
|
|
59877
|
+
return (BigInt(Math.ceil(resetsAtMs - now)) + 999n) / 1000n;
|
|
59878
|
+
}
|
|
59879
|
+
return void 0;
|
|
59880
|
+
}
|
|
59420
59881
|
function prepareAgyWireRequest(wire, request2) {
|
|
59421
59882
|
return wire.prepare(
|
|
59422
59883
|
request2.input,
|
|
@@ -59494,7 +59955,7 @@ function formatWaitTime(ms) {
|
|
|
59494
59955
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
59495
59956
|
}
|
|
59496
59957
|
function sleep4(ms, signal) {
|
|
59497
|
-
return new Promise((
|
|
59958
|
+
return new Promise((resolve31, reject) => {
|
|
59498
59959
|
if (signal?.aborted) {
|
|
59499
59960
|
reject(
|
|
59500
59961
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -59504,7 +59965,7 @@ function sleep4(ms, signal) {
|
|
|
59504
59965
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
59505
59966
|
const timeout = setTimeout(() => {
|
|
59506
59967
|
cleanup2();
|
|
59507
|
-
|
|
59968
|
+
resolve31();
|
|
59508
59969
|
}, timerMs);
|
|
59509
59970
|
const onAbort = () => {
|
|
59510
59971
|
cleanup2();
|
|
@@ -59519,6 +59980,44 @@ function sleep4(ms, signal) {
|
|
|
59519
59980
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
59520
59981
|
});
|
|
59521
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
|
+
}
|
|
59522
60021
|
function createLocalQuotaRefresh(accountManager, quotaManager, log18) {
|
|
59523
60022
|
return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
|
|
59524
60023
|
if (intervalMinutes <= 0) return;
|
|
@@ -59687,7 +60186,7 @@ function createRequestExecutor(deps) {
|
|
|
59687
60186
|
log18.debug("routing-report-failed", { sessionId, error: String(error) });
|
|
59688
60187
|
}
|
|
59689
60188
|
};
|
|
59690
|
-
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
|
|
60189
|
+
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy, waits) {
|
|
59691
60190
|
const assertAdmission = async () => {
|
|
59692
60191
|
await deadline.wait(() => deps.assertAdmission?.(deadline.signal));
|
|
59693
60192
|
};
|
|
@@ -59755,9 +60254,13 @@ function createRequestExecutor(deps) {
|
|
|
59755
60254
|
};
|
|
59756
60255
|
}
|
|
59757
60256
|
const sender = options.transport ?? defaultTransport2;
|
|
59758
|
-
const transport = (url, sendInit, sendOptions) => deadline.open(
|
|
59759
|
-
()
|
|
59760
|
-
|
|
60257
|
+
const transport = (url, sendInit, sendOptions) => deadline.open(() => {
|
|
60258
|
+
waits.resumed();
|
|
60259
|
+
return sender(url, sendInit, {
|
|
60260
|
+
...sendOptions,
|
|
60261
|
+
signal: deadline.signal
|
|
60262
|
+
});
|
|
60263
|
+
});
|
|
59761
60264
|
const requestSessionIdentity = options.session ?? extractOpenCodeSessionIdentity(init?.headers);
|
|
59762
60265
|
const agyRequestScope = agySessionRegistry.beginRequest(
|
|
59763
60266
|
agyMetadataIdentity(requestSessionIdentity, kind)
|
|
@@ -59807,6 +60310,13 @@ function createRequestExecutor(deps) {
|
|
|
59807
60310
|
let lastFailure = null;
|
|
59808
60311
|
let lastError = null;
|
|
59809
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
|
+
);
|
|
59810
60320
|
const checkAborted = () => {
|
|
59811
60321
|
deadline.check();
|
|
59812
60322
|
if (abortSignal?.aborted) {
|
|
@@ -60012,10 +60522,27 @@ function createRequestExecutor(deps) {
|
|
|
60012
60522
|
deadlineMs: Math.min(
|
|
60013
60523
|
ROUTING_ASK_DEADLINE_MS,
|
|
60014
60524
|
deadline.remainingMs()
|
|
60015
|
-
)
|
|
60525
|
+
),
|
|
60526
|
+
refusals: true
|
|
60016
60527
|
})
|
|
60017
60528
|
);
|
|
60018
60529
|
checkAborted();
|
|
60530
|
+
if (answer && "refused" in answer) {
|
|
60531
|
+
const { code: code2, routingCode } = answer.refused;
|
|
60532
|
+
log18.warn("routing-refused", {
|
|
60533
|
+
code: code2,
|
|
60534
|
+
...routingCode === void 0 ? {} : { routingCode }
|
|
60535
|
+
});
|
|
60536
|
+
const retryAfterSeconds = routingRefusalRetryAfterSeconds(
|
|
60537
|
+
answer.refused,
|
|
60538
|
+
Date.now()
|
|
60539
|
+
);
|
|
60540
|
+
return createNativeGoogleErrorResponse({
|
|
60541
|
+
status: 412,
|
|
60542
|
+
reason: "routing_refused",
|
|
60543
|
+
...retryAfterSeconds === void 0 ? {} : { retryAfterSeconds }
|
|
60544
|
+
});
|
|
60545
|
+
}
|
|
60019
60546
|
if (answer && answer.candidate.index !== account.index && !excludedIndexes?.has(answer.candidate.index)) {
|
|
60020
60547
|
account = accountManager.getCurrentOrNextForFamily(
|
|
60021
60548
|
family,
|
|
@@ -60131,7 +60658,10 @@ function createRequestExecutor(deps) {
|
|
|
60131
60658
|
);
|
|
60132
60659
|
retryState.markSoftQuotaToastShown();
|
|
60133
60660
|
}
|
|
60134
|
-
await
|
|
60661
|
+
await routingSleep(
|
|
60662
|
+
Math.min(waitMs, remainingWaitMs()),
|
|
60663
|
+
"account_free"
|
|
60664
|
+
);
|
|
60135
60665
|
continue;
|
|
60136
60666
|
}
|
|
60137
60667
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
@@ -60174,7 +60704,7 @@ function createRequestExecutor(deps) {
|
|
|
60174
60704
|
);
|
|
60175
60705
|
retryState.markRateLimitToastShown();
|
|
60176
60706
|
}
|
|
60177
|
-
await
|
|
60707
|
+
await routingSleep(Math.min(waitMs, remainingWaitMs()), "account_free");
|
|
60178
60708
|
continue;
|
|
60179
60709
|
}
|
|
60180
60710
|
allAccountsBlockedAt = void 0;
|
|
@@ -60848,7 +61378,11 @@ function createRequestExecutor(deps) {
|
|
|
60848
61378
|
`\u23F3 Server busy (${response.status}). Retrying in ${waitSec}s...`,
|
|
60849
61379
|
"warning"
|
|
60850
61380
|
);
|
|
60851
|
-
await
|
|
61381
|
+
await routingSleep(
|
|
61382
|
+
waitMs,
|
|
61383
|
+
"server_busy",
|
|
61384
|
+
capacityRetryCount + 1
|
|
61385
|
+
);
|
|
60852
61386
|
if (capacityRetryCount < 1) {
|
|
60853
61387
|
capacityRetryCount++;
|
|
60854
61388
|
i -= 1;
|
|
@@ -60918,7 +61452,7 @@ function createRequestExecutor(deps) {
|
|
|
60918
61452
|
rateLimitReason,
|
|
60919
61453
|
serverRetryMs
|
|
60920
61454
|
);
|
|
60921
|
-
await
|
|
61455
|
+
await routingSleep(effectiveDelayMs, "account_limit");
|
|
60922
61456
|
i -= 1;
|
|
60923
61457
|
continue;
|
|
60924
61458
|
}
|
|
@@ -60968,7 +61502,11 @@ function createRequestExecutor(deps) {
|
|
|
60968
61502
|
`Rate limited. Retrying in ${expBackoffFormatted} (attempt ${backoff.attempt})...`,
|
|
60969
61503
|
"warning"
|
|
60970
61504
|
);
|
|
60971
|
-
await
|
|
61505
|
+
await routingSleep(
|
|
61506
|
+
expBackoffMs,
|
|
61507
|
+
"rate_limited",
|
|
61508
|
+
backoff.attempt
|
|
61509
|
+
);
|
|
60972
61510
|
}
|
|
60973
61511
|
lastFailure = createFailureContext(response);
|
|
60974
61512
|
shouldSwitchAccount = true;
|
|
@@ -61461,15 +61999,19 @@ function createRequestExecutor(deps) {
|
|
|
61461
61999
|
const waitPolicy = {};
|
|
61462
62000
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
61463
62001
|
const selectedProjectIds = /* @__PURE__ */ new Set();
|
|
61464
|
-
const pending =
|
|
61465
|
-
|
|
61466
|
-
|
|
61467
|
-
|
|
61468
|
-
|
|
61469
|
-
|
|
61470
|
-
|
|
61471
|
-
|
|
61472
|
-
|
|
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
|
+
)
|
|
61473
62015
|
)
|
|
61474
62016
|
).catch((error) => {
|
|
61475
62017
|
cancellation.signal.throwIfAborted();
|
|
@@ -61847,18 +62389,8 @@ tool.schema = z5;
|
|
|
61847
62389
|
init_logger4();
|
|
61848
62390
|
|
|
61849
62391
|
// src/plugin/search.ts
|
|
61850
|
-
import crypto3 from "node:crypto";
|
|
61851
62392
|
init_logger4();
|
|
61852
62393
|
var log16 = createLogger4("search");
|
|
61853
|
-
var sessionCounter = 0;
|
|
61854
|
-
var sessionPrefix = `search-${Date.now().toString(36)}`;
|
|
61855
|
-
function generateRequestId() {
|
|
61856
|
-
return `agent/${crypto3.randomUUID()}/${Date.now()}/${crypto3.randomUUID()}/2`;
|
|
61857
|
-
}
|
|
61858
|
-
function getSessionId() {
|
|
61859
|
-
sessionCounter++;
|
|
61860
|
-
return `${sessionPrefix}-${sessionCounter}`;
|
|
61861
|
-
}
|
|
61862
62394
|
function formatSearchResult(result) {
|
|
61863
62395
|
const lines = [];
|
|
61864
62396
|
lines.push("## Search Results\n");
|
|
@@ -61969,13 +62501,18 @@ ${urlList}`;
|
|
|
61969
62501
|
topP: 1
|
|
61970
62502
|
}
|
|
61971
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);
|
|
61972
62512
|
const wrappedBody = {
|
|
61973
62513
|
project: projectId,
|
|
61974
|
-
requestId:
|
|
61975
|
-
request:
|
|
61976
|
-
...requestPayload,
|
|
61977
|
-
sessionId: getSessionId()
|
|
61978
|
-
},
|
|
62514
|
+
requestId: metadata.requestId,
|
|
62515
|
+
request: requestPayload,
|
|
61979
62516
|
model: SEARCH_MODEL,
|
|
61980
62517
|
userAgent: "antigravity",
|
|
61981
62518
|
requestType: "agent"
|
|
@@ -62219,8 +62756,8 @@ function createPluginLifecycle(options) {
|
|
|
62219
62756
|
};
|
|
62220
62757
|
let failDisposal = () => {
|
|
62221
62758
|
};
|
|
62222
|
-
disposal = new Promise((
|
|
62223
|
-
finishDisposal =
|
|
62759
|
+
disposal = new Promise((resolve31, reject) => {
|
|
62760
|
+
finishDisposal = resolve31;
|
|
62224
62761
|
failDisposal = reject;
|
|
62225
62762
|
});
|
|
62226
62763
|
void (async () => {
|
|
@@ -62445,7 +62982,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62445
62982
|
if (config.keep_thinking) {
|
|
62446
62983
|
initDiskSignatureCache(config.signature_cache);
|
|
62447
62984
|
}
|
|
62448
|
-
const sessionRegistry = new AgySessionRegistry(
|
|
62985
|
+
const sessionRegistry = new AgySessionRegistry();
|
|
62449
62986
|
let cachedGetAuth = null;
|
|
62450
62987
|
let stopSidebarPublisher;
|
|
62451
62988
|
const lifecycle = createPluginLifecycle({
|
|
@@ -62462,7 +62999,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62462
62999
|
await drainSidebarWrites();
|
|
62463
63000
|
}
|
|
62464
63001
|
});
|
|
62465
|
-
const accountFile =
|
|
63002
|
+
const accountFile = resolve30(accountFileForVault());
|
|
62466
63003
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
62467
63004
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
62468
63005
|
let vaultQuotaPoller;
|
|
@@ -62807,7 +63344,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
62807
63344
|
const key = vaultAccountRowKey(row);
|
|
62808
63345
|
const existing = vaultSelectors.get(key);
|
|
62809
63346
|
if (existing) return existing;
|
|
62810
|
-
const selector =
|
|
63347
|
+
const selector = randomUUID25();
|
|
62811
63348
|
vaultSelectors.set(key, selector);
|
|
62812
63349
|
return selector;
|
|
62813
63350
|
},
|