@cortexkit/opencode-antigravity-auth 3.0.10 → 3.0.11
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 +319 -111
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +48 -23
- package/dist/index.js +457 -211
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +55 -30
- package/dist/server.js +457 -211
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +27 -0
- package/dist/src/common-auth-embedded/fs/private-files.d.ts +2 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +49 -3
- package/dist/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/dist/src/common-auth-embedded/setup/enroll.js +116 -34
- package/dist/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/dist/src/common-auth-embedded/setup/process-fence.js +56 -1
- package/dist/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/dist/src/common-auth-embedded/source-output.json +45 -37
- package/dist/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.js +48 -27
- package/dist/src/plugin/lifecycle.js.map +1 -1
- package/dist/src/plugin/shared/request-services.js +2 -2
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +13 -3
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/tui-build-map.json +5 -5
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/dist/types/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +27 -0
- package/src/common-auth-embedded/fs/private-files.d.ts +2 -0
- package/src/common-auth-embedded/fs/private-files.js +49 -3
- package/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/src/common-auth-embedded/setup/enroll.js +116 -34
- package/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
- package/src/common-auth-embedded/setup/process-fence.js +56 -1
- package/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/src/common-auth-embedded/source-output.json +45 -37
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +49 -3
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +49 -3
package/dist/server.js
CHANGED
|
@@ -764,7 +764,8 @@ var init_identity = __esm({
|
|
|
764
764
|
// ../core/dist/common-auth-embedded/fs/private-files.js
|
|
765
765
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
766
766
|
import { lstat as lstat2, readFile as readFile4, rename as rename3, unlink as unlink5 } from "node:fs/promises";
|
|
767
|
-
import {
|
|
767
|
+
import { tmpdir } from "node:os";
|
|
768
|
+
import { dirname as dirname5, join as join4, resolve as resolve2 } from "node:path";
|
|
768
769
|
function ioCode(detail) {
|
|
769
770
|
if (detail?.reason === "io-error") {
|
|
770
771
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -774,8 +775,31 @@ function ioCode(detail) {
|
|
|
774
775
|
}
|
|
775
776
|
return detail?.code ?? "ERR_PRIVATE_FILE";
|
|
776
777
|
}
|
|
778
|
+
function privateFilesUnavailable(cause) {
|
|
779
|
+
return Object.assign(new Error("Windows private-files native addon is unavailable", { cause }), {
|
|
780
|
+
code: "ERR_PRIVATE_FILES_UNAVAILABLE",
|
|
781
|
+
reason: PRIVATE_FILES_UNAVAILABLE_REASON
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function isUnavailable(api, error) {
|
|
785
|
+
return error instanceof api.PrivateFilesUnavailableError || error?.code === "ERR_PRIVATE_FILES_UNAVAILABLE";
|
|
786
|
+
}
|
|
787
|
+
async function assertNativeAddonLoads(api) {
|
|
788
|
+
try {
|
|
789
|
+
await api.verifyPrivatePath(join4(tmpdir(), `.common-auth-private-files-probe-${randomUUID7()}`), "file");
|
|
790
|
+
} catch (error) {
|
|
791
|
+
if (isUnavailable(api, error))
|
|
792
|
+
throw privateFilesUnavailable(error);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
777
795
|
function loadBackend() {
|
|
778
|
-
backend ??= import("@cortexkit/private-files")
|
|
796
|
+
backend ??= import("@cortexkit/private-files").then(async (api) => {
|
|
797
|
+
if (windowsPrivateFiles)
|
|
798
|
+
await assertNativeAddonLoads(api);
|
|
799
|
+
return api;
|
|
800
|
+
}, (cause) => {
|
|
801
|
+
throw windowsPrivateFiles ? privateFilesUnavailable(cause) : cause;
|
|
802
|
+
});
|
|
779
803
|
return backend;
|
|
780
804
|
}
|
|
781
805
|
async function privateOperation(path5, stage, operation) {
|
|
@@ -1001,12 +1025,13 @@ async function writePrivateAtomic(path5, bytes, options = {}) {
|
|
|
1001
1025
|
});
|
|
1002
1026
|
}
|
|
1003
1027
|
}
|
|
1004
|
-
var windowsPrivateFiles, migrationNotices, backend, PrivateFileError, safeParentOptionsForTest;
|
|
1028
|
+
var windowsPrivateFiles, migrationNotices, backend, PRIVATE_FILES_UNAVAILABLE_REASON, PrivateFileError, safeParentOptionsForTest;
|
|
1005
1029
|
var init_private_files = __esm({
|
|
1006
1030
|
"../core/dist/common-auth-embedded/fs/private-files.js"() {
|
|
1007
1031
|
"use strict";
|
|
1008
1032
|
windowsPrivateFiles = process.platform === "win32";
|
|
1009
1033
|
migrationNotices = /* @__PURE__ */ new Set();
|
|
1034
|
+
PRIVATE_FILES_UNAVAILABLE_REASON = "native-addon-unavailable";
|
|
1010
1035
|
PrivateFileError = class extends Error {
|
|
1011
1036
|
path;
|
|
1012
1037
|
stage;
|
|
@@ -1021,7 +1046,7 @@ var init_private_files = __esm({
|
|
|
1021
1046
|
orphanPath;
|
|
1022
1047
|
constructor(path5, stage, cause) {
|
|
1023
1048
|
const detail = cause;
|
|
1024
|
-
super(`Private file refused at ${stage}: ${path5} (${detail?.reason ?? detail?.code ?? "io-error"}).
|
|
1049
|
+
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path5} (${PRIVATE_FILES_UNAVAILABLE_REASON}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.` : `Private file refused at ${stage}: ${path5} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
|
|
1025
1050
|
this.path = path5;
|
|
1026
1051
|
this.stage = stage;
|
|
1027
1052
|
this.name = "PrivateFileError";
|
|
@@ -1132,7 +1157,7 @@ var init_atomic_write = __esm({
|
|
|
1132
1157
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
1133
1158
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
1134
1159
|
import { mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename5, rm as rm4, stat as stat3 } from "node:fs/promises";
|
|
1135
|
-
import { dirname as dirname7, join as
|
|
1160
|
+
import { dirname as dirname7, join as join5 } from "node:path";
|
|
1136
1161
|
async function createExclusiveText(path5, text2) {
|
|
1137
1162
|
const handle = await open4(path5, "wx", 384);
|
|
1138
1163
|
try {
|
|
@@ -1150,7 +1175,7 @@ function acquireRefreshFileLock(options) {
|
|
|
1150
1175
|
}
|
|
1151
1176
|
async function acquireRefreshFileLockWithClock(options) {
|
|
1152
1177
|
const lockPath = lockPathFor(options.path, options.name);
|
|
1153
|
-
const legacyOwnerPath =
|
|
1178
|
+
const legacyOwnerPath = join5(lockPath, "owner.json");
|
|
1154
1179
|
const ownerId = randomUUID9();
|
|
1155
1180
|
const now = options.now ?? Date.now;
|
|
1156
1181
|
let renewTimer = null;
|
|
@@ -1193,7 +1218,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
1193
1218
|
let terminalIOError;
|
|
1194
1219
|
let renewalInFlight = null;
|
|
1195
1220
|
const evictPath = `${lockPath}.evicting`;
|
|
1196
|
-
const evictOwnerPath =
|
|
1221
|
+
const evictOwnerPath = join5(evictPath, "owner.json");
|
|
1197
1222
|
const evictOwnerId = randomUUID9();
|
|
1198
1223
|
const EVICT_TTL = 5e3;
|
|
1199
1224
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
@@ -8862,7 +8887,7 @@ var init_any_signal = __esm({
|
|
|
8862
8887
|
import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
|
|
8863
8888
|
import { constants as fsConstants } from "node:fs";
|
|
8864
8889
|
import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename6, stat as stat4, unlink as unlink6 } from "node:fs/promises";
|
|
8865
|
-
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as
|
|
8890
|
+
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve5 } from "node:path";
|
|
8866
8891
|
import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
8867
8892
|
function classifyEnrollmentError(error) {
|
|
8868
8893
|
if (!(error instanceof ClaustrumCredentialError2))
|
|
@@ -8888,7 +8913,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
|
|
|
8888
8913
|
const extension = extname(tokenPath) || ".json";
|
|
8889
8914
|
const stem = basename3(tokenPath, extname(tokenPath));
|
|
8890
8915
|
return {
|
|
8891
|
-
statePath:
|
|
8916
|
+
statePath: join6(dirname9(tokenPath), `${stem}-state${extension}`),
|
|
8892
8917
|
tokenPath
|
|
8893
8918
|
};
|
|
8894
8919
|
}
|
|
@@ -8896,7 +8921,7 @@ function hostEnrollmentPaths(input2) {
|
|
|
8896
8921
|
const override = input2.override?.trim();
|
|
8897
8922
|
if (override && !isAbsolute2(override) && !input2.cwd)
|
|
8898
8923
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
8899
|
-
const tokenPath = override ? isAbsolute2(override) ? override : resolve5(input2.cwd, override) :
|
|
8924
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve5(input2.cwd, override) : join6(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
8900
8925
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
8901
8926
|
}
|
|
8902
8927
|
function isRecord6(value) {
|
|
@@ -9129,7 +9154,7 @@ async function writeStateAtomic(path5, state, ancestorOptions = {}) {
|
|
|
9129
9154
|
}
|
|
9130
9155
|
if (windowsPrivateFiles)
|
|
9131
9156
|
return writePrivateAtomic(path5, bytes);
|
|
9132
|
-
const temporary =
|
|
9157
|
+
const temporary = join6(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
|
|
9133
9158
|
let descriptor;
|
|
9134
9159
|
let created = false;
|
|
9135
9160
|
try {
|
|
@@ -9306,7 +9331,7 @@ async function disconnectClaustrumEnrollment(paths, proposedName) {
|
|
|
9306
9331
|
await lock.release();
|
|
9307
9332
|
}
|
|
9308
9333
|
}
|
|
9309
|
-
var ENROLLMENT_SCHEMA, ENROLLMENT_FILE_MAX_BYTES, ENROLLMENT_LOCK_TTL_MS, TOKEN_RE, TERMINAL_ENROLLMENT_CODES, RETRYABLE_ENROLLMENT_CODES, ClaustrumEnrollmentManager;
|
|
9334
|
+
var ENROLLMENT_SCHEMA, ENROLLMENT_FILE_MAX_BYTES, ENROLLMENT_LOCK_TTL_MS, TOKEN_RE, UNSUPPORTED_ENROLLMENT_CODE, TERMINAL_ENROLLMENT_CODES, RETRYABLE_ENROLLMENT_CODES, ClaustrumEnrollmentManager;
|
|
9310
9335
|
var init_enrollment = __esm({
|
|
9311
9336
|
"../core/dist/common-auth-embedded/claustrum/enrollment.js"() {
|
|
9312
9337
|
"use strict";
|
|
@@ -9317,7 +9342,13 @@ var init_enrollment = __esm({
|
|
|
9317
9342
|
ENROLLMENT_FILE_MAX_BYTES = 16 * 1024;
|
|
9318
9343
|
ENROLLMENT_LOCK_TTL_MS = 3e4;
|
|
9319
9344
|
TOKEN_RE = /^[0-9a-f]{64}$/;
|
|
9345
|
+
UNSUPPORTED_ENROLLMENT_CODE = "unknown_method";
|
|
9320
9346
|
TERMINAL_ENROLLMENT_CODES = /* @__PURE__ */ new Set([
|
|
9347
|
+
// The daemon's answer to an operation it does not implement: a vault built
|
|
9348
|
+
// before the enrollment ceremony. It arrives as a transport Error frame with
|
|
9349
|
+
// no class, which claustrum-client before 0.13.0 labels transient/retry, but
|
|
9350
|
+
// asking again can never succeed.
|
|
9351
|
+
UNSUPPORTED_ENROLLMENT_CODE,
|
|
9321
9352
|
"invalid_params",
|
|
9322
9353
|
"pending_exists",
|
|
9323
9354
|
"not_found",
|
|
@@ -9451,6 +9482,18 @@ var init_enrollment = __esm({
|
|
|
9451
9482
|
retryCode: refusal3.code
|
|
9452
9483
|
};
|
|
9453
9484
|
}
|
|
9485
|
+
if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE) {
|
|
9486
|
+
await lock.assertOwned();
|
|
9487
|
+
await unlink6(this.#paths.statePath).catch((cause) => {
|
|
9488
|
+
if (cause.code !== "ENOENT")
|
|
9489
|
+
throw cause;
|
|
9490
|
+
});
|
|
9491
|
+
return {
|
|
9492
|
+
state: "unavailable",
|
|
9493
|
+
proposedName: state.proposedName,
|
|
9494
|
+
code: refusal3.code
|
|
9495
|
+
};
|
|
9496
|
+
}
|
|
9454
9497
|
return this.#block(state, refusal3.code);
|
|
9455
9498
|
}
|
|
9456
9499
|
}
|
|
@@ -22495,15 +22538,15 @@ async function redactCredentialResponse(response, credentials, bufferedBody, pro
|
|
|
22495
22538
|
|
|
22496
22539
|
// ../core/dist/pi-paths.js
|
|
22497
22540
|
import { homedir } from "node:os";
|
|
22498
|
-
import { dirname as dirname11, join as
|
|
22541
|
+
import { dirname as dirname11, join as join7 } from "node:path";
|
|
22499
22542
|
function getPiConfigDir() {
|
|
22500
|
-
return process.env.PI_AGENT_DIR?.trim() ||
|
|
22543
|
+
return process.env.PI_AGENT_DIR?.trim() || join7(homedir(), ".pi", "agent");
|
|
22501
22544
|
}
|
|
22502
22545
|
function getPiAntigravityAuthFile() {
|
|
22503
|
-
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() ||
|
|
22546
|
+
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join7(getPiConfigDir(), "antigravity-accounts.json");
|
|
22504
22547
|
}
|
|
22505
22548
|
function getPiAntigravityVaultDir() {
|
|
22506
|
-
return
|
|
22549
|
+
return join7(dirname11(getPiAntigravityAuthFile()), "antigravity-auth-vault");
|
|
22507
22550
|
}
|
|
22508
22551
|
|
|
22509
22552
|
// ../core/dist/pre-response-deadline.js
|
|
@@ -23239,11 +23282,16 @@ function mostConstrainedWindow(windows2) {
|
|
|
23239
23282
|
};
|
|
23240
23283
|
}
|
|
23241
23284
|
function poolForBucketId(bucketId) {
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23285
|
+
switch (bucketId) {
|
|
23286
|
+
case "gemini-5h":
|
|
23287
|
+
case "gemini-weekly":
|
|
23288
|
+
return "gemini";
|
|
23289
|
+
case "3p-5h":
|
|
23290
|
+
case "3p-weekly":
|
|
23291
|
+
return "non-gemini";
|
|
23292
|
+
default:
|
|
23293
|
+
return null;
|
|
23294
|
+
}
|
|
23247
23295
|
}
|
|
23248
23296
|
function parseDescriptionModelCount(description) {
|
|
23249
23297
|
const prefixMatch = description.match(/^[^:]+:\s*/);
|
|
@@ -23264,31 +23312,60 @@ function windowDurationMs(window) {
|
|
|
23264
23312
|
}
|
|
23265
23313
|
}
|
|
23266
23314
|
function aggregateQuotaSummary(response) {
|
|
23267
|
-
const
|
|
23268
|
-
|
|
23315
|
+
const windowsByPool = {
|
|
23316
|
+
gemini: /* @__PURE__ */ new Map(),
|
|
23317
|
+
"non-gemini": /* @__PURE__ */ new Map()
|
|
23318
|
+
};
|
|
23319
|
+
const modelCounts = {
|
|
23320
|
+
gemini: 0,
|
|
23321
|
+
"non-gemini": 0
|
|
23322
|
+
};
|
|
23323
|
+
const seenBucketIds = /* @__PURE__ */ new Set();
|
|
23324
|
+
const duplicateBucketIds = /* @__PURE__ */ new Set();
|
|
23269
23325
|
for (const group of response.groups) {
|
|
23270
|
-
const
|
|
23326
|
+
const contributingPools = /* @__PURE__ */ new Set();
|
|
23271
23327
|
for (const bucket of group.buckets) {
|
|
23272
|
-
|
|
23273
|
-
|
|
23328
|
+
if (bucket.disabled === true)
|
|
23329
|
+
continue;
|
|
23330
|
+
const pool = poolForBucketId(bucket.bucketId);
|
|
23331
|
+
if (!pool)
|
|
23274
23332
|
continue;
|
|
23275
|
-
|
|
23333
|
+
contributingPools.add(pool);
|
|
23334
|
+
const window = {
|
|
23276
23335
|
window: bucket.window,
|
|
23277
23336
|
remainingFraction: normalizeRemainingFraction(bucket.remainingFraction),
|
|
23278
23337
|
resetTime: bucket.resetTime
|
|
23279
|
-
}
|
|
23338
|
+
};
|
|
23339
|
+
const previous = windowsByPool[pool].get(bucket.bucketId);
|
|
23340
|
+
if (seenBucketIds.has(bucket.bucketId)) {
|
|
23341
|
+
duplicateBucketIds.add(bucket.bucketId);
|
|
23342
|
+
} else {
|
|
23343
|
+
seenBucketIds.add(bucket.bucketId);
|
|
23344
|
+
}
|
|
23345
|
+
if (!previous || window.remainingFraction < previous.remainingFraction) {
|
|
23346
|
+
windowsByPool[pool].set(bucket.bucketId, window);
|
|
23347
|
+
}
|
|
23280
23348
|
}
|
|
23349
|
+
const modelCount = group.description ? parseDescriptionModelCount(group.description) : 0;
|
|
23350
|
+
for (const pool of contributingPools)
|
|
23351
|
+
modelCounts[pool] += modelCount;
|
|
23352
|
+
}
|
|
23353
|
+
if (duplicateBucketIds.size > 0) {
|
|
23354
|
+
log4.debug("duplicate quota summary bucket ids", {
|
|
23355
|
+
bucketIds: [...duplicateBucketIds].sort()
|
|
23356
|
+
});
|
|
23357
|
+
}
|
|
23358
|
+
const groups = {};
|
|
23359
|
+
let totalCount = 0;
|
|
23360
|
+
for (const pool of ["gemini", "non-gemini"]) {
|
|
23361
|
+
const windows2 = [...windowsByPool[pool].values()];
|
|
23281
23362
|
if (windows2.length === 0)
|
|
23282
23363
|
continue;
|
|
23283
23364
|
windows2.sort((a, b) => windowDurationMs(a.window) - windowDurationMs(b.window));
|
|
23284
23365
|
const constrained = mostConstrainedWindow(windows2);
|
|
23285
|
-
|
|
23286
|
-
if (!recognizedBucket)
|
|
23366
|
+
if (!constrained)
|
|
23287
23367
|
continue;
|
|
23288
|
-
const
|
|
23289
|
-
if (!pool || !constrained)
|
|
23290
|
-
continue;
|
|
23291
|
-
const modelCount = group.description ? parseDescriptionModelCount(group.description) : 0;
|
|
23368
|
+
const modelCount = modelCounts[pool];
|
|
23292
23369
|
groups[pool] = {
|
|
23293
23370
|
remainingFraction: constrained.remainingFraction,
|
|
23294
23371
|
resetTime: constrained.resetTime,
|
|
@@ -23651,6 +23728,7 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
23651
23728
|
}
|
|
23652
23729
|
const numericConstraintHints = [];
|
|
23653
23730
|
const inputSchema = mergeSchemaAllOf(schema, numericConstraintHints);
|
|
23731
|
+
const schemaType = typeof inputSchema.type === "string" ? inputSchema.type.toUpperCase() : void 0;
|
|
23654
23732
|
let result = {};
|
|
23655
23733
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
23656
23734
|
if (inputSchema.properties && typeof inputSchema.properties === "object") {
|
|
@@ -23659,6 +23737,12 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
23659
23737
|
}
|
|
23660
23738
|
}
|
|
23661
23739
|
for (const [key, value] of Object.entries(inputSchema)) {
|
|
23740
|
+
if (schemaType !== void 0) {
|
|
23741
|
+
if (key === "items" && schemaType !== "ARRAY")
|
|
23742
|
+
continue;
|
|
23743
|
+
if (schemaType !== "OBJECT" && ["properties", "required", "propertyOrdering"].includes(key))
|
|
23744
|
+
continue;
|
|
23745
|
+
}
|
|
23662
23746
|
if (options.claudeValidated) {
|
|
23663
23747
|
if (key === "title")
|
|
23664
23748
|
continue;
|
|
@@ -24978,6 +25062,7 @@ function createAntigravityVaultAccountSource(options) {
|
|
|
24978
25062
|
}
|
|
24979
25063
|
|
|
24980
25064
|
// ../core/dist/vault-enrollment-authority.js
|
|
25065
|
+
var UNSUPPORTED_VAULT_CODE = "unknown_method";
|
|
24981
25066
|
var VAULT_ACCOUNT_REMEDY = "Vault account access is unavailable. Connect accounts in the vault, or disconnect the vault to use local accounts.";
|
|
24982
25067
|
async function enrollmentAuthority2(paths, proposedName, reader) {
|
|
24983
25068
|
try {
|
|
@@ -25336,7 +25421,8 @@ import { dirname as dirname13, resolve as resolve10 } from "node:path";
|
|
|
25336
25421
|
// src/common-auth-embedded/fs/private-files.js
|
|
25337
25422
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
25338
25423
|
import { lstat as lstat4, readFile as readFile8, rename as rename7, unlink as unlink8 } from "node:fs/promises";
|
|
25339
|
-
import {
|
|
25424
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
25425
|
+
import { dirname as dirname12, join as join8, resolve as resolve9 } from "node:path";
|
|
25340
25426
|
var windowsPrivateFiles2 = process.platform === "win32";
|
|
25341
25427
|
var migrationNotices2 = /* @__PURE__ */ new Set();
|
|
25342
25428
|
function ioCode2(detail) {
|
|
@@ -25349,8 +25435,32 @@ function ioCode2(detail) {
|
|
|
25349
25435
|
return detail?.code ?? "ERR_PRIVATE_FILE";
|
|
25350
25436
|
}
|
|
25351
25437
|
var backend2;
|
|
25438
|
+
var PRIVATE_FILES_UNAVAILABLE_REASON2 = "native-addon-unavailable";
|
|
25439
|
+
function privateFilesUnavailable2(cause) {
|
|
25440
|
+
return Object.assign(new Error("Windows private-files native addon is unavailable", { cause }), {
|
|
25441
|
+
code: "ERR_PRIVATE_FILES_UNAVAILABLE",
|
|
25442
|
+
reason: PRIVATE_FILES_UNAVAILABLE_REASON2
|
|
25443
|
+
});
|
|
25444
|
+
}
|
|
25445
|
+
function isUnavailable2(api, error) {
|
|
25446
|
+
return error instanceof api.PrivateFilesUnavailableError || error?.code === "ERR_PRIVATE_FILES_UNAVAILABLE";
|
|
25447
|
+
}
|
|
25448
|
+
async function assertNativeAddonLoads2(api) {
|
|
25449
|
+
try {
|
|
25450
|
+
await api.verifyPrivatePath(join8(tmpdir2(), `.common-auth-private-files-probe-${randomUUID13()}`), "file");
|
|
25451
|
+
} catch (error) {
|
|
25452
|
+
if (isUnavailable2(api, error))
|
|
25453
|
+
throw privateFilesUnavailable2(error);
|
|
25454
|
+
}
|
|
25455
|
+
}
|
|
25352
25456
|
function loadBackend2() {
|
|
25353
|
-
backend2 ??= import("@cortexkit/private-files")
|
|
25457
|
+
backend2 ??= import("@cortexkit/private-files").then(async (api) => {
|
|
25458
|
+
if (windowsPrivateFiles2)
|
|
25459
|
+
await assertNativeAddonLoads2(api);
|
|
25460
|
+
return api;
|
|
25461
|
+
}, (cause) => {
|
|
25462
|
+
throw windowsPrivateFiles2 ? privateFilesUnavailable2(cause) : cause;
|
|
25463
|
+
});
|
|
25354
25464
|
return backend2;
|
|
25355
25465
|
}
|
|
25356
25466
|
var PrivateFileError2 = class extends Error {
|
|
@@ -25367,7 +25477,7 @@ var PrivateFileError2 = class extends Error {
|
|
|
25367
25477
|
orphanPath;
|
|
25368
25478
|
constructor(path5, stage, cause) {
|
|
25369
25479
|
const detail = cause;
|
|
25370
|
-
super(`Private file refused at ${stage}: ${path5} (${detail?.reason ?? detail?.code ?? "io-error"}).
|
|
25480
|
+
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path5} (${PRIVATE_FILES_UNAVAILABLE_REASON2}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.` : `Private file refused at ${stage}: ${path5} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
|
|
25371
25481
|
this.path = path5;
|
|
25372
25482
|
this.stage = stage;
|
|
25373
25483
|
this.name = "PrivateFileError";
|
|
@@ -25983,7 +26093,7 @@ import {
|
|
|
25983
26093
|
unlinkSync as unlinkSync2
|
|
25984
26094
|
} from "node:fs";
|
|
25985
26095
|
import { homedir as homedir3 } from "node:os";
|
|
25986
|
-
import { join as
|
|
26096
|
+
import { join as join10 } from "node:path";
|
|
25987
26097
|
import { env } from "node:process";
|
|
25988
26098
|
|
|
25989
26099
|
// src/plugin/logging-utils.ts
|
|
@@ -26120,7 +26230,7 @@ import {
|
|
|
26120
26230
|
writeFileSync
|
|
26121
26231
|
} from "node:fs";
|
|
26122
26232
|
import { homedir as homedir2 } from "node:os";
|
|
26123
|
-
import { dirname as dirname14, join as
|
|
26233
|
+
import { dirname as dirname14, join as join9, resolve as resolve11 } from "node:path";
|
|
26124
26234
|
var log5 = createLogger4("storage");
|
|
26125
26235
|
var mutateAccountStorage2 = async (path5, mutate) => {
|
|
26126
26236
|
await assertLegacyPoolInUse(path5);
|
|
@@ -26136,7 +26246,7 @@ var GITIGNORE_ENTRIES = [
|
|
|
26136
26246
|
"antigravity-logs/"
|
|
26137
26247
|
];
|
|
26138
26248
|
async function ensureGitignore(configDir) {
|
|
26139
|
-
const gitignorePath =
|
|
26249
|
+
const gitignorePath = join9(configDir, ".gitignore");
|
|
26140
26250
|
try {
|
|
26141
26251
|
let content;
|
|
26142
26252
|
let existingLines = [];
|
|
@@ -26182,7 +26292,7 @@ async function ensureGitignore(configDir) {
|
|
|
26182
26292
|
}
|
|
26183
26293
|
}
|
|
26184
26294
|
function ensureGitignoreSync(configDir) {
|
|
26185
|
-
const gitignorePath =
|
|
26295
|
+
const gitignorePath = join9(configDir, ".gitignore");
|
|
26186
26296
|
try {
|
|
26187
26297
|
let content;
|
|
26188
26298
|
let existingLines = [];
|
|
@@ -26221,8 +26331,8 @@ function ensureGitignoreSync(configDir) {
|
|
|
26221
26331
|
}
|
|
26222
26332
|
}
|
|
26223
26333
|
function getLegacyWindowsConfigDir() {
|
|
26224
|
-
return
|
|
26225
|
-
process.env.APPDATA ||
|
|
26334
|
+
return join9(
|
|
26335
|
+
process.env.APPDATA || join9(homedir2(), "AppData", "Roaming"),
|
|
26226
26336
|
"opencode"
|
|
26227
26337
|
);
|
|
26228
26338
|
}
|
|
@@ -26230,15 +26340,15 @@ function getConfigDir() {
|
|
|
26230
26340
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
26231
26341
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
26232
26342
|
}
|
|
26233
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
26234
|
-
return
|
|
26343
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join9(homedir2(), ".config");
|
|
26344
|
+
return join9(xdgConfig2, "opencode");
|
|
26235
26345
|
}
|
|
26236
26346
|
function migrateLegacyWindowsConfig() {
|
|
26237
26347
|
if (process.platform !== "win32") {
|
|
26238
26348
|
return false;
|
|
26239
26349
|
}
|
|
26240
|
-
const newPath =
|
|
26241
|
-
const legacyPath =
|
|
26350
|
+
const newPath = join9(getConfigDir(), "antigravity-accounts.json");
|
|
26351
|
+
const legacyPath = join9(
|
|
26242
26352
|
getLegacyWindowsConfigDir(),
|
|
26243
26353
|
"antigravity-accounts.json"
|
|
26244
26354
|
);
|
|
@@ -26273,11 +26383,11 @@ function migrateLegacyWindowsConfig() {
|
|
|
26273
26383
|
}
|
|
26274
26384
|
}
|
|
26275
26385
|
function getStoragePathWithMigration() {
|
|
26276
|
-
const newPath =
|
|
26386
|
+
const newPath = join9(getConfigDir(), "antigravity-accounts.json");
|
|
26277
26387
|
if (process.platform === "win32") {
|
|
26278
26388
|
migrateLegacyWindowsConfig();
|
|
26279
26389
|
if (!existsSync3(newPath)) {
|
|
26280
|
-
const legacyPath =
|
|
26390
|
+
const legacyPath = join9(
|
|
26281
26391
|
getLegacyWindowsConfigDir(),
|
|
26282
26392
|
"antigravity-accounts.json"
|
|
26283
26393
|
);
|
|
@@ -26443,16 +26553,16 @@ var liveLogFilePaths = /* @__PURE__ */ new Set();
|
|
|
26443
26553
|
function getConfigDir2() {
|
|
26444
26554
|
const platform = process.platform;
|
|
26445
26555
|
if (platform === "win32") {
|
|
26446
|
-
return
|
|
26447
|
-
env.APPDATA ||
|
|
26556
|
+
return join10(
|
|
26557
|
+
env.APPDATA || join10(homedir3(), "AppData", "Roaming"),
|
|
26448
26558
|
"opencode"
|
|
26449
26559
|
);
|
|
26450
26560
|
}
|
|
26451
|
-
const xdgConfig2 = env.XDG_CONFIG_HOME ||
|
|
26452
|
-
return
|
|
26561
|
+
const xdgConfig2 = env.XDG_CONFIG_HOME || join10(homedir3(), ".config");
|
|
26562
|
+
return join10(xdgConfig2, "opencode");
|
|
26453
26563
|
}
|
|
26454
26564
|
function getLogsDir(customLogDir) {
|
|
26455
|
-
const logsDir = customLogDir ||
|
|
26565
|
+
const logsDir = customLogDir || join10(getConfigDir2(), "antigravity-logs");
|
|
26456
26566
|
try {
|
|
26457
26567
|
mkdirSync2(logsDir, { recursive: true, mode: 448 });
|
|
26458
26568
|
} catch {
|
|
@@ -26463,9 +26573,9 @@ function createLogFilePath(customLogDir) {
|
|
|
26463
26573
|
const logsDir = getLogsDir(customLogDir);
|
|
26464
26574
|
cleanupOldLogs(logsDir, 25);
|
|
26465
26575
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
26466
|
-
let candidate =
|
|
26576
|
+
let candidate = join10(logsDir, `antigravity-debug-${timestamp}.log`);
|
|
26467
26577
|
for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
|
|
26468
|
-
candidate =
|
|
26578
|
+
candidate = join10(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
|
|
26469
26579
|
}
|
|
26470
26580
|
return candidate;
|
|
26471
26581
|
}
|
|
@@ -26473,7 +26583,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
|
|
|
26473
26583
|
try {
|
|
26474
26584
|
const files = readdirSync(logsDir).filter(
|
|
26475
26585
|
(file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
|
|
26476
|
-
).map((file) =>
|
|
26586
|
+
).map((file) => join10(logsDir, file));
|
|
26477
26587
|
if (files.length <= maxFiles) {
|
|
26478
26588
|
return;
|
|
26479
26589
|
}
|
|
@@ -27939,7 +28049,7 @@ import { z as z4 } from "zod";
|
|
|
27939
28049
|
// src/plugin/config/loader.ts
|
|
27940
28050
|
import { existsSync as existsSync4, readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
27941
28051
|
import { homedir as homedir4 } from "node:os";
|
|
27942
|
-
import { basename as basename4, dirname as dirname15, join as
|
|
28052
|
+
import { basename as basename4, dirname as dirname15, join as join11, resolve as resolve12 } from "node:path";
|
|
27943
28053
|
|
|
27944
28054
|
// src/plugin/config/schema.ts
|
|
27945
28055
|
import { z } from "zod";
|
|
@@ -28434,14 +28544,14 @@ function getConfigDir3() {
|
|
|
28434
28544
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
28435
28545
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
28436
28546
|
}
|
|
28437
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
28438
|
-
return
|
|
28547
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join11(homedir4(), ".config");
|
|
28548
|
+
return join11(xdgConfig2, "opencode");
|
|
28439
28549
|
}
|
|
28440
28550
|
function getUserConfigPath() {
|
|
28441
|
-
return
|
|
28551
|
+
return join11(getConfigDir3(), "antigravity.json");
|
|
28442
28552
|
}
|
|
28443
28553
|
function getProjectConfigPath(directory) {
|
|
28444
|
-
return
|
|
28554
|
+
return join11(directory, ".opencode", "antigravity.json");
|
|
28445
28555
|
}
|
|
28446
28556
|
function loadConfigFile(path5, log16) {
|
|
28447
28557
|
try {
|
|
@@ -28518,7 +28628,7 @@ function canonicalizeOwnedPath(path5) {
|
|
|
28518
28628
|
let current = absolute;
|
|
28519
28629
|
for (; ; ) {
|
|
28520
28630
|
try {
|
|
28521
|
-
return
|
|
28631
|
+
return join11(realpathSync(current), ...missing.reverse());
|
|
28522
28632
|
} catch {
|
|
28523
28633
|
const parent = dirname15(current);
|
|
28524
28634
|
if (parent === current) return absolute;
|
|
@@ -29068,7 +29178,7 @@ async function replacePoolLogins(repository, results, options = {}) {
|
|
|
29068
29178
|
// src/sidebar-state.ts
|
|
29069
29179
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5 } from "node:fs";
|
|
29070
29180
|
import { homedir as homedir5 } from "node:os";
|
|
29071
|
-
import { dirname as dirname16, join as
|
|
29181
|
+
import { dirname as dirname16, join as join12 } from "node:path";
|
|
29072
29182
|
|
|
29073
29183
|
// ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
|
|
29074
29184
|
import os from "os";
|
|
@@ -29127,8 +29237,8 @@ async function emitMergeStep(step) {
|
|
|
29127
29237
|
function getSidebarStateFile() {
|
|
29128
29238
|
const override = process.env[SIDEBAR_STATE_ENV];
|
|
29129
29239
|
if (override && override.trim().length > 0) return override;
|
|
29130
|
-
const base = xdgState ??
|
|
29131
|
-
return
|
|
29240
|
+
const base = xdgState ?? join12(homedir5(), ".local", "state");
|
|
29241
|
+
return join12(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
|
|
29132
29242
|
}
|
|
29133
29243
|
function readSidebarState(path5 = getSidebarStateFile()) {
|
|
29134
29244
|
let raw;
|
|
@@ -30593,21 +30703,21 @@ import {
|
|
|
30593
30703
|
unlinkSync as unlinkSync3,
|
|
30594
30704
|
writeFileSync as writeFileSync2
|
|
30595
30705
|
} from "node:fs";
|
|
30596
|
-
import { homedir as homedir6, tmpdir } from "node:os";
|
|
30597
|
-
import { dirname as dirname17, join as
|
|
30706
|
+
import { homedir as homedir6, tmpdir as tmpdir3 } from "node:os";
|
|
30707
|
+
import { dirname as dirname17, join as join13 } from "node:path";
|
|
30598
30708
|
function getConfigDir4() {
|
|
30599
30709
|
const platform = process.platform;
|
|
30600
30710
|
if (platform === "win32") {
|
|
30601
|
-
return
|
|
30602
|
-
process.env.APPDATA ||
|
|
30711
|
+
return join13(
|
|
30712
|
+
process.env.APPDATA || join13(homedir6(), "AppData", "Roaming"),
|
|
30603
30713
|
"opencode"
|
|
30604
30714
|
);
|
|
30605
30715
|
}
|
|
30606
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
30607
|
-
return
|
|
30716
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join13(homedir6(), ".config");
|
|
30717
|
+
return join13(xdgConfig2, "opencode");
|
|
30608
30718
|
}
|
|
30609
30719
|
function getSignatureCacheFilePath() {
|
|
30610
|
-
return
|
|
30720
|
+
return join13(getConfigDir4(), "antigravity-signature-cache.json");
|
|
30611
30721
|
}
|
|
30612
30722
|
var SignatureCache = class {
|
|
30613
30723
|
// In-memory cache: key -> entry with signature and optional thinking text
|
|
@@ -30890,8 +31000,8 @@ var SignatureCache = class {
|
|
|
30890
31000
|
last_write: now
|
|
30891
31001
|
}
|
|
30892
31002
|
};
|
|
30893
|
-
const tmpPath =
|
|
30894
|
-
|
|
31003
|
+
const tmpPath = join13(
|
|
31004
|
+
tmpdir3(),
|
|
30895
31005
|
`antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
|
|
30896
31006
|
);
|
|
30897
31007
|
writeFileSync2(tmpPath, JSON.stringify(cacheData, null, 2), "utf-8");
|
|
@@ -31247,9 +31357,9 @@ function clearSignatureCache(sessionId) {
|
|
|
31247
31357
|
// src/plugin/image-saver.ts
|
|
31248
31358
|
import { chmodSync as chmodSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
31249
31359
|
import { homedir as homedir7 } from "node:os";
|
|
31250
|
-
import { join as
|
|
31360
|
+
import { join as join14 } from "node:path";
|
|
31251
31361
|
function getImageOutputDir(outputDir) {
|
|
31252
|
-
const resolved = outputDir ??
|
|
31362
|
+
const resolved = outputDir ?? join14(homedir7(), ".opencode", "generated-images");
|
|
31253
31363
|
if (!existsSync8(resolved)) {
|
|
31254
31364
|
mkdirSync5(resolved, { recursive: true, mode: 448 });
|
|
31255
31365
|
}
|
|
@@ -31272,7 +31382,7 @@ function generateImageFilename(mimeType) {
|
|
|
31272
31382
|
function saveImageToDisk(base64Data, mimeType, outputDir) {
|
|
31273
31383
|
try {
|
|
31274
31384
|
const resolvedOutputDir = getImageOutputDir(outputDir);
|
|
31275
|
-
const filePath =
|
|
31385
|
+
const filePath = join14(resolvedOutputDir, generateImageFilename(mimeType));
|
|
31276
31386
|
writeFileSync3(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
|
|
31277
31387
|
chmodSync4(filePath, 384);
|
|
31278
31388
|
return filePath;
|
|
@@ -31707,11 +31817,11 @@ data: ${JSON.stringify(syntheticUsage)}
|
|
|
31707
31817
|
// src/plugin/gemini-dump.ts
|
|
31708
31818
|
import { createHash as createHash12 } from "node:crypto";
|
|
31709
31819
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
31710
|
-
import { tmpdir as
|
|
31711
|
-
import { join as
|
|
31820
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
31821
|
+
import { join as join15 } from "node:path";
|
|
31712
31822
|
var DUMP_STATUS_TITLE = "## Gemini Dump Status";
|
|
31713
31823
|
var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
|
|
31714
|
-
var DEFAULT_DUMP_DIR =
|
|
31824
|
+
var DEFAULT_DUMP_DIR = join15(tmpdir4(), "opencode-antigravity-gemini-dumps");
|
|
31715
31825
|
var DUMP_DIR_MODE = 448;
|
|
31716
31826
|
var DUMP_FILE_MODE = 384;
|
|
31717
31827
|
var nextDumpId = 0;
|
|
@@ -31865,7 +31975,7 @@ function writeGeminiDump(input2) {
|
|
|
31865
31975
|
nextDumpId += 1;
|
|
31866
31976
|
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
|
|
31867
31977
|
const dumpDir = getGeminiDumpDirectory();
|
|
31868
|
-
const prefix =
|
|
31978
|
+
const prefix = join15(dumpDir, id);
|
|
31869
31979
|
mkdirSync6(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
|
|
31870
31980
|
const context = {
|
|
31871
31981
|
id,
|
|
@@ -31949,21 +32059,21 @@ import {
|
|
|
31949
32059
|
unlinkSync as unlinkSync4,
|
|
31950
32060
|
writeFileSync as writeFileSync5
|
|
31951
32061
|
} from "node:fs";
|
|
31952
|
-
import { join as
|
|
32062
|
+
import { join as join17 } from "node:path";
|
|
31953
32063
|
|
|
31954
32064
|
// src/plugin/recovery/constants.ts
|
|
31955
32065
|
import { homedir as homedir8 } from "node:os";
|
|
31956
|
-
import { join as
|
|
32066
|
+
import { join as join16 } from "node:path";
|
|
31957
32067
|
function getXdgData() {
|
|
31958
32068
|
const platform = process.platform;
|
|
31959
32069
|
if (platform === "win32") {
|
|
31960
|
-
return process.env.APPDATA ||
|
|
32070
|
+
return process.env.APPDATA || join16(homedir8(), "AppData", "Roaming");
|
|
31961
32071
|
}
|
|
31962
|
-
return process.env.XDG_DATA_HOME ||
|
|
32072
|
+
return process.env.XDG_DATA_HOME || join16(homedir8(), ".local", "share");
|
|
31963
32073
|
}
|
|
31964
|
-
var OPENCODE_STORAGE =
|
|
31965
|
-
var MESSAGE_STORAGE =
|
|
31966
|
-
var PART_STORAGE =
|
|
32074
|
+
var OPENCODE_STORAGE = join16(getXdgData(), "opencode", "storage");
|
|
32075
|
+
var MESSAGE_STORAGE = join16(OPENCODE_STORAGE, "message");
|
|
32076
|
+
var PART_STORAGE = join16(OPENCODE_STORAGE, "part");
|
|
31967
32077
|
var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
31968
32078
|
"thinking",
|
|
31969
32079
|
"redacted_thinking",
|
|
@@ -31973,13 +32083,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
|
31973
32083
|
// src/plugin/recovery/storage.ts
|
|
31974
32084
|
function getMessageDir(sessionID) {
|
|
31975
32085
|
if (!existsSync9(MESSAGE_STORAGE)) return "";
|
|
31976
|
-
const directPath =
|
|
32086
|
+
const directPath = join17(MESSAGE_STORAGE, sessionID);
|
|
31977
32087
|
if (existsSync9(directPath)) {
|
|
31978
32088
|
return directPath;
|
|
31979
32089
|
}
|
|
31980
32090
|
try {
|
|
31981
32091
|
for (const dir of readdirSync2(MESSAGE_STORAGE)) {
|
|
31982
|
-
const sessionPath =
|
|
32092
|
+
const sessionPath = join17(MESSAGE_STORAGE, dir, sessionID);
|
|
31983
32093
|
if (existsSync9(sessionPath)) {
|
|
31984
32094
|
return sessionPath;
|
|
31985
32095
|
}
|
|
@@ -31996,7 +32106,7 @@ function readMessages(sessionID) {
|
|
|
31996
32106
|
for (const file of readdirSync2(messageDir)) {
|
|
31997
32107
|
if (!file.endsWith(".json")) continue;
|
|
31998
32108
|
try {
|
|
31999
|
-
const content = readFileSync7(
|
|
32109
|
+
const content = readFileSync7(join17(messageDir, file), "utf-8");
|
|
32000
32110
|
messages.push(JSON.parse(content));
|
|
32001
32111
|
} catch {
|
|
32002
32112
|
}
|
|
@@ -32012,14 +32122,14 @@ function readMessages(sessionID) {
|
|
|
32012
32122
|
});
|
|
32013
32123
|
}
|
|
32014
32124
|
function readParts(messageID) {
|
|
32015
|
-
const partDir =
|
|
32125
|
+
const partDir = join17(PART_STORAGE, messageID);
|
|
32016
32126
|
if (!existsSync9(partDir)) return [];
|
|
32017
32127
|
const parts = [];
|
|
32018
32128
|
try {
|
|
32019
32129
|
for (const file of readdirSync2(partDir)) {
|
|
32020
32130
|
if (!file.endsWith(".json")) continue;
|
|
32021
32131
|
try {
|
|
32022
|
-
const content = readFileSync7(
|
|
32132
|
+
const content = readFileSync7(join17(partDir, file), "utf-8");
|
|
32023
32133
|
parts.push(JSON.parse(content));
|
|
32024
32134
|
} catch {
|
|
32025
32135
|
}
|
|
@@ -32061,7 +32171,7 @@ function findMessagesWithOrphanThinking(sessionID) {
|
|
|
32061
32171
|
return result;
|
|
32062
32172
|
}
|
|
32063
32173
|
function prependThinkingPart(sessionID, messageID) {
|
|
32064
|
-
const partDir =
|
|
32174
|
+
const partDir = join17(PART_STORAGE, messageID);
|
|
32065
32175
|
try {
|
|
32066
32176
|
if (!existsSync9(partDir)) {
|
|
32067
32177
|
mkdirSync7(partDir, { recursive: true });
|
|
@@ -32076,7 +32186,7 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
32076
32186
|
synthetic: true
|
|
32077
32187
|
};
|
|
32078
32188
|
writeFileSync5(
|
|
32079
|
-
|
|
32189
|
+
join17(partDir, `${partId}.json`),
|
|
32080
32190
|
JSON.stringify(part, null, 2)
|
|
32081
32191
|
);
|
|
32082
32192
|
return true;
|
|
@@ -32085,14 +32195,14 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
32085
32195
|
}
|
|
32086
32196
|
}
|
|
32087
32197
|
function stripThinkingParts(messageID) {
|
|
32088
|
-
const partDir =
|
|
32198
|
+
const partDir = join17(PART_STORAGE, messageID);
|
|
32089
32199
|
if (!existsSync9(partDir)) return false;
|
|
32090
32200
|
let anyRemoved = false;
|
|
32091
32201
|
try {
|
|
32092
32202
|
for (const file of readdirSync2(partDir)) {
|
|
32093
32203
|
if (!file.endsWith(".json")) continue;
|
|
32094
32204
|
try {
|
|
32095
|
-
const filePath =
|
|
32205
|
+
const filePath = join17(partDir, file);
|
|
32096
32206
|
const content = readFileSync7(filePath, "utf-8");
|
|
32097
32207
|
const part = JSON.parse(content);
|
|
32098
32208
|
if (THINKING_TYPES.has(part.type)) {
|
|
@@ -38814,8 +38924,8 @@ function extractRateLimitBodyInfo(body) {
|
|
|
38814
38924
|
}
|
|
38815
38925
|
}
|
|
38816
38926
|
if (message) {
|
|
38817
|
-
const
|
|
38818
|
-
const rawDuration =
|
|
38927
|
+
const reset = message.match(/(?:reset after|resets? in)\s+([0-9hms.]+)/i);
|
|
38928
|
+
const rawDuration = reset?.[1];
|
|
38819
38929
|
if (rawDuration) {
|
|
38820
38930
|
const parsed = parseDurationToMs(rawDuration);
|
|
38821
38931
|
if (parsed !== null) {
|
|
@@ -40106,7 +40216,7 @@ async function checkVaultQuota(input2) {
|
|
|
40106
40216
|
|
|
40107
40217
|
// src/plugin/vault-custody.ts
|
|
40108
40218
|
import { chmod as chmod3, mkdir as mkdir11, readFile as readFile9 } from "node:fs/promises";
|
|
40109
|
-
import { dirname as dirname18, join as
|
|
40219
|
+
import { dirname as dirname18, join as join18 } from "node:path";
|
|
40110
40220
|
|
|
40111
40221
|
// src/plugin/vault-insula-quota.ts
|
|
40112
40222
|
var windows = [
|
|
@@ -40156,12 +40266,12 @@ var OPENCODE_VAULT_HOST = "opencode";
|
|
|
40156
40266
|
var OPENCODE_VAULT_ENROLLMENT_NAME = getAntigravityVaultEnrollmentName(OPENCODE_VAULT_HOST);
|
|
40157
40267
|
var OPENCODE_VAULT_DIR_NAME = "antigravity-auth-vault";
|
|
40158
40268
|
function openCodeVaultPaths(accountFile) {
|
|
40159
|
-
const dir =
|
|
40269
|
+
const dir = join18(dirname18(accountFile), OPENCODE_VAULT_DIR_NAME);
|
|
40160
40270
|
return {
|
|
40161
40271
|
dir,
|
|
40162
|
-
modeFile:
|
|
40163
|
-
rosterFile:
|
|
40164
|
-
stateFile:
|
|
40272
|
+
modeFile: join18(dir, "opencode-mode.json"),
|
|
40273
|
+
rosterFile: join18(dir, "opencode-roster.json"),
|
|
40274
|
+
stateFile: join18(dir, "opencode-state.json")
|
|
40165
40275
|
};
|
|
40166
40276
|
}
|
|
40167
40277
|
async function ensureVaultDir(dir) {
|
|
@@ -40509,6 +40619,9 @@ async function refusalOr(step) {
|
|
|
40509
40619
|
}
|
|
40510
40620
|
return "Done. Start a new request to use the change.";
|
|
40511
40621
|
}
|
|
40622
|
+
function isUnsupportedEnrollment(status) {
|
|
40623
|
+
return status.state === "unavailable" && status.code === UNSUPPORTED_VAULT_CODE;
|
|
40624
|
+
}
|
|
40512
40625
|
function describeEnrollment(status) {
|
|
40513
40626
|
switch (status.state) {
|
|
40514
40627
|
case "idle":
|
|
@@ -40522,7 +40635,7 @@ function describeEnrollment(status) {
|
|
|
40522
40635
|
case "blocked":
|
|
40523
40636
|
return `blocked (${status.code})`;
|
|
40524
40637
|
case "unavailable":
|
|
40525
|
-
return `vault unavailable (${status.code})`;
|
|
40638
|
+
return isUnsupportedEnrollment(status) ? "this vault can't connect plugins yet" : `vault unavailable (${status.code})`;
|
|
40526
40639
|
case "busy":
|
|
40527
40640
|
return "another setup step is running";
|
|
40528
40641
|
}
|
|
@@ -40589,10 +40702,15 @@ function enrollmentGuidance(status) {
|
|
|
40589
40702
|
return [
|
|
40590
40703
|
"Resolve the enrollment problem with the vault operator, then request vault access again."
|
|
40591
40704
|
];
|
|
40592
|
-
if (status.state === "unavailable")
|
|
40705
|
+
if (status.state === "unavailable") {
|
|
40706
|
+
if (isUnsupportedEnrollment(status))
|
|
40707
|
+
return [
|
|
40708
|
+
"This Claustrum vault is too old to connect plugins. Ask the vault operator to update Claustrum, or keep using your local accounts."
|
|
40709
|
+
];
|
|
40593
40710
|
return [
|
|
40594
40711
|
"Check that the vault is running and its connection file is available, then request vault access again."
|
|
40595
40712
|
];
|
|
40713
|
+
}
|
|
40596
40714
|
if (status.state === "busy")
|
|
40597
40715
|
return [
|
|
40598
40716
|
"Another enrollment operation is running. OpenCode will keep checking its outcome in the background."
|
|
@@ -44762,7 +44880,7 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
44762
44880
|
|
|
44763
44881
|
// src/plugin/index.ts
|
|
44764
44882
|
import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
|
|
44765
|
-
import { join as
|
|
44883
|
+
import { join as join33, resolve as resolve19 } from "node:path";
|
|
44766
44884
|
|
|
44767
44885
|
// src/cli.ts
|
|
44768
44886
|
import { execFile } from "node:child_process";
|
|
@@ -44811,7 +44929,7 @@ async function performOAuthLogin(request, deps) {
|
|
|
44811
44929
|
|
|
44812
44930
|
// src/setup.ts
|
|
44813
44931
|
import { lstat as lstat5, readFile as readFile13 } from "node:fs/promises";
|
|
44814
|
-
import { join as
|
|
44932
|
+
import { join as join24, resolve as resolve15 } from "node:path";
|
|
44815
44933
|
|
|
44816
44934
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
44817
44935
|
var ANSI2 = {
|
|
@@ -45053,7 +45171,7 @@ async function select2(terminal, items, options) {
|
|
|
45053
45171
|
import { createHash as createHash15, randomBytes as randomBytes6, randomUUID as randomUUID17 } from "node:crypto";
|
|
45054
45172
|
import { constants as fsConstants2 } from "node:fs";
|
|
45055
45173
|
import { chmod as chmod4, mkdir as mkdir13, open as open10, readFile as readFile11, realpath as realpath4, rename as rename9, stat as stat7, unlink as unlink9 } from "node:fs/promises";
|
|
45056
|
-
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as
|
|
45174
|
+
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join20, resolve as resolve14 } from "node:path";
|
|
45057
45175
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
45058
45176
|
|
|
45059
45177
|
// src/common-auth-embedded/fs/lock-constants.js
|
|
@@ -45075,7 +45193,7 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
45075
45193
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
45076
45194
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
45077
45195
|
import { mkdir as mkdir12, open as open9, readFile as readFile10, rename as rename8, rm as rm5, stat as stat6 } from "node:fs/promises";
|
|
45078
|
-
import { dirname as dirname19, join as
|
|
45196
|
+
import { dirname as dirname19, join as join19 } from "node:path";
|
|
45079
45197
|
|
|
45080
45198
|
// src/common-auth-embedded/fs/with-lock.js
|
|
45081
45199
|
function lockPathFor2(target, name) {
|
|
@@ -45110,7 +45228,7 @@ function acquireRefreshFileLock2(options) {
|
|
|
45110
45228
|
}
|
|
45111
45229
|
async function acquireRefreshFileLockWithClock2(options) {
|
|
45112
45230
|
const lockPath = lockPathFor2(options.path, options.name);
|
|
45113
|
-
const legacyOwnerPath =
|
|
45231
|
+
const legacyOwnerPath = join19(lockPath, "owner.json");
|
|
45114
45232
|
const ownerId = randomUUID16();
|
|
45115
45233
|
const now = options.now ?? Date.now;
|
|
45116
45234
|
let renewTimer = null;
|
|
@@ -45153,7 +45271,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
45153
45271
|
let terminalIOError;
|
|
45154
45272
|
let renewalInFlight = null;
|
|
45155
45273
|
const evictPath = `${lockPath}.evicting`;
|
|
45156
|
-
const evictOwnerPath =
|
|
45274
|
+
const evictOwnerPath = join19(evictPath, "owner.json");
|
|
45157
45275
|
const evictOwnerId = randomUUID16();
|
|
45158
45276
|
const EVICT_TTL = 5e3;
|
|
45159
45277
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
@@ -45724,7 +45842,13 @@ var ENROLLMENT_SCHEMA2 = 1;
|
|
|
45724
45842
|
var ENROLLMENT_FILE_MAX_BYTES2 = 16 * 1024;
|
|
45725
45843
|
var ENROLLMENT_LOCK_TTL_MS2 = 3e4;
|
|
45726
45844
|
var TOKEN_RE2 = /^[0-9a-f]{64}$/;
|
|
45845
|
+
var UNSUPPORTED_ENROLLMENT_CODE2 = "unknown_method";
|
|
45727
45846
|
var TERMINAL_ENROLLMENT_CODES2 = /* @__PURE__ */ new Set([
|
|
45847
|
+
// The daemon's answer to an operation it does not implement: a vault built
|
|
45848
|
+
// before the enrollment ceremony. It arrives as a transport Error frame with
|
|
45849
|
+
// no class, which claustrum-client before 0.13.0 labels transient/retry, but
|
|
45850
|
+
// asking again can never succeed.
|
|
45851
|
+
UNSUPPORTED_ENROLLMENT_CODE2,
|
|
45728
45852
|
"invalid_params",
|
|
45729
45853
|
"pending_exists",
|
|
45730
45854
|
"not_found",
|
|
@@ -45754,7 +45878,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
|
|
|
45754
45878
|
const extension = extname2(tokenPath) || ".json";
|
|
45755
45879
|
const stem = basename5(tokenPath, extname2(tokenPath));
|
|
45756
45880
|
return {
|
|
45757
|
-
statePath:
|
|
45881
|
+
statePath: join20(dirname20(tokenPath), `${stem}-state${extension}`),
|
|
45758
45882
|
tokenPath
|
|
45759
45883
|
};
|
|
45760
45884
|
}
|
|
@@ -45762,7 +45886,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
45762
45886
|
const override = input2.override?.trim();
|
|
45763
45887
|
if (override && !isAbsolute3(override) && !input2.cwd)
|
|
45764
45888
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
45765
|
-
const tokenPath = override ? isAbsolute3(override) ? override : resolve14(input2.cwd, override) :
|
|
45889
|
+
const tokenPath = override ? isAbsolute3(override) ? override : resolve14(input2.cwd, override) : join20(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
45766
45890
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
45767
45891
|
}
|
|
45768
45892
|
function isRecord10(value) {
|
|
@@ -45995,7 +46119,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
45995
46119
|
}
|
|
45996
46120
|
if (windowsPrivateFiles2)
|
|
45997
46121
|
return writePrivateAtomic2(path5, bytes);
|
|
45998
|
-
const temporary =
|
|
46122
|
+
const temporary = join20(parent, `.${basename5(path5)}.${process.pid}.${randomUUID17()}.tmp`);
|
|
45999
46123
|
let descriptor;
|
|
46000
46124
|
let created = false;
|
|
46001
46125
|
try {
|
|
@@ -46219,6 +46343,18 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
46219
46343
|
retryCode: refusal3.code
|
|
46220
46344
|
};
|
|
46221
46345
|
}
|
|
46346
|
+
if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
|
|
46347
|
+
await lock.assertOwned();
|
|
46348
|
+
await unlink9(this.#paths.statePath).catch((cause) => {
|
|
46349
|
+
if (cause.code !== "ENOENT")
|
|
46350
|
+
throw cause;
|
|
46351
|
+
});
|
|
46352
|
+
return {
|
|
46353
|
+
state: "unavailable",
|
|
46354
|
+
proposedName: state.proposedName,
|
|
46355
|
+
code: refusal3.code
|
|
46356
|
+
};
|
|
46357
|
+
}
|
|
46222
46358
|
return this.#block(state, refusal3.code);
|
|
46223
46359
|
}
|
|
46224
46360
|
}
|
|
@@ -46496,8 +46632,8 @@ function recordSetupEnrollment(failure2, enrollment) {
|
|
|
46496
46632
|
// src/common-auth-embedded/setup/detect.js
|
|
46497
46633
|
import { accessSync, constants as constants3, existsSync as existsSync11, readFileSync as readFileSync9, realpathSync as realpathSync2, statSync as statSync5 } from "node:fs";
|
|
46498
46634
|
import { mkdtemp, rm as rm6 } from "node:fs/promises";
|
|
46499
|
-
import { tmpdir as
|
|
46500
|
-
import { join as
|
|
46635
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
46636
|
+
import { join as join21 } from "node:path";
|
|
46501
46637
|
import { parse } from "jsonc-parser";
|
|
46502
46638
|
|
|
46503
46639
|
// src/common-auth-embedded/setup/paths.js
|
|
@@ -46668,7 +46804,7 @@ async function detectHosts(plugin2, io = {}) {
|
|
|
46668
46804
|
return null;
|
|
46669
46805
|
let root;
|
|
46670
46806
|
try {
|
|
46671
|
-
root = await mkdtemp(
|
|
46807
|
+
root = await mkdtemp(join21(tmpdir5(), "common-auth-setup-version-"));
|
|
46672
46808
|
const probeEnv = {
|
|
46673
46809
|
...env3,
|
|
46674
46810
|
HOME: root,
|
|
@@ -46737,6 +46873,8 @@ import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexki
|
|
|
46737
46873
|
var WINDOWS_CIM_TIMEOUT_MS = 45e3;
|
|
46738
46874
|
var HOSTS = /* @__PURE__ */ new Set(["opencode", "litecode", "opencode2", "pi"]);
|
|
46739
46875
|
var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun"]);
|
|
46876
|
+
var WINDOWS_FENCE_FILTER = [...HOSTS, ...RUNTIMES].map((name) => `Name LIKE '${name}%'`).join(" OR ");
|
|
46877
|
+
var WINDOWS_FENCE_QUERY = `$ErrorActionPreference = 'Stop'; $rows = @(Get-CimInstance Win32_Process -Filter "${WINDOWS_FENCE_FILTER}" | Select-Object Name,ProcessId,CommandLine); ConvertTo-Json -Compress -Depth 3 -InputObject @{ complete = $true; processes = $rows }`;
|
|
46740
46878
|
var PI_SCRIPT_PATTERN = /(?:^|[/\\])pi-coding-agent[/\\]dist[/\\](?:(?:bundle|bun)[/\\])?cli\.m?js$/i;
|
|
46741
46879
|
function commandArguments(command) {
|
|
46742
46880
|
return [...command.matchAll(/"([^"]*)"|(\S+)/g)].map((match) => match[1] ?? match[2] ?? "");
|
|
@@ -46876,6 +47014,29 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
46876
47014
|
}
|
|
46877
47015
|
};
|
|
46878
47016
|
try {
|
|
47017
|
+
if (windows2 && options.hostImagesOnly) {
|
|
47018
|
+
const details = await inspect("CIM", "powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", WINDOWS_FENCE_QUERY], WINDOWS_CIM_TIMEOUT_MS);
|
|
47019
|
+
if (details.exitCode !== 0)
|
|
47020
|
+
throw new ProcessInspectionError(inspection);
|
|
47021
|
+
const value = JSON.parse(details.stdout);
|
|
47022
|
+
if (!value || typeof value !== "object" || !("complete" in value) || value.complete !== true || !("processes" in value))
|
|
47023
|
+
throw new ProcessInspectionError(inspection);
|
|
47024
|
+
const listed = value.processes;
|
|
47025
|
+
const rows = listed === null ? [] : Array.isArray(listed) ? listed : [listed];
|
|
47026
|
+
const processes2 = [];
|
|
47027
|
+
for (const row of rows) {
|
|
47028
|
+
if (!row || typeof row !== "object" || !("Name" in row) || typeof row.Name !== "string" || !("ProcessId" in row) || !Number.isSafeInteger(row.ProcessId) || row.ProcessId < 0 || !("CommandLine" in row))
|
|
47029
|
+
throw new ProcessInspectionError(inspection);
|
|
47030
|
+
const pid = row.ProcessId;
|
|
47031
|
+
if (!/^(?:node|bun)\.exe$/i.test(row.Name))
|
|
47032
|
+
processes2.push({ pid, command: row.Name });
|
|
47033
|
+
else if (typeof row.CommandLine === "string")
|
|
47034
|
+
processes2.push({ pid, command: row.CommandLine });
|
|
47035
|
+
else if (pid !== selfPid)
|
|
47036
|
+
throw new ProcessInspectionError(inspection);
|
|
47037
|
+
}
|
|
47038
|
+
return processes2;
|
|
47039
|
+
}
|
|
46879
47040
|
const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? "tasklist.exe" : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
46880
47041
|
if (result.exitCode !== 0)
|
|
46881
47042
|
throw new ProcessInspectionError(inspection);
|
|
@@ -46945,7 +47106,11 @@ function createProcessFence(runner = defaultCommandRunner, options = {}) {
|
|
|
46945
47106
|
const isHost = (entry) => entry.pid !== selfPid && hostName(entry.command) !== null;
|
|
46946
47107
|
return {
|
|
46947
47108
|
async listRunningHosts(env3) {
|
|
46948
|
-
return (await listSetupProcesses(runner, {
|
|
47109
|
+
return (await listSetupProcesses(runner, {
|
|
47110
|
+
...options,
|
|
47111
|
+
env: env3,
|
|
47112
|
+
hostImagesOnly: true
|
|
47113
|
+
})).filter(isHost);
|
|
46949
47114
|
},
|
|
46950
47115
|
async previewRunningHosts(env3) {
|
|
46951
47116
|
const processes = await listSetupProcesses(runner, {
|
|
@@ -46969,8 +47134,27 @@ async function assertHostsStopped(fence, env3) {
|
|
|
46969
47134
|
|
|
46970
47135
|
// src/common-auth-embedded/setup/enroll.js
|
|
46971
47136
|
var ENROLLMENT_INCOMPLETE_MESSAGE = "Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.";
|
|
47137
|
+
var UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault does not support connecting plugins yet, so setup cannot connect to it. Run setup without --claustrum to use local accounts.";
|
|
47138
|
+
var ENROLLMENT_WAIT_MS = 3e5;
|
|
47139
|
+
var APPROVAL_POLL_MS = 1e3;
|
|
47140
|
+
var PROPOSE_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
47141
|
+
function safeCode(code2) {
|
|
47142
|
+
return code2 && /^[a-z][a-z0-9_]{0,63}$/.test(code2) ? code2 : "unknown";
|
|
47143
|
+
}
|
|
46972
47144
|
var HostNotEnrolledError = class extends Error {
|
|
47145
|
+
reason;
|
|
47146
|
+
lastErrorCode;
|
|
47147
|
+
constructor(message, details) {
|
|
47148
|
+
super(message);
|
|
47149
|
+
this.name = "HostNotEnrolledError";
|
|
47150
|
+
this.reason = details.reason;
|
|
47151
|
+
if (details.lastErrorCode !== void 0)
|
|
47152
|
+
this.lastErrorCode = safeCode(details.lastErrorCode);
|
|
47153
|
+
}
|
|
46973
47154
|
};
|
|
47155
|
+
function approveCommand(requestId, name) {
|
|
47156
|
+
return `ck auth enroll approve --request-id ${requestId} --name ${name}`;
|
|
47157
|
+
}
|
|
46974
47158
|
async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
46975
47159
|
const { name, paths: input2 } = plugin2.vault.hosts[host];
|
|
46976
47160
|
const paths = hostEnrollmentPaths2(input2);
|
|
@@ -46979,54 +47163,94 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
46979
47163
|
connectionFile: plugin2.vault.connectionFile,
|
|
46980
47164
|
handshakeTimeoutMs: 2e3
|
|
46981
47165
|
}).catch(() => {
|
|
46982
|
-
throw new HostNotEnrolledError("Claustrum connection failed; start ck and rerun setup.");
|
|
47166
|
+
throw new HostNotEnrolledError("Claustrum connection failed; start ck and rerun setup.", { reason: "connection-failed" });
|
|
46983
47167
|
});
|
|
47168
|
+
const now = io.now ?? (() => performance.now());
|
|
47169
|
+
const wait2 = io.wait ?? delay;
|
|
46984
47170
|
try {
|
|
46985
47171
|
const manager = new ClaustrumEnrollmentManager2({
|
|
46986
47172
|
proposedName: name,
|
|
46987
47173
|
paths,
|
|
46988
|
-
|
|
46989
|
-
|
|
46990
|
-
|
|
46991
|
-
|
|
46992
|
-
|
|
46993
|
-
enrollPoll: async (input3) => {
|
|
46994
|
-
await fence();
|
|
46995
|
-
return client.enrollPoll(input3);
|
|
46996
|
-
}
|
|
46997
|
-
},
|
|
47174
|
+
// Each tick of the wait below checks the fence once, just before
|
|
47175
|
+
// reconcile proposes or polls. Checking again inside every vault call
|
|
47176
|
+
// doubled the process listings per tick, and on Windows each listing
|
|
47177
|
+
// starts PowerShell.
|
|
47178
|
+
client,
|
|
46998
47179
|
writeTokenFile: async (path5, file) => {
|
|
46999
47180
|
await fence();
|
|
47000
47181
|
await writeEnrollmentTokenFile3(path5, file);
|
|
47001
47182
|
}
|
|
47002
47183
|
});
|
|
47184
|
+
printLine2(terminal, `Asking the vault to connect ${name}\u2026`);
|
|
47185
|
+
const deadline = now() + ENROLLMENT_WAIT_MS;
|
|
47003
47186
|
let printedRequest;
|
|
47004
|
-
|
|
47187
|
+
let lastCode;
|
|
47188
|
+
let reportedCode;
|
|
47189
|
+
let failedProposals = 0;
|
|
47190
|
+
for (; ; ) {
|
|
47005
47191
|
await fence();
|
|
47006
47192
|
const status = await manager.reconcile();
|
|
47007
47193
|
if (status.state === "approved") {
|
|
47008
47194
|
printLine2(terminal, `Connected ${host} to Claustrum.`);
|
|
47009
47195
|
return;
|
|
47010
47196
|
}
|
|
47197
|
+
if (status.state === "unavailable" && status.code === UNSUPPORTED_ENROLLMENT_CODE2)
|
|
47198
|
+
throw new HostNotEnrolledError(UNSUPPORTED_VAULT_MESSAGE, {
|
|
47199
|
+
reason: "unsupported-vault",
|
|
47200
|
+
lastErrorCode: status.code
|
|
47201
|
+
});
|
|
47011
47202
|
if (status.state !== "pending" && status.state !== "busy")
|
|
47012
|
-
throw new HostNotEnrolledError("Claustrum enrollment refused; inspect its status with ck before rerunning setup."
|
|
47013
|
-
|
|
47014
|
-
|
|
47015
|
-
|
|
47016
|
-
|
|
47017
|
-
|
|
47018
|
-
|
|
47019
|
-
|
|
47020
|
-
|
|
47021
|
-
|
|
47022
|
-
|
|
47023
|
-
|
|
47203
|
+
throw new HostNotEnrolledError("Claustrum enrollment refused; inspect its status with ck before rerunning setup.", {
|
|
47204
|
+
reason: "refused",
|
|
47205
|
+
..."code" in status && { lastErrorCode: status.code }
|
|
47206
|
+
});
|
|
47207
|
+
let pause = APPROVAL_POLL_MS;
|
|
47208
|
+
if (status.state === "busy")
|
|
47209
|
+
lastCode = "busy";
|
|
47210
|
+
else if (status.retryCode)
|
|
47211
|
+
lastCode = status.retryCode;
|
|
47212
|
+
if (status.state === "pending" && status.requestId) {
|
|
47213
|
+
failedProposals = 0;
|
|
47214
|
+
if (status.requestId !== printedRequest) {
|
|
47215
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(status.requestId))
|
|
47216
|
+
throw new HostNotEnrolledError("Invalid enrollment request id.", {
|
|
47217
|
+
reason: "invalid-request"
|
|
47218
|
+
});
|
|
47219
|
+
printedRequest = status.requestId;
|
|
47220
|
+
printLine2(terminal, "Waiting for approval. In another terminal, run:");
|
|
47221
|
+
printLine2(terminal, ` ${approveCommand(status.requestId, name)}`);
|
|
47222
|
+
printLine2(terminal, `Enrollment files: ${paths.statePath}, ${paths.tokenPath}`);
|
|
47223
|
+
}
|
|
47224
|
+
} else if (status.state === "pending" && status.retryCode) {
|
|
47225
|
+
pause = PROPOSE_BACKOFF_MS[Math.min(failedProposals, PROPOSE_BACKOFF_MS.length - 1)] ?? APPROVAL_POLL_MS;
|
|
47226
|
+
failedProposals++;
|
|
47227
|
+
const code3 = safeCode(status.retryCode);
|
|
47228
|
+
if (code3 !== reportedCode) {
|
|
47229
|
+
reportedCode = code3;
|
|
47230
|
+
printLine2(terminal, `The vault has not created the request yet (${code3}); retrying.`);
|
|
47231
|
+
}
|
|
47232
|
+
}
|
|
47233
|
+
const remaining = deadline - now();
|
|
47234
|
+
if (remaining <= 0)
|
|
47235
|
+
break;
|
|
47236
|
+
await wait2(Math.min(pause, remaining));
|
|
47237
|
+
}
|
|
47238
|
+
if (printedRequest)
|
|
47239
|
+
throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
|
|
47240
|
+
reason: "approval-pending",
|
|
47241
|
+
...lastCode !== void 0 && { lastErrorCode: lastCode }
|
|
47242
|
+
});
|
|
47243
|
+
const code2 = safeCode(lastCode);
|
|
47244
|
+
throw new HostNotEnrolledError(`The vault never created the enrollment request (last error: ${code2}). Check that ck is running, then rerun setup.`, { reason: "request-not-created", lastErrorCode: code2 });
|
|
47024
47245
|
} catch (error) {
|
|
47025
|
-
if (error instanceof ProcessFenceViolationError || error instanceof ProcessInspectionError
|
|
47246
|
+
if (error instanceof ProcessFenceViolationError || error instanceof ProcessInspectionError || // Built above from fixed text and vetted values only.
|
|
47247
|
+
error instanceof HostNotEnrolledError)
|
|
47026
47248
|
throw error;
|
|
47027
|
-
|
|
47028
|
-
|
|
47029
|
-
|
|
47249
|
+
const code2 = error?.code;
|
|
47250
|
+
throw new HostNotEnrolledError(ENROLLMENT_INCOMPLETE_MESSAGE, {
|
|
47251
|
+
reason: "incomplete",
|
|
47252
|
+
...typeof code2 === "string" && { lastErrorCode: code2 }
|
|
47253
|
+
});
|
|
47030
47254
|
} finally {
|
|
47031
47255
|
client.close();
|
|
47032
47256
|
}
|
|
@@ -47064,7 +47288,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
|
|
|
47064
47288
|
// src/common-auth-embedded/setup/config-write.js
|
|
47065
47289
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
47066
47290
|
import { mkdir as mkdir14, open as open11, rename as rename10, stat as stat9, unlink as unlink10 } from "node:fs/promises";
|
|
47067
|
-
import { basename as basename6, dirname as dirname21, join as
|
|
47291
|
+
import { basename as basename6, dirname as dirname21, join as join22 } from "node:path";
|
|
47068
47292
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
47069
47293
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
47070
47294
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
@@ -47079,7 +47303,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
47079
47303
|
throw error;
|
|
47080
47304
|
}
|
|
47081
47305
|
}
|
|
47082
|
-
const stage =
|
|
47306
|
+
const stage = join22(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID18)()}.tmp`);
|
|
47083
47307
|
let created = false;
|
|
47084
47308
|
try {
|
|
47085
47309
|
const handle = await open11(stage, "wx", mode ?? 438);
|
|
@@ -47446,11 +47670,11 @@ ${write.content}`);
|
|
|
47446
47670
|
// src/plugin/vault-activation.ts
|
|
47447
47671
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
47448
47672
|
import { homedir as homedir10 } from "node:os";
|
|
47449
|
-
import { join as
|
|
47673
|
+
import { join as join23 } from "node:path";
|
|
47450
47674
|
var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
|
|
47451
47675
|
function nativeOpenCodeAuthPath(env3 = process.env, home = homedir10()) {
|
|
47452
|
-
return
|
|
47453
|
-
env3.XDG_DATA_HOME ||
|
|
47676
|
+
return join23(
|
|
47677
|
+
env3.XDG_DATA_HOME || join23(home, ".local", "share"),
|
|
47454
47678
|
"opencode",
|
|
47455
47679
|
"auth.json"
|
|
47456
47680
|
);
|
|
@@ -47498,7 +47722,7 @@ function createV1VaultActivationMethod(input2) {
|
|
|
47498
47722
|
// src/setup.ts
|
|
47499
47723
|
var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
|
|
47500
47724
|
function nativeAuthPath(host, context) {
|
|
47501
|
-
return host === "opencode" ? nativeOpenCodeAuthPath() :
|
|
47725
|
+
return host === "opencode" ? nativeOpenCodeAuthPath() : join24(context.piAgentDir, "auth.json");
|
|
47502
47726
|
}
|
|
47503
47727
|
function provider(host) {
|
|
47504
47728
|
return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
|
|
@@ -47619,7 +47843,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
47619
47843
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
47620
47844
|
if ((await openPiSlot2({
|
|
47621
47845
|
authPath: nativeAuthPath(host, context),
|
|
47622
|
-
stashPath:
|
|
47846
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
47623
47847
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
47624
47848
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
47625
47849
|
}).inspect()).slot === "placeholder")
|
|
@@ -47656,7 +47880,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
47656
47880
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
47657
47881
|
const inspection = await openPiSlot2({
|
|
47658
47882
|
authPath: nativeAuthPath("pi", context),
|
|
47659
|
-
stashPath:
|
|
47883
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
47660
47884
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
47661
47885
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
47662
47886
|
}).inspect();
|
|
@@ -47775,7 +47999,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
47775
47999
|
await assertSetupHostsStopped();
|
|
47776
48000
|
await openPiSlot2({
|
|
47777
48001
|
authPath: nativeAuthPath(host, context),
|
|
47778
|
-
stashPath:
|
|
48002
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
47779
48003
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
47780
48004
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
47781
48005
|
}).enterVault();
|
|
@@ -48795,8 +49019,8 @@ function isTuiConnected(sessionId) {
|
|
|
48795
49019
|
|
|
48796
49020
|
// src/rpc/rpc-dir.ts
|
|
48797
49021
|
import { createHash as createHash16 } from "node:crypto";
|
|
48798
|
-
import { homedir as homedir12, tmpdir as
|
|
48799
|
-
import { isAbsolute as isAbsolute4, join as
|
|
49022
|
+
import { homedir as homedir12, tmpdir as tmpdir6 } from "node:os";
|
|
49023
|
+
import { isAbsolute as isAbsolute4, join as join28, resolve as resolve17 } from "node:path";
|
|
48800
49024
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
48801
49025
|
function getRpcDir(projectDirectory) {
|
|
48802
49026
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
@@ -48804,8 +49028,8 @@ function getRpcDir(projectDirectory) {
|
|
|
48804
49028
|
return isAbsolute4(override) ? override : resolve17(projectDirectory, override);
|
|
48805
49029
|
}
|
|
48806
49030
|
const projectHash = createHash16("sha256").update(resolve17(projectDirectory)).digest("hex").slice(0, 16);
|
|
48807
|
-
const stateHome = process.env.XDG_STATE_HOME ??
|
|
48808
|
-
return
|
|
49031
|
+
const stateHome = process.env.XDG_STATE_HOME ?? join28(homedir12(), ".local", "state");
|
|
49032
|
+
return join28(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
48809
49033
|
}
|
|
48810
49034
|
|
|
48811
49035
|
// src/common-auth-embedded/rpc/notifications.js
|
|
@@ -48816,7 +49040,7 @@ function isSessionId(value) {
|
|
|
48816
49040
|
// src/common-auth-embedded/rpc/port-file.js
|
|
48817
49041
|
import { createHash as createHash17, randomUUID as randomUUID19 } from "node:crypto";
|
|
48818
49042
|
import { chmod as chmod5, mkdir as mkdir15, open as open12, readdir, rename as rename11, rmdir as rmdir2, stat as stat10, unlink as unlink11 } from "node:fs/promises";
|
|
48819
|
-
import { join as
|
|
49043
|
+
import { join as join29, resolve as resolve18 } from "node:path";
|
|
48820
49044
|
function isProbeablePid(pid) {
|
|
48821
49045
|
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
|
|
48822
49046
|
}
|
|
@@ -48847,7 +49071,7 @@ async function removeCorruptPortFile(portFile, log16) {
|
|
|
48847
49071
|
}
|
|
48848
49072
|
async function writePortFile(dir, entry, options = {}) {
|
|
48849
49073
|
const writeOnce = async () => {
|
|
48850
|
-
const target =
|
|
49074
|
+
const target = join29(dir, `port-${entry.pid}.json`);
|
|
48851
49075
|
if (windowsPrivateFiles2) {
|
|
48852
49076
|
await ensurePrivateDirectory3(dir, options.secureDir ?? false);
|
|
48853
49077
|
await options.beforeWrite?.();
|
|
@@ -48908,7 +49132,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
48908
49132
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
48909
49133
|
continue;
|
|
48910
49134
|
}
|
|
48911
|
-
const dir =
|
|
49135
|
+
const dir = join29(root, projectDir.name);
|
|
48912
49136
|
let names;
|
|
48913
49137
|
try {
|
|
48914
49138
|
names = await readdir(dir);
|
|
@@ -48920,7 +49144,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
48920
49144
|
for (const name of names) {
|
|
48921
49145
|
if (!name.startsWith("port-") || !name.endsWith(".json"))
|
|
48922
49146
|
continue;
|
|
48923
|
-
const portFile =
|
|
49147
|
+
const portFile = join29(dir, name);
|
|
48924
49148
|
let raw;
|
|
48925
49149
|
try {
|
|
48926
49150
|
raw = await readPrivateText2(portFile);
|
|
@@ -48957,7 +49181,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
48957
49181
|
import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
48958
49182
|
import { unlink as unlink12 } from "node:fs/promises";
|
|
48959
49183
|
import { createServer as createServer3 } from "node:http";
|
|
48960
|
-
import { join as
|
|
49184
|
+
import { join as join30 } from "node:path";
|
|
48961
49185
|
var RpcRequestError = class extends Error {
|
|
48962
49186
|
status;
|
|
48963
49187
|
constructor(status, message) {
|
|
@@ -49209,7 +49433,7 @@ async function startRpcServer(options) {
|
|
|
49209
49433
|
for (const socket of connections)
|
|
49210
49434
|
socket.destroy();
|
|
49211
49435
|
});
|
|
49212
|
-
const portFile =
|
|
49436
|
+
const portFile = join30(options.dir, `port-${process.pid}.json`);
|
|
49213
49437
|
const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
|
|
49214
49438
|
if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
|
|
49215
49439
|
throw error;
|
|
@@ -49512,7 +49736,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
|
|
|
49512
49736
|
// src/plugin/config/updater.ts
|
|
49513
49737
|
import { existsSync as existsSync14, mkdirSync as mkdirSync8, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "node:fs";
|
|
49514
49738
|
import { homedir as homedir13 } from "node:os";
|
|
49515
|
-
import { dirname as dirname23, join as
|
|
49739
|
+
import { dirname as dirname23, join as join31 } from "node:path";
|
|
49516
49740
|
var PLUGIN_NAME = "@cortexkit/opencode-antigravity-auth@latest";
|
|
49517
49741
|
var SCHEMA_URL = "https://opencode.ai/config.json";
|
|
49518
49742
|
var OPENCODE_JSON_FILENAME = "opencode.json";
|
|
@@ -49524,13 +49748,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
|
|
|
49524
49748
|
).replace(/,(\s*[}\]])/g, "$1");
|
|
49525
49749
|
}
|
|
49526
49750
|
function getOpencodeConfigDir() {
|
|
49527
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
49528
|
-
return
|
|
49751
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join31(homedir13(), ".config");
|
|
49752
|
+
return join31(xdgConfig2, "opencode");
|
|
49529
49753
|
}
|
|
49530
49754
|
function getOpencodeConfigPath() {
|
|
49531
49755
|
const configDir = getOpencodeConfigDir();
|
|
49532
|
-
const jsoncPath =
|
|
49533
|
-
const jsonPath =
|
|
49756
|
+
const jsoncPath = join31(configDir, OPENCODE_JSONC_FILENAME);
|
|
49757
|
+
const jsonPath = join31(configDir, OPENCODE_JSON_FILENAME);
|
|
49534
49758
|
if (existsSync14(jsoncPath)) {
|
|
49535
49759
|
return jsoncPath;
|
|
49536
49760
|
}
|
|
@@ -53118,15 +53342,15 @@ function projectCommandAccountRows(storage) {
|
|
|
53118
53342
|
|
|
53119
53343
|
// src/plugin/dependencies.ts
|
|
53120
53344
|
import { homedir as homedir14 } from "node:os";
|
|
53121
|
-
import { join as
|
|
53345
|
+
import { join as join32 } from "node:path";
|
|
53122
53346
|
function defaultFilesystemRoots() {
|
|
53123
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ??
|
|
53124
|
-
const xdgState2 = process.env.XDG_STATE_HOME ??
|
|
53347
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join32(homedir14(), ".config");
|
|
53348
|
+
const xdgState2 = process.env.XDG_STATE_HOME ?? join32(homedir14(), ".local", "state");
|
|
53125
53349
|
return {
|
|
53126
53350
|
projectRoot: process.cwd(),
|
|
53127
|
-
userConfigRoot:
|
|
53128
|
-
sidebarStateRoot:
|
|
53129
|
-
rpcRoot:
|
|
53351
|
+
userConfigRoot: join32(xdgConfig2, "opencode"),
|
|
53352
|
+
sidebarStateRoot: join32(xdgState2, "cortexkit", "antigravity-auth"),
|
|
53353
|
+
rpcRoot: join32(xdgState2, "cortexkit", "antigravity-auth", "rpc")
|
|
53130
53354
|
};
|
|
53131
53355
|
}
|
|
53132
53356
|
function resolvePluginDependencies(overrides = {}) {
|
|
@@ -53744,6 +53968,19 @@ function createGoogleSearchTool({
|
|
|
53744
53968
|
// src/plugin/lifecycle.ts
|
|
53745
53969
|
var NOOP_DRAIN = async () => {
|
|
53746
53970
|
};
|
|
53971
|
+
async function collectCleanupFailure(cleanup2, failures) {
|
|
53972
|
+
try {
|
|
53973
|
+
await cleanup2();
|
|
53974
|
+
} catch (error) {
|
|
53975
|
+
failures.push(error);
|
|
53976
|
+
}
|
|
53977
|
+
}
|
|
53978
|
+
function reportCleanupFailures(failures) {
|
|
53979
|
+
if (failures.length === 1) throw failures[0];
|
|
53980
|
+
if (failures.length > 1) {
|
|
53981
|
+
throw new AggregateError(failures, "Plugin cleanup failed");
|
|
53982
|
+
}
|
|
53983
|
+
}
|
|
53747
53984
|
function createPluginLifecycle(options) {
|
|
53748
53985
|
let accountManager = null;
|
|
53749
53986
|
let refreshQueue = null;
|
|
@@ -53755,19 +53992,19 @@ function createPluginLifecycle(options) {
|
|
|
53755
53992
|
const consumers = [];
|
|
53756
53993
|
const drainSidebarWrites2 = options.drainSidebarWrites ?? NOOP_DRAIN;
|
|
53757
53994
|
const retire2 = (manager, queue2, requests) => {
|
|
53758
|
-
const queueDrained =
|
|
53995
|
+
const queueDrained = (async () => {
|
|
53996
|
+
await queue2?.dispose();
|
|
53997
|
+
})();
|
|
53759
53998
|
const record3 = {
|
|
53760
53999
|
requests,
|
|
53761
54000
|
done: (async () => {
|
|
53762
|
-
const
|
|
53763
|
-
|
|
53764
|
-
|
|
54001
|
+
const failures = [];
|
|
54002
|
+
await Promise.all([
|
|
54003
|
+
collectCleanupFailure(() => queueDrained, failures),
|
|
54004
|
+
collectCleanupFailure(() => requests?.retire(), failures)
|
|
53765
54005
|
]);
|
|
53766
|
-
await manager.dispose();
|
|
53767
|
-
|
|
53768
|
-
(outcome) => outcome.status === "rejected"
|
|
53769
|
-
);
|
|
53770
|
-
if (failed) throw failed.reason;
|
|
54006
|
+
await collectCleanupFailure(() => manager.dispose(), failures);
|
|
54007
|
+
reportCleanupFailures(failures);
|
|
53771
54008
|
})()
|
|
53772
54009
|
};
|
|
53773
54010
|
retiring.add(record3);
|
|
@@ -53777,8 +54014,6 @@ function createPluginLifecycle(options) {
|
|
|
53777
54014
|
if (!requests) retiring.delete(record3);
|
|
53778
54015
|
}
|
|
53779
54016
|
);
|
|
53780
|
-
void queueDrained.catch(() => {
|
|
53781
|
-
});
|
|
53782
54017
|
return { queueDrained, done: record3.done };
|
|
53783
54018
|
};
|
|
53784
54019
|
const disposeAccountRuntime = async () => {
|
|
@@ -53790,23 +54025,26 @@ function createPluginLifecycle(options) {
|
|
|
53790
54025
|
accountRequests = null;
|
|
53791
54026
|
const retired = [...retiring];
|
|
53792
54027
|
retiring.clear();
|
|
54028
|
+
const failures = [];
|
|
53793
54029
|
const aborted = Promise.all([
|
|
53794
|
-
oldRequests?.dispose(),
|
|
53795
|
-
...retired.map(
|
|
54030
|
+
collectCleanupFailure(() => oldRequests?.dispose(), failures),
|
|
54031
|
+
...retired.map(
|
|
54032
|
+
(record3) => collectCleanupFailure(() => record3.requests?.dispose(), failures)
|
|
54033
|
+
)
|
|
53796
54034
|
]);
|
|
53797
|
-
const liveQueueDrained =
|
|
53798
|
-
|
|
53799
|
-
|
|
53800
|
-
await aborted;
|
|
53801
|
-
const retirements = await Promise.allSettled(
|
|
53802
|
-
retired.map((record3) => record3.done)
|
|
54035
|
+
const liveQueueDrained = collectCleanupFailure(
|
|
54036
|
+
() => oldQueue?.dispose(),
|
|
54037
|
+
failures
|
|
53803
54038
|
);
|
|
53804
|
-
await
|
|
53805
|
-
|
|
53806
|
-
|
|
53807
|
-
(
|
|
53808
|
-
|
|
53809
|
-
|
|
54039
|
+
await Promise.all([
|
|
54040
|
+
aborted,
|
|
54041
|
+
liveQueueDrained,
|
|
54042
|
+
...retired.map(
|
|
54043
|
+
(record3) => collectCleanupFailure(() => record3.done, failures)
|
|
54044
|
+
)
|
|
54045
|
+
]);
|
|
54046
|
+
await collectCleanupFailure(() => oldManager?.dispose(), failures);
|
|
54047
|
+
reportCleanupFailures(failures);
|
|
53810
54048
|
};
|
|
53811
54049
|
const register = (disposable, phase = "consumer") => {
|
|
53812
54050
|
if (closing) {
|
|
@@ -53861,19 +54099,27 @@ function createPluginLifecycle(options) {
|
|
|
53861
54099
|
failDisposal = reject;
|
|
53862
54100
|
});
|
|
53863
54101
|
void (async () => {
|
|
53864
|
-
|
|
53865
|
-
await
|
|
53866
|
-
|
|
53867
|
-
|
|
54102
|
+
const failures = [];
|
|
54103
|
+
await collectCleanupFailure(disposeAccountRuntime, failures);
|
|
54104
|
+
await collectCleanupFailure(
|
|
54105
|
+
() => options.shutdownDiskSignatureCache(),
|
|
54106
|
+
failures
|
|
54107
|
+
);
|
|
54108
|
+
await collectCleanupFailure(
|
|
54109
|
+
() => options.sessionRegistry.clear(),
|
|
54110
|
+
failures
|
|
54111
|
+
);
|
|
54112
|
+
await collectCleanupFailure(() => options.clearFetchState(), failures);
|
|
53868
54113
|
for (const disposable of producers) {
|
|
53869
|
-
await disposable.dispose();
|
|
54114
|
+
await collectCleanupFailure(() => disposable.dispose(), failures);
|
|
53870
54115
|
}
|
|
53871
54116
|
producers.length = 0;
|
|
53872
|
-
await drainSidebarWrites2
|
|
54117
|
+
await collectCleanupFailure(drainSidebarWrites2, failures);
|
|
53873
54118
|
for (const disposable of consumers) {
|
|
53874
|
-
await disposable.dispose();
|
|
54119
|
+
await collectCleanupFailure(() => disposable.dispose(), failures);
|
|
53875
54120
|
}
|
|
53876
54121
|
consumers.length = 0;
|
|
54122
|
+
reportCleanupFailures(failures);
|
|
53877
54123
|
})().then(finishDisposal, failDisposal);
|
|
53878
54124
|
}
|
|
53879
54125
|
return disposal;
|
|
@@ -54202,7 +54448,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
54202
54448
|
lifecycle.register(vaultQuotaPoller, "producer");
|
|
54203
54449
|
}
|
|
54204
54450
|
const operatorSettings = createOperatorSettingsController({
|
|
54205
|
-
projectConfigPath:
|
|
54451
|
+
projectConfigPath: join33(directory, ".opencode", "antigravity.json"),
|
|
54206
54452
|
// getUserConfigPath() already returns the full file path including
|
|
54207
54453
|
// 'antigravity.json' — do NOT join again or the path double-nests
|
|
54208
54454
|
// into <dir>/antigravity.json/antigravity.json.
|