@cortexkit/opencode-antigravity-auth 3.1.7 → 3.1.9
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 +182 -193
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +83 -54
- package/dist/index.js +6886 -6346
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +475 -387
- package/dist/server.js +3056 -2446
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.js +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +1 -1
- package/dist/src/common-auth-embedded/fs/private-files.js +14 -5
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/dist/src/common-auth-embedded/opencode2/install.js +14 -4
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/dist/src/common-auth-embedded/pi-slot/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/pi-slot/index.js +1 -1
- package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +6 -9
- package/dist/src/common-auth-embedded/pi-slot/slot.js +42 -105
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
- package/dist/src/common-auth-embedded/routing-accessor/index.js +123 -17
- package/dist/src/common-auth-embedded/rpc/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/rpc/index.js +1 -1
- package/dist/src/common-auth-embedded/rpc/port-file.d.ts +4 -0
- package/dist/src/common-auth-embedded/rpc/port-file.js +55 -49
- package/dist/src/common-auth-embedded/rpc/rpc-server.js +3 -2
- package/dist/src/common-auth-embedded/rpc/startup-sweep.js +32 -0
- package/dist/src/common-auth-embedded/source-output.json +77 -68
- package/dist/src/common-auth-embedded/store/mutate.js +34 -13
- package/dist/src/ga/server/index.d.ts +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +58 -19
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +3 -3
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +102 -80
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +27 -13
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +21 -11
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +13 -5
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +2 -2
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
- package/dist/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
- package/dist/src/plugin/shared/opencode-retry-hints.js +22 -0
- package/dist/src/plugin/shared/opencode-retry-hints.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +2 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +410 -112
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.js +13 -7
- package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing.d.ts +8 -1
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing.js +12 -4
- package/dist/src/plugin/shared/vault-routing.js.map +1 -1
- package/dist/src/plugin/storage.d.ts +1 -0
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +3 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +6 -13
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +19 -16
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/runtime-layout.d.ts.map +1 -1
- package/dist/src/runtime-layout.js +5 -2
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +2 -7
- package/dist/src/setup.js.map +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
- package/dist/types/src/ga/server/index.d.ts +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
- package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +2 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts +8 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +1 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +6 -13
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/runtime-layout.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/availability.js +1 -1
- package/src/common-auth-embedded/claustrum/custody.js +1 -1
- package/src/common-auth-embedded/fs/private-files.js +14 -5
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/index.js +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/src/common-auth-embedded/opencode2/install.js +14 -4
- package/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/src/common-auth-embedded/pi-slot/index.d.ts +1 -1
- package/src/common-auth-embedded/pi-slot/index.js +1 -1
- package/src/common-auth-embedded/pi-slot/slot.d.ts +6 -9
- package/src/common-auth-embedded/pi-slot/slot.js +42 -105
- package/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
- package/src/common-auth-embedded/routing-accessor/index.js +123 -17
- package/src/common-auth-embedded/rpc/index.d.ts +1 -1
- package/src/common-auth-embedded/rpc/index.js +1 -1
- package/src/common-auth-embedded/rpc/port-file.d.ts +4 -0
- package/src/common-auth-embedded/rpc/port-file.js +55 -49
- package/src/common-auth-embedded/rpc/rpc-server.js +3 -2
- package/src/common-auth-embedded/rpc/startup-sweep.js +32 -0
- package/src/common-auth-embedded/source-output.json +77 -68
- package/src/common-auth-embedded/store/mutate.js +34 -13
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +14 -5
- package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +55 -49
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +14 -5
- package/src/tui-raw/common-auth-embedded/rpc/port-file.js +55 -49
package/dist/cli.js
CHANGED
|
@@ -610,7 +610,9 @@ function ioCode(detail) {
|
|
|
610
610
|
return detail?.code ?? "ERR_PRIVATE_FILE";
|
|
611
611
|
}
|
|
612
612
|
function privateFilesUnavailable(cause) {
|
|
613
|
-
return Object.assign(new Error("Windows private-files native addon
|
|
613
|
+
return Object.assign(new Error("Windows private-files native addon could not be loaded", {
|
|
614
|
+
cause
|
|
615
|
+
}), {
|
|
614
616
|
code: "ERR_PRIVATE_FILES_UNAVAILABLE",
|
|
615
617
|
reason: PRIVATE_FILES_UNAVAILABLE_REASON
|
|
616
618
|
});
|
|
@@ -636,8 +638,11 @@ function loadBackend() {
|
|
|
636
638
|
});
|
|
637
639
|
return backend;
|
|
638
640
|
}
|
|
641
|
+
function isSharingIoError(detail) {
|
|
642
|
+
return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
|
|
643
|
+
}
|
|
639
644
|
function isWindowsSharingViolation(error) {
|
|
640
|
-
return windowsPrivateFiles && error instanceof PrivateFileError &&
|
|
645
|
+
return windowsPrivateFiles && error instanceof PrivateFileError && isSharingIoError(error);
|
|
641
646
|
}
|
|
642
647
|
async function privateOperation(path2, stage, operation) {
|
|
643
648
|
try {
|
|
@@ -759,12 +764,12 @@ async function replaceWindowsFile(from, to, options = {}) {
|
|
|
759
764
|
const delays = [0, 10, 20, 40, 80, 100];
|
|
760
765
|
let original;
|
|
761
766
|
let attempts2 = 0;
|
|
762
|
-
for (const
|
|
767
|
+
for (const delay5 of delays) {
|
|
763
768
|
const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
|
|
764
769
|
if (now() >= deadline)
|
|
765
770
|
break;
|
|
766
|
-
if (
|
|
767
|
-
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(
|
|
771
|
+
if (delay5)
|
|
772
|
+
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay5, Math.max(0, deadline - now())));
|
|
768
773
|
if (now() >= deadline)
|
|
769
774
|
break;
|
|
770
775
|
const fenceStart = now();
|
|
@@ -883,7 +888,11 @@ var init_private_files = __esm({
|
|
|
883
888
|
orphanPath;
|
|
884
889
|
constructor(path2, stage, cause) {
|
|
885
890
|
const detail = cause;
|
|
886
|
-
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ?
|
|
891
|
+
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? (
|
|
892
|
+
// The reason stays on `.reason`: its word "unavailable" would make
|
|
893
|
+
// OpenCode 1 retry a plain error carrying this message.
|
|
894
|
+
`Private file refused at ${stage}: ${path2}. 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.`
|
|
895
|
+
) : isSharingIoError(detail) ? `Private file busy at ${stage}: ${path2}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).` : `Private file refused at ${stage}: ${path2} (${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 });
|
|
887
896
|
this.path = path2;
|
|
888
897
|
this.stage = stage;
|
|
889
898
|
this.name = "PrivateFileError";
|
|
@@ -5973,7 +5982,7 @@ var init_account_repository = __esm({
|
|
|
5973
5982
|
assertPublicationReceipt(plan, receipt2) {
|
|
5974
5983
|
if (!receipt2)
|
|
5975
5984
|
return;
|
|
5976
|
-
const
|
|
5985
|
+
const digest2 = createHash2("sha256").update(canonicalJson(encodePublicationPlan(plan))).digest("hex");
|
|
5977
5986
|
const removed = plan.remove.map((row) => ({
|
|
5978
5987
|
id: row.id,
|
|
5979
5988
|
credentialEpoch: row.attribution.credentialEpoch
|
|
@@ -5984,7 +5993,7 @@ var init_account_repository = __esm({
|
|
|
5984
5993
|
reservation: row.reservation,
|
|
5985
5994
|
enabled: row.enabled
|
|
5986
5995
|
}));
|
|
5987
|
-
if (receipt2.operationId !== plan.operationId || receipt2.planDigest !==
|
|
5996
|
+
if (receipt2.operationId !== plan.operationId || receipt2.planDigest !== digest2 || !isDeepStrictEqual2(receipt2.removed, removed) || !isDeepStrictEqual2(receipt2.finalized, finalized)) {
|
|
5988
5997
|
throw refusal("replacePool", "publication-mismatch", "the native receipt does not prove this replacement plan");
|
|
5989
5998
|
}
|
|
5990
5999
|
}
|
|
@@ -6989,9 +6998,9 @@ async function acquireWithRetry(path2, sleep3) {
|
|
|
6989
6998
|
return lock;
|
|
6990
6999
|
}
|
|
6991
7000
|
if (attempt < RETRY_DELAYS_MS.length) {
|
|
6992
|
-
const
|
|
6993
|
-
if (
|
|
6994
|
-
await sleep3(
|
|
7001
|
+
const delay5 = RETRY_DELAYS_MS[attempt];
|
|
7002
|
+
if (delay5 !== void 0) {
|
|
7003
|
+
await sleep3(delay5);
|
|
6995
7004
|
}
|
|
6996
7005
|
}
|
|
6997
7006
|
}
|
|
@@ -10963,13 +10972,13 @@ function buildRawRows(config, state, codec, providerCodec) {
|
|
|
10963
10972
|
function providerStateFields(account, credential, credentialEpoch2, identity3, codec) {
|
|
10964
10973
|
if (!isRecord4(account) || !Object.hasOwn(account, PROVIDER_STATE_KEY))
|
|
10965
10974
|
return {};
|
|
10966
|
-
const
|
|
10967
|
-
if (
|
|
10975
|
+
const digest2 = boundProviderStateDigest(account, credential, credentialEpoch2, identity3);
|
|
10976
|
+
if (digest2 === void 0)
|
|
10968
10977
|
return { providerStateDropped: "uncovered" };
|
|
10969
10978
|
const value = account[PROVIDER_STATE_KEY];
|
|
10970
10979
|
if (!codec || !runInsideCodec(() => codec.validate(value)))
|
|
10971
10980
|
return { providerStateDropped: "invalid" };
|
|
10972
|
-
if (providerStateDigest(codec, value) !==
|
|
10981
|
+
if (providerStateDigest(codec, value) !== digest2)
|
|
10973
10982
|
return { providerStateDropped: "uncovered" };
|
|
10974
10983
|
return { providerState: value };
|
|
10975
10984
|
}
|
|
@@ -11218,14 +11227,19 @@ var init_torn = __esm({
|
|
|
11218
11227
|
});
|
|
11219
11228
|
|
|
11220
11229
|
// ../core/dist/common-auth-embedded/store/mutate.js
|
|
11221
|
-
import { setTimeout as
|
|
11230
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
11222
11231
|
async function readText(path2) {
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11232
|
+
for (let attempt = 0; ; attempt++) {
|
|
11233
|
+
try {
|
|
11234
|
+
return await readPrivateText(path2, windowsPrivateFiles);
|
|
11235
|
+
} catch (error) {
|
|
11236
|
+
if (error.code === "ENOENT")
|
|
11237
|
+
return void 0;
|
|
11238
|
+
const wait2 = sharingRetryDelays[attempt];
|
|
11239
|
+
if (wait2 === void 0 || !isWindowsSharingViolation(error))
|
|
11240
|
+
throw error;
|
|
11241
|
+
await delay(wait2);
|
|
11242
|
+
}
|
|
11229
11243
|
}
|
|
11230
11244
|
}
|
|
11231
11245
|
function parseFile(text2) {
|
|
@@ -11242,12 +11256,21 @@ async function readPoolConfig(path2) {
|
|
|
11242
11256
|
}
|
|
11243
11257
|
async function readPool(ctx) {
|
|
11244
11258
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11259
|
+
let configText;
|
|
11260
|
+
let stateText;
|
|
11261
|
+
let checkedConfigText;
|
|
11262
|
+
try {
|
|
11263
|
+
configText = await readText(ctx.configPath);
|
|
11264
|
+
stateText = await readText(ctx.statePath);
|
|
11265
|
+
checkedConfigText = await readText(ctx.configPath);
|
|
11266
|
+
} catch (error) {
|
|
11267
|
+
if (isWindowsSharingViolation(error))
|
|
11268
|
+
break;
|
|
11269
|
+
throw error;
|
|
11270
|
+
}
|
|
11248
11271
|
if (configText !== checkedConfigText) {
|
|
11249
11272
|
if (attempt < 2)
|
|
11250
|
-
await
|
|
11273
|
+
await delay(2 + Math.floor(Math.random() * 4));
|
|
11251
11274
|
continue;
|
|
11252
11275
|
}
|
|
11253
11276
|
const config = classifyConfig(parseFile(configText));
|
|
@@ -11427,7 +11450,7 @@ async function runOperation(ctx, operation, rowId2, onFailure, body) {
|
|
|
11427
11450
|
await locks.releaseAll();
|
|
11428
11451
|
}
|
|
11429
11452
|
}
|
|
11430
|
-
var Transaction;
|
|
11453
|
+
var sharingRetryDelays, Transaction;
|
|
11431
11454
|
var init_mutate = __esm({
|
|
11432
11455
|
"../core/dist/common-auth-embedded/store/mutate.js"() {
|
|
11433
11456
|
"use strict";
|
|
@@ -11440,6 +11463,7 @@ var init_mutate = __esm({
|
|
|
11440
11463
|
init_reserved();
|
|
11441
11464
|
init_schema();
|
|
11442
11465
|
init_torn();
|
|
11466
|
+
sharingRetryDelays = [5, 10, 20, 40, 80, 160, 320, 400];
|
|
11443
11467
|
Transaction = class {
|
|
11444
11468
|
ctx;
|
|
11445
11469
|
snapshot;
|
|
@@ -11963,9 +11987,9 @@ async function planProviderStateIn(tx, codec, operation, row, mutator, declinabl
|
|
|
11963
11987
|
nextAccount[CREDENTIAL_STAMP_KEY] = nextStamp;
|
|
11964
11988
|
} else {
|
|
11965
11989
|
nextAccount[PROVIDER_STATE_KEY] = next;
|
|
11966
|
-
const
|
|
11967
|
-
if (stamp.providerState !==
|
|
11968
|
-
nextAccount[CREDENTIAL_STAMP_KEY] = { ...rawStamp, providerState:
|
|
11990
|
+
const digest2 = providerStateDigest(codec, next);
|
|
11991
|
+
if (stamp.providerState !== digest2)
|
|
11992
|
+
nextAccount[CREDENTIAL_STAMP_KEY] = { ...rawStamp, providerState: digest2 };
|
|
11969
11993
|
}
|
|
11970
11994
|
return {
|
|
11971
11995
|
kind: "changed",
|
|
@@ -13391,11 +13415,11 @@ var init_quota_writer = __esm({
|
|
|
13391
13415
|
overlay(rows) {
|
|
13392
13416
|
return rows.map((row) => this.overlayRow(row));
|
|
13393
13417
|
}
|
|
13394
|
-
schedule(
|
|
13418
|
+
schedule(delay5) {
|
|
13395
13419
|
if (this.running || this.timer || !this.pending.size || this.stopped)
|
|
13396
13420
|
return;
|
|
13397
13421
|
const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
|
|
13398
|
-
this.timer = this.clock.schedule(Math.max(
|
|
13422
|
+
this.timer = this.clock.schedule(Math.max(delay5, remaining), () => {
|
|
13399
13423
|
this.timer = void 0;
|
|
13400
13424
|
return this.flush();
|
|
13401
13425
|
});
|
|
@@ -13495,8 +13519,8 @@ var init_quota_writer = __esm({
|
|
|
13495
13519
|
this.running = void 0;
|
|
13496
13520
|
for (const wake of this.wake)
|
|
13497
13521
|
wake();
|
|
13498
|
-
const
|
|
13499
|
-
this.schedule(
|
|
13522
|
+
const delay5 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
|
|
13523
|
+
this.schedule(delay5);
|
|
13500
13524
|
}
|
|
13501
13525
|
})();
|
|
13502
13526
|
return this.running;
|
|
@@ -16047,7 +16071,7 @@ var init_availability = __esm({
|
|
|
16047
16071
|
*/
|
|
16048
16072
|
reason;
|
|
16049
16073
|
constructor(reason) {
|
|
16050
|
-
super("unavailable", "Claustrum
|
|
16074
|
+
super("unavailable", "Claustrum vault could not be reached");
|
|
16051
16075
|
this.name = "ClaustrumUnreachableError";
|
|
16052
16076
|
if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
|
|
16053
16077
|
this.reason = reason;
|
|
@@ -17184,12 +17208,12 @@ var init_watch = __esm({
|
|
|
17184
17208
|
this.#options.logger?.debug("claustrum vault watch", { mode, reason });
|
|
17185
17209
|
this.#options.onMode?.(mode);
|
|
17186
17210
|
}
|
|
17187
|
-
#later(
|
|
17211
|
+
#later(delay5, run) {
|
|
17188
17212
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
17189
17213
|
this.#timer = void 0;
|
|
17190
17214
|
if (!this.#stopped)
|
|
17191
17215
|
run();
|
|
17192
|
-
},
|
|
17216
|
+
}, delay5);
|
|
17193
17217
|
this.#timer.unref?.();
|
|
17194
17218
|
}
|
|
17195
17219
|
async #open(resubscribed) {
|
|
@@ -17261,10 +17285,10 @@ var init_watch = __esm({
|
|
|
17261
17285
|
const now = (this.#options.now ?? Date.now)();
|
|
17262
17286
|
if (watch.acceptedAt !== void 0 && now - watch.acceptedAt >= SAFETY_POLL_MS)
|
|
17263
17287
|
this.#closes = 0;
|
|
17264
|
-
const
|
|
17288
|
+
const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
|
|
17265
17289
|
this.#closes++;
|
|
17266
17290
|
this.#setMode("polling", "resubscribing");
|
|
17267
|
-
this.#later(
|
|
17291
|
+
this.#later(delay5, () => void this.#open(true));
|
|
17268
17292
|
return;
|
|
17269
17293
|
}
|
|
17270
17294
|
this.#fallback(end.kind);
|
|
@@ -17555,12 +17579,12 @@ var init_insula = __esm({
|
|
|
17555
17579
|
watch?.handle?.stop();
|
|
17556
17580
|
this.#mode = "polling";
|
|
17557
17581
|
}
|
|
17558
|
-
#later(
|
|
17582
|
+
#later(delay5) {
|
|
17559
17583
|
this.#timer = (this.#timers.setTimeoutImpl ?? setTimeout)(() => {
|
|
17560
17584
|
this.#timer = void 0;
|
|
17561
17585
|
if (this.#watchers > 0 && !this.#watch)
|
|
17562
17586
|
this.#open();
|
|
17563
|
-
},
|
|
17587
|
+
}, delay5);
|
|
17564
17588
|
this.#timer.unref?.();
|
|
17565
17589
|
}
|
|
17566
17590
|
#open() {
|
|
@@ -17608,10 +17632,10 @@ var init_insula = __esm({
|
|
|
17608
17632
|
return;
|
|
17609
17633
|
}
|
|
17610
17634
|
if (watch.notices > 0) {
|
|
17611
|
-
const
|
|
17635
|
+
const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
|
|
17612
17636
|
this.#closes++;
|
|
17613
17637
|
this.#mode = "polling";
|
|
17614
|
-
this.#later(
|
|
17638
|
+
this.#later(delay5);
|
|
17615
17639
|
return;
|
|
17616
17640
|
}
|
|
17617
17641
|
this.#mode = "fallback";
|
|
@@ -19060,7 +19084,7 @@ var init_custody = __esm({
|
|
|
19060
19084
|
throw error;
|
|
19061
19085
|
if (classifyVaultFailure(error) === "unreachable")
|
|
19062
19086
|
throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
19063
|
-
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation
|
|
19087
|
+
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation failed");
|
|
19064
19088
|
} finally {
|
|
19065
19089
|
removeAbortListener?.();
|
|
19066
19090
|
}
|
|
@@ -19300,9 +19324,9 @@ var init_custody = __esm({
|
|
|
19300
19324
|
users: 0,
|
|
19301
19325
|
error,
|
|
19302
19326
|
pending: Promise.resolve().then(async () => {
|
|
19303
|
-
let
|
|
19327
|
+
let delay5 = 250;
|
|
19304
19328
|
for (; ; ) {
|
|
19305
|
-
await this.#receiptBackoff(
|
|
19329
|
+
await this.#receiptBackoff(delay5, controller.signal);
|
|
19306
19330
|
try {
|
|
19307
19331
|
return await this.#authorizeFresh(identity3, token, controller.signal);
|
|
19308
19332
|
} catch (failure) {
|
|
@@ -19310,7 +19334,7 @@ var init_custody = __esm({
|
|
|
19310
19334
|
if (classifyVaultFailure(failure) !== "unreachable")
|
|
19311
19335
|
throw failure;
|
|
19312
19336
|
created.error = failure;
|
|
19313
|
-
|
|
19337
|
+
delay5 = Math.min(delay5 * 2, 1e3);
|
|
19314
19338
|
}
|
|
19315
19339
|
}
|
|
19316
19340
|
})
|
|
@@ -19364,7 +19388,7 @@ var init_custody = __esm({
|
|
|
19364
19388
|
}
|
|
19365
19389
|
}
|
|
19366
19390
|
}
|
|
19367
|
-
#receiptBackoff(
|
|
19391
|
+
#receiptBackoff(delay5, signal) {
|
|
19368
19392
|
this.#check(signal);
|
|
19369
19393
|
return new Promise((resolve25, reject) => {
|
|
19370
19394
|
const abort = () => {
|
|
@@ -19375,7 +19399,7 @@ var init_custody = __esm({
|
|
|
19375
19399
|
const timer = this.#setTimeout(() => {
|
|
19376
19400
|
signal.removeEventListener("abort", abort);
|
|
19377
19401
|
resolve25();
|
|
19378
|
-
},
|
|
19402
|
+
}, delay5);
|
|
19379
19403
|
timer.unref?.();
|
|
19380
19404
|
signal.addEventListener("abort", abort, { once: true });
|
|
19381
19405
|
if (signal.aborted)
|
|
@@ -20399,11 +20423,11 @@ function pendingVaultQuota(path2, roster) {
|
|
|
20399
20423
|
function hasPendingVaultQuota(path2) {
|
|
20400
20424
|
return !!writers.get(resolve11(path2))?.pending.size;
|
|
20401
20425
|
}
|
|
20402
|
-
function schedule(writer,
|
|
20426
|
+
function schedule(writer, delay5) {
|
|
20403
20427
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
20404
20428
|
return;
|
|
20405
20429
|
const remaining = writer.draining ? 0 : (writer.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - writer.clock.now();
|
|
20406
|
-
writer.timer = writer.clock.schedule(Math.max(
|
|
20430
|
+
writer.timer = writer.clock.schedule(Math.max(delay5, remaining), () => {
|
|
20407
20431
|
writer.timer = void 0;
|
|
20408
20432
|
return flush(writer);
|
|
20409
20433
|
});
|
|
@@ -20840,13 +20864,13 @@ var init_consumer = __esm({
|
|
|
20840
20864
|
}
|
|
20841
20865
|
if (this.#shutdown.signal.aborted)
|
|
20842
20866
|
return;
|
|
20843
|
-
const
|
|
20844
|
-
if (
|
|
20867
|
+
const delay5 = this.#options.pollIntervalMs ?? 5e3;
|
|
20868
|
+
if (delay5 <= 0)
|
|
20845
20869
|
return;
|
|
20846
20870
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
20847
20871
|
this.#timer = void 0;
|
|
20848
20872
|
void this.#track(tick());
|
|
20849
|
-
},
|
|
20873
|
+
}, delay5);
|
|
20850
20874
|
this.#timer.unref?.();
|
|
20851
20875
|
};
|
|
20852
20876
|
void this.#track(tick());
|
|
@@ -22316,13 +22340,13 @@ var init_hub = __esm({
|
|
|
22316
22340
|
}
|
|
22317
22341
|
if (this.#shutdown.signal.aborted)
|
|
22318
22342
|
return;
|
|
22319
|
-
const
|
|
22320
|
-
if (
|
|
22343
|
+
const delay5 = this.#options.pollIntervalMs ?? 5e3;
|
|
22344
|
+
if (delay5 <= 0)
|
|
22321
22345
|
return;
|
|
22322
22346
|
this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
|
|
22323
22347
|
this.#timer = void 0;
|
|
22324
22348
|
void this.#track(this.#tick());
|
|
22325
|
-
},
|
|
22349
|
+
}, delay5);
|
|
22326
22350
|
this.#timer.unref?.();
|
|
22327
22351
|
}
|
|
22328
22352
|
/**
|
|
@@ -22613,12 +22637,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
22613
22637
|
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
22614
22638
|
compromise();
|
|
22615
22639
|
}
|
|
22616
|
-
function schedule2(
|
|
22640
|
+
function schedule2(delay5 = UPDATE) {
|
|
22617
22641
|
if (released)
|
|
22618
22642
|
return;
|
|
22619
22643
|
timer = setTimeout(() => {
|
|
22620
22644
|
void update();
|
|
22621
|
-
},
|
|
22645
|
+
}, delay5);
|
|
22622
22646
|
timer.unref();
|
|
22623
22647
|
}
|
|
22624
22648
|
function retry(error) {
|
|
@@ -22723,7 +22747,6 @@ var init_lock = __esm({
|
|
|
22723
22747
|
});
|
|
22724
22748
|
|
|
22725
22749
|
// ../core/dist/common-auth-embedded/pi-slot/slot.js
|
|
22726
|
-
import { createHash as createHash8 } from "node:crypto";
|
|
22727
22750
|
import { constants as constants2 } from "node:fs";
|
|
22728
22751
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink8 } from "node:fs/promises";
|
|
22729
22752
|
import { dirname as dirname12, resolve as resolve13 } from "node:path";
|
|
@@ -22791,28 +22814,17 @@ function rootSpans(text2) {
|
|
|
22791
22814
|
function object2(value) {
|
|
22792
22815
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22793
22816
|
}
|
|
22794
|
-
function canonical3(value) {
|
|
22795
|
-
if (Array.isArray(value))
|
|
22796
|
-
return `[${value.map(canonical3).join(",")}]`;
|
|
22797
|
-
if (object2(value)) {
|
|
22798
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical3(value[key])}`).join(",")}}`;
|
|
22799
|
-
}
|
|
22800
|
-
return JSON.stringify(value);
|
|
22801
|
-
}
|
|
22802
|
-
function digest2(value) {
|
|
22803
|
-
return createHash8("sha256").update(canonical3(value)).digest("hex");
|
|
22804
|
-
}
|
|
22805
22817
|
function code(error) {
|
|
22806
22818
|
return object2(error) ? error.code : void 0;
|
|
22807
22819
|
}
|
|
22808
|
-
async function safeRead(path2,
|
|
22820
|
+
async function safeRead(path2, afterReadCheck) {
|
|
22809
22821
|
if (windowsPrivateFiles) {
|
|
22810
22822
|
try {
|
|
22811
22823
|
await afterReadCheck?.(path2);
|
|
22812
22824
|
const bytes = await readPrivateBuffer(path2, true);
|
|
22813
22825
|
const text2 = bytes.toString("utf8");
|
|
22814
22826
|
if (!bytes.equals(Buffer.from(text2)))
|
|
22815
|
-
throw new PiSlotError(
|
|
22827
|
+
throw new PiSlotError("invalid-auth");
|
|
22816
22828
|
return text2;
|
|
22817
22829
|
} catch (error) {
|
|
22818
22830
|
if (code(error) === "ENOENT")
|
|
@@ -22824,7 +22836,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
22824
22836
|
try {
|
|
22825
22837
|
file = await open7(path2, constants2.O_RDONLY | constants2.O_NOFOLLOW);
|
|
22826
22838
|
const stat16 = await file.stat();
|
|
22827
|
-
if (!stat16.isFile()
|
|
22839
|
+
if (!stat16.isFile()) {
|
|
22828
22840
|
throw new PiSlotError("unsafe-path");
|
|
22829
22841
|
}
|
|
22830
22842
|
await afterReadCheck?.(path2);
|
|
@@ -22835,7 +22847,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
22835
22847
|
const bytes = await file.readFile();
|
|
22836
22848
|
const text2 = bytes.toString("utf8");
|
|
22837
22849
|
if (!bytes.equals(Buffer.from(text2))) {
|
|
22838
|
-
throw new PiSlotError(
|
|
22850
|
+
throw new PiSlotError("invalid-auth");
|
|
22839
22851
|
}
|
|
22840
22852
|
return text2;
|
|
22841
22853
|
} catch (error) {
|
|
@@ -22870,10 +22882,6 @@ function parseAuth(text2, provider2) {
|
|
|
22870
22882
|
throw new PiSlotError("invalid-auth");
|
|
22871
22883
|
}
|
|
22872
22884
|
}
|
|
22873
|
-
function entryText(auth) {
|
|
22874
|
-
const value = auth.property?.value;
|
|
22875
|
-
return value ? auth.text.slice(value.offset, value.offset + value.length) : null;
|
|
22876
|
-
}
|
|
22877
22885
|
function replaceEntry(auth, provider2, next) {
|
|
22878
22886
|
const { text: text2, root, property } = auth;
|
|
22879
22887
|
const properties = root.children ?? [];
|
|
@@ -22932,24 +22940,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
22932
22940
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
22933
22941
|
throw new PiSlotError("invalid-options");
|
|
22934
22942
|
}
|
|
22935
|
-
const authIdentity = digest2(authPath);
|
|
22936
|
-
const placeholderIdentity = digest2(placeholderKey);
|
|
22937
22943
|
const placeholder = { type: "api_key", key: placeholderKey };
|
|
22938
|
-
const isPlaceholder = (entry) =>
|
|
22939
|
-
async function loadStash() {
|
|
22940
|
-
const text2 = await safeRead(stashPath, true, hooks?.afterReadCheck);
|
|
22941
|
-
if (text2 === void 0)
|
|
22942
|
-
return void 0;
|
|
22943
|
-
try {
|
|
22944
|
-
const stash = JSON.parse(text2);
|
|
22945
|
-
if (stash.version !== 1 || stash.provider !== provider2 || stash.authIdentity !== authIdentity || stash.placeholderIdentity !== placeholderIdentity || stash.entry !== null && !object2(stash.entry) || stash.sha256 !== digest2(stash.entry) || (stash.entry === null ? stash.entryJson !== null : typeof stash.entryJson !== "string" || digest2(JSON.parse(stash.entryJson)) !== stash.sha256)) {
|
|
22946
|
-
throw new Error();
|
|
22947
|
-
}
|
|
22948
|
-
return stash;
|
|
22949
|
-
} catch {
|
|
22950
|
-
throw new PiSlotError("invalid-stash");
|
|
22951
|
-
}
|
|
22952
|
-
}
|
|
22944
|
+
const isPlaceholder = (entry) => entry !== null && Object.keys(entry).length === 2 && entry.type === placeholder.type && entry.key === placeholder.key;
|
|
22953
22945
|
async function locked(fn) {
|
|
22954
22946
|
let release;
|
|
22955
22947
|
let assertFresh;
|
|
@@ -22997,11 +22989,25 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
22997
22989
|
}
|
|
22998
22990
|
}
|
|
22999
22991
|
async function load() {
|
|
23000
|
-
|
|
23001
|
-
const stash = await loadStash();
|
|
23002
|
-
return { auth, stash };
|
|
22992
|
+
return parseAuth(await safeRead(authPath, hooks?.afterReadCheck) ?? "{}", provider2);
|
|
23003
22993
|
}
|
|
23004
22994
|
async function deleteStash(assertLock) {
|
|
22995
|
+
try {
|
|
22996
|
+
const file = await lstat5(stashPath);
|
|
22997
|
+
if (!file.isFile())
|
|
22998
|
+
throw new PiSlotError("unsafe-path");
|
|
22999
|
+
} catch (error) {
|
|
23000
|
+
if (code(error) === "ENOENT")
|
|
23001
|
+
return;
|
|
23002
|
+
throw error;
|
|
23003
|
+
}
|
|
23004
|
+
if (windowsPrivateFiles)
|
|
23005
|
+
await verifySafeDirectory(dirname12(stashPath));
|
|
23006
|
+
else {
|
|
23007
|
+
const dir = await lstat5(dirname12(stashPath));
|
|
23008
|
+
if (!dir.isDirectory() || (dir.mode & 511) !== 448)
|
|
23009
|
+
throw new PiSlotError("unsafe-path");
|
|
23010
|
+
}
|
|
23005
23011
|
assertLock();
|
|
23006
23012
|
await unlink8(stashPath);
|
|
23007
23013
|
await syncDir(dirname12(stashPath));
|
|
@@ -23009,58 +23015,27 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
23009
23015
|
}
|
|
23010
23016
|
return {
|
|
23011
23017
|
inspect: () => locked(async () => {
|
|
23012
|
-
const
|
|
23013
|
-
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" :
|
|
23014
|
-
return { slot
|
|
23018
|
+
const auth = await load();
|
|
23019
|
+
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" : "original";
|
|
23020
|
+
return { slot };
|
|
23015
23021
|
}),
|
|
23016
23022
|
enterVault: () => locked(async (assertLock) => {
|
|
23017
|
-
const
|
|
23018
|
-
if (isPlaceholder(auth.entry)) {
|
|
23019
|
-
|
|
23020
|
-
|
|
23021
|
-
return;
|
|
23022
|
-
}
|
|
23023
|
-
if (stash && digest2(auth.entry) !== stash.sha256)
|
|
23024
|
-
throw new PiSlotError("conflict");
|
|
23025
|
-
if (!stash) {
|
|
23026
|
-
if (windowsPrivateFiles)
|
|
23027
|
-
await ensurePrivateDirectory(dirname12(stashPath));
|
|
23028
|
-
else {
|
|
23029
|
-
await mkdir10(dirname12(stashPath), { recursive: true, mode: 448 });
|
|
23030
|
-
const dir = await lstat5(dirname12(stashPath));
|
|
23031
|
-
if (!dir.isDirectory() || (dir.mode & 511) !== 448)
|
|
23032
|
-
throw new PiSlotError("unsafe-path");
|
|
23033
|
-
}
|
|
23034
|
-
const saved = {
|
|
23035
|
-
version: 1,
|
|
23036
|
-
provider: provider2,
|
|
23037
|
-
authIdentity,
|
|
23038
|
-
placeholderIdentity,
|
|
23039
|
-
entry: auth.entry,
|
|
23040
|
-
entryJson: entryText(auth),
|
|
23041
|
-
sha256: digest2(auth.entry)
|
|
23042
|
-
};
|
|
23043
|
-
await atomicWrite(stashPath, JSON.stringify(saved), assertLock, hooks?.beforeRename);
|
|
23044
|
-
onStep?.("stash-written");
|
|
23023
|
+
const auth = await load();
|
|
23024
|
+
if (!isPlaceholder(auth.entry)) {
|
|
23025
|
+
await atomicWrite(authPath, replaceEntry(auth, provider2, JSON.stringify(placeholder)), assertLock, hooks?.beforeRename);
|
|
23026
|
+
onStep?.("auth-written");
|
|
23045
23027
|
}
|
|
23046
|
-
await
|
|
23047
|
-
onStep?.("auth-written");
|
|
23028
|
+
await deleteStash(assertLock);
|
|
23048
23029
|
}),
|
|
23049
23030
|
exitVault: () => locked(async (assertLock) => {
|
|
23050
|
-
const
|
|
23051
|
-
|
|
23052
|
-
|
|
23053
|
-
|
|
23054
|
-
return "nothing-to-do";
|
|
23055
|
-
}
|
|
23056
|
-
if (isPlaceholder(auth.entry)) {
|
|
23057
|
-
await atomicWrite(authPath, replaceEntry(auth, provider2, stash.entryJson), assertLock, hooks?.beforeRename);
|
|
23031
|
+
const auth = await load();
|
|
23032
|
+
const cleared = isPlaceholder(auth.entry);
|
|
23033
|
+
if (cleared) {
|
|
23034
|
+
await atomicWrite(authPath, replaceEntry(auth, provider2, null), assertLock, hooks?.beforeRename);
|
|
23058
23035
|
onStep?.("auth-written");
|
|
23059
|
-
} else if (digest2(auth.entry) !== stash.sha256) {
|
|
23060
|
-
return "conflict";
|
|
23061
23036
|
}
|
|
23062
23037
|
await deleteStash(assertLock);
|
|
23063
|
-
return "
|
|
23038
|
+
return cleared ? "cleared" : "nothing-to-do";
|
|
23064
23039
|
})
|
|
23065
23040
|
};
|
|
23066
23041
|
}
|
|
@@ -23152,6 +23127,32 @@ var init_harness_identity = __esm({
|
|
|
23152
23127
|
}
|
|
23153
23128
|
});
|
|
23154
23129
|
|
|
23130
|
+
// ../core/dist/pre-response-deadline.js
|
|
23131
|
+
var init_pre_response_deadline = __esm({
|
|
23132
|
+
"../core/dist/pre-response-deadline.js"() {
|
|
23133
|
+
"use strict";
|
|
23134
|
+
}
|
|
23135
|
+
});
|
|
23136
|
+
|
|
23137
|
+
// ../core/dist/vault-folder-refusal.js
|
|
23138
|
+
var init_vault_folder_refusal = __esm({
|
|
23139
|
+
"../core/dist/vault-folder-refusal.js"() {
|
|
23140
|
+
"use strict";
|
|
23141
|
+
}
|
|
23142
|
+
});
|
|
23143
|
+
|
|
23144
|
+
// ../core/dist/host-failure.js
|
|
23145
|
+
var init_host_failure = __esm({
|
|
23146
|
+
"../core/dist/host-failure.js"() {
|
|
23147
|
+
"use strict";
|
|
23148
|
+
init_account_migration();
|
|
23149
|
+
init_account_repository();
|
|
23150
|
+
init_credential_redaction();
|
|
23151
|
+
init_pre_response_deadline();
|
|
23152
|
+
init_vault_folder_refusal();
|
|
23153
|
+
}
|
|
23154
|
+
});
|
|
23155
|
+
|
|
23155
23156
|
// ../core/dist/model-types.js
|
|
23156
23157
|
var init_model_types = __esm({
|
|
23157
23158
|
"../core/dist/model-types.js"() {
|
|
@@ -23177,13 +23178,6 @@ var init_pi_paths = __esm({
|
|
|
23177
23178
|
}
|
|
23178
23179
|
});
|
|
23179
23180
|
|
|
23180
|
-
// ../core/dist/pre-response-deadline.js
|
|
23181
|
-
var init_pre_response_deadline = __esm({
|
|
23182
|
-
"../core/dist/pre-response-deadline.js"() {
|
|
23183
|
-
"use strict";
|
|
23184
|
-
}
|
|
23185
|
-
});
|
|
23186
|
-
|
|
23187
23181
|
// ../core/dist/project.js
|
|
23188
23182
|
function buildBootstrapRequestBody(extra = {}) {
|
|
23189
23183
|
return {
|
|
@@ -23435,12 +23429,12 @@ var init_project = __esm({
|
|
|
23435
23429
|
});
|
|
23436
23430
|
|
|
23437
23431
|
// ../core/dist/quota-manager.js
|
|
23438
|
-
import { createHash as
|
|
23432
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
23439
23433
|
function defaultKeyOf(account) {
|
|
23440
23434
|
if (account.email)
|
|
23441
23435
|
return `e:${account.email.toLowerCase()}`;
|
|
23442
23436
|
const token = account.refreshToken || "";
|
|
23443
|
-
return `t:${
|
|
23437
|
+
return `t:${createHash8("sha256").update(token).digest("hex").slice(0, 16)}`;
|
|
23444
23438
|
}
|
|
23445
23439
|
function createQuotaManager(options) {
|
|
23446
23440
|
const now = options.now ?? (() => Date.now());
|
|
@@ -23673,7 +23667,7 @@ function createQuotaManager(options) {
|
|
|
23673
23667
|
};
|
|
23674
23668
|
}
|
|
23675
23669
|
function hashKey(key) {
|
|
23676
|
-
return
|
|
23670
|
+
return createHash8("sha256").update(key).digest("hex").slice(0, 8);
|
|
23677
23671
|
}
|
|
23678
23672
|
function classifyQuotaGroup(modelName, displayName, hasArgonPool = false) {
|
|
23679
23673
|
if (isGeminiArgonModel(modelName))
|
|
@@ -24150,13 +24144,6 @@ var init_vault_enrollment_authority = __esm({
|
|
|
24150
24144
|
}
|
|
24151
24145
|
});
|
|
24152
24146
|
|
|
24153
|
-
// ../core/dist/vault-folder-refusal.js
|
|
24154
|
-
var init_vault_folder_refusal = __esm({
|
|
24155
|
-
"../core/dist/vault-folder-refusal.js"() {
|
|
24156
|
-
"use strict";
|
|
24157
|
-
}
|
|
24158
|
-
});
|
|
24159
|
-
|
|
24160
24147
|
// ../core/dist/version.js
|
|
24161
24148
|
var init_version = __esm({
|
|
24162
24149
|
"../core/dist/version.js"() {
|
|
@@ -24195,6 +24182,7 @@ var init_dist = __esm({
|
|
|
24195
24182
|
init_file_lock();
|
|
24196
24183
|
init_fingerprint();
|
|
24197
24184
|
init_harness_identity();
|
|
24185
|
+
init_host_failure();
|
|
24198
24186
|
init_logger();
|
|
24199
24187
|
init_model_registry();
|
|
24200
24188
|
init_model_types();
|
|
@@ -24238,7 +24226,9 @@ function ioCode2(detail) {
|
|
|
24238
24226
|
return detail?.code ?? "ERR_PRIVATE_FILE";
|
|
24239
24227
|
}
|
|
24240
24228
|
function privateFilesUnavailable2(cause) {
|
|
24241
|
-
return Object.assign(new Error("Windows private-files native addon
|
|
24229
|
+
return Object.assign(new Error("Windows private-files native addon could not be loaded", {
|
|
24230
|
+
cause
|
|
24231
|
+
}), {
|
|
24242
24232
|
code: "ERR_PRIVATE_FILES_UNAVAILABLE",
|
|
24243
24233
|
reason: PRIVATE_FILES_UNAVAILABLE_REASON2
|
|
24244
24234
|
});
|
|
@@ -24264,8 +24254,11 @@ function loadBackend2() {
|
|
|
24264
24254
|
});
|
|
24265
24255
|
return backend2;
|
|
24266
24256
|
}
|
|
24257
|
+
function isSharingIoError2(detail) {
|
|
24258
|
+
return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
|
|
24259
|
+
}
|
|
24267
24260
|
function isWindowsSharingViolation2(error) {
|
|
24268
|
-
return windowsPrivateFiles2 && error instanceof PrivateFileError2 &&
|
|
24261
|
+
return windowsPrivateFiles2 && error instanceof PrivateFileError2 && isSharingIoError2(error);
|
|
24269
24262
|
}
|
|
24270
24263
|
async function privateOperation2(path2, stage, operation) {
|
|
24271
24264
|
try {
|
|
@@ -24387,12 +24380,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
24387
24380
|
const delays = [0, 10, 20, 40, 80, 100];
|
|
24388
24381
|
let original;
|
|
24389
24382
|
let attempts2 = 0;
|
|
24390
|
-
for (const
|
|
24383
|
+
for (const delay5 of delays) {
|
|
24391
24384
|
const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
|
|
24392
24385
|
if (now() >= deadline)
|
|
24393
24386
|
break;
|
|
24394
|
-
if (
|
|
24395
|
-
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(
|
|
24387
|
+
if (delay5)
|
|
24388
|
+
await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay5, Math.max(0, deadline - now())));
|
|
24396
24389
|
if (now() >= deadline)
|
|
24397
24390
|
break;
|
|
24398
24391
|
const fenceStart = now();
|
|
@@ -24511,7 +24504,11 @@ var init_private_files2 = __esm({
|
|
|
24511
24504
|
orphanPath;
|
|
24512
24505
|
constructor(path2, stage, cause) {
|
|
24513
24506
|
const detail = cause;
|
|
24514
|
-
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ?
|
|
24507
|
+
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? (
|
|
24508
|
+
// The reason stays on `.reason`: its word "unavailable" would make
|
|
24509
|
+
// OpenCode 1 retry a plain error carrying this message.
|
|
24510
|
+
`Private file refused at ${stage}: ${path2}. 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.`
|
|
24511
|
+
) : isSharingIoError2(detail) ? `Private file busy at ${stage}: ${path2}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).` : `Private file refused at ${stage}: ${path2} (${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 });
|
|
24515
24512
|
this.path = path2;
|
|
24516
24513
|
this.stage = stage;
|
|
24517
24514
|
this.name = "PrivateFileError";
|
|
@@ -25557,7 +25554,7 @@ __export(runtime_layout_exports, {
|
|
|
25557
25554
|
runStoreMove: () => runStoreMove,
|
|
25558
25555
|
writeStateHomeStoreForward: () => writeStateHomeStoreForward
|
|
25559
25556
|
});
|
|
25560
|
-
import { createHash as
|
|
25557
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
25561
25558
|
import {
|
|
25562
25559
|
chmod as chmod4,
|
|
25563
25560
|
mkdir as mkdir12,
|
|
@@ -25571,8 +25568,8 @@ import {
|
|
|
25571
25568
|
import { basename as basename6, dirname as dirname16, join as join14, resolve as resolve17 } from "node:path";
|
|
25572
25569
|
function refusalMessage(stateDir, errorClass2) {
|
|
25573
25570
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
25574
|
-
return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it
|
|
25575
|
-
return `antigravity-auth cannot start: it could not settle where its vault files live in ${stateDir}
|
|
25571
|
+
return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it. Replace it with a plain folder of your own, then restart OpenCode. Check the plugin log for details.`;
|
|
25572
|
+
return `antigravity-auth cannot start: it could not settle where its vault files live in ${stateDir}. Check that this folder can be created and written by your user, then restart OpenCode. Check the plugin log for details.`;
|
|
25576
25573
|
}
|
|
25577
25574
|
function foreignFolder(stateDir, identity3) {
|
|
25578
25575
|
return new RuntimeLayoutRefusal(
|
|
@@ -26382,7 +26379,7 @@ function layoutFiles(location, accountFile) {
|
|
|
26382
26379
|
};
|
|
26383
26380
|
}
|
|
26384
26381
|
function sha256(bytes) {
|
|
26385
|
-
return
|
|
26382
|
+
return createHash9("sha256").update(bytes).digest("hex");
|
|
26386
26383
|
}
|
|
26387
26384
|
function vaultStateFile(files) {
|
|
26388
26385
|
return {
|
|
@@ -26558,8 +26555,8 @@ function isWindowsSharingError(error, platform) {
|
|
|
26558
26555
|
}
|
|
26559
26556
|
async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile10, unlink: unlink11 }) {
|
|
26560
26557
|
const started = performance.now();
|
|
26561
|
-
for (const
|
|
26562
|
-
if (
|
|
26558
|
+
for (const delay5 of SHARING_RETRY_DELAYS_MS) {
|
|
26559
|
+
if (delay5 > 0) await new Promise((done) => setTimeout(done, delay5));
|
|
26563
26560
|
let same;
|
|
26564
26561
|
try {
|
|
26565
26562
|
same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
|
|
@@ -27033,7 +27030,7 @@ async function assertLegacyPoolInUse(legacyPath) {
|
|
|
27033
27030
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
27034
27031
|
}
|
|
27035
27032
|
}
|
|
27036
|
-
function
|
|
27033
|
+
function accountStoreAdmissionMessage(admission) {
|
|
27037
27034
|
switch (admission.status) {
|
|
27038
27035
|
case "busy":
|
|
27039
27036
|
return new AccountStoreBusyError().message;
|
|
@@ -27068,7 +27065,7 @@ function unboundOpening(binding) {
|
|
|
27068
27065
|
return {
|
|
27069
27066
|
status: "refused",
|
|
27070
27067
|
admission: binding,
|
|
27071
|
-
message:
|
|
27068
|
+
message: accountStoreAdmissionMessage(binding)
|
|
27072
27069
|
};
|
|
27073
27070
|
}
|
|
27074
27071
|
async function openAccountStore(options) {
|
|
@@ -27110,7 +27107,7 @@ async function openAccountStore(options) {
|
|
|
27110
27107
|
return {
|
|
27111
27108
|
status: "refused",
|
|
27112
27109
|
admission,
|
|
27113
|
-
message:
|
|
27110
|
+
message: accountStoreAdmissionMessage(admission)
|
|
27114
27111
|
};
|
|
27115
27112
|
}
|
|
27116
27113
|
}
|
|
@@ -27160,7 +27157,7 @@ var init_storage = __esm({
|
|
|
27160
27157
|
});
|
|
27161
27158
|
|
|
27162
27159
|
// src/runtime-paths.ts
|
|
27163
|
-
import { createHash as
|
|
27160
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
27164
27161
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
27165
27162
|
import { homedir as homedir5 } from "node:os";
|
|
27166
27163
|
import { dirname as dirname18, join as join16, resolve as resolve19 } from "node:path";
|
|
@@ -27189,7 +27186,7 @@ function runtimeLayoutLocation(configDir = getConfigDir()) {
|
|
|
27189
27186
|
configDir,
|
|
27190
27187
|
stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
|
|
27191
27188
|
root,
|
|
27192
|
-
`opencode-${
|
|
27189
|
+
`opencode-${createHash10("sha256").update(key).digest("hex").slice(0, 16)}`
|
|
27193
27190
|
),
|
|
27194
27191
|
isDefaultConfigDir
|
|
27195
27192
|
};
|
|
@@ -29151,7 +29148,7 @@ async function select2(terminal, items, options) {
|
|
|
29151
29148
|
}
|
|
29152
29149
|
|
|
29153
29150
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
29154
|
-
import { createHash as
|
|
29151
|
+
import { createHash as createHash11, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
|
|
29155
29152
|
import { constants as fsConstants2 } from "node:fs";
|
|
29156
29153
|
import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat13, unlink as unlink13 } from "node:fs/promises";
|
|
29157
29154
|
import { basename as basename8, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join19, resolve as resolve22 } from "node:path";
|
|
@@ -30892,7 +30889,7 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
30892
30889
|
}
|
|
30893
30890
|
if (!state.requestId) {
|
|
30894
30891
|
try {
|
|
30895
|
-
const requestSecretHash =
|
|
30892
|
+
const requestSecretHash = createHash11("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
30896
30893
|
const proposal = {
|
|
30897
30894
|
name: state.proposedName,
|
|
30898
30895
|
requestSecretHash
|
|
@@ -31539,7 +31536,7 @@ async function detectHosts(plugin, io = {}) {
|
|
|
31539
31536
|
}
|
|
31540
31537
|
|
|
31541
31538
|
// src/common-auth-embedded/setup/enroll.js
|
|
31542
|
-
import { setTimeout as
|
|
31539
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
31543
31540
|
import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
|
|
31544
31541
|
|
|
31545
31542
|
// src/common-auth-embedded/setup/process-fence.js
|
|
@@ -31905,7 +31902,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
31905
31902
|
throw new HostNotEnrolledError("Claustrum connection failed; start ck and rerun setup.", { reason: "connection-failed" });
|
|
31906
31903
|
});
|
|
31907
31904
|
const now = io.now ?? (() => performance.now());
|
|
31908
|
-
const wait2 = io.wait ??
|
|
31905
|
+
const wait2 = io.wait ?? delay2;
|
|
31909
31906
|
try {
|
|
31910
31907
|
const manager = new ClaustrumEnrollmentManager2({
|
|
31911
31908
|
proposedName: name,
|
|
@@ -32139,7 +32136,7 @@ async function selectSetupHosts(terminal, found) {
|
|
|
32139
32136
|
|
|
32140
32137
|
// src/common-auth-embedded/setup/register.js
|
|
32141
32138
|
import { rename as rename14 } from "node:fs/promises";
|
|
32142
|
-
import { setTimeout as
|
|
32139
|
+
import { setTimeout as delay4 } from "node:timers/promises";
|
|
32143
32140
|
import { domainToUnicode } from "node:url";
|
|
32144
32141
|
import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
|
|
32145
32142
|
|
|
@@ -32147,7 +32144,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
|
|
|
32147
32144
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
32148
32145
|
import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat15, unlink as unlink14 } from "node:fs/promises";
|
|
32149
32146
|
import { basename as basename9, dirname as dirname21, join as join21 } from "node:path";
|
|
32150
|
-
import { setTimeout as
|
|
32147
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
32151
32148
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
32152
32149
|
const windows = (options.platform ?? process.platform) === "win32";
|
|
32153
32150
|
const parent = dirname21(file);
|
|
@@ -32186,7 +32183,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
32186
32183
|
const remaining = 2e3 - (now() - started);
|
|
32187
32184
|
if (!windows || !["EPERM", "EBUSY", "EACCES"].includes(code2 ?? "") || remaining <= 0 || attempt >= 40)
|
|
32188
32185
|
throw new Error(`Unable to replace host config ${file}. Close editors or other programs using the file, then rerun setup.`);
|
|
32189
|
-
await (options.wait ??
|
|
32186
|
+
await (options.wait ?? delay3)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
|
|
32190
32187
|
}
|
|
32191
32188
|
}
|
|
32192
32189
|
} finally {
|
|
@@ -32357,7 +32354,7 @@ async function registerOpenCode(writes, beforeWrite) {
|
|
|
32357
32354
|
// Only the rename publishes host-readable config; recheck on every retry.
|
|
32358
32355
|
beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
|
|
32359
32356
|
rename: guard ? (from, to) => guard.step(() => rename14(from, to)) : void 0,
|
|
32360
|
-
wait: guard ? (ms) => guard.step(() =>
|
|
32357
|
+
wait: guard ? (ms) => guard.step(() => delay4(ms)) : void 0
|
|
32361
32358
|
});
|
|
32362
32359
|
}
|
|
32363
32360
|
}
|
|
@@ -32827,20 +32824,12 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
32827
32824
|
});
|
|
32828
32825
|
} else if (selected === "pi") {
|
|
32829
32826
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
32830
|
-
|
|
32827
|
+
await openPiSlot2({
|
|
32831
32828
|
authPath: nativeAuthPath("pi", context),
|
|
32832
32829
|
stashPath: join23(piDir, "google-login-stash.json"),
|
|
32833
32830
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
32834
32831
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
32835
32832
|
}).inspect();
|
|
32836
|
-
if (inspection.slot === "foreign")
|
|
32837
|
-
throw new Error(
|
|
32838
|
-
"Pi has a different login from its saved stash; resolve the conflict before vault setup."
|
|
32839
|
-
);
|
|
32840
|
-
if (inspection.slot === "placeholder" && inspection.stash === "missing")
|
|
32841
|
-
throw new Error(
|
|
32842
|
-
"Pi holds a vault marker without its saved login stash; resolve it before vault setup."
|
|
32843
|
-
);
|
|
32844
32833
|
}
|
|
32845
32834
|
}
|
|
32846
32835
|
if (forceLogin && context.mode === "local" && context.hosts.includes("opencode") && context.opencodeGeneration !== "2") {
|