@cortexkit/anthropic-auth-core 2.15.2 → 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/host-retry.d.ts +3 -1
- package/dist/index.js +102 -133
- package/dist/internal-types/pi-slot/index.d.ts +1 -1
- package/dist/internal-types/pi-slot/slot.d.ts +6 -9
- 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 +1 -0
- 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
|
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
|
@@ -736,7 +736,7 @@ class PrivateFileError extends Error {
|
|
|
736
736
|
orphanPath;
|
|
737
737
|
constructor(path, stage, cause) {
|
|
738
738
|
const detail = cause;
|
|
739
|
-
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 });
|
|
740
740
|
this.path = path;
|
|
741
741
|
this.stage = stage;
|
|
742
742
|
this.name = "PrivateFileError";
|
|
@@ -10545,6 +10545,14 @@ async function exchange(input, verifier, redirectUri, expectedState) {
|
|
|
10545
10545
|
|
|
10546
10546
|
// src/host-retry.ts
|
|
10547
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
|
+
}
|
|
10548
10556
|
function clampHostRetryMs(delayMs) {
|
|
10549
10557
|
return Math.max(0, Math.min(MAX_HOST_RETRY_MS, Number.isNaN(delayMs) ? 0 : delayMs));
|
|
10550
10558
|
}
|
|
@@ -10567,6 +10575,8 @@ function hostRetryHeaders(upstream, now = Date.now()) {
|
|
|
10567
10575
|
return headers;
|
|
10568
10576
|
}
|
|
10569
10577
|
function hostRetryResponse(response, now = Date.now()) {
|
|
10578
|
+
if (resetWaits.has(response))
|
|
10579
|
+
return response;
|
|
10570
10580
|
const headers = hostRetryHeaders(response.headers, now);
|
|
10571
10581
|
if (["retry-after", "retry-after-ms"].every((name) => headers.get(name) === response.headers.get(name)))
|
|
10572
10582
|
return response;
|
|
@@ -12241,6 +12251,9 @@ var ROUTING_MODES = [
|
|
|
12241
12251
|
var DEFAULT_ROUTING_MODE = "main-first";
|
|
12242
12252
|
var MAX_SAME_ACCOUNT_WAITS = ["0", "15", "max"];
|
|
12243
12253
|
var DEFAULT_MAX_SAME_ACCOUNT_WAIT = "15";
|
|
12254
|
+
function getWaitForReset(storage) {
|
|
12255
|
+
return storage?.routing?.waitForReset === true;
|
|
12256
|
+
}
|
|
12244
12257
|
function getMaxSameAccountWait(storage) {
|
|
12245
12258
|
const value = storage?.routing?.maxSameAccountWait;
|
|
12246
12259
|
return MAX_SAME_ACCOUNT_WAITS.includes(value) ? value : DEFAULT_MAX_SAME_ACCOUNT_WAIT;
|
|
@@ -13095,8 +13108,10 @@ function quotaRefusalTiming(input) {
|
|
|
13095
13108
|
}
|
|
13096
13109
|
const earliest = resetTimes.sort((a, b) => a.resetAt - b.resetAt)[0];
|
|
13097
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;
|
|
13098
13112
|
return {
|
|
13099
13113
|
resetAt,
|
|
13114
|
+
...resetWaitMs === undefined ? {} : { resetWaitMs },
|
|
13100
13115
|
...earliest ? { limitName: earliest.limitName } : {},
|
|
13101
13116
|
retryAfterSeconds: quotaRefusalRetryAfterSeconds({
|
|
13102
13117
|
resetAt,
|
|
@@ -29394,9 +29409,10 @@ function retryMinutes(seconds) {
|
|
|
29394
29409
|
return minutes === 1 ? "1 minute" : `${minutes} minutes`;
|
|
29395
29410
|
}
|
|
29396
29411
|
function createQuotaRefusalResponse(reason, timing, now = Date.now(), options = {}) {
|
|
29412
|
+
const resetWaitMs = options.retry !== "manual" ? timing.resetWaitMs : undefined;
|
|
29397
29413
|
timing = {
|
|
29398
29414
|
...timing,
|
|
29399
|
-
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
|
|
29400
29416
|
};
|
|
29401
29417
|
const reset = timing.resetAt === undefined ? "Reset time is unknown." : `Reset at ${new Intl.DateTimeFormat("en-US", {
|
|
29402
29418
|
month: "long",
|
|
@@ -29418,7 +29434,7 @@ function createQuotaRefusalResponse(reason, timing, now = Date.now(), options =
|
|
|
29418
29434
|
const duration = remaining >= 3600000 ? `${Math.ceil(remaining / 3600000)} h` : `${Math.ceil(remaining / 60000)} min`;
|
|
29419
29435
|
const room = timing.limitName ? `No Claude account has room for this request (${timing.limitName} limit or your quota floor). ` : "";
|
|
29420
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.";
|
|
29421
|
-
const message = options.retry === "manual" || seconds === undefined ? `${room}This turn has stopped. ${manualAction} ${reason}` : timing.limitName && resetTime ? `${room}The earliest reset is ${resetTime} UTC (in ${duration}). Retrying every ${retryMinutes(seconds)}. ${reason}` : `${reason}${retry} ${reset}`;
|
|
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}`;
|
|
29422
29438
|
const response = new Response(JSON.stringify({
|
|
29423
29439
|
type: "error",
|
|
29424
29440
|
error: {
|
|
@@ -29433,7 +29449,7 @@ function createQuotaRefusalResponse(reason, timing, now = Date.now(), options =
|
|
|
29433
29449
|
}
|
|
29434
29450
|
});
|
|
29435
29451
|
details.set(response, { reason, timing });
|
|
29436
|
-
return response;
|
|
29452
|
+
return resetWaitMs === undefined ? response : markResetWaitResponse(response, resetWaitMs);
|
|
29437
29453
|
}
|
|
29438
29454
|
|
|
29439
29455
|
// src/sticky-routing.ts
|
|
@@ -29510,7 +29526,9 @@ function createStickyNoRouteResponse(input) {
|
|
|
29510
29526
|
storage: input.storage,
|
|
29511
29527
|
modelId,
|
|
29512
29528
|
now,
|
|
29513
|
-
sessionTtlMs: sessionCacheActivity.ttlMs(input.sessionId)
|
|
29529
|
+
sessionTtlMs: sessionCacheActivity.ttlMs(input.sessionId),
|
|
29530
|
+
waitForReset: input.waitForReset,
|
|
29531
|
+
sessionId: input.sessionId
|
|
29514
29532
|
});
|
|
29515
29533
|
const limitNames = input.vaultPolicyLimits?.map((limit) => limit === "model-scoped" ? `${modelName ?? "Model"} scoped limit` : limit === "killswitch" ? "killswitch limit" : "quota floor");
|
|
29516
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.";
|
|
@@ -34675,6 +34693,8 @@ function projectNativeAccountViews(input) {
|
|
|
34675
34693
|
...settings,
|
|
34676
34694
|
accounts: fallbacks
|
|
34677
34695
|
};
|
|
34696
|
+
if (input.settings.routing?.waitForReset === true)
|
|
34697
|
+
policyStorage.routing = { ...policyStorage.routing, waitForReset: true };
|
|
34678
34698
|
if (policyStorage.relay)
|
|
34679
34699
|
policyStorage.relay = {
|
|
34680
34700
|
...policyStorage.relay,
|
|
@@ -37212,6 +37232,7 @@ var settingsDefinition = defineSettings({
|
|
|
37212
37232
|
value: oneOf(["off", "15m", "cache"]),
|
|
37213
37233
|
default: "15m"
|
|
37214
37234
|
},
|
|
37235
|
+
wait_for_reset: { ...host, value: boolean(), default: false },
|
|
37215
37236
|
fallback_on: { ...host, value: list(integer()), default: [401, 403, 429] },
|
|
37216
37237
|
refresh_enabled: { ...host, value: boolean(), default: true },
|
|
37217
37238
|
refresh_interval_minutes: { ...host, value: nonnegative, default: 10 },
|
|
@@ -37294,6 +37315,7 @@ var settingsDefinition = defineSettings({
|
|
|
37294
37315
|
}
|
|
37295
37316
|
});
|
|
37296
37317
|
var SETTINGS_FILE_ONLY_KEYS = [
|
|
37318
|
+
"wait_for_reset",
|
|
37297
37319
|
"gateway_url",
|
|
37298
37320
|
"gateway_headers"
|
|
37299
37321
|
];
|
|
@@ -37301,6 +37323,7 @@ var SETTINGS_PI_DIFFERING_FIELDS = [];
|
|
|
37301
37323
|
var SETTINGS_DEFAULT_READERS = {
|
|
37302
37324
|
routing_mode: "packages/core/src/routing.ts:getRoutingMode",
|
|
37303
37325
|
max_same_account_wait: "packages/core/src/routing.ts:getMaxSameAccountWait",
|
|
37326
|
+
wait_for_reset: "packages/core/src/routing.ts:getWaitForReset",
|
|
37304
37327
|
fallback_on: "packages/core/src/accounts.ts:shouldFallbackStatus",
|
|
37305
37328
|
refresh_enabled: "packages/opencode/src/index.ts:mainRefreshEnabled",
|
|
37306
37329
|
refresh_interval_minutes: "packages/core/src/accounts.ts:getRefreshIntervalMs",
|
|
@@ -39217,7 +39240,8 @@ function resolveSettingsRecord(stored, generation, host2, model2) {
|
|
|
39217
39240
|
routing: {
|
|
39218
39241
|
...section2(stored, "routing"),
|
|
39219
39242
|
mode: values.routing_mode,
|
|
39220
|
-
maxSameAccountWait: legacyWait(values.max_same_account_wait)
|
|
39243
|
+
maxSameAccountWait: legacyWait(values.max_same_account_wait),
|
|
39244
|
+
waitForReset: values.wait_for_reset
|
|
39221
39245
|
},
|
|
39222
39246
|
fallbackOn: values.fallback_on,
|
|
39223
39247
|
refresh: {
|
|
@@ -45466,7 +45490,7 @@ var actions = Object.freeze([
|
|
|
45466
45490
|
group: "Accounts",
|
|
45467
45491
|
label: "Disconnect from the vault",
|
|
45468
45492
|
destructive: true,
|
|
45469
|
-
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.",
|
|
45470
45494
|
interactive: true,
|
|
45471
45495
|
headlessRefusal: "interactive-required",
|
|
45472
45496
|
parameters: []
|
|
@@ -46107,12 +46131,7 @@ function plan(actions2, rawRequest, rawContext) {
|
|
|
46107
46131
|
options
|
|
46108
46132
|
};
|
|
46109
46133
|
}
|
|
46110
|
-
var DISCONNECT_RESULTS = new Set([
|
|
46111
|
-
"disconnected",
|
|
46112
|
-
"idle",
|
|
46113
|
-
"busy",
|
|
46114
|
-
"conflict"
|
|
46115
|
-
]);
|
|
46134
|
+
var DISCONNECT_RESULTS = new Set(["disconnected", "idle", "busy"]);
|
|
46116
46135
|
function readOutcome(action, outcome) {
|
|
46117
46136
|
const fields3 = readPlain(outcome, ["ok", "text"]);
|
|
46118
46137
|
const ok = fields3 instanceof Map ? fields3.get("ok") : undefined;
|
|
@@ -46144,11 +46163,7 @@ function disconnectFailureCode(error) {
|
|
|
46144
46163
|
case "unsafe-path":
|
|
46145
46164
|
return "disconnect-unsafe-file";
|
|
46146
46165
|
case "invalid-auth":
|
|
46147
|
-
case "invalid-stash":
|
|
46148
|
-
case "missing-stash":
|
|
46149
46166
|
return "disconnect-pi-recovery";
|
|
46150
|
-
case "conflict":
|
|
46151
|
-
return "disconnect-conflict";
|
|
46152
46167
|
case "lock-timeout":
|
|
46153
46168
|
case "lock-compromised":
|
|
46154
46169
|
return "disconnect-busy";
|
|
@@ -47022,18 +47037,12 @@ var DISCONNECT_OUTCOMES = {
|
|
|
47022
47037
|
ok: false,
|
|
47023
47038
|
code: "busy",
|
|
47024
47039
|
text: "Vault disconnect could not finish because another process is changing this host's enrollment. Try again."
|
|
47025
|
-
},
|
|
47026
|
-
conflict: {
|
|
47027
|
-
ok: false,
|
|
47028
|
-
code: "conflict",
|
|
47029
|
-
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."
|
|
47030
47040
|
}
|
|
47031
47041
|
};
|
|
47032
47042
|
var DISCONNECT_FAILURES = {
|
|
47033
47043
|
"disconnect-unsafe-file": "Check file ownership, private permissions, and safe storage. Then try Disconnect again. Do not delete enrollment files by hand.",
|
|
47034
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.",
|
|
47035
|
-
"disconnect-pi-recovery": "Repair
|
|
47036
|
-
"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.",
|
|
47037
47046
|
"disconnect-busy": "Stop other setup or disconnect attempts. Then try Disconnect again.",
|
|
47038
47047
|
"disconnect-io": "Check file access and free disk space. Then try Disconnect again.",
|
|
47039
47048
|
"execution-failed": "Check this host’s vault connection and file access. Then try Disconnect again.",
|
|
@@ -47055,6 +47064,11 @@ ${result.instructions.join(`
|
|
|
47055
47064
|
`)}`
|
|
47056
47065
|
};
|
|
47057
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
|
+
};
|
|
47058
47072
|
return DISCONNECT_OUTCOMES[result.result];
|
|
47059
47073
|
case "failed":
|
|
47060
47074
|
if (result.action === "vault-disconnect")
|
|
@@ -47357,7 +47371,6 @@ function placeholderSecret(integrationID) {
|
|
|
47357
47371
|
return `${PLACEHOLDER_PREFIX}.${integrationID}`;
|
|
47358
47372
|
}
|
|
47359
47373
|
// ../../node_modules/@cortexkit/common-auth/dist/pi-slot/slot.js
|
|
47360
|
-
import { createHash as createHash26 } from "node:crypto";
|
|
47361
47374
|
import { constants as constants5 } from "node:fs";
|
|
47362
47375
|
import { lstat as lstat21, mkdir as mkdir17, open as open14, unlink as unlink11 } from "node:fs/promises";
|
|
47363
47376
|
import { dirname as dirname24, resolve as resolve23 } from "node:path";
|
|
@@ -47627,28 +47640,17 @@ function rootSpans(text6) {
|
|
|
47627
47640
|
function object4(value) {
|
|
47628
47641
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47629
47642
|
}
|
|
47630
|
-
function canonical2(value) {
|
|
47631
|
-
if (Array.isArray(value))
|
|
47632
|
-
return `[${value.map(canonical2).join(",")}]`;
|
|
47633
|
-
if (object4(value)) {
|
|
47634
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical2(value[key])}`).join(",")}}`;
|
|
47635
|
-
}
|
|
47636
|
-
return JSON.stringify(value);
|
|
47637
|
-
}
|
|
47638
|
-
function digest2(value) {
|
|
47639
|
-
return createHash26("sha256").update(canonical2(value)).digest("hex");
|
|
47640
|
-
}
|
|
47641
47643
|
function code(error) {
|
|
47642
47644
|
return object4(error) ? error.code : undefined;
|
|
47643
47645
|
}
|
|
47644
|
-
async function safeRead(path2,
|
|
47646
|
+
async function safeRead(path2, afterReadCheck) {
|
|
47645
47647
|
if (windowsPrivateFiles) {
|
|
47646
47648
|
try {
|
|
47647
47649
|
await afterReadCheck?.(path2);
|
|
47648
47650
|
const bytes = await readPrivateBuffer(path2, true);
|
|
47649
47651
|
const text6 = bytes.toString("utf8");
|
|
47650
47652
|
if (!bytes.equals(Buffer.from(text6)))
|
|
47651
|
-
throw new PiSlotError(
|
|
47653
|
+
throw new PiSlotError("invalid-auth");
|
|
47652
47654
|
return text6;
|
|
47653
47655
|
} catch (error) {
|
|
47654
47656
|
if (code(error) === "ENOENT")
|
|
@@ -47660,7 +47662,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
47660
47662
|
try {
|
|
47661
47663
|
file = await open14(path2, constants5.O_RDONLY | constants5.O_NOFOLLOW);
|
|
47662
47664
|
const stat14 = await file.stat();
|
|
47663
|
-
if (!stat14.isFile()
|
|
47665
|
+
if (!stat14.isFile()) {
|
|
47664
47666
|
throw new PiSlotError("unsafe-path");
|
|
47665
47667
|
}
|
|
47666
47668
|
await afterReadCheck?.(path2);
|
|
@@ -47671,7 +47673,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
|
|
|
47671
47673
|
const bytes = await file.readFile();
|
|
47672
47674
|
const text6 = bytes.toString("utf8");
|
|
47673
47675
|
if (!bytes.equals(Buffer.from(text6))) {
|
|
47674
|
-
throw new PiSlotError(
|
|
47676
|
+
throw new PiSlotError("invalid-auth");
|
|
47675
47677
|
}
|
|
47676
47678
|
return text6;
|
|
47677
47679
|
} catch (error) {
|
|
@@ -47706,10 +47708,6 @@ function parseAuth(text6, provider) {
|
|
|
47706
47708
|
throw new PiSlotError("invalid-auth");
|
|
47707
47709
|
}
|
|
47708
47710
|
}
|
|
47709
|
-
function entryText(auth) {
|
|
47710
|
-
const value = auth.property?.value;
|
|
47711
|
-
return value ? auth.text.slice(value.offset, value.offset + value.length) : null;
|
|
47712
|
-
}
|
|
47713
47711
|
function replaceEntry(auth, provider, next) {
|
|
47714
47712
|
const { text: text6, root, property } = auth;
|
|
47715
47713
|
const properties = root.children ?? [];
|
|
@@ -47768,24 +47766,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47768
47766
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
47769
47767
|
throw new PiSlotError("invalid-options");
|
|
47770
47768
|
}
|
|
47771
|
-
const authIdentity = digest2(authPath);
|
|
47772
|
-
const placeholderIdentity = digest2(placeholderKey);
|
|
47773
47769
|
const placeholder = { type: "api_key", key: placeholderKey };
|
|
47774
|
-
const isPlaceholder = (entry2) =>
|
|
47775
|
-
async function loadStash() {
|
|
47776
|
-
const text6 = await safeRead(stashPath, true, hooks?.afterReadCheck);
|
|
47777
|
-
if (text6 === undefined)
|
|
47778
|
-
return;
|
|
47779
|
-
try {
|
|
47780
|
-
const stash = JSON.parse(text6);
|
|
47781
|
-
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)) {
|
|
47782
|
-
throw new Error;
|
|
47783
|
-
}
|
|
47784
|
-
return stash;
|
|
47785
|
-
} catch {
|
|
47786
|
-
throw new PiSlotError("invalid-stash");
|
|
47787
|
-
}
|
|
47788
|
-
}
|
|
47770
|
+
const isPlaceholder = (entry2) => entry2 !== null && Object.keys(entry2).length === 2 && entry2.type === placeholder.type && entry2.key === placeholder.key;
|
|
47789
47771
|
async function locked(fn) {
|
|
47790
47772
|
let release2;
|
|
47791
47773
|
let assertFresh;
|
|
@@ -47832,11 +47814,25 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47832
47814
|
}
|
|
47833
47815
|
}
|
|
47834
47816
|
async function load() {
|
|
47835
|
-
|
|
47836
|
-
const stash = await loadStash();
|
|
47837
|
-
return { auth, stash };
|
|
47817
|
+
return parseAuth(await safeRead(authPath, hooks?.afterReadCheck) ?? "{}", provider);
|
|
47838
47818
|
}
|
|
47839
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
|
+
}
|
|
47840
47836
|
assertLock();
|
|
47841
47837
|
await unlink11(stashPath);
|
|
47842
47838
|
await syncDir(dirname24(stashPath));
|
|
@@ -47844,58 +47840,27 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
47844
47840
|
}
|
|
47845
47841
|
return {
|
|
47846
47842
|
inspect: () => locked(async () => {
|
|
47847
|
-
const
|
|
47848
|
-
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" :
|
|
47849
|
-
return { slot
|
|
47843
|
+
const auth = await load();
|
|
47844
|
+
const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" : "original";
|
|
47845
|
+
return { slot };
|
|
47850
47846
|
}),
|
|
47851
47847
|
enterVault: () => locked(async (assertLock) => {
|
|
47852
|
-
const
|
|
47853
|
-
if (isPlaceholder(auth.entry)) {
|
|
47854
|
-
|
|
47855
|
-
|
|
47856
|
-
return;
|
|
47857
|
-
}
|
|
47858
|
-
if (stash && digest2(auth.entry) !== stash.sha256)
|
|
47859
|
-
throw new PiSlotError("conflict");
|
|
47860
|
-
if (!stash) {
|
|
47861
|
-
if (windowsPrivateFiles)
|
|
47862
|
-
await ensurePrivateDirectory(dirname24(stashPath));
|
|
47863
|
-
else {
|
|
47864
|
-
await mkdir17(dirname24(stashPath), { recursive: true, mode: 448 });
|
|
47865
|
-
const dir = await lstat21(dirname24(stashPath));
|
|
47866
|
-
if (!dir.isDirectory() || (dir.mode & 511) !== 448)
|
|
47867
|
-
throw new PiSlotError("unsafe-path");
|
|
47868
|
-
}
|
|
47869
|
-
const saved = {
|
|
47870
|
-
version: 1,
|
|
47871
|
-
provider,
|
|
47872
|
-
authIdentity,
|
|
47873
|
-
placeholderIdentity,
|
|
47874
|
-
entry: auth.entry,
|
|
47875
|
-
entryJson: entryText(auth),
|
|
47876
|
-
sha256: digest2(auth.entry)
|
|
47877
|
-
};
|
|
47878
|
-
await atomicWrite(stashPath, JSON.stringify(saved), assertLock, hooks?.beforeRename);
|
|
47879
|
-
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");
|
|
47880
47852
|
}
|
|
47881
|
-
await
|
|
47882
|
-
onStep?.("auth-written");
|
|
47853
|
+
await deleteStash(assertLock);
|
|
47883
47854
|
}),
|
|
47884
47855
|
exitVault: () => locked(async (assertLock) => {
|
|
47885
|
-
const
|
|
47886
|
-
|
|
47887
|
-
|
|
47888
|
-
|
|
47889
|
-
return "nothing-to-do";
|
|
47890
|
-
}
|
|
47891
|
-
if (isPlaceholder(auth.entry)) {
|
|
47892
|
-
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);
|
|
47893
47860
|
onStep?.("auth-written");
|
|
47894
|
-
} else if (digest2(auth.entry) !== stash.sha256) {
|
|
47895
|
-
return "conflict";
|
|
47896
47861
|
}
|
|
47897
47862
|
await deleteStash(assertLock);
|
|
47898
|
-
return "
|
|
47863
|
+
return cleared ? "cleared" : "nothing-to-do";
|
|
47899
47864
|
})
|
|
47900
47865
|
};
|
|
47901
47866
|
}
|
|
@@ -47914,8 +47879,8 @@ function openNativePiAuthSlot(options) {
|
|
|
47914
47879
|
async function disconnectNativeVaultForHost(options) {
|
|
47915
47880
|
if (isVaultHosted())
|
|
47916
47881
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL);
|
|
47917
|
-
if (options.host === "pi"
|
|
47918
|
-
|
|
47882
|
+
if (options.host === "pi")
|
|
47883
|
+
await options.slot.exitVault();
|
|
47919
47884
|
const paths2 = getHostClaustrumEnrollmentPaths(options.host, options.env);
|
|
47920
47885
|
const result = await disconnectClaustrumEnrollment(paths2, `anthropic-auth-${options.host}`);
|
|
47921
47886
|
if (result === "disconnected" || result === "idle")
|
|
@@ -47957,7 +47922,8 @@ function createNativeVaultNoRouteResponse(input) {
|
|
|
47957
47922
|
routeAccountIds: active2.filter((account) => account.quota).map((account) => account.id),
|
|
47958
47923
|
storage: snapshot.policyStorage,
|
|
47959
47924
|
sessionId: input.sessionId,
|
|
47960
|
-
vaultPolicyLimits: [...limits]
|
|
47925
|
+
vaultPolicyLimits: [...limits],
|
|
47926
|
+
waitForReset: input.waitForReset && active2.every((account) => account.quota)
|
|
47961
47927
|
});
|
|
47962
47928
|
}
|
|
47963
47929
|
|
|
@@ -48070,7 +48036,7 @@ function requestMethod(input) {
|
|
|
48070
48036
|
return input instanceof Request ? input.method : "GET";
|
|
48071
48037
|
}
|
|
48072
48038
|
// src/prime.ts
|
|
48073
|
-
import { createHash as
|
|
48039
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
48074
48040
|
import * as fs4 from "node:fs";
|
|
48075
48041
|
import { mkdir as mkdir18, readdir as readdir7, rm as rm10, stat as stat14, writeFile as writeFile6 } from "node:fs/promises";
|
|
48076
48042
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
@@ -48279,7 +48245,7 @@ function primeStorageFingerprint(storagePath) {
|
|
|
48279
48245
|
throw error;
|
|
48280
48246
|
canonicalPath3 = absolutePath;
|
|
48281
48247
|
}
|
|
48282
|
-
return
|
|
48248
|
+
return createHash26("sha256").update(canonicalPath3).digest("hex").slice(0, 12);
|
|
48283
48249
|
}
|
|
48284
48250
|
function primeMarkerNamespaceDir(markerDir, storagePath) {
|
|
48285
48251
|
return join30(markerDir, primeStorageFingerprint(storagePath));
|
|
@@ -48602,8 +48568,8 @@ class PrimeManager {
|
|
|
48602
48568
|
return [markerPath];
|
|
48603
48569
|
const verifiedPath = this.verifiedMarkerPath(accountIdentity, resetsAtEpochMs);
|
|
48604
48570
|
if (resetsAtEpochMs === undefined) {
|
|
48605
|
-
const
|
|
48606
|
-
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}-`)))
|
|
48607
48573
|
return null;
|
|
48608
48574
|
}
|
|
48609
48575
|
if (!await this.tryClaimPath(this.verifiedMarkerDir(), verifiedPath))
|
|
@@ -48614,8 +48580,8 @@ class PrimeManager {
|
|
|
48614
48580
|
return join30(this.options.markerDir ?? defaultMarkerDir(), "accounts");
|
|
48615
48581
|
}
|
|
48616
48582
|
verifiedMarkerPath(accountIdentity, resetsAtEpochMs) {
|
|
48617
|
-
const
|
|
48618
|
-
return join30(this.verifiedMarkerDir(), `${
|
|
48583
|
+
const digest2 = createHash26("sha256").update(accountIdentity).digest("hex");
|
|
48584
|
+
return join30(this.verifiedMarkerDir(), `${digest2}-${resetsAtEpochMs ?? "bootstrap"}`);
|
|
48619
48585
|
}
|
|
48620
48586
|
async readMarkerNames(dir) {
|
|
48621
48587
|
try {
|
|
@@ -51390,12 +51356,12 @@ function expectRecord(sub, want) {
|
|
|
51390
51356
|
}
|
|
51391
51357
|
function expectDigest(path2, sha256) {
|
|
51392
51358
|
return async () => {
|
|
51393
|
-
const
|
|
51359
|
+
const digest2 = await digestFile(path2);
|
|
51394
51360
|
if (sha256 === null)
|
|
51395
|
-
return
|
|
51396
|
-
if (
|
|
51361
|
+
return digest2.status === "absent" ? undefined : "it exists";
|
|
51362
|
+
if (digest2.status === "file" && digest2.sha256 === sha256)
|
|
51397
51363
|
return;
|
|
51398
|
-
return
|
|
51364
|
+
return digest2.status === "absent" ? "it is missing" : "its bytes changed";
|
|
51399
51365
|
};
|
|
51400
51366
|
}
|
|
51401
51367
|
function expectTombstone(path2, attempt) {
|
|
@@ -51465,8 +51431,8 @@ async function rollbackPreparing(record17, dataset, ctx) {
|
|
|
51465
51431
|
await removeOwnStaging(relocatingPath(file.to, attempt));
|
|
51466
51432
|
if (file.sha256 === null)
|
|
51467
51433
|
continue;
|
|
51468
|
-
const
|
|
51469
|
-
if (
|
|
51434
|
+
const digest2 = await digestFile(file.to);
|
|
51435
|
+
if (digest2.status !== "file" || digest2.sha256 !== file.sha256)
|
|
51470
51436
|
continue;
|
|
51471
51437
|
if (!await exists5(file.from))
|
|
51472
51438
|
continue;
|
|
@@ -51531,14 +51497,14 @@ async function cleanupOldCopies(record17, dataset, ctx) {
|
|
|
51531
51497
|
const path2 = role === "journal" ? movingJournalPath(file.from, record17.attempt) : file.from;
|
|
51532
51498
|
await ctx.stack.assertAll();
|
|
51533
51499
|
const credential2 = CREDENTIAL_AUTHORITY_ROLES.includes(role);
|
|
51534
|
-
let
|
|
51500
|
+
let digest2;
|
|
51535
51501
|
try {
|
|
51536
|
-
|
|
51502
|
+
digest2 = await digestFile(path2);
|
|
51537
51503
|
} catch (error) {
|
|
51538
51504
|
if (!credential2)
|
|
51539
51505
|
throw error;
|
|
51540
51506
|
}
|
|
51541
|
-
if (
|
|
51507
|
+
if (digest2?.status === "absent") {} else if (digest2 !== undefined && file.sha256 !== null && digest2.sha256 === file.sha256) {
|
|
51542
51508
|
await owned2(ctx, { kind: "unlink", path: path2 }, expectDigest(path2, file.sha256));
|
|
51543
51509
|
} else if (credential2) {
|
|
51544
51510
|
conflict.push({ old: path2, new: file.to });
|
|
@@ -51835,9 +51801,9 @@ async function finishRestoreRetirement(record17, dataset, ctx) {
|
|
|
51835
51801
|
const kept = [...record17.restore?.kept ?? []];
|
|
51836
51802
|
for (const file of restore.files) {
|
|
51837
51803
|
try {
|
|
51838
|
-
const
|
|
51839
|
-
if (
|
|
51840
|
-
if (
|
|
51804
|
+
const digest2 = await digestFile(file.to);
|
|
51805
|
+
if (digest2.status === "file") {
|
|
51806
|
+
if (digest2.sha256 === file.sha256)
|
|
51841
51807
|
await owned2(ctx, { kind: "unlink", path: file.to }, expectDigest(file.to, file.sha256));
|
|
51842
51808
|
else
|
|
51843
51809
|
throw new Error("its bytes changed after they were restored");
|
|
@@ -52054,19 +52020,19 @@ async function startRestore(record17, dataset, ctx, options) {
|
|
|
52054
52020
|
const attempt = randomUUID28();
|
|
52055
52021
|
const files = [];
|
|
52056
52022
|
for (const slot of dataset.slots) {
|
|
52057
|
-
let
|
|
52023
|
+
let digest2;
|
|
52058
52024
|
try {
|
|
52059
|
-
|
|
52025
|
+
digest2 = await digestFile(slot.to);
|
|
52060
52026
|
} catch (error) {
|
|
52061
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);
|
|
52062
52028
|
}
|
|
52063
|
-
if (
|
|
52029
|
+
if (digest2.status !== "file")
|
|
52064
52030
|
continue;
|
|
52065
52031
|
files.push({
|
|
52066
52032
|
role: slot.role,
|
|
52067
52033
|
from: slot.from,
|
|
52068
52034
|
to: slot.to,
|
|
52069
|
-
sha256:
|
|
52035
|
+
sha256: digest2.sha256,
|
|
52070
52036
|
staging: restoreStagingPath(slot.from, attempt)
|
|
52071
52037
|
});
|
|
52072
52038
|
}
|
|
@@ -53172,6 +53138,7 @@ export {
|
|
|
53172
53138
|
resolveClaudeModelCapabilities,
|
|
53173
53139
|
resolveClaudeCodeIdentity,
|
|
53174
53140
|
resolveClaudeCodeAccountIdentity,
|
|
53141
|
+
resetWaitDelayMs,
|
|
53175
53142
|
resetVaultHostAuthorityForTests,
|
|
53176
53143
|
resetStateLayoutDecisionsForTests,
|
|
53177
53144
|
resetProcessStateLayoutsForTests,
|
|
@@ -53327,6 +53294,7 @@ export {
|
|
|
53327
53294
|
mergeHeaderQuotaForPersistence,
|
|
53328
53295
|
mergeAnthropicBetas,
|
|
53329
53296
|
markSettingsImportPending,
|
|
53297
|
+
markResetWaitResponse,
|
|
53330
53298
|
mapSettingsMoveSources,
|
|
53331
53299
|
malformedSettingsText,
|
|
53332
53300
|
lookupGatewaySettingsFile,
|
|
@@ -53412,6 +53380,7 @@ export {
|
|
|
53412
53380
|
hasPrivateSettingsConfigHome,
|
|
53413
53381
|
hasNoLocalCredential,
|
|
53414
53382
|
guardAnthropicStreamResponse,
|
|
53383
|
+
getWaitForReset,
|
|
53415
53384
|
getThinkingPrefixMismatchBehavior,
|
|
53416
53385
|
getStickyRoutingStatePath,
|
|
53417
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>;
|
|
@@ -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;
|
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
|
{
|