@cortexkit/opencode-antigravity-auth 3.0.22 → 3.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +289 -201
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +63 -38
- package/dist/index.js +399 -310
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +66 -41
- package/dist/server.js +409 -315
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/shared/vault-routing.d.ts +6 -3
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing.js +12 -12
- package/dist/src/plugin/shared/vault-routing.js.map +1 -1
- package/dist/src/runtime-layout.d.ts.map +1 -1
- package/dist/src/runtime-layout.js +14 -3
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/vault-folder.d.ts.map +1 -1
- package/dist/src/vault-folder.js +51 -14
- package/dist/src/vault-folder.js.map +1 -1
- package/dist/src/version-fence.d.ts +5 -0
- package/dist/src/version-fence.d.ts.map +1 -1
- package/dist/src/version-fence.js +64 -7
- package/dist/src/version-fence.js.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts +6 -3
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/types/src/runtime-layout.d.ts.map +1 -1
- package/dist/types/src/vault-folder.d.ts.map +1 -1
- package/dist/types/src/version-fence.d.ts +5 -0
- package/dist/types/src/version-fence.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1628,10 +1628,10 @@ async function privateDirectory(path5) {
|
|
|
1628
1628
|
if (errno(error) !== "EEXIST")
|
|
1629
1629
|
throw error;
|
|
1630
1630
|
}
|
|
1631
|
-
const
|
|
1632
|
-
if (!
|
|
1631
|
+
const stat16 = await lstat2(path5);
|
|
1632
|
+
if (!stat16.isDirectory() || stat16.isSymbolicLink())
|
|
1633
1633
|
throw new AccountMigrationError("successor directory is not a regular directory");
|
|
1634
|
-
privateMode(
|
|
1634
|
+
privateMode(stat16.mode, 448);
|
|
1635
1635
|
if (windowsPrivateFiles)
|
|
1636
1636
|
await verifySafeDirectory(path5);
|
|
1637
1637
|
if (!sameFilesystemPath(await realpath(path5), path5))
|
|
@@ -8083,7 +8083,7 @@ function writeConsoleLog(level, ...args) {
|
|
|
8083
8083
|
}
|
|
8084
8084
|
function createLogger(module) {
|
|
8085
8085
|
const service = `antigravity.${module}`;
|
|
8086
|
-
const
|
|
8086
|
+
const log17 = (level, message, extra) => {
|
|
8087
8087
|
if (_sink) {
|
|
8088
8088
|
try {
|
|
8089
8089
|
_sink({ service, level, message, extra });
|
|
@@ -8097,10 +8097,10 @@ function createLogger(module) {
|
|
|
8097
8097
|
}
|
|
8098
8098
|
};
|
|
8099
8099
|
return {
|
|
8100
|
-
debug: (message, extra) =>
|
|
8101
|
-
info: (message, extra) =>
|
|
8102
|
-
warn: (message, extra) =>
|
|
8103
|
-
error: (message, extra) =>
|
|
8100
|
+
debug: (message, extra) => log17("debug", message, extra),
|
|
8101
|
+
info: (message, extra) => log17("info", message, extra),
|
|
8102
|
+
warn: (message, extra) => log17("warn", message, extra),
|
|
8103
|
+
error: (message, extra) => log17("error", message, extra)
|
|
8104
8104
|
};
|
|
8105
8105
|
}
|
|
8106
8106
|
var ENV_CONSOLE_LOG, _sink;
|
|
@@ -25267,13 +25267,13 @@ async function safeRead(path5, privateFile = false, afterReadCheck) {
|
|
|
25267
25267
|
let file;
|
|
25268
25268
|
try {
|
|
25269
25269
|
file = await open7(path5, constants2.O_RDONLY | constants2.O_NOFOLLOW);
|
|
25270
|
-
const
|
|
25271
|
-
if (!
|
|
25270
|
+
const stat16 = await file.stat();
|
|
25271
|
+
if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
|
|
25272
25272
|
throw new PiSlotError("unsafe-path");
|
|
25273
25273
|
}
|
|
25274
25274
|
await afterReadCheck?.(path5);
|
|
25275
25275
|
const current = await lstat5(path5);
|
|
25276
|
-
if (!current.isFile() || current.dev !==
|
|
25276
|
+
if (!current.isFile() || current.dev !== stat16.dev || current.ino !== stat16.ino) {
|
|
25277
25277
|
throw new PiSlotError("unsafe-path");
|
|
25278
25278
|
}
|
|
25279
25279
|
const bytes = await file.readFile();
|
|
@@ -28694,7 +28694,7 @@ function getAntigravityVersionResolution() {
|
|
|
28694
28694
|
return lastResolution ?? { version: getAntigravityVersion(), source: "fallback" };
|
|
28695
28695
|
}
|
|
28696
28696
|
async function initAntigravityVersion() {
|
|
28697
|
-
const
|
|
28697
|
+
const log17 = createLogger("version");
|
|
28698
28698
|
const fallback = getAntigravityVersion();
|
|
28699
28699
|
let version;
|
|
28700
28700
|
let source;
|
|
@@ -28708,15 +28708,15 @@ async function initAntigravityVersion() {
|
|
|
28708
28708
|
} else {
|
|
28709
28709
|
source = "fallback";
|
|
28710
28710
|
setAntigravityVersion(fallback);
|
|
28711
|
-
|
|
28711
|
+
log17.info("version-fetch-failed", { fallback });
|
|
28712
28712
|
lastResolution = { version: fallback, source };
|
|
28713
28713
|
return lastResolution;
|
|
28714
28714
|
}
|
|
28715
28715
|
}
|
|
28716
28716
|
if (version !== fallback) {
|
|
28717
|
-
|
|
28717
|
+
log17.info("version-updated", { version, source, previous: fallback });
|
|
28718
28718
|
} else {
|
|
28719
|
-
|
|
28719
|
+
log17.debug("version-unchanged", { version, source });
|
|
28720
28720
|
}
|
|
28721
28721
|
setAntigravityVersion(version);
|
|
28722
28722
|
lastResolution = { version, source };
|
|
@@ -30917,8 +30917,8 @@ var init_process_heartbeat = __esm({
|
|
|
30917
30917
|
});
|
|
30918
30918
|
|
|
30919
30919
|
// src/version-fence.ts
|
|
30920
|
-
import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
|
|
30921
|
-
import { homedir as homedir3 } from "node:os";
|
|
30920
|
+
import { readdir as readdir2, readFile as readFile11, stat as stat9, unlink as unlink9 } from "node:fs/promises";
|
|
30921
|
+
import { homedir as homedir3, uptime } from "node:os";
|
|
30922
30922
|
import { join as join13 } from "node:path";
|
|
30923
30923
|
function defaultStateHome() {
|
|
30924
30924
|
return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
|
|
@@ -31001,13 +31001,18 @@ async function readProcessRecord(path5, pid) {
|
|
|
31001
31001
|
return { kind: "gone" };
|
|
31002
31002
|
return { kind: "unreadable" };
|
|
31003
31003
|
}
|
|
31004
|
+
let startedAt;
|
|
31004
31005
|
try {
|
|
31005
31006
|
const value = JSON.parse(text2);
|
|
31007
|
+
if (isRecord10(value) && typeof value.startedAt === "number" && Number.isFinite(value.startedAt))
|
|
31008
|
+
startedAt = value.startedAt;
|
|
31006
31009
|
if (value !== null && typeof value === "object" && value.pid === pid && typeof value.version === "string") {
|
|
31007
31010
|
const layouts = value.layouts;
|
|
31008
31011
|
const stores = value.stores;
|
|
31009
31012
|
return {
|
|
31010
31013
|
kind: "ok",
|
|
31014
|
+
text: text2,
|
|
31015
|
+
startedAt,
|
|
31011
31016
|
version: value.version,
|
|
31012
31017
|
...isRecord10(layouts) ? { layouts } : {},
|
|
31013
31018
|
...isRecord10(stores) ? { stores } : {}
|
|
@@ -31015,14 +31020,45 @@ async function readProcessRecord(path5, pid) {
|
|
|
31015
31020
|
}
|
|
31016
31021
|
} catch {
|
|
31017
31022
|
}
|
|
31018
|
-
return { kind: "unreadable" };
|
|
31023
|
+
return { kind: "unreadable", text: text2, startedAt };
|
|
31019
31024
|
}
|
|
31020
31025
|
function isRecord10(value) {
|
|
31021
31026
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
31022
31027
|
}
|
|
31028
|
+
function bootTime(options) {
|
|
31029
|
+
try {
|
|
31030
|
+
return (options.now ?? Date.now)() - (options.uptimeSeconds ?? uptime)() * 1e3;
|
|
31031
|
+
} catch {
|
|
31032
|
+
return Number.NaN;
|
|
31033
|
+
}
|
|
31034
|
+
}
|
|
31035
|
+
async function staleRecord(path5, record3, boot, heartbeat) {
|
|
31036
|
+
if (record3.text === void 0 || !Number.isFinite(boot)) return false;
|
|
31037
|
+
let start = heartbeat ? record3.startedAt : void 0;
|
|
31038
|
+
if (start === void 0) {
|
|
31039
|
+
try {
|
|
31040
|
+
start = (await stat9(path5)).mtimeMs;
|
|
31041
|
+
} catch {
|
|
31042
|
+
return false;
|
|
31043
|
+
}
|
|
31044
|
+
}
|
|
31045
|
+
if (!Number.isFinite(start) || !(start < boot - BOOT_TIME_MARGIN_MS))
|
|
31046
|
+
return false;
|
|
31047
|
+
if (heartbeat) {
|
|
31048
|
+
try {
|
|
31049
|
+
if (await readFile11(path5, "utf8") === record3.text) {
|
|
31050
|
+
await unlink9(path5);
|
|
31051
|
+
log5.debug("Removed stale pre-boot heartbeat", { path: path5 });
|
|
31052
|
+
}
|
|
31053
|
+
} catch {
|
|
31054
|
+
}
|
|
31055
|
+
}
|
|
31056
|
+
return true;
|
|
31057
|
+
}
|
|
31023
31058
|
async function versionFenceOpen(options) {
|
|
31024
31059
|
const isAlive = options.isAlive ?? pidAlive;
|
|
31025
31060
|
const self = options.selfPid ?? process.pid;
|
|
31061
|
+
const boot = bootTime(options);
|
|
31026
31062
|
const blockers = /* @__PURE__ */ new Map();
|
|
31027
31063
|
const block = (entry) => {
|
|
31028
31064
|
const key = entry.pid === "unknown" ? `dir:${entry.detail}` : entry.pid;
|
|
@@ -31045,7 +31081,8 @@ async function versionFenceOpen(options) {
|
|
|
31045
31081
|
const path5 = join13(heartbeatDir, name);
|
|
31046
31082
|
const heartbeat = await readProcessRecord(path5, pid);
|
|
31047
31083
|
if (heartbeat.kind === "gone") continue;
|
|
31048
|
-
|
|
31084
|
+
const live = alive(pid);
|
|
31085
|
+
if (await staleRecord(path5, heartbeat, boot, true) || !live) continue;
|
|
31049
31086
|
if (heartbeat.kind === "unreadable") {
|
|
31050
31087
|
block({ pid, version: "unknown", detail: path5 });
|
|
31051
31088
|
continue;
|
|
@@ -31079,6 +31116,7 @@ async function versionFenceOpen(options) {
|
|
|
31079
31116
|
const path5 = join13(dir, name);
|
|
31080
31117
|
const port = await readProcessRecord(path5, pid);
|
|
31081
31118
|
if (port.kind === "gone") continue;
|
|
31119
|
+
if (await staleRecord(path5, port, boot, false)) continue;
|
|
31082
31120
|
const version = port.kind === "ok" ? port.version : "unknown";
|
|
31083
31121
|
const order = compareVersions(version, options.currentVersion);
|
|
31084
31122
|
if (order === void 0 || order < 0)
|
|
@@ -31091,9 +31129,109 @@ async function versionFenceOpen(options) {
|
|
|
31091
31129
|
blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b))
|
|
31092
31130
|
};
|
|
31093
31131
|
}
|
|
31132
|
+
var log5, BOOT_TIME_MARGIN_MS;
|
|
31094
31133
|
var init_version_fence = __esm({
|
|
31095
31134
|
"src/version-fence.ts"() {
|
|
31096
31135
|
"use strict";
|
|
31136
|
+
init_logger4();
|
|
31137
|
+
log5 = createLogger4("version-fence");
|
|
31138
|
+
BOOT_TIME_MARGIN_MS = 3e5;
|
|
31139
|
+
}
|
|
31140
|
+
});
|
|
31141
|
+
|
|
31142
|
+
// src/vault-folder.ts
|
|
31143
|
+
var vault_folder_exports = {};
|
|
31144
|
+
__export(vault_folder_exports, {
|
|
31145
|
+
__resetVaultFoldersForTest: () => __resetVaultFoldersForTest,
|
|
31146
|
+
currentVaultFolder: () => currentVaultFolder,
|
|
31147
|
+
prepareVaultFolder: () => prepareVaultFolder
|
|
31148
|
+
});
|
|
31149
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
31150
|
+
function vaultOverride(accountFile) {
|
|
31151
|
+
const kept = refusals.get(overrideRefusalKey);
|
|
31152
|
+
if (kept) return { accountFile, vaultDir: kept.stateDir, refusal: kept };
|
|
31153
|
+
const vaultDir = process.env[OVERRIDE];
|
|
31154
|
+
if (!vaultDir) return void 0;
|
|
31155
|
+
if (isAbsolute3(vaultDir)) return { accountFile, vaultDir };
|
|
31156
|
+
const refusal3 = new RuntimeLayoutRefusal(
|
|
31157
|
+
vaultDir,
|
|
31158
|
+
"relative-vault-dir",
|
|
31159
|
+
`antigravity-auth cannot start: ${OVERRIDE} must be an absolute path. Correct it and restart OpenCode.`
|
|
31160
|
+
);
|
|
31161
|
+
refusals.set(overrideRefusalKey, refusal3);
|
|
31162
|
+
return { accountFile, vaultDir, refusal: refusal3 };
|
|
31163
|
+
}
|
|
31164
|
+
function locationKey() {
|
|
31165
|
+
const location = runtimeLayoutLocation();
|
|
31166
|
+
return `${location.stateHomeDir}\0${location.key}`;
|
|
31167
|
+
}
|
|
31168
|
+
function __resetVaultFoldersForTest() {
|
|
31169
|
+
refusals.clear();
|
|
31170
|
+
}
|
|
31171
|
+
async function prepareVaultFolder(options) {
|
|
31172
|
+
const { accountFile } = options;
|
|
31173
|
+
const override = vaultOverride(accountFile);
|
|
31174
|
+
if (override?.refusal) return override;
|
|
31175
|
+
const key = locationKey();
|
|
31176
|
+
const kept = refusals.get(key);
|
|
31177
|
+
if (kept)
|
|
31178
|
+
return override ? { ...override, refusal: kept } : refused(accountFile, kept);
|
|
31179
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
31180
|
+
const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
|
|
31181
|
+
try {
|
|
31182
|
+
if (override) {
|
|
31183
|
+
await ensurePrivateDirectory2(override.vaultDir);
|
|
31184
|
+
} else
|
|
31185
|
+
await prepareRuntimeLayout({
|
|
31186
|
+
version,
|
|
31187
|
+
accountFile,
|
|
31188
|
+
log: log17,
|
|
31189
|
+
...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
|
|
31190
|
+
});
|
|
31191
|
+
if (options.accountStore !== false)
|
|
31192
|
+
await prepareAccountStore({ version, log: log17 });
|
|
31193
|
+
} catch (error) {
|
|
31194
|
+
const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
|
|
31195
|
+
override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
|
|
31196
|
+
error instanceof Error ? error.name : typeof error
|
|
31197
|
+
);
|
|
31198
|
+
if (!refusals.has(key)) {
|
|
31199
|
+
refusals.set(key, refusal3);
|
|
31200
|
+
log17.warn(refusal3.message, {
|
|
31201
|
+
stateDir: refusal3.stateDir,
|
|
31202
|
+
errorClass: refusal3.errorClass
|
|
31203
|
+
});
|
|
31204
|
+
}
|
|
31205
|
+
return override ? { ...override, refusal: refusals.get(key) ?? refusal3 } : refused(accountFile, refusals.get(key) ?? refusal3);
|
|
31206
|
+
}
|
|
31207
|
+
return override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
31208
|
+
}
|
|
31209
|
+
function currentVaultFolder(accountFile) {
|
|
31210
|
+
const override = vaultOverride(accountFile);
|
|
31211
|
+
if (override?.refusal) return override;
|
|
31212
|
+
const kept = refusals.get(locationKey());
|
|
31213
|
+
return kept ? override ? { ...override, refusal: kept } : refused(accountFile, kept) : override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
31214
|
+
}
|
|
31215
|
+
function refused(accountFile, refusal3) {
|
|
31216
|
+
return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
|
|
31217
|
+
}
|
|
31218
|
+
var refusalsKey, globalState2, refusals, OVERRIDE, overrideRefusalKey;
|
|
31219
|
+
var init_vault_folder = __esm({
|
|
31220
|
+
"src/vault-folder.ts"() {
|
|
31221
|
+
"use strict";
|
|
31222
|
+
init_private_files2();
|
|
31223
|
+
init_logger4();
|
|
31224
|
+
init_process_heartbeat();
|
|
31225
|
+
init_runtime_layout();
|
|
31226
|
+
init_runtime_paths();
|
|
31227
|
+
refusalsKey = /* @__PURE__ */ Symbol.for(
|
|
31228
|
+
"@cortexkit/antigravity-auth/vault-folder-refusals"
|
|
31229
|
+
);
|
|
31230
|
+
globalState2 = globalThis;
|
|
31231
|
+
refusals = globalState2[refusalsKey] ?? /* @__PURE__ */ new Map();
|
|
31232
|
+
globalState2[refusalsKey] = refusals;
|
|
31233
|
+
OVERRIDE = "OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR";
|
|
31234
|
+
overrideRefusalKey = "invalid-vault-dir-override";
|
|
31097
31235
|
}
|
|
31098
31236
|
});
|
|
31099
31237
|
|
|
@@ -31124,8 +31262,8 @@ import {
|
|
|
31124
31262
|
readFile as readFile12,
|
|
31125
31263
|
rename as rename10,
|
|
31126
31264
|
rmdir as rmdir2,
|
|
31127
|
-
stat as
|
|
31128
|
-
unlink as
|
|
31265
|
+
stat as stat10,
|
|
31266
|
+
unlink as unlink10
|
|
31129
31267
|
} from "node:fs/promises";
|
|
31130
31268
|
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
|
|
31131
31269
|
function refusalMessage(stateDir, errorClass2) {
|
|
@@ -31180,10 +31318,10 @@ function errorFile(error) {
|
|
|
31180
31318
|
...typeof stage === "string" && stage ? { stage } : {}
|
|
31181
31319
|
};
|
|
31182
31320
|
}
|
|
31183
|
-
function logCleanupFailure(location,
|
|
31321
|
+
function logCleanupFailure(location, log17, step, error) {
|
|
31184
31322
|
logOnce(
|
|
31185
31323
|
`${location.key}\0cleanup`,
|
|
31186
|
-
() =>
|
|
31324
|
+
() => log17.warn(
|
|
31187
31325
|
"antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
|
|
31188
31326
|
{
|
|
31189
31327
|
configDir: location.configDir,
|
|
@@ -31212,13 +31350,13 @@ function prepareRuntimeLayout(options) {
|
|
|
31212
31350
|
return run;
|
|
31213
31351
|
}
|
|
31214
31352
|
async function decide(location, options) {
|
|
31215
|
-
const
|
|
31353
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
31216
31354
|
const stateDir = location.stateHomeDir;
|
|
31217
31355
|
const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
|
|
31218
31356
|
const files = layoutFiles(location, options.accountFile);
|
|
31219
31357
|
const fence = options.fence ?? defaultFence(options.version);
|
|
31220
31358
|
const stateHome = async () => {
|
|
31221
|
-
await settleVault(location, options, "state-home",
|
|
31359
|
+
await settleVault(location, options, "state-home", log17);
|
|
31222
31360
|
return "state-home";
|
|
31223
31361
|
};
|
|
31224
31362
|
let marker = await readMarker(markerPath, stateDir, files.vault.old);
|
|
@@ -31229,7 +31367,7 @@ async function decide(location, options) {
|
|
|
31229
31367
|
join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
|
|
31230
31368
|
).catch(() => true);
|
|
31231
31369
|
if (!manifestLeft) {
|
|
31232
|
-
await settleVault(location, options, "state-home",
|
|
31370
|
+
await settleVault(location, options, "state-home", log17);
|
|
31233
31371
|
return stateHome();
|
|
31234
31372
|
}
|
|
31235
31373
|
}
|
|
@@ -31241,7 +31379,7 @@ async function decide(location, options) {
|
|
|
31241
31379
|
RUNTIME_LAYOUT_LOCK_NAME,
|
|
31242
31380
|
markerPath,
|
|
31243
31381
|
options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
|
|
31244
|
-
|
|
31382
|
+
log17
|
|
31245
31383
|
);
|
|
31246
31384
|
} catch (error) {
|
|
31247
31385
|
marker = await readMarker(markerPath, stateDir, files.vault.old);
|
|
@@ -31261,7 +31399,7 @@ async function decide(location, options) {
|
|
|
31261
31399
|
const legacy = async () => {
|
|
31262
31400
|
try {
|
|
31263
31401
|
await lock.assertOwned();
|
|
31264
|
-
await settleVault(location, options, "legacy",
|
|
31402
|
+
await settleVault(location, options, "legacy", log17);
|
|
31265
31403
|
} catch (error) {
|
|
31266
31404
|
throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
|
|
31267
31405
|
}
|
|
@@ -31275,20 +31413,20 @@ async function decide(location, options) {
|
|
|
31275
31413
|
if (!marker.oldFilesRemoved && !aliased)
|
|
31276
31414
|
await finishOldFiles(location, files, markerPath, marker, lock, {
|
|
31277
31415
|
fence,
|
|
31278
|
-
log:
|
|
31416
|
+
log: log17,
|
|
31279
31417
|
steps: options.steps,
|
|
31280
31418
|
oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
|
|
31281
31419
|
});
|
|
31282
31420
|
else if (marker.oldFilesRemoved) {
|
|
31283
31421
|
await refuseReappearedFiles(location, files);
|
|
31284
|
-
await removeLeftoverManifest(location, lock, options.steps,
|
|
31422
|
+
await removeLeftoverManifest(location, lock, options.steps, log17);
|
|
31285
31423
|
}
|
|
31286
31424
|
return await stateHome();
|
|
31287
31425
|
}
|
|
31288
31426
|
if (aliased) {
|
|
31289
31427
|
logOnce(
|
|
31290
31428
|
`${location.key}\0aliased`,
|
|
31291
|
-
() =>
|
|
31429
|
+
() => log17.warn(
|
|
31292
31430
|
"antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
|
|
31293
31431
|
{ configDir: location.configDir, stateDir }
|
|
31294
31432
|
)
|
|
@@ -31297,14 +31435,14 @@ async function decide(location, options) {
|
|
|
31297
31435
|
}
|
|
31298
31436
|
const gate = await fence();
|
|
31299
31437
|
if (!gate.open) {
|
|
31300
|
-
logDeferral(location, gate.blockers,
|
|
31438
|
+
logDeferral(location, gate.blockers, log17);
|
|
31301
31439
|
return await legacy();
|
|
31302
31440
|
}
|
|
31303
31441
|
let markerStarted = false;
|
|
31304
31442
|
try {
|
|
31305
31443
|
const outcome = await moveFiles(location, files, markerPath, lock, {
|
|
31306
31444
|
fence,
|
|
31307
|
-
log:
|
|
31445
|
+
log: log17,
|
|
31308
31446
|
steps: options.steps,
|
|
31309
31447
|
destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
|
|
31310
31448
|
oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
|
|
@@ -31313,13 +31451,13 @@ async function decide(location, options) {
|
|
|
31313
31451
|
}
|
|
31314
31452
|
});
|
|
31315
31453
|
if (outcome.kind === "deferred") {
|
|
31316
|
-
logDeferral(location, outcome.blockers,
|
|
31454
|
+
logDeferral(location, outcome.blockers, log17);
|
|
31317
31455
|
return await legacy();
|
|
31318
31456
|
}
|
|
31319
31457
|
if (outcome.kind === "refused") {
|
|
31320
31458
|
logOnce(
|
|
31321
31459
|
`${location.key}\0refused`,
|
|
31322
|
-
() =>
|
|
31460
|
+
() => log17.warn(
|
|
31323
31461
|
outcome.reason === "destination-not-private" ? "antigravity-auth keeps its vault files in OpenCode's config folder: the vault folder in its state folder already exists and is not private to your user. It was left unchanged; remove it if it holds nothing you need, then restart OpenCode." : "antigravity-auth keeps its vault files in OpenCode's config folder: it will not move them",
|
|
31324
31462
|
{ reason: outcome.reason, paths: outcome.paths, stateDir }
|
|
31325
31463
|
)
|
|
@@ -31327,7 +31465,7 @@ async function decide(location, options) {
|
|
|
31327
31465
|
return await legacy();
|
|
31328
31466
|
}
|
|
31329
31467
|
if (outcome.moved)
|
|
31330
|
-
|
|
31468
|
+
log17.info(
|
|
31331
31469
|
"antigravity-auth moved its vault files out of OpenCode's config folder",
|
|
31332
31470
|
{ from: files.vault.old, to: files.vault.next }
|
|
31333
31471
|
);
|
|
@@ -31338,7 +31476,7 @@ async function decide(location, options) {
|
|
|
31338
31476
|
return await stateHome();
|
|
31339
31477
|
logOnce(
|
|
31340
31478
|
`${location.key}\0failed`,
|
|
31341
|
-
() =>
|
|
31479
|
+
() => log17.warn(
|
|
31342
31480
|
"antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
|
|
31343
31481
|
{
|
|
31344
31482
|
configDir: location.configDir,
|
|
@@ -31367,8 +31505,12 @@ async function settleVault(location, options, layout, _log) {
|
|
|
31367
31505
|
}
|
|
31368
31506
|
async function localAccountStoreAuthorized() {
|
|
31369
31507
|
const location = runtimeLayoutLocation();
|
|
31508
|
+
const folder = process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR ? (await Promise.resolve().then(() => (init_vault_folder(), vault_folder_exports))).currentVaultFolder(
|
|
31509
|
+
accountFileForVault(location.configDir)
|
|
31510
|
+
) : void 0;
|
|
31511
|
+
if (folder?.refusal) return false;
|
|
31370
31512
|
const claustrum = await loadCommonAuthClaustrum();
|
|
31371
|
-
const vaultDir = decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
31513
|
+
const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
31372
31514
|
return await enrollmentAuthority2(
|
|
31373
31515
|
claustrum.hostEnrollmentPaths({
|
|
31374
31516
|
stateDir: vaultDir,
|
|
@@ -31383,7 +31525,7 @@ async function prepareAccountStore(options) {
|
|
|
31383
31525
|
if (!await localAccountStoreAuthorized()) return void 0;
|
|
31384
31526
|
const decided = decidedAccountStoreAnchor(location);
|
|
31385
31527
|
if (decided) return decided;
|
|
31386
|
-
const
|
|
31528
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
31387
31529
|
const runKey = `${location.stateHomeDir}\0${location.key}`;
|
|
31388
31530
|
let run = processState.storeRuns.get(runKey);
|
|
31389
31531
|
if (!run) {
|
|
@@ -31394,12 +31536,12 @@ async function prepareAccountStore(options) {
|
|
|
31394
31536
|
RUNTIME_LAYOUT_LOCK_NAME,
|
|
31395
31537
|
join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
31396
31538
|
options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
|
|
31397
|
-
|
|
31539
|
+
log17
|
|
31398
31540
|
);
|
|
31399
31541
|
try {
|
|
31400
31542
|
await lock.assertOwned();
|
|
31401
31543
|
if (!await localAccountStoreAuthorized()) return void 0;
|
|
31402
|
-
return await settleAccountStore(location, options,
|
|
31544
|
+
return await settleAccountStore(location, options, log17);
|
|
31403
31545
|
} finally {
|
|
31404
31546
|
await lock.release();
|
|
31405
31547
|
}
|
|
@@ -31410,20 +31552,20 @@ async function prepareAccountStore(options) {
|
|
|
31410
31552
|
}
|
|
31411
31553
|
return run;
|
|
31412
31554
|
}
|
|
31413
|
-
async function settleAccountStore(location, options,
|
|
31555
|
+
async function settleAccountStore(location, options, log17) {
|
|
31414
31556
|
const decided = decidedAccountStoreAnchor(location);
|
|
31415
31557
|
if (decided) return decided;
|
|
31416
|
-
const anchor = await decideAccountStore(location, options,
|
|
31558
|
+
const anchor = await decideAccountStore(location, options, log17);
|
|
31417
31559
|
setAccountStoreAnchor(location, anchor);
|
|
31418
31560
|
return anchor;
|
|
31419
31561
|
}
|
|
31420
|
-
async function decideAccountStore(location, options,
|
|
31421
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31562
|
+
async function decideAccountStore(location, options, log17) {
|
|
31563
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31422
31564
|
if (processHasOlderGeneration()) {
|
|
31423
31565
|
logOnce(
|
|
31424
31566
|
"older-generation-account-store",
|
|
31425
31567
|
() => showLog(
|
|
31426
|
-
|
|
31568
|
+
log17,
|
|
31427
31569
|
"antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
|
|
31428
31570
|
{ accountStore: "config" }
|
|
31429
31571
|
)
|
|
@@ -31437,7 +31579,7 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31437
31579
|
if (!sameSpelling(forward.legacyPath, stateAnchor)) {
|
|
31438
31580
|
logOnce(
|
|
31439
31581
|
`${location.key}\0store-forward-elsewhere`,
|
|
31440
|
-
() =>
|
|
31582
|
+
() => log17.warn(
|
|
31441
31583
|
"the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
|
|
31442
31584
|
{ movedTo: forward.legacyPath, expected: stateAnchor }
|
|
31443
31585
|
)
|
|
@@ -31448,9 +31590,9 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31448
31590
|
options,
|
|
31449
31591
|
configAnchor,
|
|
31450
31592
|
stateAnchor,
|
|
31451
|
-
|
|
31593
|
+
log17
|
|
31452
31594
|
);
|
|
31453
|
-
return recordAnchor(location, options, "state-home",
|
|
31595
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31454
31596
|
}
|
|
31455
31597
|
if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
|
|
31456
31598
|
const configStore = await presentAccountStore(configAnchor);
|
|
@@ -31462,9 +31604,9 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31462
31604
|
`antigravity-auth cannot start: two account stores exist, one at ${configAnchor} and one at ${stateAnchor}, and neither is marked as moved. Keep the one you want and move the other one aside, then restart OpenCode.`
|
|
31463
31605
|
);
|
|
31464
31606
|
}
|
|
31465
|
-
if (stateStore) return recordAnchor(location, options, "state-home",
|
|
31607
|
+
if (stateStore) return recordAnchor(location, options, "state-home", log17);
|
|
31466
31608
|
if (configStore) {
|
|
31467
|
-
if (!await storeMovePathResolves(stateAnchor, location,
|
|
31609
|
+
if (!await storeMovePathResolves(stateAnchor, location, log17))
|
|
31468
31610
|
return keepConfig();
|
|
31469
31611
|
return moveStore(
|
|
31470
31612
|
location,
|
|
@@ -31472,21 +31614,21 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31472
31614
|
configAnchor,
|
|
31473
31615
|
stateAnchor,
|
|
31474
31616
|
false,
|
|
31475
|
-
|
|
31617
|
+
log17,
|
|
31476
31618
|
false
|
|
31477
31619
|
);
|
|
31478
31620
|
}
|
|
31479
|
-
if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor,
|
|
31621
|
+
if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log17))
|
|
31480
31622
|
return keepConfig();
|
|
31481
|
-
if (!await storeMovePathResolves(stateAnchor, location,
|
|
31623
|
+
if (!await storeMovePathResolves(stateAnchor, location, log17))
|
|
31482
31624
|
return keepConfig();
|
|
31483
|
-
return initializeStore(location, options, stateAnchor,
|
|
31625
|
+
return initializeStore(location, options, stateAnchor, log17);
|
|
31484
31626
|
}
|
|
31485
|
-
function showLog(
|
|
31486
|
-
if (
|
|
31487
|
-
else
|
|
31627
|
+
function showLog(log17, message, meta) {
|
|
31628
|
+
if (log17.log) log17.log(message, meta);
|
|
31629
|
+
else log17.info(message, meta);
|
|
31488
31630
|
}
|
|
31489
|
-
async function recordAnchor(location, options, anchor,
|
|
31631
|
+
async function recordAnchor(location, options, anchor, log17) {
|
|
31490
31632
|
try {
|
|
31491
31633
|
await recordProcessAnchor({
|
|
31492
31634
|
key: location.key,
|
|
@@ -31498,32 +31640,32 @@ async function recordAnchor(location, options, anchor, log16) {
|
|
|
31498
31640
|
}
|
|
31499
31641
|
if (anchor === "state-home")
|
|
31500
31642
|
showLog(
|
|
31501
|
-
|
|
31643
|
+
log17,
|
|
31502
31644
|
"antigravity-auth keeps its account store in its state folder",
|
|
31503
31645
|
{ accountStore: anchor }
|
|
31504
31646
|
);
|
|
31505
31647
|
return anchor;
|
|
31506
31648
|
}
|
|
31507
|
-
async function storeMovePathResolves(stateAnchor, location,
|
|
31649
|
+
async function storeMovePathResolves(stateAnchor, location, log17) {
|
|
31508
31650
|
if (folderResolvesToItself(
|
|
31509
31651
|
join14(location.stateHomeDir, "antigravity-accounts.json")
|
|
31510
31652
|
))
|
|
31511
31653
|
return true;
|
|
31512
31654
|
logOnce(
|
|
31513
31655
|
`${location.key}\0store-linked-path`,
|
|
31514
|
-
() =>
|
|
31656
|
+
() => log17.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
|
|
31515
31657
|
accountStore: stateAnchor,
|
|
31516
31658
|
stateFolder: location.stateHomeDir
|
|
31517
31659
|
})
|
|
31518
31660
|
);
|
|
31519
31661
|
return false;
|
|
31520
31662
|
}
|
|
31521
|
-
async function storeFenceOpen(location, options,
|
|
31663
|
+
async function storeFenceOpen(location, options, log17) {
|
|
31522
31664
|
const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
|
|
31523
31665
|
if (gate.open) return true;
|
|
31524
31666
|
logOnce(
|
|
31525
31667
|
`${location.key}\0store-version-fence`,
|
|
31526
|
-
() =>
|
|
31668
|
+
() => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
|
|
31527
31669
|
configDir: location.configDir,
|
|
31528
31670
|
blockers: gate.blockers
|
|
31529
31671
|
})
|
|
@@ -31550,7 +31692,7 @@ async function storeArtefacts(anchor) {
|
|
|
31550
31692
|
(name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
|
|
31551
31693
|
).length;
|
|
31552
31694
|
}
|
|
31553
|
-
async function abandonUnpublishedStore(location, stateAnchor,
|
|
31695
|
+
async function abandonUnpublishedStore(location, stateAnchor, log17) {
|
|
31554
31696
|
const store = await loadCommonAuthStoreModules();
|
|
31555
31697
|
const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
|
|
31556
31698
|
if (binding.status === "bound") return false;
|
|
@@ -31559,9 +31701,9 @@ async function abandonUnpublishedStore(location, stateAnchor, log16) {
|
|
|
31559
31701
|
await rename10(folder, archived).catch((error) => {
|
|
31560
31702
|
if (error.code !== "ENOENT") throw error;
|
|
31561
31703
|
});
|
|
31562
|
-
await
|
|
31704
|
+
await unlink10(accountStorePointerPath(stateAnchor)).catch(() => {
|
|
31563
31705
|
});
|
|
31564
|
-
|
|
31706
|
+
log17.info(
|
|
31565
31707
|
"antigravity-auth set an unfinished account store aside before starting its move again",
|
|
31566
31708
|
{ configDir: location.configDir, archived }
|
|
31567
31709
|
);
|
|
@@ -31583,9 +31725,9 @@ async function runStoreMove(input2) {
|
|
|
31583
31725
|
return { status: "pending", reason: outcome.reason };
|
|
31584
31726
|
return { status: "cancelled" };
|
|
31585
31727
|
}
|
|
31586
|
-
async function moveStore(location, options, source, target, back,
|
|
31587
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31588
|
-
if (!await storeFenceOpen(location, options,
|
|
31728
|
+
async function moveStore(location, options, source, target, back, log17, forwarded) {
|
|
31729
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31730
|
+
if (!await storeFenceOpen(location, options, log17)) return keepConfig();
|
|
31589
31731
|
try {
|
|
31590
31732
|
const result = await (options.relocate ?? runStoreMove)({
|
|
31591
31733
|
source,
|
|
@@ -31595,7 +31737,7 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31595
31737
|
if (result.status !== "completed") {
|
|
31596
31738
|
logOnce(
|
|
31597
31739
|
`${location.key}\0store-move-unfinished`,
|
|
31598
|
-
() =>
|
|
31740
|
+
() => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
|
|
31599
31741
|
configDir: location.configDir,
|
|
31600
31742
|
reason: result.status === "pending" ? result.reason : result.status
|
|
31601
31743
|
})
|
|
@@ -31603,14 +31745,14 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31603
31745
|
return forwarded ? "state-home" : keepConfig();
|
|
31604
31746
|
}
|
|
31605
31747
|
showLog(
|
|
31606
|
-
|
|
31748
|
+
log17,
|
|
31607
31749
|
"antigravity-auth moved the account store out of OpenCode's config folder",
|
|
31608
31750
|
{ from: source, to: target, generation: result.id }
|
|
31609
31751
|
);
|
|
31610
31752
|
} catch (error) {
|
|
31611
31753
|
logOnce(
|
|
31612
31754
|
`${location.key}\0store-move-failed`,
|
|
31613
|
-
() =>
|
|
31755
|
+
() => log17.warn(
|
|
31614
31756
|
"antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
|
|
31615
31757
|
{
|
|
31616
31758
|
configDir: location.configDir,
|
|
@@ -31621,9 +31763,9 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31621
31763
|
);
|
|
31622
31764
|
return forwarded ? "state-home" : keepConfig();
|
|
31623
31765
|
}
|
|
31624
|
-
return recordAnchor(location, options, "state-home",
|
|
31766
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31625
31767
|
}
|
|
31626
|
-
async function resumeForwardedStore(location, options, configAnchor, stateAnchor,
|
|
31768
|
+
async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log17) {
|
|
31627
31769
|
const store = await loadCommonAuthStoreModules();
|
|
31628
31770
|
const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
|
|
31629
31771
|
if (binding.status === "bound") return;
|
|
@@ -31634,13 +31776,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
|
|
|
31634
31776
|
configAnchor,
|
|
31635
31777
|
stateAnchor,
|
|
31636
31778
|
false,
|
|
31637
|
-
|
|
31779
|
+
log17,
|
|
31638
31780
|
true
|
|
31639
31781
|
);
|
|
31640
31782
|
} catch (error) {
|
|
31641
31783
|
logOnce(
|
|
31642
31784
|
`${location.key}\0store-resume-failed`,
|
|
31643
|
-
() =>
|
|
31785
|
+
() => log17.warn(
|
|
31644
31786
|
"antigravity-auth's account store is still moving; it could not be finished at this start",
|
|
31645
31787
|
{
|
|
31646
31788
|
configDir: location.configDir,
|
|
@@ -31651,9 +31793,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
|
|
|
31651
31793
|
);
|
|
31652
31794
|
}
|
|
31653
31795
|
}
|
|
31654
|
-
async function initializeStore(location, options, stateAnchor,
|
|
31655
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31656
|
-
if (!await storeFenceOpen(location, options,
|
|
31796
|
+
async function initializeStore(location, options, stateAnchor, log17) {
|
|
31797
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31798
|
+
if (!await storeFenceOpen(location, options, log17)) return keepConfig();
|
|
31657
31799
|
try {
|
|
31658
31800
|
const store = await loadCommonAuthStoreModules();
|
|
31659
31801
|
const created = await initializeFreshAccountStore(store, {
|
|
@@ -31666,7 +31808,7 @@ async function initializeStore(location, options, stateAnchor, log16) {
|
|
|
31666
31808
|
} catch (error) {
|
|
31667
31809
|
logOnce(
|
|
31668
31810
|
`${location.key}\0store-init-failed`,
|
|
31669
|
-
() =>
|
|
31811
|
+
() => log17.warn(
|
|
31670
31812
|
"antigravity-auth's account store stays in OpenCode's config folder: creating it in its state folder failed; it is tried again at the next start",
|
|
31671
31813
|
{
|
|
31672
31814
|
configDir: location.configDir,
|
|
@@ -31678,13 +31820,13 @@ async function initializeStore(location, options, stateAnchor, log16) {
|
|
|
31678
31820
|
return keepConfig();
|
|
31679
31821
|
}
|
|
31680
31822
|
showLog(
|
|
31681
|
-
|
|
31823
|
+
log17,
|
|
31682
31824
|
"antigravity-auth created its account store in its state folder",
|
|
31683
31825
|
{
|
|
31684
31826
|
accountStore: stateAnchor
|
|
31685
31827
|
}
|
|
31686
31828
|
);
|
|
31687
|
-
return recordAnchor(location, options, "state-home",
|
|
31829
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31688
31830
|
}
|
|
31689
31831
|
async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
|
|
31690
31832
|
const forward = {
|
|
@@ -31699,10 +31841,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
|
|
|
31699
31841
|
durability: "file-only-on-windows"
|
|
31700
31842
|
});
|
|
31701
31843
|
}
|
|
31702
|
-
function logDeferral(location, blockers,
|
|
31844
|
+
function logDeferral(location, blockers, log17) {
|
|
31703
31845
|
logOnce(
|
|
31704
31846
|
`${location.key}\0deferred`,
|
|
31705
|
-
() =>
|
|
31847
|
+
() => log17.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
|
|
31706
31848
|
configDir: location.configDir,
|
|
31707
31849
|
blockers
|
|
31708
31850
|
})
|
|
@@ -31751,7 +31893,7 @@ async function moveFiles(location, files, markerPath, layoutLock, input2) {
|
|
|
31751
31893
|
for (const path5 of listed) {
|
|
31752
31894
|
if (wanted.has(path5)) continue;
|
|
31753
31895
|
await layoutLock.assertOwned();
|
|
31754
|
-
await
|
|
31896
|
+
await unlink10(path5).catch((error) => {
|
|
31755
31897
|
if (error.code !== "ENOENT") throw error;
|
|
31756
31898
|
});
|
|
31757
31899
|
}
|
|
@@ -31860,13 +32002,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
|
|
|
31860
32002
|
if (done) await removeOldVaultFolder(files, layoutLock, input2.steps);
|
|
31861
32003
|
}
|
|
31862
32004
|
}
|
|
31863
|
-
async function removeLeftoverManifest(location, layoutLock, steps,
|
|
32005
|
+
async function removeLeftoverManifest(location, layoutLock, steps, log17) {
|
|
31864
32006
|
try {
|
|
31865
32007
|
await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
|
|
31866
32008
|
} catch (error) {
|
|
31867
32009
|
logOnce(
|
|
31868
32010
|
`${location.key}\0manifest`,
|
|
31869
|
-
() =>
|
|
32011
|
+
() => log17.warn(
|
|
31870
32012
|
`antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
|
|
31871
32013
|
{ stateDir: location.stateHomeDir, errorClass: errorClass(error) }
|
|
31872
32014
|
)
|
|
@@ -31886,16 +32028,16 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
|
|
|
31886
32028
|
} catch {
|
|
31887
32029
|
}
|
|
31888
32030
|
}
|
|
31889
|
-
async function removeOldSignatureCache(location, path5, layoutLock, steps,
|
|
32031
|
+
async function removeOldSignatureCache(location, path5, layoutLock, steps, log17) {
|
|
31890
32032
|
try {
|
|
31891
32033
|
if (!await exists2(path5)) return;
|
|
31892
32034
|
await beforeRemove(path5, layoutLock, steps);
|
|
31893
|
-
await
|
|
32035
|
+
await unlink10(path5);
|
|
31894
32036
|
} catch (error) {
|
|
31895
32037
|
if (error?.code === "ENOENT") return;
|
|
31896
32038
|
logOnce(
|
|
31897
32039
|
`${location.key}\0signature-cache`,
|
|
31898
|
-
() =>
|
|
32040
|
+
() => log17.warn(
|
|
31899
32041
|
"antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
|
|
31900
32042
|
{ path: path5, errorClass: errorClass(error) }
|
|
31901
32043
|
)
|
|
@@ -31906,7 +32048,7 @@ async function beforeRemove(path5, layoutLock, steps) {
|
|
|
31906
32048
|
await steps?.beforeRemove?.(path5);
|
|
31907
32049
|
await layoutLock.assertOwned();
|
|
31908
32050
|
}
|
|
31909
|
-
async function takeDataLocks(files,
|
|
32051
|
+
async function takeDataLocks(files, log17) {
|
|
31910
32052
|
const locks = [];
|
|
31911
32053
|
try {
|
|
31912
32054
|
if (await exists2(files.vault.old))
|
|
@@ -31916,7 +32058,7 @@ async function takeDataLocks(files, log16) {
|
|
|
31916
32058
|
lock.name,
|
|
31917
32059
|
join14(files.vault.old, lock.file),
|
|
31918
32060
|
lock.waitMs,
|
|
31919
|
-
|
|
32061
|
+
log17
|
|
31920
32062
|
)
|
|
31921
32063
|
);
|
|
31922
32064
|
return locks;
|
|
@@ -31980,6 +32122,7 @@ async function isVaultShapedKeptState(files) {
|
|
|
31980
32122
|
return vaultShape && proposedName === OPENCODE_VAULT_ENROLLMENT_NAME;
|
|
31981
32123
|
}
|
|
31982
32124
|
async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
32125
|
+
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
31983
32126
|
const location = runtimeLayoutLocation();
|
|
31984
32127
|
const files = layoutFiles(location, accountFile);
|
|
31985
32128
|
if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
|
|
@@ -31992,7 +32135,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
|
31992
32135
|
if (!marker?.oldDir || marker.oldDir !== location.key) return;
|
|
31993
32136
|
const leftover = vaultStateFile(files).old;
|
|
31994
32137
|
if (!await isVaultShapedKeptState(files)) return;
|
|
31995
|
-
await
|
|
32138
|
+
await unlink10(leftover).catch((error) => {
|
|
31996
32139
|
if (error.code !== "ENOENT") throw error;
|
|
31997
32140
|
});
|
|
31998
32141
|
await rmdir2(files.vault.old).catch(() => {
|
|
@@ -32038,7 +32181,7 @@ async function physicalAliases(location, files) {
|
|
|
32038
32181
|
async function samePhysical(a, b) {
|
|
32039
32182
|
const id = async (path5) => {
|
|
32040
32183
|
try {
|
|
32041
|
-
const info = await
|
|
32184
|
+
const info = await stat10(path5, { bigint: true });
|
|
32042
32185
|
return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
|
|
32043
32186
|
} catch (error) {
|
|
32044
32187
|
const code2 = error.code;
|
|
@@ -32128,7 +32271,7 @@ async function unlinkIfIdentical(file, stateDir, guard) {
|
|
|
32128
32271
|
if (!same) throw credentialConflict(stateDir, file);
|
|
32129
32272
|
await guard();
|
|
32130
32273
|
try {
|
|
32131
|
-
await
|
|
32274
|
+
await unlink10(file.old);
|
|
32132
32275
|
return true;
|
|
32133
32276
|
} catch (error) {
|
|
32134
32277
|
if (error.code === "ENOENT") return true;
|
|
@@ -32241,7 +32384,7 @@ async function writeManifest(stateDir, paths) {
|
|
|
32241
32384
|
);
|
|
32242
32385
|
}
|
|
32243
32386
|
async function removeManifest(stateDir) {
|
|
32244
|
-
await
|
|
32387
|
+
await unlink10(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
|
|
32245
32388
|
(error) => {
|
|
32246
32389
|
if (error.code !== "ENOENT") throw error;
|
|
32247
32390
|
}
|
|
@@ -32265,7 +32408,7 @@ async function ensureOwnerOnlyDir(path5) {
|
|
|
32265
32408
|
await mkdir13(path5, { recursive: true, mode: 448 });
|
|
32266
32409
|
await chmod5(path5, 448);
|
|
32267
32410
|
}
|
|
32268
|
-
async function takeLock(name, path5, waitMs,
|
|
32411
|
+
async function takeLock(name, path5, waitMs, log17) {
|
|
32269
32412
|
const fs5 = await loadCommonAuthFs();
|
|
32270
32413
|
const started = performance.now();
|
|
32271
32414
|
let announced = false;
|
|
@@ -32290,7 +32433,7 @@ async function takeLock(name, path5, waitMs, log16) {
|
|
|
32290
32433
|
);
|
|
32291
32434
|
if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
|
|
32292
32435
|
announced = true;
|
|
32293
|
-
|
|
32436
|
+
log17.info(
|
|
32294
32437
|
`antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path5}.${lockHolderText(name)}`,
|
|
32295
32438
|
{ lock: name, path: path5 }
|
|
32296
32439
|
);
|
|
@@ -32303,7 +32446,7 @@ function lockHolderText(name) {
|
|
|
32303
32446
|
}
|
|
32304
32447
|
async function exists2(path5) {
|
|
32305
32448
|
try {
|
|
32306
|
-
await
|
|
32449
|
+
await stat10(path5);
|
|
32307
32450
|
return true;
|
|
32308
32451
|
} catch (error) {
|
|
32309
32452
|
const code2 = error.code;
|
|
@@ -32311,7 +32454,7 @@ async function exists2(path5) {
|
|
|
32311
32454
|
throw error;
|
|
32312
32455
|
}
|
|
32313
32456
|
}
|
|
32314
|
-
var RUNTIME_LAYOUT_LOCK_NAME, RUNTIME_LAYOUT_MANIFEST_FILE, VAULT_ENROLLMENT_STATE_FILE, VAULT_ENROLLMENT_TOKEN_FILE, VAULT_FILE_NAMES, LOCK_TTL_MS, DATA_LOCKS, LAYOUT_LOCK_WAIT_MS, LOCK_RETRY_MS, LOCK_WAIT_NOTICE_MS, MARKER_READ_ATTEMPTS, MARKER_READ_RETRY_MS, SHARING_RETRY_DELAYS_MS, SHARING_RETRY_BUDGET_MS, RUNTIME_LAYOUT_DEFERRED_MESSAGE, ACCOUNT_STORE_DEFERRED_MESSAGE, ACCOUNT_STORE_LINKED_PATH_MESSAGE, RuntimeLayoutRefusal, stateKey2,
|
|
32457
|
+
var RUNTIME_LAYOUT_LOCK_NAME, RUNTIME_LAYOUT_MANIFEST_FILE, VAULT_ENROLLMENT_STATE_FILE, VAULT_ENROLLMENT_TOKEN_FILE, VAULT_FILE_NAMES, LOCK_TTL_MS, DATA_LOCKS, LAYOUT_LOCK_WAIT_MS, LOCK_RETRY_MS, LOCK_WAIT_NOTICE_MS, MARKER_READ_ATTEMPTS, MARKER_READ_RETRY_MS, SHARING_RETRY_DELAYS_MS, SHARING_RETRY_BUDGET_MS, RUNTIME_LAYOUT_DEFERRED_MESSAGE, ACCOUNT_STORE_DEFERRED_MESSAGE, ACCOUNT_STORE_LINKED_PATH_MESSAGE, RuntimeLayoutRefusal, stateKey2, globalState3, processState, LayoutMoveError, OldVaultFileKeptError, SHA256_HEX2;
|
|
32315
32458
|
var init_runtime_layout = __esm({
|
|
32316
32459
|
"src/runtime-layout.ts"() {
|
|
32317
32460
|
"use strict";
|
|
@@ -32368,8 +32511,8 @@ var init_runtime_layout = __esm({
|
|
|
32368
32511
|
errorClass;
|
|
32369
32512
|
};
|
|
32370
32513
|
stateKey2 = /* @__PURE__ */ Symbol.for("@cortexkit/antigravity-auth/runtime-layout-runs");
|
|
32371
|
-
|
|
32372
|
-
processState =
|
|
32514
|
+
globalState3 = globalThis;
|
|
32515
|
+
processState = globalState3[stateKey2] ?? {
|
|
32373
32516
|
runs: /* @__PURE__ */ new Map(),
|
|
32374
32517
|
storeRuns: /* @__PURE__ */ new Map(),
|
|
32375
32518
|
logged: /* @__PURE__ */ new Set()
|
|
@@ -32377,7 +32520,7 @@ var init_runtime_layout = __esm({
|
|
|
32377
32520
|
processState.runs ??= /* @__PURE__ */ new Map();
|
|
32378
32521
|
processState.storeRuns ??= /* @__PURE__ */ new Map();
|
|
32379
32522
|
processState.logged ??= /* @__PURE__ */ new Set();
|
|
32380
|
-
|
|
32523
|
+
globalState3[stateKey2] = processState;
|
|
32381
32524
|
LayoutMoveError = class extends Error {
|
|
32382
32525
|
constructor(code2, message) {
|
|
32383
32526
|
super(message);
|
|
@@ -32438,7 +32581,7 @@ async function ensureGitignore(configDir) {
|
|
|
32438
32581
|
`,
|
|
32439
32582
|
"utf-8"
|
|
32440
32583
|
);
|
|
32441
|
-
|
|
32584
|
+
log6.info("Created .gitignore in config directory");
|
|
32442
32585
|
} else {
|
|
32443
32586
|
const suffix = content.endsWith("\n") ? "" : "\n";
|
|
32444
32587
|
await fs.appendFile(
|
|
@@ -32447,12 +32590,12 @@ async function ensureGitignore(configDir) {
|
|
|
32447
32590
|
`,
|
|
32448
32591
|
"utf-8"
|
|
32449
32592
|
);
|
|
32450
|
-
|
|
32593
|
+
log6.info("Updated .gitignore with missing entries", {
|
|
32451
32594
|
added: missingEntries
|
|
32452
32595
|
});
|
|
32453
32596
|
}
|
|
32454
32597
|
} catch (error) {
|
|
32455
|
-
|
|
32598
|
+
log6.warn("Failed to update .gitignore with account storage entries", {
|
|
32456
32599
|
error: String(error)
|
|
32457
32600
|
});
|
|
32458
32601
|
}
|
|
@@ -32487,21 +32630,21 @@ function migrateLegacyWindowsConfig() {
|
|
|
32487
32630
|
mkdirSync(newConfigDir, { recursive: true });
|
|
32488
32631
|
try {
|
|
32489
32632
|
renameSync3(legacyPath, newPath);
|
|
32490
|
-
|
|
32633
|
+
log6.info("Migrated Windows config via rename", {
|
|
32491
32634
|
from: legacyPath,
|
|
32492
32635
|
to: newPath
|
|
32493
32636
|
});
|
|
32494
32637
|
} catch {
|
|
32495
32638
|
copyFileSync(legacyPath, newPath);
|
|
32496
32639
|
unlinkSync(legacyPath);
|
|
32497
|
-
|
|
32640
|
+
log6.info("Migrated Windows config via copy+delete", {
|
|
32498
32641
|
from: legacyPath,
|
|
32499
32642
|
to: newPath
|
|
32500
32643
|
});
|
|
32501
32644
|
}
|
|
32502
32645
|
return true;
|
|
32503
32646
|
} catch (error) {
|
|
32504
|
-
|
|
32647
|
+
log6.warn("Failed to migrate legacy Windows config, will use legacy path", {
|
|
32505
32648
|
legacyPath,
|
|
32506
32649
|
newPath,
|
|
32507
32650
|
error: String(error)
|
|
@@ -32534,7 +32677,7 @@ function getStoragePathWithMigration() {
|
|
|
32534
32677
|
);
|
|
32535
32678
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
32536
32679
|
if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
|
|
32537
|
-
|
|
32680
|
+
log6.info("Using legacy Windows config path (migration failed)", {
|
|
32538
32681
|
legacyPath,
|
|
32539
32682
|
newPath
|
|
32540
32683
|
});
|
|
@@ -32702,18 +32845,18 @@ async function clearAccounts() {
|
|
|
32702
32845
|
} catch (error) {
|
|
32703
32846
|
const code2 = error.code;
|
|
32704
32847
|
if (code2 !== "ENOENT") {
|
|
32705
|
-
|
|
32848
|
+
log6.error("Failed to clear account storage", { error: String(error) });
|
|
32706
32849
|
}
|
|
32707
32850
|
}
|
|
32708
32851
|
}
|
|
32709
|
-
var
|
|
32852
|
+
var log6, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
|
|
32710
32853
|
var init_storage = __esm({
|
|
32711
32854
|
"src/plugin/storage.ts"() {
|
|
32712
32855
|
"use strict";
|
|
32713
32856
|
init_dist();
|
|
32714
32857
|
init_runtime_paths();
|
|
32715
32858
|
init_logger4();
|
|
32716
|
-
|
|
32859
|
+
log6 = createLogger4("storage");
|
|
32717
32860
|
mutateAccountStorage2 = async (path5, mutate) => {
|
|
32718
32861
|
await assertLegacyPoolInUse(path5);
|
|
32719
32862
|
return mutateAccountStorage(path5, mutate);
|
|
@@ -33657,15 +33800,15 @@ function initLogger3(client) {
|
|
|
33657
33800
|
}
|
|
33658
33801
|
function createLogger4(module) {
|
|
33659
33802
|
let channel3;
|
|
33660
|
-
const
|
|
33803
|
+
const log17 = (level, message, extra) => {
|
|
33661
33804
|
channel3 ??= getLegacyLogger().createLogger(module);
|
|
33662
33805
|
channel3[level](message, extra);
|
|
33663
33806
|
};
|
|
33664
33807
|
return {
|
|
33665
|
-
debug: (message, extra) =>
|
|
33666
|
-
info: (message, extra) =>
|
|
33667
|
-
warn: (message, extra) =>
|
|
33668
|
-
error: (message, extra) =>
|
|
33808
|
+
debug: (message, extra) => log17("debug", message, extra),
|
|
33809
|
+
info: (message, extra) => log17("info", message, extra),
|
|
33810
|
+
warn: (message, extra) => log17("warn", message, extra),
|
|
33811
|
+
error: (message, extra) => log17("error", message, extra)
|
|
33669
33812
|
};
|
|
33670
33813
|
}
|
|
33671
33814
|
var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
|
|
@@ -34501,7 +34644,7 @@ init_storage();
|
|
|
34501
34644
|
// src/plugin/token.ts
|
|
34502
34645
|
init_dist();
|
|
34503
34646
|
init_logger4();
|
|
34504
|
-
var
|
|
34647
|
+
var log7 = createLogger4("token");
|
|
34505
34648
|
function parseOAuthErrorPayload(text2) {
|
|
34506
34649
|
if (!text2) {
|
|
34507
34650
|
return {};
|
|
@@ -34584,13 +34727,13 @@ async function exchangeRefreshToken(refreshToken, now) {
|
|
|
34584
34727
|
const details = [code2, description ?? errorText3].filter(Boolean).join(": ");
|
|
34585
34728
|
const baseMessage = `Antigravity token refresh failed (${response.status} ${response.statusText})`;
|
|
34586
34729
|
const message = details ? `${baseMessage} - ${details}` : baseMessage;
|
|
34587
|
-
|
|
34730
|
+
log7.warn("Token refresh failed", {
|
|
34588
34731
|
status: response.status,
|
|
34589
34732
|
code: code2,
|
|
34590
34733
|
details
|
|
34591
34734
|
});
|
|
34592
34735
|
if (code2 === "invalid_grant") {
|
|
34593
|
-
|
|
34736
|
+
log7.warn(
|
|
34594
34737
|
"Google revoked the stored refresh token - reauthentication required"
|
|
34595
34738
|
);
|
|
34596
34739
|
invalidateProjectContextCache(refreshToken);
|
|
@@ -34646,7 +34789,7 @@ async function refreshAccessToken(auth, _client, _providerId) {
|
|
|
34646
34789
|
if (error instanceof AntigravityTokenRefreshError) {
|
|
34647
34790
|
throw error;
|
|
34648
34791
|
}
|
|
34649
|
-
|
|
34792
|
+
log7.error("Unexpected token refresh error", { error: String(error) });
|
|
34650
34793
|
return void 0;
|
|
34651
34794
|
}
|
|
34652
34795
|
}
|
|
@@ -34773,7 +34916,7 @@ init_dist();
|
|
|
34773
34916
|
// src/plugin/quota.ts
|
|
34774
34917
|
init_logger4();
|
|
34775
34918
|
init_dist();
|
|
34776
|
-
var
|
|
34919
|
+
var log8 = createLogger4("quota");
|
|
34777
34920
|
function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID, options = {}) {
|
|
34778
34921
|
const fetchPoolFileQuota = makeFetchAccountQuota(
|
|
34779
34922
|
client,
|
|
@@ -34964,7 +35107,7 @@ async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActive
|
|
|
34964
35107
|
);
|
|
34965
35108
|
} catch (error) {
|
|
34966
35109
|
;
|
|
34967
|
-
(options.logger ??
|
|
35110
|
+
(options.logger ?? log8).debug("sidebar-quota-write-failed", {
|
|
34968
35111
|
error: String(error)
|
|
34969
35112
|
});
|
|
34970
35113
|
}
|
|
@@ -35330,7 +35473,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
35330
35473
|
let rotatedRefresh;
|
|
35331
35474
|
if (purpose === "advisory") {
|
|
35332
35475
|
if (accessTokenExpired(auth)) {
|
|
35333
|
-
|
|
35476
|
+
log8.debug("advisory-quota-skipped-refresh-needed");
|
|
35334
35477
|
return {
|
|
35335
35478
|
index,
|
|
35336
35479
|
email: account.email,
|
|
@@ -35342,7 +35485,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
35342
35485
|
const managedProjectId = parts.managedProjectId ?? account.managedProjectId;
|
|
35343
35486
|
const projectId = managedProjectId ?? parts.projectId ?? account.projectId;
|
|
35344
35487
|
if (!projectId) {
|
|
35345
|
-
|
|
35488
|
+
log8.debug("advisory-quota-skipped-project-needed");
|
|
35346
35489
|
return {
|
|
35347
35490
|
index,
|
|
35348
35491
|
email: account.email,
|
|
@@ -35364,7 +35507,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
35364
35507
|
{ timeoutMs: extra.timeoutMs }
|
|
35365
35508
|
);
|
|
35366
35509
|
},
|
|
35367
|
-
logger:
|
|
35510
|
+
logger: log8
|
|
35368
35511
|
}),
|
|
35369
35512
|
signal
|
|
35370
35513
|
);
|
|
@@ -35421,7 +35564,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
35421
35564
|
managedProjectId,
|
|
35422
35565
|
projectId: projectContext.effectiveProjectId,
|
|
35423
35566
|
fetchVia,
|
|
35424
|
-
logger:
|
|
35567
|
+
logger: log8
|
|
35425
35568
|
});
|
|
35426
35569
|
quotaResult = payloads.quota;
|
|
35427
35570
|
if (quotaResult.error) throw new Error(quotaResult.error);
|
|
@@ -36290,8 +36433,8 @@ async function select2(terminal, items, options) {
|
|
|
36290
36433
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
36291
36434
|
import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as randomUUID17 } from "node:crypto";
|
|
36292
36435
|
import { constants as fsConstants2 } from "node:fs";
|
|
36293
|
-
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as
|
|
36294
|
-
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as
|
|
36436
|
+
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat12, unlink as unlink11 } from "node:fs/promises";
|
|
36437
|
+
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join20, resolve as resolve19 } from "node:path";
|
|
36295
36438
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
36296
36439
|
|
|
36297
36440
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
@@ -36364,7 +36507,7 @@ init_private_files2();
|
|
|
36364
36507
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
36365
36508
|
init_private_files2();
|
|
36366
36509
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
36367
|
-
import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as
|
|
36510
|
+
import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat11 } from "node:fs/promises";
|
|
36368
36511
|
import { dirname as dirname19, join as join19 } from "node:path";
|
|
36369
36512
|
|
|
36370
36513
|
// src/common-auth-embedded/fs/with-lock.js
|
|
@@ -36618,7 +36761,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36618
36761
|
};
|
|
36619
36762
|
}
|
|
36620
36763
|
try {
|
|
36621
|
-
const current = await
|
|
36764
|
+
const current = await stat11(lockPath);
|
|
36622
36765
|
const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
|
|
36623
36766
|
if (legacyExpiry > now())
|
|
36624
36767
|
return { status: "live" };
|
|
@@ -36685,7 +36828,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36685
36828
|
if (!sameMarkerDirectory2(created, current))
|
|
36686
36829
|
return false;
|
|
36687
36830
|
try {
|
|
36688
|
-
await
|
|
36831
|
+
await stat11(evictOwnerPath);
|
|
36689
36832
|
return true;
|
|
36690
36833
|
} catch (error) {
|
|
36691
36834
|
if (error.code !== "ENOENT")
|
|
@@ -36737,7 +36880,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36737
36880
|
async function recoverStaleEvictionMarker() {
|
|
36738
36881
|
let evictStat;
|
|
36739
36882
|
try {
|
|
36740
|
-
evictStat = await
|
|
36883
|
+
evictStat = await stat11(evictPath);
|
|
36741
36884
|
} catch (error) {
|
|
36742
36885
|
if (error.code === "ENOENT")
|
|
36743
36886
|
return "missing";
|
|
@@ -36755,7 +36898,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36755
36898
|
if (evictStat.mtimeMs + EVICT_TTL > now()) {
|
|
36756
36899
|
let hasOwner = true;
|
|
36757
36900
|
try {
|
|
36758
|
-
await
|
|
36901
|
+
await stat11(evictOwnerPath);
|
|
36759
36902
|
} catch (error) {
|
|
36760
36903
|
if (error.code === "ENOENT")
|
|
36761
36904
|
hasOwner = false;
|
|
@@ -37157,9 +37300,9 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
|
|
|
37157
37300
|
}
|
|
37158
37301
|
function hostEnrollmentPaths2(input2) {
|
|
37159
37302
|
const override = input2.override?.trim();
|
|
37160
|
-
if (override && !
|
|
37303
|
+
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
37161
37304
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
37162
|
-
const tokenPath = override ?
|
|
37305
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve19(input2.cwd, override) : join20(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
37163
37306
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
37164
37307
|
}
|
|
37165
37308
|
function isRecord11(value) {
|
|
@@ -37344,7 +37487,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
|
|
|
37344
37487
|
}
|
|
37345
37488
|
let privateGroup;
|
|
37346
37489
|
for (; ; ) {
|
|
37347
|
-
const metadata = await
|
|
37490
|
+
const metadata = await stat12(component).catch(() => void 0);
|
|
37348
37491
|
if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
|
|
37349
37492
|
if (privateGroup === void 0) {
|
|
37350
37493
|
privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
|
|
@@ -37373,7 +37516,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
|
|
|
37373
37516
|
return;
|
|
37374
37517
|
}
|
|
37375
37518
|
await mkdir15(directory, { recursive: true, mode: 448 });
|
|
37376
|
-
const metadata = await
|
|
37519
|
+
const metadata = await stat12(directory);
|
|
37377
37520
|
const uid = process.geteuid?.();
|
|
37378
37521
|
if (uid !== void 0 && metadata.uid !== uid) {
|
|
37379
37522
|
throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
|
|
@@ -37409,7 +37552,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
37409
37552
|
await descriptor?.close().catch(() => {
|
|
37410
37553
|
});
|
|
37411
37554
|
if (created)
|
|
37412
|
-
await
|
|
37555
|
+
await unlink11(temporary).catch(() => {
|
|
37413
37556
|
});
|
|
37414
37557
|
}
|
|
37415
37558
|
}
|
|
@@ -37636,7 +37779,7 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
37636
37779
|
}
|
|
37637
37780
|
if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
|
|
37638
37781
|
await lock.assertOwned();
|
|
37639
|
-
await
|
|
37782
|
+
await unlink11(this.#paths.statePath).catch((cause) => {
|
|
37640
37783
|
if (cause.code !== "ENOENT")
|
|
37641
37784
|
throw cause;
|
|
37642
37785
|
});
|
|
@@ -37726,7 +37869,7 @@ async function resetClaustrumEnrollmentState2(paths, proposedName) {
|
|
|
37726
37869
|
if (state.phase === "pending")
|
|
37727
37870
|
return "refused-pending";
|
|
37728
37871
|
await lock.assertOwned();
|
|
37729
|
-
await
|
|
37872
|
+
await unlink11(paths.statePath);
|
|
37730
37873
|
return "reset";
|
|
37731
37874
|
} finally {
|
|
37732
37875
|
await lock.release();
|
|
@@ -37962,7 +38105,7 @@ function setupPaths(io = {}) {
|
|
|
37962
38105
|
}
|
|
37963
38106
|
|
|
37964
38107
|
// src/common-auth-embedded/setup/detect.js
|
|
37965
|
-
function
|
|
38108
|
+
function stat13(path5, kind) {
|
|
37966
38109
|
try {
|
|
37967
38110
|
return statSync5(path5)[kind]();
|
|
37968
38111
|
} catch {
|
|
@@ -37971,12 +38114,12 @@ function stat12(path5, kind) {
|
|
|
37971
38114
|
}
|
|
37972
38115
|
var defaultSetupFileSystem = {
|
|
37973
38116
|
exists: existsSync6,
|
|
37974
|
-
isFile: (path5) =>
|
|
37975
|
-
isDirectory: (path5) =>
|
|
38117
|
+
isFile: (path5) => stat13(path5, "isFile"),
|
|
38118
|
+
isDirectory: (path5) => stat13(path5, "isDirectory"),
|
|
37976
38119
|
isExecutable(path5) {
|
|
37977
38120
|
try {
|
|
37978
38121
|
accessSync(path5, constants3.X_OK);
|
|
37979
|
-
return
|
|
38122
|
+
return stat13(path5, "isFile");
|
|
37980
38123
|
} catch {
|
|
37981
38124
|
return false;
|
|
37982
38125
|
}
|
|
@@ -38682,7 +38825,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
|
|
|
38682
38825
|
|
|
38683
38826
|
// src/common-auth-embedded/setup/config-write.js
|
|
38684
38827
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
38685
|
-
import { mkdir as mkdir16, open as open11, rename as rename13, stat as
|
|
38828
|
+
import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat14, unlink as unlink12 } from "node:fs/promises";
|
|
38686
38829
|
import { basename as basename6, dirname as dirname21, join as join22 } from "node:path";
|
|
38687
38830
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
38688
38831
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
@@ -38692,7 +38835,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
38692
38835
|
let mode;
|
|
38693
38836
|
if (!windows2) {
|
|
38694
38837
|
try {
|
|
38695
|
-
mode = (await
|
|
38838
|
+
mode = (await stat14(file)).mode & 4095;
|
|
38696
38839
|
} catch (error) {
|
|
38697
38840
|
if (error.code !== "ENOENT")
|
|
38698
38841
|
throw error;
|
|
@@ -38728,7 +38871,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
38728
38871
|
}
|
|
38729
38872
|
} finally {
|
|
38730
38873
|
if (created)
|
|
38731
|
-
await
|
|
38874
|
+
await unlink12(stage).catch(() => {
|
|
38732
38875
|
});
|
|
38733
38876
|
}
|
|
38734
38877
|
}
|
|
@@ -39170,63 +39313,7 @@ function createV1VaultActivationMethod(input2) {
|
|
|
39170
39313
|
// src/setup.ts
|
|
39171
39314
|
init_vault_custody();
|
|
39172
39315
|
init_runtime_paths();
|
|
39173
|
-
|
|
39174
|
-
// src/vault-folder.ts
|
|
39175
|
-
init_logger4();
|
|
39176
|
-
init_process_heartbeat();
|
|
39177
|
-
init_runtime_layout();
|
|
39178
|
-
init_runtime_paths();
|
|
39179
|
-
var refusalsKey = /* @__PURE__ */ Symbol.for(
|
|
39180
|
-
"@cortexkit/antigravity-auth/vault-folder-refusals"
|
|
39181
|
-
);
|
|
39182
|
-
var globalState3 = globalThis;
|
|
39183
|
-
var refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
|
|
39184
|
-
globalState3[refusalsKey] = refusals;
|
|
39185
|
-
function locationKey() {
|
|
39186
|
-
const location = runtimeLayoutLocation();
|
|
39187
|
-
return `${location.stateHomeDir}\0${location.key}`;
|
|
39188
|
-
}
|
|
39189
|
-
async function prepareVaultFolder(options) {
|
|
39190
|
-
const { accountFile } = options;
|
|
39191
|
-
const key = locationKey();
|
|
39192
|
-
const kept = refusals.get(key);
|
|
39193
|
-
if (kept) return refused(accountFile, kept);
|
|
39194
|
-
const log16 = options.log ?? createLogger4("runtime-layout");
|
|
39195
|
-
const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
|
|
39196
|
-
try {
|
|
39197
|
-
await prepareRuntimeLayout({
|
|
39198
|
-
version,
|
|
39199
|
-
accountFile,
|
|
39200
|
-
log: log16,
|
|
39201
|
-
...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
|
|
39202
|
-
});
|
|
39203
|
-
if (options.accountStore !== false)
|
|
39204
|
-
await prepareAccountStore({ version, log: log16 });
|
|
39205
|
-
} catch (error) {
|
|
39206
|
-
const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
|
|
39207
|
-
runtimeLayoutLocation().stateHomeDir,
|
|
39208
|
-
error instanceof Error ? error.name : typeof error
|
|
39209
|
-
);
|
|
39210
|
-
if (!refusals.has(key)) {
|
|
39211
|
-
refusals.set(key, refusal3);
|
|
39212
|
-
log16.warn(refusal3.message, {
|
|
39213
|
-
stateDir: refusal3.stateDir,
|
|
39214
|
-
errorClass: refusal3.errorClass
|
|
39215
|
-
});
|
|
39216
|
-
}
|
|
39217
|
-
return refused(accountFile, refusals.get(key) ?? refusal3);
|
|
39218
|
-
}
|
|
39219
|
-
return { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
39220
|
-
}
|
|
39221
|
-
function currentVaultFolder(accountFile) {
|
|
39222
|
-
const kept = refusals.get(locationKey());
|
|
39223
|
-
return kept ? refused(accountFile, kept) : { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
39224
|
-
}
|
|
39225
|
-
function refused(accountFile, refusal3) {
|
|
39226
|
-
return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
|
|
39227
|
-
}
|
|
39228
|
-
|
|
39229
|
-
// src/setup.ts
|
|
39316
|
+
init_vault_folder();
|
|
39230
39317
|
var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
|
|
39231
39318
|
async function storePresent(anchor) {
|
|
39232
39319
|
return await pathPresent(accountStorePointerPath(anchor)) || await pathPresent(anchor);
|
|
@@ -39595,6 +39682,7 @@ async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
|
|
|
39595
39682
|
}
|
|
39596
39683
|
|
|
39597
39684
|
// src/cli.ts
|
|
39685
|
+
init_vault_folder();
|
|
39598
39686
|
var HELP = `Usage: antigravity-auth <command> [options]
|
|
39599
39687
|
|
|
39600
39688
|
Commands:
|
|
@@ -40405,8 +40493,8 @@ function getLocalDevPath(directory) {
|
|
|
40405
40493
|
}
|
|
40406
40494
|
function findPackageJsonUp(startPath) {
|
|
40407
40495
|
try {
|
|
40408
|
-
const
|
|
40409
|
-
let dir =
|
|
40496
|
+
const stat16 = fs4.statSync(startPath);
|
|
40497
|
+
let dir = stat16.isDirectory() ? startPath : path4.dirname(startPath);
|
|
40410
40498
|
for (let i = 0; i < 10; i++) {
|
|
40411
40499
|
const pkgPath = path4.join(dir, "package.json");
|
|
40412
40500
|
if (fs4.existsSync(pkgPath)) {
|
|
@@ -40716,12 +40804,12 @@ function isTuiConnected(sessionId) {
|
|
|
40716
40804
|
// src/rpc/rpc-dir.ts
|
|
40717
40805
|
import { createHash as createHash14 } from "node:crypto";
|
|
40718
40806
|
import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
|
|
40719
|
-
import { isAbsolute as
|
|
40807
|
+
import { isAbsolute as isAbsolute5, join as join28, resolve as resolve22 } from "node:path";
|
|
40720
40808
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
40721
40809
|
function getRpcDir(projectDirectory) {
|
|
40722
40810
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
40723
40811
|
if (override) {
|
|
40724
|
-
return
|
|
40812
|
+
return isAbsolute5(override) ? override : resolve22(projectDirectory, override);
|
|
40725
40813
|
}
|
|
40726
40814
|
const projectHash = createHash14("sha256").update(resolve22(projectDirectory)).digest("hex").slice(0, 16);
|
|
40727
40815
|
const stateHome = process.env.XDG_STATE_HOME ?? join28(homedir10(), ".local", "state");
|
|
@@ -40736,7 +40824,7 @@ function isSessionId(value) {
|
|
|
40736
40824
|
// src/common-auth-embedded/rpc/port-file.js
|
|
40737
40825
|
init_private_files2();
|
|
40738
40826
|
import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
|
|
40739
|
-
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as
|
|
40827
|
+
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat15, unlink as unlink13 } from "node:fs/promises";
|
|
40740
40828
|
import { join as join29, resolve as resolve23 } from "node:path";
|
|
40741
40829
|
function isProbeablePid(pid) {
|
|
40742
40830
|
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
|
|
@@ -40761,9 +40849,9 @@ function isUsablePortFileEntry(value, name) {
|
|
|
40761
40849
|
const { pid, port, token } = value;
|
|
40762
40850
|
return isProbeablePid(pid) && filenamePid(name) === pid && typeof port === "number" && Number.isInteger(port) && port >= 1 && port <= 65535 && typeof token === "string" && token.length > 0;
|
|
40763
40851
|
}
|
|
40764
|
-
async function removeCorruptPortFile(portFile,
|
|
40765
|
-
|
|
40766
|
-
await
|
|
40852
|
+
async function removeCorruptPortFile(portFile, log17) {
|
|
40853
|
+
log17?.debug("rpc corrupt port file", { pid: process.pid, portFile });
|
|
40854
|
+
await unlink13(portFile).catch(() => {
|
|
40767
40855
|
});
|
|
40768
40856
|
}
|
|
40769
40857
|
async function writePortFile(dir, entry, options = {}) {
|
|
@@ -40801,7 +40889,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
40801
40889
|
await handle?.close().catch(() => {
|
|
40802
40890
|
});
|
|
40803
40891
|
if (created)
|
|
40804
|
-
await
|
|
40892
|
+
await unlink13(tmp).catch(() => {
|
|
40805
40893
|
});
|
|
40806
40894
|
}
|
|
40807
40895
|
return target;
|
|
@@ -40815,7 +40903,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
40815
40903
|
throw error;
|
|
40816
40904
|
}
|
|
40817
40905
|
}
|
|
40818
|
-
async function sweepRpcState(root, activeDir, isManagedDir,
|
|
40906
|
+
async function sweepRpcState(root, activeDir, isManagedDir, log17) {
|
|
40819
40907
|
let projectDirs;
|
|
40820
40908
|
try {
|
|
40821
40909
|
projectDirs = await readdir4(root, { withFileTypes: true });
|
|
@@ -40856,16 +40944,16 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
40856
40944
|
try {
|
|
40857
40945
|
parsed = JSON.parse(raw);
|
|
40858
40946
|
} catch {
|
|
40859
|
-
await removeCorruptPortFile(portFile,
|
|
40947
|
+
await removeCorruptPortFile(portFile, log17);
|
|
40860
40948
|
continue;
|
|
40861
40949
|
}
|
|
40862
40950
|
if (!isUsablePortFileEntry(parsed, name)) {
|
|
40863
|
-
await removeCorruptPortFile(portFile,
|
|
40951
|
+
await removeCorruptPortFile(portFile, log17);
|
|
40864
40952
|
continue;
|
|
40865
40953
|
}
|
|
40866
40954
|
const entry = parsed;
|
|
40867
40955
|
if (!pidAlive2(entry.pid))
|
|
40868
|
-
await
|
|
40956
|
+
await unlink13(portFile).catch(() => {
|
|
40869
40957
|
});
|
|
40870
40958
|
}
|
|
40871
40959
|
if (resolve23(dir) !== active2)
|
|
@@ -40880,7 +40968,7 @@ init_private_files2();
|
|
|
40880
40968
|
// src/common-auth-embedded/rpc/rpc-server.js
|
|
40881
40969
|
init_private_files2();
|
|
40882
40970
|
import { randomBytes as randomBytes6, timingSafeEqual } from "node:crypto";
|
|
40883
|
-
import { unlink as
|
|
40971
|
+
import { unlink as unlink14 } from "node:fs/promises";
|
|
40884
40972
|
import { createServer as createServer2 } from "node:http";
|
|
40885
40973
|
import { join as join30 } from "node:path";
|
|
40886
40974
|
var RpcRequestError = class extends Error {
|
|
@@ -40955,7 +41043,7 @@ function tokenOk(header, token) {
|
|
|
40955
41043
|
async function startRpcServer(options) {
|
|
40956
41044
|
if (typeof options.drain === "function" === (typeof options.drainAsync === "function"))
|
|
40957
41045
|
throw new TypeError("exactly one of drain or drainAsync must be provided");
|
|
40958
|
-
const
|
|
41046
|
+
const log17 = options.log ?? { warn() {
|
|
40959
41047
|
}, debug() {
|
|
40960
41048
|
} };
|
|
40961
41049
|
const token = randomBytes6(32).toString("hex");
|
|
@@ -41056,7 +41144,7 @@ async function startRpcServer(options) {
|
|
|
41056
41144
|
return json(400, { error: "session required" });
|
|
41057
41145
|
if (sessionId === void 0 && !warnedMissingNotificationSession) {
|
|
41058
41146
|
warnedMissingNotificationSession = true;
|
|
41059
|
-
|
|
41147
|
+
log17.warn("rpc notification drain missing session id", {
|
|
41060
41148
|
pid: process.pid
|
|
41061
41149
|
});
|
|
41062
41150
|
}
|
|
@@ -41065,7 +41153,7 @@ async function startRpcServer(options) {
|
|
|
41065
41153
|
try {
|
|
41066
41154
|
messages = await options.drainAsync(lastReceivedId, sessionId);
|
|
41067
41155
|
} catch (error) {
|
|
41068
|
-
|
|
41156
|
+
log17.warn("rpc notification drain failed", {
|
|
41069
41157
|
pid: process.pid,
|
|
41070
41158
|
error: error instanceof Error ? error.message : String(error)
|
|
41071
41159
|
});
|
|
@@ -41084,20 +41172,20 @@ async function startRpcServer(options) {
|
|
|
41084
41172
|
return json(404, { error: "unknown method" });
|
|
41085
41173
|
} catch (error) {
|
|
41086
41174
|
if (error instanceof RpcRequestError) {
|
|
41087
|
-
|
|
41175
|
+
log17.debug("rpc request refused", {
|
|
41088
41176
|
pid: process.pid,
|
|
41089
41177
|
status: error.status
|
|
41090
41178
|
});
|
|
41091
41179
|
return json(error.status, { error: error.message });
|
|
41092
41180
|
}
|
|
41093
41181
|
if (error instanceof ApplyDeadlineError) {
|
|
41094
|
-
|
|
41182
|
+
log17.warn("rpc apply deadline exceeded", {
|
|
41095
41183
|
pid: process.pid,
|
|
41096
41184
|
deadlineMs: options.applyDeadlineMs
|
|
41097
41185
|
});
|
|
41098
41186
|
return json(504, { error: "handler deadline exceeded" });
|
|
41099
41187
|
}
|
|
41100
|
-
|
|
41188
|
+
log17.warn("rpc request failed", {
|
|
41101
41189
|
pid: process.pid,
|
|
41102
41190
|
error: error instanceof Error ? error.message : String(error)
|
|
41103
41191
|
});
|
|
@@ -41117,9 +41205,9 @@ async function startRpcServer(options) {
|
|
|
41117
41205
|
server.unref();
|
|
41118
41206
|
if (options.sweepRoot) {
|
|
41119
41207
|
try {
|
|
41120
|
-
await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir,
|
|
41208
|
+
await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log17);
|
|
41121
41209
|
} catch (error) {
|
|
41122
|
-
|
|
41210
|
+
log17.warn("rpc state sweep failed", {
|
|
41123
41211
|
pid: process.pid,
|
|
41124
41212
|
error: error instanceof Error ? error.message : String(error)
|
|
41125
41213
|
});
|
|
@@ -41127,7 +41215,7 @@ async function startRpcServer(options) {
|
|
|
41127
41215
|
}
|
|
41128
41216
|
try {
|
|
41129
41217
|
await writePortFile(options.dir, { port, token, pid: process.pid }, { secureDir: options.secureDir });
|
|
41130
|
-
|
|
41218
|
+
log17.debug("rpc server pid", {
|
|
41131
41219
|
pid: process.pid,
|
|
41132
41220
|
rpcPort: port
|
|
41133
41221
|
});
|
|
@@ -41152,7 +41240,7 @@ async function startRpcServer(options) {
|
|
|
41152
41240
|
return void 0;
|
|
41153
41241
|
});
|
|
41154
41242
|
if (current?.port === port && current.token === token)
|
|
41155
|
-
await
|
|
41243
|
+
await unlink14(portFile).catch(() => {
|
|
41156
41244
|
});
|
|
41157
41245
|
}
|
|
41158
41246
|
};
|
|
@@ -41227,6 +41315,9 @@ function parsePending(value) {
|
|
|
41227
41315
|
};
|
|
41228
41316
|
}
|
|
41229
41317
|
|
|
41318
|
+
// src/plugin/index.ts
|
|
41319
|
+
init_vault_folder();
|
|
41320
|
+
|
|
41230
41321
|
// src/plugin/account-access.ts
|
|
41231
41322
|
init_dist();
|
|
41232
41323
|
|
|
@@ -43276,10 +43367,10 @@ function toV1AuthCallbackResult(result) {
|
|
|
43276
43367
|
};
|
|
43277
43368
|
}
|
|
43278
43369
|
var MAX_OAUTH_ACCOUNTS = 10;
|
|
43279
|
-
var
|
|
43280
|
-
async function reportPersistenceFailure(error, client,
|
|
43370
|
+
var log9 = createLogger4("oauth-methods");
|
|
43371
|
+
async function reportPersistenceFailure(error, client, log17) {
|
|
43281
43372
|
const message = error instanceof AccountStorageUnreadableError ? `Account storage at ${error.details.path} is unreadable (${error.details.reason}: ${error.details.detail}).${error.details.backupPath ? ` A backup was written to ${error.details.backupPath}. Repair or remove the existing file before retrying.` : " A backup could not be written; repair or remove the existing file before retrying."}` : error instanceof Error ? error.message : String(error);
|
|
43282
|
-
|
|
43373
|
+
log17.error("OAuth login persistence failed; aborting login", {
|
|
43283
43374
|
error: message
|
|
43284
43375
|
});
|
|
43285
43376
|
try {
|
|
@@ -44116,7 +44207,7 @@ ${verifyUrl}
|
|
|
44116
44207
|
}
|
|
44117
44208
|
});
|
|
44118
44209
|
} catch (storeError) {
|
|
44119
|
-
|
|
44210
|
+
log9.error(
|
|
44120
44211
|
"Failed to update stored Antigravity OAuth credentials",
|
|
44121
44212
|
{ error: String(storeError) }
|
|
44122
44213
|
);
|
|
@@ -44141,7 +44232,7 @@ ${verifyUrl}
|
|
|
44141
44232
|
}
|
|
44142
44233
|
});
|
|
44143
44234
|
} catch (storeError) {
|
|
44144
|
-
|
|
44235
|
+
log9.error(
|
|
44145
44236
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
44146
44237
|
{ error: String(storeError) }
|
|
44147
44238
|
);
|
|
@@ -44182,7 +44273,7 @@ Re-authenticating ${refreshEmail || "account"}...
|
|
|
44182
44273
|
}
|
|
44183
44274
|
});
|
|
44184
44275
|
} catch (storeError) {
|
|
44185
|
-
|
|
44276
|
+
log9.error(
|
|
44186
44277
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
44187
44278
|
{ error: String(storeError) }
|
|
44188
44279
|
);
|
|
@@ -44521,7 +44612,7 @@ ${authorization2.url}
|
|
|
44521
44612
|
return await reportPersistenceFailure(
|
|
44522
44613
|
persistError,
|
|
44523
44614
|
client,
|
|
44524
|
-
|
|
44615
|
+
log9
|
|
44525
44616
|
);
|
|
44526
44617
|
}
|
|
44527
44618
|
const newTotal = existingCount + 1;
|
|
@@ -44565,7 +44656,7 @@ ${authorization2.url}
|
|
|
44565
44656
|
try {
|
|
44566
44657
|
await persistAccountPool2([result], false);
|
|
44567
44658
|
} catch (persistError) {
|
|
44568
|
-
return await reportPersistenceFailure(persistError, client,
|
|
44659
|
+
return await reportPersistenceFailure(persistError, client, log9);
|
|
44569
44660
|
}
|
|
44570
44661
|
const newTotal = existingCount + 1;
|
|
44571
44662
|
const toastMessage = existingCount > 0 ? `Added account${result.email ? ` (${result.email})` : ""} - ${newTotal} total` : `Authenticated${result.email ? ` (${result.email})` : ""}`;
|
|
@@ -44728,7 +44819,7 @@ init_logger4();
|
|
|
44728
44819
|
|
|
44729
44820
|
// src/plugin/refresh-queue.ts
|
|
44730
44821
|
init_logger4();
|
|
44731
|
-
var
|
|
44822
|
+
var log10 = createLogger4("refresh-queue");
|
|
44732
44823
|
var DEFAULT_PROACTIVE_REFRESH_CONFIG = {
|
|
44733
44824
|
enabled: true,
|
|
44734
44825
|
bufferSeconds: 1800,
|
|
@@ -44768,7 +44859,7 @@ var ProactiveRefreshQueue = class {
|
|
|
44768
44859
|
"ProactiveRefreshQueue needs a host client or explicit dependencies"
|
|
44769
44860
|
);
|
|
44770
44861
|
}
|
|
44771
|
-
this.log =
|
|
44862
|
+
this.log = log10;
|
|
44772
44863
|
this.refresh = (auth) => refreshAccessToken(auth, client, providerId);
|
|
44773
44864
|
}
|
|
44774
44865
|
this.config = {
|
|
@@ -45856,7 +45947,7 @@ function getUserConfigPath() {
|
|
|
45856
45947
|
function getProjectConfigPath(directory) {
|
|
45857
45948
|
return join33(directory, ".opencode", "antigravity.json");
|
|
45858
45949
|
}
|
|
45859
|
-
function loadConfigFile(path5,
|
|
45950
|
+
function loadConfigFile(path5, log17) {
|
|
45860
45951
|
try {
|
|
45861
45952
|
if (!existsSync11(path5)) {
|
|
45862
45953
|
return null;
|
|
@@ -45865,7 +45956,7 @@ function loadConfigFile(path5, log16) {
|
|
|
45865
45956
|
const rawConfig = JSON.parse(content);
|
|
45866
45957
|
const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
|
|
45867
45958
|
if (!result.success) {
|
|
45868
|
-
|
|
45959
|
+
log17.warn("Config validation error", {
|
|
45869
45960
|
path: path5,
|
|
45870
45961
|
issues: result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ")
|
|
45871
45962
|
});
|
|
@@ -45874,9 +45965,9 @@ function loadConfigFile(path5, log16) {
|
|
|
45874
45965
|
return result.data;
|
|
45875
45966
|
} catch (error) {
|
|
45876
45967
|
if (error instanceof SyntaxError) {
|
|
45877
|
-
|
|
45968
|
+
log17.warn("Invalid JSON in config file", { path: path5, error: error.message });
|
|
45878
45969
|
} else {
|
|
45879
|
-
|
|
45970
|
+
log17.warn("Failed to load config file", { path: path5, error: String(error) });
|
|
45880
45971
|
}
|
|
45881
45972
|
return null;
|
|
45882
45973
|
}
|
|
@@ -45895,15 +45986,15 @@ function mergeConfigs(base, override) {
|
|
|
45895
45986
|
function loadConfig(directory) {
|
|
45896
45987
|
return loadConfigWithLogger(directory, legacyLog);
|
|
45897
45988
|
}
|
|
45898
|
-
function loadConfigWithLogger(directory,
|
|
45989
|
+
function loadConfigWithLogger(directory, log17) {
|
|
45899
45990
|
let config = structuredClone(DEFAULT_CONFIG);
|
|
45900
45991
|
const userConfigPath = getUserConfigPath();
|
|
45901
|
-
const userConfig = loadConfigFile(userConfigPath,
|
|
45992
|
+
const userConfig = loadConfigFile(userConfigPath, log17);
|
|
45902
45993
|
if (userConfig) {
|
|
45903
45994
|
config = mergeConfigs(config, userConfig);
|
|
45904
45995
|
}
|
|
45905
45996
|
const projectConfigPath = getProjectConfigPath(directory);
|
|
45906
|
-
const projectConfig = loadConfigFile(projectConfigPath,
|
|
45997
|
+
const projectConfig = loadConfigFile(projectConfigPath, log17);
|
|
45907
45998
|
if (projectConfig) {
|
|
45908
45999
|
config = mergeConfigs(config, projectConfig);
|
|
45909
46000
|
}
|
|
@@ -47312,8 +47403,8 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
47312
47403
|
if (!sessionID) return false;
|
|
47313
47404
|
let assistantMsgID = info.id;
|
|
47314
47405
|
let msgs;
|
|
47315
|
-
const
|
|
47316
|
-
|
|
47406
|
+
const log17 = createLogger4("session-recovery");
|
|
47407
|
+
log17.debug("Recovery attempt started", {
|
|
47317
47408
|
errorType,
|
|
47318
47409
|
sessionID,
|
|
47319
47410
|
providedMsgID: assistantMsgID ?? "none"
|
|
@@ -47333,7 +47424,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
47333
47424
|
const m = msgs[i];
|
|
47334
47425
|
if (m && m.info?.role === "assistant" && m.info?.id) {
|
|
47335
47426
|
assistantMsgID = m.info.id;
|
|
47336
|
-
|
|
47427
|
+
log17.debug("Found assistant message ID from session messages", {
|
|
47337
47428
|
msgID: assistantMsgID,
|
|
47338
47429
|
msgIndex: i
|
|
47339
47430
|
});
|
|
@@ -47342,7 +47433,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
47342
47433
|
}
|
|
47343
47434
|
}
|
|
47344
47435
|
if (!assistantMsgID) {
|
|
47345
|
-
|
|
47436
|
+
log17.debug("No assistant message ID found, cannot recover");
|
|
47346
47437
|
return false;
|
|
47347
47438
|
}
|
|
47348
47439
|
if (processingErrors.has(assistantMsgID)) return false;
|
|
@@ -47386,7 +47477,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
47386
47477
|
}
|
|
47387
47478
|
return success;
|
|
47388
47479
|
} catch (err) {
|
|
47389
|
-
|
|
47480
|
+
log17.error("Recovery failed", { error: String(err) });
|
|
47390
47481
|
return false;
|
|
47391
47482
|
} finally {
|
|
47392
47483
|
processingErrors.delete(assistantMsgID);
|
|
@@ -47406,7 +47497,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
47406
47497
|
// src/plugin/request-helpers.ts
|
|
47407
47498
|
init_dist();
|
|
47408
47499
|
init_logger4();
|
|
47409
|
-
var
|
|
47500
|
+
var log11 = createLogger4("request-helpers");
|
|
47410
47501
|
var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
|
|
47411
47502
|
function appendDescriptionHint(schema, hint) {
|
|
47412
47503
|
if (!schema || typeof schema !== "object") {
|
|
@@ -47831,7 +47922,7 @@ function filterContentArray(contentArray, sessionId, getCachedSignatureFn, isCla
|
|
|
47831
47922
|
}
|
|
47832
47923
|
const existingSignature = item.signature || item.thoughtSignature;
|
|
47833
47924
|
const signatureInfo = existingSignature ? `foreign signature (${String(existingSignature).length} chars)` : "no signature";
|
|
47834
|
-
|
|
47925
|
+
log11.debug(
|
|
47835
47926
|
`Injecting plain text sentinel for last-message thinking block with ${signatureInfo}`
|
|
47836
47927
|
);
|
|
47837
47928
|
const sentinel2 = { text: "." };
|
|
@@ -48343,7 +48434,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
|
|
|
48343
48434
|
if (lastBracket > 0) {
|
|
48344
48435
|
const cleaned = stripped.slice(0, lastBracket + 1);
|
|
48345
48436
|
const parsed = JSON.parse(cleaned);
|
|
48346
|
-
|
|
48437
|
+
log11.debug("Auto-corrected malformed JSON array", {
|
|
48347
48438
|
truncatedChars: stripped.length - cleaned.length
|
|
48348
48439
|
});
|
|
48349
48440
|
return recursivelyParseJsonStrings(parsed);
|
|
@@ -48357,7 +48448,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
|
|
|
48357
48448
|
if (lastBrace > 0) {
|
|
48358
48449
|
const cleaned = stripped.slice(0, lastBrace + 1);
|
|
48359
48450
|
const parsed = JSON.parse(cleaned);
|
|
48360
|
-
|
|
48451
|
+
log11.debug("Auto-corrected malformed JSON object", {
|
|
48361
48452
|
truncatedChars: stripped.length - cleaned.length
|
|
48362
48453
|
});
|
|
48363
48454
|
return recursivelyParseJsonStrings(parsed);
|
|
@@ -48457,7 +48548,7 @@ function fixToolResponseGrouping(contents) {
|
|
|
48457
48548
|
if (orphanResp.functionResponse.name === "unknown_function" && expectedName) {
|
|
48458
48549
|
orphanResp.functionResponse.name = expectedName;
|
|
48459
48550
|
}
|
|
48460
|
-
|
|
48551
|
+
log11.debug("Auto-repaired tool ID mismatch", {
|
|
48461
48552
|
mappedFrom: matchedId,
|
|
48462
48553
|
mappedTo: expectedId,
|
|
48463
48554
|
functionName: expectedName
|
|
@@ -48477,7 +48568,7 @@ function fixToolResponseGrouping(contents) {
|
|
|
48477
48568
|
id: expectedId
|
|
48478
48569
|
}
|
|
48479
48570
|
};
|
|
48480
|
-
|
|
48571
|
+
log11.debug("Created placeholder response for missing tool", {
|
|
48481
48572
|
id: expectedId,
|
|
48482
48573
|
name: expectedName
|
|
48483
48574
|
});
|
|
@@ -48795,7 +48886,7 @@ function applyToolPairingFixes(payload, isClaude) {
|
|
|
48795
48886
|
);
|
|
48796
48887
|
payload.contents = fixToolResponseGrouping(contentsWithMatchedIds);
|
|
48797
48888
|
contentsFixed = true;
|
|
48798
|
-
|
|
48889
|
+
log11.debug("Applied tool pairing fixes to contents[]", {
|
|
48799
48890
|
originalLength: payload.contents.length
|
|
48800
48891
|
});
|
|
48801
48892
|
}
|
|
@@ -48804,7 +48895,7 @@ function applyToolPairingFixes(payload, isClaude) {
|
|
|
48804
48895
|
payload.messages
|
|
48805
48896
|
);
|
|
48806
48897
|
messagesFixed = true;
|
|
48807
|
-
|
|
48898
|
+
log11.debug("Applied tool pairing fixes to messages[]", {
|
|
48808
48899
|
originalLength: payload.messages.length
|
|
48809
48900
|
});
|
|
48810
48901
|
}
|
|
@@ -49043,7 +49134,7 @@ init_dist();
|
|
|
49043
49134
|
init_dist();
|
|
49044
49135
|
|
|
49045
49136
|
// src/plugin/request.ts
|
|
49046
|
-
var
|
|
49137
|
+
var log12 = createLogger4("request");
|
|
49047
49138
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
49048
49139
|
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext("");
|
|
49049
49140
|
var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
|
|
@@ -49842,7 +49933,7 @@ var openCode1WireLocation = {
|
|
|
49842
49933
|
logAntigravityDebugResponse: (context, response, meta) => logAntigravityDebugResponse(context, response, meta),
|
|
49843
49934
|
logCacheStats: (model, cacheRead, cacheWrite, totalInput) => logCacheStats(model, cacheRead, cacheWrite, totalInput)
|
|
49844
49935
|
},
|
|
49845
|
-
logger:
|
|
49936
|
+
logger: log12,
|
|
49846
49937
|
sessionFingerprint: () => getSessionFingerprint(),
|
|
49847
49938
|
displayedThinkingHashes: sessionDisplayedThinkingHashes,
|
|
49848
49939
|
cacheStats: { last: null }
|
|
@@ -50994,7 +51085,7 @@ function publishResponse(dispatch) {
|
|
|
50994
51085
|
|
|
50995
51086
|
// src/plugin/auth-loader.ts
|
|
50996
51087
|
init_storage();
|
|
50997
|
-
var
|
|
51088
|
+
var log13 = createLogger4("auth-loader");
|
|
50998
51089
|
function refreshTokenIdentity(refreshToken) {
|
|
50999
51090
|
return createHash18("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
51000
51091
|
}
|
|
@@ -51141,7 +51232,7 @@ function createAuthLoader({
|
|
|
51141
51232
|
});
|
|
51142
51233
|
refreshQueue = deps.createStoreRefreshQueue(
|
|
51143
51234
|
{
|
|
51144
|
-
logger:
|
|
51235
|
+
logger: log13,
|
|
51145
51236
|
refreshToken: (_auth, account) => credentials.refresh(account)
|
|
51146
51237
|
},
|
|
51147
51238
|
queueConfig
|
|
@@ -51249,7 +51340,7 @@ function createAuthLoader({
|
|
|
51249
51340
|
}
|
|
51250
51341
|
if (opening.status === "ready") {
|
|
51251
51342
|
if (!isOAuthAuth(auth) && !readAuthority) {
|
|
51252
|
-
|
|
51343
|
+
log13.warn(
|
|
51253
51344
|
"The host holds no Antigravity sign-in; the account store is left untouched"
|
|
51254
51345
|
);
|
|
51255
51346
|
return {};
|
|
@@ -51262,7 +51353,7 @@ function createAuthLoader({
|
|
|
51262
51353
|
}
|
|
51263
51354
|
if (!usesPoolFile(opening)) {
|
|
51264
51355
|
const message = opening.status === "refused" || opening.status === "recovery-required" ? opening.message : "The Antigravity account store cannot be opened";
|
|
51265
|
-
|
|
51356
|
+
log13.error("Refusing to start: the account store cannot serve", {
|
|
51266
51357
|
message
|
|
51267
51358
|
});
|
|
51268
51359
|
try {
|
|
@@ -51279,7 +51370,7 @@ function createAuthLoader({
|
|
|
51279
51370
|
storedAccounts = await deps.loadAccounts();
|
|
51280
51371
|
} catch (error) {
|
|
51281
51372
|
if (error instanceof AccountStorageUnreadableError) {
|
|
51282
|
-
|
|
51373
|
+
log13.error("Refusing to start: account storage is unreadable", {
|
|
51283
51374
|
path: error.details.path,
|
|
51284
51375
|
reason: error.details.reason,
|
|
51285
51376
|
backupPath: error.details.backupPath
|
|
@@ -51311,12 +51402,12 @@ function createAuthLoader({
|
|
|
51311
51402
|
expires: auth.expires ?? 0
|
|
51312
51403
|
}
|
|
51313
51404
|
});
|
|
51314
|
-
|
|
51405
|
+
log13.info("Restored Antigravity OAuth auth from account storage", {
|
|
51315
51406
|
reason: drift.reason,
|
|
51316
51407
|
email: drift.account.email
|
|
51317
51408
|
});
|
|
51318
51409
|
} catch (error) {
|
|
51319
|
-
|
|
51410
|
+
log13.warn(
|
|
51320
51411
|
"Failed to restore Antigravity OAuth auth from account storage",
|
|
51321
51412
|
{ error: String(error) }
|
|
51322
51413
|
);
|
|
@@ -53577,7 +53668,6 @@ var AgySessionRegistry = class {
|
|
|
53577
53668
|
};
|
|
53578
53669
|
|
|
53579
53670
|
// src/plugin/shared/vault-routing.ts
|
|
53580
|
-
var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
|
|
53581
53671
|
function hasVaultRoutingAccessor() {
|
|
53582
53672
|
try {
|
|
53583
53673
|
return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
|
|
@@ -53595,7 +53685,7 @@ function routingExhaustionFields(scope) {
|
|
|
53595
53685
|
window: scope.limitWindow === "five_hour" ? "5h" : "7d"
|
|
53596
53686
|
};
|
|
53597
53687
|
}
|
|
53598
|
-
function reportVaultExhaustion(input2,
|
|
53688
|
+
function reportVaultExhaustion(input2, report = reportRouting) {
|
|
53599
53689
|
if (!hasVaultRoutingAccessor() || input2.signal?.aborted || input2.status !== 429 || input2.reason !== "QUOTA_EXHAUSTED" || !Number.isFinite(input2.observedAt) || (input2.observedAt ?? 0) <= 0 || (input2.observedAt ?? Infinity) > Date.now())
|
|
53600
53690
|
return;
|
|
53601
53691
|
for (const window of input2.quota?.windows ?? []) {
|
|
@@ -53603,13 +53693,12 @@ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCO
|
|
|
53603
53693
|
const scope = routingQuotaScope(input2.group, window.window);
|
|
53604
53694
|
const resetsAt = Date.parse(window.resetTime);
|
|
53605
53695
|
if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
|
|
53606
|
-
|
|
53607
|
-
|
|
53608
|
-
|
|
53609
|
-
|
|
53610
|
-
|
|
53611
|
-
|
|
53612
|
-
});
|
|
53696
|
+
report({
|
|
53697
|
+
...input2.identity,
|
|
53698
|
+
outcome: "exhausted",
|
|
53699
|
+
...routingExhaustionFields(scope),
|
|
53700
|
+
resetsAt
|
|
53701
|
+
});
|
|
53613
53702
|
}
|
|
53614
53703
|
}
|
|
53615
53704
|
var RATE_LIMIT_HEADERS = [
|
|
@@ -53882,7 +53971,7 @@ function sleep4(ms, signal) {
|
|
|
53882
53971
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
53883
53972
|
});
|
|
53884
53973
|
}
|
|
53885
|
-
function createLocalQuotaRefresh(accountManager, quotaManager,
|
|
53974
|
+
function createLocalQuotaRefresh(accountManager, quotaManager, log17) {
|
|
53886
53975
|
return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
|
|
53887
53976
|
if (intervalMinutes <= 0) return;
|
|
53888
53977
|
const accountIndex = accountManager.getAccounts().indexOf(account);
|
|
@@ -53913,7 +54002,7 @@ function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
|
|
|
53913
54002
|
accountManager.requestSaveToDisk();
|
|
53914
54003
|
}
|
|
53915
54004
|
} catch (err) {
|
|
53916
|
-
|
|
54005
|
+
log17.debug(
|
|
53917
54006
|
`quota-refresh-failed ${singleAccount ? quotaManager.hashedLogLabel("account", singleAccount) : `idx-${accountIndex}`}`,
|
|
53918
54007
|
{ error: String(err) }
|
|
53919
54008
|
);
|
|
@@ -53931,7 +54020,7 @@ function createRequestExecutor(deps) {
|
|
|
53931
54020
|
wire,
|
|
53932
54021
|
debug,
|
|
53933
54022
|
dump,
|
|
53934
|
-
logger:
|
|
54023
|
+
logger: log17,
|
|
53935
54024
|
trackers,
|
|
53936
54025
|
classifyAccessError,
|
|
53937
54026
|
notify,
|
|
@@ -53950,7 +54039,7 @@ function createRequestExecutor(deps) {
|
|
|
53950
54039
|
const reportVault401 = (admission, status) => {
|
|
53951
54040
|
if (!admission || status !== 401) return;
|
|
53952
54041
|
void Promise.resolve().then(() => admission.report401(status)).catch((error) => {
|
|
53953
|
-
|
|
54042
|
+
log17.debug("send-admission-401-report-failed", { error: String(error) });
|
|
53954
54043
|
});
|
|
53955
54044
|
};
|
|
53956
54045
|
const reportRouting2 = (sessionId, entry) => {
|
|
@@ -53958,7 +54047,7 @@ function createRequestExecutor(deps) {
|
|
|
53958
54047
|
try {
|
|
53959
54048
|
onRouting(sessionId, entry);
|
|
53960
54049
|
} catch (error) {
|
|
53961
|
-
|
|
54050
|
+
log17.debug("routing-report-failed", { sessionId, error: String(error) });
|
|
53962
54051
|
}
|
|
53963
54052
|
};
|
|
53964
54053
|
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
|
|
@@ -54089,7 +54178,7 @@ function createRequestExecutor(deps) {
|
|
|
54089
54178
|
const quietMode = config.quiet_mode;
|
|
54090
54179
|
const toastScope = config.toast_scope;
|
|
54091
54180
|
const showToast = async (message, variant2) => {
|
|
54092
|
-
|
|
54181
|
+
log17.debug("toast", {
|
|
54093
54182
|
message,
|
|
54094
54183
|
variant: variant2,
|
|
54095
54184
|
isChildSession: isChildRequest,
|
|
@@ -54098,7 +54187,7 @@ function createRequestExecutor(deps) {
|
|
|
54098
54187
|
if (quietMode) return;
|
|
54099
54188
|
if (abortSignal?.aborted) return;
|
|
54100
54189
|
if (toastScope === "root_only" && isChildRequest) {
|
|
54101
|
-
|
|
54190
|
+
log17.debug("toast-suppressed-child-session", {
|
|
54102
54191
|
message,
|
|
54103
54192
|
variant: variant2,
|
|
54104
54193
|
parentID: requestSessionIdentity.parentSessionId
|
|
@@ -54171,7 +54260,7 @@ function createRequestExecutor(deps) {
|
|
|
54171
54260
|
});
|
|
54172
54261
|
} catch (error) {
|
|
54173
54262
|
if (error instanceof AntigravityKillswitchError) {
|
|
54174
|
-
|
|
54263
|
+
log17.warn("killswitch-all-excluded", {
|
|
54175
54264
|
family,
|
|
54176
54265
|
model,
|
|
54177
54266
|
threshold: error.thresholdPercent,
|
|
@@ -54196,7 +54285,7 @@ function createRequestExecutor(deps) {
|
|
|
54196
54285
|
pushDebug(
|
|
54197
54286
|
`model-unavailable: all ${candidates.length} eligible account(s) skipped`
|
|
54198
54287
|
);
|
|
54199
|
-
|
|
54288
|
+
log17.warn("model-unavailable-all-accounts", {
|
|
54200
54289
|
family,
|
|
54201
54290
|
model,
|
|
54202
54291
|
accounts: candidates.length
|
|
@@ -54435,7 +54524,7 @@ function createRequestExecutor(deps) {
|
|
|
54435
54524
|
await deadline.wait(() => credentials.saveToDisk());
|
|
54436
54525
|
} catch (error) {
|
|
54437
54526
|
checkAborted();
|
|
54438
|
-
|
|
54527
|
+
log17.error("Failed to persist project context", {
|
|
54439
54528
|
error: String(error)
|
|
54440
54529
|
});
|
|
54441
54530
|
}
|
|
@@ -54492,7 +54581,7 @@ function createRequestExecutor(deps) {
|
|
|
54492
54581
|
await deadline.wait(() => credentials.saveToDisk());
|
|
54493
54582
|
} catch (error) {
|
|
54494
54583
|
checkAborted();
|
|
54495
|
-
|
|
54584
|
+
log17.error("Failed to persist refreshed auth", {
|
|
54496
54585
|
error: String(error)
|
|
54497
54586
|
});
|
|
54498
54587
|
}
|
|
@@ -54501,14 +54590,14 @@ function createRequestExecutor(deps) {
|
|
|
54501
54590
|
if (credentials.isInvalidGrant(error)) {
|
|
54502
54591
|
const removed = credentials.removeAccount(account);
|
|
54503
54592
|
if (removed) {
|
|
54504
|
-
|
|
54593
|
+
log17.warn(
|
|
54505
54594
|
"Removed revoked account from pool - reauthenticate via `opencode auth login`"
|
|
54506
54595
|
);
|
|
54507
54596
|
try {
|
|
54508
54597
|
await deadline.wait(() => credentials.saveToDiskReplace());
|
|
54509
54598
|
} catch (persistError) {
|
|
54510
54599
|
checkAborted();
|
|
54511
|
-
|
|
54600
|
+
log17.error("Failed to persist revoked account removal", {
|
|
54512
54601
|
error: String(persistError)
|
|
54513
54602
|
});
|
|
54514
54603
|
}
|
|
@@ -54518,7 +54607,7 @@ function createRequestExecutor(deps) {
|
|
|
54518
54607
|
await deadline.wait(() => credentials.clearStoredAuth());
|
|
54519
54608
|
} catch (storeError) {
|
|
54520
54609
|
checkAborted();
|
|
54521
|
-
|
|
54610
|
+
log17.error(
|
|
54522
54611
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
54523
54612
|
{
|
|
54524
54613
|
error: String(storeError)
|
|
@@ -54912,7 +55001,7 @@ function createRequestExecutor(deps) {
|
|
|
54912
55001
|
);
|
|
54913
55002
|
} catch (error) {
|
|
54914
55003
|
checkAborted();
|
|
54915
|
-
|
|
55004
|
+
log17.debug("send-admission-401-report-failed", {
|
|
54916
55005
|
error: String(error)
|
|
54917
55006
|
});
|
|
54918
55007
|
}
|
|
@@ -55149,7 +55238,7 @@ function createRequestExecutor(deps) {
|
|
|
55149
55238
|
debug.logAntigravityDebugResponse(debugContext, response, {
|
|
55150
55239
|
note
|
|
55151
55240
|
});
|
|
55152
|
-
|
|
55241
|
+
log17.info("model-unavailable", {
|
|
55153
55242
|
accountIndex: account.index,
|
|
55154
55243
|
family,
|
|
55155
55244
|
model,
|
|
@@ -55604,11 +55693,11 @@ function createRequestExecutor(deps) {
|
|
|
55604
55693
|
cancellation.signal,
|
|
55605
55694
|
deps.preResponseClock
|
|
55606
55695
|
);
|
|
55607
|
-
|
|
55696
|
+
log17.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
|
|
55608
55697
|
const handoff = createAfterHandoff(
|
|
55609
55698
|
advisoryWork,
|
|
55610
55699
|
requestedSignal ? [requestedSignal, shutdown.signal] : [shutdown.signal],
|
|
55611
|
-
() =>
|
|
55700
|
+
() => log17.debug("post-response-advisory-work-failed")
|
|
55612
55701
|
);
|
|
55613
55702
|
const waitPolicy = {};
|
|
55614
55703
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
@@ -55626,7 +55715,7 @@ function createRequestExecutor(deps) {
|
|
|
55626
55715
|
).catch((error) => {
|
|
55627
55716
|
cancellation.signal.throwIfAborted();
|
|
55628
55717
|
if (error instanceof PreResponseTimeoutError) {
|
|
55629
|
-
|
|
55718
|
+
log17.debug("pre-response-timeout", { reason: error.reason });
|
|
55630
55719
|
return waitPolicy.refusal?.() ?? preResponseTimeoutResponse();
|
|
55631
55720
|
}
|
|
55632
55721
|
throw error;
|
|
@@ -55833,7 +55922,7 @@ function parseDurationToMs(duration) {
|
|
|
55833
55922
|
|
|
55834
55923
|
// src/plugin/fetch-interceptor.ts
|
|
55835
55924
|
init_vault_request_credentials();
|
|
55836
|
-
var
|
|
55925
|
+
var log14 = createLogger4("fetch-interceptor");
|
|
55837
55926
|
var defaultAgyTransport = (url, init, options) => fetchWithAgyCliTransport(url, init, options);
|
|
55838
55927
|
var defaultFetchImpl = (input2, init) => globalThis.fetch(input2, init);
|
|
55839
55928
|
function poolFileCredentials(accountManager, client, providerId) {
|
|
@@ -55886,14 +55975,14 @@ function openCode1EngineCollaborators(common) {
|
|
|
55886
55975
|
// the engine calls.
|
|
55887
55976
|
debug: debug_exports,
|
|
55888
55977
|
dump: { dumpRequest: dumpGeminiRequest },
|
|
55889
|
-
logger:
|
|
55978
|
+
logger: log14,
|
|
55890
55979
|
classifyAccessError: extractAccountAccessErrorDetails,
|
|
55891
55980
|
notify: (message, variant) => client.tui.showToast({ body: { message, variant } }),
|
|
55892
55981
|
onRouting: common.onRouting ?? ((sessionId, entry) => {
|
|
55893
55982
|
void upsertSidebarActiveRouting(sessionId, entry, {
|
|
55894
55983
|
authoritative: true
|
|
55895
55984
|
}).catch((error) => {
|
|
55896
|
-
|
|
55985
|
+
log14.debug("sidebar-routing-upsert-failed", {
|
|
55897
55986
|
sessionId,
|
|
55898
55987
|
error: String(error)
|
|
55899
55988
|
});
|
|
@@ -55919,7 +56008,7 @@ function createFetchInterceptor(context) {
|
|
|
55919
56008
|
const refreshQuotaAfterSuccess = createLocalQuotaRefresh(
|
|
55920
56009
|
accountManager,
|
|
55921
56010
|
quotaManager,
|
|
55922
|
-
|
|
56011
|
+
log14
|
|
55923
56012
|
);
|
|
55924
56013
|
const executor = createRequestExecutor({
|
|
55925
56014
|
assertAdmission: context.assertAdmission,
|
|
@@ -56065,7 +56154,7 @@ init_logger4();
|
|
|
56065
56154
|
// src/plugin/search.ts
|
|
56066
56155
|
import crypto3 from "node:crypto";
|
|
56067
56156
|
init_logger4();
|
|
56068
|
-
var
|
|
56157
|
+
var log15 = createLogger4("search");
|
|
56069
56158
|
var sessionCounter = 0;
|
|
56070
56159
|
var sessionPrefix = `search-${Date.now().toString(36)}`;
|
|
56071
56160
|
function generateRequestId() {
|
|
@@ -56197,7 +56286,7 @@ ${urlList}`;
|
|
|
56197
56286
|
requestType: "agent"
|
|
56198
56287
|
};
|
|
56199
56288
|
const url = `${ANTIGRAVITY_ENDPOINT}/v1internal:generateContent`;
|
|
56200
|
-
|
|
56289
|
+
log15.debug("Executing search", {
|
|
56201
56290
|
query,
|
|
56202
56291
|
urlCount: urls?.length ?? 0,
|
|
56203
56292
|
thinking
|
|
@@ -56220,7 +56309,7 @@ ${urlList}`;
|
|
|
56220
56309
|
);
|
|
56221
56310
|
if (!response.ok) {
|
|
56222
56311
|
const errorText3 = await response.text();
|
|
56223
|
-
|
|
56312
|
+
log15.debug("Search API error", {
|
|
56224
56313
|
status: response.status,
|
|
56225
56314
|
error: errorText3
|
|
56226
56315
|
});
|
|
@@ -56233,14 +56322,14 @@ ${errorText3}
|
|
|
56233
56322
|
Please try again with a different query.`;
|
|
56234
56323
|
}
|
|
56235
56324
|
const data = await response.json();
|
|
56236
|
-
|
|
56325
|
+
log15.debug("Search response received", { hasResponse: !!data.response });
|
|
56237
56326
|
const result = parseSearchResponse(data);
|
|
56238
56327
|
const formatted = formatSearchResult(result);
|
|
56239
|
-
|
|
56328
|
+
log15.debug("Search response formatted", { resultLength: formatted.length });
|
|
56240
56329
|
return formatted;
|
|
56241
56330
|
} catch (error) {
|
|
56242
56331
|
const message = error instanceof Error ? error.message : String(error);
|
|
56243
|
-
|
|
56332
|
+
log15.debug("Search execution error", { error: message });
|
|
56244
56333
|
return `## Search Error
|
|
56245
56334
|
|
|
56246
56335
|
Failed to execute search: ${message}. Please try again with a different query.`;
|
|
@@ -56248,7 +56337,7 @@ Failed to execute search: ${message}. Please try again with a different query.`;
|
|
|
56248
56337
|
}
|
|
56249
56338
|
|
|
56250
56339
|
// src/plugin/google-search-tool.ts
|
|
56251
|
-
var
|
|
56340
|
+
var log16 = createLogger4("plugin");
|
|
56252
56341
|
function createGoogleSearchTool({
|
|
56253
56342
|
getAuth,
|
|
56254
56343
|
client,
|
|
@@ -56270,7 +56359,7 @@ function createGoogleSearchTool({
|
|
|
56270
56359
|
if (mayStartLocalWork && !await mayStartLocalWork()) {
|
|
56271
56360
|
return "Google Search is not available through local credentials while vault custody is active or unreadable.";
|
|
56272
56361
|
}
|
|
56273
|
-
|
|
56362
|
+
log16.debug("Google Search tool called", {
|
|
56274
56363
|
query: args.query,
|
|
56275
56364
|
urlCount: args.urls?.length ?? 0
|
|
56276
56365
|
});
|