@cortexkit/opencode-anthropic-auth 1.22.0 → 1.23.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.
Files changed (68) hide show
  1. package/README.md +37 -20
  2. package/dist/billing-lineage.d.ts +51 -0
  3. package/dist/claustrum-enrollment-registry.d.ts +4 -0
  4. package/dist/cli.d.ts +2 -1
  5. package/dist/cli.js +89 -6
  6. package/dist/custody-dimensions.d.ts +36 -0
  7. package/dist/custody-enrollment.d.ts +14 -0
  8. package/dist/custody-live.d.ts +111 -0
  9. package/dist/custody-manifest-watcher.d.ts +16 -0
  10. package/dist/custody-mode.d.ts +186 -0
  11. package/dist/effort-history.d.ts +5 -1
  12. package/dist/fable-fallback.d.ts +1 -1
  13. package/dist/{index-926t2bzc.js → index-0jfsxyn9.js} +1 -1
  14. package/dist/index-1fq7h6yd.js +430 -0
  15. package/dist/{index-7f57ewkp.js → index-1gr8v4fn.js} +1 -1
  16. package/dist/index-797pmamn.js +2 -0
  17. package/dist/{index-bx5hsgf8.js → index-8y2t4mwz.js} +2 -2
  18. package/dist/index-a5d6v3ba.js +5 -0
  19. package/dist/index-n96q8pks.js +2 -0
  20. package/dist/index-xxhyhp98.js +2 -0
  21. package/dist/index-xzbhzz0a.js +2 -0
  22. package/dist/index-z7gfdyv3.js +1 -0
  23. package/dist/index.js +27 -22
  24. package/dist/local-login.d.ts +64 -0
  25. package/dist/{logger-jrkranbz.js → logger-kk9vyem9.js} +1 -1
  26. package/dist/prime-manager-registry.d.ts +5 -1
  27. package/dist/rpc/notifications.d.ts +3 -3
  28. package/dist/rpc/port-file.js +1 -1
  29. package/dist/rpc/protocol.d.ts +9 -2
  30. package/dist/rpc/protocol.js +1 -1
  31. package/dist/rpc/rpc-client.d.ts +1 -1
  32. package/dist/rpc/rpc-client.js +1 -1
  33. package/dist/rpc/rpc-dir.js +1 -1
  34. package/dist/rpc/server-registry.d.ts +10 -0
  35. package/dist/setup/activation.d.ts +7 -0
  36. package/dist/setup/claustrum.d.ts +26 -0
  37. package/dist/setup/command-runner.d.ts +2 -0
  38. package/dist/setup/command.d.ts +8 -0
  39. package/dist/setup/detect.d.ts +5 -0
  40. package/dist/setup/jsonc.d.ts +9 -0
  41. package/dist/setup/opencode-config.d.ts +18 -0
  42. package/dist/setup/paths.d.ts +15 -0
  43. package/dist/setup/pi.d.ts +8 -0
  44. package/dist/setup/process-fence.d.ts +14 -0
  45. package/dist/setup/types.d.ts +37 -0
  46. package/dist/sidebar-state.d.ts +3 -1
  47. package/dist/sidebar-state.js +1 -1
  48. package/dist/transform.d.ts +5 -1
  49. package/dist/tui/command-dialogs.d.ts +27 -2
  50. package/dist/tui-preferences.js +2 -2
  51. package/package.json +10 -5
  52. package/src/rpc/notifications.ts +28 -24
  53. package/src/rpc/protocol.ts +18 -2
  54. package/src/rpc/rpc-client.ts +1 -1
  55. package/src/rpc/rpc-server.ts +18 -5
  56. package/src/rpc/server-registry.ts +61 -0
  57. package/src/sidebar-state.ts +26 -2
  58. package/src/tui/command-dialogs.tsx +273 -68
  59. package/src/tui-compiled/rpc/protocol.ts +18 -2
  60. package/src/tui-compiled/rpc/rpc-client.ts +1 -1
  61. package/src/tui-compiled/sidebar-state.ts +26 -2
  62. package/src/tui-compiled/tui/command-dialogs.tsx +215 -61
  63. package/src/tui-compiled/tui.tsx +1 -0
  64. package/src/tui.tsx +1 -0
  65. package/dist/index-8aga2zwv.js +0 -4
  66. package/dist/index-cgez4m0h.js +0 -2
  67. package/dist/index-d3f8g6ve.js +0 -428
  68. package/dist/index-sh51yqxs.js +0 -2
@@ -0,0 +1,111 @@
1
+ import * as core from '@cortexkit/anthropic-auth-core';
2
+ import { type ClaustrumTakeoverPlan, type CustodyCacheCredential, type ExecuteClaustrumTakeoverDeps } from './custody-mode.ts';
3
+ type Lock = {
4
+ release: () => Promise<void>;
5
+ };
6
+ type RawCacheCredential = core.ClaustrumCredential | CustodyCacheCredential;
7
+ type LiveRoute = {
8
+ id: string;
9
+ label?: string;
10
+ type: string;
11
+ enabled?: boolean;
12
+ local?: unknown;
13
+ claustrumHandle?: string;
14
+ };
15
+ type ClaustrumTakeoverCommandDeps = {
16
+ storagePath: string;
17
+ loadStorage: () => Promise<core.AccountStorage | null>;
18
+ getCache: () => Promise<{
19
+ get: (handle: string, minTtlMs?: number) => Promise<RawCacheCredential>;
20
+ } | null>;
21
+ latestGetAuth?: () => Promise<unknown>;
22
+ now: () => number;
23
+ fallbackManager?: Pick<core.FallbackAccountManager, 'withAccountRefreshLock'>;
24
+ refreshManifest: () => Promise<void>;
25
+ debug?: (message: string) => void;
26
+ };
27
+ export declare function runClaustrumTakeoverCommand(deps: ClaustrumTakeoverCommandDeps, mode: 'local' | 'claustrum'): Promise<{
28
+ text: string;
29
+ }>;
30
+ export declare function createLiveCustodyDeps(input: {
31
+ storagePath: string;
32
+ cache: {
33
+ get: (handle: string, minTtlMs?: number) => Promise<RawCacheCredential>;
34
+ };
35
+ latestGetAuth: () => Promise<unknown>;
36
+ now: number | (() => number);
37
+ fallbackManager?: Pick<core.FallbackAccountManager, 'withAccountRefreshLock'>;
38
+ storage?: core.AccountStorage | null;
39
+ writeManifestEntryLocked?: typeof core.writeCustodyHandleManifestEntryLocked;
40
+ debug?: (message: string) => void;
41
+ }): {
42
+ hostAuth: {
43
+ get: () => Promise<unknown>;
44
+ };
45
+ readonly manifestPath: string;
46
+ readBindings(routes: LiveRoute[]): Promise<{
47
+ accountId: string;
48
+ label: string;
49
+ handle: string;
50
+ credentialId: string;
51
+ source: "legacy" | "manifest";
52
+ }[]>;
53
+ cache: {
54
+ get: (handle: string, options: {
55
+ minTtlMs: number;
56
+ }) => Promise<CustodyCacheCredential>;
57
+ };
58
+ preflightInput(main: Pick<LiveRoute, 'id' | 'label' | 'enabled'>, fallbacks: LiveRoute[]): Promise<{
59
+ now: number;
60
+ storage: core.AccountStorage | null;
61
+ main: Pick<LiveRoute, "enabled" | "id" | "label">;
62
+ fallbacks: {
63
+ id: string;
64
+ label?: string;
65
+ type: string;
66
+ enabled?: boolean;
67
+ claustrumHandle?: string;
68
+ local: {};
69
+ }[];
70
+ hostAuth: {
71
+ get: () => Promise<unknown>;
72
+ };
73
+ bindings: {
74
+ accountId: string;
75
+ label: string;
76
+ handle: string;
77
+ credentialId: string;
78
+ source: "legacy" | "manifest";
79
+ }[];
80
+ cache: {
81
+ get: (handle: string, options: {
82
+ minTtlMs: number;
83
+ }) => Promise<CustodyCacheCredential>;
84
+ };
85
+ debug: ((message: string) => void) | undefined;
86
+ }>;
87
+ locks: {
88
+ storagePath: string;
89
+ readonly manifestPath: string;
90
+ acquireTransition: ({ name, path }: {
91
+ name: string;
92
+ path: string;
93
+ }) => Promise<{
94
+ release: () => Promise<void>;
95
+ assertOwned: () => Promise<void>;
96
+ } | null>;
97
+ acquireManifest: ({ path }: {
98
+ path: string;
99
+ }) => Promise<Lock>;
100
+ acquireRefresh: ({ name, path }: {
101
+ name: string;
102
+ path: string;
103
+ }) => Promise<Lock> | Promise<{
104
+ release: () => Promise<void>;
105
+ assertOwned: () => Promise<void>;
106
+ } | null>;
107
+ withFallbackRefreshLock: <T>(accountId: string, fn: () => Promise<T>) => Promise<T>;
108
+ };
109
+ takeoverDeps(plan: ClaustrumTakeoverPlan): ExecuteClaustrumTakeoverDeps;
110
+ };
111
+ export {};
@@ -0,0 +1,16 @@
1
+ import { watch } from 'node:fs';
2
+ type Listener = () => void | Promise<void>;
3
+ type WatchFactory = typeof watch;
4
+ export declare function adoptCustodyManifestWatcher(manifestPath: string, listener: Listener, options?: {
5
+ watchImpl?: WatchFactory;
6
+ setTimeoutImpl?: typeof setTimeout;
7
+ clearTimeoutImpl?: typeof clearTimeout;
8
+ pollSetTimeoutImpl?: typeof setTimeout;
9
+ pollClearTimeoutImpl?: typeof clearTimeout;
10
+ debounceMs?: number;
11
+ pollIntervalMs?: number;
12
+ onError?: (error: unknown) => void;
13
+ }): {
14
+ release: () => void;
15
+ };
16
+ export {};
@@ -0,0 +1,186 @@
1
+ type ModeDimension = 'L' | 'C';
2
+ type MainDimension = 'R' | 'T' | 'X';
3
+ type FallbackDimension = 'R' | 'T' | 'M';
4
+ type EvidenceDimension = 'V' | 'N' | 'unknown';
5
+ type Lock = {
6
+ release: () => Promise<void>;
7
+ };
8
+ export declare const OPENCODE_MAIN_OAUTH_REFRESH_LOCK = "opencode-main-oauth-refresh";
9
+ export declare const CUSTODY_PREFLIGHT_MIN_TTL_MS: number;
10
+ export type CustodyCacheCredential = {
11
+ credentialId?: string;
12
+ recordVersion: number;
13
+ access: string;
14
+ refresh: string;
15
+ expiresAt: number | null;
16
+ state: 'usable' | 'revoked' | 'reauth' | 'timeout';
17
+ };
18
+ export type ClaustrumTakeoverPlan = {
19
+ accounts: Array<{
20
+ id: string;
21
+ label: string;
22
+ handle: string;
23
+ credentialId: string;
24
+ recordVersion: number;
25
+ bindingPersisted: boolean;
26
+ localAuthFingerprint: string;
27
+ cacheCredential: CustodyCacheCredential;
28
+ }>;
29
+ toJSON: () => unknown;
30
+ toString: () => string;
31
+ };
32
+ export type CustodyPreflightRefusalReason = 'TAKEOVER_INCOMPLETE_MAIN_REAL' | 'TAKEOVER_INCOMPLETE_MAIN_BINDING' | 'binding_missing' | 'credential_revoked' | 'credential_reauth' | 'credential_timeout' | 'credential_unusable' | 'credential_identity_mismatch' | 'divergence_fenced' | 'TAKEOVER_INCOMPLETE_MAIN_SLOT' | 'local_credential_unavailable';
33
+ export type CustodyPreflightRefusal = {
34
+ label: string;
35
+ reason: CustodyPreflightRefusalReason;
36
+ guidance?: string;
37
+ };
38
+ export type MainCustodyRefusal = 'cold' | 'reauth' | 'takeover-incomplete' | 'identity-mismatch';
39
+ export declare class CustodyPreflightRefusedError extends Error {
40
+ readonly accountId: string;
41
+ readonly reason: CustodyPreflightRefusalReason;
42
+ readonly refusals: CustodyPreflightRefusal[];
43
+ readonly code = "custody_preflight_refused";
44
+ constructor(accountId: string, reason: CustodyPreflightRefusalReason, refusals?: CustodyPreflightRefusal[]);
45
+ toJSON(): {
46
+ ok: boolean;
47
+ code: string;
48
+ accountId: string;
49
+ reason: CustodyPreflightRefusalReason;
50
+ refusals: CustodyPreflightRefusal[];
51
+ };
52
+ }
53
+ export declare class CustodyStateMismatchError extends Error {
54
+ readonly verdict: string;
55
+ readonly dimensions: {
56
+ mode: ModeDimension;
57
+ main: MainDimension;
58
+ fallbacks: FallbackDimension;
59
+ evidence: EvidenceDimension;
60
+ };
61
+ readonly code = "custody_state_mismatch";
62
+ constructor(verdict: string, dimensions: {
63
+ mode: ModeDimension;
64
+ main: MainDimension;
65
+ fallbacks: FallbackDimension;
66
+ evidence: EvidenceDimension;
67
+ });
68
+ toJSON(): {
69
+ code: string;
70
+ verdict: string;
71
+ dimensions: {
72
+ mode: ModeDimension;
73
+ main: MainDimension;
74
+ fallbacks: FallbackDimension;
75
+ evidence: EvidenceDimension;
76
+ };
77
+ };
78
+ }
79
+ export declare class CustodyLockBusyError extends Error {
80
+ readonly lockName: string;
81
+ readonly code = "lock_busy";
82
+ constructor(lockName: string);
83
+ }
84
+ type PreflightRoute = {
85
+ id: string;
86
+ label?: string;
87
+ enabled?: boolean;
88
+ type: string;
89
+ local?: unknown;
90
+ };
91
+ type PreflightBinding = {
92
+ accountId: string;
93
+ label: string;
94
+ handle: string;
95
+ credentialId: string;
96
+ source?: 'manifest' | 'legacy';
97
+ };
98
+ export type PreflightClaustrumTakeoverInput = {
99
+ now: number;
100
+ storage: {
101
+ refresh?: {
102
+ refreshBeforeExpiryMinutes?: number;
103
+ };
104
+ claustrumDivergence?: Record<string, {
105
+ minimumRecordVersion: number;
106
+ observedAt?: number;
107
+ }>;
108
+ } | null;
109
+ main: Pick<PreflightRoute, 'id' | 'label' | 'enabled'>;
110
+ fallbacks: PreflightRoute[];
111
+ hostAuth: {
112
+ get: () => unknown | Promise<unknown>;
113
+ };
114
+ bindings: PreflightBinding[];
115
+ cache: {
116
+ get: (handle: string, options: {
117
+ minTtlMs: number;
118
+ }) => Promise<CustodyCacheCredential | {
119
+ state: string;
120
+ expiresAt?: number;
121
+ }>;
122
+ };
123
+ debug?: (message: string) => void;
124
+ };
125
+ export declare function preflightClaustrumTakeover(input: PreflightClaustrumTakeoverInput): Promise<ClaustrumTakeoverPlan>;
126
+ export declare function reconcileCustodyStartup(input: {
127
+ mode: ModeDimension;
128
+ main: MainDimension;
129
+ fallbacks: FallbackDimension;
130
+ evidence: EvidenceDimension;
131
+ } | {
132
+ mode: ModeDimension;
133
+ mainSlot: 'unknown';
134
+ fallbacks: FallbackDimension;
135
+ evidence: EvidenceDimension;
136
+ }): {
137
+ verdict: string;
138
+ provisional?: boolean;
139
+ };
140
+ export declare function acquireCustodyTransitionLocks(input: {
141
+ storagePath: string;
142
+ manifestPath: string;
143
+ fallbackAccountIds: string[];
144
+ acquireTransition: (input: {
145
+ name: 'claustrum-mode-transition';
146
+ path: string;
147
+ }) => Promise<Lock | null>;
148
+ acquireManifest: (input: {
149
+ path: string;
150
+ }) => Promise<Lock | null>;
151
+ acquireRefresh: (input: {
152
+ name: string;
153
+ path: string;
154
+ }) => Promise<Lock | null>;
155
+ }): Promise<{
156
+ release: () => Promise<void>;
157
+ }>;
158
+ export declare class CustodyTransitionError extends Error {
159
+ readonly stage: 'reverify_fingerprint' | 'write_manifest' | 'write_sidecar' | 'readback' | 'mode_commit' | 'post_commit_readback';
160
+ readonly accountId?: string | undefined;
161
+ readonly guidance?: string | undefined;
162
+ readonly code = "custody_transition_failed";
163
+ constructor(stage: 'reverify_fingerprint' | 'write_manifest' | 'write_sidecar' | 'readback' | 'mode_commit' | 'post_commit_readback', accountId?: string | undefined, guidance?: string | undefined);
164
+ toJSON(): {
165
+ code: string;
166
+ stage: "mode_commit" | "post_commit_readback" | "readback" | "reverify_fingerprint" | "write_manifest" | "write_sidecar";
167
+ accountId: string | undefined;
168
+ guidance: string | undefined;
169
+ };
170
+ }
171
+ export type ExecuteClaustrumTakeoverDeps = {
172
+ locks: Parameters<typeof acquireCustodyTransitionLocks>[0];
173
+ getLocalAuth: (accountId: string) => Promise<unknown>;
174
+ isCommitted: (plan: ClaustrumTakeoverPlan) => Promise<boolean>;
175
+ writeManifestBindings: (plan: ClaustrumTakeoverPlan) => Promise<void>;
176
+ writeSidecarAccount: (account: ClaustrumTakeoverPlan['accounts'][number]) => Promise<void>;
177
+ verifyTarget: (plan: ClaustrumTakeoverPlan) => Promise<boolean>;
178
+ verifyCommitted: (plan: ClaustrumTakeoverPlan) => Promise<boolean>;
179
+ setMode: (mode: 'claustrum' | 'local') => Promise<'changed' | 'unchanged'>;
180
+ };
181
+ export declare function executeClaustrumTakeover(plan: ClaustrumTakeoverPlan, deps: ExecuteClaustrumTakeoverDeps): Promise<'changed' | 'unchanged'>;
182
+ export declare function executeLocalExit(deps: {
183
+ path?: string;
184
+ setMode?: (mode: 'local') => Promise<'changed' | 'unchanged'>;
185
+ }): Promise<"changed" | "unchanged">;
186
+ export {};
@@ -1,11 +1,14 @@
1
1
  import { type AdaptiveEffort } from '@cortexkit/anthropic-auth-core';
2
2
  export declare const EFFORT_MARKER_PREFIX = "<cortexkit-internal-effort-v2 ";
3
+ export declare const EFFORT_ANCHOR_PREFIX = "<cortexkit-internal-effort-anchor-v1 ";
3
4
  export declare const EFFORT_PLAN_REQUEST_HEADER = "x-cortexkit-effort-plan";
4
5
  export type OpenCodeEffortMarkerPlan = {
5
6
  scope: string;
6
7
  baseline: AdaptiveEffort;
7
8
  markerCount: number;
8
9
  digest: string;
10
+ transitionTokens: readonly string[];
11
+ anchorToken?: string;
9
12
  sessionId: string;
10
13
  messageId: string;
11
14
  };
@@ -40,7 +43,7 @@ export declare function encodeOpenCodeEffortPlan(plan: OpenCodeEffortMarkerPlan)
40
43
  */
41
44
  export declare function markOpenCodeEffortTransitions(messages: MutableOpenCodeMessage[]): OpenCodeEffortMarkerPlan | null;
42
45
  /** Consume request-correlated markers and insert Anthropic effort system messages. */
43
- export declare function applyOpenCodeEffortMarkers(body: Record<string, unknown>, enabled: boolean, requestPlanHeader?: string): {
46
+ export declare function applyOpenCodeEffortMarkers(body: Record<string, unknown>, enabled: boolean, requestPlanHeader?: string, resolvedPlan?: OpenCodeEffortMarkerPlan): {
44
47
  found: number;
45
48
  inserted: number;
46
49
  };
@@ -53,6 +56,7 @@ export declare class OpenCodeEffortPlanTracker {
53
56
  messageId: string;
54
57
  headers: Record<string, string>;
55
58
  }): boolean;
59
+ resolveHeader(value: string | undefined): OpenCodeEffortMarkerPlan | undefined;
56
60
  private key;
57
61
  }
58
62
  export {};
@@ -27,7 +27,7 @@ export type FableFallbackPlan = {
27
27
  * the same classifier refusal shape and recovery period. Mythos has no
28
28
  * classifiers and Sonnet 5 is not flagged — both stay outside this gate.
29
29
  */
30
- export type RecoverableRefusalFamily = 'fable-5' | 'fable-5-1' | 'opus-5';
30
+ export type RecoverableRefusalFamily = 'fable-5' | 'fable-5-1' | 'opus-5' | 'opus-5-5';
31
31
  export declare function recoverableRefusalFamily(model: unknown): RecoverableRefusalFamily | null;
32
32
  export declare function isRecoverableRefusalModel(model: unknown): model is string;
33
33
  export declare class FableFallbackManager {
@@ -1,2 +1,2 @@
1
1
  import{mkdir as l,readdir as u,readFile as c,rename as p,unlink as m,writeFile as d}from"node:fs/promises";import{join as a}from"node:path";function f(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}async function b(t,r){await l(t,{recursive:!0});let s={...r,startedAt:Date.now()},e=a(t,`port-${r.pid}.json`),i=`${e}.${process.pid}.tmp`;return await d(i,JSON.stringify(s),{encoding:"utf8",mode:384}),await p(i,e),e}async function h(t,r){let s;try{s=await u(t)}catch{return null}let e=[];for(let n of s){if(!n.startsWith("port-")||!n.endsWith(".json"))continue;try{let o=JSON.parse(await c(a(t,n),"utf8"));if(Number.isFinite(o.port))if(f(o.pid))e.push(o);else m(a(t,n)).catch(()=>{})}catch{}}if(e.length===0)return null;let i=r&&r>=1?e.filter((n)=>n.pid===r):[];return(i.length>0?i:e).sort((n,o)=>o.startedAt-n.startedAt)[0]??null}
2
- export{b as nd,h as od};
2
+ export{b as oh,h as ph};