@cortexkit/anthropic-auth-core 2.7.3 → 2.9.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/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
  }
@@ -14615,6 +14647,7 @@ async function dumpResponseArtifact(handle, input) {
14615
14647
  var CLAUDE_FABLE_5_MODEL_ID = "claude-fable-5";
14616
14648
  var CLAUDE_MYTHOS_5_MODEL_ID = "claude-mythos-5";
14617
14649
  var CLAUDE_FABLE_5_1_MODEL_ID = "claude-fable-5-1";
14650
+ var CLAUDE_FABLE_5_2_MODEL_ID = "claude-fable-5-2";
14618
14651
  var CLAUDE_MYTHOS_5_1_MODEL_ID = "claude-mythos-5-1";
14619
14652
  var CLAUDE_HAIKU_4_5_MODEL_ID = "claude-haiku-4-5";
14620
14653
  var CLAUDE_HAIKU_4_5_PRICING = {
@@ -14628,7 +14661,8 @@ var CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS = [
14628
14661
  var CLAUDE_FABLE_MYTHOS_5_MODEL_IDS = [
14629
14662
  CLAUDE_FABLE_5_MODEL_ID,
14630
14663
  CLAUDE_MYTHOS_5_MODEL_ID,
14631
- ...CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS
14664
+ ...CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS,
14665
+ CLAUDE_FABLE_5_2_MODEL_ID
14632
14666
  ];
14633
14667
  var CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING = {
14634
14668
  type: "adaptive",
@@ -14636,8 +14670,11 @@ var CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING = {
14636
14670
  };
14637
14671
  var FABLE_5_CATALOGUE = getClaudeModelCatalogue(CLAUDE_FABLE_5_MODEL_ID);
14638
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);
14639
14674
  var CLAUDE_FABLE_MYTHOS_5_PRICING = FABLE_5_CATALOGUE.pricing;
14640
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;
14641
14678
  var CLAUDE_FABLE_MYTHOS_5_CONTEXT_WINDOW = FABLE_5_CATALOGUE.contextWindow;
14642
14679
  var CLAUDE_FABLE_MYTHOS_5_MAX_OUTPUT_TOKENS = FABLE_5_CATALOGUE.maxOutputTokens;
14643
14680
  var CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE = FABLE_5_CATALOGUE.releaseDate;
@@ -14670,7 +14707,8 @@ function isClaudeFable51Model(model) {
14670
14707
  return resolvedModelId(model) === CLAUDE_FABLE_5_1_MODEL_ID;
14671
14708
  }
14672
14709
  function getClaudeFableMythos5ReleaseDate(model) {
14673
- 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;
14674
14712
  }
14675
14713
  var CLAUDE_SONNET_5_MODEL_ID = "claude-sonnet-5";
14676
14714
  var CLAUDE_SONNET_5_ADAPTIVE_THINKING = CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING;
@@ -16634,7 +16672,7 @@ async function buildCacheKeepPrewarmBody(bodyText, options = {}) {
16634
16672
  if (toolChoice?.type === "tool" || toolChoice?.type === "any") {
16635
16673
  delete warm.tool_choice;
16636
16674
  }
16637
- const signedBodyText = await signRequestBody(JSON.stringify(orderClaudeCodeBody(warm)));
16675
+ const signedBodyText = await signRequestBody(JSON.stringify(orderClaudeCodeBody(warm, { isOAuth: true })));
16638
16676
  return { ok: true, bodyText: signedBodyText };
16639
16677
  }
16640
16678
  function updateAcceptedUsage(target, bodyText, usage) {
@@ -41464,7 +41502,9 @@ function getRequestGzipLatch(path2) {
41464
41502
  }
41465
41503
  return latch;
41466
41504
  }
41467
- function getRequestGzipLatchPath(accountStoragePath) {
41505
+ function getRequestGzipLatchPath(accountStoragePath, layout = LEGACY_STATE_LAYOUT) {
41506
+ if (layout.kind === "state-home")
41507
+ return stateHomeFilePaths(layout.dir).requestGzip;
41468
41508
  const name = basename10(accountStoragePath);
41469
41509
  const stem = name.endsWith(".json") ? name.slice(0, -5) : name;
41470
41510
  return join27(dirname23(accountStoragePath), `${stem}-request-gzip.json`);
@@ -43172,7 +43212,7 @@ async function restoreLegacyLayout(options = {}) {
43172
43212
  // src/state-layout-decision.ts
43173
43213
  var ACCOUNT_FILE2 = "anthropic-auth.json";
43174
43214
  var ACCOUNT_STATE_FILE2 = "anthropic-auth-state.json";
43175
- var RELOCATION_MOVE_ENABLED = false;
43215
+ var RELOCATION_MOVE_ENABLED = true;
43176
43216
  var moveEnabledOverride;
43177
43217
  function setRelocationMoveEnabledForTests(enabled) {
43178
43218
  moveEnabledOverride = enabled;
@@ -43229,6 +43269,49 @@ async function readRecord2(sub) {
43229
43269
  markerUnreadable(sub, error);
43230
43270
  }
43231
43271
  }
43272
+ async function readPreflightCustodyAuthority(host, env) {
43273
+ const authority = await vaultAuthority(getHostClaustrumEnrollmentPaths(host, env), `anthropic-auth-${host}`);
43274
+ return authority === "host" ? "vault" : authority;
43275
+ }
43276
+ async function preflightExistingAuthority(paths, host, env) {
43277
+ if (await readPreflightCustodyAuthority(host, env) !== "local")
43278
+ return;
43279
+ const vault = nativeVaultPaths(paths, LEGACY_STATE_LAYOUT);
43280
+ for (const runtime2 of [paths.runtime, vault.runtime])
43281
+ if (await readRelocationPointer(runtime2))
43282
+ return;
43283
+ for (const dir of new Set(nativeHolderDatasetFiles(paths).map(dirname25)))
43284
+ if (await readConfigDirMarker(dir) || await readStateLayoutMarker(dir))
43285
+ return;
43286
+ await requireNativePoolAuthority(paths);
43287
+ }
43288
+ async function preflightOpenCodeAuthority(configDir, env, home) {
43289
+ if (await readPreflightCustodyAuthority("opencode", env) !== "local")
43290
+ return;
43291
+ if (!isExplicit(env)) {
43292
+ const identity3 = configIdentity(configDir);
43293
+ if (identity3 !== undefined) {
43294
+ const target2 = stateHomeTargetFor(identity3, { env, home });
43295
+ const record12 = await readRecord2(target2.dir);
43296
+ if (record12?.phase === "committed") {
43297
+ const dataset = await resolveRelocationDataset({
43298
+ configDir,
43299
+ identity: identity3,
43300
+ stateRoot: target2.stateRoot,
43301
+ sub: await canonicalPath(target2.dir)
43302
+ });
43303
+ requireRecordMatches2(record12, dataset);
43304
+ await requireNativePoolAuthority(dataset.newPaths);
43305
+ return;
43306
+ }
43307
+ if (!noMoveRecord(record12))
43308
+ return;
43309
+ }
43310
+ }
43311
+ const config = env.OPENCODE_ANTHROPIC_AUTH_FILE?.trim() || join31(configDir, ACCOUNT_FILE2);
43312
+ const state = env.OPENCODE_ANTHROPIC_AUTH_STATE_FILE?.trim() || (config.endsWith(ACCOUNT_FILE2) ? join31(dirname25(config), ACCOUNT_STATE_FILE2) : `${config}.state.json`);
43313
+ await preflightExistingAuthority(await resolveNativePoolPaths(config, state, LEGACY_STATE_LAYOUT), "opencode", env);
43314
+ }
43232
43315
  async function registerHeld(holderFile, paths, kind, identity3, options, ctx) {
43233
43316
  const entry2 = await buildHolderEntry({
43234
43317
  role: options.role,
@@ -43429,6 +43512,8 @@ async function decideOpenCodeStateLayout(options) {
43429
43512
  const home = options.home ?? homedir8();
43430
43513
  const fs3 = options.fs ?? defaultStateLayoutFs();
43431
43514
  const configDir = getOpenCodeConfigDir(env, home);
43515
+ if (options.requireExistingAuthority)
43516
+ await preflightOpenCodeAuthority(configDir, env, home);
43432
43517
  const newContext = () => ({
43433
43518
  fs: fs3,
43434
43519
  stack: new StateLayoutLockStack(options.onLockEvent),
@@ -43758,8 +43843,16 @@ function decisionKey(options) {
43758
43843
  function decideOpenCodeStateLayoutOnce(options) {
43759
43844
  const key = decisionKey(options);
43760
43845
  const known = processDecisions.get(key);
43761
- if (known)
43762
- return known;
43846
+ if (known) {
43847
+ if (!options.requireExistingAuthority)
43848
+ return known;
43849
+ return known.then(async (decision2) => {
43850
+ const env = options.env ?? process.env;
43851
+ const home = options.home ?? homedir8();
43852
+ await preflightOpenCodeAuthority(getOpenCodeConfigDir(env, home), env, home);
43853
+ return decision2;
43854
+ });
43855
+ }
43763
43856
  const decision = decideOpenCodeStateLayout(options);
43764
43857
  processDecisions.set(key, decision);
43765
43858
  decision.catch(() => {
@@ -43772,6 +43865,8 @@ function resetStateLayoutDecisionsForTests() {
43772
43865
  processDecisions.clear();
43773
43866
  }
43774
43867
  async function decidePiStateLayout(options) {
43868
+ if (options.requireExistingAuthority)
43869
+ await preflightExistingAuthority(options.paths, "pi", options.env ?? process.env);
43775
43870
  const registration = await registerNativePoolHolder({
43776
43871
  paths: options.paths,
43777
43872
  role: options.role,
@@ -44592,6 +44687,9 @@ export {
44592
44687
  CLAUDE_FABLE_MYTHOS_5_1_MODEL_SPECS,
44593
44688
  CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS,
44594
44689
  CLAUDE_FABLE_5_MODEL_ID,
44690
+ CLAUDE_FABLE_5_2_RELEASE_DATE,
44691
+ CLAUDE_FABLE_5_2_PRICING,
44692
+ CLAUDE_FABLE_5_2_MODEL_ID,
44595
44693
  CLAUDE_FABLE_5_1_MODEL_ID,
44596
44694
  CLAUDE_DUMP_COMMAND_NAME,
44597
44695
  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;
@@ -1,3 +1,4 @@
1
+ import { type StateLayout } from './state-layout-paths.ts';
1
2
  /** Claude Code's own opt-out: `0`/`false` turns gzip off, `1`/`true` forces it. */
2
3
  export declare const GZIP_REQUEST_BODIES_ENV = "CLAUDE_CODE_GZIP_REQUEST_BODIES";
3
4
  /** How long a persisted latch keeps gzip off. */
@@ -43,8 +44,8 @@ export declare class RequestGzipLatch {
43
44
  }
44
45
  /** One latch per storage path, shared by every send path in this process. */
45
46
  export declare function getRequestGzipLatch(path?: string): RequestGzipLatch;
46
- /** The latch file path: `<stem>-request-gzip.json` beside the account storage file. */
47
- export declare function getRequestGzipLatchPath(accountStoragePath: string): string;
47
+ /** The advisory latch starts empty in state-home; legacy and Pi keep their account-file sibling. */
48
+ export declare function getRequestGzipLatchPath(accountStoragePath: string, layout?: StateLayout): string;
48
49
  /** Decide, in Claude Code's order, whether this request body goes out gzipped. */
49
50
  export declare function decideRequestGzip(options: {
50
51
  url: string | URL;
@@ -16,7 +16,7 @@ import { type StateLayoutRecord } from './state-layout-record.ts';
16
16
  * checks, and the mandatory state-home registration. The release that ships
17
17
  * the move turns it on.
18
18
  */
19
- export declare const RELOCATION_MOVE_ENABLED = false;
19
+ export declare const RELOCATION_MOVE_ENABLED = true;
20
20
  /** Turn the move on or off for this process, or back to the default; tests only. */
21
21
  export declare function setRelocationMoveEnabledForTests(enabled: boolean | undefined): void;
22
22
  /**
@@ -41,6 +41,8 @@ export interface DecideStateLayoutOptions {
41
41
  role: HolderRole;
42
42
  env?: NodeJS.ProcessEnv;
43
43
  home?: string;
44
+ /** Read-only local migration check before registration; offline setup omits it. */
45
+ requireExistingAuthority?: boolean;
44
46
  /** Filesystem seam; `node:fs` for this platform otherwise. */
45
47
  fs?: StateLayoutFs;
46
48
  liveness?: HolderLiveness;
@@ -91,6 +93,8 @@ export type StateLayoutDecision = {
91
93
  * neither copy may be served safely; the process must then do no pool I/O
92
94
  * for the dataset. `RelocatedError` is never thrown here: a dataset moved by
93
95
  * a newer version of the same layout rules is served from its new folder.
96
+ * With `requireExistingAuthority`, an unmigrated local dataset refuses with
97
+ * `NativeAuthorityError` before locks, registration or relocation writes.
94
98
  */
95
99
  export declare function decideOpenCodeStateLayout(options: DecideStateLayoutOptions): Promise<StateLayoutDecision>;
96
100
  /**
@@ -112,6 +116,9 @@ export declare function resetStateLayoutDecisionsForTests(): void;
112
116
  export declare function decidePiStateLayout(options: {
113
117
  paths: NativePoolPaths;
114
118
  role: HolderRole;
119
+ env?: NodeJS.ProcessEnv;
120
+ /** Read-only local migration check before registration; offline setup omits it. */
121
+ requireExistingAuthority?: boolean;
115
122
  onLockEvent?: (event: NativeLockEvent) => void;
116
123
  liveness?: HolderLiveness;
117
124
  lockTimeoutMs?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "2.7.3",
3
+ "version": "2.9.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",