@cortexkit/anthropic-auth-core 2.5.6 → 2.5.8
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.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export * from './request-abort.ts';
|
|
|
97
97
|
export * from './request-gzip.ts';
|
|
98
98
|
export * from './request-history.ts';
|
|
99
99
|
export * from './routing.ts';
|
|
100
|
+
export * from './server-fallback-usage.ts';
|
|
100
101
|
export * from './session-cache-activity.ts';
|
|
101
102
|
export type { SseEvent, SseFramer, SseFramerOptions } from './sse.ts';
|
|
102
103
|
export { createSseFramer, DEFAULT_SSE_MAX_FRAME_BYTES, decodeSseFrame, isSseCandidateFrame, isTerminatedSseFrame, parseSseFrame, SseFrameTooLargeError, } from './sse.ts';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,39 @@ function routingHandle(sessionId) {
|
|
|
14
14
|
function isObject(value) {
|
|
15
15
|
return typeof value === "object" && value !== null;
|
|
16
16
|
}
|
|
17
|
+
function turnNotes(sessionId) {
|
|
18
|
+
try {
|
|
19
|
+
const handle = routingHandle(sessionId);
|
|
20
|
+
if (!handle)
|
|
21
|
+
return [];
|
|
22
|
+
const read = handle.turn_notes;
|
|
23
|
+
if (typeof read !== "function")
|
|
24
|
+
return [];
|
|
25
|
+
const answer = read.call(handle);
|
|
26
|
+
if (isObject(answer) && typeof answer.then === "function") {
|
|
27
|
+
Promise.resolve(answer).catch(() => {});
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(answer))
|
|
31
|
+
return [];
|
|
32
|
+
const notes = [];
|
|
33
|
+
const encoder = new TextEncoder;
|
|
34
|
+
for (const entry of answer) {
|
|
35
|
+
try {
|
|
36
|
+
if (!isObject(entry) || Array.isArray(entry))
|
|
37
|
+
continue;
|
|
38
|
+
const afterToolUseId = entry.after_tool_use_id;
|
|
39
|
+
const text = entry.text;
|
|
40
|
+
if (typeof afterToolUseId !== "string" || afterToolUseId.length === 0 || typeof text !== "string" || text.trim().length === 0 || encoder.encode(text).byteLength > 16384)
|
|
41
|
+
continue;
|
|
42
|
+
notes.push({ afterToolUseId, text });
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
45
|
+
return notes;
|
|
46
|
+
} catch {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
17
50
|
function selectionFor(answer, candidates) {
|
|
18
51
|
if (!isObject(answer))
|
|
19
52
|
return;
|
|
@@ -76,32 +109,61 @@ function reportRouting(input) {
|
|
|
76
109
|
const report = handle.report;
|
|
77
110
|
if (typeof report !== "function")
|
|
78
111
|
return;
|
|
79
|
-
const identity = {
|
|
80
|
-
account_id: input.accountId,
|
|
81
|
-
...input.credentialId !== undefined ? { credential_id: input.credentialId } : {}
|
|
82
|
-
};
|
|
83
112
|
let payload;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
if ("kind" in input) {
|
|
114
|
+
switch (input.kind) {
|
|
115
|
+
case "turn_notes_supported": {
|
|
116
|
+
const { model, supported } = input;
|
|
117
|
+
if (typeof model !== "string" || model.length === 0 || typeof supported !== "boolean")
|
|
118
|
+
return;
|
|
119
|
+
payload = {
|
|
120
|
+
kind: "turn_notes_supported",
|
|
121
|
+
model,
|
|
122
|
+
supported
|
|
123
|
+
};
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case "turn_note_skipped": {
|
|
127
|
+
const { after_tool_use_id, reason } = input;
|
|
128
|
+
if (typeof after_tool_use_id !== "string" || after_tool_use_id.length === 0 || reason !== "anchor_missing" && reason !== "before_user_message" && reason !== "unsupported_model" && reason !== "not_oauth")
|
|
129
|
+
return;
|
|
130
|
+
payload = {
|
|
131
|
+
kind: "turn_note_skipped",
|
|
132
|
+
after_tool_use_id,
|
|
133
|
+
reason
|
|
134
|
+
};
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
91
138
|
return;
|
|
92
|
-
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
const identity = {
|
|
142
|
+
account_id: input.accountId,
|
|
143
|
+
...input.credentialId !== undefined ? { credential_id: input.credentialId } : {}
|
|
144
|
+
};
|
|
145
|
+
switch (input.outcome) {
|
|
146
|
+
case "served":
|
|
147
|
+
payload = { ...identity, outcome: "served", headers: input.headers };
|
|
148
|
+
break;
|
|
149
|
+
case "exhausted": {
|
|
150
|
+
const { window, pool } = input;
|
|
151
|
+
if (window !== "5h" && window !== "7d")
|
|
152
|
+
return;
|
|
153
|
+
if (pool !== undefined && (typeof pool !== "string" || !/^[a-z0-9._-]{1,64}$/.test(pool)))
|
|
154
|
+
return;
|
|
155
|
+
payload = {
|
|
156
|
+
...identity,
|
|
157
|
+
outcome: "exhausted",
|
|
158
|
+
window,
|
|
159
|
+
...pool ? { pool } : {},
|
|
160
|
+
...input.resetsAt !== undefined ? { resets_at: input.resetsAt } : {}
|
|
161
|
+
};
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
93
165
|
return;
|
|
94
|
-
payload = {
|
|
95
|
-
...identity,
|
|
96
|
-
outcome: "exhausted",
|
|
97
|
-
window,
|
|
98
|
-
...pool ? { pool } : {},
|
|
99
|
-
...input.resetsAt !== undefined ? { resets_at: input.resetsAt } : {}
|
|
100
|
-
};
|
|
101
|
-
break;
|
|
102
166
|
}
|
|
103
|
-
default:
|
|
104
|
-
return;
|
|
105
167
|
}
|
|
106
168
|
const pending = report.call(handle, payload);
|
|
107
169
|
if (isObject(pending) && typeof pending.then === "function") {
|
|
@@ -802,7 +864,7 @@ var WRITER_LOCK_CONSTANTS = Object.freeze({
|
|
|
802
864
|
});
|
|
803
865
|
// ../../node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.js
|
|
804
866
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
805
|
-
import { lstat as lstat3, mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename3, rm as rm2, stat as stat2 } from "node:fs/promises";
|
|
867
|
+
import { link, lstat as lstat3, mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename3, rm as rm2, stat as stat2 } from "node:fs/promises";
|
|
806
868
|
import { dirname as dirname3, join as join3 } from "node:path";
|
|
807
869
|
|
|
808
870
|
// ../../node_modules/@cortexkit/common-auth/dist/fs/with-lock.js
|
|
@@ -878,7 +940,35 @@ async function withLock(target, options, fn) {
|
|
|
878
940
|
}
|
|
879
941
|
|
|
880
942
|
// ../../node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.js
|
|
943
|
+
var leaseCreationTestHooks;
|
|
881
944
|
async function createExclusiveText(path, text) {
|
|
945
|
+
const tempPath = `${path}.${randomUUID3()}.tmp`;
|
|
946
|
+
let handle;
|
|
947
|
+
try {
|
|
948
|
+
handle = await open2(tempPath, "wx", 384);
|
|
949
|
+
try {
|
|
950
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
951
|
+
await leaseCreationTestHooks.beforeWrite(tempPath);
|
|
952
|
+
await handle.writeFile(text, "utf8");
|
|
953
|
+
} finally {
|
|
954
|
+
await handle.close();
|
|
955
|
+
}
|
|
956
|
+
try {
|
|
957
|
+
if (leaseCreationTestHooks?.beforeLink)
|
|
958
|
+
await leaseCreationTestHooks.beforeLink(tempPath, path);
|
|
959
|
+
await link(tempPath, path);
|
|
960
|
+
} catch (error) {
|
|
961
|
+
const code = error.code;
|
|
962
|
+
if (code !== "EPERM" && code !== "ENOTSUP" && code !== "EOPNOTSUPP" && code !== "EXDEV")
|
|
963
|
+
throw error;
|
|
964
|
+
await writeExclusiveText(path, text);
|
|
965
|
+
}
|
|
966
|
+
} finally {
|
|
967
|
+
if (handle)
|
|
968
|
+
await rm2(tempPath, { force: true }).catch(() => {});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
async function writeExclusiveText(path, text) {
|
|
882
972
|
const handle = await open2(path, "wx", 384);
|
|
883
973
|
let createdStat;
|
|
884
974
|
try {
|
|
@@ -887,6 +977,8 @@ async function createExclusiveText(path, text) {
|
|
|
887
977
|
createdStat = undefined;
|
|
888
978
|
}
|
|
889
979
|
try {
|
|
980
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
981
|
+
await leaseCreationTestHooks.beforeWrite(path);
|
|
890
982
|
await handle.writeFile(text, "utf8");
|
|
891
983
|
} catch (error) {
|
|
892
984
|
try {
|
|
@@ -1257,7 +1349,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
1257
1349
|
if (windowsPrivateFiles)
|
|
1258
1350
|
await createPrivateBytes(evictOwnerPath, bytes);
|
|
1259
1351
|
else
|
|
1260
|
-
await
|
|
1352
|
+
await writeExclusiveText(evictOwnerPath, bytes);
|
|
1261
1353
|
} catch (error) {
|
|
1262
1354
|
const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
|
|
1263
1355
|
if (isLostMarkerRaceError(error) && !stillOurs)
|
|
@@ -14846,6 +14938,32 @@ function createProviderErrorResponseScope(secrets, mode) {
|
|
|
14846
14938
|
return Object.freeze(scope);
|
|
14847
14939
|
}
|
|
14848
14940
|
|
|
14941
|
+
// src/server-fallback-usage.ts
|
|
14942
|
+
var SERVER_FALLBACK_USAGE_MARKER_TEXT = "";
|
|
14943
|
+
var SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX = "cortexkit-server-fallback-usage-v1:";
|
|
14944
|
+
function isServerFallbackUsageMarker(value) {
|
|
14945
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
14946
|
+
return false;
|
|
14947
|
+
const block = value;
|
|
14948
|
+
return block.type === "thinking" && (block.thinking === SERVER_FALLBACK_USAGE_MARKER_TEXT || typeof block.signature === "string" && block.signature.startsWith(SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX));
|
|
14949
|
+
}
|
|
14950
|
+
function stripServerFallbackUsageMarkers(body) {
|
|
14951
|
+
let removed = 0;
|
|
14952
|
+
if (!Array.isArray(body.messages))
|
|
14953
|
+
return removed;
|
|
14954
|
+
for (const message of body.messages) {
|
|
14955
|
+
if (!message || !Array.isArray(message.content))
|
|
14956
|
+
continue;
|
|
14957
|
+
message.content = message.content.filter((block) => {
|
|
14958
|
+
if (!isServerFallbackUsageMarker(block))
|
|
14959
|
+
return true;
|
|
14960
|
+
removed++;
|
|
14961
|
+
return false;
|
|
14962
|
+
});
|
|
14963
|
+
}
|
|
14964
|
+
return removed;
|
|
14965
|
+
}
|
|
14966
|
+
|
|
14849
14967
|
// src/cachekeep.ts
|
|
14850
14968
|
var CLAUDE_CACHE_KEEP_COMMAND_NAME = "claude-cachekeep";
|
|
14851
14969
|
var CACHE_KEEP_TTL_MS = 60 * 60000;
|
|
@@ -15051,6 +15169,7 @@ async function buildCacheKeepPrewarmBody(bodyText, options = {}) {
|
|
|
15051
15169
|
return { ok: false, reason: "body has no explicit cache breakpoints" };
|
|
15052
15170
|
}
|
|
15053
15171
|
const warm = structuredClone(body);
|
|
15172
|
+
stripServerFallbackUsageMarkers(warm);
|
|
15054
15173
|
delete warm.thread;
|
|
15055
15174
|
stripBillingLineageFromBody(warm);
|
|
15056
15175
|
warm.max_tokens = 0;
|
|
@@ -15770,7 +15889,7 @@ class CacheKeepManager {
|
|
|
15770
15889
|
// src/cachekeep-registry.ts
|
|
15771
15890
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
15772
15891
|
import {
|
|
15773
|
-
link,
|
|
15892
|
+
link as link2,
|
|
15774
15893
|
lstat as lstat13,
|
|
15775
15894
|
mkdir as mkdir11,
|
|
15776
15895
|
readdir as readdir3,
|
|
@@ -24019,7 +24138,7 @@ class CacheKeepSessionRegistry {
|
|
|
24019
24138
|
}
|
|
24020
24139
|
async restoreSweptRecord(recordPath, sweptPath, raw) {
|
|
24021
24140
|
try {
|
|
24022
|
-
await
|
|
24141
|
+
await link2(sweptPath, recordPath);
|
|
24023
24142
|
} catch (error) {
|
|
24024
24143
|
const code = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
24025
24144
|
if (code === "EEXIST") {
|
|
@@ -25132,6 +25251,7 @@ class ReplyFingerprint {
|
|
|
25132
25251
|
normalizeToolName;
|
|
25133
25252
|
open = new Map;
|
|
25134
25253
|
seen = new Set;
|
|
25254
|
+
ignored = new Set;
|
|
25135
25255
|
tools = new Map;
|
|
25136
25256
|
layout = new Map;
|
|
25137
25257
|
textBlocks = new Map;
|
|
@@ -25179,6 +25299,10 @@ class ReplyFingerprint {
|
|
|
25179
25299
|
return;
|
|
25180
25300
|
}
|
|
25181
25301
|
this.seen.add(index);
|
|
25302
|
+
if (isServerFallbackUsageMarker(block)) {
|
|
25303
|
+
this.ignored.add(index);
|
|
25304
|
+
return;
|
|
25305
|
+
}
|
|
25182
25306
|
const state = {
|
|
25183
25307
|
type: block.type,
|
|
25184
25308
|
signatureLength: 0,
|
|
@@ -25215,6 +25339,8 @@ class ReplyFingerprint {
|
|
|
25215
25339
|
this.open.set(index, state);
|
|
25216
25340
|
}
|
|
25217
25341
|
delta(index, delta) {
|
|
25342
|
+
if (typeof index === "number" && this.ignored.has(index))
|
|
25343
|
+
return;
|
|
25218
25344
|
const state = typeof index === "number" ? this.open.get(index) : undefined;
|
|
25219
25345
|
if (!state || !isBody(delta) || delta.type === "citations_delta") {
|
|
25220
25346
|
this.invalid = true;
|
|
@@ -25251,6 +25377,8 @@ class ReplyFingerprint {
|
|
|
25251
25377
|
}
|
|
25252
25378
|
}
|
|
25253
25379
|
stop(index) {
|
|
25380
|
+
if (typeof index === "number" && this.ignored.delete(index))
|
|
25381
|
+
return;
|
|
25254
25382
|
const state = typeof index === "number" ? this.open.get(index) : undefined;
|
|
25255
25383
|
if (!state || typeof index !== "number") {
|
|
25256
25384
|
this.invalid = true;
|
|
@@ -25291,7 +25419,7 @@ class ReplyFingerprint {
|
|
|
25291
25419
|
}
|
|
25292
25420
|
}
|
|
25293
25421
|
digest() {
|
|
25294
|
-
if (this.invalid || this.open.size)
|
|
25422
|
+
if (this.invalid || this.open.size || this.ignored.size)
|
|
25295
25423
|
return;
|
|
25296
25424
|
const ordered = [...this.layout].sort(([a], [b]) => a - b);
|
|
25297
25425
|
const kept = withoutTrailingToolWhitespace(ordered.map(([, block]) => block));
|
|
@@ -36757,10 +36885,10 @@ function isSignInLink(candidate) {
|
|
|
36757
36885
|
}
|
|
36758
36886
|
function showSignInLink(text6, scrub) {
|
|
36759
36887
|
const links = new Set((text6.match(/https:\/\/\S+/g) ?? []).filter(isSignInLink));
|
|
36760
|
-
const [
|
|
36761
|
-
if (links.size !== 1 ||
|
|
36888
|
+
const [link3] = links;
|
|
36889
|
+
if (links.size !== 1 || link3 === undefined)
|
|
36762
36890
|
return { text: scrub(text6) };
|
|
36763
|
-
return { text: text6.split(
|
|
36891
|
+
return { text: text6.split(link3).map(scrub).join(link3), link: link3 };
|
|
36764
36892
|
}
|
|
36765
36893
|
var DISCONNECT_OUTCOMES = {
|
|
36766
36894
|
disconnected: {
|
|
@@ -41432,60 +41560,26 @@ function supportsTurnEndNote(model) {
|
|
|
41432
41560
|
var runnerReports = new Map;
|
|
41433
41561
|
var SKIP_REPORT_LIMIT = 512;
|
|
41434
41562
|
var RUNNER_REPORT_SESSION_LIMIT = 1024;
|
|
41435
|
-
function
|
|
41436
|
-
try {
|
|
41437
|
-
const read = handle.turn_notes;
|
|
41438
|
-
if (typeof read !== "function")
|
|
41439
|
-
return [];
|
|
41440
|
-
const answer = read.call(handle);
|
|
41441
|
-
if (answer !== null && (typeof answer === "object" || typeof answer === "function") && typeof Reflect.get(answer, "then") === "function") {
|
|
41442
|
-
Promise.resolve(answer).catch(() => {});
|
|
41443
|
-
return [];
|
|
41444
|
-
}
|
|
41445
|
-
if (!Array.isArray(answer))
|
|
41446
|
-
return [];
|
|
41447
|
-
const notes = [];
|
|
41448
|
-
for (let index = 0;index < answer.length; index++) {
|
|
41449
|
-
try {
|
|
41450
|
-
const entry2 = answer[index];
|
|
41451
|
-
if (!isRecord20(entry2) || Array.isArray(entry2))
|
|
41452
|
-
continue;
|
|
41453
|
-
const { after_tool_use_id, text: text6 } = entry2;
|
|
41454
|
-
if (typeof after_tool_use_id !== "string" || typeof text6 !== "string" || !text6.trim() || new TextEncoder().encode(text6).byteLength > 16384)
|
|
41455
|
-
continue;
|
|
41456
|
-
notes.push({ after_tool_use_id, text: text6 });
|
|
41457
|
-
} catch {}
|
|
41458
|
-
}
|
|
41459
|
-
return notes;
|
|
41460
|
-
} catch {
|
|
41461
|
-
return [];
|
|
41462
|
-
}
|
|
41463
|
-
}
|
|
41464
|
-
function runnerNotes(sessionId) {
|
|
41563
|
+
function hasRunnerTurnNotes(sessionId) {
|
|
41465
41564
|
try {
|
|
41466
41565
|
const routing = Reflect.get(globalThis, Symbol.for("cortexkit.routing"));
|
|
41467
41566
|
if (typeof routing !== "function")
|
|
41468
|
-
return;
|
|
41567
|
+
return false;
|
|
41469
41568
|
const handle = routing(sessionId);
|
|
41470
|
-
|
|
41471
|
-
return { handle, notes: readRunnerNotes(handle) };
|
|
41569
|
+
return isRecord20(handle) && typeof handle.turn_notes === "function";
|
|
41472
41570
|
} catch {
|
|
41473
|
-
return;
|
|
41571
|
+
return false;
|
|
41474
41572
|
}
|
|
41475
41573
|
}
|
|
41476
|
-
function reportRunnerNote(
|
|
41477
|
-
Promise.resolve().then(() => {
|
|
41478
|
-
const report = handle.report;
|
|
41479
|
-
if (typeof report === "function")
|
|
41480
|
-
return report.call(handle, payload);
|
|
41481
|
-
}).catch(() => {});
|
|
41574
|
+
function reportRunnerNote(payload) {
|
|
41575
|
+
Promise.resolve().then(() => reportRouting(payload)).catch(() => {});
|
|
41482
41576
|
}
|
|
41483
41577
|
function applyRunnerTurnNotes(body, options) {
|
|
41484
41578
|
if (!options.sessionId)
|
|
41485
41579
|
return 0;
|
|
41486
|
-
|
|
41487
|
-
if (!runner)
|
|
41580
|
+
if (!hasRunnerTurnNotes(options.sessionId))
|
|
41488
41581
|
return 0;
|
|
41582
|
+
const notes = turnNotes(options.sessionId);
|
|
41489
41583
|
let reported3 = runnerReports.get(options.sessionId);
|
|
41490
41584
|
if (reported3) {
|
|
41491
41585
|
runnerReports.delete(options.sessionId);
|
|
@@ -41502,7 +41596,8 @@ function applyRunnerTurnNotes(body, options) {
|
|
|
41502
41596
|
const model = options.modelId;
|
|
41503
41597
|
if (reported3.models.get(model) !== supported) {
|
|
41504
41598
|
reported3.models.set(model, supported);
|
|
41505
|
-
reportRunnerNote(
|
|
41599
|
+
reportRunnerNote({
|
|
41600
|
+
sessionId: options.sessionId,
|
|
41506
41601
|
kind: "turn_notes_supported",
|
|
41507
41602
|
model,
|
|
41508
41603
|
supported
|
|
@@ -41520,21 +41615,22 @@ function applyRunnerTurnNotes(body, options) {
|
|
|
41520
41615
|
}
|
|
41521
41616
|
const insertions = new Map;
|
|
41522
41617
|
let inserted = 0;
|
|
41523
|
-
for (const note of
|
|
41524
|
-
const index = anchors.get(note.
|
|
41618
|
+
for (const note of notes) {
|
|
41619
|
+
const index = anchors.get(note.afterToolUseId);
|
|
41525
41620
|
const next = index === undefined ? undefined : messages[index + 1];
|
|
41526
41621
|
const reason = !options.isOAuth ? "not_oauth" : !supported ? "unsupported_model" : index === undefined ? "anchor_missing" : isRecord20(next) && next.role === "user" ? "before_user_message" : undefined;
|
|
41527
41622
|
if (reason) {
|
|
41528
|
-
if (!reported3.skipped.has(note.
|
|
41623
|
+
if (!reported3.skipped.has(note.afterToolUseId)) {
|
|
41529
41624
|
if (reported3.skipped.size >= SKIP_REPORT_LIMIT) {
|
|
41530
41625
|
const oldest = reported3.skipped.values().next();
|
|
41531
41626
|
if (!oldest.done)
|
|
41532
41627
|
reported3.skipped.delete(oldest.value);
|
|
41533
41628
|
}
|
|
41534
|
-
reported3.skipped.add(note.
|
|
41535
|
-
reportRunnerNote(
|
|
41629
|
+
reported3.skipped.add(note.afterToolUseId);
|
|
41630
|
+
reportRunnerNote({
|
|
41631
|
+
sessionId: options.sessionId,
|
|
41536
41632
|
kind: "turn_note_skipped",
|
|
41537
|
-
after_tool_use_id: note.
|
|
41633
|
+
after_tool_use_id: note.afterToolUseId,
|
|
41538
41634
|
reason
|
|
41539
41635
|
});
|
|
41540
41636
|
}
|
|
@@ -41619,6 +41715,7 @@ export {
|
|
|
41619
41715
|
supportsTurnEndNote,
|
|
41620
41716
|
supportsPerMessageEffort,
|
|
41621
41717
|
summarizePrewarmProviderError,
|
|
41718
|
+
stripServerFallbackUsageMarkers,
|
|
41622
41719
|
stripEmptyTrailingAssistantMessages,
|
|
41623
41720
|
stripBillingLineageFromBody,
|
|
41624
41721
|
stripBillingLineageFields,
|
|
@@ -41805,6 +41902,7 @@ export {
|
|
|
41805
41902
|
isTerminatedSseFrame,
|
|
41806
41903
|
isStateLayoutRefusalCode,
|
|
41807
41904
|
isSseCandidateFrame,
|
|
41905
|
+
isServerFallbackUsageMarker,
|
|
41808
41906
|
isSecretKey,
|
|
41809
41907
|
isQuotaStale,
|
|
41810
41908
|
isQuotaPolicyAuthError,
|
|
@@ -42056,6 +42154,8 @@ export {
|
|
|
42056
42154
|
STATE_LAYOUT_REFUSAL_CODES,
|
|
42057
42155
|
STATE_LAYOUT_PHASES,
|
|
42058
42156
|
STATE_HOME_FILE_NAMES,
|
|
42157
|
+
SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX,
|
|
42158
|
+
SERVER_FALLBACK_USAGE_MARKER_TEXT,
|
|
42059
42159
|
SECRET_KEY_EXACT2 as SECRET_KEY_EXACT,
|
|
42060
42160
|
RequestGzipLatch,
|
|
42061
42161
|
RelocatedError,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type LeaseCreationTestHooks = {
|
|
2
|
+
beforeWrite?: (path: string) => void | Promise<void>;
|
|
3
|
+
beforeLink?: (tempPath: string, lockPath: string) => void | Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
6
|
+
export declare function setLeaseCreationTestHooksForTest(hooks?: LeaseCreationTestHooks): void;
|
|
1
7
|
export declare function isLostMarkerRaceError(error: unknown): boolean;
|
|
2
8
|
/** Test-only fault injection between marker mkdir and owner.json write. */
|
|
3
9
|
export interface EvictionMarkerTestHooks {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional THALAMUS routing for vault mode and advisory turn notes for request
|
|
3
|
+
* shaping. Account ids are vault account ids, not local pool rows. Nothing is
|
|
4
|
+
* persisted here; plugins on routes the runner does not serve get no turn notes.
|
|
5
|
+
*/
|
|
1
6
|
/** An eligible vault route, not a local pool row. */
|
|
2
7
|
export interface RoutingCandidate {
|
|
3
8
|
/** Vault account id, not the plugin's route id. */
|
|
@@ -35,7 +40,7 @@ interface RoutingReportIdentity {
|
|
|
35
40
|
accountId: string;
|
|
36
41
|
credentialId?: string;
|
|
37
42
|
}
|
|
38
|
-
export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
43
|
+
export type ReportRoutingInput = (RoutingReportIdentity & ({
|
|
39
44
|
outcome: 'served';
|
|
40
45
|
/**
|
|
41
46
|
* Pass only rate-limit headers, never the whole response headers.
|
|
@@ -56,7 +61,26 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
56
61
|
pool?: string;
|
|
57
62
|
/** Optional reset time in epoch milliseconds. */
|
|
58
63
|
resetsAt?: number;
|
|
59
|
-
})
|
|
64
|
+
})) | {
|
|
65
|
+
sessionId: string;
|
|
66
|
+
kind: 'turn_notes_supported';
|
|
67
|
+
model: string;
|
|
68
|
+
supported: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
sessionId: string;
|
|
71
|
+
kind: 'turn_note_skipped';
|
|
72
|
+
after_tool_use_id: string;
|
|
73
|
+
reason: 'anchor_missing' | 'before_user_message' | 'unsupported_model' | 'not_oauth';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Read advisory input for request shaping, in landing order, without persisting
|
|
77
|
+
* it. If no routing handle is available or the runner does not serve the route,
|
|
78
|
+
* returns [].
|
|
79
|
+
*/
|
|
80
|
+
export declare function turnNotes(sessionId: string): readonly {
|
|
81
|
+
afterToolUseId: string;
|
|
82
|
+
text: string;
|
|
83
|
+
}[];
|
|
60
84
|
/**
|
|
61
85
|
* Ask routing for an eligible vault route. Any failure or unfamiliar answer
|
|
62
86
|
* yields undefined so the plugin can keep its own choice. This does not admit
|
|
@@ -64,9 +88,10 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
64
88
|
*/
|
|
65
89
|
export declare function askRouting<Candidate extends RoutingCandidate>(input: AskRoutingInput<Candidate>): Promise<RoutingSelection<Candidate> | undefined>;
|
|
66
90
|
/**
|
|
67
|
-
* Report a vault request without waiting for routing. Only
|
|
68
|
-
* sent, and all accessor failures are ignored. Headers must
|
|
69
|
-
* to rate-limit headers by the caller; values are not filtered
|
|
91
|
+
* Report a vault request or turn-note event without waiting for routing. Only
|
|
92
|
+
* contract fields are sent, and all accessor failures are ignored. Headers must
|
|
93
|
+
* already be limited to rate-limit headers by the caller; values are not filtered
|
|
94
|
+
* or redacted here.
|
|
70
95
|
*/
|
|
71
96
|
export declare function reportRouting(input: ReportRoutingInput): void;
|
|
72
97
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SERVER_FALLBACK_USAGE_MARKER_TEXT = "\u2060\u2060";
|
|
2
|
+
export declare const SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX = "cortexkit-server-fallback-usage-v1:";
|
|
3
|
+
/** Usage-only thinking parts are local metadata, not provider conversation state. */
|
|
4
|
+
export declare function isServerFallbackUsageMarker(value: unknown): boolean;
|
|
5
|
+
/** Strip by text or signature prefix, including markers with corrupted signatures. */
|
|
6
|
+
export declare function stripServerFallbackUsageMarkers(body: Record<string, unknown>): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepublishOnly": "bun run build"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@cortexkit/common-auth": "0.
|
|
33
|
+
"@cortexkit/common-auth": "0.39.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@cortexkit/claustrum-client": "0.13.0",
|