@cortexkit/anthropic-auth-core 2.15.1 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts.d.ts +5 -0
- package/dist/holder-registry.d.ts +10 -0
- package/dist/host-retry.d.ts +3 -1
- package/dist/index.js +189 -147
- package/dist/internal-types/pi-slot/index.d.ts +1 -1
- package/dist/internal-types/pi-slot/slot.d.ts +6 -9
- package/dist/layout-fence.d.ts +2 -2
- package/dist/native-menu-executor.d.ts +5 -7
- package/dist/native-ui.d.ts +1 -3
- package/dist/native-vault-connection.d.ts +5 -6
- package/dist/native-vault-refusal.d.ts +1 -0
- package/dist/routing.d.ts +1 -0
- package/dist/settings-definition.d.ts +13 -1
- package/dist/sticky-routing.d.ts +16 -1
- package/package.json +2 -2
- package/schema/anthropic-auth.schema.json +22 -0
package/dist/accounts.d.ts
CHANGED
|
@@ -183,6 +183,7 @@ export type AccountStorage = {
|
|
|
183
183
|
routing?: {
|
|
184
184
|
mode?: RoutingMode;
|
|
185
185
|
maxSameAccountWait?: import('./routing.ts').MaxSameAccountWait;
|
|
186
|
+
waitForReset?: boolean;
|
|
186
187
|
};
|
|
187
188
|
fallbackOn?: number[];
|
|
188
189
|
refresh?: {
|
|
@@ -447,11 +448,15 @@ export declare function quotaRefusalTiming(input: {
|
|
|
447
448
|
scopedModelId?: string;
|
|
448
449
|
modelId?: string;
|
|
449
450
|
sessionTtlMs?: number;
|
|
451
|
+
/** The caller found no other route and this host supports reset-sized waits. */
|
|
452
|
+
waitForReset?: boolean;
|
|
453
|
+
sessionId?: string | null;
|
|
450
454
|
now?: number;
|
|
451
455
|
}): {
|
|
452
456
|
resetAt: number | undefined;
|
|
453
457
|
retryAfterSeconds: number | undefined;
|
|
454
458
|
limitName?: string;
|
|
459
|
+
resetWaitMs?: number;
|
|
455
460
|
};
|
|
456
461
|
/**
|
|
457
462
|
* The retry delay a quota refusal advertises: the time until `resetAt` (five
|
|
@@ -105,12 +105,22 @@ export interface HolderLiveness {
|
|
|
105
105
|
pidAlive(pid: number): boolean;
|
|
106
106
|
/** Undefined or null when it can't be read. */
|
|
107
107
|
incarnation(pid: number): Promise<string | null>;
|
|
108
|
+
/** Wall-clock process start, when the OS can report it. */
|
|
109
|
+
processStartedAtMs?(pid: number): Promise<number | null>;
|
|
108
110
|
/** Wall clock and OS uptime; tests replace both. */
|
|
109
111
|
now?(): number;
|
|
110
112
|
uptime?(): number;
|
|
111
113
|
}
|
|
112
114
|
/** The OS's fixed per-process value for `pid`, or null when none is read. */
|
|
113
115
|
export declare function processIncarnation(pid: number): Promise<string | null>;
|
|
116
|
+
/** OS reads used to obtain a wall-clock process start; tests supply fixtures. */
|
|
117
|
+
export interface ProcessStartReads {
|
|
118
|
+
platform: NodeJS.Platform;
|
|
119
|
+
readFile(path: string): Promise<string>;
|
|
120
|
+
exec(file: string, args: string[]): Promise<string>;
|
|
121
|
+
}
|
|
122
|
+
/** Wall-clock process start, or null if the OS cannot safely report it. */
|
|
123
|
+
export declare function processStartedAtMs(pid: number, reads?: ProcessStartReads): Promise<number | null>;
|
|
114
124
|
/**
|
|
115
125
|
* A process recorded before this boot cannot still be running, even if its
|
|
116
126
|
* pid is alive again. Keep a five-minute margin for clock imprecision, and
|
package/dist/host-retry.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Ordinary host retries recheck availability periodically. */
|
|
2
2
|
export declare const MAX_HOST_RETRY_MS: number;
|
|
3
|
+
export declare function markResetWaitResponse(response: Response, delayMs: number): Response;
|
|
4
|
+
export declare function resetWaitDelayMs(response: Response): number | undefined;
|
|
3
5
|
export declare function clampHostRetryMs(delayMs: number): number;
|
|
4
6
|
/** Keep quota reset headers intact: they are evidence, not instructions to the host. */
|
|
5
7
|
export declare function hostRetryHeaders(upstream: Headers, now?: number): Headers;
|
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ var VAULT_FAILURE_CLASSES = Object.freeze({
|
|
|
95
95
|
class ClaustrumUnreachableError extends ClaustrumConsumerError {
|
|
96
96
|
reason;
|
|
97
97
|
constructor(reason) {
|
|
98
|
-
super("unavailable", "Claustrum
|
|
98
|
+
super("unavailable", "Claustrum vault could not be reached");
|
|
99
99
|
this.name = "ClaustrumUnreachableError";
|
|
100
100
|
if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
|
|
101
101
|
this.reason = reason;
|
|
@@ -693,7 +693,9 @@ function ioCode(detail) {
|
|
|
693
693
|
var backend;
|
|
694
694
|
var PRIVATE_FILES_UNAVAILABLE_REASON = "native-addon-unavailable";
|
|
695
695
|
function privateFilesUnavailable(cause) {
|
|
696
|
-
return Object.assign(new Error("Windows private-files native addon
|
|
696
|
+
return Object.assign(new Error("Windows private-files native addon could not be loaded", {
|
|
697
|
+
cause
|
|
698
|
+
}), {
|
|
697
699
|
code: "ERR_PRIVATE_FILES_UNAVAILABLE",
|
|
698
700
|
reason: PRIVATE_FILES_UNAVAILABLE_REASON
|
|
699
701
|
});
|
|
@@ -734,7 +736,7 @@ class PrivateFileError extends Error {
|
|
|
734
736
|
orphanPath;
|
|
735
737
|
constructor(path, stage, cause) {
|
|
736
738
|
const detail = cause;
|
|
737
|
-
super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path}
|
|
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 });
|
|
738
740
|
this.path = path;
|
|
739
741
|
this.stage = stage;
|
|
740
742
|
this.name = "PrivateFileError";
|
|
@@ -3909,7 +3911,7 @@ class ClaustrumScopedCustody {
|
|
|
3909
3911
|
throw error;
|
|
3910
3912
|
if (classifyVaultFailure(error) === "unreachable")
|
|
3911
3913
|
throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : undefined);
|
|
3912
|
-
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation
|
|
3914
|
+
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation failed");
|
|
3913
3915
|
} finally {
|
|
3914
3916
|
removeAbortListener?.();
|
|
3915
3917
|
}
|
|
@@ -10543,6 +10545,14 @@ async function exchange(input, verifier, redirectUri, expectedState) {
|
|
|
10543
10545
|
|
|
10544
10546
|
// src/host-retry.ts
|
|
10545
10547
|
var MAX_HOST_RETRY_MS = 15 * 60000;
|
|
10548
|
+
var resetWaits = new WeakMap;
|
|
10549
|
+
function markResetWaitResponse(response, delayMs) {
|
|
10550
|
+
resetWaits.set(response, delayMs);
|
|
10551
|
+
return response;
|
|
10552
|
+
}
|
|
10553
|
+
function resetWaitDelayMs(response) {
|
|
10554
|
+
return resetWaits.get(response);
|
|
10555
|
+
}
|
|
10546
10556
|
function clampHostRetryMs(delayMs) {
|
|
10547
10557
|
return Math.max(0, Math.min(MAX_HOST_RETRY_MS, Number.isNaN(delayMs) ? 0 : delayMs));
|
|
10548
10558
|
}
|
|
@@ -10565,6 +10575,8 @@ function hostRetryHeaders(upstream, now = Date.now()) {
|
|
|
10565
10575
|
return headers;
|
|
10566
10576
|
}
|
|
10567
10577
|
function hostRetryResponse(response, now = Date.now()) {
|
|
10578
|
+
if (resetWaits.has(response))
|
|
10579
|
+
return response;
|
|
10568
10580
|
const headers = hostRetryHeaders(response.headers, now);
|
|
10569
10581
|
if (["retry-after", "retry-after-ms"].every((name) => headers.get(name) === response.headers.get(name)))
|
|
10570
10582
|
return response;
|
|
@@ -12239,6 +12251,9 @@ var ROUTING_MODES = [
|
|
|
12239
12251
|
var DEFAULT_ROUTING_MODE = "main-first";
|
|
12240
12252
|
var MAX_SAME_ACCOUNT_WAITS = ["0", "15", "max"];
|
|
12241
12253
|
var DEFAULT_MAX_SAME_ACCOUNT_WAIT = "15";
|
|
12254
|
+
function getWaitForReset(storage) {
|
|
12255
|
+
return storage?.routing?.waitForReset === true;
|
|
12256
|
+
}
|
|
12242
12257
|
function getMaxSameAccountWait(storage) {
|
|
12243
12258
|
const value = storage?.routing?.maxSameAccountWait;
|
|
12244
12259
|
return MAX_SAME_ACCOUNT_WAITS.includes(value) ? value : DEFAULT_MAX_SAME_ACCOUNT_WAIT;
|
|
@@ -13093,8 +13108,10 @@ function quotaRefusalTiming(input) {
|
|
|
13093
13108
|
}
|
|
13094
13109
|
const earliest = resetTimes.sort((a, b) => a.resetAt - b.resetAt)[0];
|
|
13095
13110
|
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) + createHash4("sha256").update(input.sessionId ?? "").digest().readUInt32BE(0) % 21) * 1000 : undefined;
|
|
13096
13112
|
return {
|
|
13097
13113
|
resetAt,
|
|
13114
|
+
...resetWaitMs === undefined ? {} : { resetWaitMs },
|
|
13098
13115
|
...earliest ? { limitName: earliest.limitName } : {},
|
|
13099
13116
|
retryAfterSeconds: quotaRefusalRetryAfterSeconds({
|
|
13100
13117
|
resetAt,
|
|
@@ -29392,9 +29409,10 @@ function retryMinutes(seconds) {
|
|
|
29392
29409
|
return minutes === 1 ? "1 minute" : `${minutes} minutes`;
|
|
29393
29410
|
}
|
|
29394
29411
|
function createQuotaRefusalResponse(reason, timing, now = Date.now(), options = {}) {
|
|
29412
|
+
const resetWaitMs = options.retry !== "manual" ? timing.resetWaitMs : undefined;
|
|
29395
29413
|
timing = {
|
|
29396
29414
|
...timing,
|
|
29397
|
-
retryAfterSeconds: timing.retryAfterSeconds === undefined ? undefined : clampHostRetryMs(timing.retryAfterSeconds * 1000) / 1000
|
|
29415
|
+
retryAfterSeconds: resetWaitMs !== undefined ? resetWaitMs / 1000 : timing.retryAfterSeconds === undefined ? undefined : clampHostRetryMs(timing.retryAfterSeconds * 1000) / 1000
|
|
29398
29416
|
};
|
|
29399
29417
|
const reset = timing.resetAt === undefined ? "Reset time is unknown." : `Reset at ${new Intl.DateTimeFormat("en-US", {
|
|
29400
29418
|
month: "long",
|
|
@@ -29414,7 +29432,9 @@ function createQuotaRefusalResponse(reason, timing, now = Date.now(), options =
|
|
|
29414
29432
|
}).format(timing.resetAt);
|
|
29415
29433
|
const remaining = timing.resetAt === undefined ? 0 : Math.max(0, timing.resetAt - now);
|
|
29416
29434
|
const duration = remaining >= 3600000 ? `${Math.ceil(remaining / 3600000)} h` : `${Math.ceil(remaining / 60000)} min`;
|
|
29417
|
-
const
|
|
29435
|
+
const room = timing.limitName ? `No Claude account has room for this request (${timing.limitName} limit or your quota floor). ` : "";
|
|
29436
|
+
const manualAction = resetTime ? `The earliest reset is ${resetTime} UTC (in ${duration}). Send the message again after ${resetTime} UTC.` : "Reset time is unknown. Check account availability before sending the message again.";
|
|
29437
|
+
const message = options.retry === "manual" || seconds === undefined ? `${room}This turn has stopped. ${manualAction} ${reason}` : resetWaitMs !== undefined && resetTime ? `${room}The earliest reset is ${resetTime} UTC (in ${duration}). Waiting until the reset before retrying. ${reason}` : timing.limitName && resetTime ? `${room}The earliest reset is ${resetTime} UTC (in ${duration}). Retrying every ${retryMinutes(seconds)}. ${reason}` : `${reason}${retry} ${reset}`;
|
|
29418
29438
|
const response = new Response(JSON.stringify({
|
|
29419
29439
|
type: "error",
|
|
29420
29440
|
error: {
|
|
@@ -29429,7 +29449,7 @@ function createQuotaRefusalResponse(reason, timing, now = Date.now(), options =
|
|
|
29429
29449
|
}
|
|
29430
29450
|
});
|
|
29431
29451
|
details.set(response, { reason, timing });
|
|
29432
|
-
return response;
|
|
29452
|
+
return resetWaitMs === undefined ? response : markResetWaitResponse(response, resetWaitMs);
|
|
29433
29453
|
}
|
|
29434
29454
|
|
|
29435
29455
|
// src/sticky-routing.ts
|
|
@@ -29506,7 +29526,9 @@ function createStickyNoRouteResponse(input) {
|
|
|
29506
29526
|
storage: input.storage,
|
|
29507
29527
|
modelId,
|
|
29508
29528
|
now,
|
|
29509
|
-
sessionTtlMs: sessionCacheActivity.ttlMs(input.sessionId)
|
|
29529
|
+
sessionTtlMs: sessionCacheActivity.ttlMs(input.sessionId),
|
|
29530
|
+
waitForReset: input.waitForReset,
|
|
29531
|
+
sessionId: input.sessionId
|
|
29510
29532
|
});
|
|
29511
29533
|
const limitNames = input.vaultPolicyLimits?.map((limit) => limit === "model-scoped" ? `${modelName ?? "Model"} scoped limit` : limit === "killswitch" ? "killswitch limit" : "quota floor");
|
|
29512
29534
|
const reason = limitNames ? `No vault account currently satisfies quota policy: ${limitNames.join(", ")}. Open /claude → Killswitch / Quota to change these limits.` : scopedBlocked && modelName ? `${modelName} weekly limit reached, no routable OAuth accounts.` : "No OAuth account currently satisfies sticky-balanced quota policy.";
|
|
@@ -29747,6 +29769,13 @@ function stickyQuotaEvidence(input) {
|
|
|
29747
29769
|
return reading2 || confirmed && Object.keys(confirmed).length ? { ...reading2, ...confirmed } : undefined;
|
|
29748
29770
|
}
|
|
29749
29771
|
function stickyQuotaExhaustionInForce(input) {
|
|
29772
|
+
const blocker = quotaBlockerInForce(input, false);
|
|
29773
|
+
return blocker?.resetAt === undefined ? undefined : { ...blocker, resetAt: blocker.resetAt };
|
|
29774
|
+
}
|
|
29775
|
+
function stickyQuotaBlockerInForce(input) {
|
|
29776
|
+
return quotaBlockerInForce(input, true);
|
|
29777
|
+
}
|
|
29778
|
+
function quotaBlockerInForce(input, includeUnknown) {
|
|
29750
29779
|
const now = input.now ?? Date.now();
|
|
29751
29780
|
const quota2 = stickyQuotaEvidence({
|
|
29752
29781
|
quota: input.quota,
|
|
@@ -29759,6 +29788,7 @@ function stickyQuotaExhaustionInForce(input) {
|
|
|
29759
29788
|
return;
|
|
29760
29789
|
const scoped = getScopedQuotaWindowForModel(quota2, input.modelId);
|
|
29761
29790
|
let blocking;
|
|
29791
|
+
let unknown;
|
|
29762
29792
|
for (const [reason, limitName, window2] of [
|
|
29763
29793
|
["model-scoped", `${scoped?.modelName ?? "Model"} weekly`, scoped],
|
|
29764
29794
|
["seven-day", "weekly", quota2.seven_day],
|
|
@@ -29767,19 +29797,24 @@ function stickyQuotaExhaustionInForce(input) {
|
|
|
29767
29797
|
if (!window2 || !Number.isFinite(window2.remainingPercent) || window2.remainingPercent > 0)
|
|
29768
29798
|
continue;
|
|
29769
29799
|
const resetAt = window2.resetsAt ? Date.parse(window2.resetsAt) : NaN;
|
|
29770
|
-
if (!Number.isFinite(resetAt)
|
|
29800
|
+
if (!Number.isFinite(resetAt)) {
|
|
29801
|
+
if (includeUnknown)
|
|
29802
|
+
unknown = { reason, limitName };
|
|
29803
|
+
continue;
|
|
29804
|
+
}
|
|
29805
|
+
if (resetAt <= now)
|
|
29771
29806
|
continue;
|
|
29772
29807
|
if (!blocking || resetAt > blocking.resetAt)
|
|
29773
29808
|
blocking = { resetAt, reason, limitName };
|
|
29774
29809
|
}
|
|
29775
|
-
return blocking;
|
|
29810
|
+
return unknown ?? blocking;
|
|
29776
29811
|
}
|
|
29777
29812
|
function createExhaustedNoRouteResponse(input) {
|
|
29778
29813
|
const now = input.now ?? Date.now();
|
|
29779
|
-
const earliest =
|
|
29814
|
+
const earliest = input.exhausted.filter((row) => row.resetAt !== undefined).sort((a, b) => a.resetAt - b.resetAt)[0];
|
|
29780
29815
|
return createQuotaRefusalResponse("Claude reports every account that could take this request as out of quota.", {
|
|
29781
29816
|
resetAt: earliest?.resetAt,
|
|
29782
|
-
|
|
29817
|
+
limitName: earliest?.limitName ?? input.exhausted[0]?.limitName,
|
|
29783
29818
|
retryAfterSeconds: quotaRefusalRetryAfterSeconds({
|
|
29784
29819
|
resetAt: earliest?.resetAt,
|
|
29785
29820
|
storage: input.storage,
|
|
@@ -31293,6 +31328,55 @@ function processIncarnation(pid) {
|
|
|
31293
31328
|
return macosIncarnation(pid);
|
|
31294
31329
|
return Promise.resolve(null);
|
|
31295
31330
|
}
|
|
31331
|
+
var processStartReads = {
|
|
31332
|
+
platform: process.platform,
|
|
31333
|
+
readFile: (path2) => readFile14(path2, "utf8"),
|
|
31334
|
+
exec: (file, args) => new Promise((resolve18, reject) => {
|
|
31335
|
+
execFile2(file, args, { env: { ...process.env, TZ: "UTC0", LC_ALL: "C" }, timeout: 5000 }, (error, stdout) => error ? reject(error) : resolve18(String(stdout)));
|
|
31336
|
+
})
|
|
31337
|
+
};
|
|
31338
|
+
var clockTicks;
|
|
31339
|
+
async function processStartedAtMs(pid, reads = processStartReads) {
|
|
31340
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
31341
|
+
return null;
|
|
31342
|
+
try {
|
|
31343
|
+
if (reads.platform === "darwin") {
|
|
31344
|
+
const text5 = (await reads.exec("ps", ["-o", "lstart=", "-p", String(pid)])).trim();
|
|
31345
|
+
if (!/^\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4}$/.test(text5))
|
|
31346
|
+
return null;
|
|
31347
|
+
const start2 = Date.parse(`${text5} GMT`);
|
|
31348
|
+
return Number.isFinite(start2) && start2 >= 0 ? start2 : null;
|
|
31349
|
+
}
|
|
31350
|
+
if (reads.platform !== "linux")
|
|
31351
|
+
return null;
|
|
31352
|
+
const getTicks = async () => {
|
|
31353
|
+
try {
|
|
31354
|
+
const ticks2 = Number((await reads.exec("getconf", ["CLK_TCK"])).trim());
|
|
31355
|
+
if (Number.isFinite(ticks2) && ticks2 > 0)
|
|
31356
|
+
return ticks2;
|
|
31357
|
+
} catch {}
|
|
31358
|
+
return 100;
|
|
31359
|
+
};
|
|
31360
|
+
let ticks;
|
|
31361
|
+
if (reads === processStartReads) {
|
|
31362
|
+
clockTicks ??= getTicks();
|
|
31363
|
+
ticks = await clockTicks;
|
|
31364
|
+
} else
|
|
31365
|
+
ticks = await getTicks();
|
|
31366
|
+
const stat13 = await reads.readFile(`/proc/${pid}/stat`);
|
|
31367
|
+
const end = stat13.lastIndexOf(")");
|
|
31368
|
+
if (end < 0)
|
|
31369
|
+
return null;
|
|
31370
|
+
const startTicks = stat13.slice(end + 1).trim().split(/\s+/)[19];
|
|
31371
|
+
const boot = /^btime\s+(\d+)\s*$/m.exec(await reads.readFile("/proc/stat"))?.[1];
|
|
31372
|
+
if (!startTicks || !/^\d+$/.test(startTicks) || !boot)
|
|
31373
|
+
return null;
|
|
31374
|
+
const start = Number(boot) * 1000 + Number(startTicks) / ticks * 1000;
|
|
31375
|
+
return Number.isFinite(start) && start >= 0 ? start : null;
|
|
31376
|
+
} catch {
|
|
31377
|
+
return null;
|
|
31378
|
+
}
|
|
31379
|
+
}
|
|
31296
31380
|
var defaultLiveness = {
|
|
31297
31381
|
pidAlive,
|
|
31298
31382
|
incarnation: processIncarnation
|
|
@@ -34609,6 +34693,8 @@ function projectNativeAccountViews(input) {
|
|
|
34609
34693
|
...settings,
|
|
34610
34694
|
accounts: fallbacks
|
|
34611
34695
|
};
|
|
34696
|
+
if (input.settings.routing?.waitForReset === true)
|
|
34697
|
+
policyStorage.routing = { ...policyStorage.routing, waitForReset: true };
|
|
34612
34698
|
if (policyStorage.relay)
|
|
34613
34699
|
policyStorage.relay = {
|
|
34614
34700
|
...policyStorage.relay,
|
|
@@ -37146,6 +37232,7 @@ var settingsDefinition = defineSettings({
|
|
|
37146
37232
|
value: oneOf(["off", "15m", "cache"]),
|
|
37147
37233
|
default: "15m"
|
|
37148
37234
|
},
|
|
37235
|
+
wait_for_reset: { ...host, value: boolean(), default: false },
|
|
37149
37236
|
fallback_on: { ...host, value: list(integer()), default: [401, 403, 429] },
|
|
37150
37237
|
refresh_enabled: { ...host, value: boolean(), default: true },
|
|
37151
37238
|
refresh_interval_minutes: { ...host, value: nonnegative, default: 10 },
|
|
@@ -37228,6 +37315,7 @@ var settingsDefinition = defineSettings({
|
|
|
37228
37315
|
}
|
|
37229
37316
|
});
|
|
37230
37317
|
var SETTINGS_FILE_ONLY_KEYS = [
|
|
37318
|
+
"wait_for_reset",
|
|
37231
37319
|
"gateway_url",
|
|
37232
37320
|
"gateway_headers"
|
|
37233
37321
|
];
|
|
@@ -37235,6 +37323,7 @@ var SETTINGS_PI_DIFFERING_FIELDS = [];
|
|
|
37235
37323
|
var SETTINGS_DEFAULT_READERS = {
|
|
37236
37324
|
routing_mode: "packages/core/src/routing.ts:getRoutingMode",
|
|
37237
37325
|
max_same_account_wait: "packages/core/src/routing.ts:getMaxSameAccountWait",
|
|
37326
|
+
wait_for_reset: "packages/core/src/routing.ts:getWaitForReset",
|
|
37238
37327
|
fallback_on: "packages/core/src/accounts.ts:shouldFallbackStatus",
|
|
37239
37328
|
refresh_enabled: "packages/opencode/src/index.ts:mainRefreshEnabled",
|
|
37240
37329
|
refresh_interval_minutes: "packages/core/src/accounts.ts:getRefreshIntervalMs",
|
|
@@ -39151,7 +39240,8 @@ function resolveSettingsRecord(stored, generation, host2, model2) {
|
|
|
39151
39240
|
routing: {
|
|
39152
39241
|
...section2(stored, "routing"),
|
|
39153
39242
|
mode: values.routing_mode,
|
|
39154
|
-
maxSameAccountWait: legacyWait(values.max_same_account_wait)
|
|
39243
|
+
maxSameAccountWait: legacyWait(values.max_same_account_wait),
|
|
39244
|
+
waitForReset: values.wait_for_reset
|
|
39155
39245
|
},
|
|
39156
39246
|
fallbackOn: values.fallback_on,
|
|
39157
39247
|
refresh: {
|
|
@@ -45400,7 +45490,7 @@ var actions = Object.freeze([
|
|
|
45400
45490
|
group: "Accounts",
|
|
45401
45491
|
label: "Disconnect from the vault",
|
|
45402
45492
|
destructive: true,
|
|
45403
|
-
confirm: "Disconnect this host from the vault and return to local accounts? The vault keeps this host's enrollment approved until an operator revokes it there.",
|
|
45493
|
+
confirm: "Disconnect this host from the vault and return to local accounts? Pi's previous saved Claude sign-in is not restored; sign in again after disconnecting. The vault keeps this host's enrollment approved until an operator revokes it there.",
|
|
45404
45494
|
interactive: true,
|
|
45405
45495
|
headlessRefusal: "interactive-required",
|
|
45406
45496
|
parameters: []
|
|
@@ -46041,12 +46131,7 @@ function plan(actions2, rawRequest, rawContext) {
|
|
|
46041
46131
|
options
|
|
46042
46132
|
};
|
|
46043
46133
|
}
|
|
46044
|
-
var DISCONNECT_RESULTS = new Set([
|
|
46045
|
-
"disconnected",
|
|
46046
|
-
"idle",
|
|
46047
|
-
"busy",
|
|
46048
|
-
"conflict"
|
|
46049
|
-
]);
|
|
46134
|
+
var DISCONNECT_RESULTS = new Set(["disconnected", "idle", "busy"]);
|
|
46050
46135
|
function readOutcome(action, outcome) {
|
|
46051
46136
|
const fields3 = readPlain(outcome, ["ok", "text"]);
|
|
46052
46137
|
const ok = fields3 instanceof Map ? fields3.get("ok") : undefined;
|
|
@@ -46078,11 +46163,7 @@ function disconnectFailureCode(error) {
|
|
|
46078
46163
|
case "unsafe-path":
|
|
46079
46164
|
return "disconnect-unsafe-file";
|
|
46080
46165
|
case "invalid-auth":
|
|
46081
|
-
case "invalid-stash":
|
|
46082
|
-
case "missing-stash":
|
|
46083
46166
|
return "disconnect-pi-recovery";
|
|
46084
|
-
case "conflict":
|
|
46085
|
-
return "disconnect-conflict";
|
|
46086
46167
|
case "lock-timeout":
|
|
46087
46168
|
case "lock-compromised":
|
|
46088
46169
|
return "disconnect-busy";
|
|
@@ -46956,18 +47037,12 @@ var DISCONNECT_OUTCOMES = {
|
|
|
46956
47037
|
ok: false,
|
|
46957
47038
|
code: "busy",
|
|
46958
47039
|
text: "Vault disconnect could not finish because another process is changing this host's enrollment. Try again."
|
|
46959
|
-
},
|
|
46960
|
-
conflict: {
|
|
46961
|
-
ok: false,
|
|
46962
|
-
code: "conflict",
|
|
46963
|
-
text: "Disconnect stopped: this host already has a different stored sign-in, so it and the sign-in saved when the host joined the vault were both kept, and the vault connection remains. Resolve the two sign-ins with offline setup."
|
|
46964
47040
|
}
|
|
46965
47041
|
};
|
|
46966
47042
|
var DISCONNECT_FAILURES = {
|
|
46967
47043
|
"disconnect-unsafe-file": "Check file ownership, private permissions, and safe storage. Then try Disconnect again. Do not delete enrollment files by hand.",
|
|
46968
47044
|
"disconnect-wrong-consumer": "The enrollment belongs to another host or plugin. Check this host’s enrollment path. Then try Disconnect again. Do not delete another host’s enrollment.",
|
|
46969
|
-
"disconnect-pi-recovery": "Repair
|
|
46970
|
-
"disconnect-conflict": "Resolve the stored Pi sign-in and its private recovery copy with offline setup. Keep both sign-ins. Then try Disconnect again.",
|
|
47045
|
+
"disconnect-pi-recovery": "Repair Pi’s auth file with offline setup. Then try Disconnect again. No saved sign-in will be restored.",
|
|
46971
47046
|
"disconnect-busy": "Stop other setup or disconnect attempts. Then try Disconnect again.",
|
|
46972
47047
|
"disconnect-io": "Check file access and free disk space. Then try Disconnect again.",
|
|
46973
47048
|
"execution-failed": "Check this host’s vault connection and file access. Then try Disconnect again.",
|
|
@@ -46989,6 +47064,11 @@ ${result.instructions.join(`
|
|
|
46989
47064
|
`)}`
|
|
46990
47065
|
};
|
|
46991
47066
|
case "disconnect":
|
|
47067
|
+
if (host2 === "pi" && (result.result === "disconnected" || result.result === "idle"))
|
|
47068
|
+
return {
|
|
47069
|
+
ok: true,
|
|
47070
|
+
text: "Pi is disconnected from the vault. Its previous saved Claude sign-in is not restored. Sign in again in Pi to use local authentication."
|
|
47071
|
+
};
|
|
46992
47072
|
return DISCONNECT_OUTCOMES[result.result];
|
|
46993
47073
|
case "failed":
|
|
46994
47074
|
if (result.action === "vault-disconnect")
|
|
@@ -47291,7 +47371,6 @@ function placeholderSecret(integrationID) {
|
|
|
47291
47371
|
return `${PLACEHOLDER_PREFIX}.${integrationID}`;
|
|
47292
47372
|
}
|
|
47293
47373
|
// ../../node_modules/@cortexkit/common-auth/dist/pi-slot/slot.js
|
|
47294
|
-
import { createHash as createHash26 } from "node:crypto";
|
|
47295
47374
|
import { constants as constants5 } from "node:fs";
|
|
47296
47375
|
import { lstat as lstat21, mkdir as mkdir17, open as open14, unlink as unlink11 } from "node:fs/promises";
|
|
47297
47376
|
import { dirname as dirname24, resolve as resolve23 } from "node:path";
|
|
@@ -47561,28 +47640,17 @@ function rootSpans(text6) {
|
|
|
47561
47640
|
function object4(value) {
|
|
47562
47641
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47563
47642
|
}
|
|
47564
|
-
function canonical2(value) {
|
|
47565
|
-
if (Array.isArray(value))
|
|
47566
|
-
return `[${value.map(canonical2).join(",")}]`;
|
|
47567
|
-
if (object4(value)) {
|
|
47568
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical2(value[key])}`).join(",")}}`;
|
|
47569
|
-
}
|
|
47570
|
-
return JSON.stringify(value);
|
|
47571
|
-
}
|
|
47572
|
-
function digest2(value) {
|
|
47573
|
-
return createHash26("sha256").update(canonical2(value)).digest("hex");
|
|
47574
|
-
}
|
|
47575
47643
|
function code(error) {
|
|
47576
47644
|
return object4(error) ? error.code : undefined;
|
|
47577
47645
|
}
|
|
47578
|
-
async function safeRead(path2,
|
|
47646
|
+
async function safeRead(path2, afterReadCheck) {
|
|
47579
47647
|
if (windowsPrivateFiles) {
|
|
47580
47648
|
try {
|
|
47581
47649
|
await afterReadCheck?.(path2);
|
|
47582
47650
|
const bytes = await readPrivateBuffer(path2, true);
|
|
47583
47651
|
const text6 = bytes.toString("utf8");
|
|
47584
47652
|
if (!bytes.equals(Buffer.from(text6)))
|
|
47585
|
-
throw new PiSlotError(
|
|
47653
|
+
throw new PiSlotError("invalid-auth");
|
|
47586
47654
|
return text6;
|
|
47587
47655
|
} catch (error) {
|
|
47588
47656
|
if (code(error) === "ENOENT")
|
|
@@ -47594,7 +47662,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
47594
47662
|
try {
|
|
47595
47663
|
file = await open14(path2, constants5.O_RDONLY | constants5.O_NOFOLLOW);
|
|
47596
47664
|
const stat14 = await file.stat();
|
|
47597
|
-
if (!stat14.isFile()
|
|
47665
|
+
if (!stat14.isFile()) {
|
|
47598
47666
|
throw new PiSlotError("unsafe-path");
|
|
47599
47667
|
}
|
|
47600
47668
|
await afterReadCheck?.(path2);
|
|
@@ -47605,7 +47673,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
47605
47673
|
const bytes = await file.readFile();
|
|
47606
47674
|
const text6 = bytes.toString("utf8");
|
|
47607
47675
|
if (!bytes.equals(Buffer.from(text6))) {
|
|
47608
|
-
throw new PiSlotError(
|
|
47676
|
+
throw new PiSlotError("invalid-auth");
|
|
47609
47677
|
}
|
|
47610
47678
|
return text6;
|
|
47611
47679
|
} catch (error) {
|
|
@@ -47640,10 +47708,6 @@ function parseAuth(text6, provider) {
|
|
|
47640
47708
|
throw new PiSlotError("invalid-auth");
|
|
47641
47709
|
}
|
|
47642
47710
|
}
|
|
47643
|
-
function entryText(auth) {
|
|
47644
|
-
const value = auth.property?.value;
|
|
47645
|
-
return value ? auth.text.slice(value.offset, value.offset + value.length) : null;
|
|
47646
|
-
}
|
|
47647
47711
|
function replaceEntry(auth, provider, next) {
|
|
47648
47712
|
const { text: text6, root, property } = auth;
|
|
47649
47713
|
const properties = root.children ?? [];
|
|
@@ -47702,24 +47766,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47702
47766
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
47703
47767
|
throw new PiSlotError("invalid-options");
|
|
47704
47768
|
}
|
|
47705
|
-
const authIdentity = digest2(authPath);
|
|
47706
|
-
const placeholderIdentity = digest2(placeholderKey);
|
|
47707
47769
|
const placeholder = { type: "api_key", key: placeholderKey };
|
|
47708
|
-
const isPlaceholder = (entry2) =>
|
|
47709
|
-
async function loadStash() {
|
|
47710
|
-
const text6 = await safeRead(stashPath, true, hooks?.afterReadCheck);
|
|
47711
|
-
if (text6 === undefined)
|
|
47712
|
-
return;
|
|
47713
|
-
try {
|
|
47714
|
-
const stash = JSON.parse(text6);
|
|
47715
|
-
if (stash.version !== 1 || stash.provider !== provider || stash.authIdentity !== authIdentity || stash.placeholderIdentity !== placeholderIdentity || stash.entry !== null && !object4(stash.entry) || stash.sha256 !== digest2(stash.entry) || (stash.entry === null ? stash.entryJson !== null : typeof stash.entryJson !== "string" || digest2(JSON.parse(stash.entryJson)) !== stash.sha256)) {
|
|
47716
|
-
throw new Error;
|
|
47717
|
-
}
|
|
47718
|
-
return stash;
|
|
47719
|
-
} catch {
|
|
47720
|
-
throw new PiSlotError("invalid-stash");
|
|
47721
|
-
}
|
|
47722
|
-
}
|
|
47770
|
+
const isPlaceholder = (entry2) => entry2 !== null && Object.keys(entry2).length === 2 && entry2.type === placeholder.type && entry2.key === placeholder.key;
|
|
47723
47771
|
async function locked(fn) {
|
|
47724
47772
|
let release2;
|
|
47725
47773
|
let assertFresh;
|
|
@@ -47766,11 +47814,25 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47766
47814
|
}
|
|
47767
47815
|
}
|
|
47768
47816
|
async function load() {
|
|
47769
|
-
|
|
47770
|
-
const stash = await loadStash();
|
|
47771
|
-
return { auth, stash };
|
|
47817
|
+
return parseAuth(await safeRead(authPath, hooks?.afterReadCheck) ?? "{}", provider);
|
|
47772
47818
|
}
|
|
47773
47819
|
async function deleteStash(assertLock) {
|
|
47820
|
+
try {
|
|
47821
|
+
const file = await lstat21(stashPath);
|
|
47822
|
+
if (!file.isFile())
|
|
47823
|
+
throw new PiSlotError("unsafe-path");
|
|
47824
|
+
} catch (error) {
|
|
47825
|
+
if (code(error) === "ENOENT")
|
|
47826
|
+
return;
|
|
47827
|
+
throw error;
|
|
47828
|
+
}
|
|
47829
|
+
if (windowsPrivateFiles)
|
|
47830
|
+
await verifySafeDirectory(dirname24(stashPath));
|
|
47831
|
+
else {
|
|
47832
|
+
const dir = await lstat21(dirname24(stashPath));
|
|
47833
|
+
if (!dir.isDirectory() || (dir.mode & 511) !== 448)
|
|
47834
|
+
throw new PiSlotError("unsafe-path");
|
|
47835
|
+
}
|
|
47774
47836
|
assertLock();
|
|
47775
47837
|
await unlink11(stashPath);
|
|
47776
47838
|
await syncDir(dirname24(stashPath));
|
|
@@ -47778,58 +47840,27 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47778
47840
|
}
|
|
47779
47841
|
return {
|
|
47780
47842
|
inspect: () => locked(async () => {
|
|
47781
|
-
const
|
|
47782
|
-
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" :
|
|
47783
|
-
return { slot
|
|
47843
|
+
const auth = await load();
|
|
47844
|
+
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" : "original";
|
|
47845
|
+
return { slot };
|
|
47784
47846
|
}),
|
|
47785
47847
|
enterVault: () => locked(async (assertLock) => {
|
|
47786
|
-
const
|
|
47787
|
-
if (isPlaceholder(auth.entry)) {
|
|
47788
|
-
|
|
47789
|
-
|
|
47790
|
-
return;
|
|
47791
|
-
}
|
|
47792
|
-
if (stash && digest2(auth.entry) !== stash.sha256)
|
|
47793
|
-
throw new PiSlotError("conflict");
|
|
47794
|
-
if (!stash) {
|
|
47795
|
-
if (windowsPrivateFiles)
|
|
47796
|
-
await ensurePrivateDirectory(dirname24(stashPath));
|
|
47797
|
-
else {
|
|
47798
|
-
await mkdir17(dirname24(stashPath), { recursive: true, mode: 448 });
|
|
47799
|
-
const dir = await lstat21(dirname24(stashPath));
|
|
47800
|
-
if (!dir.isDirectory() || (dir.mode & 511) !== 448)
|
|
47801
|
-
throw new PiSlotError("unsafe-path");
|
|
47802
|
-
}
|
|
47803
|
-
const saved = {
|
|
47804
|
-
version: 1,
|
|
47805
|
-
provider,
|
|
47806
|
-
authIdentity,
|
|
47807
|
-
placeholderIdentity,
|
|
47808
|
-
entry: auth.entry,
|
|
47809
|
-
entryJson: entryText(auth),
|
|
47810
|
-
sha256: digest2(auth.entry)
|
|
47811
|
-
};
|
|
47812
|
-
await atomicWrite(stashPath, JSON.stringify(saved), assertLock, hooks?.beforeRename);
|
|
47813
|
-
onStep?.("stash-written");
|
|
47848
|
+
const auth = await load();
|
|
47849
|
+
if (!isPlaceholder(auth.entry)) {
|
|
47850
|
+
await atomicWrite(authPath, replaceEntry(auth, provider, JSON.stringify(placeholder)), assertLock, hooks?.beforeRename);
|
|
47851
|
+
onStep?.("auth-written");
|
|
47814
47852
|
}
|
|
47815
|
-
await
|
|
47816
|
-
onStep?.("auth-written");
|
|
47853
|
+
await deleteStash(assertLock);
|
|
47817
47854
|
}),
|
|
47818
47855
|
exitVault: () => locked(async (assertLock) => {
|
|
47819
|
-
const
|
|
47820
|
-
|
|
47821
|
-
|
|
47822
|
-
|
|
47823
|
-
return "nothing-to-do";
|
|
47824
|
-
}
|
|
47825
|
-
if (isPlaceholder(auth.entry)) {
|
|
47826
|
-
await atomicWrite(authPath, replaceEntry(auth, provider, stash.entryJson), assertLock, hooks?.beforeRename);
|
|
47856
|
+
const auth = await load();
|
|
47857
|
+
const cleared = isPlaceholder(auth.entry);
|
|
47858
|
+
if (cleared) {
|
|
47859
|
+
await atomicWrite(authPath, replaceEntry(auth, provider, null), assertLock, hooks?.beforeRename);
|
|
47827
47860
|
onStep?.("auth-written");
|
|
47828
|
-
} else if (digest2(auth.entry) !== stash.sha256) {
|
|
47829
|
-
return "conflict";
|
|
47830
47861
|
}
|
|
47831
47862
|
await deleteStash(assertLock);
|
|
47832
|
-
return "
|
|
47863
|
+
return cleared ? "cleared" : "nothing-to-do";
|
|
47833
47864
|
})
|
|
47834
47865
|
};
|
|
47835
47866
|
}
|
|
@@ -47848,8 +47879,8 @@ function openNativePiAuthSlot(options) {
|
|
|
47848
47879
|
async function disconnectNativeVaultForHost(options) {
|
|
47849
47880
|
if (isVaultHosted())
|
|
47850
47881
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL);
|
|
47851
|
-
if (options.host === "pi"
|
|
47852
|
-
|
|
47882
|
+
if (options.host === "pi")
|
|
47883
|
+
await options.slot.exitVault();
|
|
47853
47884
|
const paths2 = getHostClaustrumEnrollmentPaths(options.host, options.env);
|
|
47854
47885
|
const result = await disconnectClaustrumEnrollment(paths2, `anthropic-auth-${options.host}`);
|
|
47855
47886
|
if (result === "disconnected" || result === "idle")
|
|
@@ -47891,7 +47922,8 @@ function createNativeVaultNoRouteResponse(input) {
|
|
|
47891
47922
|
routeAccountIds: active2.filter((account) => account.quota).map((account) => account.id),
|
|
47892
47923
|
storage: snapshot.policyStorage,
|
|
47893
47924
|
sessionId: input.sessionId,
|
|
47894
|
-
vaultPolicyLimits: [...limits]
|
|
47925
|
+
vaultPolicyLimits: [...limits],
|
|
47926
|
+
waitForReset: input.waitForReset && active2.every((account) => account.quota)
|
|
47895
47927
|
});
|
|
47896
47928
|
}
|
|
47897
47929
|
|
|
@@ -48004,7 +48036,7 @@ function requestMethod(input) {
|
|
|
48004
48036
|
return input instanceof Request ? input.method : "GET";
|
|
48005
48037
|
}
|
|
48006
48038
|
// src/prime.ts
|
|
48007
|
-
import { createHash as
|
|
48039
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
48008
48040
|
import * as fs4 from "node:fs";
|
|
48009
48041
|
import { mkdir as mkdir18, readdir as readdir7, rm as rm10, stat as stat14, writeFile as writeFile6 } from "node:fs/promises";
|
|
48010
48042
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
@@ -48213,7 +48245,7 @@ function primeStorageFingerprint(storagePath) {
|
|
|
48213
48245
|
throw error;
|
|
48214
48246
|
canonicalPath3 = absolutePath;
|
|
48215
48247
|
}
|
|
48216
|
-
return
|
|
48248
|
+
return createHash26("sha256").update(canonicalPath3).digest("hex").slice(0, 12);
|
|
48217
48249
|
}
|
|
48218
48250
|
function primeMarkerNamespaceDir(markerDir, storagePath) {
|
|
48219
48251
|
return join30(markerDir, primeStorageFingerprint(storagePath));
|
|
@@ -48536,8 +48568,8 @@ class PrimeManager {
|
|
|
48536
48568
|
return [markerPath];
|
|
48537
48569
|
const verifiedPath = this.verifiedMarkerPath(accountIdentity, resetsAtEpochMs);
|
|
48538
48570
|
if (resetsAtEpochMs === undefined) {
|
|
48539
|
-
const
|
|
48540
|
-
if ((await this.readMarkerNames(this.verifiedMarkerDir())).some((name) => name.startsWith(`${
|
|
48571
|
+
const digest2 = createHash26("sha256").update(accountIdentity).digest("hex");
|
|
48572
|
+
if ((await this.readMarkerNames(this.verifiedMarkerDir())).some((name) => name.startsWith(`${digest2}-`)))
|
|
48541
48573
|
return null;
|
|
48542
48574
|
}
|
|
48543
48575
|
if (!await this.tryClaimPath(this.verifiedMarkerDir(), verifiedPath))
|
|
@@ -48548,8 +48580,8 @@ class PrimeManager {
|
|
|
48548
48580
|
return join30(this.options.markerDir ?? defaultMarkerDir(), "accounts");
|
|
48549
48581
|
}
|
|
48550
48582
|
verifiedMarkerPath(accountIdentity, resetsAtEpochMs) {
|
|
48551
|
-
const
|
|
48552
|
-
return join30(this.verifiedMarkerDir(), `${
|
|
48583
|
+
const digest2 = createHash26("sha256").update(accountIdentity).digest("hex");
|
|
48584
|
+
return join30(this.verifiedMarkerDir(), `${digest2}-${resetsAtEpochMs ?? "bootstrap"}`);
|
|
48553
48585
|
}
|
|
48554
48586
|
async readMarkerNames(dir) {
|
|
48555
48587
|
try {
|
|
@@ -49897,7 +49929,7 @@ async function readArtifact(path2, blockers, malformedIsStale) {
|
|
|
49897
49929
|
} catch (error) {
|
|
49898
49930
|
if (errorCode5(error) === "ENOENT")
|
|
49899
49931
|
return;
|
|
49900
|
-
if (!malformedIsStale())
|
|
49932
|
+
if (!await malformedIsStale())
|
|
49901
49933
|
blockers.push({ kind: "artifact-scan", path: path2, reason: reasonOf(error) });
|
|
49902
49934
|
return;
|
|
49903
49935
|
}
|
|
@@ -49906,20 +49938,25 @@ async function readArtifact(path2, blockers, malformedIsStale) {
|
|
|
49906
49938
|
const startedAt = typeof value === "object" && value !== null ? "startedAt" in value ? value.startedAt : ("registeredAt" in value) ? value.registeredAt : mtimeMs : mtimeMs;
|
|
49907
49939
|
return { value, startedAt, regular };
|
|
49908
49940
|
} catch {
|
|
49909
|
-
if (!malformedIsStale(regular ? mtimeMs : undefined))
|
|
49941
|
+
if (!await malformedIsStale(regular ? mtimeMs : undefined))
|
|
49910
49942
|
blockers.push({ kind: "artifact-scan", path: path2, reason: "invalid" });
|
|
49911
49943
|
return;
|
|
49912
49944
|
}
|
|
49913
49945
|
}
|
|
49914
49946
|
async function preNArtifactBlockers(locations, pidAlive2 = defaultLiveness2.pidAlive, clock = {}, acceptsRelease) {
|
|
49915
49947
|
const exempt = (value) => stamped(value) && (!acceptsRelease || acceptsRelease(value.writer.release));
|
|
49916
|
-
const malformedIsStale = (pid, startedAt) => {
|
|
49948
|
+
const malformedIsStale = async (pid, startedAt) => {
|
|
49917
49949
|
if (pid === undefined)
|
|
49918
49950
|
return false;
|
|
49919
49951
|
if (recordPredatesBoot(startedAt, clock))
|
|
49920
49952
|
return true;
|
|
49921
49953
|
try {
|
|
49922
|
-
|
|
49954
|
+
if (!pidAlive2(pid))
|
|
49955
|
+
return true;
|
|
49956
|
+
if (typeof startedAt !== "number" || !Number.isFinite(startedAt) || startedAt < 0 || startedAt > (clock.now ?? Date.now)())
|
|
49957
|
+
return false;
|
|
49958
|
+
const start = await (clock.processStartedAtMs ?? processStartedAtMs)(pid);
|
|
49959
|
+
return start !== null && Number.isFinite(start) && start > startedAt + 2000;
|
|
49923
49960
|
} catch {
|
|
49924
49961
|
return false;
|
|
49925
49962
|
}
|
|
@@ -49942,11 +49979,11 @@ async function preNArtifactBlockers(locations, pidAlive2 = defaultLiveness2.pidA
|
|
|
49942
49979
|
const { value, startedAt } = record17;
|
|
49943
49980
|
const pid = value?.pid;
|
|
49944
49981
|
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0) {
|
|
49945
|
-
if (!isStale(record17.regular ? startedAt : undefined))
|
|
49982
|
+
if (!await isStale(record17.regular ? startedAt : undefined))
|
|
49946
49983
|
blockers.push({ kind: "artifact-scan", path: path2, reason: "invalid" });
|
|
49947
49984
|
continue;
|
|
49948
49985
|
}
|
|
49949
|
-
if (!
|
|
49986
|
+
if (!await malformedIsStale(pid, record17.regular ? startedAt : undefined))
|
|
49950
49987
|
blockers.push({ kind: "pre-n-artifact", artifact: path2, pid });
|
|
49951
49988
|
}
|
|
49952
49989
|
}
|
|
@@ -49961,7 +49998,7 @@ async function preNArtifactBlockers(locations, pidAlive2 = defaultLiveness2.pidA
|
|
|
49961
49998
|
if (record17 === undefined || exempt(record17.value))
|
|
49962
49999
|
continue;
|
|
49963
50000
|
const pid = Number(match[1]);
|
|
49964
|
-
if (!
|
|
50001
|
+
if (!await malformedIsStale(pid, record17.regular ? record17.startedAt : undefined))
|
|
49965
50002
|
blockers.push({ kind: "pre-n-artifact", artifact: path2, pid });
|
|
49966
50003
|
}
|
|
49967
50004
|
}
|
|
@@ -51319,12 +51356,12 @@ function expectRecord(sub, want) {
|
|
|
51319
51356
|
}
|
|
51320
51357
|
function expectDigest(path2, sha256) {
|
|
51321
51358
|
return async () => {
|
|
51322
|
-
const
|
|
51359
|
+
const digest2 = await digestFile(path2);
|
|
51323
51360
|
if (sha256 === null)
|
|
51324
|
-
return
|
|
51325
|
-
if (
|
|
51361
|
+
return digest2.status === "absent" ? undefined : "it exists";
|
|
51362
|
+
if (digest2.status === "file" && digest2.sha256 === sha256)
|
|
51326
51363
|
return;
|
|
51327
|
-
return
|
|
51364
|
+
return digest2.status === "absent" ? "it is missing" : "its bytes changed";
|
|
51328
51365
|
};
|
|
51329
51366
|
}
|
|
51330
51367
|
function expectTombstone(path2, attempt) {
|
|
@@ -51394,8 +51431,8 @@ async function rollbackPreparing(record17, dataset, ctx) {
|
|
|
51394
51431
|
await removeOwnStaging(relocatingPath(file.to, attempt));
|
|
51395
51432
|
if (file.sha256 === null)
|
|
51396
51433
|
continue;
|
|
51397
|
-
const
|
|
51398
|
-
if (
|
|
51434
|
+
const digest2 = await digestFile(file.to);
|
|
51435
|
+
if (digest2.status !== "file" || digest2.sha256 !== file.sha256)
|
|
51399
51436
|
continue;
|
|
51400
51437
|
if (!await exists5(file.from))
|
|
51401
51438
|
continue;
|
|
@@ -51460,14 +51497,14 @@ async function cleanupOldCopies(record17, dataset, ctx) {
|
|
|
51460
51497
|
const path2 = role === "journal" ? movingJournalPath(file.from, record17.attempt) : file.from;
|
|
51461
51498
|
await ctx.stack.assertAll();
|
|
51462
51499
|
const credential2 = CREDENTIAL_AUTHORITY_ROLES.includes(role);
|
|
51463
|
-
let
|
|
51500
|
+
let digest2;
|
|
51464
51501
|
try {
|
|
51465
|
-
|
|
51502
|
+
digest2 = await digestFile(path2);
|
|
51466
51503
|
} catch (error) {
|
|
51467
51504
|
if (!credential2)
|
|
51468
51505
|
throw error;
|
|
51469
51506
|
}
|
|
51470
|
-
if (
|
|
51507
|
+
if (digest2?.status === "absent") {} else if (digest2 !== undefined && file.sha256 !== null && digest2.sha256 === file.sha256) {
|
|
51471
51508
|
await owned2(ctx, { kind: "unlink", path: path2 }, expectDigest(path2, file.sha256));
|
|
51472
51509
|
} else if (credential2) {
|
|
51473
51510
|
conflict.push({ old: path2, new: file.to });
|
|
@@ -51764,9 +51801,9 @@ async function finishRestoreRetirement(record17, dataset, ctx) {
|
|
|
51764
51801
|
const kept = [...record17.restore?.kept ?? []];
|
|
51765
51802
|
for (const file of restore.files) {
|
|
51766
51803
|
try {
|
|
51767
|
-
const
|
|
51768
|
-
if (
|
|
51769
|
-
if (
|
|
51804
|
+
const digest2 = await digestFile(file.to);
|
|
51805
|
+
if (digest2.status === "file") {
|
|
51806
|
+
if (digest2.sha256 === file.sha256)
|
|
51770
51807
|
await owned2(ctx, { kind: "unlink", path: file.to }, expectDigest(file.to, file.sha256));
|
|
51771
51808
|
else
|
|
51772
51809
|
throw new Error("its bytes changed after they were restored");
|
|
@@ -51983,19 +52020,19 @@ async function startRestore(record17, dataset, ctx, options) {
|
|
|
51983
52020
|
const attempt = randomUUID28();
|
|
51984
52021
|
const files = [];
|
|
51985
52022
|
for (const slot of dataset.slots) {
|
|
51986
|
-
let
|
|
52023
|
+
let digest2;
|
|
51987
52024
|
try {
|
|
51988
|
-
|
|
52025
|
+
digest2 = await digestFile(slot.to);
|
|
51989
52026
|
} catch (error) {
|
|
51990
52027
|
throw refused2(`${slot.to} is not a regular file, so anthropic-auth won't restore it; move it aside, then run ${RESTORE_LEGACY_COMMAND} again.`, [slot.to], error);
|
|
51991
52028
|
}
|
|
51992
|
-
if (
|
|
52029
|
+
if (digest2.status !== "file")
|
|
51993
52030
|
continue;
|
|
51994
52031
|
files.push({
|
|
51995
52032
|
role: slot.role,
|
|
51996
52033
|
from: slot.from,
|
|
51997
52034
|
to: slot.to,
|
|
51998
|
-
sha256:
|
|
52035
|
+
sha256: digest2.sha256,
|
|
51999
52036
|
staging: restoreStagingPath(slot.from, attempt)
|
|
52000
52037
|
});
|
|
52001
52038
|
}
|
|
@@ -53035,6 +53072,7 @@ export {
|
|
|
53035
53072
|
stickyRetainRetryHeaders,
|
|
53036
53073
|
stickyQuotaSnapshotIsFresh,
|
|
53037
53074
|
stickyQuotaExhaustionInForce,
|
|
53075
|
+
stickyQuotaBlockerInForce,
|
|
53038
53076
|
stateSubfolderName,
|
|
53039
53077
|
stateRefusalPublicMessage,
|
|
53040
53078
|
stateRefusalCause,
|
|
@@ -53100,6 +53138,7 @@ export {
|
|
|
53100
53138
|
resolveClaudeModelCapabilities,
|
|
53101
53139
|
resolveClaudeCodeIdentity,
|
|
53102
53140
|
resolveClaudeCodeAccountIdentity,
|
|
53141
|
+
resetWaitDelayMs,
|
|
53103
53142
|
resetVaultHostAuthorityForTests,
|
|
53104
53143
|
resetStateLayoutDecisionsForTests,
|
|
53105
53144
|
resetProcessStateLayoutsForTests,
|
|
@@ -53178,6 +53217,7 @@ export {
|
|
|
53178
53217
|
publishNativeEmptyInit,
|
|
53179
53218
|
publishHolderEntryLocked,
|
|
53180
53219
|
processStateLayout,
|
|
53220
|
+
processStartedAtMs,
|
|
53181
53221
|
processIncarnation,
|
|
53182
53222
|
primeStorageFingerprint,
|
|
53183
53223
|
primeMarkerPath,
|
|
@@ -53254,6 +53294,7 @@ export {
|
|
|
53254
53294
|
mergeHeaderQuotaForPersistence,
|
|
53255
53295
|
mergeAnthropicBetas,
|
|
53256
53296
|
markSettingsImportPending,
|
|
53297
|
+
markResetWaitResponse,
|
|
53257
53298
|
mapSettingsMoveSources,
|
|
53258
53299
|
malformedSettingsText,
|
|
53259
53300
|
lookupGatewaySettingsFile,
|
|
@@ -53339,6 +53380,7 @@ export {
|
|
|
53339
53380
|
hasPrivateSettingsConfigHome,
|
|
53340
53381
|
hasNoLocalCredential,
|
|
53341
53382
|
guardAnthropicStreamResponse,
|
|
53383
|
+
getWaitForReset,
|
|
53342
53384
|
getThinkingPrefixMismatchBehavior,
|
|
53343
53385
|
getStickyRoutingStatePath,
|
|
53344
53386
|
getSettingsStorePaths,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Replace a Pi provider login with a vault placeholder without changing provider or model identifiers. */
|
|
2
2
|
export type { PiSlot, PiSlotErrorCode, PiSlotInspection, PiSlotOptions, } from './slot.js';
|
|
3
3
|
export { openPiSlot, PiSlotError } from './slot.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type PiSlotErrorCode = 'invalid-options' | 'invalid-auth' | '
|
|
1
|
+
export type PiSlotErrorCode = 'invalid-options' | 'invalid-auth' | 'unsafe-path' | 'lock-timeout' | 'lock-compromised' | 'io';
|
|
2
2
|
/** Errors deliberately contain neither paths nor credentials nor underlying error messages. */
|
|
3
3
|
export declare class PiSlotError extends Error {
|
|
4
4
|
readonly code: PiSlotErrorCode;
|
|
@@ -10,10 +10,8 @@ export interface PiSlotOptions {
|
|
|
10
10
|
authPath: string;
|
|
11
11
|
provider: string;
|
|
12
12
|
/**
|
|
13
|
-
* Where the
|
|
14
|
-
*
|
|
15
|
-
* stash holds one provider's original login, and a second provider writing
|
|
16
|
-
* to it would overwrite the first one's backup.
|
|
13
|
+
* Where older versions kept the original Pi login; deleted when found.
|
|
14
|
+
* Keep the same path across upgrades so legacy credentials can be removed.
|
|
17
15
|
*/
|
|
18
16
|
stashPath: string;
|
|
19
17
|
/**
|
|
@@ -26,13 +24,12 @@ export interface PiSlotOptions {
|
|
|
26
24
|
lockTimeoutMs?: number;
|
|
27
25
|
}
|
|
28
26
|
export interface PiSlotInspection {
|
|
29
|
-
slot: 'original' | 'placeholder' | '
|
|
30
|
-
stash: 'valid' | 'missing';
|
|
27
|
+
slot: 'original' | 'placeholder' | 'empty';
|
|
31
28
|
}
|
|
32
29
|
export interface PiSlot {
|
|
33
30
|
inspect(): Promise<PiSlotInspection>;
|
|
34
31
|
enterVault(): Promise<void>;
|
|
35
|
-
exitVault(): Promise<'
|
|
32
|
+
exitVault(): Promise<'cleared' | 'nothing-to-do'>;
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* Production entry point. Pi caches which models are usable; after a
|
|
@@ -44,7 +41,7 @@ export declare function openPiSlot(options: PiSlotOptions): PiSlot;
|
|
|
44
41
|
* Internal test entry point: pause reads, renewals, or renames to simulate races,
|
|
45
42
|
* and observe durable writes/deletion to simulate crashes. Not a public export.
|
|
46
43
|
*/
|
|
47
|
-
export declare function createPiSlot(options: PiSlotOptions, onStep?: (step: '
|
|
44
|
+
export declare function createPiSlot(options: PiSlotOptions, onStep?: (step: 'auth-written' | 'stash-deleted') => void, hooks?: {
|
|
48
45
|
afterReadCheck?: (path: string) => Promise<void>;
|
|
49
46
|
onRenew?: (renew: () => Promise<void>) => void;
|
|
50
47
|
beforeRename?: (path: string) => Promise<void>;
|
package/dist/layout-fence.d.ts
CHANGED
|
@@ -58,11 +58,11 @@ export declare function defaultPreNArtifactLocations(env?: NodeJS.ProcessEnv, ho
|
|
|
58
58
|
* The fence's check for older versions: an RPC port file or CacheKeep record without the
|
|
59
59
|
* `writer` stamp, whose pid is alive, belongs to a version that registers
|
|
60
60
|
* nothing and blocks. Unreadable or malformed publisher-owned files need a
|
|
61
|
-
* proven dead filename pid, or a readable regular file's pre-boot mtime.
|
|
61
|
+
* proven dead or reused filename pid, or a readable regular file's pre-boot mtime.
|
|
62
62
|
* Other scan failures block. A record from before this boot is stale even
|
|
63
63
|
* if its pid has been reused; missing or untrustworthy times keep blocking.
|
|
64
64
|
*/
|
|
65
|
-
export declare function preNArtifactBlockers(locations: PreNArtifactLocations, pidAlive?: (pid: number) => boolean, clock?: Pick<HolderLiveness, 'now' | 'uptime'>,
|
|
65
|
+
export declare function preNArtifactBlockers(locations: PreNArtifactLocations, pidAlive?: (pid: number) => boolean, clock?: Pick<HolderLiveness, 'now' | 'uptime' | 'processStartedAtMs'>,
|
|
66
66
|
/**
|
|
67
67
|
* When set, a stamped artifact counts as older too unless this accepts its
|
|
68
68
|
* `writer.release`: its writer may be a release below a later fence's
|
|
@@ -170,13 +170,11 @@ export type NativeMenuExecutorOptions = {
|
|
|
170
170
|
};
|
|
171
171
|
/**
|
|
172
172
|
* What a host's vault disconnect reports. `disconnected`: the host is back in
|
|
173
|
-
* local custody. `idle`: no active enrollment remains
|
|
174
|
-
*
|
|
175
|
-
* and disconnect could not finish.
|
|
176
|
-
* the host's stored sign-in could not be restored without overwriting one it
|
|
177
|
-
* already has, so both were kept and the enrollment remains.
|
|
173
|
+
* local custody. `idle`: no active enrollment remains. Pi's vault placeholder
|
|
174
|
+
* is cleared in either case, but no discarded sign-in is restored.
|
|
175
|
+
* `busy`: another process holds the enrollment lock and disconnect could not finish.
|
|
178
176
|
*/
|
|
179
|
-
export type NativeVaultDisconnectResult = 'disconnected' | 'idle' | 'busy'
|
|
177
|
+
export type NativeVaultDisconnectResult = 'disconnected' | 'idle' | 'busy';
|
|
180
178
|
/** The host capability that disconnects this host from the vault. */
|
|
181
179
|
export type NativeVaultDisconnect = (options: NativeMenuDispatchOptions) => Promise<NativeVaultDisconnectResult>;
|
|
182
180
|
/** Facts about the invocation that the safety rules depend on. */
|
|
@@ -215,7 +213,7 @@ export type NativeMenuExecutionResult = {
|
|
|
215
213
|
*/
|
|
216
214
|
readonly status: 'failed';
|
|
217
215
|
readonly action: NativeMenuDispatchActionId | 'vault-disconnect';
|
|
218
|
-
readonly code: 'execution-failed' | 'invalid-outcome' | 'disconnect-unsafe-file' | 'disconnect-wrong-consumer' | 'disconnect-pi-recovery' | 'disconnect-
|
|
216
|
+
readonly code: 'execution-failed' | 'invalid-outcome' | 'disconnect-unsafe-file' | 'disconnect-wrong-consumer' | 'disconnect-pi-recovery' | 'disconnect-busy' | 'disconnect-io';
|
|
219
217
|
} | {
|
|
220
218
|
/** The host's disconnect capability ran and reported this result. */
|
|
221
219
|
readonly status: 'disconnect';
|
package/dist/native-ui.d.ts
CHANGED
|
@@ -26,9 +26,7 @@ export interface NativeUiOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* Disconnects this host from the vault; while enrolled, this is the host's
|
|
28
28
|
* only enrollment action. Before ending the enrollment, the callback
|
|
29
|
-
*
|
|
30
|
-
* that restore would overwrite a sign-in the host already has, the callback
|
|
31
|
-
* reports `conflict` and leaves the enrollment in place. Every host must
|
|
29
|
+
* clears Pi's vault placeholder without restoring any sign-in. Every host must
|
|
32
30
|
* supply it: a host enrolled in the vault, or with an unreadable
|
|
33
31
|
* enrollment, always needs a way back to local accounts.
|
|
34
32
|
*/
|
|
@@ -6,14 +6,14 @@ export interface NativePiAuthSlotOptions {
|
|
|
6
6
|
authPath: string;
|
|
7
7
|
env?: NodeJS.ProcessEnv;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/** Keep the legacy stash path stable so setup and disconnect remove old saved credentials. */
|
|
10
10
|
export declare function nativePiAuthSlotPaths(options: NativePiAuthSlotOptions): {
|
|
11
11
|
authPath: string;
|
|
12
12
|
stashPath: string;
|
|
13
13
|
provider: string;
|
|
14
14
|
placeholderKey: string;
|
|
15
15
|
};
|
|
16
|
-
/** Delegate
|
|
16
|
+
/** Delegate Pi-auth replacement and legacy cleanup to the shared locked writer. */
|
|
17
17
|
export declare function openNativePiAuthSlot(options: NativePiAuthSlotOptions): PiSlot;
|
|
18
18
|
export type NativeVaultDisconnectOptions = {
|
|
19
19
|
host: 'opencode';
|
|
@@ -23,11 +23,10 @@ export type NativeVaultDisconnectOptions = {
|
|
|
23
23
|
env?: NodeJS.ProcessEnv;
|
|
24
24
|
slot: Pick<PiSlot, 'exitVault'>;
|
|
25
25
|
};
|
|
26
|
-
export type NativeVaultDisconnectResult = 'disconnected' | 'idle' | 'busy'
|
|
26
|
+
export type NativeVaultDisconnectResult = 'disconnected' | 'idle' | 'busy';
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* intact rather than selecting local custody with unresolved recovery data.
|
|
28
|
+
* Clear Pi's vault placeholder before removing this host's enrollment.
|
|
29
|
+
* No saved sign-in is restored; a new sign-in made through Pi is left alone.
|
|
31
30
|
* OpenCode authentication is never changed by this operation.
|
|
32
31
|
*/
|
|
33
32
|
export declare function disconnectNativeVaultForHost(options: NativeVaultDisconnectOptions): Promise<NativeVaultDisconnectResult>;
|
package/dist/routing.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const DEFAULT_ROUTING_MODE: RoutingMode;
|
|
|
5
5
|
export declare const MAX_SAME_ACCOUNT_WAITS: readonly ['0', '15', 'max'];
|
|
6
6
|
export type MaxSameAccountWait = (typeof MAX_SAME_ACCOUNT_WAITS)[number];
|
|
7
7
|
export declare const DEFAULT_MAX_SAME_ACCOUNT_WAIT: MaxSameAccountWait;
|
|
8
|
+
export declare function getWaitForReset(storage: AccountSettingsReaderInput | null): boolean;
|
|
8
9
|
export declare function getMaxSameAccountWait(storage: AccountSettingsReaderInput | null): MaxSameAccountWait;
|
|
9
10
|
type RoutingCommandAction = {
|
|
10
11
|
type: 'status';
|
|
@@ -24,6 +24,17 @@ export declare const settingsDefinition: import("./internal-types/settings/index
|
|
|
24
24
|
}>;
|
|
25
25
|
readonly default: "15m";
|
|
26
26
|
};
|
|
27
|
+
readonly wait_for_reset: {
|
|
28
|
+
readonly hosts: 'both';
|
|
29
|
+
readonly project: 'user-only';
|
|
30
|
+
readonly overrides: {
|
|
31
|
+
readonly host: true;
|
|
32
|
+
};
|
|
33
|
+
readonly value: Readonly<{
|
|
34
|
+
readonly kind: 'boolean';
|
|
35
|
+
}>;
|
|
36
|
+
readonly default: false;
|
|
37
|
+
};
|
|
27
38
|
readonly fallback_on: {
|
|
28
39
|
readonly hosts: 'both';
|
|
29
40
|
readonly project: 'user-only';
|
|
@@ -469,13 +480,14 @@ export type SettingsKey = keyof typeof settingsDefinition.settings;
|
|
|
469
480
|
* them, so the one-time move never reads or writes them, and the `/claude`
|
|
470
481
|
* menu never writes them.
|
|
471
482
|
*/
|
|
472
|
-
export declare const SETTINGS_FILE_ONLY_KEYS: readonly ["gateway_url", "gateway_headers"];
|
|
483
|
+
export declare const SETTINGS_FILE_ONLY_KEYS: readonly ["wait_for_reset", "gateway_url", "gateway_headers"];
|
|
473
484
|
/** Empty: no Pi-specific default is needed beyond per-reader default/on/off handling. */
|
|
474
485
|
export declare const SETTINGS_PI_DIFFERING_FIELDS: readonly [];
|
|
475
486
|
/** Names the current readers whose absence behavior determines each schema default. */
|
|
476
487
|
export declare const SETTINGS_DEFAULT_READERS: {
|
|
477
488
|
readonly routing_mode: 'packages/core/src/routing.ts:getRoutingMode';
|
|
478
489
|
readonly max_same_account_wait: 'packages/core/src/routing.ts:getMaxSameAccountWait';
|
|
490
|
+
readonly wait_for_reset: 'packages/core/src/routing.ts:getWaitForReset';
|
|
479
491
|
readonly fallback_on: 'packages/core/src/accounts.ts:shouldFallbackStatus';
|
|
480
492
|
readonly refresh_enabled: 'packages/opencode/src/index.ts:mainRefreshEnabled';
|
|
481
493
|
readonly refresh_interval_minutes: 'packages/core/src/accounts.ts:getRefreshIntervalMs';
|
package/dist/sticky-routing.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export declare function createStickyNoRouteResponse(input: {
|
|
|
75
75
|
storage?: AccountStorage | null;
|
|
76
76
|
sessionId?: string | null;
|
|
77
77
|
vaultPolicyLimits?: readonly NativeQuotaPolicyLimit[];
|
|
78
|
+
waitForReset?: boolean;
|
|
78
79
|
modelId?: string;
|
|
79
80
|
now?: number;
|
|
80
81
|
}): Response;
|
|
@@ -141,13 +142,27 @@ export declare function stickyQuotaExhaustionInForce(input: {
|
|
|
141
142
|
modelId?: string;
|
|
142
143
|
now?: number;
|
|
143
144
|
}): StickyQuotaExhaustion | undefined;
|
|
145
|
+
export type StickyQuotaBlocker = Omit<StickyQuotaExhaustion, 'resetAt'> & {
|
|
146
|
+
readonly resetAt?: number;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Like stickyQuotaExhaustionInForce, but also report confirmed exhaustion whose
|
|
150
|
+
* reset time is unknown. Callers use it to stop a turn: without a known reset
|
|
151
|
+
* there is nothing to wait for, so the host is not asked to retry later.
|
|
152
|
+
*/
|
|
153
|
+
export declare function stickyQuotaBlockerInForce(input: {
|
|
154
|
+
quota: OAuthQuotaSnapshot | QuotaState | undefined;
|
|
155
|
+
responseHeaders?: Headers;
|
|
156
|
+
modelId?: string;
|
|
157
|
+
now?: number;
|
|
158
|
+
}): StickyQuotaBlocker | undefined;
|
|
144
159
|
/**
|
|
145
160
|
* The quota refusal for a request that no account can take because every
|
|
146
161
|
* account that could is confirmed exhausted (see `stickyQuotaExhaustionInForce`).
|
|
147
162
|
* It names the window that resets first across those accounts.
|
|
148
163
|
*/
|
|
149
164
|
export declare function createExhaustedNoRouteResponse(input: {
|
|
150
|
-
exhausted: readonly
|
|
165
|
+
exhausted: readonly StickyQuotaBlocker[];
|
|
151
166
|
storage?: AccountStorage | null;
|
|
152
167
|
sessionId?: string | null;
|
|
153
168
|
now?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepublishOnly": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cortexkit/common-auth": "0.
|
|
34
|
+
"@cortexkit/common-auth": "0.54.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cortexkit/claustrum-client": "0.18.0",
|
|
@@ -85,6 +85,28 @@
|
|
|
85
85
|
}
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
|
+
"wait_for_reset": {
|
|
89
|
+
"anyOf": [
|
|
90
|
+
{
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"type": "object",
|
|
95
|
+
"properties": {
|
|
96
|
+
"default": {
|
|
97
|
+
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"opencode": {
|
|
100
|
+
"type": "boolean"
|
|
101
|
+
},
|
|
102
|
+
"pi": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"additionalProperties": false
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
88
110
|
"fallback_on": {
|
|
89
111
|
"anyOf": [
|
|
90
112
|
{
|