@cortexkit/anthropic-auth-core 2.16.0 → 2.16.2
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/index.js
CHANGED
|
@@ -721,6 +721,9 @@ function loadBackend() {
|
|
|
721
721
|
});
|
|
722
722
|
return backend;
|
|
723
723
|
}
|
|
724
|
+
function isSharingIoError(detail) {
|
|
725
|
+
return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
|
|
726
|
+
}
|
|
724
727
|
|
|
725
728
|
class PrivateFileError extends Error {
|
|
726
729
|
path;
|
|
@@ -736,7 +739,7 @@ class PrivateFileError extends Error {
|
|
|
736
739
|
orphanPath;
|
|
737
740
|
constructor(path, stage, cause) {
|
|
738
741
|
const detail = cause;
|
|
739
|
-
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path}. 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}: ${path} (${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 });
|
|
742
|
+
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path}. 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.` : isSharingIoError(detail) ? `Private file busy at ${stage}: ${path}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).` : `Private file refused at ${stage}: ${path} (${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 });
|
|
740
743
|
this.path = path;
|
|
741
744
|
this.stage = stage;
|
|
742
745
|
this.name = "PrivateFileError";
|
|
@@ -746,7 +749,7 @@ class PrivateFileError extends Error {
|
|
|
746
749
|
}
|
|
747
750
|
}
|
|
748
751
|
function isWindowsSharingViolation(error) {
|
|
749
|
-
return windowsPrivateFiles && error instanceof PrivateFileError &&
|
|
752
|
+
return windowsPrivateFiles && error instanceof PrivateFileError && isSharingIoError(error);
|
|
750
753
|
}
|
|
751
754
|
async function privateOperation(path, stage, operation) {
|
|
752
755
|
try {
|
|
@@ -3670,22 +3673,22 @@ function credentialTypeOf(row, family) {
|
|
|
3670
3673
|
return notMine;
|
|
3671
3674
|
if ("classify" in family) {
|
|
3672
3675
|
const metadata = rowFactsOf(row);
|
|
3673
|
-
let
|
|
3676
|
+
let type2;
|
|
3674
3677
|
switch (metadata.authMethod) {
|
|
3675
3678
|
case "apikey":
|
|
3676
|
-
|
|
3679
|
+
type2 = "api_key";
|
|
3677
3680
|
break;
|
|
3678
3681
|
case "chatgpt":
|
|
3679
3682
|
case "antigravity":
|
|
3680
3683
|
case "oauth":
|
|
3681
|
-
|
|
3684
|
+
type2 = "oauth";
|
|
3682
3685
|
break;
|
|
3683
3686
|
default:
|
|
3684
3687
|
return { kind: "refused", code: "unknown-auth-method" };
|
|
3685
3688
|
}
|
|
3686
3689
|
const facts = {
|
|
3687
3690
|
credentialId: row.id,
|
|
3688
|
-
credentialType:
|
|
3691
|
+
credentialType: type2,
|
|
3689
3692
|
categories: row.categories,
|
|
3690
3693
|
refreshAdapter: row.refreshAdapter,
|
|
3691
3694
|
...metadata
|
|
@@ -3697,24 +3700,37 @@ function credentialTypeOf(row, family) {
|
|
|
3697
3700
|
if (result.kind === "not-mine")
|
|
3698
3701
|
return notMine;
|
|
3699
3702
|
if (result.kind === "mine" && typeof result.member === "string")
|
|
3700
|
-
return { kind: "mine", type, member: result.member };
|
|
3703
|
+
return { kind: "mine", type: type2, member: result.member };
|
|
3701
3704
|
if (result.kind === "refused" && typeof result.code === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(result.code) && !result.code.includes(`
|
|
3702
3705
|
`) && family.refusalCodes.includes(result.code))
|
|
3703
3706
|
return { kind: "refused", code: result.code };
|
|
3704
3707
|
} catch {}
|
|
3705
3708
|
return { kind: "refused", code: "unclassified" };
|
|
3706
3709
|
}
|
|
3707
|
-
|
|
3710
|
+
const type = row.credentialType;
|
|
3711
|
+
if (type === "oauth") {
|
|
3712
|
+
if (row.refreshAdapter !== family.refreshAdapter)
|
|
3713
|
+
return notMine;
|
|
3714
|
+
} else if (type === "api_key") {
|
|
3715
|
+
if (!family.apiKeys || row.refreshAdapter !== undefined)
|
|
3716
|
+
return notMine;
|
|
3717
|
+
} else {
|
|
3708
3718
|
return notMine;
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
if (
|
|
3712
|
-
|
|
3713
|
-
|
|
3719
|
+
}
|
|
3720
|
+
const { authMethod } = rowFactsOf(row, { includeProviderIds: false });
|
|
3721
|
+
if (authMethod !== undefined) {
|
|
3722
|
+
const matchesType = type === "oauth" ? authMethod === "chatgpt" || authMethod === "antigravity" || authMethod === "oauth" : authMethod === "apikey";
|
|
3723
|
+
if (!matchesType)
|
|
3724
|
+
return { kind: "refused", code: "unknown-auth-method" };
|
|
3725
|
+
}
|
|
3726
|
+
return { kind: "mine", type };
|
|
3714
3727
|
}
|
|
3715
|
-
function rowFactsOf(row) {
|
|
3728
|
+
function rowFactsOf(row, { includeProviderIds = true } = {}) {
|
|
3716
3729
|
const metadata = row;
|
|
3717
|
-
return {
|
|
3730
|
+
return {
|
|
3731
|
+
providerIds: includeProviderIds ? metadata.providerIds : undefined,
|
|
3732
|
+
authMethod: metadata.authMethod
|
|
3733
|
+
};
|
|
3718
3734
|
}
|
|
3719
3735
|
function grantReachOf(listed) {
|
|
3720
3736
|
const { grants, grantTuples } = listed;
|
|
@@ -4010,14 +4026,15 @@ class ClaustrumScopedCustody {
|
|
|
4010
4026
|
for (const record2 of skipped)
|
|
4011
4027
|
this.#logger.warn("skipped malformed vault record", record2);
|
|
4012
4028
|
const grantReach = grantReachOf(inventory);
|
|
4029
|
+
const classifying = "classify" in this.#family;
|
|
4013
4030
|
return {
|
|
4014
4031
|
view: inventory.view,
|
|
4015
4032
|
credentials: Object.freeze(credentials),
|
|
4016
4033
|
skipped: Object.freeze(skipped),
|
|
4017
|
-
...
|
|
4018
|
-
refused: Object.freeze(refused)
|
|
4019
|
-
notMine
|
|
4034
|
+
...(classifying || refused.length > 0) && {
|
|
4035
|
+
refused: Object.freeze(refused)
|
|
4020
4036
|
},
|
|
4037
|
+
...classifying && { notMine },
|
|
4021
4038
|
...grantReach && { grantReach }
|
|
4022
4039
|
};
|
|
4023
4040
|
}
|
|
@@ -7359,6 +7376,9 @@ async function connectClaustrumScopedClient(options) {
|
|
|
7359
7376
|
clearTimeout(timer);
|
|
7360
7377
|
}
|
|
7361
7378
|
}
|
|
7379
|
+
// ../../node_modules/@cortexkit/common-auth/dist/routing-accessor/index.js
|
|
7380
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
7381
|
+
|
|
7362
7382
|
// ../../node_modules/@cortexkit/common-auth/dist/routing-accessor/handle.js
|
|
7363
7383
|
function routingHandle(sessionId) {
|
|
7364
7384
|
const routing = Reflect.get(globalThis, Symbol.for("cortexkit.routing"));
|
|
@@ -7499,6 +7519,39 @@ function isObject(value) {
|
|
|
7499
7519
|
function isNonEmptyString(value) {
|
|
7500
7520
|
return typeof value === "string" && value.length > 0;
|
|
7501
7521
|
}
|
|
7522
|
+
function isBoundedControlFreeString(value, maxLength) {
|
|
7523
|
+
return isNonEmptyString(value) && value.length <= maxLength && !/\p{Cc}/u.test(value);
|
|
7524
|
+
}
|
|
7525
|
+
function isRoutingCode(value) {
|
|
7526
|
+
return typeof value === "string" && /^[a-z0-9._-]{1,64}$/.test(value);
|
|
7527
|
+
}
|
|
7528
|
+
function continueExhaustion(value) {
|
|
7529
|
+
if (!isObject(value) || Array.isArray(value))
|
|
7530
|
+
return;
|
|
7531
|
+
const { accountId, credentialId, limitWindow, observedAtMs } = value;
|
|
7532
|
+
if (!isBoundedControlFreeString(accountId, 256) || !isBoundedControlFreeString(credentialId, 256) || typeof observedAtMs !== "number" || !Number.isSafeInteger(observedAtMs) || observedAtMs <= 0 || limitWindow !== "five_hour" && limitWindow !== "seven_day" && limitWindow !== "signed_out")
|
|
7533
|
+
return;
|
|
7534
|
+
const exhausted = {
|
|
7535
|
+
account: accountId,
|
|
7536
|
+
credential_id: credentialId,
|
|
7537
|
+
limit_window: limitWindow,
|
|
7538
|
+
observed_at_ms: observedAtMs
|
|
7539
|
+
};
|
|
7540
|
+
if (limitWindow === "signed_out") {
|
|
7541
|
+
if ("pool" in value || "resetsAtMs" in value || "retryAfterS" in value)
|
|
7542
|
+
return;
|
|
7543
|
+
return exhausted;
|
|
7544
|
+
}
|
|
7545
|
+
const { pool, resetsAtMs, retryAfterS } = value;
|
|
7546
|
+
if (pool !== undefined && !isRoutingCode(pool) || resetsAtMs !== undefined && (typeof resetsAtMs !== "number" || !Number.isSafeInteger(resetsAtMs) || resetsAtMs <= 0) || retryAfterS !== undefined && (typeof retryAfterS !== "number" || !Number.isFinite(retryAfterS) || retryAfterS < 0))
|
|
7547
|
+
return;
|
|
7548
|
+
return {
|
|
7549
|
+
...exhausted,
|
|
7550
|
+
...pool !== undefined ? { pool } : {},
|
|
7551
|
+
...resetsAtMs !== undefined ? { resets_at_ms: resetsAtMs } : {},
|
|
7552
|
+
...retryAfterS !== undefined ? { retry_after_s: Math.floor(retryAfterS) } : {}
|
|
7553
|
+
};
|
|
7554
|
+
}
|
|
7502
7555
|
function billingCache(value) {
|
|
7503
7556
|
if (!isObject(value) || Array.isArray(value))
|
|
7504
7557
|
return;
|
|
@@ -7579,6 +7632,22 @@ function turnNotes(sessionId) {
|
|
|
7579
7632
|
return [];
|
|
7580
7633
|
}
|
|
7581
7634
|
}
|
|
7635
|
+
function candidateView(candidates) {
|
|
7636
|
+
const accounts = [];
|
|
7637
|
+
for (const { accountId, credentialId } of candidates) {
|
|
7638
|
+
if (isNonEmptyString(accountId) && isBoundedControlFreeString(credentialId, 256)) {
|
|
7639
|
+
accounts.push({ account_id: accountId, credential_id: credentialId });
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
if (accounts.length === 0)
|
|
7643
|
+
return;
|
|
7644
|
+
const lines = accounts.map(({ account_id, credential_id }) => Buffer.from(`${account_id} ${credential_id}
|
|
7645
|
+
`, "utf8")).sort(Buffer.compare);
|
|
7646
|
+
const hash2 = createHash4("sha256");
|
|
7647
|
+
for (const line of lines)
|
|
7648
|
+
hash2.update(line);
|
|
7649
|
+
return { view_digest: hash2.digest("hex"), accounts };
|
|
7650
|
+
}
|
|
7582
7651
|
function selectionFor(answer, candidates) {
|
|
7583
7652
|
if (!isObject(answer))
|
|
7584
7653
|
return;
|
|
@@ -7607,10 +7676,11 @@ function refusalFor(value) {
|
|
|
7607
7676
|
return;
|
|
7608
7677
|
}
|
|
7609
7678
|
const refused = { code };
|
|
7610
|
-
const routingCode = value
|
|
7611
|
-
if (
|
|
7679
|
+
const { routing_code: routingCode, reason } = value;
|
|
7680
|
+
if (isRoutingCode(routingCode))
|
|
7612
7681
|
refused.routingCode = routingCode;
|
|
7613
|
-
|
|
7682
|
+
if (isRoutingCode(reason))
|
|
7683
|
+
refused.reason = reason;
|
|
7614
7684
|
const retryAfterSecs = value.retry_after_secs;
|
|
7615
7685
|
if (typeof retryAfterSecs === "number" && Number.isFinite(retryAfterSecs) && retryAfterSecs >= 0) {
|
|
7616
7686
|
refused.retryAfterSecs = retryAfterSecs;
|
|
@@ -7624,6 +7694,21 @@ function refusalFor(value) {
|
|
|
7624
7694
|
async function askRouting(input) {
|
|
7625
7695
|
let timer;
|
|
7626
7696
|
try {
|
|
7697
|
+
const request2 = {
|
|
7698
|
+
provider: input.provider,
|
|
7699
|
+
modelId: input.modelId
|
|
7700
|
+
};
|
|
7701
|
+
if (input.mode === "continue") {
|
|
7702
|
+
const { requestId } = input;
|
|
7703
|
+
if (!isBoundedControlFreeString(requestId, 128))
|
|
7704
|
+
return;
|
|
7705
|
+
const exhausted = continueExhaustion(input.exhausted);
|
|
7706
|
+
if (!exhausted)
|
|
7707
|
+
return;
|
|
7708
|
+
request2.mode = "continue";
|
|
7709
|
+
request2.request_id = requestId;
|
|
7710
|
+
request2.exhausted = exhausted;
|
|
7711
|
+
}
|
|
7627
7712
|
const handle = routingHandle(input.sessionId);
|
|
7628
7713
|
if (!handle)
|
|
7629
7714
|
return;
|
|
@@ -7636,10 +7721,6 @@ async function askRouting(input) {
|
|
|
7636
7721
|
timer = setTimeout(() => resolve12(undefined), deadlineMs);
|
|
7637
7722
|
timer.unref();
|
|
7638
7723
|
});
|
|
7639
|
-
const request2 = {
|
|
7640
|
-
provider: input.provider,
|
|
7641
|
-
modelId: input.modelId
|
|
7642
|
-
};
|
|
7643
7724
|
const cap = input.holdWaitMaxS;
|
|
7644
7725
|
if (typeof cap === "number" && Number.isFinite(cap)) {
|
|
7645
7726
|
request2.hold_wait_max_s = Math.max(0, Math.floor(cap));
|
|
@@ -7647,9 +7728,12 @@ async function askRouting(input) {
|
|
|
7647
7728
|
if (input.refusals === true)
|
|
7648
7729
|
request2.refusals = true;
|
|
7649
7730
|
const warmCredentialId = input.warmCredentialId;
|
|
7650
|
-
if (
|
|
7731
|
+
if (isBoundedControlFreeString(warmCredentialId, 256) && input.candidates.some((candidate) => candidate.credentialId === warmCredentialId)) {
|
|
7651
7732
|
request2.warm_credential = warmCredentialId;
|
|
7652
7733
|
}
|
|
7734
|
+
const candidates = candidateView(input.candidates);
|
|
7735
|
+
if (candidates)
|
|
7736
|
+
request2.candidates = candidates;
|
|
7653
7737
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
7654
7738
|
if (!isObject(pending) || typeof pending.then !== "function")
|
|
7655
7739
|
return;
|
|
@@ -7676,6 +7760,19 @@ function reportRouting(input) {
|
|
|
7676
7760
|
let payload;
|
|
7677
7761
|
if ("kind" in input) {
|
|
7678
7762
|
switch (input.kind) {
|
|
7763
|
+
case "transient_backoff": {
|
|
7764
|
+
const { accountId, credentialId, retryAtMs, providerCode } = input;
|
|
7765
|
+
if (!isNonEmptyString(sessionId) || !isNonEmptyString(accountId) || !Number.isSafeInteger(retryAtMs) || retryAtMs <= 0 || credentialId !== undefined && !isBoundedControlFreeString(credentialId, 256) || providerCode !== undefined && !isBoundedControlFreeString(providerCode, 128))
|
|
7766
|
+
return;
|
|
7767
|
+
payload = {
|
|
7768
|
+
kind: "transient_backoff",
|
|
7769
|
+
account_id: accountId,
|
|
7770
|
+
...credentialId !== undefined ? { credential_id: credentialId } : {},
|
|
7771
|
+
retry_at_ms: retryAtMs,
|
|
7772
|
+
...providerCode !== undefined ? { provider_code: providerCode } : {}
|
|
7773
|
+
};
|
|
7774
|
+
break;
|
|
7775
|
+
}
|
|
7679
7776
|
case "wait": {
|
|
7680
7777
|
const { phase, waitId, reason, nextMs, attempt, message, outcome } = input;
|
|
7681
7778
|
if (!isNonEmptyString(sessionId) || phase !== "start" && phase !== "end" || !isNonEmptyString(waitId) || waitId.length > 64 || /[^A-Za-z0-9._:-]/.test(waitId) || !PLUGIN_WAIT_REASONS.includes(reason))
|
|
@@ -7771,7 +7868,7 @@ function reportRouting(input) {
|
|
|
7771
7868
|
const { window, pool } = input;
|
|
7772
7869
|
if (window !== "5h" && window !== "7d")
|
|
7773
7870
|
return;
|
|
7774
|
-
if (pool !== undefined && (
|
|
7871
|
+
if (pool !== undefined && !isRoutingCode(pool))
|
|
7775
7872
|
return;
|
|
7776
7873
|
payload = {
|
|
7777
7874
|
...identity2,
|
|
@@ -8548,6 +8645,7 @@ import { writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexki
|
|
|
8548
8645
|
import { statSync as statSync3 } from "node:fs";
|
|
8549
8646
|
import { win32 as win322 } from "node:path";
|
|
8550
8647
|
var WINDOWS_CIM_TIMEOUT_MS = 45000;
|
|
8648
|
+
var log = createLogger("setup-process-fence");
|
|
8551
8649
|
var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 90000;
|
|
8552
8650
|
function isFile(file) {
|
|
8553
8651
|
try {
|
|
@@ -8710,14 +8808,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8710
8808
|
options.onStep?.({ ...inspection });
|
|
8711
8809
|
}
|
|
8712
8810
|
};
|
|
8713
|
-
const inspectCim = (args) => {
|
|
8811
|
+
const inspectCim = async (args) => {
|
|
8714
8812
|
const pwsh = win322.resolve(windowsEnv(env, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
|
|
8715
8813
|
const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
|
|
8716
8814
|
const arm64 = (windowsEnv(env, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
|
|
8717
8815
|
const slow = program === "powershell" && arm64;
|
|
8718
8816
|
if (slow)
|
|
8719
8817
|
options.onProgress?.("Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.");
|
|
8720
|
-
|
|
8818
|
+
const file = program === "pwsh" ? pwsh : win322.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
8819
|
+
const timeoutMs = slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS;
|
|
8820
|
+
const started = performance.now();
|
|
8821
|
+
const result = await inspect("CIM", file, args, timeoutMs, program);
|
|
8822
|
+
const remaining = Math.floor(timeoutMs - (performance.now() - started));
|
|
8823
|
+
if ((result.exitCode === 3221225477 || result.exitCode === -1073741819) && !result.timedOut && !result.signal && !result.spawnError && remaining > 0) {
|
|
8824
|
+
log.warn("Windows process query crashed with an access violation; retrying once");
|
|
8825
|
+
return inspect("CIM", file, args, remaining, program);
|
|
8826
|
+
}
|
|
8827
|
+
return result;
|
|
8721
8828
|
};
|
|
8722
8829
|
try {
|
|
8723
8830
|
if (windows && options.hostImagesOnly) {
|
|
@@ -9619,7 +9726,7 @@ ${write.content}`);
|
|
|
9619
9726
|
return { hosts, dryRun: options.dryRun, mode, detection };
|
|
9620
9727
|
}
|
|
9621
9728
|
// src/accounts.ts
|
|
9622
|
-
import { createHash as
|
|
9729
|
+
import { createHash as createHash5, randomUUID as randomUUID8 } from "node:crypto";
|
|
9623
9730
|
import { mkdir as mkdir6, readFile as readFile7, rename as rename8, rm as rm4, stat as stat10, writeFile } from "node:fs/promises";
|
|
9624
9731
|
import { homedir as homedir3 } from "node:os";
|
|
9625
9732
|
import { join as join13 } from "node:path";
|
|
@@ -11909,7 +12016,7 @@ async function exists(path) {
|
|
|
11909
12016
|
throw error;
|
|
11910
12017
|
}
|
|
11911
12018
|
}
|
|
11912
|
-
function
|
|
12019
|
+
function log2(options, level, message, data) {
|
|
11913
12020
|
try {
|
|
11914
12021
|
options.log[level](message, data);
|
|
11915
12022
|
} catch {}
|
|
@@ -11979,7 +12086,7 @@ function merge(options, legacy, mapped, result) {
|
|
|
11979
12086
|
}));
|
|
11980
12087
|
if (values.some(({ host, value }) => !isDeepStrictEqual2(hosts.has(host) ? hosts.get(host) : primary.value, value))) {
|
|
11981
12088
|
result.differing.push({ setting, values });
|
|
11982
|
-
|
|
12089
|
+
log2(options, "info", `Differing legacy settings: ${setting}`, { values });
|
|
11983
12090
|
}
|
|
11984
12091
|
}
|
|
11985
12092
|
return document;
|
|
@@ -12016,7 +12123,7 @@ A rollback loses changes made after the move.
|
|
|
12016
12123
|
}
|
|
12017
12124
|
} catch (error) {
|
|
12018
12125
|
result.noteFailures.push({ path, error });
|
|
12019
|
-
|
|
12126
|
+
log2(options, "warn", "Could not write settings move note", {
|
|
12020
12127
|
path,
|
|
12021
12128
|
error
|
|
12022
12129
|
});
|
|
@@ -12061,7 +12168,7 @@ ${JSON.stringify(document, null, 2)}
|
|
|
12061
12168
|
staged = false;
|
|
12062
12169
|
} catch (error) {
|
|
12063
12170
|
result.postPublishFailures.push({ step: "temp-unlink", error });
|
|
12064
|
-
|
|
12171
|
+
log2(options, "warn", "Settings move temp cleanup failed", { temp, error });
|
|
12065
12172
|
}
|
|
12066
12173
|
if (process.platform !== "win32") {
|
|
12067
12174
|
try {
|
|
@@ -12073,7 +12180,7 @@ ${JSON.stringify(document, null, 2)}
|
|
|
12073
12180
|
}
|
|
12074
12181
|
} catch (error) {
|
|
12075
12182
|
result.postPublishFailures.push({ step: "directory-sync", error });
|
|
12076
|
-
|
|
12183
|
+
log2(options, "warn", "Settings move directory sync failed", {
|
|
12077
12184
|
target,
|
|
12078
12185
|
error
|
|
12079
12186
|
});
|
|
@@ -12181,7 +12288,7 @@ async function moveSettingsOnce(options) {
|
|
|
12181
12288
|
if (settled.outcome === "moved") {
|
|
12182
12289
|
settled.postPublishFailures.push({ step: "lock-release", error });
|
|
12183
12290
|
}
|
|
12184
|
-
|
|
12291
|
+
log2(options, "warn", "Settings move lock release failed", { error });
|
|
12185
12292
|
return settled;
|
|
12186
12293
|
}
|
|
12187
12294
|
} catch (cause) {
|
|
@@ -12803,7 +12910,7 @@ function getRefreshIntervalMs(storage) {
|
|
|
12803
12910
|
return Math.max(1, minutes) * 60000;
|
|
12804
12911
|
}
|
|
12805
12912
|
function hashRefreshToken(refreshToken) {
|
|
12806
|
-
return
|
|
12913
|
+
return createHash5("sha256").update(refreshToken).digest("hex");
|
|
12807
12914
|
}
|
|
12808
12915
|
function isTransientRefreshError(error) {
|
|
12809
12916
|
const status = error.status;
|
|
@@ -13108,7 +13215,7 @@ function quotaRefusalTiming(input) {
|
|
|
13108
13215
|
}
|
|
13109
13216
|
const earliest = resetTimes.sort((a, b) => a.resetAt - b.resetAt)[0];
|
|
13110
13217
|
const resetAt = earliest?.resetAt;
|
|
13111
|
-
const resetWaitMs = input.waitForReset && getWaitForReset(storage) && resetAt !== undefined && input.readings.length > 0 && resetTimes.length === input.readings.length ? (Math.ceil((resetAt - now) / 1000) +
|
|
13218
|
+
const resetWaitMs = input.waitForReset && getWaitForReset(storage) && resetAt !== undefined && input.readings.length > 0 && resetTimes.length === input.readings.length ? (Math.ceil((resetAt - now) / 1000) + createHash5("sha256").update(input.sessionId ?? "").digest().readUInt32BE(0) % 21) * 1000 : undefined;
|
|
13112
13219
|
return {
|
|
13113
13220
|
resetAt,
|
|
13114
13221
|
...resetWaitMs === undefined ? {} : { resetWaitMs },
|
|
@@ -13567,7 +13674,7 @@ function scheduleFlush() {
|
|
|
13567
13674
|
}, FLUSH_INTERVAL_MS);
|
|
13568
13675
|
}
|
|
13569
13676
|
var CHANNEL_REGEX = /^\[([\w-]+)\]\s*/;
|
|
13570
|
-
function
|
|
13677
|
+
function log3(message, data) {
|
|
13571
13678
|
if (!shouldEmit("debug"))
|
|
13572
13679
|
return;
|
|
13573
13680
|
if (isTestEnv)
|
|
@@ -14369,7 +14476,7 @@ function executeCache1hCommand(input) {
|
|
|
14369
14476
|
}
|
|
14370
14477
|
// src/cachekeep.ts
|
|
14371
14478
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
14372
|
-
import { createHash as
|
|
14479
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
14373
14480
|
|
|
14374
14481
|
// ../../node_modules/@cortexkit/common-auth/dist/cachekeep/decision.js
|
|
14375
14482
|
function withinHours(hours, at) {
|
|
@@ -15086,7 +15193,7 @@ class CacheKeepManager {
|
|
|
15086
15193
|
}
|
|
15087
15194
|
}
|
|
15088
15195
|
// src/claustrum-enrollment.ts
|
|
15089
|
-
import { createHash as
|
|
15196
|
+
import { createHash as createHash7, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
|
|
15090
15197
|
import { constants as fsConstants2 } from "node:fs";
|
|
15091
15198
|
import {
|
|
15092
15199
|
chmod as chmod2,
|
|
@@ -15247,7 +15354,7 @@ async function ensureWindowsOwnerOnlyDirectory(path2, options = {}) {
|
|
|
15247
15354
|
}
|
|
15248
15355
|
|
|
15249
15356
|
// src/state-layout-paths.ts
|
|
15250
|
-
import { createHash as
|
|
15357
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
15251
15358
|
import { realpathSync as realpathSync3 } from "node:fs";
|
|
15252
15359
|
import { open as open7 } from "node:fs/promises";
|
|
15253
15360
|
import { homedir as homedir4 } from "node:os";
|
|
@@ -15298,7 +15405,7 @@ function homeDefaultConfigDir(home = homedir4(), pathApi = nodePath) {
|
|
|
15298
15405
|
function stateSubfolderName(identity4, homeDefaultIdentity) {
|
|
15299
15406
|
if (identity4 === homeDefaultIdentity)
|
|
15300
15407
|
return "opencode";
|
|
15301
|
-
const hash2 =
|
|
15408
|
+
const hash2 = createHash6("sha256").update(identity4).digest("hex");
|
|
15302
15409
|
return `opencode-${hash2.slice(0, 16)}`;
|
|
15303
15410
|
}
|
|
15304
15411
|
function resolveStateHomeTarget(options = {}) {
|
|
@@ -15867,7 +15974,7 @@ class ClaustrumEnrollmentManager2 {
|
|
|
15867
15974
|
}
|
|
15868
15975
|
if (!state.requestId) {
|
|
15869
15976
|
try {
|
|
15870
|
-
const requestSecretHash =
|
|
15977
|
+
const requestSecretHash = createHash7("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
15871
15978
|
const proposed = await this.#client.enrollPropose({
|
|
15872
15979
|
name: state.proposedName,
|
|
15873
15980
|
requestSecretHash
|
|
@@ -16666,7 +16773,7 @@ class CacheKeepPrewarmError extends Error {
|
|
|
16666
16773
|
}
|
|
16667
16774
|
|
|
16668
16775
|
// src/cch.ts
|
|
16669
|
-
import { createHash as
|
|
16776
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
16670
16777
|
import xxhashInit from "xxhash-wasm";
|
|
16671
16778
|
var ANTHROPIC_REQUEST_ID_PATTERN = /^req_[A-Za-z0-9_-]{8,128}$/;
|
|
16672
16779
|
var PROMPT_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
@@ -16776,7 +16883,7 @@ async function signRequestBody(bodyString) {
|
|
|
16776
16883
|
}
|
|
16777
16884
|
function computeCcVersionSuffix(firstUserText, version = CLAUDE_CODE_VERSION) {
|
|
16778
16885
|
const sampledText = CCH_POSITIONS.map((position) => firstUserText[position] ?? "0").join("");
|
|
16779
|
-
return
|
|
16886
|
+
return createHash8("sha256").update(`${CCH_SALT}${sampledText}${version}`).digest("hex").slice(0, 3);
|
|
16780
16887
|
}
|
|
16781
16888
|
function countUserPrompts(messages) {
|
|
16782
16889
|
if (!Array.isArray(messages))
|
|
@@ -17260,7 +17367,7 @@ function claudeCodeEntrypoint() {
|
|
|
17260
17367
|
}
|
|
17261
17368
|
|
|
17262
17369
|
// src/dump.ts
|
|
17263
|
-
import { createHash as
|
|
17370
|
+
import { createHash as createHash9, randomBytes as randomBytes4 } from "node:crypto";
|
|
17264
17371
|
import {
|
|
17265
17372
|
lstat as lstat6,
|
|
17266
17373
|
mkdir as mkdir8,
|
|
@@ -18068,7 +18175,7 @@ function headersToRecord(headers) {
|
|
|
18068
18175
|
return Object.fromEntries(new Headers(headers).entries());
|
|
18069
18176
|
}
|
|
18070
18177
|
function hashText(value) {
|
|
18071
|
-
return
|
|
18178
|
+
return createHash9("sha256").update(value).digest("hex");
|
|
18072
18179
|
}
|
|
18073
18180
|
function cchToken(bodyText) {
|
|
18074
18181
|
return extractBillingHeaderCCH(bodyText);
|
|
@@ -20334,7 +20441,7 @@ function cacheWarmCacheablePrefixFingerprint(bodyText) {
|
|
|
20334
20441
|
system,
|
|
20335
20442
|
messages: messages.slice(0, lastBreakpoint + 1)
|
|
20336
20443
|
});
|
|
20337
|
-
return
|
|
20444
|
+
return createHash10("sha256").update(JSON.stringify(prefix)).digest("hex");
|
|
20338
20445
|
}
|
|
20339
20446
|
function cacheKeepSourceWarmIdleCap(modelId) {
|
|
20340
20447
|
let pricing;
|
|
@@ -21873,16 +21980,16 @@ function observeNativeLocks(acquire, observer) {
|
|
|
21873
21980
|
}
|
|
21874
21981
|
|
|
21875
21982
|
// src/native-vault-paths.ts
|
|
21876
|
-
import { createHash as
|
|
21983
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
21877
21984
|
import { basename as basename12, dirname as dirname18, join as join22 } from "node:path";
|
|
21878
21985
|
|
|
21879
21986
|
// src/pool-paths.ts
|
|
21880
|
-
import { createHash as
|
|
21987
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
21881
21988
|
import * as fsPromises from "node:fs/promises";
|
|
21882
21989
|
import { basename as basename11, dirname as dirname17, join as join21 } from "node:path";
|
|
21883
21990
|
|
|
21884
21991
|
// src/sticky-routing.ts
|
|
21885
|
-
import { createHash as
|
|
21992
|
+
import { createHash as createHash18, randomUUID as randomUUID15 } from "node:crypto";
|
|
21886
21993
|
import { mkdir as mkdir10, readFile as readFile11, rename as rename13, rm as rm6, stat as stat12, writeFile as writeFile3 } from "node:fs/promises";
|
|
21887
21994
|
import { basename as basename10, dirname as dirname16, join as join20 } from "node:path";
|
|
21888
21995
|
|
|
@@ -21890,7 +21997,7 @@ import { basename as basename10, dirname as dirname16, join as join20 } from "no
|
|
|
21890
21997
|
import { lstat as lstat9, readFile as readFile10 } from "node:fs/promises";
|
|
21891
21998
|
|
|
21892
21999
|
// src/native-migration-source.ts
|
|
21893
|
-
import { createHash as
|
|
22000
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
21894
22001
|
|
|
21895
22002
|
// ../../node_modules/@cortexkit/common-auth/dist/store/errors.js
|
|
21896
22003
|
class PoolOperationError extends Error {
|
|
@@ -21999,7 +22106,7 @@ async function callFailureHook(operation, hook, rowId, error, logger3) {
|
|
|
21999
22106
|
}
|
|
22000
22107
|
|
|
22001
22108
|
// ../../node_modules/@cortexkit/common-auth/dist/store/mutate.js
|
|
22002
|
-
import { setTimeout as
|
|
22109
|
+
import { setTimeout as delay4 } from "node:timers/promises";
|
|
22003
22110
|
|
|
22004
22111
|
// ../../node_modules/@cortexkit/common-auth/dist/store/reserved.js
|
|
22005
22112
|
function assertNotReserved(operation, id, reservation) {
|
|
@@ -22015,7 +22122,7 @@ function assertNotReserved(operation, id, reservation) {
|
|
|
22015
22122
|
}
|
|
22016
22123
|
|
|
22017
22124
|
// ../../node_modules/@cortexkit/common-auth/dist/store/schema.js
|
|
22018
|
-
import { createHash as
|
|
22125
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
22019
22126
|
var POOL_KEY = "commonAuthPool";
|
|
22020
22127
|
var POOL_SCHEMA_VERSION = 1;
|
|
22021
22128
|
var POOL_ROWS_KEY = "rows";
|
|
@@ -22035,7 +22142,7 @@ function canonicalJson2(value) {
|
|
|
22035
22142
|
return encode(normalized);
|
|
22036
22143
|
}
|
|
22037
22144
|
function canonicalDigest(value) {
|
|
22038
|
-
return
|
|
22145
|
+
return createHash11("sha256").update(canonicalJson2(value)).digest("hex");
|
|
22039
22146
|
}
|
|
22040
22147
|
function parseReservation(raw) {
|
|
22041
22148
|
if (!isRecord11(raw) || Object.keys(raw).length !== 1 || typeof raw.reservation !== "string" || !raw.reservation)
|
|
@@ -22082,10 +22189,10 @@ function secretOf(credential) {
|
|
|
22082
22189
|
return credential.type === "oauth" ? `oauth\x00${credential.refresh}` : `api\x00${credential.apiKey}`;
|
|
22083
22190
|
}
|
|
22084
22191
|
function fingerprintOf(credential) {
|
|
22085
|
-
return
|
|
22192
|
+
return createHash11("sha256").update(secretOf(credential)).digest("hex");
|
|
22086
22193
|
}
|
|
22087
22194
|
function credentialDigest(credential) {
|
|
22088
|
-
return
|
|
22195
|
+
return createHash11("sha256").update(`credential-stamp\x00${secretOf(credential)}`).digest("hex");
|
|
22089
22196
|
}
|
|
22090
22197
|
function dispatchDigest(credential) {
|
|
22091
22198
|
const parts = credential.type === "oauth" ? [
|
|
@@ -22099,7 +22206,7 @@ function dispatchDigest(credential) {
|
|
|
22099
22206
|
credential.baseURL.trim(),
|
|
22100
22207
|
credential.authHeader ?? "authorization-bearer"
|
|
22101
22208
|
];
|
|
22102
|
-
return
|
|
22209
|
+
return createHash11("sha256").update(`credential-dispatch\x00${JSON.stringify(parts)}`).digest("hex");
|
|
22103
22210
|
}
|
|
22104
22211
|
function stampFor(credential, credentialEpoch, binding, options = {}) {
|
|
22105
22212
|
return {
|
|
@@ -22113,7 +22220,7 @@ function stampFor(credential, credentialEpoch, binding, options = {}) {
|
|
|
22113
22220
|
}
|
|
22114
22221
|
function providerStateDigest(codec, value) {
|
|
22115
22222
|
const bound = codec?.credentialBound ? runInsideCodec(() => codec.credentialBound?.(value)) : value;
|
|
22116
|
-
return
|
|
22223
|
+
return createHash11("sha256").update(`provider-state\x00${JSON.stringify(bound ?? null)}`).digest("hex");
|
|
22117
22224
|
}
|
|
22118
22225
|
function boundProviderStateDigest(account, credential, credentialEpoch, identity4) {
|
|
22119
22226
|
if (!credential || credentialEpoch === undefined)
|
|
@@ -22679,13 +22786,19 @@ function loadRows(config, state, codec, options = {}) {
|
|
|
22679
22786
|
}
|
|
22680
22787
|
|
|
22681
22788
|
// ../../node_modules/@cortexkit/common-auth/dist/store/mutate.js
|
|
22789
|
+
var sharingRetryDelays = [5, 10, 20, 40, 80, 160, 320, 400];
|
|
22682
22790
|
async function readText(path2) {
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22791
|
+
for (let attempt = 0;; attempt++) {
|
|
22792
|
+
try {
|
|
22793
|
+
return await readPrivateText(path2, windowsPrivateFiles);
|
|
22794
|
+
} catch (error) {
|
|
22795
|
+
if (error.code === "ENOENT")
|
|
22796
|
+
return;
|
|
22797
|
+
const wait = sharingRetryDelays[attempt];
|
|
22798
|
+
if (wait === undefined || !isWindowsSharingViolation(error))
|
|
22799
|
+
throw error;
|
|
22800
|
+
await delay4(wait);
|
|
22801
|
+
}
|
|
22689
22802
|
}
|
|
22690
22803
|
}
|
|
22691
22804
|
function parseFile(text) {
|
|
@@ -22702,12 +22815,21 @@ async function readPoolConfig(path2) {
|
|
|
22702
22815
|
}
|
|
22703
22816
|
async function readPool(ctx) {
|
|
22704
22817
|
for (let attempt = 0;attempt < 3; attempt++) {
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22818
|
+
let configText;
|
|
22819
|
+
let stateText;
|
|
22820
|
+
let checkedConfigText;
|
|
22821
|
+
try {
|
|
22822
|
+
configText = await readText(ctx.configPath);
|
|
22823
|
+
stateText = await readText(ctx.statePath);
|
|
22824
|
+
checkedConfigText = await readText(ctx.configPath);
|
|
22825
|
+
} catch (error) {
|
|
22826
|
+
if (isWindowsSharingViolation(error))
|
|
22827
|
+
break;
|
|
22828
|
+
throw error;
|
|
22829
|
+
}
|
|
22708
22830
|
if (configText !== checkedConfigText) {
|
|
22709
22831
|
if (attempt < 2)
|
|
22710
|
-
await
|
|
22832
|
+
await delay4(2 + Math.floor(Math.random() * 4));
|
|
22711
22833
|
continue;
|
|
22712
22834
|
}
|
|
22713
22835
|
const config = classifyConfig(parseFile(configText));
|
|
@@ -24668,11 +24790,11 @@ class PoolQuotaWriter {
|
|
|
24668
24790
|
overlay(rows) {
|
|
24669
24791
|
return rows.map((row) => this.overlayRow(row));
|
|
24670
24792
|
}
|
|
24671
|
-
schedule(
|
|
24793
|
+
schedule(delay5) {
|
|
24672
24794
|
if (this.running || this.timer || !this.pending.size || this.stopped)
|
|
24673
24795
|
return;
|
|
24674
24796
|
const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
|
|
24675
|
-
this.timer = this.clock.schedule(Math.max(
|
|
24797
|
+
this.timer = this.clock.schedule(Math.max(delay5, remaining), () => {
|
|
24676
24798
|
this.timer = undefined;
|
|
24677
24799
|
return this.flush();
|
|
24678
24800
|
});
|
|
@@ -24770,8 +24892,8 @@ class PoolQuotaWriter {
|
|
|
24770
24892
|
this.running = undefined;
|
|
24771
24893
|
for (const wake of this.wake)
|
|
24772
24894
|
wake();
|
|
24773
|
-
const
|
|
24774
|
-
this.schedule(
|
|
24895
|
+
const delay5 = this.failures ? Math.min(5000, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS2;
|
|
24896
|
+
this.schedule(delay5);
|
|
24775
24897
|
}
|
|
24776
24898
|
})();
|
|
24777
24899
|
return this.running;
|
|
@@ -25216,7 +25338,7 @@ function openPoolStore(options) {
|
|
|
25216
25338
|
};
|
|
25217
25339
|
}
|
|
25218
25340
|
// src/native-host-auth.ts
|
|
25219
|
-
import { createHash as
|
|
25341
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
25220
25342
|
class NativeHostAuthError extends Error {
|
|
25221
25343
|
code;
|
|
25222
25344
|
constructor(code) {
|
|
@@ -25342,7 +25464,7 @@ function inspectNativeHostAuthEntry(host, hostAuth) {
|
|
|
25342
25464
|
}
|
|
25343
25465
|
return Object.freeze({
|
|
25344
25466
|
kind,
|
|
25345
|
-
digest:
|
|
25467
|
+
digest: createHash12("sha256").update(canonical2, "utf8").digest("hex")
|
|
25346
25468
|
});
|
|
25347
25469
|
} catch {
|
|
25348
25470
|
throw new NativeHostAuthError("invalid-source");
|
|
@@ -25350,7 +25472,7 @@ function inspectNativeHostAuthEntry(host, hostAuth) {
|
|
|
25350
25472
|
}
|
|
25351
25473
|
|
|
25352
25474
|
// src/native-migration-proof.ts
|
|
25353
|
-
import { createHash as
|
|
25475
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
25354
25476
|
import { types } from "node:util";
|
|
25355
25477
|
|
|
25356
25478
|
class NativeMigrationProofError extends Error {
|
|
@@ -25424,7 +25546,7 @@ function nativeMigrationCanonicalJson(value) {
|
|
|
25424
25546
|
return JSON.stringify(captureNativeMigrationJson(value));
|
|
25425
25547
|
}
|
|
25426
25548
|
function nativeMigrationDigest(value) {
|
|
25427
|
-
return
|
|
25549
|
+
return createHash13("sha256").update(nativeMigrationCanonicalJson(value)).digest("hex");
|
|
25428
25550
|
}
|
|
25429
25551
|
function record6(value) {
|
|
25430
25552
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -25772,7 +25894,7 @@ import { basename as basename9, dirname as dirname15, isAbsolute as isAbsolute4,
|
|
|
25772
25894
|
import { types as utilTypes5 } from "node:util";
|
|
25773
25895
|
|
|
25774
25896
|
// src/pool-binding.ts
|
|
25775
|
-
import { createHash as
|
|
25897
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
25776
25898
|
|
|
25777
25899
|
class NativePoolBindingError extends Error {
|
|
25778
25900
|
constructor() {
|
|
@@ -25816,7 +25938,7 @@ function nativeLocalPoolBindingMatches(binding, paths, row) {
|
|
|
25816
25938
|
function nativeLocalRefreshJobKey(binding) {
|
|
25817
25939
|
if (!isNativeLocalPoolBinding(binding))
|
|
25818
25940
|
throw new NativePoolBindingError;
|
|
25819
|
-
return
|
|
25941
|
+
return createHash14("sha256").update(JSON.stringify([
|
|
25820
25942
|
"anthropic-local-refresh",
|
|
25821
25943
|
binding.storageId,
|
|
25822
25944
|
binding.credentialEpoch,
|
|
@@ -25825,9 +25947,9 @@ function nativeLocalRefreshJobKey(binding) {
|
|
|
25825
25947
|
}
|
|
25826
25948
|
|
|
25827
25949
|
// src/token-fingerprint.ts
|
|
25828
|
-
import { createHash as
|
|
25950
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
25829
25951
|
function tokenFingerprint(token) {
|
|
25830
|
-
return
|
|
25952
|
+
return createHash15("sha256").update(token).digest("hex").slice(0, 16);
|
|
25831
25953
|
}
|
|
25832
25954
|
|
|
25833
25955
|
// src/native-credential-validation.ts
|
|
@@ -25983,11 +26105,11 @@ async function renameWithWindowsSharingRetry(from, to, options = {}, beforeRetry
|
|
|
25983
26105
|
throw error;
|
|
25984
26106
|
original = error;
|
|
25985
26107
|
}
|
|
25986
|
-
for (const
|
|
26108
|
+
for (const delay5 of [10, 20, 40, 80, 100]) {
|
|
25987
26109
|
const remaining = 500 - (now() - start);
|
|
25988
26110
|
if (remaining <= 0)
|
|
25989
26111
|
break;
|
|
25990
|
-
await sleep(Math.min(
|
|
26112
|
+
await sleep(Math.min(delay5, remaining));
|
|
25991
26113
|
if (now() - start >= 500)
|
|
25992
26114
|
break;
|
|
25993
26115
|
if (await beforeRetry?.() === "skip")
|
|
@@ -26011,7 +26133,7 @@ import { join as join18 } from "node:path";
|
|
|
26011
26133
|
|
|
26012
26134
|
// src/relay.ts
|
|
26013
26135
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
26014
|
-
import { createHash as
|
|
26136
|
+
import { createHash as createHash16, randomBytes as randomBytes5 } from "node:crypto";
|
|
26015
26137
|
var WEBSOCKET_RELAY_URL = /^wss?:\/\//i;
|
|
26016
26138
|
function effectiveRelayTransport(stored, url) {
|
|
26017
26139
|
if (stored === "http" || stored === "websocket")
|
|
@@ -26165,7 +26287,7 @@ function generateRelayToken() {
|
|
|
26165
26287
|
return randomBytes5(32).toString("base64url");
|
|
26166
26288
|
}
|
|
26167
26289
|
function hashBody(body) {
|
|
26168
|
-
return `sha256:${
|
|
26290
|
+
return `sha256:${createHash16("sha256").update(body).digest("hex")}`;
|
|
26169
26291
|
}
|
|
26170
26292
|
function createStringPatch(previous, next) {
|
|
26171
26293
|
let start = 0;
|
|
@@ -27130,7 +27252,7 @@ function websocketSessionKey(config, affinity) {
|
|
|
27130
27252
|
return JSON.stringify([
|
|
27131
27253
|
affinity,
|
|
27132
27254
|
config.url,
|
|
27133
|
-
|
|
27255
|
+
createHash16("sha256").update(config.token).digest("hex")
|
|
27134
27256
|
]);
|
|
27135
27257
|
}
|
|
27136
27258
|
function getPersistentRelaySession(config, affinity, timers) {
|
|
@@ -28848,7 +28970,7 @@ function runtime(source2, accountIdentity, current) {
|
|
|
28848
28970
|
"permanent"
|
|
28849
28971
|
]);
|
|
28850
28972
|
safe.message = field === "lastRefreshError" ? "Imported refresh failure" : "Imported quota failure";
|
|
28851
|
-
if (field === "lastRefreshError" && current?.type === "oauth" && error.tokenHash ===
|
|
28973
|
+
if (field === "lastRefreshError" && current?.type === "oauth" && error.tokenHash === createHash17("sha256").update(current.refresh).digest("hex"))
|
|
28852
28974
|
safe.credentialFingerprint = fingerprintOf(current);
|
|
28853
28975
|
result[field] = safe;
|
|
28854
28976
|
}
|
|
@@ -28872,7 +28994,7 @@ function projectNativeMigrationSource(input) {
|
|
|
28872
28994
|
const hostEntry = inspectNativeHostAuthEntry(input.host, auth);
|
|
28873
28995
|
if (config.version !== undefined && config.version !== 1 || state.version !== undefined && state.version !== 1)
|
|
28874
28996
|
refuse2();
|
|
28875
|
-
const formerMain =
|
|
28997
|
+
const formerMain = createHash17("sha256").update(JSON.stringify([input.storageId, input.configDigest, "former-main"])).digest("hex");
|
|
28876
28998
|
const mainRouteId = config.mainAccountId === undefined ? `${formerMain.slice(0, 8)}-${formerMain.slice(8, 12)}-${formerMain.slice(12, 16)}-${formerMain.slice(16, 20)}-${formerMain.slice(20, 32)}` : id(config.mainAccountId);
|
|
28877
28999
|
const settings = {
|
|
28878
29000
|
mainAccountId: mainRouteId,
|
|
@@ -29627,7 +29749,7 @@ function emptyState(now) {
|
|
|
29627
29749
|
return { version: 1, updatedAt: now, assignments: {} };
|
|
29628
29750
|
}
|
|
29629
29751
|
function sessionKey(sessionId) {
|
|
29630
|
-
return
|
|
29752
|
+
return createHash18("sha256").update(sessionId).digest("hex");
|
|
29631
29753
|
}
|
|
29632
29754
|
function stickyQuotaSnapshotIsFresh(quota2, storage, now = Date.now(), modelId) {
|
|
29633
29755
|
const maxAge = getQuotaCheckIntervalMs(storage);
|
|
@@ -29854,7 +29976,7 @@ function getStickyRoutingStatePath(accountStoragePath) {
|
|
|
29854
29976
|
return join20(dirname16(accountStoragePath), `${stem}-routing-state.json`);
|
|
29855
29977
|
}
|
|
29856
29978
|
function stickyRetryAfterWithJitter(sessionId, retryAfterSeconds) {
|
|
29857
|
-
const hash2 =
|
|
29979
|
+
const hash2 = createHash18("sha256").update(sessionId).digest().readUInt32BE(0);
|
|
29858
29980
|
return Math.max(1, Math.ceil(retryAfterSeconds)) + hash2 % 21;
|
|
29859
29981
|
}
|
|
29860
29982
|
var localRecoveries = new Map;
|
|
@@ -30394,7 +30516,7 @@ async function resolveNativePoolPaths(legacyConfig = getAccountStoragePath(), le
|
|
|
30394
30516
|
if (new Set(paths).size !== paths.length) {
|
|
30395
30517
|
throw new Error("Anthropic account storage paths overlap; migration requires separate files");
|
|
30396
30518
|
}
|
|
30397
|
-
const storageId =
|
|
30519
|
+
const storageId = createHash19("sha256").update(JSON.stringify(["anthropic", config, legacyLayoutState])).digest("hex");
|
|
30398
30520
|
return {
|
|
30399
30521
|
legacyConfig: sourceConfig,
|
|
30400
30522
|
legacyState: sourceState,
|
|
@@ -30444,7 +30566,7 @@ function nativeVaultPaths(local, layout = stateLayoutOfPaths(local)) {
|
|
|
30444
30566
|
runtime: runtime2,
|
|
30445
30567
|
roster,
|
|
30446
30568
|
routing,
|
|
30447
|
-
storageId:
|
|
30569
|
+
storageId: createHash20("sha256").update(JSON.stringify(["anthropic-vault", config, legacyLayoutState])).digest("hex")
|
|
30448
30570
|
};
|
|
30449
30571
|
}
|
|
30450
30572
|
|
|
@@ -30502,7 +30624,7 @@ function stateLayoutMovedElsewhere(configDir, relocatedTo, stateRoot) {
|
|
|
30502
30624
|
}
|
|
30503
30625
|
|
|
30504
30626
|
// src/state-layout-io.ts
|
|
30505
|
-
import { createHash as
|
|
30627
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
30506
30628
|
import {
|
|
30507
30629
|
lstat as lstat10,
|
|
30508
30630
|
open as open10,
|
|
@@ -30542,7 +30664,7 @@ function errorCode3(error) {
|
|
|
30542
30664
|
return error instanceof Error && "code" in error ? error.code : undefined;
|
|
30543
30665
|
}
|
|
30544
30666
|
function sha256Hex(bytes) {
|
|
30545
|
-
return
|
|
30667
|
+
return createHash21("sha256").update(bytes).digest("hex");
|
|
30546
30668
|
}
|
|
30547
30669
|
async function digestFile(path2) {
|
|
30548
30670
|
try {
|
|
@@ -31955,7 +32077,7 @@ class CacheKeepSessionRegistry {
|
|
|
31955
32077
|
}
|
|
31956
32078
|
}
|
|
31957
32079
|
// src/cachekeep-store.ts
|
|
31958
|
-
import { createHash as
|
|
32080
|
+
import { createHash as createHash22, randomUUID as randomUUID19 } from "node:crypto";
|
|
31959
32081
|
import { constants as constants3 } from "node:fs";
|
|
31960
32082
|
import { lstat as lstat16, mkdir as mkdir13, open as open11, readdir as readdir6, rm as rm8, writeFile as writeFile5 } from "node:fs/promises";
|
|
31961
32083
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
@@ -31964,7 +32086,7 @@ import { promisify } from "node:util";
|
|
|
31964
32086
|
import { gunzip, gzip } from "node:zlib";
|
|
31965
32087
|
var compress = promisify(gzip);
|
|
31966
32088
|
var decompress = promisify(gunzip);
|
|
31967
|
-
var hash3 = (value) =>
|
|
32089
|
+
var hash3 = (value) => createHash22("sha256").update(value).digest("hex");
|
|
31968
32090
|
var FILE = /^[a-f0-9]{64}\.json\.gz$/;
|
|
31969
32091
|
var TEMP = /^[a-f0-9]{64}\.json\.gz\.[a-f0-9-]+\.tmp$/;
|
|
31970
32092
|
var MAX_RECORD_BYTES = 2 * CACHE_KEEP_MAX_BODY_BYTES + 64 * 1024;
|
|
@@ -32258,8 +32380,8 @@ class CacheKeepStore {
|
|
|
32258
32380
|
this.pending.set(entry2.id, entry2);
|
|
32259
32381
|
if (this.timers.has(entry2.id))
|
|
32260
32382
|
return;
|
|
32261
|
-
const
|
|
32262
|
-
const timer = (this.options.setTimeoutImpl ?? setTimeout)(() => this.flush(entry2.id),
|
|
32383
|
+
const delay5 = Math.max(250, (this.lastWrite.get(entry2.id) ?? 0) + 5000 - (this.options.now?.() ?? Date.now()));
|
|
32384
|
+
const timer = (this.options.setTimeoutImpl ?? setTimeout)(() => this.flush(entry2.id), delay5);
|
|
32263
32385
|
timer.unref?.();
|
|
32264
32386
|
this.timers.set(entry2.id, timer);
|
|
32265
32387
|
}
|
|
@@ -33002,7 +33124,7 @@ function executeLoggingCommand(input) {
|
|
|
33002
33124
|
`);
|
|
33003
33125
|
}
|
|
33004
33126
|
// src/message-threads.ts
|
|
33005
|
-
import { createHash as
|
|
33127
|
+
import { createHash as createHash23, randomUUID as randomUUID20 } from "node:crypto";
|
|
33006
33128
|
var MESSAGE_THREADS_BETA = "message-threads-2026-08-12";
|
|
33007
33129
|
var MAX_AGE_MS = 5 * 60000;
|
|
33008
33130
|
var MAX_SESSIONS = 2048;
|
|
@@ -33016,7 +33138,7 @@ function localMessageThreadCredential(binding2) {
|
|
|
33016
33138
|
]);
|
|
33017
33139
|
}
|
|
33018
33140
|
function hash4(value) {
|
|
33019
|
-
return
|
|
33141
|
+
return createHash23("sha256").update(JSON.stringify(value)).digest("hex");
|
|
33020
33142
|
}
|
|
33021
33143
|
function normalizedReplyName(name) {
|
|
33022
33144
|
const bare = name.startsWith("mcp_") ? name.slice(4) : name;
|
|
@@ -33063,7 +33185,7 @@ class ReplyFingerprint {
|
|
|
33063
33185
|
layout = new Map;
|
|
33064
33186
|
textBlocks = new Map;
|
|
33065
33187
|
signatures = new Map;
|
|
33066
|
-
text =
|
|
33188
|
+
text = createHash23("sha256");
|
|
33067
33189
|
committedText = this.text.copy();
|
|
33068
33190
|
hasText = false;
|
|
33069
33191
|
activeText;
|
|
@@ -33085,7 +33207,7 @@ class ReplyFingerprint {
|
|
|
33085
33207
|
this.text.update(part.slice(visible.length));
|
|
33086
33208
|
}
|
|
33087
33209
|
appendBlockText(state, value) {
|
|
33088
|
-
state.text ??=
|
|
33210
|
+
state.text ??= createHash23("sha256");
|
|
33089
33211
|
state.committedText ??= state.text.copy();
|
|
33090
33212
|
const part = state.textHasContent ? value : value.trimStart();
|
|
33091
33213
|
const visible = part.trimEnd();
|
|
@@ -33136,7 +33258,7 @@ class ReplyFingerprint {
|
|
|
33136
33258
|
state.input = block.input;
|
|
33137
33259
|
}
|
|
33138
33260
|
if (block.type === "thinking" || block.type === "redacted_thinking") {
|
|
33139
|
-
state.signature =
|
|
33261
|
+
state.signature = createHash23("sha256");
|
|
33140
33262
|
const signature = block.type === "redacted_thinking" ? block.data : block.signature;
|
|
33141
33263
|
if (typeof signature === "string") {
|
|
33142
33264
|
state.signature.update(signature);
|
|
@@ -35084,20 +35206,21 @@ function createNativeLocalRuntimeReaders(options) {
|
|
|
35084
35206
|
}
|
|
35085
35207
|
|
|
35086
35208
|
// src/native-refresh-coordinator.ts
|
|
35087
|
-
import { createHash as
|
|
35209
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
35088
35210
|
|
|
35089
35211
|
// src/native-transient-account.ts
|
|
35090
35212
|
var TRANSIENT_ACCOUNT_MESSAGE = "Anthropic account update in progress; retry the request";
|
|
35091
35213
|
var transientAccountErrors = new WeakSet;
|
|
35092
35214
|
|
|
35093
35215
|
class NativeTransientAccountError extends Error {
|
|
35094
|
-
constructor() {
|
|
35216
|
+
constructor(operation) {
|
|
35095
35217
|
super(TRANSIENT_ACCOUNT_MESSAGE);
|
|
35096
35218
|
const fixed = {
|
|
35097
35219
|
name: "NativeTransientAccountError",
|
|
35098
35220
|
message: TRANSIENT_ACCOUNT_MESSAGE,
|
|
35099
35221
|
code: "ECONNRESET",
|
|
35100
|
-
syscall: "native-account-update"
|
|
35222
|
+
syscall: "native-account-update",
|
|
35223
|
+
...operation === "pool-read" && { poolRead: true }
|
|
35101
35224
|
};
|
|
35102
35225
|
for (const [key, value] of Object.entries(fixed))
|
|
35103
35226
|
Object.defineProperty(this, key, {
|
|
@@ -35112,6 +35235,21 @@ class NativeTransientAccountError extends Error {
|
|
|
35112
35235
|
function isNativeTransientAccountError(value) {
|
|
35113
35236
|
return typeof value === "object" && value !== null && transientAccountErrors.has(value);
|
|
35114
35237
|
}
|
|
35238
|
+
async function readNativePool(read) {
|
|
35239
|
+
const result = await readNativePoolSettings(read);
|
|
35240
|
+
if (result.status === "error" && result.kind === "snapshot-contended" && result.retryable)
|
|
35241
|
+
throw new NativeTransientAccountError("pool-read");
|
|
35242
|
+
return result;
|
|
35243
|
+
}
|
|
35244
|
+
async function readNativePoolSettings(read) {
|
|
35245
|
+
try {
|
|
35246
|
+
return await read;
|
|
35247
|
+
} catch (error) {
|
|
35248
|
+
if (error instanceof PrivateFileError && error.stage === "read" && error.reason === "io-error" && (error.win32Code === 32 || error.win32Code === 303))
|
|
35249
|
+
throw new NativeTransientAccountError("pool-read");
|
|
35250
|
+
throw error;
|
|
35251
|
+
}
|
|
35252
|
+
}
|
|
35115
35253
|
var NATIVE_POOL_WRITE_JOIN_BUDGET_MS = 2000;
|
|
35116
35254
|
async function joinNativePoolWrite(paths, signals, check, onLockEvent) {
|
|
35117
35255
|
const observer = nativeLockObserver(onLockEvent);
|
|
@@ -35186,7 +35324,7 @@ function pause(ms, signals) {
|
|
|
35186
35324
|
var NATIVE_REFRESH_MAX_ATTEMPTS = 3;
|
|
35187
35325
|
var NATIVE_REFRESH_JOIN_BUDGET_MS = 2000;
|
|
35188
35326
|
function nativeAccountProviderLock(paths, identity5) {
|
|
35189
|
-
const key =
|
|
35327
|
+
const key = createHash24("sha256").update(JSON.stringify([paths.storageId, identity5])).digest("hex");
|
|
35190
35328
|
return {
|
|
35191
35329
|
path: paths.state,
|
|
35192
35330
|
name: `native-account-provider-${key}`,
|
|
@@ -35323,7 +35461,7 @@ function createNativeRefreshCoordinator(options) {
|
|
|
35323
35461
|
const bootstrap = options.resolveIdentity ?? resolveClaudeCodeAccountIdentity;
|
|
35324
35462
|
const onLockEvent = nativeLockObserver(options.onLockEvent);
|
|
35325
35463
|
async function rowFor(binding2) {
|
|
35326
|
-
const read = await store.read();
|
|
35464
|
+
const read = await readNativePool(store.read());
|
|
35327
35465
|
return read.status === "ready" ? read.rows.find((row) => row.id === binding2.rowId) : undefined;
|
|
35328
35466
|
}
|
|
35329
35467
|
async function readPolicy(subject) {
|
|
@@ -36000,7 +36138,7 @@ function createNativeRefreshCoordinator(options) {
|
|
|
36000
36138
|
import { isAbsolute as isAbsolute5, normalize, parse as parse3, sep } from "node:path";
|
|
36001
36139
|
|
|
36002
36140
|
// src/migration-source.ts
|
|
36003
|
-
import { createHash as
|
|
36141
|
+
import { createHash as createHash25 } from "node:crypto";
|
|
36004
36142
|
import { constants as constants4 } from "node:fs";
|
|
36005
36143
|
import { lstat as lstat17, open as open12 } from "node:fs/promises";
|
|
36006
36144
|
class NativeMigrationSourceError extends Error {
|
|
@@ -36099,7 +36237,7 @@ async function readNativeMigrationSource(role, path2, hooks = {}) {
|
|
|
36099
36237
|
return sourceSnapshot({
|
|
36100
36238
|
role,
|
|
36101
36239
|
path: path2,
|
|
36102
|
-
digest:
|
|
36240
|
+
digest: createHash25("sha256").update(content).digest("hex"),
|
|
36103
36241
|
data: freezeJson(data),
|
|
36104
36242
|
metadata: Object.freeze({
|
|
36105
36243
|
uid: Number(before.uid),
|
|
@@ -41500,7 +41638,7 @@ function createNativeVaultRuntime(options) {
|
|
|
41500
41638
|
});
|
|
41501
41639
|
}
|
|
41502
41640
|
async function rowFor(roster, routeId) {
|
|
41503
|
-
const settings = await store.readSettings();
|
|
41641
|
+
const settings = await readNativePoolSettings(store.readSettings());
|
|
41504
41642
|
if (settings.status !== "ready")
|
|
41505
41643
|
throw new NativeCustodyError("invalid-state");
|
|
41506
41644
|
const pin = nativeVaultPrimaryPin(settings.settings);
|
|
@@ -42435,7 +42573,7 @@ function buildNativeAccountRuntime(options, env, runtimeSettings) {
|
|
|
42435
42573
|
};
|
|
42436
42574
|
}
|
|
42437
42575
|
async function poolRow(id2) {
|
|
42438
|
-
const read = await store.read();
|
|
42576
|
+
const read = await readNativePool(store.read());
|
|
42439
42577
|
if (read.status !== "ready")
|
|
42440
42578
|
throw new NativeRuntimeError("publication-refused");
|
|
42441
42579
|
return read.rows.find((row) => row.id === id2);
|
|
@@ -42443,7 +42581,7 @@ function buildNativeAccountRuntime(options, env, runtimeSettings) {
|
|
|
42443
42581
|
async function physicalId(id2) {
|
|
42444
42582
|
if (id2 !== "main")
|
|
42445
42583
|
return id2;
|
|
42446
|
-
const settings = await store.readSettings();
|
|
42584
|
+
const settings = await readNativePoolSettings(store.readSettings());
|
|
42447
42585
|
if (settings.status !== "ready" || typeof settings.settings.mainAccountId !== "string")
|
|
42448
42586
|
throw new NativeCustodyError("route-unavailable");
|
|
42449
42587
|
return settings.settings.mainAccountId;
|
|
@@ -42609,8 +42747,8 @@ function buildNativeAccountRuntime(options, env, runtimeSettings) {
|
|
|
42609
42747
|
const selectedPaths = mode === "claustrum" ? vaultPaths : paths2;
|
|
42610
42748
|
const selectedStore = mode === "claustrum" ? vaultStore : store;
|
|
42611
42749
|
const [read, settings, metadata2] = await Promise.all([
|
|
42612
|
-
selectedStore.read(),
|
|
42613
|
-
selectedStore.readSettings(),
|
|
42750
|
+
readNativePool(selectedStore.read()),
|
|
42751
|
+
readNativePoolSettings(selectedStore.readSettings()),
|
|
42614
42752
|
readNativeRuntime(selectedPaths.runtime, selectedPaths.storageId)
|
|
42615
42753
|
]);
|
|
42616
42754
|
if (read.status !== "ready" || settings.status !== "ready")
|
|
@@ -42710,7 +42848,7 @@ function buildNativeAccountRuntime(options, env, runtimeSettings) {
|
|
|
42710
42848
|
for (let attempt = 0;attempt < 4; attempt++) {
|
|
42711
42849
|
if (attempt)
|
|
42712
42850
|
await new Promise((resolve23) => setTimeout(resolve23, 10));
|
|
42713
|
-
const settings = await readSettings();
|
|
42851
|
+
const settings = await readNativePoolSettings(readSettings());
|
|
42714
42852
|
if (settings.status !== "ready")
|
|
42715
42853
|
throw new NativeRuntimeError("publication-refused");
|
|
42716
42854
|
if (location !== "default") {
|
|
@@ -43711,7 +43849,7 @@ async function writeNativeHostAuth(input, hooks = {}) {
|
|
|
43711
43849
|
}
|
|
43712
43850
|
|
|
43713
43851
|
// src/native-migration.ts
|
|
43714
|
-
import { createHash as
|
|
43852
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
43715
43853
|
import { lstat as lstat20, mkdir as mkdir15, unlink as unlink10 } from "node:fs/promises";
|
|
43716
43854
|
import { dirname as dirname23, isAbsolute as isAbsolute7 } from "node:path";
|
|
43717
43855
|
class NativeMigrationError extends Error {
|
|
@@ -44103,7 +44241,7 @@ function routingBytes(captured) {
|
|
|
44103
44241
|
`;
|
|
44104
44242
|
}
|
|
44105
44243
|
function bytesDigest(bytes) {
|
|
44106
|
-
return bytes === undefined ? null :
|
|
44244
|
+
return bytes === undefined ? null : createHash26("sha256").update(bytes).digest("hex");
|
|
44107
44245
|
}
|
|
44108
44246
|
function expectedAuth(input, snapshot) {
|
|
44109
44247
|
const entry2 = inspectNativeHostAuthEntry(input.host, snapshot.data);
|
|
@@ -47481,12 +47619,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
47481
47619
|
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
47482
47620
|
compromise();
|
|
47483
47621
|
}
|
|
47484
|
-
function schedule2(
|
|
47622
|
+
function schedule2(delay5 = UPDATE) {
|
|
47485
47623
|
if (released)
|
|
47486
47624
|
return;
|
|
47487
47625
|
timer = setTimeout(() => {
|
|
47488
47626
|
update();
|
|
47489
|
-
},
|
|
47627
|
+
}, delay5);
|
|
47490
47628
|
timer.unref();
|
|
47491
47629
|
}
|
|
47492
47630
|
function retry(error) {
|
|
@@ -48036,7 +48174,7 @@ function requestMethod(input) {
|
|
|
48036
48174
|
return input instanceof Request ? input.method : "GET";
|
|
48037
48175
|
}
|
|
48038
48176
|
// src/prime.ts
|
|
48039
|
-
import { createHash as
|
|
48177
|
+
import { createHash as createHash27 } from "node:crypto";
|
|
48040
48178
|
import * as fs4 from "node:fs";
|
|
48041
48179
|
import { mkdir as mkdir18, readdir as readdir7, rm as rm10, stat as stat14, writeFile as writeFile6 } from "node:fs/promises";
|
|
48042
48180
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
@@ -48245,7 +48383,7 @@ function primeStorageFingerprint(storagePath) {
|
|
|
48245
48383
|
throw error;
|
|
48246
48384
|
canonicalPath3 = absolutePath;
|
|
48247
48385
|
}
|
|
48248
|
-
return
|
|
48386
|
+
return createHash27("sha256").update(canonicalPath3).digest("hex").slice(0, 12);
|
|
48249
48387
|
}
|
|
48250
48388
|
function primeMarkerNamespaceDir(markerDir, storagePath) {
|
|
48251
48389
|
return join30(markerDir, primeStorageFingerprint(storagePath));
|
|
@@ -48568,7 +48706,7 @@ class PrimeManager {
|
|
|
48568
48706
|
return [markerPath];
|
|
48569
48707
|
const verifiedPath = this.verifiedMarkerPath(accountIdentity, resetsAtEpochMs);
|
|
48570
48708
|
if (resetsAtEpochMs === undefined) {
|
|
48571
|
-
const digest2 =
|
|
48709
|
+
const digest2 = createHash27("sha256").update(accountIdentity).digest("hex");
|
|
48572
48710
|
if ((await this.readMarkerNames(this.verifiedMarkerDir())).some((name) => name.startsWith(`${digest2}-`)))
|
|
48573
48711
|
return null;
|
|
48574
48712
|
}
|
|
@@ -48580,7 +48718,7 @@ class PrimeManager {
|
|
|
48580
48718
|
return join30(this.options.markerDir ?? defaultMarkerDir(), "accounts");
|
|
48581
48719
|
}
|
|
48582
48720
|
verifiedMarkerPath(accountIdentity, resetsAtEpochMs) {
|
|
48583
|
-
const digest2 =
|
|
48721
|
+
const digest2 = createHash27("sha256").update(accountIdentity).digest("hex");
|
|
48584
48722
|
return join30(this.verifiedMarkerDir(), `${digest2}-${resetsAtEpochMs ?? "bootstrap"}`);
|
|
48585
48723
|
}
|
|
48586
48724
|
async readMarkerNames(dir) {
|
|
@@ -52354,9 +52492,9 @@ async function registerLegacyHeld(oldDir, paths2, identity5, options, ctx) {
|
|
|
52354
52492
|
return deferLegacyRegistration(paths2, oldDir, options, error);
|
|
52355
52493
|
}
|
|
52356
52494
|
}
|
|
52357
|
-
function chooseLegacy(paths2, reasons2,
|
|
52495
|
+
function chooseLegacy(paths2, reasons2, log4, registration) {
|
|
52358
52496
|
recordProcessStateLayout(paths2.legacyConfig, LEGACY_STATE_LAYOUT);
|
|
52359
|
-
if (reasons2.length &&
|
|
52497
|
+
if (reasons2.length && log4)
|
|
52360
52498
|
logger2.info("state-layout", "anthropic-auth keeps its runtime files in OpenCode’s config folder until every running OpenCode or Pi using them has restarted on this version", { reasons: reasons2 });
|
|
52361
52499
|
return {
|
|
52362
52500
|
kind: "legacy",
|
|
@@ -52426,7 +52564,7 @@ async function readPointers(dataset) {
|
|
|
52426
52564
|
}
|
|
52427
52565
|
return pointed;
|
|
52428
52566
|
}
|
|
52429
|
-
async function legacyHeld(dataset, options, ctx, reasons2,
|
|
52567
|
+
async function legacyHeld(dataset, options, ctx, reasons2, log4 = true) {
|
|
52430
52568
|
const pointed = await readPointers(dataset);
|
|
52431
52569
|
const record17 = await readRecord2(dataset.sub);
|
|
52432
52570
|
if (record17)
|
|
@@ -52436,7 +52574,7 @@ async function legacyHeld(dataset, options, ctx, reasons2, log3 = true) {
|
|
|
52436
52574
|
if (pointed || !noMoveRecord(record17))
|
|
52437
52575
|
return "changed";
|
|
52438
52576
|
const registration = await registerLegacyHeld(dataset.oldDir, dataset.oldPaths, dataset.identity, options, ctx);
|
|
52439
|
-
return chooseLegacy(dataset.oldPaths, reasons2,
|
|
52577
|
+
return chooseLegacy(dataset.oldPaths, reasons2, log4, registration);
|
|
52440
52578
|
}
|
|
52441
52579
|
async function oldFolderTransition(old, recordedMovingJournal) {
|
|
52442
52580
|
for (const runtime2 of [old.oldPaths.runtime, old.oldVault.runtime])
|
|
@@ -52751,8 +52889,8 @@ async function underLayoutLock(dataset, options, ctx, overrides, neverMove) {
|
|
|
52751
52889
|
await rollbackPreparing(record17, dataset, ctx);
|
|
52752
52890
|
return "again";
|
|
52753
52891
|
}
|
|
52754
|
-
const stay = async (reasons2,
|
|
52755
|
-
const decided = await legacyHeld(dataset, options, ctx, reasons2,
|
|
52892
|
+
const stay = async (reasons2, log4 = true) => {
|
|
52893
|
+
const decided = await legacyHeld(dataset, options, ctx, reasons2, log4);
|
|
52756
52894
|
return decided === "changed" ? "again" : decided;
|
|
52757
52895
|
};
|
|
52758
52896
|
if (overrides.length || neverMove.length) {
|
|
@@ -53300,7 +53438,7 @@ export {
|
|
|
53300
53438
|
lookupGatewaySettingsFile,
|
|
53301
53439
|
lookupAccountHome,
|
|
53302
53440
|
logger2 as logger,
|
|
53303
|
-
|
|
53441
|
+
log3 as log,
|
|
53304
53442
|
localMessageThreadCredential,
|
|
53305
53443
|
localDayKey,
|
|
53306
53444
|
legacySettingsProtection,
|