@cortexkit/anthropic-auth-core 2.5.7 → 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
@@ -14938,6 +14938,32 @@ function createProviderErrorResponseScope(secrets, mode) {
14938
14938
  return Object.freeze(scope);
14939
14939
  }
14940
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
+
14941
14967
  // src/cachekeep.ts
14942
14968
  var CLAUDE_CACHE_KEEP_COMMAND_NAME = "claude-cachekeep";
14943
14969
  var CACHE_KEEP_TTL_MS = 60 * 60000;
@@ -15143,6 +15169,7 @@ async function buildCacheKeepPrewarmBody(bodyText, options = {}) {
15143
15169
  return { ok: false, reason: "body has no explicit cache breakpoints" };
15144
15170
  }
15145
15171
  const warm = structuredClone(body);
15172
+ stripServerFallbackUsageMarkers(warm);
15146
15173
  delete warm.thread;
15147
15174
  stripBillingLineageFromBody(warm);
15148
15175
  warm.max_tokens = 0;
@@ -25224,6 +25251,7 @@ class ReplyFingerprint {
25224
25251
  normalizeToolName;
25225
25252
  open = new Map;
25226
25253
  seen = new Set;
25254
+ ignored = new Set;
25227
25255
  tools = new Map;
25228
25256
  layout = new Map;
25229
25257
  textBlocks = new Map;
@@ -25271,6 +25299,10 @@ class ReplyFingerprint {
25271
25299
  return;
25272
25300
  }
25273
25301
  this.seen.add(index);
25302
+ if (isServerFallbackUsageMarker(block)) {
25303
+ this.ignored.add(index);
25304
+ return;
25305
+ }
25274
25306
  const state = {
25275
25307
  type: block.type,
25276
25308
  signatureLength: 0,
@@ -25307,6 +25339,8 @@ class ReplyFingerprint {
25307
25339
  this.open.set(index, state);
25308
25340
  }
25309
25341
  delta(index, delta) {
25342
+ if (typeof index === "number" && this.ignored.has(index))
25343
+ return;
25310
25344
  const state = typeof index === "number" ? this.open.get(index) : undefined;
25311
25345
  if (!state || !isBody(delta) || delta.type === "citations_delta") {
25312
25346
  this.invalid = true;
@@ -25343,6 +25377,8 @@ class ReplyFingerprint {
25343
25377
  }
25344
25378
  }
25345
25379
  stop(index) {
25380
+ if (typeof index === "number" && this.ignored.delete(index))
25381
+ return;
25346
25382
  const state = typeof index === "number" ? this.open.get(index) : undefined;
25347
25383
  if (!state || typeof index !== "number") {
25348
25384
  this.invalid = true;
@@ -25383,7 +25419,7 @@ class ReplyFingerprint {
25383
25419
  }
25384
25420
  }
25385
25421
  digest() {
25386
- if (this.invalid || this.open.size)
25422
+ if (this.invalid || this.open.size || this.ignored.size)
25387
25423
  return;
25388
25424
  const ordered = [...this.layout].sort(([a], [b]) => a - b);
25389
25425
  const kept = withoutTrailingToolWhitespace(ordered.map(([, block]) => block));
@@ -41679,6 +41715,7 @@ export {
41679
41715
  supportsTurnEndNote,
41680
41716
  supportsPerMessageEffort,
41681
41717
  summarizePrewarmProviderError,
41718
+ stripServerFallbackUsageMarkers,
41682
41719
  stripEmptyTrailingAssistantMessages,
41683
41720
  stripBillingLineageFromBody,
41684
41721
  stripBillingLineageFields,
@@ -41865,6 +41902,7 @@ export {
41865
41902
  isTerminatedSseFrame,
41866
41903
  isStateLayoutRefusalCode,
41867
41904
  isSseCandidateFrame,
41905
+ isServerFallbackUsageMarker,
41868
41906
  isSecretKey,
41869
41907
  isQuotaStale,
41870
41908
  isQuotaPolicyAuthError,
@@ -42116,6 +42154,8 @@ export {
42116
42154
  STATE_LAYOUT_REFUSAL_CODES,
42117
42155
  STATE_LAYOUT_PHASES,
42118
42156
  STATE_HOME_FILE_NAMES,
42157
+ SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX,
42158
+ SERVER_FALLBACK_USAGE_MARKER_TEXT,
42119
42159
  SECRET_KEY_EXACT2 as SECRET_KEY_EXACT,
42120
42160
  RequestGzipLatch,
42121
42161
  RelocatedError,
@@ -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.7",
3
+ "version": "2.5.8",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",