@codelia/storage 0.1.86 → 0.1.89
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.cjs +3118 -568
- package/dist/index.d.cts +449 -4
- package/dist/index.d.ts +449 -4
- package/dist/index.js +3048 -548
- package/package.json +8 -4
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,15 @@ import { StoragePaths, ResolveStorageOptions, RunEventStoreFactory, RunEventStor
|
|
|
3
3
|
export { ResolveStorageOptions, StorageLayout, StoragePathService, StoragePaths } from '@codelia/core';
|
|
4
4
|
import { GeneratedImageMetadata, ImageArtifactRef, ImageMediaType, AttachedImageMetadata, ImageArtifactMetadata, AttachmentRef, ApprovalMode, SandboxMode, GoalRecord, SubagentLineage, AgentMessage, TaskTerminationReason, TaskUsage } from '@codelia/shared-types';
|
|
5
5
|
|
|
6
|
+
type AtomicWriteOptions = {
|
|
7
|
+
mode?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Write UTF-8 text atomically via a sibling temp file, fsync, and rename.
|
|
11
|
+
* Ensures restrictive permissions (default 0o600) and cleans up on error.
|
|
12
|
+
*/
|
|
13
|
+
declare const writeFileAtomic: (targetPath: string, data: string, options?: AtomicWriteOptions) => Promise<void>;
|
|
14
|
+
|
|
6
15
|
type AttachmentWriteOptions = {
|
|
7
16
|
artifactId?: string;
|
|
8
17
|
ownerSessionId?: string;
|
|
@@ -66,6 +75,312 @@ declare class FileAttachmentStore implements AttachmentStore {
|
|
|
66
75
|
private readImage;
|
|
67
76
|
}
|
|
68
77
|
|
|
78
|
+
/** Bounded timeout for OAuth token refresh HTTP requests (spec §9.5). */
|
|
79
|
+
declare const DEFAULT_OAUTH_REFRESH_TIMEOUT_MS = 30000;
|
|
80
|
+
/**
|
|
81
|
+
* Interprocess lock wait deadline for credential stores (spec §9.5).
|
|
82
|
+
* Deliberately longer than DEFAULT_OAUTH_REFRESH_TIMEOUT_MS (and separate from
|
|
83
|
+
* ProjectsPolicyStore's 1s lock) so sibling processes wait for an in-flight
|
|
84
|
+
* token rotation instead of double-consuming a single-use refresh token.
|
|
85
|
+
*/
|
|
86
|
+
declare const DEFAULT_AUTH_LOCK_TIMEOUT_MS = 35000;
|
|
87
|
+
declare const authLockPathFor: (dir: string) => string;
|
|
88
|
+
type AuthLockOptions = {
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
pollMs?: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Run `fn` while holding both an in-process queue slot and an interprocess
|
|
94
|
+
* SQLite `BEGIN IMMEDIATE` lock at `lockPath`.
|
|
95
|
+
*/
|
|
96
|
+
declare const withAuthStoreLock: <T>(lockPath: string, fn: () => Promise<T>, options?: AuthLockOptions) => Promise<T>;
|
|
97
|
+
|
|
98
|
+
type CredentialBackendKind = "file" | "keyring";
|
|
99
|
+
type PendingCleanupSource = CredentialBackendKind | "legacy_file";
|
|
100
|
+
type StoreMigrationStatus = "pending" | "verified";
|
|
101
|
+
type PendingCleanupState = {
|
|
102
|
+
source_backend: PendingCleanupSource;
|
|
103
|
+
auth: boolean;
|
|
104
|
+
mcp_auth: boolean;
|
|
105
|
+
};
|
|
106
|
+
type AuthStorageState = {
|
|
107
|
+
version: 1;
|
|
108
|
+
status: "steady";
|
|
109
|
+
active_backend: CredentialBackendKind;
|
|
110
|
+
mcp_reauth_required?: string[];
|
|
111
|
+
} | {
|
|
112
|
+
version: 1;
|
|
113
|
+
status: "migrating";
|
|
114
|
+
active_backend: CredentialBackendKind;
|
|
115
|
+
target_backend: CredentialBackendKind;
|
|
116
|
+
stores: {
|
|
117
|
+
auth: StoreMigrationStatus;
|
|
118
|
+
mcp_auth: StoreMigrationStatus;
|
|
119
|
+
};
|
|
120
|
+
cleanup_pending?: PendingCleanupState;
|
|
121
|
+
mcp_reauth_required?: string[];
|
|
122
|
+
};
|
|
123
|
+
declare class CredentialConflictError extends Error {
|
|
124
|
+
readonly code = "credential_storage_conflict";
|
|
125
|
+
readonly store: "auth" | "mcp_auth";
|
|
126
|
+
constructor(store: "auth" | "mcp_auth", detail?: string);
|
|
127
|
+
}
|
|
128
|
+
declare const canonicalJsonStringify: (value: unknown) => string;
|
|
129
|
+
declare const canonicalJsonEqual: (left: unknown, right: unknown) => boolean;
|
|
130
|
+
declare const parseAuthStorageState: (text: string) => AuthStorageState;
|
|
131
|
+
declare const readAuthStorageState: (stateFile: string) => Promise<AuthStorageState | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Synchronous read of `storage-state.json` for approval-time checks.
|
|
134
|
+
* Returns `null` ONLY on ENOENT; throws on corrupt or unreadable markers.
|
|
135
|
+
*/
|
|
136
|
+
declare const readAuthStorageStateSync: (stateFile: string) => AuthStorageState | null;
|
|
137
|
+
declare const writeAuthStorageState: (stateFile: string, state: AuthStorageState) => Promise<void>;
|
|
138
|
+
type StoreMigrationSlot<T> = {
|
|
139
|
+
name: "auth" | "mcp_auth";
|
|
140
|
+
readSource: () => Promise<{
|
|
141
|
+
present: boolean;
|
|
142
|
+
normalized: T;
|
|
143
|
+
nonEmpty: boolean;
|
|
144
|
+
extraWarnings?: string[];
|
|
145
|
+
}>;
|
|
146
|
+
readDest: () => Promise<{
|
|
147
|
+
present: boolean;
|
|
148
|
+
normalized: T;
|
|
149
|
+
nonEmpty: boolean;
|
|
150
|
+
}>;
|
|
151
|
+
writeDest: (normalized: T) => Promise<void>;
|
|
152
|
+
verifyDest: (expected: T) => Promise<boolean>;
|
|
153
|
+
cleanupSource: () => Promise<void>;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Universal pre-write conflict detection and two-phase migration (spec §9.6).
|
|
157
|
+
* Must be called while holding the interprocess auth lock.
|
|
158
|
+
*/
|
|
159
|
+
declare const runTwoPhaseMigration: <TAuth, TMcp>(options: {
|
|
160
|
+
stateFile: string;
|
|
161
|
+
fromBackend: CredentialBackendKind;
|
|
162
|
+
toBackend: CredentialBackendKind;
|
|
163
|
+
cleanupSourceKind?: PendingCleanupSource;
|
|
164
|
+
authSlot: StoreMigrationSlot<TAuth>;
|
|
165
|
+
mcpSlot: StoreMigrationSlot<TMcp>;
|
|
166
|
+
existingMcpReauth?: string[];
|
|
167
|
+
/**
|
|
168
|
+
* When true (or when `fromBackend !== toBackend`), commit steady state on
|
|
169
|
+
* `toBackend` even if both source stores are absent/empty.
|
|
170
|
+
*/
|
|
171
|
+
commitSteadyIfEmpty?: boolean;
|
|
172
|
+
}) => Promise<{
|
|
173
|
+
migrated: boolean;
|
|
174
|
+
mcpReauthRequired: string[];
|
|
175
|
+
}>;
|
|
176
|
+
|
|
177
|
+
declare const CODELIA_AUTH_KEYCHAIN_SERVICE = "codelia.auth";
|
|
178
|
+
declare const CODELIA_MCP_AUTH_KEYCHAIN_SERVICE = "codelia.mcp-auth";
|
|
179
|
+
type KeychainProbeResult = {
|
|
180
|
+
available: true;
|
|
181
|
+
} | {
|
|
182
|
+
available: false;
|
|
183
|
+
reason: "unsupported_platform" | "keychain_locked" | "keychain_unavailable";
|
|
184
|
+
message: string;
|
|
185
|
+
};
|
|
186
|
+
type KeychainErrorCode = "keychain_locked" | "keychain_access_denied" | "keychain_unavailable" | "keychain_error";
|
|
187
|
+
declare class KeychainError extends Error {
|
|
188
|
+
readonly code: KeychainErrorCode;
|
|
189
|
+
constructor(code: KeychainErrorCode, message: string);
|
|
190
|
+
}
|
|
191
|
+
interface KeychainClient {
|
|
192
|
+
probe(): Promise<KeychainProbeResult>;
|
|
193
|
+
get(service: string, account: string): Promise<string | null>;
|
|
194
|
+
getSync(service: string, account: string, timeoutMs?: number): string | null;
|
|
195
|
+
set(service: string, account: string, value: string): Promise<void>;
|
|
196
|
+
delete(service: string, account: string): Promise<boolean>;
|
|
197
|
+
}
|
|
198
|
+
declare const keychainAccountForConfigDir: (configDir: string) => string;
|
|
199
|
+
type MacOsKeychainClientOptions = {
|
|
200
|
+
securityPath?: string;
|
|
201
|
+
helperPath?: string;
|
|
202
|
+
credentialsDir?: string;
|
|
203
|
+
};
|
|
204
|
+
declare class MacOsKeychainClient implements KeychainClient {
|
|
205
|
+
private readonly securityBinary;
|
|
206
|
+
private readonly hasCustomBinary;
|
|
207
|
+
constructor(options?: MacOsKeychainClientOptions);
|
|
208
|
+
private resolveBinary;
|
|
209
|
+
private requireBinary;
|
|
210
|
+
private runArgsAsync;
|
|
211
|
+
private runInteractiveBatchAsync;
|
|
212
|
+
private findRawAsync;
|
|
213
|
+
private findRawSync;
|
|
214
|
+
probe(): Promise<KeychainProbeResult>;
|
|
215
|
+
private readFullAsync;
|
|
216
|
+
get(service: string, account: string): Promise<string | null>;
|
|
217
|
+
getSync(service: string, account: string, timeoutMs?: number): string | null;
|
|
218
|
+
private sweepGenSlotBestEffort;
|
|
219
|
+
/**
|
|
220
|
+
* Exhaustively delete every possible chunk index (`0..MAX_CHUNKS-1`) in a
|
|
221
|
+
* fixed generation slot and propagate any non-not-found delete error.
|
|
222
|
+
*/
|
|
223
|
+
private deleteAllSlotChunksStrict;
|
|
224
|
+
private cleanupOldChunks;
|
|
225
|
+
private writeSingleChunk;
|
|
226
|
+
/**
|
|
227
|
+
* Multi-chunk write: alternates between fixed A/B slots (`a` and `b`) so
|
|
228
|
+
* existing credentials stay untouched until every staged chunk verifies via
|
|
229
|
+
* read-back AND crashed writes remain deterministically discoverable on logout.
|
|
230
|
+
*/
|
|
231
|
+
private writeMultiChunk;
|
|
232
|
+
set(service: string, account: string, value: string): Promise<void>;
|
|
233
|
+
private deleteSingleItem;
|
|
234
|
+
delete(service: string, account: string): Promise<boolean>;
|
|
235
|
+
/** Let macOS prompt the user to authorize reading each existing item. */
|
|
236
|
+
authorize(service: string, account: string): Promise<boolean>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
type ConfiguredAuthStorageMode = "auto" | "keyring" | "file";
|
|
240
|
+
type AuthStorageFallbackReason = "unsupported_platform" | "keychain_locked" | "keychain_unavailable";
|
|
241
|
+
type ResolvedCredentialBackend = {
|
|
242
|
+
configured: ConfiguredAuthStorageMode;
|
|
243
|
+
active: CredentialBackendKind;
|
|
244
|
+
state: "steady" | "migrating";
|
|
245
|
+
fallbackReason?: AuthStorageFallbackReason;
|
|
246
|
+
};
|
|
247
|
+
type CredentialStoreRuntimeOptions = {
|
|
248
|
+
paths?: StoragePaths;
|
|
249
|
+
lock?: AuthLockOptions;
|
|
250
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
251
|
+
keychain?: KeychainClient;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Resolve `auth.storage` strictly from `CODELIA_AUTH_STORAGE` or the global
|
|
255
|
+
* `config.json`. Project-level `.codelia/config.json` is never consulted.
|
|
256
|
+
*/
|
|
257
|
+
declare const resolveConfiguredAuthStorageMode: (paths: StoragePaths, overrideMode?: ConfiguredAuthStorageMode) => ConfiguredAuthStorageMode;
|
|
258
|
+
type StoreAdapter<T> = {
|
|
259
|
+
name: "auth" | "mcp_auth";
|
|
260
|
+
service: string;
|
|
261
|
+
filePath: (paths: StoragePaths) => string;
|
|
262
|
+
legacyFilePath: (paths: StoragePaths) => string;
|
|
263
|
+
empty: () => T;
|
|
264
|
+
isNonEmpty: (doc: T) => boolean;
|
|
265
|
+
parse: (text: string) => {
|
|
266
|
+
normalized: T;
|
|
267
|
+
sourceVersion: 1 | 2;
|
|
268
|
+
extraWarnings?: string[];
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Determine target backend and perform any needed two-phase forward/reverse
|
|
273
|
+
* migration under the interprocess lock (spec §9.1 & §9.6).
|
|
274
|
+
*/
|
|
275
|
+
declare const coordinateCredentialBackendUnlocked: <TAuth, TMcp>(options: {
|
|
276
|
+
paths: StoragePaths;
|
|
277
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
278
|
+
keychain?: KeychainClient;
|
|
279
|
+
authAdapter: StoreAdapter<TAuth>;
|
|
280
|
+
mcpAdapter: StoreAdapter<TMcp>;
|
|
281
|
+
}) => Promise<ResolvedCredentialBackend>;
|
|
282
|
+
declare const coordinateCredentialBackend: <TAuth, TMcp>(options: {
|
|
283
|
+
paths?: StoragePaths;
|
|
284
|
+
lock?: AuthLockOptions;
|
|
285
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
286
|
+
keychain?: KeychainClient;
|
|
287
|
+
authAdapter: StoreAdapter<TAuth>;
|
|
288
|
+
mcpAdapter: StoreAdapter<TMcp>;
|
|
289
|
+
}) => Promise<ResolvedCredentialBackend>;
|
|
290
|
+
type CredentialConflictResolutionStrategy = "keep_keyring" | "keep_file" | "keep_legacy" | "clear_all";
|
|
291
|
+
/**
|
|
292
|
+
* Remove a single store (`auth` or `mcp_auth`) across ALL credential locations
|
|
293
|
+
* (protected `credentials/`, legacy root, and Keychain if reachable) under an
|
|
294
|
+
* already-held interprocess lock. Used for explicit full logout (`clearAll`)
|
|
295
|
+
* so users are never trapped by a dual-store conflict when wiping credentials.
|
|
296
|
+
*/
|
|
297
|
+
declare const clearStoreAcrossAllLocationsUnlocked: <T>(options: {
|
|
298
|
+
paths: StoragePaths;
|
|
299
|
+
adapter: StoreAdapter<T>;
|
|
300
|
+
keychain?: KeychainClient;
|
|
301
|
+
}) => Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Explicit user-confirmed conflict resolution under the interprocess lock
|
|
304
|
+
* (spec §9.6). Validates the chosen authoritative source before deleting
|
|
305
|
+
* competing copies, or wipes all copies when `strategy === "clear_all"`.
|
|
306
|
+
*/
|
|
307
|
+
declare const resolveCredentialConflict: <TAuth, TMcp>(options: {
|
|
308
|
+
paths?: StoragePaths;
|
|
309
|
+
lock?: AuthLockOptions;
|
|
310
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
311
|
+
keychain?: KeychainClient;
|
|
312
|
+
authAdapter: StoreAdapter<TAuth>;
|
|
313
|
+
mcpAdapter: StoreAdapter<TMcp>;
|
|
314
|
+
strategy: CredentialConflictResolutionStrategy;
|
|
315
|
+
stores?: ReadonlyArray<"auth" | "mcp_auth">;
|
|
316
|
+
}) => Promise<{
|
|
317
|
+
active: CredentialBackendKind;
|
|
318
|
+
resolvedStores: Array<"auth" | "mcp_auth">;
|
|
319
|
+
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Non-mutating inspection for `auth.status` (spec §9.7).
|
|
322
|
+
* Never leaks secrets and surfaces conflict / locked-keychain / migration state.
|
|
323
|
+
*/
|
|
324
|
+
declare const inspectCredentialStorageStatus: <TAuth, TMcp>(options: {
|
|
325
|
+
paths?: StoragePaths;
|
|
326
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
327
|
+
keychain?: KeychainClient;
|
|
328
|
+
authAdapter: StoreAdapter<TAuth>;
|
|
329
|
+
mcpAdapter: StoreAdapter<TMcp>;
|
|
330
|
+
/** Invoked only for an unambiguous, steady snapshot. Never serialized by storage. */
|
|
331
|
+
onReadableAuth?: (doc: TAuth) => void;
|
|
332
|
+
}) => Promise<{
|
|
333
|
+
configured: ConfiguredAuthStorageMode;
|
|
334
|
+
active: CredentialBackendKind;
|
|
335
|
+
state: "steady" | "migrating" | "conflict";
|
|
336
|
+
fallbackReason?: AuthStorageFallbackReason;
|
|
337
|
+
mcpReauthRequired: string[];
|
|
338
|
+
conflictStores: Array<"auth" | "mcp_auth">;
|
|
339
|
+
unreadableStores: Array<"auth" | "mcp_auth" | "storage_state">;
|
|
340
|
+
keychainIssue?: "keychain_locked" | "keychain_access_denied" | "keychain_unavailable";
|
|
341
|
+
}>;
|
|
342
|
+
|
|
343
|
+
type OAuthTokens = {
|
|
344
|
+
access_token: string;
|
|
345
|
+
refresh_token: string;
|
|
346
|
+
expires_at: number;
|
|
347
|
+
account_id?: string;
|
|
348
|
+
};
|
|
349
|
+
type ApiKeyCredential = {
|
|
350
|
+
api_key: string;
|
|
351
|
+
/** The built-in API base at credential acquisition, when known. */
|
|
352
|
+
api_base?: string;
|
|
353
|
+
};
|
|
354
|
+
type ProviderAuth = ({
|
|
355
|
+
method: "api_key";
|
|
356
|
+
} & ApiKeyCredential) | {
|
|
357
|
+
method: "oauth";
|
|
358
|
+
oauth: OAuthTokens;
|
|
359
|
+
};
|
|
360
|
+
/** Legacy v1 view retained for callers expecting single-method provider entries. */
|
|
361
|
+
type AuthFile = {
|
|
362
|
+
version: 1;
|
|
363
|
+
providers: Record<string, ProviderAuth>;
|
|
364
|
+
};
|
|
365
|
+
type ProviderAuthV2 = {
|
|
366
|
+
chat_method?: "api_key" | "oauth";
|
|
367
|
+
credentials: {
|
|
368
|
+
api_key?: ApiKeyCredential;
|
|
369
|
+
oauth?: OAuthTokens;
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
type AuthFileV2 = {
|
|
373
|
+
version: 2;
|
|
374
|
+
providers: Record<string, ProviderAuthV2>;
|
|
375
|
+
};
|
|
376
|
+
declare const AUTH_VERSION_V1: 1;
|
|
377
|
+
declare const AUTH_VERSION_V2: 2;
|
|
378
|
+
declare const parseAuthDocument: (text: string) => {
|
|
379
|
+
normalized: AuthFileV2;
|
|
380
|
+
sourceVersion: 1 | 2;
|
|
381
|
+
};
|
|
382
|
+
declare const providerAuthStoreAdapter: StoreAdapter<AuthFileV2>;
|
|
383
|
+
|
|
69
384
|
declare function detectImageAttachmentType(bytes: Buffer): ImageMediaType | undefined;
|
|
70
385
|
/** Bounded header validation; attachment originals are not decoded or re-encoded. */
|
|
71
386
|
declare function validateImageAttachment(bytes: Buffer, mediaType: ImageMediaType): {
|
|
@@ -89,14 +404,84 @@ type McpOAuthTokens = {
|
|
|
89
404
|
client_id?: string;
|
|
90
405
|
client_secret?: string;
|
|
91
406
|
};
|
|
407
|
+
type McpServerAuthBinding = {
|
|
408
|
+
/** Canonical MCP server / resource URI. */
|
|
409
|
+
resource_uri: string;
|
|
410
|
+
/** Canonical OAuth authorization server issuer (when known). */
|
|
411
|
+
issuer?: string;
|
|
412
|
+
/** Canonical OAuth token endpoint (when known). */
|
|
413
|
+
token_endpoint?: string;
|
|
414
|
+
/** OAuth client ID bound to the token (when known). */
|
|
415
|
+
client_id?: string;
|
|
416
|
+
};
|
|
417
|
+
type McpBoundServerAuth = {
|
|
418
|
+
binding: McpServerAuthBinding;
|
|
419
|
+
tokens: McpOAuthTokens;
|
|
420
|
+
};
|
|
92
421
|
type McpAuthFile = {
|
|
93
|
-
version:
|
|
94
|
-
servers: Record<string,
|
|
422
|
+
version: 2;
|
|
423
|
+
servers: Record<string, McpBoundServerAuth>;
|
|
424
|
+
};
|
|
425
|
+
declare const MCP_AUTH_VERSION: 2;
|
|
426
|
+
/**
|
|
427
|
+
* Canonicalize an HTTP(S) URI for MCP resource and token endpoint comparisons.
|
|
428
|
+
* Strips fragments, normalizes scheme/host casing, and drops default ports.
|
|
429
|
+
*/
|
|
430
|
+
declare const canonicalizeMcpUri: (raw: string) => string;
|
|
431
|
+
declare const deriveMcpIssuer: (options: {
|
|
432
|
+
issuer?: string;
|
|
433
|
+
tokenUrl?: string;
|
|
434
|
+
authorizationUrl?: string;
|
|
435
|
+
}) => string | undefined;
|
|
436
|
+
declare const buildMcpAuthBinding: (options: {
|
|
437
|
+
resourceUri: string;
|
|
438
|
+
issuer?: string;
|
|
439
|
+
tokenEndpoint?: string;
|
|
440
|
+
clientId?: string;
|
|
441
|
+
}) => McpServerAuthBinding;
|
|
442
|
+
/**
|
|
443
|
+
* Verify that a stored MCP token binding matches the currently resolved server
|
|
444
|
+
* endpoint, OAuth issuer, token endpoint, and client ID (spec §9.4).
|
|
445
|
+
*
|
|
446
|
+
* Fail-closed: every binding attribute recorded on `stored` MUST be confirmed
|
|
447
|
+
* on `resolved`. Missing issuer, token_endpoint, or client_id on `resolved`
|
|
448
|
+
* when present on `stored` returns `false` and requires re-authentication.
|
|
449
|
+
*/
|
|
450
|
+
declare const mcpAuthBindingMatches: (stored: McpServerAuthBinding, resolved: McpServerAuthBinding) => boolean;
|
|
451
|
+
declare const parseMcpAuthDocument: (text: string) => {
|
|
452
|
+
normalized: McpAuthFile;
|
|
453
|
+
sourceVersion: 1 | 2;
|
|
454
|
+
droppedLegacyServers: string[];
|
|
455
|
+
};
|
|
456
|
+
declare const mcpAuthStoreAdapter: StoreAdapter<McpAuthFile>;
|
|
457
|
+
type McpAuthStoreOptions = {
|
|
458
|
+
lock?: AuthLockOptions;
|
|
459
|
+
storageMode?: ConfiguredAuthStorageMode;
|
|
460
|
+
keychain?: KeychainClient;
|
|
95
461
|
};
|
|
96
462
|
declare class McpAuthStore {
|
|
97
463
|
private readonly paths;
|
|
98
|
-
|
|
464
|
+
private readonly lockOptions?;
|
|
465
|
+
private readonly storageMode?;
|
|
466
|
+
private readonly keychain;
|
|
467
|
+
constructor(paths?: StoragePaths, options?: McpAuthStoreOptions);
|
|
468
|
+
private lockPath;
|
|
469
|
+
private keychainAccount;
|
|
470
|
+
private resolveBackendUnlocked;
|
|
471
|
+
private recordDroppedLegacyServers;
|
|
472
|
+
private readFromBackend;
|
|
473
|
+
private clearReauthenticatedServers;
|
|
474
|
+
private writeToBackend;
|
|
475
|
+
/**
|
|
476
|
+
* Load normalized v2 MCP auth from the active backend (macOS Keychain or
|
|
477
|
+
* protected `credentials/` file), running safe two-phase migration if needed.
|
|
478
|
+
*/
|
|
99
479
|
load(): Promise<McpAuthFile>;
|
|
480
|
+
/**
|
|
481
|
+
* Reload, mutate, and atomically save under the interprocess auth lock.
|
|
482
|
+
* Skips writing if the serialized document did not change.
|
|
483
|
+
*/
|
|
484
|
+
update<T>(mutate: (auth: McpAuthFile) => T | Promise<T>): Promise<T>;
|
|
100
485
|
save(auth: McpAuthFile): Promise<void>;
|
|
101
486
|
}
|
|
102
487
|
|
|
@@ -371,6 +756,15 @@ declare class SessionStoreWriterImpl implements SessionStore {
|
|
|
371
756
|
append(record: SessionRecord): Promise<void>;
|
|
372
757
|
}
|
|
373
758
|
|
|
759
|
+
type SqliteAdapter = {
|
|
760
|
+
exec: (sql: string) => void;
|
|
761
|
+
close: () => void;
|
|
762
|
+
run: (sql: string, params?: unknown[]) => void;
|
|
763
|
+
get: <T>(sql: string, params?: unknown[]) => T | undefined;
|
|
764
|
+
all: <T>(sql: string, params?: unknown[]) => T[];
|
|
765
|
+
};
|
|
766
|
+
declare const openSqlite: (filename: string) => Promise<SqliteAdapter>;
|
|
767
|
+
|
|
374
768
|
type TaskState = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
375
769
|
type TaskKind = "shell" | "subagent";
|
|
376
770
|
type TaskWorkspaceMode = "live_workspace" | "worktree";
|
|
@@ -475,4 +869,55 @@ declare class ToolOutputCacheStoreImpl implements ToolOutputCacheStore {
|
|
|
475
869
|
private resolvePath;
|
|
476
870
|
}
|
|
477
871
|
|
|
478
|
-
|
|
872
|
+
declare const isWithinPath: (root: string, target: string) => boolean;
|
|
873
|
+
declare const canonicalPathOrResolvedSync: (target: string) => string;
|
|
874
|
+
declare const isSameConfigFilePath: (leftPath: string, rightPath: string) => boolean;
|
|
875
|
+
declare const isCanonicalHomeWorkspaceSync: (workspace: string) => boolean;
|
|
876
|
+
declare const verifyOwnedAncestors: (directory: string, uid: number, errorMessage?: string) => Promise<void>;
|
|
877
|
+
declare const verifyOwnedAncestorsSync: (directory: string, uid: number, errorMessage?: string) => void;
|
|
878
|
+
type VerifyStorageLocationParams = {
|
|
879
|
+
workspace: string;
|
|
880
|
+
configured: string;
|
|
881
|
+
resolved: string;
|
|
882
|
+
relativePath?: string;
|
|
883
|
+
reservedOverride?: string;
|
|
884
|
+
errorMessage?: string;
|
|
885
|
+
redirectErrorMessage?: string;
|
|
886
|
+
};
|
|
887
|
+
declare const verifyUserStorageLocation: ({ workspace, configured, resolved, relativePath, reservedOverride, errorMessage, redirectErrorMessage, }: VerifyStorageLocationParams) => Promise<{
|
|
888
|
+
insideWorkspace: boolean;
|
|
889
|
+
}>;
|
|
890
|
+
declare const verifyUserStorageLocationSync: ({ workspace, configured, resolved, relativePath, reservedOverride, errorMessage, redirectErrorMessage, }: VerifyStorageLocationParams) => {
|
|
891
|
+
insideWorkspace: boolean;
|
|
892
|
+
};
|
|
893
|
+
/**
|
|
894
|
+
* Check whether `configPath` can be trusted as a user-global config file for
|
|
895
|
+
* `workingDir` (for example, when deciding MCP `trustedService`).
|
|
896
|
+
*
|
|
897
|
+
* Files outside `workingDir` are trusted as global. Files inside `workingDir`
|
|
898
|
+
* are trusted only when `workingDir` is the canonical home directory and
|
|
899
|
+
* `configPath` is the owner-verified, non-redirected default reserved
|
|
900
|
+
* `config.json` for the active layout.
|
|
901
|
+
*/
|
|
902
|
+
declare const isTrustedGlobalConfigLocationSync: (workingDir: string, configPath: string) => boolean;
|
|
903
|
+
|
|
904
|
+
declare const resolveWindowsSystem32Dir: (env?: NodeJS.ProcessEnv) => string;
|
|
905
|
+
type WindowsAclRunnerOptions = {
|
|
906
|
+
cwd?: string;
|
|
907
|
+
env?: NodeJS.ProcessEnv;
|
|
908
|
+
};
|
|
909
|
+
type WindowsAclRunner = (file: string, args: readonly string[], options?: WindowsAclRunnerOptions) => Promise<{
|
|
910
|
+
stdout: string;
|
|
911
|
+
stderr: string;
|
|
912
|
+
}>;
|
|
913
|
+
declare const enforceWindowsOwnerOnlyDacl: (dirPath: string, runner?: WindowsAclRunner, env?: NodeJS.ProcessEnv) => Promise<void>;
|
|
914
|
+
/** Verify a Windows credential read without creating or repairing files. */
|
|
915
|
+
declare const verifyWindowsCredentialFileAcl: (filePath: string, legacy?: boolean) => Promise<boolean>;
|
|
916
|
+
declare const verifyWindowsCredentialFileAclSync: (filePath: string, legacy?: boolean) => boolean;
|
|
917
|
+
/** Secure the dedicated credential directory before creating any auth files. */
|
|
918
|
+
declare const ensureCredentialsDirectory: (credentialsDir: string, options?: {
|
|
919
|
+
platform?: NodeJS.Platform;
|
|
920
|
+
windowsRunner?: WindowsAclRunner;
|
|
921
|
+
}) => Promise<void>;
|
|
922
|
+
|
|
923
|
+
export { AUTH_VERSION_V1, AUTH_VERSION_V2, type ApiKeyCredential, type AtomicWriteOptions, type AttachmentStore, type AuthFile, type AuthFileV2, type AuthLockOptions, type AuthStorageFallbackReason, type AuthStorageState, CODELIA_AUTH_KEYCHAIN_SERVICE, CODELIA_MCP_AUTH_KEYCHAIN_SERVICE, type ConfiguredAuthStorageMode, type CredentialBackendKind, CredentialConflictError, type CredentialConflictResolutionStrategy, type CredentialStoreRuntimeOptions, DEFAULT_AUTH_LOCK_TIMEOUT_MS, DEFAULT_OAUTH_REFRESH_TIMEOUT_MS, FileAttachmentStore, type GoalRunClaim, IMAGE_MAX_BYTES, ImageArtifactStore, type KeychainClient, KeychainError, type KeychainProbeResult, MCP_AUTH_VERSION, MacOsKeychainClient, type MacOsKeychainClientOptions, type McpAuthFile, McpAuthStore, type McpAuthStoreOptions, type McpBoundServerAuth, type McpOAuthTokens, type McpServerAuthBinding, type OAuthTokens, type PendingCleanupSource, type PendingCleanupState, type ProjectsPolicyFile, ProjectsPolicyStore, type ProviderAuth, type ProviderAuthV2, RUN_LOG_RETENTION_MS, type ResolvedCredentialBackend, RunEventStoreFactoryImpl, type RunLogCleanupResult, SessionGoalStore, type SessionRunEntry, type SessionRunRecorder, SessionStateStoreImpl, SessionStoreWriterImpl, type SqliteAdapter, StoragePathServiceImpl, type StoreAdapter, type StoreMigrationSlot, type StoreMigrationStatus, type StoredAttachment, type StoredSessionGoal, type TaskArtifact, type TaskKind, type TaskRecord, TaskRegistryStore, type TaskResult, type TaskState, type TaskTruncatedOutput, type TaskWorkspaceMode, ToolOutputCacheStoreImpl, type WindowsAclRunner, type WindowsAclRunnerOptions, authLockPathFor, buildMcpAuthBinding, canonicalJsonEqual, canonicalJsonStringify, canonicalPathOrResolvedSync, canonicalizeMcpUri, cleanupRunLogs, clearStoreAcrossAllLocationsUnlocked, coordinateCredentialBackend, coordinateCredentialBackendUnlocked, createAttachmentId, deriveMcpIssuer, detectImageAttachmentType, enforceWindowsOwnerOnlyDacl, ensureCredentialsDirectory, ensureStorageDirs, getProcessIdentity, inspectCredentialStorageStatus, isAttachmentId, isCanonicalHomeWorkspaceSync, isSameConfigFilePath, isTrustedGlobalConfigLocationSync, isWithinPath, keychainAccountForConfigDir, mcpAuthBindingMatches, mcpAuthStoreAdapter, openSqlite, parseAuthDocument, parseAuthStorageState, parseMcpAuthDocument, providerAuthStoreAdapter, readAuthStorageState, readAuthStorageStateSync, readRunLogLines, resolveConfiguredAuthStorageMode, resolveCredentialConflict, resolveIndexedRunLog, resolveRunLogPath, resolveStoragePaths, resolveWindowsSystem32Dir, runTwoPhaseMigration, scanSessionRunLogs, validateImageAttachment, validateImagePng, verifyOwnedAncestors, verifyOwnedAncestorsSync, verifyUserStorageLocation, verifyUserStorageLocationSync, verifyWindowsCredentialFileAcl, verifyWindowsCredentialFileAclSync, withAuthStoreLock, writeAuthStorageState, writeFileAtomic };
|