@cortexkit/anthropic-auth-core 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1486,6 +1486,9 @@ async function syncJsonFile(path) {
|
|
|
1486
1486
|
// ../../node_modules/@cortexkit/common-auth/dist/fs/canonical-file-path.js
|
|
1487
1487
|
import { basename, dirname as dirname4, join as join2, resolve as resolve5 } from "node:path";
|
|
1488
1488
|
var maxSymlinkHops = 40;
|
|
1489
|
+
function symlinkLoop(file) {
|
|
1490
|
+
return Object.assign(new Error(`ELOOP: too many symbolic links encountered, realpath '${file}'`), { code: "ELOOP", syscall: "realpath", path: file });
|
|
1491
|
+
}
|
|
1489
1492
|
async function canonicalFilePath(file, fs) {
|
|
1490
1493
|
let target = file;
|
|
1491
1494
|
for (let hops = 0;; hops++) {
|
|
@@ -1501,7 +1504,7 @@ async function canonicalFilePath(file, fs) {
|
|
|
1501
1504
|
if (!isSymlink)
|
|
1502
1505
|
return target;
|
|
1503
1506
|
if (hops >= maxSymlinkHops)
|
|
1504
|
-
throw
|
|
1507
|
+
throw symlinkLoop(file);
|
|
1505
1508
|
target = resolve5(dirname4(target), await fs.readlink(target));
|
|
1506
1509
|
}
|
|
1507
1510
|
}
|
|
@@ -1520,7 +1523,7 @@ function canonicalFilePathSync(file, fs) {
|
|
|
1520
1523
|
if (!isSymlink)
|
|
1521
1524
|
return target;
|
|
1522
1525
|
if (hops >= maxSymlinkHops)
|
|
1523
|
-
throw
|
|
1526
|
+
throw symlinkLoop(file);
|
|
1524
1527
|
target = resolve5(dirname4(target), fs.readlinkSync(target));
|
|
1525
1528
|
}
|
|
1526
1529
|
}
|
|
@@ -19831,28 +19834,40 @@ function applySessionCacheTtl(body, ttl) {
|
|
|
19831
19834
|
delete control.ttl;
|
|
19832
19835
|
});
|
|
19833
19836
|
}
|
|
19834
|
-
function
|
|
19837
|
+
function visitRequestCacheLifetimes(input, visit) {
|
|
19835
19838
|
let body = input;
|
|
19836
19839
|
if (typeof input === "string") {
|
|
19837
19840
|
try {
|
|
19838
19841
|
body = JSON.parse(input);
|
|
19839
19842
|
} catch {
|
|
19840
|
-
return
|
|
19843
|
+
return;
|
|
19841
19844
|
}
|
|
19842
19845
|
}
|
|
19843
19846
|
if (!record5(body))
|
|
19844
|
-
return
|
|
19845
|
-
let ttlMs = 0;
|
|
19847
|
+
return;
|
|
19846
19848
|
cacheHolders(body, (holder) => {
|
|
19847
19849
|
for (const key of ["cache_control", "cacheControl"]) {
|
|
19848
19850
|
const control = holder[key];
|
|
19849
19851
|
if (!record5(control) || control.type !== "ephemeral")
|
|
19850
19852
|
continue;
|
|
19851
|
-
|
|
19853
|
+
visit(control.ttl === "1h" ? PROMPT_CACHE_1H_TTL_MS : PROMPT_CACHE_DEFAULT_TTL_MS);
|
|
19852
19854
|
}
|
|
19853
19855
|
});
|
|
19856
|
+
}
|
|
19857
|
+
function requestCacheLifetimeMs(input) {
|
|
19858
|
+
let ttlMs = 0;
|
|
19859
|
+
visitRequestCacheLifetimes(input, (lifetime) => {
|
|
19860
|
+
ttlMs = Math.max(ttlMs, lifetime);
|
|
19861
|
+
});
|
|
19854
19862
|
return ttlMs;
|
|
19855
19863
|
}
|
|
19864
|
+
function requestShortestCacheLifetimeMs(input) {
|
|
19865
|
+
let ttlMs = Infinity;
|
|
19866
|
+
visitRequestCacheLifetimes(input, (lifetime) => {
|
|
19867
|
+
ttlMs = Math.min(ttlMs, lifetime);
|
|
19868
|
+
});
|
|
19869
|
+
return ttlMs === Infinity ? 0 : ttlMs;
|
|
19870
|
+
}
|
|
19856
19871
|
|
|
19857
19872
|
// src/cachekeep.ts
|
|
19858
19873
|
var CLAUDE_CACHE_KEEP_COMMAND_NAME = "claude-cachekeep";
|
|
@@ -24517,14 +24532,17 @@ function settingsRefusal(message) {
|
|
|
24517
24532
|
});
|
|
24518
24533
|
}
|
|
24519
24534
|
var settingsCache = new FileReadCache;
|
|
24520
|
-
|
|
24521
|
-
|
|
24522
|
-
|
|
24535
|
+
function readPoolSettings(rt) {
|
|
24536
|
+
return readPoolSettingsAt(rt.ctx.configPath);
|
|
24537
|
+
}
|
|
24538
|
+
async function readPoolSettingsAt(configPath) {
|
|
24539
|
+
const read = async ([path2 = configPath] = []) => {
|
|
24540
|
+
const result2 = await readPoolConfig(path2);
|
|
24523
24541
|
if (result2.status === "error")
|
|
24524
24542
|
return { status: "error", file: "config", reason: result2.reason };
|
|
24525
24543
|
return { status: result2.status, settings: settingsOf(result2.config) };
|
|
24526
24544
|
};
|
|
24527
|
-
const result = windowsPrivateFiles ? await read() : await settingsCache.read([
|
|
24545
|
+
const result = windowsPrivateFiles ? await read() : await settingsCache.read([configPath], read);
|
|
24528
24546
|
return structuredClone(result);
|
|
24529
24547
|
}
|
|
24530
24548
|
async function updatePoolSettings(rt, mutator, options = {}) {
|
|
@@ -25379,20 +25397,6 @@ async function drainNativePoolStores(statePaths) {
|
|
|
25379
25397
|
function createNativePoolStore(options) {
|
|
25380
25398
|
return trackStore(options.paths.state, openNativePoolStore(options));
|
|
25381
25399
|
}
|
|
25382
|
-
var exactSettingsReaders = new Map;
|
|
25383
|
-
function readNativePoolSettingsAt(configPath, quota) {
|
|
25384
|
-
let reader = exactSettingsReaders.get(configPath);
|
|
25385
|
-
if (!reader) {
|
|
25386
|
-
reader = openPoolStore({
|
|
25387
|
-
provider: "anthropic",
|
|
25388
|
-
configPath,
|
|
25389
|
-
statePath: configPath,
|
|
25390
|
-
quota
|
|
25391
|
-
});
|
|
25392
|
-
exactSettingsReaders.set(configPath, reader);
|
|
25393
|
-
}
|
|
25394
|
-
return reader.readSettings();
|
|
25395
|
-
}
|
|
25396
25400
|
function openNativePoolStore(options) {
|
|
25397
25401
|
const store = openPoolStore({
|
|
25398
25402
|
provider: "anthropic",
|
|
@@ -41931,7 +41935,7 @@ function buildNativeAccountRuntime(options, env, runtimeSettings) {
|
|
|
41931
41935
|
async getRelayConfig() {
|
|
41932
41936
|
const { mode, paths: paths3, store: store2 } = await selectedStorage();
|
|
41933
41937
|
const { location, files } = await relayLocation.resolve(mode);
|
|
41934
|
-
const readSettings = files ? () =>
|
|
41938
|
+
const readSettings = files ? () => readPoolSettingsAt(files.config) : () => store2.readSettings();
|
|
41935
41939
|
const runtimeFile = files ? files.runtime : paths3.runtime;
|
|
41936
41940
|
for (let attempt = 0;attempt < 4; attempt++) {
|
|
41937
41941
|
if (attempt)
|
|
@@ -52354,6 +52358,7 @@ export {
|
|
|
52354
52358
|
requireNoSupervisedAuthContentSnapshot,
|
|
52355
52359
|
requireAnthropicOAuthOrigin,
|
|
52356
52360
|
requestSignal,
|
|
52361
|
+
requestShortestCacheLifetimeMs,
|
|
52357
52362
|
requestGzipPadding,
|
|
52358
52363
|
requestCacheLifetimeMs,
|
|
52359
52364
|
reportSessionCacheWarmStopped,
|
|
@@ -52387,7 +52392,6 @@ export {
|
|
|
52387
52392
|
readRelocationPointer,
|
|
52388
52393
|
readPeerLegacySettingsProtection,
|
|
52389
52394
|
readOwnLegacySettingsProtection,
|
|
52390
|
-
readNativePoolSettingsAt,
|
|
52391
52395
|
readNativeMigrationJournal,
|
|
52392
52396
|
readNativeHostAuthKind,
|
|
52393
52397
|
readNativeEnrollmentMode,
|
|
@@ -19,4 +19,4 @@ export type { PullReason } from './runtime.js';
|
|
|
19
19
|
export type { ApiKeyCredential, CredentialStampStatus, OAuthCredential, PoolCredential, PoolRow, ProviderStateCodec, ProviderStateDrop, ProviderStateReplacement, QuotaCodec, RotateCredential, StoredCredential, } from './schema.js';
|
|
20
20
|
export { fingerprintOf, LEGACY_STORE_VERSION, POOL_KEY, POOL_ROWS_KEY, POOL_SCHEMA_VERSION, PROVIDER_STATE_KEY, REFRESH_STAMP_TOLERANCE_MS, rowLockKey, } from './schema.js';
|
|
21
21
|
export type { PoolSettings, SettingsMutator, SettingsRead, UpdateSettingsOptions, UpdateSettingsResult, } from './settings.js';
|
|
22
|
-
export { POOL_OWNED_KEYS } from './settings.js';
|
|
22
|
+
export { POOL_OWNED_KEYS, readPoolSettingsAt } from './settings.js';
|
|
@@ -52,6 +52,14 @@ export type UpdateSettingsResult = {
|
|
|
52
52
|
};
|
|
53
53
|
/** Reads only the config's settings, without taking a lock or writing anything. */
|
|
54
54
|
export declare function readPoolSettings(rt: StoreRuntime): Promise<SettingsRead>;
|
|
55
|
+
/**
|
|
56
|
+
* Reads the settings of the pool config at `configPath`, exactly as a store's
|
|
57
|
+
* `readSettings()` does, without opening a store. It reads only that file: no
|
|
58
|
+
* state file, lock, write or migration. A plugin that has already resolved
|
|
59
|
+
* which config file to trust (for example, after a location check) reads it
|
|
60
|
+
* here rather than opening a second store on it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function readPoolSettingsAt(configPath: string): Promise<SettingsRead>;
|
|
55
63
|
/**
|
|
56
64
|
* One locked read-modify-write of the plugin's settings in the config file
|
|
57
65
|
* the pool lives in. The pool must be ready (a pending migration or a load
|
package/dist/pool-store.d.ts
CHANGED
|
@@ -38,10 +38,3 @@ export declare function drainNativePoolStores(statePaths: readonly string[]): Pr
|
|
|
38
38
|
* authority or vault enrollment authority before using these files.
|
|
39
39
|
*/
|
|
40
40
|
export declare function createNativePoolStore(options: NativePoolStoreOptions): import("./internal-types/store/index.js").PoolStore;
|
|
41
|
-
/**
|
|
42
|
-
* Reads the plugin settings from exactly the config file at `configPath`, for
|
|
43
|
-
* a caller that resolved that file itself and must not read through another
|
|
44
|
-
* path's text. Nothing is ever written or locked through the store opened for
|
|
45
|
-
* it, so its state path is never used and is set to the config path.
|
|
46
|
-
*/
|
|
47
|
-
export declare function readNativePoolSettingsAt(configPath: string, quota: NativeQuotaCodec): Promise<import("./internal-types/store/index.js").SettingsRead>;
|
|
@@ -17,5 +17,11 @@ export declare function reportSessionCacheTouch(sessionId: string, input: CacheT
|
|
|
17
17
|
export declare function reportSessionCacheWarmStopped(sessionId: string, input: CacheWarmStoppedInput): boolean;
|
|
18
18
|
/** Apply only a lifetime override; the host still chooses breakpoint placement. */
|
|
19
19
|
export declare function applySessionCacheTtl(body: Record<string, unknown>, ttl: SessionCacheTtl | undefined): void;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Cache-touch reports and our local activity, hold and keep-warm timing use the
|
|
22
|
+
* longest sent lifetime: the cache is fully cold only after every prefix expires.
|
|
23
|
+
* Billing reports use requestShortestCacheLifetimeMs instead.
|
|
24
|
+
*/
|
|
21
25
|
export declare function requestCacheLifetimeMs(input: Record<string, unknown> | string): number;
|
|
26
|
+
/** Billing reports use the shortest sent lifetime among the cache breakpoints. */
|
|
27
|
+
export declare function requestShortestCacheLifetimeMs(input: Record<string, unknown> | string): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.1",
|
|
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.50.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cortexkit/claustrum-client": "0.18.0",
|