@opendatalabs/personal-server-ts-lite 0.0.1-canary.00328bf
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/bridge.d.ts +23 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +53 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser-runtime.d.ts +58 -0
- package/dist/browser-runtime.d.ts.map +1 -0
- package/dist/browser-runtime.js +214 -0
- package/dist/browser-runtime.js.map +1 -0
- package/dist/browser-tls-rustls/browser_tls_rustls.d.ts +49 -0
- package/dist/browser-tls-rustls/browser_tls_rustls.js +401 -0
- package/dist/browser-tls-rustls/browser_tls_rustls_bg.wasm +0 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +408 -0
- package/dist/client.js.map +1 -0
- package/dist/derivatives.d.ts +51 -0
- package/dist/derivatives.d.ts.map +1 -0
- package/dist/derivatives.js +87 -0
- package/dist/derivatives.js.map +1 -0
- package/dist/diagnostics.d.ts +166 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +265 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-store.d.ts +35 -0
- package/dist/mcp-store.d.ts.map +1 -0
- package/dist/mcp-store.js +208 -0
- package/dist/mcp-store.js.map +1 -0
- package/dist/owner-binding.d.ts +7 -0
- package/dist/owner-binding.d.ts.map +1 -0
- package/dist/owner-binding.js +18 -0
- package/dist/owner-binding.js.map +1 -0
- package/dist/persistence.d.ts +69 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +58 -0
- package/dist/persistence.js.map +1 -0
- package/dist/relay-tls.d.ts +61 -0
- package/dist/relay-tls.d.ts.map +1 -0
- package/dist/relay-tls.js +316 -0
- package/dist/relay-tls.js.map +1 -0
- package/dist/relay.d.ts +149 -0
- package/dist/relay.d.ts.map +1 -0
- package/dist/relay.js +646 -0
- package/dist/relay.js.map +1 -0
- package/dist/runtime.d.ts +188 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1178 -0
- package/dist/runtime.js.map +1 -0
- package/dist/state.d.ts +72 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +366 -0
- package/dist/state.js.map +1 -0
- package/dist/storage-utils.d.ts +8 -0
- package/dist/storage-utils.d.ts.map +1 -0
- package/dist/storage-utils.js +67 -0
- package/dist/storage-utils.js.map +1 -0
- package/dist/storage.d.ts +61 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +718 -0
- package/dist/storage.js.map +1 -0
- package/dist/sync.d.ts +58 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +216 -0
- package/dist/sync.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PS Lite one-shot diagnostics — v1
|
|
3
|
+
*
|
|
4
|
+
* Produces a bounded, plain-JSON diagnostic snapshot that the web MCP approval
|
|
5
|
+
* page can copy verbatim when it is stuck waiting for scopes. No payload bodies
|
|
6
|
+
* or secrets are ever included.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const recorder = new DiagnosticsRecorder();
|
|
10
|
+
* recorder.push({ phase: "indexing", detail: "scope=drive" });
|
|
11
|
+
* // … pass recorder into createPsLiteRuntime({ diagnostics: recorder, … })
|
|
12
|
+
* // GET /v1/diagnostics returns recorder.snapshot(syncStatus, storage)
|
|
13
|
+
*/
|
|
14
|
+
import type { SyncStatus } from "@opendatalabs/personal-server-ts-core/sync";
|
|
15
|
+
import type { DataStoragePort } from "@opendatalabs/personal-server-ts-core/ports";
|
|
16
|
+
export declare const DIAGNOSTICS_VERSION = 1;
|
|
17
|
+
/** Phases that the PS / PS Lite can be in during its lifecycle. */
|
|
18
|
+
export type DiagnosticsPhase = "booting" | "registering" | "routing" | "syncing" | "downloading" | "decrypting" | "indexing" | "buildingManifest" | "repairingManifest" | "generatingScopes" | "storageFailing" | "networkFailing" | "ready" | "unknown";
|
|
19
|
+
/** Per-scope readiness states visible to the approval page. */
|
|
20
|
+
export type ScopeReadinessStatus = "ready" | "indexing" | "waitingForPayload" | "manifestMissing" | "downloadFailed" | "decryptFailed" | "indexFailed" | "unknown";
|
|
21
|
+
export interface DiagnosticsEvent {
|
|
22
|
+
/** ISO 8601 timestamp */
|
|
23
|
+
at: string;
|
|
24
|
+
phase: DiagnosticsPhase;
|
|
25
|
+
/** Free-form detail — no payload bodies or secrets */
|
|
26
|
+
detail?: string;
|
|
27
|
+
/** Associated scope identifier, if known */
|
|
28
|
+
scope?: string;
|
|
29
|
+
/** Associated file id, if known */
|
|
30
|
+
fileId?: string;
|
|
31
|
+
/** Whether this event represents an error condition */
|
|
32
|
+
error?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ScopeDiagnostics {
|
|
35
|
+
scope: string;
|
|
36
|
+
status: ScopeReadinessStatus;
|
|
37
|
+
/** ISO 8601 */
|
|
38
|
+
lastActivityAt?: string;
|
|
39
|
+
lastError?: string;
|
|
40
|
+
lastFileId?: string;
|
|
41
|
+
/** Bytes of the last payload, if known */
|
|
42
|
+
sizeBytes?: number;
|
|
43
|
+
/** How many times a repair loop has fired for this scope */
|
|
44
|
+
repairCount?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ActiveOperation {
|
|
47
|
+
phase: DiagnosticsPhase;
|
|
48
|
+
startedAt: string;
|
|
49
|
+
elapsedMs: number;
|
|
50
|
+
scope?: string;
|
|
51
|
+
fileId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface LastNetworkOperation {
|
|
54
|
+
/** e.g. "download", "upload", "gatewayGetServer" */
|
|
55
|
+
operationClass: string;
|
|
56
|
+
status: "ok" | "error";
|
|
57
|
+
elapsedMs: number;
|
|
58
|
+
/** HTTP status code or error class, no body */
|
|
59
|
+
statusOrError?: string | number;
|
|
60
|
+
at: string;
|
|
61
|
+
}
|
|
62
|
+
export interface StorageHealthSummary {
|
|
63
|
+
indexedDbAvailable: boolean;
|
|
64
|
+
persistenceBackend?: string;
|
|
65
|
+
opfsAvailable?: boolean;
|
|
66
|
+
entryCount?: number;
|
|
67
|
+
unsyncedCount?: number;
|
|
68
|
+
scopeCount?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface PsLiteDiagnosticsSnapshot {
|
|
71
|
+
diagnosticVersion: 1;
|
|
72
|
+
capturedAt: string;
|
|
73
|
+
/** Current runtime active state */
|
|
74
|
+
runtimeActive: boolean | "unknown";
|
|
75
|
+
/** Current or last readiness phase */
|
|
76
|
+
currentPhase: DiagnosticsPhase;
|
|
77
|
+
/** Active operation with elapsed time, if any */
|
|
78
|
+
activeOperation: ActiveOperation | null;
|
|
79
|
+
/** Recent event ring, newest-last, bounded to MAX_EVENTS */
|
|
80
|
+
recentEvents: DiagnosticsEvent[];
|
|
81
|
+
/** Per-scope readiness where known */
|
|
82
|
+
scopes: ScopeDiagnostics[];
|
|
83
|
+
/** Sync manager status, if available */
|
|
84
|
+
sync: SyncDiagnostics | null;
|
|
85
|
+
/** Storage health, if available */
|
|
86
|
+
storage: StorageHealthSummary | null;
|
|
87
|
+
/** Most recent network/storage operation, no body */
|
|
88
|
+
lastNetworkOperation: LastNetworkOperation | null;
|
|
89
|
+
/** Repair loop counts keyed by scope */
|
|
90
|
+
repairCounts: Record<string, number>;
|
|
91
|
+
/** Whether diagnostics collection itself timed out */
|
|
92
|
+
partial: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface SyncDiagnostics {
|
|
95
|
+
enabled: boolean;
|
|
96
|
+
running: boolean;
|
|
97
|
+
syncing: boolean;
|
|
98
|
+
blocked: {
|
|
99
|
+
reason: string;
|
|
100
|
+
message: string;
|
|
101
|
+
} | null;
|
|
102
|
+
lastSync: string | null;
|
|
103
|
+
lastProcessedTimestamp: string | null;
|
|
104
|
+
pendingFiles: number;
|
|
105
|
+
recentErrors: Array<{
|
|
106
|
+
fileId: string | null;
|
|
107
|
+
scope: string | null;
|
|
108
|
+
message: string;
|
|
109
|
+
timestamp: string;
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
/** Options passed when recording an event. */
|
|
113
|
+
export interface RecordEventOptions {
|
|
114
|
+
phase: DiagnosticsPhase;
|
|
115
|
+
detail?: string;
|
|
116
|
+
scope?: string;
|
|
117
|
+
fileId?: string;
|
|
118
|
+
error?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Lightweight thread-safe (single-threaded JS) recorder.
|
|
122
|
+
*
|
|
123
|
+
* Instantiate once per PS Lite runtime; pass it into createPsLiteRuntime and
|
|
124
|
+
* call recorder.push() from sync, storage, and indexing code paths.
|
|
125
|
+
*/
|
|
126
|
+
export declare class DiagnosticsRecorder {
|
|
127
|
+
private readonly events;
|
|
128
|
+
private currentPhase;
|
|
129
|
+
private activeOp;
|
|
130
|
+
private lastNetwork;
|
|
131
|
+
private readonly scopeMap;
|
|
132
|
+
private readonly repairCounts;
|
|
133
|
+
push(options: RecordEventOptions): void;
|
|
134
|
+
/** Call when an async operation starts (e.g. a download or index run). */
|
|
135
|
+
beginOperation(phase: DiagnosticsPhase, scope?: string, fileId?: string): void;
|
|
136
|
+
/** Call when the async operation completes or fails. */
|
|
137
|
+
endOperation(): void;
|
|
138
|
+
/** Record a network or storage operation result without payload. */
|
|
139
|
+
recordNetworkOp(operationClass: string, status: "ok" | "error", elapsedMs: number, statusOrError?: string | number): void;
|
|
140
|
+
/** Increment the repair loop counter for a scope. */
|
|
141
|
+
recordRepair(scope: string): void;
|
|
142
|
+
/** Update per-scope readiness explicitly. */
|
|
143
|
+
setScopeStatus(scope: string, status: ScopeReadinessStatus, extra?: Partial<Omit<ScopeDiagnostics, "scope" | "status">>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Mark a scope as ready after a successful index pass, unless an earlier
|
|
146
|
+
* phase found that the bounded read sidecar is missing or corrupt.
|
|
147
|
+
*/
|
|
148
|
+
setScopeReadyAfterIndex(scope: string): void;
|
|
149
|
+
/** Mark a successful block-manifest write and clear any stale manifest error. */
|
|
150
|
+
setScopeManifestBuilt(scope: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Assemble a snapshot. Optionally accepts sync status and storage port to
|
|
153
|
+
* enrich the result. Runs with a hard timeout so it can never block.
|
|
154
|
+
*/
|
|
155
|
+
snapshot(options?: {
|
|
156
|
+
runtimeActive?: boolean;
|
|
157
|
+
syncStatus?: SyncStatus | null;
|
|
158
|
+
storage?: DataStoragePort | null;
|
|
159
|
+
}): PsLiteDiagnosticsSnapshot;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Collect a diagnostic snapshot with a hard timeout so it can never block the
|
|
163
|
+
* approval page. Returns a partial snapshot if the timeout fires.
|
|
164
|
+
*/
|
|
165
|
+
export declare function collectDiagnosticsWithTimeout(recorder: DiagnosticsRecorder, options?: Parameters<DiagnosticsRecorder["snapshot"]>[0], timeoutMs?: number): Promise<PsLiteDiagnosticsSnapshot>;
|
|
166
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEnF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,aAAa,GACb,SAAS,GACT,SAAS,GACT,aAAa,GACb,YAAY,GACZ,UAAU,GACV,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,OAAO,GACP,SAAS,CA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,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,GAC1D,IAAI;IAKP;;;OAGG;IACH,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ5C,iFAAiF;IACjF,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAa1C;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC/B,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;KAClC,GAAG,yBAAyB;CAgC9B;AA0FD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,UAAU,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,SAAS,SAAkB,GAC1B,OAAO,CAAC,yBAAyB,CAAC,CA4BpC"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PS Lite one-shot diagnostics — v1
|
|
3
|
+
*
|
|
4
|
+
* Produces a bounded, plain-JSON diagnostic snapshot that the web MCP approval
|
|
5
|
+
* page can copy verbatim when it is stuck waiting for scopes. No payload bodies
|
|
6
|
+
* or secrets are ever included.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const recorder = new DiagnosticsRecorder();
|
|
10
|
+
* recorder.push({ phase: "indexing", detail: "scope=drive" });
|
|
11
|
+
* // … pass recorder into createPsLiteRuntime({ diagnostics: recorder, … })
|
|
12
|
+
* // GET /v1/diagnostics returns recorder.snapshot(syncStatus, storage)
|
|
13
|
+
*/
|
|
14
|
+
export const DIAGNOSTICS_VERSION = 1;
|
|
15
|
+
const MAX_EVENTS = 100;
|
|
16
|
+
const DIAG_TIMEOUT_MS = 3_000;
|
|
17
|
+
/**
|
|
18
|
+
* Lightweight thread-safe (single-threaded JS) recorder.
|
|
19
|
+
*
|
|
20
|
+
* Instantiate once per PS Lite runtime; pass it into createPsLiteRuntime and
|
|
21
|
+
* call recorder.push() from sync, storage, and indexing code paths.
|
|
22
|
+
*/
|
|
23
|
+
export class DiagnosticsRecorder {
|
|
24
|
+
events = [];
|
|
25
|
+
currentPhase = "booting";
|
|
26
|
+
activeOp = null;
|
|
27
|
+
lastNetwork = null;
|
|
28
|
+
scopeMap = new Map();
|
|
29
|
+
repairCounts = {};
|
|
30
|
+
push(options) {
|
|
31
|
+
const event = {
|
|
32
|
+
at: new Date().toISOString(),
|
|
33
|
+
phase: options.phase,
|
|
34
|
+
...(options.detail !== undefined ? { detail: options.detail } : {}),
|
|
35
|
+
...(options.scope !== undefined ? { scope: options.scope } : {}),
|
|
36
|
+
...(options.fileId !== undefined ? { fileId: options.fileId } : {}),
|
|
37
|
+
...(options.error ? { error: true } : {}),
|
|
38
|
+
};
|
|
39
|
+
this.events.push(event);
|
|
40
|
+
if (this.events.length > MAX_EVENTS) {
|
|
41
|
+
this.events.splice(0, this.events.length - MAX_EVENTS);
|
|
42
|
+
}
|
|
43
|
+
this.currentPhase = options.phase;
|
|
44
|
+
if (options.scope) {
|
|
45
|
+
const existing = this.scopeMap.get(options.scope) ?? {
|
|
46
|
+
scope: options.scope,
|
|
47
|
+
status: "unknown",
|
|
48
|
+
};
|
|
49
|
+
const next = {
|
|
50
|
+
...existing,
|
|
51
|
+
scope: options.scope,
|
|
52
|
+
lastActivityAt: event.at,
|
|
53
|
+
...(options.fileId ? { lastFileId: options.fileId } : {}),
|
|
54
|
+
...(options.error && options.detail
|
|
55
|
+
? { lastError: options.detail }
|
|
56
|
+
: {}),
|
|
57
|
+
status: nextScopeStatus(existing.status, options.phase, options.error),
|
|
58
|
+
};
|
|
59
|
+
this.scopeMap.set(options.scope, next);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Call when an async operation starts (e.g. a download or index run). */
|
|
63
|
+
beginOperation(phase, scope, fileId) {
|
|
64
|
+
this.activeOp = { phase, startedAt: Date.now(), scope, fileId };
|
|
65
|
+
this.currentPhase = phase;
|
|
66
|
+
}
|
|
67
|
+
/** Call when the async operation completes or fails. */
|
|
68
|
+
endOperation() {
|
|
69
|
+
this.activeOp = null;
|
|
70
|
+
}
|
|
71
|
+
/** Record a network or storage operation result without payload. */
|
|
72
|
+
recordNetworkOp(operationClass, status, elapsedMs, statusOrError) {
|
|
73
|
+
this.lastNetwork = {
|
|
74
|
+
operationClass,
|
|
75
|
+
status,
|
|
76
|
+
elapsedMs,
|
|
77
|
+
...(statusOrError !== undefined ? { statusOrError } : {}),
|
|
78
|
+
at: new Date().toISOString(),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Increment the repair loop counter for a scope. */
|
|
82
|
+
recordRepair(scope) {
|
|
83
|
+
this.repairCounts[scope] = (this.repairCounts[scope] ?? 0) + 1;
|
|
84
|
+
const existing = this.scopeMap.get(scope) ?? {
|
|
85
|
+
scope,
|
|
86
|
+
status: "unknown",
|
|
87
|
+
};
|
|
88
|
+
this.scopeMap.set(scope, {
|
|
89
|
+
...existing,
|
|
90
|
+
repairCount: this.repairCounts[scope],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** Update per-scope readiness explicitly. */
|
|
94
|
+
setScopeStatus(scope, status, extra) {
|
|
95
|
+
const existing = this.scopeMap.get(scope) ?? { scope, status };
|
|
96
|
+
this.scopeMap.set(scope, { ...existing, ...extra, scope, status });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mark a scope as ready after a successful index pass, unless an earlier
|
|
100
|
+
* phase found that the bounded read sidecar is missing or corrupt.
|
|
101
|
+
*/
|
|
102
|
+
setScopeReadyAfterIndex(scope) {
|
|
103
|
+
const existing = this.scopeMap.get(scope);
|
|
104
|
+
if (existing && isBlockingScopeStatus(existing.status)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.setScopeStatus(scope, "ready");
|
|
108
|
+
}
|
|
109
|
+
/** Mark a successful block-manifest write and clear any stale manifest error. */
|
|
110
|
+
setScopeManifestBuilt(scope) {
|
|
111
|
+
const existing = this.scopeMap.get(scope) ?? {
|
|
112
|
+
scope,
|
|
113
|
+
status: "indexing",
|
|
114
|
+
};
|
|
115
|
+
const { lastError: _lastError, ...withoutError } = existing;
|
|
116
|
+
this.scopeMap.set(scope, {
|
|
117
|
+
...withoutError,
|
|
118
|
+
scope,
|
|
119
|
+
status: "indexing",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Assemble a snapshot. Optionally accepts sync status and storage port to
|
|
124
|
+
* enrich the result. Runs with a hard timeout so it can never block.
|
|
125
|
+
*/
|
|
126
|
+
snapshot(options) {
|
|
127
|
+
const now = new Date().toISOString();
|
|
128
|
+
const activeOperation = this.activeOp
|
|
129
|
+
? {
|
|
130
|
+
phase: this.activeOp.phase,
|
|
131
|
+
startedAt: new Date(this.activeOp.startedAt).toISOString(),
|
|
132
|
+
elapsedMs: Date.now() - this.activeOp.startedAt,
|
|
133
|
+
...(this.activeOp.scope ? { scope: this.activeOp.scope } : {}),
|
|
134
|
+
...(this.activeOp.fileId ? { fileId: this.activeOp.fileId } : {}),
|
|
135
|
+
}
|
|
136
|
+
: null;
|
|
137
|
+
const sync = buildSyncDiagnostics(options?.syncStatus);
|
|
138
|
+
const storage = buildStorageDiagnostics(options?.storage);
|
|
139
|
+
const scopes = Array.from(this.scopeMap.values());
|
|
140
|
+
return {
|
|
141
|
+
diagnosticVersion: DIAGNOSTICS_VERSION,
|
|
142
|
+
capturedAt: now,
|
|
143
|
+
runtimeActive: options?.runtimeActive ?? "unknown",
|
|
144
|
+
currentPhase: this.currentPhase,
|
|
145
|
+
activeOperation,
|
|
146
|
+
recentEvents: [...this.events],
|
|
147
|
+
scopes,
|
|
148
|
+
sync,
|
|
149
|
+
storage,
|
|
150
|
+
lastNetworkOperation: this.lastNetwork,
|
|
151
|
+
repairCounts: { ...this.repairCounts },
|
|
152
|
+
partial: false,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function phaseToScopeStatus(phase, error) {
|
|
157
|
+
if (error) {
|
|
158
|
+
if (phase === "downloading")
|
|
159
|
+
return "downloadFailed";
|
|
160
|
+
if (phase === "decrypting")
|
|
161
|
+
return "decryptFailed";
|
|
162
|
+
if (phase === "indexing")
|
|
163
|
+
return "indexFailed";
|
|
164
|
+
if (phase === "buildingManifest" || phase === "repairingManifest")
|
|
165
|
+
return "manifestMissing";
|
|
166
|
+
return "unknown";
|
|
167
|
+
}
|
|
168
|
+
switch (phase) {
|
|
169
|
+
case "ready":
|
|
170
|
+
return "ready";
|
|
171
|
+
case "indexing":
|
|
172
|
+
return "indexing";
|
|
173
|
+
case "downloading":
|
|
174
|
+
return "waitingForPayload";
|
|
175
|
+
case "buildingManifest":
|
|
176
|
+
case "repairingManifest":
|
|
177
|
+
return "indexing";
|
|
178
|
+
default:
|
|
179
|
+
return "unknown";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function nextScopeStatus(existingStatus, phase, error) {
|
|
183
|
+
if (!error && isBlockingScopeStatus(existingStatus)) {
|
|
184
|
+
return existingStatus;
|
|
185
|
+
}
|
|
186
|
+
return phaseToScopeStatus(phase, error);
|
|
187
|
+
}
|
|
188
|
+
function isBlockingScopeStatus(status) {
|
|
189
|
+
return (status === "manifestMissing" ||
|
|
190
|
+
status === "downloadFailed" ||
|
|
191
|
+
status === "decryptFailed" ||
|
|
192
|
+
status === "indexFailed");
|
|
193
|
+
}
|
|
194
|
+
function buildSyncDiagnostics(status) {
|
|
195
|
+
if (!status)
|
|
196
|
+
return null;
|
|
197
|
+
return {
|
|
198
|
+
enabled: status.enabled,
|
|
199
|
+
running: status.running,
|
|
200
|
+
syncing: status.syncing,
|
|
201
|
+
blocked: status.blocked ?? null,
|
|
202
|
+
lastSync: status.lastSync,
|
|
203
|
+
lastProcessedTimestamp: status.lastProcessedTimestamp,
|
|
204
|
+
pendingFiles: status.pendingFiles,
|
|
205
|
+
recentErrors: status.errors.map((e) => ({
|
|
206
|
+
fileId: e.fileId,
|
|
207
|
+
scope: e.scope,
|
|
208
|
+
message: e.message,
|
|
209
|
+
timestamp: e.timestamp,
|
|
210
|
+
})),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function buildStorageDiagnostics(storage) {
|
|
214
|
+
if (!storage)
|
|
215
|
+
return null;
|
|
216
|
+
try {
|
|
217
|
+
const scopeResult = storage.listScopes({ limit: 1000 });
|
|
218
|
+
const unsynced = storage.findUnsynced({ limit: 1000 });
|
|
219
|
+
return {
|
|
220
|
+
indexedDbAvailable: typeof indexedDB !== "undefined",
|
|
221
|
+
persistenceBackend: storage.kind,
|
|
222
|
+
scopeCount: scopeResult.total,
|
|
223
|
+
unsyncedCount: unsynced.length,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return {
|
|
228
|
+
indexedDbAvailable: typeof indexedDB !== "undefined",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Collect a diagnostic snapshot with a hard timeout so it can never block the
|
|
234
|
+
* approval page. Returns a partial snapshot if the timeout fires.
|
|
235
|
+
*/
|
|
236
|
+
export async function collectDiagnosticsWithTimeout(recorder, options, timeoutMs = DIAG_TIMEOUT_MS) {
|
|
237
|
+
return new Promise((resolve) => {
|
|
238
|
+
const tid = setTimeout(() => {
|
|
239
|
+
resolve({ ...recorder.snapshot(options), partial: true });
|
|
240
|
+
}, timeoutMs);
|
|
241
|
+
try {
|
|
242
|
+
const snap = recorder.snapshot(options);
|
|
243
|
+
clearTimeout(tid);
|
|
244
|
+
resolve(snap);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
clearTimeout(tid);
|
|
248
|
+
resolve({
|
|
249
|
+
diagnosticVersion: DIAGNOSTICS_VERSION,
|
|
250
|
+
capturedAt: new Date().toISOString(),
|
|
251
|
+
runtimeActive: options?.runtimeActive ?? "unknown",
|
|
252
|
+
currentPhase: "unknown",
|
|
253
|
+
activeOperation: null,
|
|
254
|
+
recentEvents: [],
|
|
255
|
+
scopes: [],
|
|
256
|
+
sync: null,
|
|
257
|
+
storage: null,
|
|
258
|
+
lastNetworkOperation: null,
|
|
259
|
+
repairCounts: {},
|
|
260
|
+
partial: true,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AA6HrC,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,eAAe,GAAG,KAAK,CAAC;AAW9B;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IACb,MAAM,GAAuB,EAAE,CAAC;IACzC,YAAY,GAAqB,SAAS,CAAC;IAC3C,QAAQ,GAKL,IAAI,CAAC;IACR,WAAW,GAAgC,IAAI,CAAC;IACvC,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC/C,YAAY,GAA2B,EAAE,CAAC;IAE3D,IAAI,CAAC,OAA2B;QAC9B,MAAM,KAAK,GAAqB;YAC9B,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK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AG,EAAE;YAC1B,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxC,YAAY,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,YAAY,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,CAAC;gBACN,iBAAiB,EAAE,mBAAmB;gBACtC,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,SAAS;gBAClD,YAAY,EAAE,SAAS;gBACvB,eAAe,EAAE,IAAI;gBACrB,YAAY,EAAE,EAAE;gBAChB,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;gBACb,oBAAoB,EAAE,IAAI;gBAC1B,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { createIndexedDbPsLiteRuntime, type IndexedDbPsLiteRuntime, type IndexedDbPsLiteRuntimeOptions, } from "./browser-runtime.js";
|
|
2
|
+
export { startPersonalServer, type StartPersonalServerLiteOptions, type StartPersonalServerLiteRelayOptions, } from "./client.js";
|
|
3
|
+
export type { PersonalServerHandle, PersonalServerClientErrorBody, PersonalServerDataVersion, PersonalServerHealthRegistration, PersonalServerIdentity, PersonalServerInfo, PersonalServerAuthRequestOptions, PersonalServerListDataOptions, PersonalServerListDataResult, PersonalServerListVersionsOptions, PersonalServerListVersionsResult, PersonalServerReadDataOptions, PersonalServerRegistrationRequest, PersonalServerStatus, PersonalServerSyncTriggerResult, PersonalServerUrls, } from "@opendatalabs/personal-server-ts-core/client";
|
|
4
|
+
export { PersonalServerClientError, dataListPath, dataReadPath, dataVersionsPath, parsePersonalServerJsonResponse, } from "@opendatalabs/personal-server-ts-core/client";
|
|
5
|
+
export { handlePsLiteBridgeRequest, type PsLiteBridgeRequest, type PsLiteBridgeResponse, } from "./bridge.js";
|
|
6
|
+
export { createIndexedDbPsLitePersistence, createOpfsPsLiteDataFileStore, createPersistentPsLiteStorage, isOpfsAvailable, type IndexedDbPsLitePersistenceOptions, type PsLiteDataFileStore, type PsLiteFileStorageKind, type PsLitePersistedStorageState, type PsLitePersistenceAdapter, type PsLiteStorageCapabilities, type PsLiteStoragePort, } from "./storage.js";
|
|
7
|
+
export { createIndexedDbPsLiteAccessLogStore, createIndexedDbPsLiteStateStore, createIndexedDbPsLiteTokenStore, loadOrCreatePsLiteConfig, loadOrCreatePsLiteServerIdentity, loadPsLiteRelayState, savePsLiteConfig, savePsLiteRelayState, type IndexedDbPsLiteAccessLogStoreOptions, type IndexedDbPsLiteStateStoreOptions, type IndexedDbPsLiteTokenStoreOptions, type PsLiteEncryptedPrivateKey, type PsLiteEncryptedServerIdentity, type PsLiteRelayState, type PsLiteStateKey, type PsLiteStateStore, type PsLiteUnlockedServerIdentity, } from "./state.js";
|
|
8
|
+
export { createPsLitePendingBlobDeletionStore, createPsLiteSyncCursor, createPsLiteSyncManager, type PsLiteSyncOptions, type PsLiteOwnerSyncSigner, } from "./sync.js";
|
|
9
|
+
export { resolvePsLiteOwner, type PsLiteOwnerBindingInput, } from "./owner-binding.js";
|
|
10
|
+
export { createPsLiteDerivativeCompute, createPsLiteQuestionStore, psLiteInferenceConfigured, type PsLiteDerivativeCompute, type PsLiteDerivativeComputeOptions, } from "./derivatives.js";
|
|
11
|
+
export { createBearerTokenPsLiteAuth, createPsLiteRuntime, createWeb3SignedPsLiteAuth, type BearerTokenPsLiteAuthOptions, type PsLiteAuthAdapter, type PsLiteReadAuthInput, type PsLiteRuntime, type PsLiteRuntimeOptions, type PsLiteStorageAdapter, type PsLiteTokenStore, type PsLiteWriteSessionAuthOptions, type Web3SignedPsLiteAuthOptions, } from "./runtime.js";
|
|
12
|
+
export { createInMemoryWriteProofReplayStore, createInMemoryWriteSessionStore, hashWriteSessionToken, verifyStoredWriterAttribution, WRITE_SIGNATURE_HEADER, WRITER_ATTRIBUTION_KEY, type WriteProofReplayStore, type WriteSessionRecord, type WriteSessionStore, } from "@opendatalabs/personal-server-ts-core/write";
|
|
13
|
+
export { createIndexedDbMcpConnectionStore, createIndexedDbMcpOAuthAuthorizationStore, type IndexedDbMcpConnectionStoreOptions, type IndexedDbMcpOAuthAuthorizationStoreOptions, } from "./mcp-store.js";
|
|
14
|
+
export { DiagnosticsRecorder, collectDiagnosticsWithTimeout, DIAGNOSTICS_VERSION, type ActiveOperation, type DiagnosticsEvent, type DiagnosticsPhase, type LastNetworkOperation, type PsLiteDiagnosticsSnapshot, type RecordEventOptions, type ScopeDiagnostics, type ScopeReadinessStatus, type StorageHealthSummary, type SyncDiagnostics, } from "./diagnostics.js";
|
|
15
|
+
export { decodeDataFrame, encodeDataFrame, psLiteRelayControlUrl, psLiteRelayPublicUrl, RELAY_CLOSE_SESSION_REPLACED, startPsLiteRelayClient, type PsLiteRelayClient, type PsLiteRelayClientOptions, type PsLiteRelayCloseEvent, type PsLiteRelayStatus, type PsLiteRelayTlsFactory, type PsLiteRelayTlsPrepareInput, type PsLiteRelayTlsStep, type PsLiteRelayTlsStream, type PsLiteRelayTlsStreamInput, type PsLiteRelayWebSocket, type PsLiteRelayWebSocketFactory, } from "./relay.js";
|
|
16
|
+
export { createLocalStoragePsLiteRelayTlsIdentityStore, createRustlsPsLiteRelayTlsFactory, psLiteRelayPublicHost, psLiteRelayPublicUrl as psLiteRelayTlsPublicUrl, type PsLiteRelayTlsIdentity, type PsLiteRelayTlsIdentityStore, type RustlsPsLiteRelayTlsOptions, } from "./relay-tls.js";
|
|
17
|
+
export { assertCompletePsLitePersistenceBundle, psLitePersistenceRuntimeOptions, type PsLitePersistenceBundle, type PsLitePersistenceRuntimeOptions, } from "./persistence.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GACnC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,KAAK,8BAA8B,EACnC,KAAK,mCAAmC,GACzC,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EACtB,kBAAkB,EAClB,gCAAgC,EAChC,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,EACjC,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,oBAAoB,EACpB,+BAA+B,EAC/B,kBAAkB,GACnB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,+BAA+B,GAChC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,6BAA6B,EAC7B,eAAe,EACf,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,+BAA+B,EAC/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pB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,GACjC,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,6CAA6C,EAC7C,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,IAAI,uBAAuB,EAC/C,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qCAAqC,EACrC,+BAA+B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,+BAA+B,GACrC,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { createIndexedDbPsLiteRuntime, } from "./browser-runtime.js";
|
|
2
|
+
export { startPersonalServer, } from "./client.js";
|
|
3
|
+
export { PersonalServerClientError, dataListPath, dataReadPath, dataVersionsPath, parsePersonalServerJsonResponse, } from "@opendatalabs/personal-server-ts-core/client";
|
|
4
|
+
export { handlePsLiteBridgeRequest, } from "./bridge.js";
|
|
5
|
+
export { createIndexedDbPsLitePersistence, createOpfsPsLiteDataFileStore, createPersistentPsLiteStorage, isOpfsAvailable, } from "./storage.js";
|
|
6
|
+
export { createIndexedDbPsLiteAccessLogStore, createIndexedDbPsLiteStateStore, createIndexedDbPsLiteTokenStore, loadOrCreatePsLiteConfig, loadOrCreatePsLiteServerIdentity, loadPsLiteRelayState, savePsLiteConfig, savePsLiteRelayState, } from "./state.js";
|
|
7
|
+
export { createPsLitePendingBlobDeletionStore, createPsLiteSyncCursor, createPsLiteSyncManager, } from "./sync.js";
|
|
8
|
+
export { resolvePsLiteOwner, } from "./owner-binding.js";
|
|
9
|
+
export { createPsLiteDerivativeCompute, createPsLiteQuestionStore, psLiteInferenceConfigured, } from "./derivatives.js";
|
|
10
|
+
export { createBearerTokenPsLiteAuth, createPsLiteRuntime, createWeb3SignedPsLiteAuth, } from "./runtime.js";
|
|
11
|
+
// Delegated builder writes: hosts that build their own auth adapter (or want
|
|
12
|
+
// one store shared across several runtimes) wire these themselves.
|
|
13
|
+
export { createInMemoryWriteProofReplayStore, createInMemoryWriteSessionStore, hashWriteSessionToken, verifyStoredWriterAttribution, WRITE_SIGNATURE_HEADER, WRITER_ATTRIBUTION_KEY, } from "@opendatalabs/personal-server-ts-core/write";
|
|
14
|
+
export { createIndexedDbMcpConnectionStore, createIndexedDbMcpOAuthAuthorizationStore, } from "./mcp-store.js";
|
|
15
|
+
export { DiagnosticsRecorder, collectDiagnosticsWithTimeout, DIAGNOSTICS_VERSION, } from "./diagnostics.js";
|
|
16
|
+
export { decodeDataFrame, encodeDataFrame, psLiteRelayControlUrl, psLiteRelayPublicUrl, RELAY_CLOSE_SESSION_REPLACED, startPsLiteRelayClient, } from "./relay.js";
|
|
17
|
+
export { createLocalStoragePsLiteRelayTlsIdentityStore, createRustlsPsLiteRelayTlsFactory, psLiteRelayPublicHost, psLiteRelayPublicUrl as psLiteRelayTlsPublicUrl, } from "./relay-tls.js";
|
|
18
|
+
export { assertCompletePsLitePersistenceBundle, psLitePersistenceRuntimeOptions, } from "./persistence.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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BAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GAYvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,6CAA6C,EAC7C,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,IAAI,uBAAuB,GAIhD,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qCAAqC,EACrC,+BAA+B,GAGhC,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB-backed `McpConnectionStore` for Web PS Lite.
|
|
3
|
+
*
|
|
4
|
+
* Phase 1 trade-off: persists the per-connection grantee private key in
|
|
5
|
+
* PLAINTEXT in IndexedDB. The owner-derived AES-GCM wrap used for the PS Lite
|
|
6
|
+
* server identity is not yet applied to grantee keys — that's the Phase 2
|
|
7
|
+
* "encrypt grantee private keys at rest" task in
|
|
8
|
+
* `260604-PLAN-vana-mcp-personal-server.md`. The risk is bounded by:
|
|
9
|
+
*
|
|
10
|
+
* 1. The browser same-origin policy — only code running on the PS Lite tab's
|
|
11
|
+
* origin (e.g. app-dev.vana.org) can read this store.
|
|
12
|
+
* 2. Grantee keys are scoped per-connection and revocable. A leaked key only
|
|
13
|
+
* lets the holder read the grants that connection already approved; any
|
|
14
|
+
* revoke removes both the grant and the connection's lookup record.
|
|
15
|
+
* 3. There are no write tools — leaked grantee keys cannot mutate user data.
|
|
16
|
+
*
|
|
17
|
+
* Persistent storage is strongly preferred over in-memory because:
|
|
18
|
+
* - app-dev page reloads are routine in a browser app;
|
|
19
|
+
* - Claude's MCP URL is meant to live in the Claude config across sessions;
|
|
20
|
+
* - the alternative (re-create on every boot) would silently invalidate every
|
|
21
|
+
* prior Claude connection on every reload, indistinguishable from a real
|
|
22
|
+
* revoke from the user's perspective.
|
|
23
|
+
*/
|
|
24
|
+
import { type McpConnectionStore, type McpOAuthAuthorizationStore } from "@opendatalabs/personal-server-ts-core/mcp";
|
|
25
|
+
export interface IndexedDbMcpConnectionStoreOptions {
|
|
26
|
+
dbName?: string;
|
|
27
|
+
storeName?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IndexedDbMcpOAuthAuthorizationStoreOptions {
|
|
30
|
+
dbName?: string;
|
|
31
|
+
storeName?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function createIndexedDbMcpConnectionStore(options?: IndexedDbMcpConnectionStoreOptions): McpConnectionStore;
|
|
34
|
+
export declare function createIndexedDbMcpOAuthAuthorizationStore(options?: IndexedDbMcpOAuthAuthorizationStoreOptions): McpOAuthAuthorizationStore;
|
|
35
|
+
//# sourceMappingURL=mcp-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-store.d.ts","sourceRoot":"","sources":["../src/mcp-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,kBAAkB,EAEvB,KAAK,0BAA0B,EAChC,MAAM,2CAA2C,CAAC;AAqBnD,MAAM,WAAW,kCAAkC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,0CAA0C;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8ID,wBAAgB,iCAAiC,CAC/C,OAAO,GAAE,kCAAuC,GAC/C,kBAAkB,CAqFpB;AAED,wBAAgB,yCAAyC,CACvD,OAAO,GAAE,0CAA+C,GACvD,0BAA0B,CA0E5B"}
|