@cortexkit/anthropic-auth-core 2.4.0 → 2.4.2
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/holder-registry.d.ts +88 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23001 -20075
- package/dist/layout-fence.d.ts +65 -0
- package/dist/native-local-runtime-readers.d.ts +1 -1
- package/dist/native-vault-paths.d.ts +5 -6
- package/dist/pool-paths.d.ts +6 -0
- package/dist/pool-store.d.ts +7 -0
- package/dist/relocation-guard.d.ts +13 -2
- package/dist/state-home-serving-guard.d.ts +84 -0
- package/dist/state-layout-decision.d.ts +126 -0
- package/dist/state-layout-errors.d.ts +65 -0
- package/dist/state-layout-io.d.ts +109 -0
- package/dist/state-layout-move.d.ts +253 -0
- package/dist/state-layout-paths.d.ts +28 -4
- package/dist/state-layout-record.d.ts +120 -0
- package/dist/state-layout-restore.d.ts +83 -0
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type NativeLockEvent } from './native-lock-observer.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type OwnerOnlyOptions } from './owner-only.ts';
|
|
3
|
+
import { type NativePoolPaths } from './pool-paths.ts';
|
|
3
4
|
import { RelocatedError } from './relocation-guard.ts';
|
|
5
|
+
import { StateLayoutRefusalError } from './state-layout-errors.ts';
|
|
4
6
|
/** The file, beside a dataset's files, that lists the processes using them. */
|
|
5
7
|
export declare const HOLDER_FILE_NAME = "anthropic-auth-holders.json";
|
|
6
8
|
/** Lock name on the holder file: lock file `<holder file>.holders.lock`. */
|
|
@@ -90,7 +92,14 @@ export declare const HOLDER_REGISTRATION_ERROR_MESSAGES: readonly string[];
|
|
|
90
92
|
* roster operations wrap what their hooks throw in their own error, which
|
|
91
93
|
* keeps the original as its `cause`, so the chain is followed a few levels.
|
|
92
94
|
*/
|
|
93
|
-
export declare function stateRefusalCause(error: unknown): RelocatedError | HolderRegistrationError | undefined;
|
|
95
|
+
export declare function stateRefusalCause(error: unknown): RelocatedError | HolderRegistrationError | StateLayoutRefusalError | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* The fixed message, naming no file or folder, to show for the relocation,
|
|
98
|
+
* registration or layout refusal behind `error`, or undefined when there is
|
|
99
|
+
* none. Hosts show it where their output may be shared; the refusal's own
|
|
100
|
+
* message and the log name the files.
|
|
101
|
+
*/
|
|
102
|
+
export declare function stateRefusalPublicMessage(error: unknown): string | undefined;
|
|
94
103
|
/** How liveness is read; tests replace it. */
|
|
95
104
|
export interface HolderLiveness {
|
|
96
105
|
pidAlive(pid: number): boolean;
|
|
@@ -106,6 +115,28 @@ export declare function processIncarnation(pid: number): Promise<string | null>;
|
|
|
106
115
|
* So pid reuse can keep a stale entry, but never clears a live one.
|
|
107
116
|
*/
|
|
108
117
|
export declare function holderEntryIsLive(entry: Pick<HolderEntry, 'pid' | 'incarnation'>, liveness?: HolderLiveness): Promise<boolean>;
|
|
118
|
+
export interface HolderFileContents {
|
|
119
|
+
/** Entries as found, including any this version doesn't understand. */
|
|
120
|
+
entries: unknown[];
|
|
121
|
+
}
|
|
122
|
+
/** An entry's pid and incarnation when it has a usable shape. */
|
|
123
|
+
export declare function holderEntryLiveness(value: unknown): Pick<HolderEntry, 'pid' | 'incarnation'> | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Read a holder file. Undefined when it is absent. A file that exists but
|
|
126
|
+
* doesn't parse throws: rewriting it would erase other processes' entries.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readHolderFile(path: string): Promise<HolderFileContents | undefined>;
|
|
129
|
+
/**
|
|
130
|
+
* Refuse dataset paths a caller chose itself, rather than the layout
|
|
131
|
+
* decision, when they reach into the state folder: paths resolved in the
|
|
132
|
+
* state-home layout, or with any dataset file in a folder anthropic-auth
|
|
133
|
+
* manages (holding `config-dir.json` or `layout.json`) or in a
|
|
134
|
+
* destination-shaped folder. Serving such files needs the decision's
|
|
135
|
+
* admission under the holder lock, which checks the move record; registering
|
|
136
|
+
* them as an ordinary `legacy` dataset would skip it. Throws
|
|
137
|
+
* `HolderRegistrationError('managed-folder')`, whose message is fixed.
|
|
138
|
+
*/
|
|
139
|
+
export declare function assertUnmanagedInjectedPaths(paths: NativePoolPaths): Promise<void>;
|
|
109
140
|
export interface RegisterNativePoolHolderOptions {
|
|
110
141
|
paths: NativePoolPaths;
|
|
111
142
|
role: HolderRole;
|
|
@@ -118,6 +149,18 @@ export interface RegisterNativePoolHolderOptions {
|
|
|
118
149
|
retryIntervalMs?: number;
|
|
119
150
|
liveness?: HolderLiveness;
|
|
120
151
|
now?: () => number;
|
|
152
|
+
/** How a missing folder is made owner-only; tests simulate Windows here. */
|
|
153
|
+
ownerOnly?: OwnerOnlyOptions;
|
|
154
|
+
/**
|
|
155
|
+
* `mandatory`: the entry is published in every holder file before the
|
|
156
|
+
* process serves, even before any dataset file exists there, and any
|
|
157
|
+
* failure to publish refuses with `HolderRegistrationError`. The layout
|
|
158
|
+
* decision passes it once moving is enabled (`unmovedRegistrationPolicy`).
|
|
159
|
+
* Without it, a failed write refuses only for an `explicit` or `pi`
|
|
160
|
+
* dataset with a file in a destination-shaped folder; every other failure
|
|
161
|
+
* is retried in the background.
|
|
162
|
+
*/
|
|
163
|
+
policy?: 'mandatory';
|
|
121
164
|
}
|
|
122
165
|
/** The outcome of a registration that did not refuse. */
|
|
123
166
|
export interface NativeHolderRegistration {
|
|
@@ -132,6 +175,34 @@ export interface NativeHolderRegistration {
|
|
|
132
175
|
/** Stop retrying. Published entries stay; later writers prune them once the pid is dead. */
|
|
133
176
|
close(): void;
|
|
134
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Create `dir` for a holder file when it is missing, readable by its owner
|
|
180
|
+
* only: `0700` on POSIX, and on Windows a protected owner-only DACL set by
|
|
181
|
+
* the native helper as the folder is created, along with any missing parent.
|
|
182
|
+
* An existing folder is left exactly as it is: it may be the user's own
|
|
183
|
+
* config folder, shared on purpose. On Windows a folder that another process
|
|
184
|
+
* created first is adopted only if it is owner-only; otherwise this throws.
|
|
185
|
+
*/
|
|
186
|
+
export declare function ensureHolderDirectory(dir: string, ownerOnly?: OwnerOnlyOptions): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Add `entry` to `holderFile`, pruning entries of dead processes, while the
|
|
189
|
+
* caller holds that file's `holders` lock. Writes nothing when a live entry
|
|
190
|
+
* for this process, kind and files is already there. A holder file that
|
|
191
|
+
* doesn't parse throws and is never overwritten.
|
|
192
|
+
*/
|
|
193
|
+
export declare function publishHolderEntryLocked(holderFile: string, entry: HolderEntry, options: {
|
|
194
|
+
liveness?: HolderLiveness;
|
|
195
|
+
assertOwned(): Promise<void>;
|
|
196
|
+
}): Promise<void>;
|
|
197
|
+
/** A holder entry for this process. */
|
|
198
|
+
export declare function buildHolderEntry(input: {
|
|
199
|
+
role: HolderRole;
|
|
200
|
+
kind: HolderKind;
|
|
201
|
+
identity: string | null;
|
|
202
|
+
files: readonly string[];
|
|
203
|
+
liveness?: HolderLiveness;
|
|
204
|
+
now?: () => number;
|
|
205
|
+
}): Promise<HolderEntry>;
|
|
135
206
|
/**
|
|
136
207
|
* Record, beside a dataset's files, that this process uses them, before the
|
|
137
208
|
* process's first pool I/O for that dataset. A later release reads these
|
|
@@ -142,7 +213,9 @@ export interface NativeHolderRegistration {
|
|
|
142
213
|
* dataset lies in a folder anthropic-auth manages (`HolderRegistrationError`
|
|
143
214
|
* with `managed-folder`).
|
|
144
215
|
*
|
|
145
|
-
* A failed write is handled by
|
|
216
|
+
* A failed write is handled by `options.policy`. With `mandatory` the call
|
|
217
|
+
* throws `HolderRegistrationError` and the process must not serve. Without
|
|
218
|
+
* it, by kind:
|
|
146
219
|
* - An `explicit` or `pi` dataset with a file in a destination-shaped folder
|
|
147
220
|
* (see `isDestinationShapedDirectory`) must be registered there, so the
|
|
148
221
|
* call throws `HolderRegistrationError` and the process must not serve it.
|
|
@@ -155,5 +228,17 @@ export interface NativeHolderRegistration {
|
|
|
155
228
|
* for data locks.
|
|
156
229
|
*/
|
|
157
230
|
export declare function registerNativePoolHolder(options: RegisterNativePoolHolderOptions): Promise<NativeHolderRegistration>;
|
|
231
|
+
/**
|
|
232
|
+
* Hand a registration that already failed once to the ordinary policy's
|
|
233
|
+
* background retry, for a caller that tried to publish `options`'s entry
|
|
234
|
+
* itself and may serve without it: log the failure at WARN (once per folder
|
|
235
|
+
* and process) and retry at most once a minute until it succeeds or `close()`
|
|
236
|
+
* is called. A retry that finds a relocation tombstone or a managed folder
|
|
237
|
+
* stops retrying; the relocation guards then refuse every later write.
|
|
238
|
+
*/
|
|
239
|
+
export declare function deferNativePoolHolderRegistration(options: RegisterNativePoolHolderOptions, failure: {
|
|
240
|
+
readonly directory: string;
|
|
241
|
+
readonly error: unknown;
|
|
242
|
+
}): NativeHolderRegistration;
|
|
158
243
|
/** Forget what this process has published; tests only. */
|
|
159
244
|
export declare function resetNativeHolderRegistryForTests(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -89,7 +89,10 @@ export * from './routing.ts';
|
|
|
89
89
|
export type { SseEvent, SseFramer, SseFramerOptions } from './sse.ts';
|
|
90
90
|
export { createSseFramer, DEFAULT_SSE_MAX_FRAME_BYTES, decodeSseFrame, isSseCandidateFrame, isTerminatedSseFrame, parseSseFrame, SseFrameTooLargeError, } from './sse.ts';
|
|
91
91
|
export * from './start.ts';
|
|
92
|
+
export * from './state-layout-decision.ts';
|
|
93
|
+
export * from './state-layout-errors.ts';
|
|
92
94
|
export * from './state-layout-paths.ts';
|
|
95
|
+
export * from './state-layout-restore.ts';
|
|
93
96
|
export * from './sticky-routing.ts';
|
|
94
97
|
export * from './thinking-binding.ts';
|
|
95
98
|
export * from './turn-end-note.ts';
|