@cortexkit/anthropic-auth-core 2.0.2 → 2.1.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.
- package/dist/accounts.d.ts +7 -1
- package/dist/cache1h.d.ts +2 -0
- package/dist/cachekeep-registry.d.ts +3 -0
- package/dist/cachekeep.d.ts +2 -0
- package/dist/cch.d.ts +19 -0
- package/dist/claude-code.d.ts +8 -2
- package/dist/claustrum-enrollment.d.ts +5 -1
- package/dist/constants.d.ts +15 -3
- package/dist/dump.d.ts +4 -0
- package/dist/fast.d.ts +2 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.js +29647 -25296
- package/dist/insula-quota.d.ts +25 -0
- package/dist/internal-types/auth-menu/terminal.d.ts +43 -0
- package/dist/internal-types/claustrum/availability.d.ts +89 -0
- package/dist/internal-types/claustrum/consumer.d.ts +172 -0
- package/dist/internal-types/claustrum/custody.d.ts +299 -0
- package/dist/internal-types/claustrum/enrollment.d.ts +164 -0
- package/dist/internal-types/claustrum/errors.d.ts +17 -0
- package/dist/internal-types/claustrum/host-slot.d.ts +39 -0
- package/dist/internal-types/claustrum/index.d.ts +21 -0
- package/dist/internal-types/claustrum/insula.d.ts +117 -0
- package/dist/internal-types/claustrum/interlock.d.ts +27 -0
- package/dist/internal-types/claustrum/roster.d.ts +221 -0
- package/dist/internal-types/claustrum/watch.d.ts +141 -0
- package/dist/internal-types/fs/refresh-file-lock.d.ts +8 -2
- package/dist/internal-types/quota/format.d.ts +43 -3
- package/dist/internal-types/quota/index.d.ts +3 -3
- package/dist/internal-types/quota/projection.d.ts +16 -0
- package/dist/internal-types/routing/admission.d.ts +93 -0
- package/dist/internal-types/routing/index.d.ts +8 -0
- package/dist/internal-types/routing/ordered.d.ts +47 -0
- package/dist/internal-types/routing/pins.d.ts +22 -0
- package/dist/internal-types/routing/sticky.d.ts +158 -0
- package/dist/internal-types/setup/command-error.d.ts +32 -0
- package/dist/internal-types/setup/command.d.ts +3 -0
- package/dist/internal-types/setup/detect.d.ts +6 -0
- package/dist/internal-types/setup/index.d.ts +6 -0
- package/dist/internal-types/setup/process-fence.d.ts +43 -0
- package/dist/internal-types/setup/register.d.ts +11 -0
- package/dist/internal-types/setup/types.d.ts +150 -0
- package/dist/internal-types/store/pool.d.ts +1 -1
- package/dist/internal-types/store/refresh-lock.d.ts +0 -1
- package/dist/logging.d.ts +2 -0
- package/dist/mid-conversation-output-config.d.ts +34 -2
- package/dist/migration-source.d.ts +2 -0
- package/dist/native-account-runtime.d.ts +9 -4
- package/dist/native-account-view.d.ts +19 -3
- package/dist/native-custody-activation.d.ts +1 -1
- package/dist/native-custody.d.ts +130 -0
- package/dist/native-enrollment-authority.d.ts +5 -1
- package/dist/native-host-auth-read.d.ts +2 -1
- package/dist/native-host-auth-write.d.ts +2 -0
- package/dist/native-menu-executor.d.ts +1 -1
- package/dist/native-migration.d.ts +25 -4
- package/dist/native-quota-observations.d.ts +26 -0
- package/dist/native-runtime.d.ts +5 -1
- package/dist/native-transient-account.d.ts +3 -4
- package/dist/native-ui.d.ts +2 -0
- package/dist/native-usage-publication.d.ts +5 -0
- package/dist/native-vault-invalidation.d.ts +9 -0
- package/dist/native-vault-runtime.d.ts +36 -3
- package/dist/network-errors.d.ts +1 -0
- package/dist/owner-only.d.ts +19 -0
- package/dist/pool-authority.d.ts +27 -8
- package/dist/pool-paths.d.ts +2 -0
- package/dist/provider-error.d.ts +34 -0
- package/dist/publication-rename.d.ts +11 -0
- package/dist/quota-manager.d.ts +21 -4
- package/dist/quotas.d.ts +31 -2
- package/dist/relay.d.ts +20 -0
- package/dist/request-gzip.d.ts +99 -0
- package/package.json +4 -4
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type PoolRow } from "./internal-types/store/index.js";
|
|
2
|
+
import type { NativeAccountSnapshot } from './native-account-view.ts';
|
|
2
3
|
import type { NativeCustodyInventory } from './native-custody.ts';
|
|
3
4
|
import { type NativeHostAuthWriteHooks } from './native-host-auth-write.ts';
|
|
4
5
|
import { type NativeRosterSeedInput, type NativeVaultRosterSeed } from './native-roster-seed.ts';
|
|
5
6
|
import { type NativeRuntimeState } from './native-runtime.ts';
|
|
6
|
-
import { type
|
|
7
|
+
import { type NativeEmptyInitJournal, type NativeLegacyMigrationJournal } from './pool-authority.ts';
|
|
7
8
|
import { type NativePoolPaths } from './pool-paths.ts';
|
|
8
9
|
import { createNativePoolStore } from './pool-store.ts';
|
|
9
10
|
export declare class NativeMigrationError extends Error {
|
|
10
|
-
readonly code: 'invalid-source' | 'unsafe-source' | 'consent-required' | 'primary-unverified' | 'migration-busy' | 'ownership-lost' | 'retirement-refused';
|
|
11
|
-
constructor(code: 'invalid-source' | 'unsafe-source' | 'consent-required' | 'primary-unverified' | 'migration-busy' | 'ownership-lost' | 'retirement-refused');
|
|
11
|
+
readonly code: 'invalid-source' | 'unsafe-source' | 'consent-required' | 'primary-unverified' | 'migration-busy' | 'ownership-lost' | 'pool-populated' | 'host-login-present' | 'settings-changed' | 'retirement-refused';
|
|
12
|
+
constructor(code: 'invalid-source' | 'unsafe-source' | 'consent-required' | 'primary-unverified' | 'migration-busy' | 'ownership-lost' | 'pool-populated' | 'host-login-present' | 'settings-changed' | 'retirement-refused');
|
|
12
13
|
}
|
|
13
14
|
export interface NativeMigrationCustody {
|
|
14
15
|
/** Use the host’s approved Claustrum token and account-list permission to discover accounts; never open the vault’s credential files. */
|
|
@@ -54,6 +55,26 @@ export interface NativeMigrationHooks {
|
|
|
54
55
|
hostWrite?: NativeHostAuthWriteHooks;
|
|
55
56
|
store?: Pick<Parameters<typeof createNativePoolStore>[0], 'onStep' | 'onLockStep'>;
|
|
56
57
|
}
|
|
58
|
+
/** Session pins and preferences do not establish account ownership. */
|
|
59
|
+
export declare function nativePoolHoldsAccountData({ paths, }: {
|
|
60
|
+
paths: NativePoolPaths;
|
|
61
|
+
}): Promise<boolean>;
|
|
62
|
+
/** Only enabled local OAuth rows can authorize local OAuth serving. */
|
|
63
|
+
export declare function snapshotHasServableLocalOAuth(snapshot: Pick<NativeAccountSnapshot, 'accounts'>): boolean;
|
|
64
|
+
export interface NativeEmptyInitOptions {
|
|
65
|
+
paths: NativePoolPaths;
|
|
66
|
+
routingDestinationPath: string;
|
|
67
|
+
processFence: () => Promise<void>;
|
|
68
|
+
env: NodeJS.ProcessEnv;
|
|
69
|
+
}
|
|
70
|
+
export interface NativeEmptyInitHooks extends Pick<NativeMigrationHooks, 'onStep'> {
|
|
71
|
+
lockOptions?: {
|
|
72
|
+
ttlMs: number;
|
|
73
|
+
timeoutMs: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Establish local authority for a new OpenCode pool without reading legacy credentials. */
|
|
77
|
+
export declare function publishNativeEmptyInit(input: NativeEmptyInitOptions, hooks?: NativeEmptyInitHooks): Promise<NativeEmptyInitJournal>;
|
|
57
78
|
/** Preflight is read-only so setup can validate all selected hosts before any begin. */
|
|
58
79
|
export declare function prepareNativeMigration(input: NativeMigrationOptions): Promise<NativeMigrationPreflight>;
|
|
59
80
|
export declare function releaseNativeMigrationPreflight(token: NativeMigrationPreflight): void;
|
|
@@ -63,4 +84,4 @@ export declare function releaseNativeMigrationPreflight(token: NativeMigrationPr
|
|
|
63
84
|
*/
|
|
64
85
|
export declare function importedRuntimeProjection(paths: NativePoolPaths, store: ReturnType<typeof createNativePoolStore>, rows: PoolRow[]): Promise<unknown>;
|
|
65
86
|
/** Offline, crash-forward transaction. Native serving never calls this controller. */
|
|
66
|
-
export declare function runNativeMigration(input: NativeMigrationOptions, hooks?: NativeMigrationHooks): Promise<
|
|
87
|
+
export declare function runNativeMigration(input: NativeMigrationOptions, hooks?: NativeMigrationHooks): Promise<NativeLegacyMigrationJournal>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AccountStorage, type OAuthQuotaSnapshot } from './accounts.ts';
|
|
2
|
+
import type { NativeLocalPoolBinding } from './pool-binding.ts';
|
|
3
|
+
import type { QuotaEntry } from './quota-manager.ts';
|
|
4
|
+
export type NativeQuotaObservation = {
|
|
5
|
+
lineage: string;
|
|
6
|
+
accountUuid: string;
|
|
7
|
+
entry: QuotaEntry;
|
|
8
|
+
generalExhausted: boolean;
|
|
9
|
+
quotaErrorClearedAt?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function nativePollQuotaGenerallyExhausted(quota: OAuthQuotaSnapshot): boolean;
|
|
12
|
+
export declare function nativeLocalQuotaLineage(binding: NativeLocalPoolBinding & {
|
|
13
|
+
readonly identity: string;
|
|
14
|
+
}): string;
|
|
15
|
+
export declare function nativeLocalQuotaLineage(binding: NativeLocalPoolBinding | undefined): string | undefined;
|
|
16
|
+
/** Shared by header receipt, poll completion, routing and display; contains no credentials. */
|
|
17
|
+
export declare class NativeQuotaObservations extends Map<string, NativeQuotaObservation> {
|
|
18
|
+
private readonly publications;
|
|
19
|
+
set(accountId: string, observation: NativeQuotaObservation): this;
|
|
20
|
+
quota(lineage: string | undefined, accountUuid: string | undefined, committed: OAuthQuotaSnapshot | undefined, storage: AccountStorage, now?: number): {
|
|
21
|
+
quota: OAuthQuotaSnapshot;
|
|
22
|
+
clearAt?: number;
|
|
23
|
+
} | undefined;
|
|
24
|
+
publish(accountId: string, observation: NativeQuotaObservation, write: () => Promise<boolean>): Promise<void>;
|
|
25
|
+
drain(): Promise<void>;
|
|
26
|
+
}
|
package/dist/native-runtime.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import type { AccountOperationError, OAuthAccountProfile, PrimeUsageCounters } f
|
|
|
2
2
|
import { type NativeLocalCredentialValidation } from './native-credential-validation.ts';
|
|
3
3
|
import { type NativeQuotaMap } from './native-quota-codec.ts';
|
|
4
4
|
import type { NativeRefreshObservation, NativeRefreshSubject } from './native-refresh-coordinator.ts';
|
|
5
|
+
import { type OwnerOnlyOptions } from './owner-only.ts';
|
|
5
6
|
import { type NativeLocalPoolBinding } from './pool-binding.ts';
|
|
6
7
|
import type { NativePoolPaths } from './pool-paths.ts';
|
|
8
|
+
import { type PublicationOptions } from './publication-rename.ts';
|
|
7
9
|
/** Identifies the vault credential and Claude account that supplied an observation. This binding contains no access token. */
|
|
8
10
|
export interface NativeCustodyRuntimeBinding {
|
|
9
11
|
kind: 'custody';
|
|
@@ -83,8 +85,9 @@ export declare class NativeRuntimeError extends Error {
|
|
|
83
85
|
}
|
|
84
86
|
/** Validate structure and internal identifier consistency. The publisher separately checks these identifiers against the current pool or vault roster. */
|
|
85
87
|
export declare function decodeNativeRuntime(value: unknown, storageId: string): NativeRuntimeState;
|
|
86
|
-
export declare function readNativeRuntime(path: string, storageId: string): Promise<NativeRuntimeRead>;
|
|
88
|
+
export declare function readNativeRuntime(path: string, storageId: string, ownership?: OwnerOnlyOptions): Promise<NativeRuntimeRead>;
|
|
87
89
|
export interface NativeRuntimeWriteHooks {
|
|
90
|
+
publication?: PublicationOptions;
|
|
88
91
|
/** Verify that the observed account still matches the current pool record or vault roster and that the caller still owns the locks protecting those records. */
|
|
89
92
|
beforeRename?: () => Promise<void>;
|
|
90
93
|
/** Check caller authority after every lease assertion, immediately before replacement. This hook can only refuse publication. */
|
|
@@ -112,6 +115,7 @@ export type NativeRuntimeOptionalPublication = {
|
|
|
112
115
|
status: 'skipped';
|
|
113
116
|
};
|
|
114
117
|
export interface NativeRuntimeOptionalWriteHooks {
|
|
118
|
+
publication?: PublicationOptions;
|
|
115
119
|
/**
|
|
116
120
|
* Same checks as NativeRuntimeWriteHooks.beforeRename, run at the same
|
|
117
121
|
* point. Resolve 'skip' to discard the staged write without an error; throw
|
|
@@ -31,8 +31,7 @@ export declare function isNativeTransientAccountError(value: unknown): value is
|
|
|
31
31
|
* budget. Each wait between attempts ends early when any of `signals`
|
|
32
32
|
* aborts; `check` is then called after the leases are released and is
|
|
33
33
|
* expected to throw the caller's cancellation error. `check` runs before
|
|
34
|
-
* every attempt too, so a cancelled caller never takes a lock.
|
|
35
|
-
*
|
|
36
|
-
* writer's lock could be judged expired and taken over.
|
|
34
|
+
* every attempt too, so a cancelled caller never takes a lock. All pool
|
|
35
|
+
* leases use wall time, independently of logical observation timestamps.
|
|
37
36
|
*/
|
|
38
|
-
export declare function joinNativePoolWrite(paths: NativePoolStorePaths, signals: readonly AbortSignal[], check: () => void
|
|
37
|
+
export declare function joinNativePoolWrite(paths: NativePoolStorePaths, signals: readonly AbortSignal[], check: () => void): Promise<'joined' | 'deadline'>;
|
package/dist/native-ui.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface NativeUiOptions {
|
|
|
21
21
|
readonly readMode: () => Promise<NativeMenuCustodyMode>;
|
|
22
22
|
/** Token-free account names, credential IDs and states used to show which vault account needs re-login and its replacement command. */
|
|
23
23
|
readonly readAccounts?: () => Promise<import('./native-account-view.ts').NativeAccountSnapshot>;
|
|
24
|
+
/** Re-read the separate host-login notice on each local Accounts render. */
|
|
25
|
+
readonly readSeparateHostLoginNotice?: () => Promise<boolean>;
|
|
24
26
|
/**
|
|
25
27
|
* Disconnects this host from the vault; while enrolled, this is the host's
|
|
26
28
|
* only enrollment action. Before ending the enrollment, the callback
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* The error classes are not public runtime exports, so match name and code.
|
|
5
5
|
*/
|
|
6
6
|
export declare function usagePublicationRefusalIsFatal(error: unknown): boolean;
|
|
7
|
+
/** Return only allowlisted classes and codes, never the exception text. */
|
|
8
|
+
export declare function classifySafeErrorForLog(error: unknown): {
|
|
9
|
+
name: string;
|
|
10
|
+
code: string;
|
|
11
|
+
};
|
|
7
12
|
/** Own advisory writes for one host instance and join them before runtime close. */
|
|
8
13
|
export declare function createNativeUsagePublisher(channel: string): {
|
|
9
14
|
observe: (write: Promise<unknown>) => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeVaultRosterDocument } from './native-roster-seed.ts';
|
|
2
|
+
export declare function watchNativeVaultAuthority(holder: {
|
|
3
|
+
roster: string;
|
|
4
|
+
tokenPath: string;
|
|
5
|
+
retain: (roster: NativeVaultRosterDocument | undefined) => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
}): () => void;
|
|
8
|
+
export declare function retainNativeVaultRoster(path: string, roster: NativeVaultRosterDocument | undefined): void;
|
|
9
|
+
export declare function closeNativeVaultAuthority(tokenPath: string): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ClaustrumClientOptions } from '@cortexkit/claustrum-client';
|
|
2
2
|
import { type OAuthAccountProfile, type OAuthQuotaSnapshot, type PrimeUsageDelta } from './accounts.ts';
|
|
3
3
|
import { type NativeAccountMetadataPatch } from './native-account-view.ts';
|
|
4
4
|
import { type NativeCustodyClient, type NativeCustodyInventory, type NativeCustodyReceipt, type NativeCustodyReporterSource, type NativeCustodyRetry } from './native-custody.ts';
|
|
5
|
+
import { NativeQuotaObservations } from './native-quota-observations.ts';
|
|
5
6
|
import { type NativeRosterSeedInput, type NativeVaultRosterDocument, type NativeVaultRosterSeed } from './native-roster-seed.ts';
|
|
6
7
|
import { type NativeRuntimeState } from './native-runtime.ts';
|
|
7
8
|
import type { NativeVaultPaths } from './native-vault-paths.ts';
|
|
8
9
|
import type { NativePoolPaths } from './pool-paths.ts';
|
|
9
|
-
import type { QuotaRequestDispatch } from './quota-manager.ts';
|
|
10
|
+
import type { QuotaReadingPurpose, QuotaRequestDispatch } from './quota-manager.ts';
|
|
10
11
|
export interface NativeVaultRuntimeOptions {
|
|
11
12
|
paths: NativePoolPaths;
|
|
12
13
|
host: 'opencode' | 'pi';
|
|
@@ -20,7 +21,34 @@ export interface NativeVaultRuntimeOptions {
|
|
|
20
21
|
}>;
|
|
21
22
|
env?: NodeJS.ProcessEnv;
|
|
22
23
|
now?: () => number;
|
|
24
|
+
/**
|
|
25
|
+
* Timer functions for the vault custody's outage probe and roster watch
|
|
26
|
+
* retries. Defaults to the global ones; tests pass their own.
|
|
27
|
+
*/
|
|
28
|
+
setTimeout?: typeof globalThis.setTimeout;
|
|
29
|
+
clearTimeout?: typeof globalThis.clearTimeout;
|
|
30
|
+
/**
|
|
31
|
+
* Called each time the runtime has finished handling a vault notice that
|
|
32
|
+
* asked it to rediscover the roster, after the discovery that notice ran.
|
|
33
|
+
* Common-auth asks when the notice's view differs from the roster held,
|
|
34
|
+
* after a gap in the notices, and on a re-subscribed watch's first notice.
|
|
35
|
+
* Tests use it to wait for that handling instead of for the clock.
|
|
36
|
+
*/
|
|
37
|
+
onRosterNoticeHandled?: () => void;
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Why a vault quota reading is wanted, which decides whether insula's
|
|
41
|
+
* background quota cache may answer instead of Anthropic's usage endpoint.
|
|
42
|
+
* - 'background': a periodic sweep. Refresh insula's cache (at most once a
|
|
43
|
+
* minute per daemon and enrollment), look the route's account up in it,
|
|
44
|
+
* and skip the usage GET when it holds a current reading.
|
|
45
|
+
* - 'admission': a request needs a reading. Look the served credential's
|
|
46
|
+
* account up in insula's cache only, never refreshing it, then poll on a
|
|
47
|
+
* miss.
|
|
48
|
+
* Omitted: poll Anthropic directly (explicit user refreshes and other
|
|
49
|
+
* callers that must see the provider's own reading).
|
|
50
|
+
*/
|
|
51
|
+
export type NativeVaultQuotaPurpose = QuotaReadingPurpose;
|
|
24
52
|
export interface NativeVaultWatchOptions {
|
|
25
53
|
intervalMs: number;
|
|
26
54
|
onRefresh?: () => void | Promise<void>;
|
|
@@ -53,6 +81,9 @@ export interface NativeDisplayProfile {
|
|
|
53
81
|
/** Build a NativeDisplayProfile from a validated profile and its publication. */
|
|
54
82
|
export declare function nativeDisplayProfile(profile: OAuthAccountProfile, publish: () => Promise<boolean>, isCurrent: () => Promise<boolean>): NativeDisplayProfile;
|
|
55
83
|
export interface NativeVaultRuntime {
|
|
84
|
+
readonly quotaObservations: NativeQuotaObservations;
|
|
85
|
+
drainQuotaPublications(): Promise<void>;
|
|
86
|
+
quotaLineage(routeId: string, credentialId: string | undefined, accountIdentity: string | undefined): string | undefined;
|
|
56
87
|
/** Subscribe to one discovery loop; notifications contain no credential material. */
|
|
57
88
|
watch(options: NativeVaultWatchOptions): NativeVaultWatch;
|
|
58
89
|
initializeSettings(): Promise<void>;
|
|
@@ -69,7 +100,7 @@ export interface NativeVaultRuntime {
|
|
|
69
100
|
*/
|
|
70
101
|
prepareRetry(receipt: NativeCustodyReceipt, signal?: AbortSignal, site?: NativeScoped401Site): Promise<NativeCustodyRetry>;
|
|
71
102
|
publish(receipt: NativeCustodyReceipt, patch: NativeAccountMetadataPatch): Promise<boolean>;
|
|
72
|
-
fetchQuota(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal, dispatch?: QuotaRequestDispatch): Promise<OAuthQuotaSnapshot>;
|
|
103
|
+
fetchQuota(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal, dispatch?: QuotaRequestDispatch, purpose?: NativeVaultQuotaPurpose): Promise<OAuthQuotaSnapshot>;
|
|
73
104
|
fetchProfile(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal): Promise<OAuthAccountProfile>;
|
|
74
105
|
/** Return the fetched account profile without waiting for its metadata write. NativeDisplayProfile.persisted reports whether that asynchronous write succeeded, failed or was refused. */
|
|
75
106
|
fetchProfileForDisplay(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal): Promise<NativeDisplayProfile>;
|
|
@@ -91,6 +122,8 @@ export declare function publishNativeVaultRosterSeed(paths: Pick<NativeVaultPath
|
|
|
91
122
|
export declare function publishNativeVaultRuntimeSeed(paths: Pick<NativeVaultPaths, 'roster' | 'runtime' | 'storageId'>, state: NativeRuntimeState, options?: {
|
|
92
123
|
assertOwned?: () => Promise<void>;
|
|
93
124
|
}): Promise<void>;
|
|
125
|
+
/** Connect through the same short deadline used when requests wait for a vault roster. */
|
|
126
|
+
export declare function connectNativeVaultScopedClient(connectionFile: string, identity?: ClaustrumClientOptions['identity']): Promise<import("./internal-types/claustrum/index.js").ClaustrumScopedClient>;
|
|
94
127
|
/** List accounts readable by this host's enrollment for offline setup. An inventory grants no bearer authority; every outbound request still needs a fresh scoped receipt. */
|
|
95
128
|
export declare function discoverNativeVaultInventory(options: NativeVaultRuntimeOptions, signal?: AbortSignal): Promise<NativeCustodyInventory>;
|
|
96
129
|
/** Retain the vault client's original per-attempt receipts and version provenance; access tokens never persist in roster or runtime metadata. */
|
package/dist/network-errors.d.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as PrivateFiles from '@cortexkit/private-files';
|
|
2
|
+
/** Per-operation injection keeps simulated Windows policy out of process globals. */
|
|
3
|
+
export interface OwnerOnlyOptions {
|
|
4
|
+
platform?: NodeJS.Platform;
|
|
5
|
+
privateFiles?: Pick<typeof PrivateFiles, 'verifyOwnerOnly' | 'readPrivateFile'> & Partial<Pick<typeof PrivateFiles, 'verifySafeParent' | 'createPrivateFile' | 'createPrivateDirectory'>>;
|
|
6
|
+
}
|
|
7
|
+
/** POSIX callers retain their exact mode/uid policy; Windows must prove its DACL. */
|
|
8
|
+
export declare function isOwnerOnly(path: string, posix: () => boolean, options?: OwnerOnlyOptions): Promise<boolean>;
|
|
9
|
+
/** Windows reads through the ACL-verified native handle, not a pathname reopen. */
|
|
10
|
+
export declare function readWindowsOwnerOnly(path: string, options?: OwnerOnlyOptions): Promise<Buffer | undefined>;
|
|
11
|
+
/** Ancestors protect directory entries; they need not themselves be private. */
|
|
12
|
+
export declare function isSafeWindowsParent(path: string, options?: OwnerOnlyOptions): Promise<boolean | undefined>;
|
|
13
|
+
/** Native creation establishes a protected DACL before any bytes are written. */
|
|
14
|
+
export declare function createWindowsOwnerOnly(path: string, bytes: string, options?: OwnerOnlyOptions): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Create only missing Windows directories; never tighten an existing shared directory.
|
|
17
|
+
* Returns false off Windows so callers retain their POSIX directory policy.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ensureWindowsOwnerOnlyDirectory(path: string, options?: OwnerOnlyOptions): Promise<boolean>;
|
package/dist/pool-authority.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type NativeMigrationPreparedProof } from './native-migration-proof.ts';
|
|
2
|
+
import { type OwnerOnlyOptions } from './owner-only.ts';
|
|
2
3
|
import type { NativePoolPaths } from './pool-paths.ts';
|
|
3
4
|
declare const PHASES: readonly ['building', 'verified', 'activation-installed', 'committed', 'retired'];
|
|
4
5
|
export type NativeMigrationPhase = (typeof PHASES)[number];
|
|
@@ -23,6 +24,7 @@ export interface NativeMigrationInput {
|
|
|
23
24
|
* keeps native serving blocked until the separate vault activation commits.
|
|
24
25
|
*/
|
|
25
26
|
activation?: 'requested';
|
|
27
|
+
nativeSettingsDigest?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface NativeMigrationExpectations {
|
|
28
30
|
expectedHostAuth: string;
|
|
@@ -97,8 +99,7 @@ export interface NativeCustodyActivationPlan {
|
|
|
97
99
|
export type NativeCustodyActivation = {
|
|
98
100
|
kind: 'requested';
|
|
99
101
|
} | NativeCustodyActivationPlan;
|
|
100
|
-
|
|
101
|
-
version: 4;
|
|
102
|
+
interface NativeMigrationRecord {
|
|
102
103
|
storageId: string;
|
|
103
104
|
host: 'opencode' | 'pi';
|
|
104
105
|
phase: NativeMigrationPhase;
|
|
@@ -114,11 +115,27 @@ export interface NativeMigrationJournal {
|
|
|
114
115
|
*/
|
|
115
116
|
activation: NativeCustodyActivation | null;
|
|
116
117
|
}
|
|
118
|
+
export type NativeLegacyMigrationJournal = NativeMigrationRecord & ({
|
|
119
|
+
version: 4;
|
|
120
|
+
kind?: never;
|
|
121
|
+
} | {
|
|
122
|
+
version: 5;
|
|
123
|
+
kind: 'legacy-import';
|
|
124
|
+
nativeSettingsDigest: string;
|
|
125
|
+
});
|
|
126
|
+
export interface NativeEmptyInitJournal {
|
|
127
|
+
version: 5;
|
|
128
|
+
kind: 'empty-init';
|
|
129
|
+
storageId: string;
|
|
130
|
+
host: 'opencode';
|
|
131
|
+
phase: 'committed';
|
|
132
|
+
}
|
|
133
|
+
export type NativeMigrationJournal = NativeLegacyMigrationJournal | NativeEmptyInitJournal;
|
|
117
134
|
export declare class NativeAuthorityError extends Error {
|
|
118
135
|
readonly code: 'migration-required' | 'migration-incomplete' | 'invalid-journal' | 'journal-conflict';
|
|
119
136
|
constructor(code: 'migration-required' | 'migration-incomplete' | 'invalid-journal' | 'journal-conflict');
|
|
120
137
|
}
|
|
121
|
-
export declare function readNativeMigrationJournal(paths: NativePoolPaths): Promise<NativeMigrationJournal | undefined>;
|
|
138
|
+
export declare function readNativeMigrationJournal(paths: NativePoolPaths, ownership?: OwnerOnlyOptions): Promise<NativeMigrationJournal | undefined>;
|
|
122
139
|
/**
|
|
123
140
|
* The migration phase that authorizes serving, or undefined while the
|
|
124
141
|
* migration or a requested switch to vault custody is unfinished. Every reader
|
|
@@ -137,23 +154,25 @@ interface JournalHooks {
|
|
|
137
154
|
onWriteStep?: (step: 'before-write' | 'after-write', journal: NativeMigrationJournal) => Promise<void>;
|
|
138
155
|
}
|
|
139
156
|
/** Migration resume retains the original digests and resolved paths so a retry cannot adopt changed inputs or redirect writes. */
|
|
140
|
-
export declare function beginNativeMigration(paths: NativePoolPaths, input: NativeMigrationInput, hooks?: JournalHooks): Promise<
|
|
157
|
+
export declare function beginNativeMigration(paths: NativePoolPaths, input: NativeMigrationInput, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
141
158
|
/** Save the expected host-auth entry and routing digests together before changing files, so recovery can recognize completed writes. */
|
|
142
|
-
export declare function recordNativeMigrationExpectations(paths: NativePoolPaths, expectations: NativeMigrationExpectations, hooks?: JournalHooks): Promise<
|
|
159
|
+
export declare function recordNativeMigrationExpectations(paths: NativePoolPaths, expectations: NativeMigrationExpectations, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
143
160
|
/**
|
|
144
161
|
* Advance one phase at a time. A retry of the same transition returns the journal.
|
|
145
162
|
* Before recording activation, the caller must compare the host's Anthropic auth
|
|
146
163
|
* entry and routing file with the saved expected values. This journal records the
|
|
147
164
|
* migration stage; it does not read or verify those files.
|
|
148
165
|
*/
|
|
149
|
-
export declare function advanceNativeMigration(paths: NativePoolPaths, expected: NativeMigrationPhase, next: NativeMigrationPhase, hooks?: JournalHooks): Promise<
|
|
166
|
+
export declare function advanceNativeMigration(paths: NativePoolPaths, expected: NativeMigrationPhase, next: NativeMigrationPhase, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
150
167
|
/**
|
|
151
168
|
* Record the prepared switch to vault custody on a retired migration. From
|
|
152
169
|
* this write until the activation commits, the pool authorizes no serving.
|
|
153
170
|
* Retrying with the identical plan returns the journal; any other plan is a
|
|
154
171
|
* conflict, so a resumed setup can never replace what it recorded.
|
|
155
172
|
*/
|
|
156
|
-
export declare function recordNativeCustodyActivation(paths: NativePoolPaths, plan: NativeCustodyActivationPlan, hooks?: JournalHooks): Promise<
|
|
173
|
+
export declare function recordNativeCustodyActivation(paths: NativePoolPaths, plan: NativeCustodyActivationPlan, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
157
174
|
/** Advance a recorded activation one phase; never backwards or across a phase. */
|
|
158
|
-
export declare function advanceNativeCustodyActivation(paths: NativePoolPaths, expected: NativeCustodyActivationPhase, next: NativeCustodyActivationPhase, hooks?: JournalHooks): Promise<
|
|
175
|
+
export declare function advanceNativeCustodyActivation(paths: NativePoolPaths, expected: NativeCustodyActivationPhase, next: NativeCustodyActivationPhase, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
176
|
+
/** Publish local authority without inventing migration inputs or creating a pool. */
|
|
177
|
+
export declare function beginNativeEmptyInit(paths: NativePoolPaths, hooks?: JournalHooks): Promise<NativeEmptyInitJournal>;
|
|
159
178
|
export {};
|
package/dist/pool-paths.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface NativePoolPaths {
|
|
|
8
8
|
roster: string;
|
|
9
9
|
storageId: string;
|
|
10
10
|
}
|
|
11
|
+
/** Local hosts share the native pool's routing file unless explicitly overridden. */
|
|
12
|
+
export declare function resolveLocalRoutingDestination(host: 'opencode' | 'pi', paths: NativePoolPaths, env: NodeJS.ProcessEnv): string;
|
|
11
13
|
/**
|
|
12
14
|
* Resolve existing parent aliases and nonexistent leaves without creating files.
|
|
13
15
|
* This can follow a leaf symlink, so it does not establish configured-leaf safety.
|
package/dist/provider-error.d.ts
CHANGED
|
@@ -33,6 +33,39 @@ export declare const PROVIDER_ERROR_OVERSIZED_MESSAGE = "Provider error body exc
|
|
|
33
33
|
export declare const PROVIDER_ERROR_MAX_BODY_BYTES: number;
|
|
34
34
|
/** Largest SSE frame carried while looking for its end. */
|
|
35
35
|
export declare const PROVIDER_ERROR_MAX_FRAME_BYTES: number;
|
|
36
|
+
/**
|
|
37
|
+
* Error types kept in a generic replacement body. A closed list rather than
|
|
38
|
+
* a syntax check: an opaque credential can look like any identifier.
|
|
39
|
+
*/
|
|
40
|
+
declare const PROVIDER_ERROR_TYPES: readonly ['api_error', 'authentication_error', 'billing_error', 'invalid_request_error', 'not_found_error', 'overloaded_error', 'permission_error', 'rate_limit_error', 'relay_upstream_error', 'request_too_large', 'timeout_error'];
|
|
41
|
+
type ProviderErrorType = (typeof PROVIDER_ERROR_TYPES)[number];
|
|
42
|
+
declare const PREWARM_ERROR_MESSAGES: {
|
|
43
|
+
readonly http_validation: 'Provider rejected the prewarm request';
|
|
44
|
+
readonly http_error: 'Provider prewarm request failed';
|
|
45
|
+
readonly credential_unavailable: 'OAuth cache prewarm credential is unavailable';
|
|
46
|
+
readonly transport: 'Provider prewarm transport failed';
|
|
47
|
+
readonly withheld: 'Provider prewarm error details were withheld';
|
|
48
|
+
readonly parse_failure: 'Provider prewarm error response could not be parsed';
|
|
49
|
+
};
|
|
50
|
+
export type ProviderErrorSummary = {
|
|
51
|
+
status?: number;
|
|
52
|
+
provider_error: {
|
|
53
|
+
type: ProviderErrorType | 'unknown';
|
|
54
|
+
reason: keyof typeof PREWARM_ERROR_MESSAGES;
|
|
55
|
+
message: (typeof PREWARM_ERROR_MESSAGES)[keyof typeof PREWARM_ERROR_MESSAGES];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Prompt-safe prewarm metadata, not a replacement for per-send redaction.
|
|
60
|
+
* Read input.body from the response returned by ProviderErrorResponseScope's
|
|
61
|
+
* redactResponse, using a scope created for the physical request's credentials.
|
|
62
|
+
* Parsing is bounded independently; no provider text is copied to the result.
|
|
63
|
+
*/
|
|
64
|
+
export declare function summarizePrewarmProviderError(input: {
|
|
65
|
+
status?: number;
|
|
66
|
+
body?: string;
|
|
67
|
+
failure?: 'credential_unavailable' | 'transport';
|
|
68
|
+
}): ProviderErrorSummary;
|
|
36
69
|
/**
|
|
37
70
|
* For producers of a non-2xx body, such as the relay, that stop buffering it
|
|
38
71
|
* at PROVIDER_ERROR_MAX_BODY_BYTES: error the raw body stream with a new
|
|
@@ -137,3 +170,4 @@ export declare const PROVIDER_ERROR_RESPONSE_SCOPE_USED_MESSAGE = "Provider erro
|
|
|
137
170
|
* once settled, `redactError` only returns a generic error.
|
|
138
171
|
*/
|
|
139
172
|
export declare function createProviderErrorResponseScope(secrets: readonly string[], mode: ProviderResponseMode): ProviderErrorResponseScope;
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Per-publication seams keep platform and sharing-failure tests out of process globals. */
|
|
2
|
+
export interface PublicationOptions {
|
|
3
|
+
readonly platform?: NodeJS.Platform;
|
|
4
|
+
readonly rename?: (from: string, to: string) => Promise<void>;
|
|
5
|
+
readonly now?: () => number;
|
|
6
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Capture optional callbacks before staging I/O, just like the writer's other hooks. */
|
|
9
|
+
export declare function capturePublicationOptions(options?: PublicationOptions): PublicationOptions;
|
|
10
|
+
/** First publication is unconditional; only subsequent Windows sharing failures are retried. */
|
|
11
|
+
export declare function renameWithWindowsSharingRetry(from: string, to: string, options?: PublicationOptions, beforeRetry?: () => Promise<'publish' | 'skip'>): Promise<'published' | 'skipped'>;
|
package/dist/quota-manager.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export type QuotaRefreshResult = {
|
|
|
17
17
|
/** False when backoff or a cross-process lock served the existing cache. */
|
|
18
18
|
fetched: boolean;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Why a quota reading is wanted, passed to fetchQuotaSnapshot unchanged.
|
|
22
|
+
* Vault custody uses it to decide whether insula's background quota cache
|
|
23
|
+
* may answer instead of a usage GET (see NativeVaultQuotaPurpose); omitted
|
|
24
|
+
* means poll the provider directly.
|
|
25
|
+
*/
|
|
26
|
+
export type QuotaReadingPurpose = 'background' | 'admission';
|
|
20
27
|
/** Pace a physical usage GET and verify the selected credential is still eligible before sending. */
|
|
21
28
|
export type QuotaRequestDispatch = (send: () => Promise<Response>, revalidate: () => Promise<void>) => Promise<Response>;
|
|
22
29
|
export type QuotaManagerOptions = {
|
|
@@ -34,8 +41,17 @@ export type QuotaManagerOptions = {
|
|
|
34
41
|
kind: 'main' | 'fallback';
|
|
35
42
|
accountId: string | undefined;
|
|
36
43
|
accessToken: string;
|
|
44
|
+
purpose?: QuotaReadingPurpose;
|
|
37
45
|
}, dispatch: QuotaRequestDispatch) => Promise<OAuthQuotaSnapshot>;
|
|
38
46
|
now?: () => number;
|
|
47
|
+
/**
|
|
48
|
+
* Waits before a physical usage GET until the minimum gap since the previous
|
|
49
|
+
* one has passed. It receives the milliseconds still to wait, measured with
|
|
50
|
+
* `now`, and is called only when that remainder is positive. Defaults to a
|
|
51
|
+
* real timer that does not keep the process alive. Tests pass one that
|
|
52
|
+
* records the requested wait and resolves at once.
|
|
53
|
+
*/
|
|
54
|
+
pauseBetweenQuotaCalls?: (ms: number) => Promise<void>;
|
|
39
55
|
onMainQuotaFetched?: (quota: OAuthQuotaSnapshot, checkedAt: number, tokenFingerprint: string, fetchStartedAt: number, quotaErrorGeneration: number, quotaErrorClearedAt: number | undefined) => void;
|
|
40
56
|
onApiError?: (error: AccountOperationError, quotaErrorGeneration: number) => void;
|
|
41
57
|
onFallbackQuotaFetched?: (accountId: string, quota: OAuthQuotaSnapshot, checkedAt: number, fetchStartedAt: number) => void;
|
|
@@ -66,6 +82,7 @@ export declare class QuotaManager {
|
|
|
66
82
|
private readonly fetchImpl;
|
|
67
83
|
private readonly fetchQuotaSnapshot;
|
|
68
84
|
private readonly now;
|
|
85
|
+
private readonly pauseBetweenQuotaCalls;
|
|
69
86
|
private readonly onMainQuotaFetched;
|
|
70
87
|
private readonly onApiError;
|
|
71
88
|
private readonly onFallbackQuotaFetched;
|
|
@@ -91,10 +108,10 @@ export declare class QuotaManager {
|
|
|
91
108
|
clearFallback(accountId: string): void;
|
|
92
109
|
pushMainFromHeaders(mainAccountId: string | undefined, incoming: OAuthQuotaSnapshot): QuotaEntry;
|
|
93
110
|
pushFallbackFromHeaders(accountId: string, incoming: OAuthQuotaSnapshot, account: Pick<OAuthAccount, 'authLineageId'> | undefined): QuotaEntry | null;
|
|
94
|
-
refreshMain(mainAccountIdOrAccessToken: string | undefined, accessToken?: string, expectedIdentityGeneration?: number): Promise<OAuthQuotaSnapshot>;
|
|
95
|
-
refreshMainWithMetadata(mainAccountIdOrAccessToken: string | undefined, accessToken?: string, expectedIdentityGeneration?: number): Promise<QuotaRefreshResult>;
|
|
96
|
-
refreshFallback(accountId: string, accessToken: string, account: Pick<OAuthAccount, 'authLineageId'> | undefined): Promise<OAuthQuotaSnapshot>;
|
|
97
|
-
refreshFallbackWithMetadata(accountId: string, accessToken: string, account: Pick<OAuthAccount, 'authLineageId'> | undefined): Promise<QuotaRefreshResult>;
|
|
111
|
+
refreshMain(mainAccountIdOrAccessToken: string | undefined, accessToken?: string, expectedIdentityGeneration?: number, purpose?: QuotaReadingPurpose): Promise<OAuthQuotaSnapshot>;
|
|
112
|
+
refreshMainWithMetadata(mainAccountIdOrAccessToken: string | undefined, accessToken?: string, expectedIdentityGeneration?: number, purpose?: QuotaReadingPurpose): Promise<QuotaRefreshResult>;
|
|
113
|
+
refreshFallback(accountId: string, accessToken: string, account: Pick<OAuthAccount, 'authLineageId'> | undefined, purpose?: QuotaReadingPurpose): Promise<OAuthQuotaSnapshot>;
|
|
114
|
+
refreshFallbackWithMetadata(accountId: string, accessToken: string, account: Pick<OAuthAccount, 'authLineageId'> | undefined, purpose?: QuotaReadingPurpose): Promise<QuotaRefreshResult>;
|
|
98
115
|
refreshAllFallbacks(accounts: OAuthAccount[], resolveAccessToken?: (account: OAuthAccount) => string | undefined): Promise<void>;
|
|
99
116
|
/**
|
|
100
117
|
* Fire-and-forget refresh. Does not await, swallows errors.
|
package/dist/quotas.d.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { formatQuota, isQuotaStale, type ProjectedQuota, quotaTextParts, quotaWindowParts } from "./internal-types/quota/index.js";
|
|
2
|
+
import type { AccountQuotaWindow, AccountScopedQuotaWindow, AccountStorage, OAuthExtraUsageSnapshot, OAuthQuotaSnapshot, QuotaMoney } from './accounts.ts';
|
|
2
3
|
export declare const CLAUDE_QUOTAS_COMMAND_NAME = "claude-quota";
|
|
4
|
+
export type { QuotaWindowPart } from "./internal-types/quota/index.js";
|
|
5
|
+
export { formatQuota, isQuotaStale, quotaTextParts, quotaWindowParts };
|
|
6
|
+
type DisplayWindow = Omit<AccountQuotaWindow, 'checkedAt'> & {
|
|
7
|
+
checkedAt?: number;
|
|
8
|
+
};
|
|
9
|
+
/** Sidebar files written by older versions may not retain reading times. */
|
|
10
|
+
export type QuotaDisplaySnapshot = Pick<OAuthQuotaSnapshot, 'checkedAt' | 'extraUsage' | 'bindingWindow'> & {
|
|
11
|
+
five_hour?: DisplayWindow;
|
|
12
|
+
seven_day?: DisplayWindow;
|
|
13
|
+
scoped?: (Omit<AccountScopedQuotaWindow, 'checkedAt'> & DisplayWindow)[];
|
|
14
|
+
};
|
|
15
|
+
/** Adapt every reported window without projecting away other model families. */
|
|
16
|
+
export declare function quotaDisplayProjection(snapshot: QuotaDisplaySnapshot | null | undefined, now: number): ProjectedQuota | undefined;
|
|
17
|
+
export type QuotaMoneyFormat = {
|
|
18
|
+
/** Leave out the fractional digits, cutting the amount down to whole units. */
|
|
19
|
+
wholeUnits?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A stored money amount in its own currency, such as `$25.00` or `€1,250.00`.
|
|
23
|
+
* An amount whose currency the runtime cannot format reads as its raw minor
|
|
24
|
+
* units and currency code.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatQuotaMoney(money: QuotaMoney, options?: QuotaMoneyFormat): string;
|
|
27
|
+
/**
|
|
28
|
+
* The credit amounts shown after the shared credit figure: `$25.00/$100.00`
|
|
29
|
+
* (spent / monthly limit). Undefined when the limit is zero or either amount
|
|
30
|
+
* is missing or malformed, so the figure is then shown on its own.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatCreditAmounts(extraUsage: Partial<OAuthExtraUsageSnapshot> | null | undefined, options?: QuotaMoneyFormat): string | undefined;
|
|
3
33
|
export type QuotaAccountSummary = {
|
|
4
34
|
name: string;
|
|
5
35
|
role: 'main' | 'fallback';
|
|
@@ -9,7 +39,6 @@ export type QuotaAccountSummary = {
|
|
|
9
39
|
error?: string;
|
|
10
40
|
tierLabel?: string;
|
|
11
41
|
};
|
|
12
|
-
export declare function formatQuotaMoney(money: QuotaMoney): string;
|
|
13
42
|
export declare function buildFallbackQuotaSummaries(storage: AccountStorage | null, errors?: ReadonlyMap<string, string>): {
|
|
14
43
|
name: string;
|
|
15
44
|
role: 'fallback';
|
package/dist/relay.d.ts
CHANGED
|
@@ -6,6 +6,26 @@ export type RelayConfig = {
|
|
|
6
6
|
fallbackToDirect: boolean;
|
|
7
7
|
transport: 'http' | 'websocket';
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* The transport a stored relay configuration selects. A stored `http` or
|
|
11
|
+
* `websocket` value always wins. Without one (missing or unrecognized), the
|
|
12
|
+
* URL decides: a `ws://` or `wss://` URL selects WebSocket, so hand-edited
|
|
13
|
+
* WebSocket configurations keep working; any other URL selects HTTP, the
|
|
14
|
+
* documented default. Request dispatch and the relay status shown to users
|
|
15
|
+
* both call this, so they cannot report different transports.
|
|
16
|
+
*/
|
|
17
|
+
export declare function effectiveRelayTransport(stored: unknown, url: unknown): RelayConfig['transport'];
|
|
18
|
+
/**
|
|
19
|
+
* Secret-free relay status for displays such as the OpenCode sidebar: the
|
|
20
|
+
* transport requests will use, or null when requests cannot use the relay
|
|
21
|
+
* because it is disabled, has no URL or has no token. Native account
|
|
22
|
+
* snapshots never carry the private token; they set `tokenConfigured` to say
|
|
23
|
+
* whether one is stored.
|
|
24
|
+
*/
|
|
25
|
+
export declare function effectiveRelayStatus(relay: AccountStorage['relay'] | undefined): {
|
|
26
|
+
enabled: true;
|
|
27
|
+
transport: RelayConfig['transport'];
|
|
28
|
+
} | null;
|
|
9
29
|
export type RelayPatch = {
|
|
10
30
|
start: number;
|
|
11
31
|
deleteCount: number;
|