@cortexkit/anthropic-auth-core 2.7.2 → 2.8.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.
@@ -46,5 +46,7 @@ export declare function applyClaudeCodeHeaders(headers: Headers, accessToken: st
46
46
  */
47
47
  requestClass?: ClaudeCodeRequestClass;
48
48
  }): Headers;
49
- export declare function orderClaudeCodeBody<T extends Record<string, unknown>>(body: T): T;
49
+ export declare function orderClaudeCodeBody<T extends Record<string, unknown>>(body: T, options?: {
50
+ isOAuth?: boolean;
51
+ }): T;
50
52
  export declare function claudeCodeEntrypoint(): string;
package/dist/dump.d.ts CHANGED
@@ -71,10 +71,24 @@ export declare function dumpRelayRequest(input: {
71
71
  relayBytes: number;
72
72
  tag?: DumpTag;
73
73
  }): Promise<DumpHandle | null>;
74
+ export type ReplyTextEdge = {
75
+ index: number;
76
+ leading: number;
77
+ trailing: number;
78
+ chars: number;
79
+ };
80
+ /** Summarize parsed provider events without retaining any reply text. */
81
+ export declare function createDumpResponseObserver(handle: DumpHandle | null, status: number): {
82
+ observe(event: Record<string, unknown>): void;
83
+ replyTextEdges: () => ReplyTextEdge[] | undefined;
84
+ fail(): void;
85
+ finish(): Promise<void>;
86
+ };
74
87
  export declare function dumpResponseArtifact(handle: DumpHandle | null, input: {
75
88
  status: number;
76
89
  message: unknown;
77
90
  complete?: boolean;
78
91
  provider_error?: ProviderErrorSummary['provider_error'];
92
+ reply_text_edges?: readonly ReplyTextEdge[];
79
93
  }): Promise<void>;
80
94
  export {};
package/dist/index.js CHANGED
@@ -9069,6 +9069,18 @@ var FABLE_MYTHOS_5_1_CATALOGUE = {
9069
9069
  cacheWrite1h: 20
9070
9070
  }
9071
9071
  };
9072
+ var FABLE_5_2_CATALOGUE = {
9073
+ releaseDate: "2026-11-09",
9074
+ contextWindow: 1e6,
9075
+ maxOutputTokens: 128000,
9076
+ pricing: {
9077
+ input: 8,
9078
+ output: 40,
9079
+ cacheRead: 0.2,
9080
+ cacheWrite5m: 10,
9081
+ cacheWrite1h: 16
9082
+ }
9083
+ };
9072
9084
  var CLAUDE_MODEL_CAPABILITIES = [
9073
9085
  {
9074
9086
  id: "claude-fable-5",
@@ -9142,6 +9154,24 @@ var CLAUDE_MODEL_CAPABILITIES = [
9142
9154
  scopedQuota: "mythos",
9143
9155
  fastMode: false
9144
9156
  },
9157
+ {
9158
+ id: "claude-fable-5-2",
9159
+ name: "Claude Fable 5.2",
9160
+ family: "fable",
9161
+ idSuffixes: "any",
9162
+ catalogue: FABLE_5_2_CATALOGUE,
9163
+ thinkingModes: ["adaptive"],
9164
+ rejectsForcedToolChoice: true,
9165
+ efforts: { variants: ALL_ADAPTIVE_EFFORTS, default: "medium" },
9166
+ effortMarkers: "always",
9167
+ turnEndNote: true,
9168
+ thinkingBindingControls: true,
9169
+ claudeCodeBetas: claudeCodeBetaLists({ perTurnControl: true }),
9170
+ serverSideFallback: true,
9171
+ refusalRecoveryFamily: "fable-5-2",
9172
+ scopedQuota: "fable",
9173
+ fastMode: false
9174
+ },
9145
9175
  {
9146
9176
  id: "claude-opus-5",
9147
9177
  name: "Claude Opus 5",
@@ -13911,13 +13941,15 @@ var BODY_FIELD_ORDER = [
13911
13941
  "stream",
13912
13942
  "speed"
13913
13943
  ];
13914
- function orderClaudeCodeBody(body) {
13944
+ function orderClaudeCodeBody(body, options = {}) {
13915
13945
  const ordered = {};
13916
13946
  for (const key of BODY_FIELD_ORDER) {
13917
13947
  if (Object.hasOwn(body, key))
13918
13948
  ordered[key] = body[key];
13919
13949
  }
13920
13950
  for (const [key, value] of Object.entries(body)) {
13951
+ if (options.isOAuth && key === "service_tier")
13952
+ continue;
13921
13953
  if (!Object.hasOwn(ordered, key))
13922
13954
  ordered[key] = value;
13923
13955
  }
@@ -14482,6 +14514,100 @@ async function dumpRelayRequest(input) {
14482
14514
  tag: input.tag
14483
14515
  });
14484
14516
  }
14517
+ function createDumpResponseObserver(handle, status) {
14518
+ const edges = new Map;
14519
+ let message;
14520
+ let complete = false;
14521
+ let failed = false;
14522
+ const record3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
14523
+ const replyTextEdges = () => message && !failed && status >= 200 && status < 300 ? [...edges.values()] : undefined;
14524
+ const append = (edge, text) => {
14525
+ if (typeof text !== "string")
14526
+ return;
14527
+ let leading = 0;
14528
+ while (leading < text.length && /\s/u.test(text.charAt(leading)))
14529
+ leading++;
14530
+ if (edge.leading === edge.chars)
14531
+ edge.leading += leading;
14532
+ let trailing = 0;
14533
+ while (trailing < text.length && /\s/u.test(text.charAt(text.length - trailing - 1)))
14534
+ trailing++;
14535
+ edge.trailing = trailing === text.length ? edge.trailing + trailing : trailing;
14536
+ edge.chars += text.length;
14537
+ };
14538
+ const start = (index, block) => {
14539
+ if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0 || !block || typeof block !== "object" || block.type !== "text" || edges.has(index))
14540
+ return;
14541
+ const edge = { index, leading: 0, trailing: 0, chars: 0 };
14542
+ edges.set(index, edge);
14543
+ append(edge, block.text);
14544
+ };
14545
+ return {
14546
+ observe(event) {
14547
+ if (!handle)
14548
+ return;
14549
+ if (event.type === "message_start") {
14550
+ const opening = event.message;
14551
+ if (!opening || typeof opening !== "object")
14552
+ return;
14553
+ message = {};
14554
+ for (const key of [
14555
+ "id",
14556
+ "model",
14557
+ "usage",
14558
+ "diagnostics",
14559
+ "stop_reason"
14560
+ ]) {
14561
+ if (Object.hasOwn(opening, key))
14562
+ message[key] = opening[key];
14563
+ }
14564
+ if (Array.isArray(opening.content)) {
14565
+ for (const [index, block] of opening.content.entries())
14566
+ start(index, block);
14567
+ }
14568
+ } else if (event.type === "content_block_start") {
14569
+ start(event.index, event.content_block);
14570
+ } else if (event.type === "content_block_delta") {
14571
+ const delta = event.delta;
14572
+ const edge = typeof event.index === "number" ? edges.get(event.index) : undefined;
14573
+ if (edge && delta?.type === "text_delta")
14574
+ append(edge, delta.text);
14575
+ } else if (event.type === "message_delta" && message) {
14576
+ const nested = record3(event.message);
14577
+ const usage = record3(event.usage) ?? record3(nested?.usage);
14578
+ const delta = record3(event.delta);
14579
+ const stopReason = [
14580
+ delta?.stop_reason,
14581
+ event.stop_reason,
14582
+ ...usage ? [nested?.stop_reason] : []
14583
+ ].find((value) => typeof value === "string");
14584
+ if (usage || stopReason) {
14585
+ if (usage)
14586
+ message.usage = { ...message.usage, ...usage };
14587
+ if (stopReason)
14588
+ message.stop_reason = stopReason;
14589
+ complete = true;
14590
+ }
14591
+ } else if (event.type === "error") {
14592
+ failed = true;
14593
+ }
14594
+ },
14595
+ replyTextEdges,
14596
+ fail() {
14597
+ failed = true;
14598
+ },
14599
+ async finish() {
14600
+ if (!message)
14601
+ return;
14602
+ await dumpResponseArtifact(handle, {
14603
+ status,
14604
+ message,
14605
+ complete: complete && !failed,
14606
+ ...complete ? { reply_text_edges: replyTextEdges() } : {}
14607
+ });
14608
+ }
14609
+ };
14610
+ }
14485
14611
  async function dumpResponseArtifact(handle, input) {
14486
14612
  if (!handle)
14487
14613
  return;
@@ -14502,6 +14628,13 @@ async function dumpResponseArtifact(handle, input) {
14502
14628
  artifact.stop_reason = message.stop_reason;
14503
14629
  if (input.provider_error)
14504
14630
  artifact.provider_error = input.provider_error;
14631
+ if (input.reply_text_edges && input.complete !== false && input.status >= 200 && input.status < 300 && !input.provider_error)
14632
+ artifact.reply_text_edges = input.reply_text_edges.map(({ index, leading, trailing, chars }) => ({
14633
+ index,
14634
+ leading,
14635
+ trailing,
14636
+ chars
14637
+ }));
14505
14638
  try {
14506
14639
  await writeDumpFile(handle.responsePath, `${JSON.stringify(artifact, null, 2)}
14507
14640
  `);
@@ -14514,6 +14647,7 @@ async function dumpResponseArtifact(handle, input) {
14514
14647
  var CLAUDE_FABLE_5_MODEL_ID = "claude-fable-5";
14515
14648
  var CLAUDE_MYTHOS_5_MODEL_ID = "claude-mythos-5";
14516
14649
  var CLAUDE_FABLE_5_1_MODEL_ID = "claude-fable-5-1";
14650
+ var CLAUDE_FABLE_5_2_MODEL_ID = "claude-fable-5-2";
14517
14651
  var CLAUDE_MYTHOS_5_1_MODEL_ID = "claude-mythos-5-1";
14518
14652
  var CLAUDE_HAIKU_4_5_MODEL_ID = "claude-haiku-4-5";
14519
14653
  var CLAUDE_HAIKU_4_5_PRICING = {
@@ -14527,7 +14661,8 @@ var CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS = [
14527
14661
  var CLAUDE_FABLE_MYTHOS_5_MODEL_IDS = [
14528
14662
  CLAUDE_FABLE_5_MODEL_ID,
14529
14663
  CLAUDE_MYTHOS_5_MODEL_ID,
14530
- ...CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS
14664
+ ...CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS,
14665
+ CLAUDE_FABLE_5_2_MODEL_ID
14531
14666
  ];
14532
14667
  var CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING = {
14533
14668
  type: "adaptive",
@@ -14535,8 +14670,11 @@ var CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING = {
14535
14670
  };
14536
14671
  var FABLE_5_CATALOGUE = getClaudeModelCatalogue(CLAUDE_FABLE_5_MODEL_ID);
14537
14672
  var FABLE_5_1_CATALOGUE = getClaudeModelCatalogue(CLAUDE_FABLE_5_1_MODEL_ID);
14673
+ var FABLE_5_2_CATALOGUE2 = getClaudeModelCatalogue(CLAUDE_FABLE_5_2_MODEL_ID);
14538
14674
  var CLAUDE_FABLE_MYTHOS_5_PRICING = FABLE_5_CATALOGUE.pricing;
14539
14675
  var CLAUDE_FABLE_MYTHOS_5_1_PRICING = FABLE_5_1_CATALOGUE.pricing;
14676
+ var CLAUDE_FABLE_5_2_PRICING = FABLE_5_2_CATALOGUE2.pricing;
14677
+ var CLAUDE_FABLE_5_2_RELEASE_DATE = FABLE_5_2_CATALOGUE2.releaseDate;
14540
14678
  var CLAUDE_FABLE_MYTHOS_5_CONTEXT_WINDOW = FABLE_5_CATALOGUE.contextWindow;
14541
14679
  var CLAUDE_FABLE_MYTHOS_5_MAX_OUTPUT_TOKENS = FABLE_5_CATALOGUE.maxOutputTokens;
14542
14680
  var CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE = FABLE_5_CATALOGUE.releaseDate;
@@ -14569,7 +14707,8 @@ function isClaudeFable51Model(model) {
14569
14707
  return resolvedModelId(model) === CLAUDE_FABLE_5_1_MODEL_ID;
14570
14708
  }
14571
14709
  function getClaudeFableMythos5ReleaseDate(model) {
14572
- return isClaudeFableOrMythos51Model(model) ? CLAUDE_FABLE_MYTHOS_5_1_RELEASE_DATE : CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE;
14710
+ const row = resolveClaudeModelCapabilities(model);
14711
+ return isFableOrMythosRow(row) && row?.catalogue?.releaseDate || CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE;
14573
14712
  }
14574
14713
  var CLAUDE_SONNET_5_MODEL_ID = "claude-sonnet-5";
14575
14714
  var CLAUDE_SONNET_5_ADAPTIVE_THINKING = CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING;
@@ -16533,7 +16672,7 @@ async function buildCacheKeepPrewarmBody(bodyText, options = {}) {
16533
16672
  if (toolChoice?.type === "tool" || toolChoice?.type === "any") {
16534
16673
  delete warm.tool_choice;
16535
16674
  }
16536
- const signedBodyText = await signRequestBody(JSON.stringify(orderClaudeCodeBody(warm)));
16675
+ const signedBodyText = await signRequestBody(JSON.stringify(orderClaudeCodeBody(warm, { isOAuth: true })));
16537
16676
  return { ok: true, bodyText: signedBodyText };
16538
16677
  }
16539
16678
  function updateAcceptedUsage(target, bodyText, usage) {
@@ -44270,6 +44409,7 @@ export {
44270
44409
  createNativeCustody,
44271
44410
  createNativeAccountRuntime,
44272
44411
  createEmptyStorage,
44412
+ createDumpResponseObserver,
44273
44413
  createAnthropicOAuthFetch,
44274
44414
  countUserPrompts,
44275
44415
  connectVaultHost,
@@ -44490,6 +44630,9 @@ export {
44490
44630
  CLAUDE_FABLE_MYTHOS_5_1_MODEL_SPECS,
44491
44631
  CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS,
44492
44632
  CLAUDE_FABLE_5_MODEL_ID,
44633
+ CLAUDE_FABLE_5_2_RELEASE_DATE,
44634
+ CLAUDE_FABLE_5_2_PRICING,
44635
+ CLAUDE_FABLE_5_2_MODEL_ID,
44493
44636
  CLAUDE_FABLE_5_1_MODEL_ID,
44494
44637
  CLAUDE_DUMP_COMMAND_NAME,
44495
44638
  CLAUDE_CODE_VERSION,
@@ -21,7 +21,7 @@ export declare function normalizeAdaptiveEffort(value: unknown): AdaptiveEffort
21
21
  export declare function usesPerTurnControl(model: unknown): boolean;
22
22
  /**
23
23
  * Models whose OAuth requests carry `PER_TURN_CONTROL_BETA`: those whose
24
- * Claude Code main beta list includes it (Opus 5.5, Sonnet 5.5, Fable 5.1 and
24
+ * Claude Code main beta list includes it (Opus 5.5, Sonnet 5.5, Fable 5.1/5.2 and
25
25
  * Haiku 5.5 in Claude Code 2.1.302). Sending the beta does not by itself make
26
26
  * a model eligible for effort markers; `supportsPerMessageEffort` decides that.
27
27
  */
@@ -29,7 +29,7 @@ export declare function sendsPerTurnControlBeta(model: unknown): boolean;
29
29
  /**
30
30
  * Whether a request may move effort changes into empty system messages.
31
31
  *
32
- * Models with `effortMarkers: "always"` (Fable 5.1) are always eligible,
32
+ * Models with `effortMarkers: "always"` (Fable 5.1/5.2) are always eligible,
33
33
  * whatever the thinking field says. Models with `"with-adaptive-thinking"`
34
34
  * (Opus 5.5, Sonnet 5.5) qualify only with adaptive thinking: Anthropic
35
35
  * rejects a differing per-message effort with HTTP 400 on Sonnet 5.5
@@ -55,7 +55,7 @@ export type ClaudeModelCatalogue = {
55
55
  };
56
56
  };
57
57
  /** Source-model keys for content-filter recovery to Opus 4.8 in OpenCode. */
58
- export type ClaudeRefusalRecoveryFamily = 'fable-5' | 'fable-5-1' | 'opus-5' | 'opus-5-5';
58
+ export type ClaudeRefusalRecoveryFamily = 'fable-5' | 'fable-5-1' | 'fable-5-2' | 'opus-5' | 'opus-5-5';
59
59
  export type ClaudeModelCapabilities = {
60
60
  /** Exact Anthropic model id. */
61
61
  id: string;
package/dist/models.d.ts CHANGED
@@ -3,6 +3,7 @@ export { normalizeAnthropicModelId };
3
3
  export declare const CLAUDE_FABLE_5_MODEL_ID = "claude-fable-5";
4
4
  export declare const CLAUDE_MYTHOS_5_MODEL_ID = "claude-mythos-5";
5
5
  export declare const CLAUDE_FABLE_5_1_MODEL_ID = "claude-fable-5-1";
6
+ export declare const CLAUDE_FABLE_5_2_MODEL_ID = "claude-fable-5-2";
6
7
  export declare const CLAUDE_MYTHOS_5_1_MODEL_ID = "claude-mythos-5-1";
7
8
  /**
8
9
  * Haiku 4.5 model identifier used by `/claude-prime` to start each OAuth
@@ -21,7 +22,7 @@ export declare const CLAUDE_HAIKU_4_5_PRICING: {
21
22
  readonly output: 5;
22
23
  };
23
24
  export declare const CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS: readonly ["claude-fable-5-1", "claude-mythos-5-1"];
24
- export declare const CLAUDE_FABLE_MYTHOS_5_MODEL_IDS: readonly ["claude-fable-5", "claude-mythos-5", "claude-fable-5-1", "claude-mythos-5-1"];
25
+ export declare const CLAUDE_FABLE_MYTHOS_5_MODEL_IDS: readonly ["claude-fable-5", "claude-mythos-5", "claude-fable-5-1", "claude-mythos-5-1", "claude-fable-5-2"];
25
26
  export type ClaudeFableMythos5ModelId = (typeof CLAUDE_FABLE_MYTHOS_5_MODEL_IDS)[number];
26
27
  export declare const CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING: {
27
28
  readonly type: 'adaptive';
@@ -29,6 +30,8 @@ export declare const CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING: {
29
30
  };
30
31
  export declare const CLAUDE_FABLE_MYTHOS_5_PRICING: import("./model-capabilities.ts").ClaudeModelPricing;
31
32
  export declare const CLAUDE_FABLE_MYTHOS_5_1_PRICING: import("./model-capabilities.ts").ClaudeModelPricing;
33
+ export declare const CLAUDE_FABLE_5_2_PRICING: import("./model-capabilities.ts").ClaudeModelPricing;
34
+ export declare const CLAUDE_FABLE_5_2_RELEASE_DATE: string;
32
35
  export declare const CLAUDE_FABLE_MYTHOS_5_CONTEXT_WINDOW: number;
33
36
  export declare const CLAUDE_FABLE_MYTHOS_5_MAX_OUTPUT_TOKENS: number;
34
37
  export declare const CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,9 +33,9 @@
33
33
  "@cortexkit/common-auth": "0.42.0"
34
34
  },
35
35
  "dependencies": {
36
- "@cortexkit/claustrum-client": "0.13.0",
36
+ "@cortexkit/claustrum-client": "0.17.0",
37
37
  "@cortexkit/private-files": "0.2.2",
38
- "@cortexkit/subc-client": "^0.22.10",
38
+ "@cortexkit/subc-client": "^0.24",
39
39
  "jsonc-parser": "^3.3.1",
40
40
  "xxhash-wasm": "^1.1.0"
41
41
  }