@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/server.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((resolve32) => setTimeout(resolve32, 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((resolve32) => {
|
|
8121
|
+
lostResolve = resolve32;
|
|
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 resolve32 = lostResolve;
|
|
8073
8132
|
lostResolve = null;
|
|
8074
|
-
|
|
8133
|
+
resolve32?.();
|
|
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((resolve32) => setTimeout(resolve32, 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((resolve32) => setTimeout(resolve32, 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((resolve32, reject) => {
|
|
10023
|
+
this.savePromiseResolvers.push({ resolve: resolve32, 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: resolve32 } of resolvers)
|
|
10067
|
+
resolve32();
|
|
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: resolve32 } of resolvers) {
|
|
10082
|
+
resolve32();
|
|
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: resolve32 } of resolvers) {
|
|
10090
|
+
resolve32();
|
|
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((resolve32, 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(() => resolve32({ 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((resolve32, 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
|
+
resolve32();
|
|
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((resolve32, 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
|
+
resolve32(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((resolve32, 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
|
+
resolve32(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((resolve32) => {
|
|
13485
|
+
resolveLoss = resolve32;
|
|
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((resolve32) => setTimeout(resolve32, 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((resolve32) => setTimeout(resolve32, 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((resolve32) => setTimeout(resolve32, 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((resolve32) => setTimeout(resolve32, 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((resolve32) => setTimeout(resolve32, 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((resolve32) => {
|
|
17258
17319
|
const done = () => {
|
|
17259
17320
|
clearTimeout(timer);
|
|
17260
17321
|
this.wake.delete(done);
|
|
17261
|
-
|
|
17322
|
+
resolve32();
|
|
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((resolve32) => {
|
|
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
|
+
resolve32(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
|
+
resolve32(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((resolve32) => {
|
|
22412
22473
|
timer = setTimeout(() => {
|
|
22413
22474
|
expired = true;
|
|
22414
|
-
|
|
22475
|
+
resolve32();
|
|
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 shared4 = wait2;
|
|
23228
|
+
shared4.users++;
|
|
23229
|
+
let timer;
|
|
23230
|
+
let abort;
|
|
23231
|
+
try {
|
|
23232
|
+
const attempt = await Promise.race([
|
|
23233
|
+
shared4.pending,
|
|
23234
|
+
new Promise((_resolve, reject) => {
|
|
23235
|
+
timer = this.#setTimeout(() => {
|
|
23236
|
+
if (this.#outage)
|
|
23237
|
+
this.#outageWaitSpent = true;
|
|
23238
|
+
reject(shared4.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 (--shared4.users === 0) {
|
|
23262
|
+
shared4.controller.abort();
|
|
23263
|
+
if (this.#receiptWaits.get(key) === shared4)
|
|
23264
|
+
this.#receiptWaits.delete(key);
|
|
23265
|
+
}
|
|
23266
|
+
}
|
|
23267
|
+
}
|
|
23268
|
+
#receiptBackoff(delay3, signal) {
|
|
23269
|
+
this.#check(signal);
|
|
23270
|
+
return new Promise((resolve32, 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
|
+
resolve32();
|
|
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((resolve32, 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
|
+
resolve32(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((resolve32, 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
|
+
resolve32(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((resolve32) => {
|
|
27456
|
+
setTimeout(resolve32, 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((resolve32, 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(resolve32, 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((resolve32, 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(() => resolve32(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((resolve32) => {
|
|
31568
31823
|
const done = () => {
|
|
31569
31824
|
clearTimeout(timer);
|
|
31570
31825
|
cancelWait = void 0;
|
|
31571
|
-
|
|
31826
|
+
resolve32();
|
|
31572
31827
|
};
|
|
31573
31828
|
const timer = setTimeout(done, 2e3);
|
|
31574
31829
|
timer.unref?.();
|
|
@@ -34554,13 +34809,13 @@ function closeDebugStream(state) {
|
|
|
34554
34809
|
state.logWriter = () => {
|
|
34555
34810
|
};
|
|
34556
34811
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34557
|
-
return new Promise((
|
|
34558
|
-
current.once("close", () =>
|
|
34559
|
-
current.once("error", () =>
|
|
34812
|
+
return new Promise((resolve32) => {
|
|
34813
|
+
current.once("close", () => resolve32());
|
|
34814
|
+
current.once("error", () => resolve32());
|
|
34560
34815
|
try {
|
|
34561
34816
|
current.end();
|
|
34562
34817
|
} catch {
|
|
34563
|
-
|
|
34818
|
+
resolve32();
|
|
34564
34819
|
}
|
|
34565
34820
|
});
|
|
34566
34821
|
}
|
|
@@ -34825,13 +35080,13 @@ function closeDebugLog() {
|
|
|
34825
35080
|
if (!state || !current) return Promise.resolve();
|
|
34826
35081
|
state.logStream = null;
|
|
34827
35082
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34828
|
-
return new Promise((
|
|
34829
|
-
current.once("close", () =>
|
|
34830
|
-
current.once("error", () =>
|
|
35083
|
+
return new Promise((resolve32) => {
|
|
35084
|
+
current.once("close", () => resolve32());
|
|
35085
|
+
current.once("error", () => resolve32());
|
|
34831
35086
|
try {
|
|
34832
35087
|
current.end();
|
|
34833
35088
|
} catch {
|
|
34834
|
-
|
|
35089
|
+
resolve32();
|
|
34835
35090
|
}
|
|
34836
35091
|
});
|
|
34837
35092
|
}
|
|
@@ -35149,7 +35404,7 @@ var init_vault_folder = __esm({
|
|
|
35149
35404
|
|
|
35150
35405
|
// src/ga/server/index.ts
|
|
35151
35406
|
init_dist();
|
|
35152
|
-
import { randomUUID as
|
|
35407
|
+
import { randomUUID as randomUUID21 } from "node:crypto";
|
|
35153
35408
|
import {
|
|
35154
35409
|
createServer as createServer2
|
|
35155
35410
|
} from "node:http";
|
|
@@ -35355,12 +35610,12 @@ async function startOAuthListener({
|
|
|
35355
35610
|
let resolveCallback;
|
|
35356
35611
|
let rejectCallback;
|
|
35357
35612
|
let timeoutHandle;
|
|
35358
|
-
const callbackPromise = new Promise((
|
|
35613
|
+
const callbackPromise = new Promise((resolve32, reject) => {
|
|
35359
35614
|
resolveCallback = (url) => {
|
|
35360
35615
|
if (settled) return;
|
|
35361
35616
|
settled = true;
|
|
35362
35617
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
35363
|
-
|
|
35618
|
+
resolve32(url);
|
|
35364
35619
|
};
|
|
35365
35620
|
rejectCallback = (error) => {
|
|
35366
35621
|
if (settled) return;
|
|
@@ -35519,7 +35774,7 @@ async function startOAuthListener({
|
|
|
35519
35774
|
});
|
|
35520
35775
|
});
|
|
35521
35776
|
const bindAddress = getBindAddress();
|
|
35522
|
-
await new Promise((
|
|
35777
|
+
await new Promise((resolve32, reject) => {
|
|
35523
35778
|
const handleError = (error) => {
|
|
35524
35779
|
server.off("error", handleError);
|
|
35525
35780
|
if (error.code === "EADDRINUSE") {
|
|
@@ -35535,7 +35790,7 @@ async function startOAuthListener({
|
|
|
35535
35790
|
server.once("error", handleError);
|
|
35536
35791
|
server.listen(port, bindAddress, () => {
|
|
35537
35792
|
server.off("error", handleError);
|
|
35538
|
-
|
|
35793
|
+
resolve32();
|
|
35539
35794
|
});
|
|
35540
35795
|
});
|
|
35541
35796
|
server.on("error", (error) => {
|
|
@@ -35543,7 +35798,7 @@ async function startOAuthListener({
|
|
|
35543
35798
|
});
|
|
35544
35799
|
return {
|
|
35545
35800
|
waitForCallback: () => callbackPromise,
|
|
35546
|
-
close: () => new Promise((
|
|
35801
|
+
close: () => new Promise((resolve32, reject) => {
|
|
35547
35802
|
server.close((error) => {
|
|
35548
35803
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
35549
35804
|
reject(error);
|
|
@@ -35552,7 +35807,7 @@ async function startOAuthListener({
|
|
|
35552
35807
|
if (!settled) {
|
|
35553
35808
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
35554
35809
|
}
|
|
35555
|
-
|
|
35810
|
+
resolve32();
|
|
35556
35811
|
});
|
|
35557
35812
|
})
|
|
35558
35813
|
};
|
|
@@ -35568,11 +35823,11 @@ var GA_POOL_PASTE_METHOD_ID = "antigravity-auth-pool-paste";
|
|
|
35568
35823
|
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
35569
35824
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
35570
35825
|
function abortable(pending, signal) {
|
|
35571
|
-
return new Promise((
|
|
35826
|
+
return new Promise((resolve32, reject) => {
|
|
35572
35827
|
const abort = () => reject(signal.reason);
|
|
35573
35828
|
if (signal.aborted) abort();
|
|
35574
35829
|
else signal.addEventListener("abort", abort, { once: true });
|
|
35575
|
-
void pending.then(
|
|
35830
|
+
void pending.then(resolve32, reject).finally(() => {
|
|
35576
35831
|
signal.removeEventListener("abort", abort);
|
|
35577
35832
|
});
|
|
35578
35833
|
});
|
|
@@ -37119,7 +37374,10 @@ function descriptorAtPath(descriptor, path5) {
|
|
|
37119
37374
|
}
|
|
37120
37375
|
return current;
|
|
37121
37376
|
}
|
|
37122
|
-
function destination(declaration, setting, value, { host, model }) {
|
|
37377
|
+
function destination(declaration, setting, value, { host, model }, level) {
|
|
37378
|
+
if (level !== void 0) {
|
|
37379
|
+
return level === "default" && !isJsonObject(value) ? [setting] : [setting, level];
|
|
37380
|
+
}
|
|
37123
37381
|
if (declaration.overrides !== void 0 && isJsonObject(value)) {
|
|
37124
37382
|
if (declaration.overrides.model && model !== void 0 && model !== "default" && model !== "opencode" && model !== "pi" && Object.hasOwn(value, model)) {
|
|
37125
37383
|
return [setting, model];
|
|
@@ -37149,6 +37407,19 @@ function checkPath(parsed, path5) {
|
|
|
37149
37407
|
invalid();
|
|
37150
37408
|
}
|
|
37151
37409
|
}
|
|
37410
|
+
function preservePlainDefault(parsed, setting) {
|
|
37411
|
+
const node = parsed.tree && findNodeAtLocation(parsed.tree, [setting]);
|
|
37412
|
+
if (!node)
|
|
37413
|
+
invalid();
|
|
37414
|
+
const value = parsed.text.slice(node.offset, node.offset + node.length);
|
|
37415
|
+
return parseForEdit(applyEdits(parsed.text, [
|
|
37416
|
+
{
|
|
37417
|
+
offset: node.offset,
|
|
37418
|
+
length: node.length,
|
|
37419
|
+
content: `{ "default": ${value} }`
|
|
37420
|
+
}
|
|
37421
|
+
]));
|
|
37422
|
+
}
|
|
37152
37423
|
function removeMember(text2, tree, path5) {
|
|
37153
37424
|
const property = tree && findNodeAtLocation(tree, path5)?.parent;
|
|
37154
37425
|
const parent = property?.parent;
|
|
@@ -37222,6 +37493,16 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
37222
37493
|
if (!Object.hasOwn(definition.settings, edit.setting))
|
|
37223
37494
|
invalid();
|
|
37224
37495
|
const declaration = definition.settings[edit.setting];
|
|
37496
|
+
if (edit.level !== void 0) {
|
|
37497
|
+
if (edit.path !== void 0)
|
|
37498
|
+
invalid();
|
|
37499
|
+
if (edit.level === "default") {
|
|
37500
|
+
if (declaration.overrides === void 0)
|
|
37501
|
+
invalid();
|
|
37502
|
+
} else if (edit.level !== "opencode" && edit.level !== "pi" || !declaration.overrides?.host) {
|
|
37503
|
+
invalid();
|
|
37504
|
+
}
|
|
37505
|
+
}
|
|
37225
37506
|
if (edit.path !== void 0 && declaration.value.kind !== "object" && declaration.value.kind !== "record")
|
|
37226
37507
|
invalid();
|
|
37227
37508
|
const descriptor = descriptorAtPath(declaration.value, edit.path ?? []);
|
|
@@ -37233,7 +37514,19 @@ function applySettingsEdits(definition, source, edits, context) {
|
|
|
37233
37514
|
const units = [];
|
|
37234
37515
|
for (const edit of edits) {
|
|
37235
37516
|
const declaration = definition.settings[edit.setting];
|
|
37236
|
-
|
|
37517
|
+
if (edit.level !== void 0 && edit.level !== "default" && !isJsonObject(working.value[edit.setting])) {
|
|
37518
|
+
if (edit.remove === true)
|
|
37519
|
+
continue;
|
|
37520
|
+
if (Object.hasOwn(working.value, edit.setting)) {
|
|
37521
|
+
working = preservePlainDefault(working, edit.setting);
|
|
37522
|
+
}
|
|
37523
|
+
for (const unit of units) {
|
|
37524
|
+
if (unit.path.length === 1 && unit.path[0] === edit.setting) {
|
|
37525
|
+
unit.path.push("default");
|
|
37526
|
+
}
|
|
37527
|
+
}
|
|
37528
|
+
}
|
|
37529
|
+
const base = edit.path !== void 0 ? [edit.setting] : destination(declaration, edit.setting, working.value[edit.setting], context, edit.level);
|
|
37237
37530
|
const path5 = [...base, ...edit.path ?? []];
|
|
37238
37531
|
checkPath(working, path5);
|
|
37239
37532
|
units.push(resolutionUnit(declaration.value, base, edit.path ?? []));
|
|
@@ -37386,18 +37679,20 @@ async function writeTarget(file) {
|
|
|
37386
37679
|
} catch (error) {
|
|
37387
37680
|
if (error.code !== "ENOENT")
|
|
37388
37681
|
unavailable(file, error);
|
|
37682
|
+
let isSymlink = false;
|
|
37389
37683
|
try {
|
|
37390
|
-
await SettingsFs.lstat(file);
|
|
37684
|
+
isSymlink = (await SettingsFs.lstat(file)).isSymbolicLink();
|
|
37391
37685
|
} catch (lstatError) {
|
|
37392
37686
|
if (lstatError.code !== "ENOENT")
|
|
37393
37687
|
unavailable(file, lstatError);
|
|
37394
|
-
try {
|
|
37395
|
-
return join11(await SettingsFs.realpath(dirname14(file)), basename6(file));
|
|
37396
|
-
} catch (parentError) {
|
|
37397
|
-
unavailable(file, parentError);
|
|
37398
|
-
}
|
|
37399
37688
|
}
|
|
37400
|
-
|
|
37689
|
+
if (isSymlink)
|
|
37690
|
+
unavailable(file, error);
|
|
37691
|
+
try {
|
|
37692
|
+
return join11(await SettingsFs.realpath(dirname14(file)), basename6(file));
|
|
37693
|
+
} catch (parentError) {
|
|
37694
|
+
unavailable(file, parentError);
|
|
37695
|
+
}
|
|
37401
37696
|
}
|
|
37402
37697
|
}
|
|
37403
37698
|
async function updateSettings(definition, options, edits, context) {
|
|
@@ -37452,6 +37747,16 @@ async function updateSettings(definition, options, edits, context) {
|
|
|
37452
37747
|
if (Number.isInteger(version) && version > 1) {
|
|
37453
37748
|
throw new SettingsRefusal("settings-newer-version", "Settings were written by a newer version");
|
|
37454
37749
|
}
|
|
37750
|
+
if (typeof edits === "function") {
|
|
37751
|
+
const planned = edits(deepFreeze(missing ? { status: "missing" } : {
|
|
37752
|
+
status: "ready",
|
|
37753
|
+
document: structuredClone(parsed.value)
|
|
37754
|
+
}));
|
|
37755
|
+
if (planned !== null && (typeof planned === "object" || typeof planned === "function") && "then" in planned && typeof planned.then === "function") {
|
|
37756
|
+
throw new SettingsRefusal("settings-invalid-value", "Settings update plans must be synchronous");
|
|
37757
|
+
}
|
|
37758
|
+
edits = planned;
|
|
37759
|
+
}
|
|
37455
37760
|
if (!parsed.tree) {
|
|
37456
37761
|
source = `${parsed.hasBom ? "\uFEFF" : ""}// ${definition.plugin} settings
|
|
37457
37762
|
{
|
|
@@ -38842,7 +39147,7 @@ function buildAccountAccessProbeRequest(projectId) {
|
|
|
38842
39147
|
generationConfig: { maxOutputTokens: 1, temperature: 0 }
|
|
38843
39148
|
};
|
|
38844
39149
|
const requestMetadata = buildAgyAgentRequestMetadata(
|
|
38845
|
-
createAgyRequestSessionContext(
|
|
39150
|
+
createAgyRequestSessionContext(),
|
|
38846
39151
|
request2,
|
|
38847
39152
|
wireModel
|
|
38848
39153
|
);
|
|
@@ -40421,7 +40726,7 @@ function drainSidebarWrites() {
|
|
|
40421
40726
|
return sidebarWriteChain;
|
|
40422
40727
|
}
|
|
40423
40728
|
async function sleep3(ms) {
|
|
40424
|
-
await new Promise((
|
|
40729
|
+
await new Promise((resolve32) => setTimeout(resolve32, ms));
|
|
40425
40730
|
}
|
|
40426
40731
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
40427
40732
|
const start = Date.now();
|
|
@@ -40980,14 +41285,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
40980
41285
|
name = "LocalQuotaGrantStaleError";
|
|
40981
41286
|
};
|
|
40982
41287
|
function untilQuotaAborted(pending, signal) {
|
|
40983
|
-
return new Promise((
|
|
41288
|
+
return new Promise((resolve32, reject) => {
|
|
40984
41289
|
const abort = () => reject(signal.reason);
|
|
40985
41290
|
if (signal.aborted) abort();
|
|
40986
41291
|
else signal.addEventListener("abort", abort, { once: true });
|
|
40987
41292
|
void pending.then(
|
|
40988
41293
|
(value) => {
|
|
40989
41294
|
signal.removeEventListener("abort", abort);
|
|
40990
|
-
|
|
41295
|
+
resolve32(value);
|
|
40991
41296
|
},
|
|
40992
41297
|
(error) => {
|
|
40993
41298
|
signal.removeEventListener("abort", abort);
|
|
@@ -42899,6 +43204,30 @@ To view: \`open "${filePath}"\``;
|
|
|
42899
43204
|
return ``;
|
|
42900
43205
|
}
|
|
42901
43206
|
|
|
43207
|
+
// src/plugin/core/streaming/terminal-event.ts
|
|
43208
|
+
function responseHasFinishReason(response) {
|
|
43209
|
+
if (!response || typeof response !== "object") return false;
|
|
43210
|
+
const resp = response;
|
|
43211
|
+
if (Array.isArray(resp.candidates)) {
|
|
43212
|
+
return resp.candidates.some((candidate) => {
|
|
43213
|
+
const cand = candidate;
|
|
43214
|
+
return typeof cand?.finishReason === "string" && cand.finishReason.length > 0;
|
|
43215
|
+
});
|
|
43216
|
+
}
|
|
43217
|
+
const stopReason = resp.stopReason ?? resp.stop_reason;
|
|
43218
|
+
return typeof stopReason === "string" && stopReason.length > 0;
|
|
43219
|
+
}
|
|
43220
|
+
function isTerminalSseLine(line) {
|
|
43221
|
+
if (!line.startsWith("data:")) return false;
|
|
43222
|
+
if (!/"(?:finishReason|stopReason|stop_reason)"/.test(line)) return false;
|
|
43223
|
+
try {
|
|
43224
|
+
const parsed = JSON.parse(line.slice(5).trim());
|
|
43225
|
+
return parsed?.response !== void 0 && responseHasFinishReason(parsed.response);
|
|
43226
|
+
} catch {
|
|
43227
|
+
return false;
|
|
43228
|
+
}
|
|
43229
|
+
}
|
|
43230
|
+
|
|
42902
43231
|
// src/plugin/core/streaming/transformer.ts
|
|
42903
43232
|
function hashString(str) {
|
|
42904
43233
|
let hash2 = 5381;
|
|
@@ -43068,18 +43397,6 @@ function responseHasToolCall(response) {
|
|
|
43068
43397
|
}
|
|
43069
43398
|
return false;
|
|
43070
43399
|
}
|
|
43071
|
-
function responseHasFinishReason(response) {
|
|
43072
|
-
if (!response || typeof response !== "object") return false;
|
|
43073
|
-
const resp = response;
|
|
43074
|
-
if (Array.isArray(resp.candidates)) {
|
|
43075
|
-
return resp.candidates.some((candidate) => {
|
|
43076
|
-
const cand = candidate;
|
|
43077
|
-
return typeof cand?.finishReason === "string" && cand.finishReason.length > 0;
|
|
43078
|
-
});
|
|
43079
|
-
}
|
|
43080
|
-
const stopReason = resp.stopReason ?? resp.stop_reason;
|
|
43081
|
-
return typeof stopReason === "string" && stopReason.length > 0;
|
|
43082
|
-
}
|
|
43083
43400
|
function transformSseLineWithMetadata(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState2, usageState) {
|
|
43084
43401
|
if (!line.startsWith("data:")) {
|
|
43085
43402
|
return { line, hasToolCall: false, hasFinishReason: false };
|
|
@@ -45473,6 +45790,7 @@ var NATIVE_GOOGLE_ERROR_MESSAGES = {
|
|
|
45473
45790
|
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.',
|
|
45474
45791
|
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.",
|
|
45475
45792
|
model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
|
|
45793
|
+
routing_refused: "Routing has no Antigravity account available for this request right now; try again later.",
|
|
45476
45794
|
missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
|
|
45477
45795
|
empty_response: "Antigravity returned an empty response after the internal retry attempts."
|
|
45478
45796
|
};
|
|
@@ -45499,6 +45817,9 @@ function createNativeGoogleErrorResponse(options) {
|
|
|
45499
45817
|
let body = JSON.stringify({
|
|
45500
45818
|
error: { code: options.status, status, message }
|
|
45501
45819
|
});
|
|
45820
|
+
if (options.reason === "routing_refused" && options.retryAfterSeconds !== void 0 && options.retryAfterSeconds >= 0n) {
|
|
45821
|
+
headers.set("Retry-After", options.retryAfterSeconds.toString());
|
|
45822
|
+
}
|
|
45502
45823
|
if (options.status === 412 && typeof options.resetAfterMs === "number" && Number.isFinite(options.resetAfterMs) && options.resetAfterMs >= 0) {
|
|
45503
45824
|
const delaySeconds = (BigInt(Math.ceil(options.resetAfterMs)) + 999n) / 1000n;
|
|
45504
45825
|
headers.set("Retry-After", delaySeconds.toString());
|
|
@@ -46028,7 +46349,7 @@ init_dist();
|
|
|
46028
46349
|
// src/plugin/request.ts
|
|
46029
46350
|
var log11 = createLogger4("request");
|
|
46030
46351
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
46031
|
-
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext(
|
|
46352
|
+
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext();
|
|
46032
46353
|
var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
|
|
46033
46354
|
var MIN_SIGNATURE_LENGTH = 50;
|
|
46034
46355
|
var AGY_CLAUDE_THINKING_BUDGET = 1024;
|
|
@@ -46109,7 +46430,9 @@ function getAgyMaxOutputTokens(model) {
|
|
|
46109
46430
|
}
|
|
46110
46431
|
function applyAgyGenerationDefaults(model, generationConfig) {
|
|
46111
46432
|
if (getAgyNativeModel(model)) {
|
|
46112
|
-
applyAgyNativeGenerationConfig(model, generationConfig
|
|
46433
|
+
applyAgyNativeGenerationConfig(model, generationConfig, {
|
|
46434
|
+
preserveThinkingBudget: false
|
|
46435
|
+
});
|
|
46113
46436
|
return;
|
|
46114
46437
|
}
|
|
46115
46438
|
const maxOutputTokens = getAgyMaxOutputTokens(model);
|
|
@@ -46425,20 +46748,38 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
46425
46748
|
}
|
|
46426
46749
|
}
|
|
46427
46750
|
}
|
|
46428
|
-
function
|
|
46429
|
-
|
|
46430
|
-
|
|
46431
|
-
|
|
46751
|
+
function isGeminiFunctionResponseTurn(content, wireModel) {
|
|
46752
|
+
return wireModel.startsWith("gemini-") && content?.role === "model" && Array.isArray(content.parts) && content.parts.length > 0 && content.parts.every((part) => part?.functionResponse);
|
|
46753
|
+
}
|
|
46754
|
+
function configureAntigravityToolCalling(payload) {
|
|
46755
|
+
delete payload.toolConfig;
|
|
46756
|
+
if (Array.isArray(payload.tools)) {
|
|
46757
|
+
payload.tools = payload.tools.flatMap(
|
|
46758
|
+
(tool2) => Array.isArray(tool2?.functionDeclarations) ? tool2.functionDeclarations.map((declaration) => ({
|
|
46759
|
+
functionDeclarations: [declaration]
|
|
46760
|
+
})) : [tool2]
|
|
46761
|
+
);
|
|
46432
46762
|
}
|
|
46433
|
-
const toolConfig = payload.toolConfig && typeof payload.toolConfig === "object" && !Array.isArray(payload.toolConfig) ? payload.toolConfig : {};
|
|
46434
|
-
const functionCallingConfig = toolConfig.functionCallingConfig && typeof toolConfig.functionCallingConfig === "object" && !Array.isArray(toolConfig.functionCallingConfig) ? toolConfig.functionCallingConfig : {};
|
|
46435
|
-
functionCallingConfig.mode = "VALIDATED";
|
|
46436
|
-
toolConfig.functionCallingConfig = functionCallingConfig;
|
|
46437
|
-
payload.toolConfig = toolConfig;
|
|
46438
46763
|
}
|
|
46439
|
-
function normalizeNativeFunctionResponseRoles(payload) {
|
|
46764
|
+
function normalizeNativeFunctionResponseRoles(payload, wireModel) {
|
|
46440
46765
|
const contents = payload.contents;
|
|
46441
46766
|
if (!Array.isArray(contents)) return;
|
|
46767
|
+
if (wireModel.startsWith("claude-")) {
|
|
46768
|
+
for (const content of contents) {
|
|
46769
|
+
if (Array.isArray(content?.parts)) {
|
|
46770
|
+
for (const part of content.parts) {
|
|
46771
|
+
if (part?.functionCall) {
|
|
46772
|
+
delete part.thoughtSignature;
|
|
46773
|
+
delete part.thought_signature;
|
|
46774
|
+
}
|
|
46775
|
+
}
|
|
46776
|
+
}
|
|
46777
|
+
if (content?.role === "model" && Array.isArray(content.parts) && content.parts.length > 0 && content.parts.every((part) => part?.functionResponse)) {
|
|
46778
|
+
content.role = "user";
|
|
46779
|
+
}
|
|
46780
|
+
}
|
|
46781
|
+
return;
|
|
46782
|
+
}
|
|
46442
46783
|
const signedCalls = /* @__PURE__ */ new Set();
|
|
46443
46784
|
for (const content of contents) {
|
|
46444
46785
|
const parts = content?.parts;
|
|
@@ -46884,7 +47225,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
46884
47225
|
}
|
|
46885
47226
|
const [, rawModel = "", rawAction = ""] = match;
|
|
46886
47227
|
const requestedModel = rawModel;
|
|
46887
|
-
const
|
|
47228
|
+
const hydrogenTier = isGeminiHydrogenModel(rawModel) ? options?.variant?.thinkingLevel : void 0;
|
|
47229
|
+
const resolved = resolveAntigravityModel(
|
|
47230
|
+
hydrogenTier ? `${rawModel.replace(/-(low|medium|high|xhigh)$/i, "")}-${hydrogenTier}` : rawModel
|
|
47231
|
+
);
|
|
46888
47232
|
let effectiveModel = resolved.actualModel;
|
|
46889
47233
|
const streaming = rawAction === STREAM_ACTION;
|
|
46890
47234
|
const defaultEndpoint = ANTIGRAVITY_ENDPOINT;
|
|
@@ -46973,14 +47317,14 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
46973
47317
|
}
|
|
46974
47318
|
sanitizeRequestPayloadForAntigravity(req);
|
|
46975
47319
|
stripUnsupportedAntigravityFields(req);
|
|
46976
|
-
configureAntigravityToolCalling(req
|
|
46977
|
-
normalizeNativeFunctionResponseRoles(req);
|
|
47320
|
+
configureAntigravityToolCalling(req);
|
|
47321
|
+
normalizeNativeFunctionResponseRoles(req, effectiveModel);
|
|
46978
47322
|
}
|
|
46979
47323
|
for (const req of requestObjects) {
|
|
46980
47324
|
if (Array.isArray(req.contents)) {
|
|
46981
47325
|
const contents = req.contents;
|
|
46982
47326
|
const lastContent = contents[contents.length - 1];
|
|
46983
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
47327
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
46984
47328
|
contents.push({ role: "user", parts: [{ text: "[Continue]" }] });
|
|
46985
47329
|
}
|
|
46986
47330
|
}
|
|
@@ -47015,7 +47359,9 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47015
47359
|
{
|
|
47016
47360
|
const generationConfig = wireRequest.generationConfig;
|
|
47017
47361
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
47018
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
47362
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
47363
|
+
thinkingBudget: options?.variant?.thinkingBudget
|
|
47364
|
+
});
|
|
47019
47365
|
if (Object.keys(config).length > 0)
|
|
47020
47366
|
wireRequest.generationConfig = config;
|
|
47021
47367
|
const metadata = buildAgyAgentRequestMetadata(
|
|
@@ -47044,13 +47390,19 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47044
47390
|
requestPayload.providerOptions,
|
|
47045
47391
|
rawGenerationConfig
|
|
47046
47392
|
);
|
|
47393
|
+
const callerThinking = rawGenerationConfig?.thinkingConfig ?? extraBody?.thinkingConfig ?? requestPayload.thinkingConfig;
|
|
47394
|
+
const callerAnthropicThinking = extraBody?.thinking ?? requestPayload.thinking;
|
|
47395
|
+
const explicitThinkingBudget = variantConfig?.thinkingBudget ?? (typeof callerThinking?.thinkingBudget === "number" ? callerThinking.thinkingBudget : void 0) ?? (typeof callerAnthropicThinking?.budgetTokens === "number" ? callerAnthropicThinking.budgetTokens : void 0);
|
|
47047
47396
|
const isGemini3 = effectiveModel.toLowerCase().includes("gemini-3");
|
|
47048
47397
|
wire.logger.debug(
|
|
47049
47398
|
`[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)}`
|
|
47050
47399
|
);
|
|
47051
47400
|
delete requestPayload.providerOptions;
|
|
47052
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
47053
|
-
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(
|
|
47401
|
+
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || isGeminiHydrogenModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
47402
|
+
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(
|
|
47403
|
+
isGeminiHydrogenModel(effectiveModel) ? /-(low|medium|high|xhigh)$/i : /-(minimal|low|medium|high)$/i,
|
|
47404
|
+
""
|
|
47405
|
+
);
|
|
47054
47406
|
const variantResolved = resolveAntigravityModel(
|
|
47055
47407
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
47056
47408
|
);
|
|
@@ -47146,7 +47498,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47146
47498
|
if (rawGenerationConfig) {
|
|
47147
47499
|
rawGenerationConfig.thinkingConfig = thinkingConfig;
|
|
47148
47500
|
applyAgyGenerationDefaults(effectiveModel, rawGenerationConfig);
|
|
47149
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
47501
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
47150
47502
|
const currentMax = rawGenerationConfig.maxOutputTokens ?? rawGenerationConfig.max_output_tokens;
|
|
47151
47503
|
if (!currentMax) {
|
|
47152
47504
|
rawGenerationConfig.maxOutputTokens = 64e3;
|
|
@@ -47162,7 +47514,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47162
47514
|
const generationConfig = {
|
|
47163
47515
|
thinkingConfig
|
|
47164
47516
|
};
|
|
47165
|
-
if (isClaudeThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
47517
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
47166
47518
|
generationConfig.maxOutputTokens = 64e3;
|
|
47167
47519
|
}
|
|
47168
47520
|
applyAgyGenerationDefaults(effectiveModel, generationConfig);
|
|
@@ -47263,7 +47615,11 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47263
47615
|
});
|
|
47264
47616
|
const finalTools = [];
|
|
47265
47617
|
if (functionDeclarations.length > 0) {
|
|
47266
|
-
finalTools.push(
|
|
47618
|
+
finalTools.push(
|
|
47619
|
+
...functionDeclarations.map((declaration) => ({
|
|
47620
|
+
functionDeclarations: [declaration]
|
|
47621
|
+
}))
|
|
47622
|
+
);
|
|
47267
47623
|
}
|
|
47268
47624
|
requestPayload.tools = finalTools.concat(passthroughTools);
|
|
47269
47625
|
} else {
|
|
@@ -47395,7 +47751,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47395
47751
|
requestPayload.messages
|
|
47396
47752
|
);
|
|
47397
47753
|
}
|
|
47398
|
-
if (isClaudeThinking && Array.isArray(requestPayload.contents)) {
|
|
47754
|
+
if (isClaudeThinking && !getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking && Array.isArray(requestPayload.contents)) {
|
|
47399
47755
|
const conversationState = analyzeConversationState(
|
|
47400
47756
|
requestPayload.contents
|
|
47401
47757
|
);
|
|
@@ -47409,7 +47765,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47409
47765
|
}
|
|
47410
47766
|
if (Array.isArray(requestPayload.contents)) {
|
|
47411
47767
|
const lastContent = requestPayload.contents[requestPayload.contents.length - 1];
|
|
47412
|
-
if (lastContent?.role === "model" || lastContent?.role === "assistant") {
|
|
47768
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
47413
47769
|
requestPayload.contents.push({
|
|
47414
47770
|
role: "user",
|
|
47415
47771
|
parts: [{ text: "[Continue]" }]
|
|
@@ -47434,15 +47790,18 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
47434
47790
|
{
|
|
47435
47791
|
const generationConfig = requestPayload.generationConfig;
|
|
47436
47792
|
const config = generationConfig && typeof generationConfig === "object" && !Array.isArray(generationConfig) ? generationConfig : {};
|
|
47437
|
-
applyAgyNativeGenerationConfig(effectiveModel, config
|
|
47793
|
+
applyAgyNativeGenerationConfig(effectiveModel, config, {
|
|
47794
|
+
thinkingBudget: explicitThinkingBudget,
|
|
47795
|
+
preserveThinkingBudget: false
|
|
47796
|
+
});
|
|
47438
47797
|
if (Object.keys(config).length > 0)
|
|
47439
47798
|
requestPayload.generationConfig = config;
|
|
47440
47799
|
stripUnsupportedAntigravityFields(requestPayload);
|
|
47441
|
-
configureAntigravityToolCalling(requestPayload
|
|
47442
|
-
normalizeNativeFunctionResponseRoles(requestPayload);
|
|
47800
|
+
configureAntigravityToolCalling(requestPayload);
|
|
47801
|
+
normalizeNativeFunctionResponseRoles(requestPayload, effectiveModel);
|
|
47443
47802
|
if (Array.isArray(requestPayload.contents)) {
|
|
47444
|
-
const lastContent = requestPayload.contents
|
|
47445
|
-
if (lastContent?.role === "model") {
|
|
47803
|
+
const lastContent = requestPayload.contents.at(-1);
|
|
47804
|
+
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel)) {
|
|
47446
47805
|
requestPayload.contents.push({
|
|
47447
47806
|
role: "user",
|
|
47448
47807
|
parts: [{ text: "[Continue]" }]
|
|
@@ -47548,7 +47907,9 @@ function buildThinkingWarmupBody(bodyText, isClaudeThinking) {
|
|
|
47548
47907
|
thinkingBudget: AGY_CLAUDE_THINKING_BUDGET
|
|
47549
47908
|
};
|
|
47550
47909
|
generationConfig.maxOutputTokens ??= generationConfig.max_output_tokens ?? getAgyMaxOutputTokens(wireModel) ?? computeClaudeMaxOutputTokens(AGY_CLAUDE_THINKING_BUDGET);
|
|
47551
|
-
applyAgyNativeGenerationConfig(wireModel, generationConfig
|
|
47910
|
+
applyAgyNativeGenerationConfig(wireModel, generationConfig, {
|
|
47911
|
+
preserveThinkingBudget: false
|
|
47912
|
+
});
|
|
47552
47913
|
req.generationConfig = generationConfig;
|
|
47553
47914
|
requestObjects.push(req);
|
|
47554
47915
|
};
|
|
@@ -47958,8 +48319,6 @@ function transformAntigravityResponse(...args) {
|
|
|
47958
48319
|
}
|
|
47959
48320
|
|
|
47960
48321
|
// src/plugin/session-context.ts
|
|
47961
|
-
import { resolve as resolve24 } from "node:path";
|
|
47962
|
-
import { pathToFileURL } from "node:url";
|
|
47963
48322
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
47964
48323
|
function extractOpenCodeSessionIdentity(headers) {
|
|
47965
48324
|
const normalized = new Headers(headers);
|
|
@@ -47971,9 +48330,8 @@ function extractOpenCodeSessionIdentity(headers) {
|
|
|
47971
48330
|
var AgySessionRegistry = class {
|
|
47972
48331
|
requestSessions;
|
|
47973
48332
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
47974
|
-
constructor(
|
|
47975
|
-
|
|
47976
|
-
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
48333
|
+
constructor(options = {}) {
|
|
48334
|
+
this.requestSessions = new AgyRequestSessionStore(options);
|
|
47977
48335
|
}
|
|
47978
48336
|
getOrCreate(identity4) {
|
|
47979
48337
|
const key = identity4.sessionId ?? FALLBACK_SESSION_KEY;
|
|
@@ -48134,10 +48492,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
48134
48492
|
cancellation.release();
|
|
48135
48493
|
throw error;
|
|
48136
48494
|
}
|
|
48137
|
-
let
|
|
48495
|
+
let resolve32 = () => {
|
|
48138
48496
|
};
|
|
48139
48497
|
const settled = new Promise((done) => {
|
|
48140
|
-
|
|
48498
|
+
resolve32 = done;
|
|
48141
48499
|
});
|
|
48142
48500
|
let stopping = false;
|
|
48143
48501
|
let finished = false;
|
|
@@ -48147,7 +48505,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
48147
48505
|
finished = true;
|
|
48148
48506
|
cancellation.signal.removeEventListener("abort", abort);
|
|
48149
48507
|
cancellation.release();
|
|
48150
|
-
|
|
48508
|
+
resolve32();
|
|
48151
48509
|
};
|
|
48152
48510
|
const abort = () => {
|
|
48153
48511
|
if (finished || stopping) return;
|
|
@@ -48205,7 +48563,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
48205
48563
|
|
|
48206
48564
|
// src/plugin/shared/request-services.ts
|
|
48207
48565
|
init_dist();
|
|
48208
|
-
import { createHash as createHash17 } from "node:crypto";
|
|
48566
|
+
import { createHash as createHash17, randomUUID as randomUUID20 } from "node:crypto";
|
|
48209
48567
|
|
|
48210
48568
|
// src/common-auth-embedded/claustrum/host.js
|
|
48211
48569
|
import { ClaustrumCredentialError as ClaustrumCredentialError8 } from "@cortexkit/claustrum-client";
|
|
@@ -48327,6 +48685,14 @@ function isCacheWarmStopReason(value) {
|
|
|
48327
48685
|
}
|
|
48328
48686
|
|
|
48329
48687
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
48688
|
+
var PLUGIN_WAIT_REASONS = [
|
|
48689
|
+
"account_limit",
|
|
48690
|
+
"account_free",
|
|
48691
|
+
"rate_limited",
|
|
48692
|
+
"server_busy",
|
|
48693
|
+
"quota_reading",
|
|
48694
|
+
"routing_hold"
|
|
48695
|
+
];
|
|
48330
48696
|
function isObject2(value) {
|
|
48331
48697
|
return typeof value === "object" && value !== null;
|
|
48332
48698
|
}
|
|
@@ -48400,6 +48766,28 @@ function selectionFor(answer, candidates) {
|
|
|
48400
48766
|
}
|
|
48401
48767
|
return { candidate };
|
|
48402
48768
|
}
|
|
48769
|
+
function refusalFor(value) {
|
|
48770
|
+
if (!isObject2(value))
|
|
48771
|
+
return void 0;
|
|
48772
|
+
const code2 = value.code;
|
|
48773
|
+
if (code2 !== "account_limit_exhausted" && code2 !== "account_selection_refused" && code2 !== "account_selection_final") {
|
|
48774
|
+
return void 0;
|
|
48775
|
+
}
|
|
48776
|
+
const refused2 = { code: code2 };
|
|
48777
|
+
const routingCode = value.routing_code;
|
|
48778
|
+
if (typeof routingCode === "string" && /^[a-z0-9._-]{1,64}$/.test(routingCode)) {
|
|
48779
|
+
refused2.routingCode = routingCode;
|
|
48780
|
+
}
|
|
48781
|
+
const retryAfterSecs = value.retry_after_secs;
|
|
48782
|
+
if (typeof retryAfterSecs === "number" && Number.isFinite(retryAfterSecs) && retryAfterSecs >= 0) {
|
|
48783
|
+
refused2.retryAfterSecs = retryAfterSecs;
|
|
48784
|
+
}
|
|
48785
|
+
const resetsAtMs = value.resets_at_ms;
|
|
48786
|
+
if (typeof resetsAtMs === "number" && Number.isSafeInteger(resetsAtMs) && resetsAtMs > 0) {
|
|
48787
|
+
refused2.resetsAtMs = resetsAtMs;
|
|
48788
|
+
}
|
|
48789
|
+
return { refused: refused2 };
|
|
48790
|
+
}
|
|
48403
48791
|
async function askRouting(input2) {
|
|
48404
48792
|
let timer;
|
|
48405
48793
|
try {
|
|
@@ -48409,10 +48797,10 @@ async function askRouting(input2) {
|
|
|
48409
48797
|
const accountFor = handle.accountFor;
|
|
48410
48798
|
if (typeof accountFor !== "function")
|
|
48411
48799
|
return void 0;
|
|
48412
|
-
const requested = input2.deadlineMs ??
|
|
48413
|
-
const deadlineMs = Number.isNaN(requested) ?
|
|
48414
|
-
const expired = new Promise((
|
|
48415
|
-
timer = setTimeout(() =>
|
|
48800
|
+
const requested = input2.deadlineMs ?? 1500;
|
|
48801
|
+
const deadlineMs = Number.isNaN(requested) ? 1500 : Math.min(2e3, Math.max(1, requested));
|
|
48802
|
+
const expired = new Promise((resolve32) => {
|
|
48803
|
+
timer = setTimeout(() => resolve32(void 0), deadlineMs);
|
|
48416
48804
|
timer.unref();
|
|
48417
48805
|
});
|
|
48418
48806
|
const request2 = {
|
|
@@ -48423,10 +48811,19 @@ async function askRouting(input2) {
|
|
|
48423
48811
|
if (typeof cap === "number" && Number.isFinite(cap)) {
|
|
48424
48812
|
request2.hold_wait_max_s = Math.max(0, Math.floor(cap));
|
|
48425
48813
|
}
|
|
48814
|
+
if (input2.refusals === true)
|
|
48815
|
+
request2.refusals = true;
|
|
48816
|
+
const warmCredentialId = input2.warmCredentialId;
|
|
48817
|
+
if (isNonEmptyString(warmCredentialId) && warmCredentialId.length <= 256 && !/\p{Cc}/u.test(warmCredentialId) && input2.candidates.some((candidate) => candidate.credentialId === warmCredentialId)) {
|
|
48818
|
+
request2.warm_credential = warmCredentialId;
|
|
48819
|
+
}
|
|
48426
48820
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
48427
48821
|
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
48428
48822
|
return void 0;
|
|
48429
48823
|
const answer = await Promise.race([pending, expired]);
|
|
48824
|
+
if (input2.refusals === true && isObject2(answer) && "refused" in answer) {
|
|
48825
|
+
return refusalFor(answer.refused);
|
|
48826
|
+
}
|
|
48430
48827
|
return selectionFor(answer, input2.candidates);
|
|
48431
48828
|
} catch {
|
|
48432
48829
|
return void 0;
|
|
@@ -48436,7 +48833,8 @@ async function askRouting(input2) {
|
|
|
48436
48833
|
}
|
|
48437
48834
|
function reportRouting(input2) {
|
|
48438
48835
|
try {
|
|
48439
|
-
const
|
|
48836
|
+
const sessionId = input2.sessionId;
|
|
48837
|
+
const handle = routingHandle(sessionId);
|
|
48440
48838
|
if (!handle)
|
|
48441
48839
|
return;
|
|
48442
48840
|
const report = handle.report;
|
|
@@ -48445,6 +48843,22 @@ function reportRouting(input2) {
|
|
|
48445
48843
|
let payload;
|
|
48446
48844
|
if ("kind" in input2) {
|
|
48447
48845
|
switch (input2.kind) {
|
|
48846
|
+
case "wait": {
|
|
48847
|
+
const { phase, waitId, reason, nextMs, attempt, message, outcome } = input2;
|
|
48848
|
+
if (!isNonEmptyString(sessionId) || phase !== "start" && phase !== "end" || !isNonEmptyString(waitId) || waitId.length > 64 || /[^A-Za-z0-9._:-]/.test(waitId) || !PLUGIN_WAIT_REASONS.includes(reason))
|
|
48849
|
+
return;
|
|
48850
|
+
payload = {
|
|
48851
|
+
kind: "wait",
|
|
48852
|
+
phase,
|
|
48853
|
+
wait_id: waitId,
|
|
48854
|
+
reason,
|
|
48855
|
+
...typeof nextMs === "number" && Number.isSafeInteger(nextMs) && nextMs > 0 ? { next_ms: nextMs } : {},
|
|
48856
|
+
...typeof attempt === "number" && Number.isInteger(attempt) && attempt >= 1 ? { attempt } : {},
|
|
48857
|
+
...typeof message === "string" && message.length >= 1 && message.length <= 160 && !/\p{Cc}/u.test(message) ? { message } : {},
|
|
48858
|
+
...phase === "end" && (outcome === "resumed" || outcome === "cancelled" || outcome === "abandoned") ? { outcome } : {}
|
|
48859
|
+
};
|
|
48860
|
+
break;
|
|
48861
|
+
}
|
|
48448
48862
|
case "billing": {
|
|
48449
48863
|
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
48450
48864
|
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")
|
|
@@ -48535,6 +48949,17 @@ function reportRouting(input2) {
|
|
|
48535
48949
|
};
|
|
48536
48950
|
break;
|
|
48537
48951
|
}
|
|
48952
|
+
case "credential_refused": {
|
|
48953
|
+
const { credentialId, providerCode } = input2;
|
|
48954
|
+
if (!isNonEmptyString(credentialId) || typeof providerCode !== "string" || !/^[a-z0-9._-]{1,64}$/.test(providerCode))
|
|
48955
|
+
return;
|
|
48956
|
+
payload = {
|
|
48957
|
+
...identity4,
|
|
48958
|
+
outcome: "credential_refused",
|
|
48959
|
+
provider_code: providerCode
|
|
48960
|
+
};
|
|
48961
|
+
break;
|
|
48962
|
+
}
|
|
48538
48963
|
default:
|
|
48539
48964
|
return;
|
|
48540
48965
|
}
|
|
@@ -48872,8 +49297,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
48872
49297
|
let running = false;
|
|
48873
49298
|
let resolveCompletion = () => {
|
|
48874
49299
|
};
|
|
48875
|
-
const completion = new Promise((
|
|
48876
|
-
resolveCompletion =
|
|
49300
|
+
const completion = new Promise((resolve32) => {
|
|
49301
|
+
resolveCompletion = resolve32;
|
|
48877
49302
|
});
|
|
48878
49303
|
const finish = () => {
|
|
48879
49304
|
if (finished) return;
|
|
@@ -48920,14 +49345,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
48920
49345
|
};
|
|
48921
49346
|
}
|
|
48922
49347
|
function publishResponse(dispatch) {
|
|
48923
|
-
return new Promise((
|
|
49348
|
+
return new Promise((resolve32, reject) => {
|
|
48924
49349
|
let acknowledge;
|
|
48925
49350
|
void Promise.resolve().then(
|
|
48926
49351
|
() => dispatch((callback) => {
|
|
48927
49352
|
acknowledge = callback;
|
|
48928
49353
|
})
|
|
48929
49354
|
).then((response) => {
|
|
48930
|
-
|
|
49355
|
+
resolve32(response);
|
|
48931
49356
|
acknowledge?.();
|
|
48932
49357
|
}, reject);
|
|
48933
49358
|
});
|
|
@@ -49164,9 +49589,13 @@ function observeVaultUpstream(response, signal) {
|
|
|
49164
49589
|
return void 0;
|
|
49165
49590
|
let completed = false;
|
|
49166
49591
|
return {
|
|
49167
|
-
response: observeBody(
|
|
49168
|
-
|
|
49169
|
-
|
|
49592
|
+
response: observeBody(
|
|
49593
|
+
response,
|
|
49594
|
+
() => {
|
|
49595
|
+
completed = !signal?.aborted;
|
|
49596
|
+
},
|
|
49597
|
+
isTerminalSseLine
|
|
49598
|
+
),
|
|
49170
49599
|
completedSuccessfully: () => completed
|
|
49171
49600
|
};
|
|
49172
49601
|
}
|
|
@@ -49185,29 +49614,36 @@ function observeVaultServed(identity4, response, signal, upstream) {
|
|
|
49185
49614
|
};
|
|
49186
49615
|
return observeBody(response, report);
|
|
49187
49616
|
}
|
|
49188
|
-
function observeBody(response, complete) {
|
|
49617
|
+
function observeBody(response, complete, terminal) {
|
|
49189
49618
|
if (!response.body) {
|
|
49190
49619
|
complete();
|
|
49191
49620
|
return response;
|
|
49192
49621
|
}
|
|
49193
49622
|
const sse = response.headers.get("content-type")?.includes("text/event-stream");
|
|
49623
|
+
const awaitsTerminal = sse && terminal !== void 0;
|
|
49194
49624
|
const reader = response.body.getReader();
|
|
49195
49625
|
const decoder = new TextDecoder();
|
|
49196
49626
|
let pending = "";
|
|
49197
49627
|
let failed = false;
|
|
49628
|
+
let terminated = false;
|
|
49198
49629
|
const inspect = (line) => {
|
|
49630
|
+
if (terminated) return;
|
|
49199
49631
|
if (line.length > 1024 * 1024) {
|
|
49200
49632
|
failed = true;
|
|
49201
49633
|
return;
|
|
49202
49634
|
}
|
|
49203
49635
|
if (line.startsWith("event:") && line.slice(6).trim() === "error")
|
|
49204
49636
|
failed = true;
|
|
49205
|
-
if (
|
|
49206
|
-
|
|
49207
|
-
|
|
49208
|
-
|
|
49209
|
-
|
|
49210
|
-
|
|
49637
|
+
if (line.startsWith("data:") && /"(?:error|response.failed|failed)"/.test(line)) {
|
|
49638
|
+
try {
|
|
49639
|
+
failed ||= streamFailure(JSON.parse(line.slice(5)));
|
|
49640
|
+
} catch {
|
|
49641
|
+
failed = true;
|
|
49642
|
+
}
|
|
49643
|
+
}
|
|
49644
|
+
if (awaitsTerminal && !failed && terminal?.(line)) {
|
|
49645
|
+
terminated = true;
|
|
49646
|
+
complete();
|
|
49211
49647
|
}
|
|
49212
49648
|
};
|
|
49213
49649
|
const body = new ReadableStream(
|
|
@@ -49224,12 +49660,12 @@ function observeBody(response, complete) {
|
|
|
49224
49660
|
failed = true;
|
|
49225
49661
|
}
|
|
49226
49662
|
}
|
|
49227
|
-
if (!failed) complete();
|
|
49663
|
+
if (!failed && !awaitsTerminal) complete();
|
|
49228
49664
|
controller.close();
|
|
49229
49665
|
reader.releaseLock();
|
|
49230
49666
|
return;
|
|
49231
49667
|
}
|
|
49232
|
-
if (!failed) {
|
|
49668
|
+
if (!failed && !terminated) {
|
|
49233
49669
|
pending += decoder.decode(chunk.value, { stream: true });
|
|
49234
49670
|
if (sse) {
|
|
49235
49671
|
let newline = pending.indexOf("\n");
|
|
@@ -49290,6 +49726,16 @@ function isPrimaryVaultRequest(kind, headers) {
|
|
|
49290
49726
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
49291
49727
|
var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
|
|
49292
49728
|
var ROUTING_ASK_DEADLINE_MS = 2e3;
|
|
49729
|
+
function routingRefusalRetryAfterSeconds(refused2, now) {
|
|
49730
|
+
const { retryAfterSecs, resetsAtMs } = refused2;
|
|
49731
|
+
if (typeof retryAfterSecs === "number" && Number.isFinite(retryAfterSecs) && retryAfterSecs > 0) {
|
|
49732
|
+
return BigInt(Math.ceil(retryAfterSecs));
|
|
49733
|
+
}
|
|
49734
|
+
if (typeof resetsAtMs === "number" && Number.isFinite(resetsAtMs) && resetsAtMs > now) {
|
|
49735
|
+
return (BigInt(Math.ceil(resetsAtMs - now)) + 999n) / 1000n;
|
|
49736
|
+
}
|
|
49737
|
+
return void 0;
|
|
49738
|
+
}
|
|
49293
49739
|
function prepareAgyWireRequest(wire, request2) {
|
|
49294
49740
|
return wire.prepare(
|
|
49295
49741
|
request2.input,
|
|
@@ -49367,7 +49813,7 @@ function formatWaitTime(ms) {
|
|
|
49367
49813
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
49368
49814
|
}
|
|
49369
49815
|
function sleep4(ms, signal) {
|
|
49370
|
-
return new Promise((
|
|
49816
|
+
return new Promise((resolve32, reject) => {
|
|
49371
49817
|
if (signal?.aborted) {
|
|
49372
49818
|
reject(
|
|
49373
49819
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -49377,7 +49823,7 @@ function sleep4(ms, signal) {
|
|
|
49377
49823
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
49378
49824
|
const timeout = setTimeout(() => {
|
|
49379
49825
|
cleanup2();
|
|
49380
|
-
|
|
49826
|
+
resolve32();
|
|
49381
49827
|
}, timerMs);
|
|
49382
49828
|
const onAbort = () => {
|
|
49383
49829
|
cleanup2();
|
|
@@ -49392,6 +49838,44 @@ function sleep4(ms, signal) {
|
|
|
49392
49838
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
49393
49839
|
});
|
|
49394
49840
|
}
|
|
49841
|
+
var WAIT_MESSAGES = {
|
|
49842
|
+
account_free: "Waiting for an available account...",
|
|
49843
|
+
account_limit: "Waiting for the same account (prompt cache preserved)...",
|
|
49844
|
+
rate_limited: "Rate limited. Retrying...",
|
|
49845
|
+
server_busy: "Server busy. Retrying..."
|
|
49846
|
+
};
|
|
49847
|
+
async function withRoutingWaitReports(cancellation, run) {
|
|
49848
|
+
const pending = [];
|
|
49849
|
+
let closed2 = false;
|
|
49850
|
+
const finish = (outcome) => {
|
|
49851
|
+
for (const wait2 of pending.splice(0)) {
|
|
49852
|
+
reportRouting({ kind: "wait", phase: "end", ...wait2, outcome });
|
|
49853
|
+
}
|
|
49854
|
+
};
|
|
49855
|
+
try {
|
|
49856
|
+
return await run({
|
|
49857
|
+
sleep(ms, signal, sessionId, reason, attempt) {
|
|
49858
|
+
if (!closed2 && ms >= 2e3 && sessionId && hasVaultRoutingAccessor()) {
|
|
49859
|
+
const wait2 = {
|
|
49860
|
+
sessionId,
|
|
49861
|
+
waitId: randomUUID20(),
|
|
49862
|
+
reason,
|
|
49863
|
+
nextMs: Date.now() + ms,
|
|
49864
|
+
...attempt === void 0 ? {} : { attempt },
|
|
49865
|
+
message: WAIT_MESSAGES[reason]
|
|
49866
|
+
};
|
|
49867
|
+
pending.push(wait2);
|
|
49868
|
+
reportRouting({ kind: "wait", phase: "start", ...wait2 });
|
|
49869
|
+
}
|
|
49870
|
+
return sleep4(ms, signal);
|
|
49871
|
+
},
|
|
49872
|
+
resumed: () => finish("resumed")
|
|
49873
|
+
});
|
|
49874
|
+
} finally {
|
|
49875
|
+
closed2 = true;
|
|
49876
|
+
finish(cancellation.aborted ? "cancelled" : "abandoned");
|
|
49877
|
+
}
|
|
49878
|
+
}
|
|
49395
49879
|
function createLocalQuotaRefresh(accountManager, quotaManager, log18) {
|
|
49396
49880
|
return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
|
|
49397
49881
|
if (intervalMinutes <= 0) return;
|
|
@@ -49560,7 +50044,7 @@ function createRequestExecutor(deps) {
|
|
|
49560
50044
|
log18.debug("routing-report-failed", { sessionId, error: String(error) });
|
|
49561
50045
|
}
|
|
49562
50046
|
};
|
|
49563
|
-
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
|
|
50047
|
+
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy, waits) {
|
|
49564
50048
|
const assertAdmission = async () => {
|
|
49565
50049
|
await deadline.wait(() => deps.assertAdmission?.(deadline.signal));
|
|
49566
50050
|
};
|
|
@@ -49628,9 +50112,13 @@ function createRequestExecutor(deps) {
|
|
|
49628
50112
|
};
|
|
49629
50113
|
}
|
|
49630
50114
|
const sender = options.transport ?? defaultTransport2;
|
|
49631
|
-
const transport = (url, sendInit, sendOptions) => deadline.open(
|
|
49632
|
-
()
|
|
49633
|
-
|
|
50115
|
+
const transport = (url, sendInit, sendOptions) => deadline.open(() => {
|
|
50116
|
+
waits.resumed();
|
|
50117
|
+
return sender(url, sendInit, {
|
|
50118
|
+
...sendOptions,
|
|
50119
|
+
signal: deadline.signal
|
|
50120
|
+
});
|
|
50121
|
+
});
|
|
49634
50122
|
const requestSessionIdentity = options.session ?? extractOpenCodeSessionIdentity(init?.headers);
|
|
49635
50123
|
const agyRequestScope = agySessionRegistry.beginRequest(
|
|
49636
50124
|
agyMetadataIdentity(requestSessionIdentity, kind)
|
|
@@ -49680,6 +50168,13 @@ function createRequestExecutor(deps) {
|
|
|
49680
50168
|
let lastFailure = null;
|
|
49681
50169
|
let lastError = null;
|
|
49682
50170
|
const abortSignal = init?.signal ?? void 0;
|
|
50171
|
+
const routingSleep = (ms, reason, attempt) => waits.sleep(
|
|
50172
|
+
ms,
|
|
50173
|
+
abortSignal,
|
|
50174
|
+
credentials.domain === "vault" ? requestSessionIdentity.sessionId ?? void 0 : void 0,
|
|
50175
|
+
reason,
|
|
50176
|
+
attempt
|
|
50177
|
+
);
|
|
49683
50178
|
const checkAborted = () => {
|
|
49684
50179
|
deadline.check();
|
|
49685
50180
|
if (abortSignal?.aborted) {
|
|
@@ -49885,10 +50380,27 @@ function createRequestExecutor(deps) {
|
|
|
49885
50380
|
deadlineMs: Math.min(
|
|
49886
50381
|
ROUTING_ASK_DEADLINE_MS,
|
|
49887
50382
|
deadline.remainingMs()
|
|
49888
|
-
)
|
|
50383
|
+
),
|
|
50384
|
+
refusals: true
|
|
49889
50385
|
})
|
|
49890
50386
|
);
|
|
49891
50387
|
checkAborted();
|
|
50388
|
+
if (answer && "refused" in answer) {
|
|
50389
|
+
const { code: code2, routingCode } = answer.refused;
|
|
50390
|
+
log18.warn("routing-refused", {
|
|
50391
|
+
code: code2,
|
|
50392
|
+
...routingCode === void 0 ? {} : { routingCode }
|
|
50393
|
+
});
|
|
50394
|
+
const retryAfterSeconds = routingRefusalRetryAfterSeconds(
|
|
50395
|
+
answer.refused,
|
|
50396
|
+
Date.now()
|
|
50397
|
+
);
|
|
50398
|
+
return createNativeGoogleErrorResponse({
|
|
50399
|
+
status: 412,
|
|
50400
|
+
reason: "routing_refused",
|
|
50401
|
+
...retryAfterSeconds === void 0 ? {} : { retryAfterSeconds }
|
|
50402
|
+
});
|
|
50403
|
+
}
|
|
49892
50404
|
if (answer && answer.candidate.index !== account.index && !excludedIndexes?.has(answer.candidate.index)) {
|
|
49893
50405
|
account = accountManager.getCurrentOrNextForFamily(
|
|
49894
50406
|
family,
|
|
@@ -50004,7 +50516,10 @@ function createRequestExecutor(deps) {
|
|
|
50004
50516
|
);
|
|
50005
50517
|
retryState.markSoftQuotaToastShown();
|
|
50006
50518
|
}
|
|
50007
|
-
await
|
|
50519
|
+
await routingSleep(
|
|
50520
|
+
Math.min(waitMs, remainingWaitMs()),
|
|
50521
|
+
"account_free"
|
|
50522
|
+
);
|
|
50008
50523
|
continue;
|
|
50009
50524
|
}
|
|
50010
50525
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
@@ -50047,7 +50562,7 @@ function createRequestExecutor(deps) {
|
|
|
50047
50562
|
);
|
|
50048
50563
|
retryState.markRateLimitToastShown();
|
|
50049
50564
|
}
|
|
50050
|
-
await
|
|
50565
|
+
await routingSleep(Math.min(waitMs, remainingWaitMs()), "account_free");
|
|
50051
50566
|
continue;
|
|
50052
50567
|
}
|
|
50053
50568
|
allAccountsBlockedAt = void 0;
|
|
@@ -50721,7 +51236,11 @@ function createRequestExecutor(deps) {
|
|
|
50721
51236
|
`\u23F3 Server busy (${response.status}). Retrying in ${waitSec}s...`,
|
|
50722
51237
|
"warning"
|
|
50723
51238
|
);
|
|
50724
|
-
await
|
|
51239
|
+
await routingSleep(
|
|
51240
|
+
waitMs,
|
|
51241
|
+
"server_busy",
|
|
51242
|
+
capacityRetryCount + 1
|
|
51243
|
+
);
|
|
50725
51244
|
if (capacityRetryCount < 1) {
|
|
50726
51245
|
capacityRetryCount++;
|
|
50727
51246
|
i -= 1;
|
|
@@ -50791,7 +51310,7 @@ function createRequestExecutor(deps) {
|
|
|
50791
51310
|
rateLimitReason,
|
|
50792
51311
|
serverRetryMs
|
|
50793
51312
|
);
|
|
50794
|
-
await
|
|
51313
|
+
await routingSleep(effectiveDelayMs, "account_limit");
|
|
50795
51314
|
i -= 1;
|
|
50796
51315
|
continue;
|
|
50797
51316
|
}
|
|
@@ -50841,7 +51360,11 @@ function createRequestExecutor(deps) {
|
|
|
50841
51360
|
`Rate limited. Retrying in ${expBackoffFormatted} (attempt ${backoff.attempt})...`,
|
|
50842
51361
|
"warning"
|
|
50843
51362
|
);
|
|
50844
|
-
await
|
|
51363
|
+
await routingSleep(
|
|
51364
|
+
expBackoffMs,
|
|
51365
|
+
"rate_limited",
|
|
51366
|
+
backoff.attempt
|
|
51367
|
+
);
|
|
50845
51368
|
}
|
|
50846
51369
|
lastFailure = createFailureContext(response);
|
|
50847
51370
|
shouldSwitchAccount = true;
|
|
@@ -51334,15 +51857,19 @@ function createRequestExecutor(deps) {
|
|
|
51334
51857
|
const waitPolicy = {};
|
|
51335
51858
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
51336
51859
|
const selectedProjectIds = /* @__PURE__ */ new Set();
|
|
51337
|
-
const pending =
|
|
51338
|
-
|
|
51339
|
-
|
|
51340
|
-
|
|
51341
|
-
|
|
51342
|
-
|
|
51343
|
-
|
|
51344
|
-
|
|
51345
|
-
|
|
51860
|
+
const pending = withRoutingWaitReports(
|
|
51861
|
+
cancellation.signal,
|
|
51862
|
+
(waits) => deadline.wait(
|
|
51863
|
+
() => execute(
|
|
51864
|
+
input2,
|
|
51865
|
+
{ ...init, signal: deadline.signal },
|
|
51866
|
+
requestOptions ?? {},
|
|
51867
|
+
selectedCredentials,
|
|
51868
|
+
selectedProjectIds,
|
|
51869
|
+
deadline,
|
|
51870
|
+
waitPolicy,
|
|
51871
|
+
waits
|
|
51872
|
+
)
|
|
51346
51873
|
)
|
|
51347
51874
|
).catch((error) => {
|
|
51348
51875
|
cancellation.signal.throwIfAborted();
|
|
@@ -53502,7 +54029,7 @@ function createGaReauthorize(input2) {
|
|
|
53502
54029
|
const continuations = /* @__PURE__ */ new Set();
|
|
53503
54030
|
const shutdown = new AbortController();
|
|
53504
54031
|
let disposed = false;
|
|
53505
|
-
const waitForRedirect = (code2) => new Promise((
|
|
54032
|
+
const waitForRedirect = (code2) => new Promise((resolve32, reject) => {
|
|
53506
54033
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
53507
54034
|
const abort = () => {
|
|
53508
54035
|
detach();
|
|
@@ -53513,7 +54040,7 @@ function createGaReauthorize(input2) {
|
|
|
53513
54040
|
void code2.then(
|
|
53514
54041
|
(value) => {
|
|
53515
54042
|
detach();
|
|
53516
|
-
|
|
54043
|
+
resolve32(value);
|
|
53517
54044
|
},
|
|
53518
54045
|
(error) => {
|
|
53519
54046
|
detach();
|
|
@@ -53891,7 +54418,7 @@ function gaEngineCollaborators(input2) {
|
|
|
53891
54418
|
const observe = input2.overrides.observeRawSenderSignal;
|
|
53892
54419
|
return {
|
|
53893
54420
|
config: runtime.config.config,
|
|
53894
|
-
sessions: new AgySessionRegistry(
|
|
54421
|
+
sessions: new AgySessionRegistry(),
|
|
53895
54422
|
operatorSettings: runtime.operatorSettings,
|
|
53896
54423
|
modelAccess: () => runtime.settings.modelAccess(),
|
|
53897
54424
|
transport: (url, init, options) => {
|
|
@@ -56702,11 +57229,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
56702
57229
|
}
|
|
56703
57230
|
}
|
|
56704
57231
|
};
|
|
56705
|
-
await new Promise((
|
|
57232
|
+
await new Promise((resolve32, reject) => {
|
|
56706
57233
|
server.once("error", reject);
|
|
56707
57234
|
server.listen(0, BRIDGE_HOST, () => {
|
|
56708
57235
|
server.off("error", reject);
|
|
56709
|
-
|
|
57236
|
+
resolve32();
|
|
56710
57237
|
});
|
|
56711
57238
|
});
|
|
56712
57239
|
server.unref();
|
|
@@ -56717,7 +57244,7 @@ async function startGaLoopbackBridge(options) {
|
|
|
56717
57244
|
origin,
|
|
56718
57245
|
rewrite(original, job, env3) {
|
|
56719
57246
|
if (closing) throw new Error("The Antigravity bridge is disposed");
|
|
56720
|
-
const id =
|
|
57247
|
+
const id = randomUUID21();
|
|
56721
57248
|
const target = `${origin}/agy/${id}`;
|
|
56722
57249
|
assertLoopbackProxyGuard({ env: env3, target });
|
|
56723
57250
|
const timer = setTimeout(() => {
|
|
@@ -56810,8 +57337,8 @@ async function startGaLoopbackBridge(options) {
|
|
|
56810
57337
|
disposal = (async () => {
|
|
56811
57338
|
for (const { timer } of queued.values()) clearTimeout(timer);
|
|
56812
57339
|
queued.clear();
|
|
56813
|
-
const closed2 = new Promise((
|
|
56814
|
-
server.close(() =>
|
|
57340
|
+
const closed2 = new Promise((resolve32) => {
|
|
57341
|
+
server.close(() => resolve32());
|
|
56815
57342
|
});
|
|
56816
57343
|
for (const controller of running) {
|
|
56817
57344
|
controller.abort(
|
|
@@ -56877,9 +57404,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
56877
57404
|
return;
|
|
56878
57405
|
}
|
|
56879
57406
|
if (!response.write(value) && !response.destroyed) {
|
|
56880
|
-
await new Promise((
|
|
56881
|
-
response.once("drain",
|
|
56882
|
-
response.once("close",
|
|
57407
|
+
await new Promise((resolve32) => {
|
|
57408
|
+
response.once("drain", resolve32);
|
|
57409
|
+
response.once("close", resolve32);
|
|
56883
57410
|
});
|
|
56884
57411
|
}
|
|
56885
57412
|
if (response.destroyed) {
|
|
@@ -56947,7 +57474,7 @@ function isObject3(value) {
|
|
|
56947
57474
|
return typeof value === "object" && value !== null;
|
|
56948
57475
|
}
|
|
56949
57476
|
function createGaGeneration() {
|
|
56950
|
-
return `g-${
|
|
57477
|
+
return `g-${randomUUID21()}`;
|
|
56951
57478
|
}
|
|
56952
57479
|
var GaRpcInputError = class extends Error {
|
|
56953
57480
|
constructor(issues) {
|
|
@@ -57556,14 +58083,14 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
57556
58083
|
|
|
57557
58084
|
// src/plugin/index.ts
|
|
57558
58085
|
init_dist();
|
|
57559
|
-
import { createHash as createHash24, randomUUID as
|
|
57560
|
-
import { join as join47, resolve as
|
|
58086
|
+
import { createHash as createHash24, randomUUID as randomUUID26 } from "node:crypto";
|
|
58087
|
+
import { join as join47, resolve as resolve31 } from "node:path";
|
|
57561
58088
|
|
|
57562
58089
|
// src/cli.ts
|
|
57563
58090
|
init_dist();
|
|
57564
58091
|
import { execFile } from "node:child_process";
|
|
57565
58092
|
import { realpathSync as realpathSync6 } from "node:fs";
|
|
57566
|
-
import { resolve as
|
|
58093
|
+
import { resolve as resolve28 } from "node:path";
|
|
57567
58094
|
import { createInterface } from "node:readline/promises";
|
|
57568
58095
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
57569
58096
|
import { promisify } from "node:util";
|
|
@@ -57620,7 +58147,7 @@ init_runtime_paths();
|
|
|
57620
58147
|
// src/setup.ts
|
|
57621
58148
|
init_dist();
|
|
57622
58149
|
import { lstat as lstat10, readFile as readFile22 } from "node:fs/promises";
|
|
57623
|
-
import { join as join38, resolve as
|
|
58150
|
+
import { join as join38, resolve as resolve27 } from "node:path";
|
|
57624
58151
|
|
|
57625
58152
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
57626
58153
|
var ANSI2 = {
|
|
@@ -57788,7 +58315,7 @@ async function select2(terminal, items, options) {
|
|
|
57788
58315
|
writeLine("");
|
|
57789
58316
|
renderedLines = lines;
|
|
57790
58317
|
};
|
|
57791
|
-
return new Promise((
|
|
58318
|
+
return new Promise((resolve32) => {
|
|
57792
58319
|
const wasRaw = stdin.isRaw ?? false;
|
|
57793
58320
|
const cleanup2 = () => {
|
|
57794
58321
|
if (cleaned)
|
|
@@ -57808,7 +58335,7 @@ async function select2(terminal, items, options) {
|
|
|
57808
58335
|
};
|
|
57809
58336
|
const finish = (value) => {
|
|
57810
58337
|
cleanup2();
|
|
57811
|
-
|
|
58338
|
+
resolve32(value);
|
|
57812
58339
|
};
|
|
57813
58340
|
const onSignal = () => finish(null);
|
|
57814
58341
|
const onKey = (data) => {
|
|
@@ -57848,7 +58375,7 @@ async function select2(terminal, items, options) {
|
|
|
57848
58375
|
stdin.setRawMode(true);
|
|
57849
58376
|
} catch {
|
|
57850
58377
|
cleanup2();
|
|
57851
|
-
|
|
58378
|
+
resolve32(null);
|
|
57852
58379
|
return;
|
|
57853
58380
|
}
|
|
57854
58381
|
stdin.resume();
|
|
@@ -57859,15 +58386,15 @@ async function select2(terminal, items, options) {
|
|
|
57859
58386
|
}
|
|
57860
58387
|
|
|
57861
58388
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
57862
|
-
import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as
|
|
58389
|
+
import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as randomUUID23 } from "node:crypto";
|
|
57863
58390
|
import { constants as fsConstants2 } from "node:fs";
|
|
57864
58391
|
import { chmod as chmod6, mkdir as mkdir18, open as open11, readFile as readFile20, realpath as realpath6, rename as rename13, stat as stat17, unlink as unlink14 } from "node:fs/promises";
|
|
57865
|
-
import { basename as basename13, dirname as dirname28, extname as extname2, isAbsolute as isAbsolute4, join as join34, resolve as
|
|
58392
|
+
import { basename as basename13, dirname as dirname28, extname as extname2, isAbsolute as isAbsolute4, join as join34, resolve as resolve26 } from "node:path";
|
|
57866
58393
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
57867
58394
|
|
|
57868
58395
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
57869
58396
|
import { lstat as lstat8, stat as stat15 } from "node:fs/promises";
|
|
57870
|
-
import { resolve as
|
|
58397
|
+
import { resolve as resolve24 } from "node:path";
|
|
57871
58398
|
async function identity3(path5, probe) {
|
|
57872
58399
|
try {
|
|
57873
58400
|
const metadata = await probe(path5);
|
|
@@ -57888,7 +58415,7 @@ var FileReadCache2 = class {
|
|
|
57888
58415
|
this.#probe = options.followSymlinks ? (path5) => (options.stat ?? stat15)(path5) : (path5) => (options.lstat ?? lstat8)(path5);
|
|
57889
58416
|
}
|
|
57890
58417
|
async read(paths, read, validateHit) {
|
|
57891
|
-
const resolvedPaths = paths.map((path5) =>
|
|
58418
|
+
const resolvedPaths = paths.map((path5) => resolve24(path5));
|
|
57892
58419
|
const key = JSON.stringify(resolvedPaths);
|
|
57893
58420
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity3(path5, this.#probe)));
|
|
57894
58421
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -57937,13 +58464,14 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
57937
58464
|
init_private_files2();
|
|
57938
58465
|
|
|
57939
58466
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
57940
|
-
|
|
58467
|
+
init_logger3();
|
|
58468
|
+
import { randomUUID as randomUUID22 } from "node:crypto";
|
|
57941
58469
|
import { link as link4, lstat as lstat9, mkdir as mkdir17, open as open10, readdir as readdir6, readFile as readFile19, rename as rename12, rm as rm7, stat as stat16, unlink as unlink13 } from "node:fs/promises";
|
|
57942
58470
|
import { basename as basename12, dirname as dirname27, join as join33 } from "node:path";
|
|
57943
58471
|
|
|
57944
58472
|
// src/common-auth-embedded/fs/lock-record.js
|
|
57945
58473
|
init_private_files2();
|
|
57946
|
-
import { resolve as
|
|
58474
|
+
import { resolve as resolve25 } from "node:path";
|
|
57947
58475
|
var DisappearedLockRecordError2 = class extends Error {
|
|
57948
58476
|
path;
|
|
57949
58477
|
code = "ENOENT";
|
|
@@ -57953,10 +58481,10 @@ var DisappearedLockRecordError2 = class extends Error {
|
|
|
57953
58481
|
}
|
|
57954
58482
|
};
|
|
57955
58483
|
function isWindowsAccessDeniedRead2(error, paths) {
|
|
57956
|
-
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) =>
|
|
58484
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve25(path5) === error.path);
|
|
57957
58485
|
}
|
|
57958
58486
|
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
57959
|
-
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) =>
|
|
58487
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve25(path5) === error.path);
|
|
57960
58488
|
}
|
|
57961
58489
|
async function readLockRecord2(path5, read) {
|
|
57962
58490
|
try {
|
|
@@ -57994,7 +58522,7 @@ var LockOwnershipError2 = class extends Error {
|
|
|
57994
58522
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
57995
58523
|
var leaseCreationTestHooks2;
|
|
57996
58524
|
async function createExclusiveText2(path5, text2) {
|
|
57997
|
-
const tempPath = `${path5}.${
|
|
58525
|
+
const tempPath = `${path5}.${randomUUID22()}.tmp`;
|
|
57998
58526
|
let handle;
|
|
57999
58527
|
try {
|
|
58000
58528
|
handle = await open10(tempPath, "wx", 384);
|
|
@@ -58152,15 +58680,15 @@ function acquireRefreshFileLock2(options) {
|
|
|
58152
58680
|
async function acquireRefreshFileLockWithClock2(options) {
|
|
58153
58681
|
const lockPath = lockPathFor2(options.path, options.name);
|
|
58154
58682
|
const legacyOwnerPath = join33(lockPath, "owner.json");
|
|
58155
|
-
const ownerId =
|
|
58683
|
+
const ownerId = randomUUID22();
|
|
58156
58684
|
const now = options.now ?? Date.now;
|
|
58157
58685
|
let renewTimer = null;
|
|
58158
58686
|
let released = false;
|
|
58159
58687
|
let releaseConfirmed = false;
|
|
58160
58688
|
let loss;
|
|
58161
58689
|
let resolveLoss;
|
|
58162
|
-
const lostPromise = new Promise((
|
|
58163
|
-
resolveLoss =
|
|
58690
|
+
const lostPromise = new Promise((resolve32) => {
|
|
58691
|
+
resolveLoss = resolve32;
|
|
58164
58692
|
});
|
|
58165
58693
|
function notifyTimerStep(event) {
|
|
58166
58694
|
try {
|
|
@@ -58195,7 +58723,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58195
58723
|
let renewalInFlight = null;
|
|
58196
58724
|
const evictPath = `${lockPath}.evicting`;
|
|
58197
58725
|
const evictOwnerPath = join33(evictPath, "owner.json");
|
|
58198
|
-
const evictOwnerId =
|
|
58726
|
+
const evictOwnerId = randomUUID22();
|
|
58199
58727
|
const EVICT_TTL = 5e3;
|
|
58200
58728
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
58201
58729
|
function isChangingLockCreate(error) {
|
|
@@ -58240,7 +58768,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58240
58768
|
});
|
|
58241
58769
|
return;
|
|
58242
58770
|
}
|
|
58243
|
-
const tempPath = `${lockPath}.${
|
|
58771
|
+
const tempPath = `${lockPath}.${randomUUID22()}.tmp`;
|
|
58244
58772
|
let handle;
|
|
58245
58773
|
let created = false;
|
|
58246
58774
|
try {
|
|
@@ -58324,7 +58852,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58324
58852
|
}
|
|
58325
58853
|
}
|
|
58326
58854
|
async function backoff() {
|
|
58327
|
-
await new Promise((
|
|
58855
|
+
await new Promise((resolve32) => setTimeout(resolve32, Math.floor(Math.random() * 4)));
|
|
58328
58856
|
}
|
|
58329
58857
|
async function readLockState(notifyReady = true) {
|
|
58330
58858
|
if (notifyReady && options.onStep)
|
|
@@ -58417,7 +58945,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58417
58945
|
const remainingMs = deadline - performance.now();
|
|
58418
58946
|
if (remainingMs <= 0)
|
|
58419
58947
|
throw original;
|
|
58420
|
-
await new Promise((
|
|
58948
|
+
await new Promise((resolve32) => setTimeout(resolve32, Math.min(delayMs, remainingMs)));
|
|
58421
58949
|
if (performance.now() >= deadline)
|
|
58422
58950
|
throw original;
|
|
58423
58951
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -58545,7 +59073,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58545
59073
|
}
|
|
58546
59074
|
if (options.onStep)
|
|
58547
59075
|
await options.onStep("stale-marker-stat");
|
|
58548
|
-
const claimedPath = `${evictPath}.${
|
|
59076
|
+
const claimedPath = `${evictPath}.${randomUUID22()}`;
|
|
58549
59077
|
try {
|
|
58550
59078
|
await rename12(evictPath, claimedPath);
|
|
58551
59079
|
} catch (error) {
|
|
@@ -58891,17 +59419,15 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58891
59419
|
removalConfirmed = true;
|
|
58892
59420
|
}, deadline);
|
|
58893
59421
|
changingRecordError = void 0;
|
|
58894
|
-
if (markerAcquired) {
|
|
58895
|
-
|
|
58896
|
-
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
58897
|
-
code: "EIO"
|
|
58898
|
-
});
|
|
58899
|
-
releaseConfirmed = removalConfirmed;
|
|
59422
|
+
if (markerAcquired && removalConfirmed) {
|
|
59423
|
+
releaseConfirmed = true;
|
|
58900
59424
|
return;
|
|
58901
59425
|
}
|
|
58902
|
-
if (
|
|
58903
|
-
|
|
58904
|
-
|
|
59426
|
+
if (!markerAcquired) {
|
|
59427
|
+
if (signal?.aborted)
|
|
59428
|
+
return;
|
|
59429
|
+
await recoverStaleEvictionMarker(deadline);
|
|
59430
|
+
}
|
|
58905
59431
|
} catch (error) {
|
|
58906
59432
|
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
58907
59433
|
lockPath,
|
|
@@ -58922,7 +59448,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58922
59448
|
const remainingMs = deadline - performance.now();
|
|
58923
59449
|
if (remainingMs <= 0)
|
|
58924
59450
|
break;
|
|
58925
|
-
await new Promise((
|
|
59451
|
+
await new Promise((resolve32) => setTimeout(resolve32, Math.min(delayMs, remainingMs)));
|
|
58926
59452
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
58927
59453
|
break;
|
|
58928
59454
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -58931,6 +59457,9 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
58931
59457
|
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
58932
59458
|
code: "ETIMEDOUT"
|
|
58933
59459
|
});
|
|
59460
|
+
createLogger3("fs").warn("File lock release deadline expired", {
|
|
59461
|
+
lockPath
|
|
59462
|
+
});
|
|
58934
59463
|
}
|
|
58935
59464
|
};
|
|
58936
59465
|
}
|
|
@@ -59008,7 +59537,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
59008
59537
|
const override = input2.override?.trim();
|
|
59009
59538
|
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
59010
59539
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
59011
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
59540
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve26(input2.cwd, override) : join34(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
59012
59541
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
59013
59542
|
}
|
|
59014
59543
|
function isRecord11(value) {
|
|
@@ -59250,7 +59779,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
59250
59779
|
}
|
|
59251
59780
|
if (windowsPrivateFiles2)
|
|
59252
59781
|
return writePrivateAtomic2(path5, bytes);
|
|
59253
|
-
const temporary = join34(parent, `.${basename13(path5)}.${process.pid}.${
|
|
59782
|
+
const temporary = join34(parent, `.${basename13(path5)}.${process.pid}.${randomUUID23()}.tmp`);
|
|
59254
59783
|
let descriptor;
|
|
59255
59784
|
let created = false;
|
|
59256
59785
|
try {
|
|
@@ -59702,7 +60231,7 @@ var ByteTail = class {
|
|
|
59702
60231
|
};
|
|
59703
60232
|
var defaultCommandRunner = {
|
|
59704
60233
|
run(file, args, options = {}) {
|
|
59705
|
-
return new Promise((
|
|
60234
|
+
return new Promise((resolve32) => {
|
|
59706
60235
|
const started = performance.now();
|
|
59707
60236
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
59708
60237
|
const stderr = new ByteTail();
|
|
@@ -59720,7 +60249,7 @@ var defaultCommandRunner = {
|
|
|
59720
60249
|
stdio: ["ignore", "pipe", "pipe"]
|
|
59721
60250
|
});
|
|
59722
60251
|
} catch {
|
|
59723
|
-
|
|
60252
|
+
resolve32({
|
|
59724
60253
|
exitCode: 1,
|
|
59725
60254
|
stdout: "",
|
|
59726
60255
|
stderr: "",
|
|
@@ -59755,7 +60284,7 @@ var defaultCommandRunner = {
|
|
|
59755
60284
|
settled = true;
|
|
59756
60285
|
if (timer)
|
|
59757
60286
|
clearTimeout(timer);
|
|
59758
|
-
|
|
60287
|
+
resolve32({
|
|
59759
60288
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
59760
60289
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
59761
60290
|
stderr: stderr.toString(),
|
|
@@ -60686,7 +61215,7 @@ import { domainToUnicode } from "node:url";
|
|
|
60686
61215
|
import { applyEdits as applyEdits2, createScanner as createScanner2, findNodeAtLocation as findNodeAtLocation2, modify as modify2, parse as parse2, parseTree as parseTree2 } from "jsonc-parser";
|
|
60687
61216
|
|
|
60688
61217
|
// src/common-auth-embedded/setup/config-write.js
|
|
60689
|
-
import { randomUUID as
|
|
61218
|
+
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
60690
61219
|
import { mkdir as mkdir19, open as open12, rename as rename14, stat as stat19, unlink as unlink15 } from "node:fs/promises";
|
|
60691
61220
|
import { basename as basename14, dirname as dirname29, join as join36 } from "node:path";
|
|
60692
61221
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
@@ -60703,7 +61232,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
60703
61232
|
throw error;
|
|
60704
61233
|
}
|
|
60705
61234
|
}
|
|
60706
|
-
const stage = join36(parent, `.${basename14(file)}.${(options.stageName ??
|
|
61235
|
+
const stage = join36(parent, `.${basename14(file)}.${(options.stageName ?? randomUUID24)()}.tmp`);
|
|
60707
61236
|
let created = false;
|
|
60708
61237
|
try {
|
|
60709
61238
|
const handle = await open12(stage, "wx", mode ?? 438);
|
|
@@ -61269,7 +61798,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
61269
61798
|
beforeRename: async () => {
|
|
61270
61799
|
await assertSetupHostsStopped();
|
|
61271
61800
|
const claustrum = await loadCommonAuthClaustrum();
|
|
61272
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
61801
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve27(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
61273
61802
|
if (await claustrum.vaultAuthority(
|
|
61274
61803
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
61275
61804
|
`antigravity-auth-${host}`
|
|
@@ -61314,7 +61843,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
61314
61843
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
61315
61844
|
paths: {
|
|
61316
61845
|
get stateDir() {
|
|
61317
|
-
return openCodeVaultDir(
|
|
61846
|
+
return openCodeVaultDir(resolve27(accountFileForVault()));
|
|
61318
61847
|
},
|
|
61319
61848
|
host: "opencode"
|
|
61320
61849
|
}
|
|
@@ -61338,7 +61867,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
61338
61867
|
const assertLocal = async (host, context) => {
|
|
61339
61868
|
if (host === "opencode")
|
|
61340
61869
|
return assertLocalOpenCodeLogin(
|
|
61341
|
-
|
|
61870
|
+
resolve27(accountFileForVault()),
|
|
61342
61871
|
context.opencodeGeneration
|
|
61343
61872
|
);
|
|
61344
61873
|
if (await authority(host) !== "local")
|
|
@@ -61998,7 +62527,7 @@ async function runCliProcess(argv, deps) {
|
|
|
61998
62527
|
...deps,
|
|
61999
62528
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
62000
62529
|
const folder = await prepareVaultFolder({
|
|
62001
|
-
accountFile:
|
|
62530
|
+
accountFile: resolve28(accountFileForVault()),
|
|
62002
62531
|
...options
|
|
62003
62532
|
});
|
|
62004
62533
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -62044,11 +62573,11 @@ function createDefaultCliDependencies() {
|
|
|
62044
62573
|
);
|
|
62045
62574
|
if (host !== "pi")
|
|
62046
62575
|
await assertLocalOpenCodeLogin(
|
|
62047
|
-
|
|
62576
|
+
resolve28(accountFileForVault()),
|
|
62048
62577
|
context?.opencodeGeneration
|
|
62049
62578
|
);
|
|
62050
62579
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
62051
|
-
|
|
62580
|
+
resolve28(getStoragePath()),
|
|
62052
62581
|
context?.opencodeGeneration
|
|
62053
62582
|
);
|
|
62054
62583
|
try {
|
|
@@ -62064,7 +62593,7 @@ function createDefaultCliDependencies() {
|
|
|
62064
62593
|
}
|
|
62065
62594
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
62066
62595
|
await assertLocalOpenCodeLogin(
|
|
62067
|
-
|
|
62596
|
+
resolve28(accountFileForVault()),
|
|
62068
62597
|
context?.opencodeGeneration
|
|
62069
62598
|
);
|
|
62070
62599
|
await persistCliStoreLogin(
|
|
@@ -62084,7 +62613,7 @@ function createDefaultCliDependencies() {
|
|
|
62084
62613
|
};
|
|
62085
62614
|
}
|
|
62086
62615
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
62087
|
-
await assertLocalOpenCodeLogin(
|
|
62616
|
+
await assertLocalOpenCodeLogin(resolve28(accountFileForVault()), generation);
|
|
62088
62617
|
const modules = await loadCommonAuthStoreModules();
|
|
62089
62618
|
const options = {
|
|
62090
62619
|
legacyPath,
|
|
@@ -62229,7 +62758,7 @@ async function readAccountStore(legacyPath) {
|
|
|
62229
62758
|
function createDefaultAccountStoreOperations() {
|
|
62230
62759
|
const offline = { processesStopped: true };
|
|
62231
62760
|
return {
|
|
62232
|
-
legacyPath: () =>
|
|
62761
|
+
legacyPath: () => resolve28(
|
|
62233
62762
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
62234
62763
|
),
|
|
62235
62764
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -62260,7 +62789,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
62260
62789
|
};
|
|
62261
62790
|
}
|
|
62262
62791
|
function samePath(left, right) {
|
|
62263
|
-
return process.platform === "win32" ?
|
|
62792
|
+
return process.platform === "win32" ? resolve28(left).toLowerCase() === resolve28(right).toLowerCase() : resolve28(left) === resolve28(right);
|
|
62264
62793
|
}
|
|
62265
62794
|
function isCliEntry() {
|
|
62266
62795
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -62750,14 +63279,14 @@ function isTuiConnected(sessionId) {
|
|
|
62750
63279
|
// src/rpc/rpc-dir.ts
|
|
62751
63280
|
import { createHash as createHash20 } from "node:crypto";
|
|
62752
63281
|
import { homedir as homedir14, tmpdir as tmpdir6 } from "node:os";
|
|
62753
|
-
import { isAbsolute as isAbsolute5, join as join42, resolve as
|
|
63282
|
+
import { isAbsolute as isAbsolute5, join as join42, resolve as resolve29 } from "node:path";
|
|
62754
63283
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
62755
63284
|
function getRpcDir(projectDirectory) {
|
|
62756
63285
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
62757
63286
|
if (override) {
|
|
62758
|
-
return isAbsolute5(override) ? override :
|
|
63287
|
+
return isAbsolute5(override) ? override : resolve29(projectDirectory, override);
|
|
62759
63288
|
}
|
|
62760
|
-
const projectHash = createHash20("sha256").update(
|
|
63289
|
+
const projectHash = createHash20("sha256").update(resolve29(projectDirectory)).digest("hex").slice(0, 16);
|
|
62761
63290
|
const stateHome = process.env.XDG_STATE_HOME ?? join42(homedir14(), ".local", "state");
|
|
62762
63291
|
return join42(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
62763
63292
|
}
|
|
@@ -62769,10 +63298,10 @@ function isSessionId(value) {
|
|
|
62769
63298
|
|
|
62770
63299
|
// src/common-auth-embedded/rpc/port-file.js
|
|
62771
63300
|
init_private_files2();
|
|
62772
|
-
import { createHash as createHash21, randomUUID as
|
|
63301
|
+
import { createHash as createHash21, randomUUID as randomUUID25 } from "node:crypto";
|
|
62773
63302
|
import { chmod as chmod7, mkdir as mkdir20, open as open13, readdir as readdir7, rename as rename15, rmdir as rmdir3, stat as stat20, unlink as unlink16 } from "node:fs/promises";
|
|
62774
63303
|
import { uptime as uptime2 } from "node:os";
|
|
62775
|
-
import { join as join43, resolve as
|
|
63304
|
+
import { join as join43, resolve as resolve30 } from "node:path";
|
|
62776
63305
|
function staleBefore(clock2) {
|
|
62777
63306
|
return (clock2.now ?? Date.now)() - (clock2.uptime ?? uptime2)() * 1e3 - 3e5;
|
|
62778
63307
|
}
|
|
@@ -62830,7 +63359,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
62830
63359
|
await ensurePrivateDirectory2(dir, options.secureDir ?? false);
|
|
62831
63360
|
await options.beforeWrite?.();
|
|
62832
63361
|
await writePrivateAtomic2(target, JSON.stringify({ ...entry, startedAt: Date.now() }), {
|
|
62833
|
-
stagePath: `${target}.${(options.stageName ??
|
|
63362
|
+
stagePath: `${target}.${(options.stageName ?? randomUUID25)()}.tmp`
|
|
62834
63363
|
});
|
|
62835
63364
|
return target;
|
|
62836
63365
|
}
|
|
@@ -62842,7 +63371,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
62842
63371
|
await chmod7(dir, 448);
|
|
62843
63372
|
await options.beforeWrite?.();
|
|
62844
63373
|
const full = { ...entry, startedAt: Date.now() };
|
|
62845
|
-
const tmp = `${target}.${(options.stageName ??
|
|
63374
|
+
const tmp = `${target}.${(options.stageName ?? randomUUID25)()}.tmp`;
|
|
62846
63375
|
let handle;
|
|
62847
63376
|
let created = false;
|
|
62848
63377
|
try {
|
|
@@ -62882,7 +63411,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log18, options = {})
|
|
|
62882
63411
|
return;
|
|
62883
63412
|
throw error;
|
|
62884
63413
|
}
|
|
62885
|
-
const active2 =
|
|
63414
|
+
const active2 = resolve30(activeDir);
|
|
62886
63415
|
for (const projectDir of projectDirs) {
|
|
62887
63416
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
62888
63417
|
continue;
|
|
@@ -62929,7 +63458,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log18, options = {})
|
|
|
62929
63458
|
else if (isStalePortFile(entry, info, cutoff))
|
|
62930
63459
|
await removeStalePortFile(portFile, raw, info, options.beforeRemove);
|
|
62931
63460
|
}
|
|
62932
|
-
if (
|
|
63461
|
+
if (resolve30(dir) !== active2)
|
|
62933
63462
|
await rmdir3(dir).catch(() => {
|
|
62934
63463
|
});
|
|
62935
63464
|
}
|
|
@@ -62963,7 +63492,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
62963
63492
|
}
|
|
62964
63493
|
};
|
|
62965
63494
|
function readBody(req) {
|
|
62966
|
-
return new Promise((
|
|
63495
|
+
return new Promise((resolve32, reject) => {
|
|
62967
63496
|
const tooLarge = (declaredOversize = false) => {
|
|
62968
63497
|
req.removeAllListeners("data");
|
|
62969
63498
|
req.on("data", () => {
|
|
@@ -62986,7 +63515,7 @@ function readBody(req) {
|
|
|
62986
63515
|
}
|
|
62987
63516
|
chunks.push(chunk);
|
|
62988
63517
|
});
|
|
62989
|
-
req.on("end", () =>
|
|
63518
|
+
req.on("end", () => resolve32(Buffer.concat(chunks).toString("utf8")));
|
|
62990
63519
|
req.on("error", reject);
|
|
62991
63520
|
});
|
|
62992
63521
|
}
|
|
@@ -63165,12 +63694,12 @@ async function startRpcServer(options) {
|
|
|
63165
63694
|
json(500, { error: "internal error" });
|
|
63166
63695
|
}
|
|
63167
63696
|
}
|
|
63168
|
-
const port = await new Promise((
|
|
63697
|
+
const port = await new Promise((resolve32, reject) => {
|
|
63169
63698
|
server.on("error", reject);
|
|
63170
63699
|
server.listen(0, "127.0.0.1", () => {
|
|
63171
63700
|
const addr = server.address();
|
|
63172
63701
|
if (addr && typeof addr === "object")
|
|
63173
|
-
|
|
63702
|
+
resolve32(addr.port);
|
|
63174
63703
|
else
|
|
63175
63704
|
reject(new Error("no port"));
|
|
63176
63705
|
});
|
|
@@ -63193,16 +63722,16 @@ async function startRpcServer(options) {
|
|
|
63193
63722
|
rpcPort: port
|
|
63194
63723
|
});
|
|
63195
63724
|
} catch (error) {
|
|
63196
|
-
await new Promise((
|
|
63725
|
+
await new Promise((resolve32) => server.close(() => resolve32()));
|
|
63197
63726
|
throw error;
|
|
63198
63727
|
}
|
|
63199
63728
|
return {
|
|
63200
63729
|
port,
|
|
63201
63730
|
token,
|
|
63202
63731
|
async stop() {
|
|
63203
|
-
await new Promise((
|
|
63732
|
+
await new Promise((resolve32) => {
|
|
63204
63733
|
server.closeAllConnections?.();
|
|
63205
|
-
server.close(() =>
|
|
63734
|
+
server.close(() => resolve32());
|
|
63206
63735
|
for (const socket of connections)
|
|
63207
63736
|
socket.destroy();
|
|
63208
63737
|
});
|
|
@@ -63534,6 +64063,18 @@ import { dirname as dirname31, join as join45 } from "node:path";
|
|
|
63534
64063
|
// src/plugin/model-registry.ts
|
|
63535
64064
|
init_dist();
|
|
63536
64065
|
|
|
64066
|
+
// src/plugin/config/models.ts
|
|
64067
|
+
function getOpencode1ModelDefinitions() {
|
|
64068
|
+
const models = { ...OPENCODE_MODEL_DEFINITIONS };
|
|
64069
|
+
const hydrogen = models["antigravity-gemini-4-hydrogen"];
|
|
64070
|
+
if (hydrogen) {
|
|
64071
|
+
const variants = { ...hydrogen.variants };
|
|
64072
|
+
delete variants.xhigh;
|
|
64073
|
+
models[hydrogen.id] = { ...hydrogen, variants };
|
|
64074
|
+
}
|
|
64075
|
+
return models;
|
|
64076
|
+
}
|
|
64077
|
+
|
|
63537
64078
|
// src/plugin/config/updater.ts
|
|
63538
64079
|
var PLUGIN_NAME = "@cortexkit/opencode-antigravity-auth@latest";
|
|
63539
64080
|
var SCHEMA_URL = "https://opencode.ai/config.json";
|
|
@@ -63595,7 +64136,7 @@ async function updateOpencodeConfig(options = {}) {
|
|
|
63595
64136
|
if (!config.provider.google) {
|
|
63596
64137
|
config.provider.google = {};
|
|
63597
64138
|
}
|
|
63598
|
-
config.provider.google.models =
|
|
64139
|
+
config.provider.google.models = getOpencode1ModelDefinitions();
|
|
63599
64140
|
config.provider.google.whitelist = getAntigravityOpencodeModelIds();
|
|
63600
64141
|
const configDir = dirname31(configPath);
|
|
63601
64142
|
if (!existsSync15(configDir)) {
|
|
@@ -63811,7 +64352,7 @@ async function select3(items, options) {
|
|
|
63811
64352
|
}
|
|
63812
64353
|
renderedLines = linesWritten;
|
|
63813
64354
|
};
|
|
63814
|
-
return new Promise((
|
|
64355
|
+
return new Promise((resolve32) => {
|
|
63815
64356
|
const wasRaw = stdin.isRaw ?? false;
|
|
63816
64357
|
const cleanup2 = () => {
|
|
63817
64358
|
if (isCleanedUp) return;
|
|
@@ -63832,11 +64373,11 @@ async function select3(items, options) {
|
|
|
63832
64373
|
};
|
|
63833
64374
|
const onSignal = () => {
|
|
63834
64375
|
cleanup2();
|
|
63835
|
-
|
|
64376
|
+
resolve32(null);
|
|
63836
64377
|
};
|
|
63837
64378
|
const finishWithValue = (value) => {
|
|
63838
64379
|
cleanup2();
|
|
63839
|
-
|
|
64380
|
+
resolve32(value);
|
|
63840
64381
|
};
|
|
63841
64382
|
const findNextSelectable = (from, direction) => {
|
|
63842
64383
|
if (items.length === 0) return from;
|
|
@@ -63882,7 +64423,7 @@ async function select3(items, options) {
|
|
|
63882
64423
|
stdin.setRawMode(true);
|
|
63883
64424
|
} catch {
|
|
63884
64425
|
cleanup2();
|
|
63885
|
-
|
|
64426
|
+
resolve32(null);
|
|
63886
64427
|
return;
|
|
63887
64428
|
}
|
|
63888
64429
|
stdin.resume();
|
|
@@ -66756,9 +67297,10 @@ function applyAntigravityProviderCatalog(config, providerId) {
|
|
|
66756
67297
|
const mutableConfig = config;
|
|
66757
67298
|
mutableConfig.provider ??= {};
|
|
66758
67299
|
const providerConfig = mutableConfig.provider[providerId] ?? {};
|
|
67300
|
+
const models = getOpencode1ModelDefinitions();
|
|
66759
67301
|
providerConfig.models = {
|
|
66760
67302
|
...providerConfig.models ?? {},
|
|
66761
|
-
...
|
|
67303
|
+
...models
|
|
66762
67304
|
};
|
|
66763
67305
|
providerConfig.whitelist = getAntigravityOpencodeModelIds();
|
|
66764
67306
|
mutableConfig.provider[providerId] = providerConfig;
|
|
@@ -66895,10 +67437,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
66895
67437
|
}
|
|
66896
67438
|
async function defaultSleep(ms, signal) {
|
|
66897
67439
|
if (ms <= 0) return;
|
|
66898
|
-
await new Promise((
|
|
67440
|
+
await new Promise((resolve32, reject) => {
|
|
66899
67441
|
const timer = setTimeout(() => {
|
|
66900
67442
|
signal?.removeEventListener("abort", onAbort);
|
|
66901
|
-
|
|
67443
|
+
resolve32();
|
|
66902
67444
|
}, ms);
|
|
66903
67445
|
timer.unref?.();
|
|
66904
67446
|
const onAbort = () => {
|
|
@@ -67249,18 +67791,8 @@ tool.schema = z5;
|
|
|
67249
67791
|
init_logger4();
|
|
67250
67792
|
|
|
67251
67793
|
// src/plugin/search.ts
|
|
67252
|
-
import crypto3 from "node:crypto";
|
|
67253
67794
|
init_logger4();
|
|
67254
67795
|
var log16 = createLogger4("search");
|
|
67255
|
-
var sessionCounter = 0;
|
|
67256
|
-
var sessionPrefix = `search-${Date.now().toString(36)}`;
|
|
67257
|
-
function generateRequestId() {
|
|
67258
|
-
return `agent/${crypto3.randomUUID()}/${Date.now()}/${crypto3.randomUUID()}/2`;
|
|
67259
|
-
}
|
|
67260
|
-
function getSessionId() {
|
|
67261
|
-
sessionCounter++;
|
|
67262
|
-
return `${sessionPrefix}-${sessionCounter}`;
|
|
67263
|
-
}
|
|
67264
67796
|
function formatSearchResult(result) {
|
|
67265
67797
|
const lines = [];
|
|
67266
67798
|
lines.push("## Search Results\n");
|
|
@@ -67371,13 +67903,18 @@ ${urlList}`;
|
|
|
67371
67903
|
topP: 1
|
|
67372
67904
|
}
|
|
67373
67905
|
};
|
|
67906
|
+
const metadata = buildAgyAgentRequestMetadata(
|
|
67907
|
+
createAgyRequestSessionContext(),
|
|
67908
|
+
requestPayload,
|
|
67909
|
+
SEARCH_MODEL
|
|
67910
|
+
);
|
|
67911
|
+
requestPayload.labels = metadata.labels;
|
|
67912
|
+
requestPayload.sessionId = metadata.sessionId;
|
|
67913
|
+
orderAgyRequestPayloadInPlace(requestPayload);
|
|
67374
67914
|
const wrappedBody = {
|
|
67375
67915
|
project: projectId,
|
|
67376
|
-
requestId:
|
|
67377
|
-
request:
|
|
67378
|
-
...requestPayload,
|
|
67379
|
-
sessionId: getSessionId()
|
|
67380
|
-
},
|
|
67916
|
+
requestId: metadata.requestId,
|
|
67917
|
+
request: requestPayload,
|
|
67381
67918
|
model: SEARCH_MODEL,
|
|
67382
67919
|
userAgent: "antigravity",
|
|
67383
67920
|
requestType: "agent"
|
|
@@ -67621,8 +68158,8 @@ function createPluginLifecycle(options) {
|
|
|
67621
68158
|
};
|
|
67622
68159
|
let failDisposal = () => {
|
|
67623
68160
|
};
|
|
67624
|
-
disposal = new Promise((
|
|
67625
|
-
finishDisposal =
|
|
68161
|
+
disposal = new Promise((resolve32, reject) => {
|
|
68162
|
+
finishDisposal = resolve32;
|
|
67626
68163
|
failDisposal = reject;
|
|
67627
68164
|
});
|
|
67628
68165
|
void (async () => {
|
|
@@ -67773,7 +68310,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
67773
68310
|
if (config.keep_thinking) {
|
|
67774
68311
|
initDiskSignatureCache(config.signature_cache);
|
|
67775
68312
|
}
|
|
67776
|
-
const sessionRegistry = new AgySessionRegistry(
|
|
68313
|
+
const sessionRegistry = new AgySessionRegistry();
|
|
67777
68314
|
let cachedGetAuth = null;
|
|
67778
68315
|
let stopSidebarPublisher;
|
|
67779
68316
|
const lifecycle = createPluginLifecycle({
|
|
@@ -67790,7 +68327,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
67790
68327
|
await drainSidebarWrites();
|
|
67791
68328
|
}
|
|
67792
68329
|
});
|
|
67793
|
-
const accountFile =
|
|
68330
|
+
const accountFile = resolve31(accountFileForVault());
|
|
67794
68331
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
67795
68332
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
67796
68333
|
let vaultQuotaPoller;
|
|
@@ -68135,7 +68672,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
68135
68672
|
const key = vaultAccountRowKey(row);
|
|
68136
68673
|
const existing = vaultSelectors2.get(key);
|
|
68137
68674
|
if (existing) return existing;
|
|
68138
|
-
const selector =
|
|
68675
|
+
const selector = randomUUID26();
|
|
68139
68676
|
vaultSelectors2.set(key, selector);
|
|
68140
68677
|
return selector;
|
|
68141
68678
|
},
|