dsh-mnemon-source-memory-spaces 0.5.0-rc.1
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/LICENSE +21 -0
- package/README.md +38 -0
- package/lib/client.js +3462 -0
- package/lib/contracts.d.ts +498 -0
- package/lib/contracts.js +41 -0
- package/lib/definitions-CEpa-tvm.d.ts +135 -0
- package/lib/definitions-DfmOqJjR.js +214 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +3456 -0
- package/lib/plugin-DlsNeZbQ.js +388 -0
- package/lib/process-B-t3UflO.js +81 -0
- package/lib/provider-sdk.d.ts +54 -0
- package/lib/provider-sdk.js +105 -0
- package/lib/testing.d.ts +28 -0
- package/lib/testing.js +106 -0
- package/lib/types/client/ProviderIcon.d.ts +10 -0
- package/lib/types/client/api.d.ts +39 -0
- package/lib/types/client/pages.d.ts +72 -0
- package/lib/types/client/provider-presentation.d.ts +6 -0
- package/lib/types/client/ui.d.ts +17 -0
- package/lib/types/client.d.ts +3 -0
- package/lib/types/contracts.d.ts +496 -0
- package/package.json +103 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { MemoryJsonValue as JsonValue } from "dsh-mnemon/contracts";
|
|
2
|
+
//#region src/contracts.d.ts
|
|
3
|
+
type MemoryProviderId = string;
|
|
4
|
+
type MemoryProviderConnectionValue = string | number | boolean;
|
|
5
|
+
type MemoryProviderConnection = Record<string, MemoryProviderConnectionValue>;
|
|
6
|
+
interface MemoryProviderIcon {
|
|
7
|
+
/** Bundled brand token, self-contained image data, or a short text glyph. */
|
|
8
|
+
kind: 'brand' | 'data-url' | 'glyph';
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
interface MemoryProviderConfigOption {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
/** Optional Host-provided translation key; clients fall back to label. */
|
|
15
|
+
i18nKey?: string;
|
|
16
|
+
}
|
|
17
|
+
interface MemoryProviderConfigField {
|
|
18
|
+
key: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/** Optional Host-provided translation key; clients fall back to label. */
|
|
21
|
+
i18nKey?: string;
|
|
22
|
+
/** Service fields are configured once in Settings; memory fields belong to each Memory Space. */
|
|
23
|
+
scope: 'service' | 'memory';
|
|
24
|
+
/** A reusable local data location presented with the same default/custom scope UI as Mnemon Native. */
|
|
25
|
+
role?: 'global-location';
|
|
26
|
+
input: 'text' | 'url' | 'secret' | 'number' | 'boolean' | 'select' | 'path';
|
|
27
|
+
required: boolean;
|
|
28
|
+
defaultValue?: MemoryProviderConnectionValue;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
help?: string;
|
|
31
|
+
min?: number;
|
|
32
|
+
max?: number;
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
pattern?: string;
|
|
35
|
+
normalize?: 'trim-trailing-slash';
|
|
36
|
+
validationMessage?: string;
|
|
37
|
+
/** Seed an empty service default from this field on the first discovered Memory Space. */
|
|
38
|
+
discoveryDefaultFrom?: string;
|
|
39
|
+
options?: MemoryProviderConfigOption[];
|
|
40
|
+
}
|
|
41
|
+
type MemoryPlacementCapability = 'graph' | 'entities' | 'related' | 'exact-write' | 'link' | 'forget';
|
|
42
|
+
type MemoryPlacementPreference = 'balanced' | 'local-first' | 'shared-first';
|
|
43
|
+
interface MemoryPlacementRules {
|
|
44
|
+
allowedProviderIds?: MemoryProviderId[];
|
|
45
|
+
dataBoundary?: 'allow-remote' | 'local-only';
|
|
46
|
+
requiredCapabilities?: MemoryPlacementCapability[];
|
|
47
|
+
preference?: MemoryPlacementPreference;
|
|
48
|
+
}
|
|
49
|
+
/** Persistent policy for provider selection during Agent-supervised memory distillation. */
|
|
50
|
+
interface MemoryPersistenceStrategy {
|
|
51
|
+
mode?: 'manual' | 'automatic';
|
|
52
|
+
/** Fixed provider in manual mode. */
|
|
53
|
+
providerId?: MemoryProviderId;
|
|
54
|
+
/** User-authored guidance used only after hard rules have filtered automatic candidates. */
|
|
55
|
+
prompt?: string;
|
|
56
|
+
rules?: MemoryPlacementRules;
|
|
57
|
+
/** Memory-level connection values for providers that may be selected by the policy. */
|
|
58
|
+
providerConnections?: Partial<Record<MemoryProviderId, MemoryProviderConnection>>;
|
|
59
|
+
}
|
|
60
|
+
interface ResolvedMemoryPersistenceStrategy {
|
|
61
|
+
mode: 'manual' | 'automatic';
|
|
62
|
+
providerId: MemoryProviderId;
|
|
63
|
+
prompt: string;
|
|
64
|
+
rules: {
|
|
65
|
+
allowedProviderIds: MemoryProviderId[];
|
|
66
|
+
dataBoundary: 'allow-remote' | 'local-only';
|
|
67
|
+
requiredCapabilities: MemoryPlacementCapability[];
|
|
68
|
+
preference: MemoryPlacementPreference;
|
|
69
|
+
};
|
|
70
|
+
providerConnections: Partial<Record<MemoryProviderId, MemoryProviderConnection>>;
|
|
71
|
+
}
|
|
72
|
+
interface AutomaticMemoryPlacementRequest {
|
|
73
|
+
mode: 'automatic';
|
|
74
|
+
/** User-authored routing guidance. Hard rules above always take precedence. */
|
|
75
|
+
prompt?: string;
|
|
76
|
+
rules?: MemoryPlacementRules;
|
|
77
|
+
}
|
|
78
|
+
interface MemoryPlacementDecision {
|
|
79
|
+
mode: 'automatic';
|
|
80
|
+
providerId: MemoryProviderId;
|
|
81
|
+
decidedBy: 'rules' | 'llm';
|
|
82
|
+
reason: string;
|
|
83
|
+
confidence: 'high' | 'medium' | 'low';
|
|
84
|
+
candidateProviderIds: MemoryProviderId[];
|
|
85
|
+
appliedRules: string[];
|
|
86
|
+
decidedAt: string;
|
|
87
|
+
runId?: string;
|
|
88
|
+
subagentProvider?: string;
|
|
89
|
+
}
|
|
90
|
+
interface MemoryProviderCapabilities {
|
|
91
|
+
search: boolean;
|
|
92
|
+
browse: boolean;
|
|
93
|
+
graph: boolean;
|
|
94
|
+
entities: boolean;
|
|
95
|
+
related: boolean;
|
|
96
|
+
remember: boolean;
|
|
97
|
+
link: boolean;
|
|
98
|
+
forget: boolean;
|
|
99
|
+
writeMode: 'exact' | 'async-extracting';
|
|
100
|
+
deletionMode: 'soft' | 'hard' | 'unsupported';
|
|
101
|
+
}
|
|
102
|
+
interface MemoryProviderDescriptor {
|
|
103
|
+
/** Provider implementation type; omitted when it is identical to id. */
|
|
104
|
+
typeId?: string;
|
|
105
|
+
id: MemoryProviderId;
|
|
106
|
+
label: string;
|
|
107
|
+
icon?: MemoryProviderIcon;
|
|
108
|
+
kind: 'local' | 'remote';
|
|
109
|
+
/** How the provider data scope reacts when DSH switches workspaces. */
|
|
110
|
+
workspaceBinding: 'automatic' | 'optional-override' | 'provider-global';
|
|
111
|
+
summary: string;
|
|
112
|
+
/** Optional Host-provided translation key; clients fall back to summary. */
|
|
113
|
+
summaryI18nKey?: string;
|
|
114
|
+
origin: 'native' | 'third-party';
|
|
115
|
+
capabilities: MemoryProviderCapabilities;
|
|
116
|
+
fields: MemoryProviderConfigField[];
|
|
117
|
+
/** Runtime projection: whether this scope has a usable saved service configuration. */
|
|
118
|
+
serviceConfigured?: boolean;
|
|
119
|
+
}
|
|
120
|
+
interface MemoryProviderServiceView {
|
|
121
|
+
providerId: MemoryProviderId;
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
configured: boolean;
|
|
124
|
+
settings: MemoryProviderConnection;
|
|
125
|
+
configuredSecrets: string[];
|
|
126
|
+
/** Present only on the settings RPC so its password inputs can use native reveal/hide behavior. */
|
|
127
|
+
secretValues?: MemoryProviderConnection;
|
|
128
|
+
}
|
|
129
|
+
interface MemoryProviderServiceCatalog {
|
|
130
|
+
providers: MemoryProviderDescriptor[];
|
|
131
|
+
items: MemoryProviderServiceView[];
|
|
132
|
+
generatedAt: string;
|
|
133
|
+
}
|
|
134
|
+
interface UpdateMemoryProviderServiceRequest {
|
|
135
|
+
providerId: MemoryProviderId;
|
|
136
|
+
settings: MemoryProviderConnection;
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
clearSecrets?: string[];
|
|
139
|
+
}
|
|
140
|
+
interface MemoryProviderRuntimeStatus {
|
|
141
|
+
providerId: MemoryProviderId;
|
|
142
|
+
label: string;
|
|
143
|
+
icon?: MemoryProviderIcon;
|
|
144
|
+
enabled: boolean;
|
|
145
|
+
configured: boolean;
|
|
146
|
+
status: 'disabled' | 'idle' | 'healthy' | 'unhealthy';
|
|
147
|
+
memoryBodyCount: number;
|
|
148
|
+
activeMemoryBodyCount: number;
|
|
149
|
+
error?: string;
|
|
150
|
+
}
|
|
151
|
+
interface MemoryBodyProvider {
|
|
152
|
+
id: MemoryProviderId;
|
|
153
|
+
/** Implementation type; differs from id when one module has several child instances. */
|
|
154
|
+
typeId?: string;
|
|
155
|
+
label: string;
|
|
156
|
+
icon?: MemoryProviderIcon;
|
|
157
|
+
origin?: 'native' | 'third-party';
|
|
158
|
+
kind: 'local' | 'remote';
|
|
159
|
+
location: string;
|
|
160
|
+
targetUri?: string;
|
|
161
|
+
account?: string;
|
|
162
|
+
user?: string;
|
|
163
|
+
actorPeerId?: string;
|
|
164
|
+
apiKeyConfigured: boolean;
|
|
165
|
+
settings: MemoryProviderConnection;
|
|
166
|
+
configuredSecrets: string[];
|
|
167
|
+
capabilities: MemoryProviderCapabilities;
|
|
168
|
+
}
|
|
169
|
+
interface OpenVikingBodyConnection {
|
|
170
|
+
endpoint: string;
|
|
171
|
+
targetUri: string;
|
|
172
|
+
apiKey?: string;
|
|
173
|
+
account?: string;
|
|
174
|
+
user?: string;
|
|
175
|
+
actorPeerId?: string;
|
|
176
|
+
}
|
|
177
|
+
interface MemoryBody {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
description: string;
|
|
181
|
+
active: boolean;
|
|
182
|
+
dbPath: string;
|
|
183
|
+
provider: MemoryBodyProvider;
|
|
184
|
+
placement?: MemoryPlacementDecision;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
updatedAt: string;
|
|
187
|
+
}
|
|
188
|
+
interface CreateMemoryBodyRequest {
|
|
189
|
+
name: string;
|
|
190
|
+
description: string;
|
|
191
|
+
active?: boolean;
|
|
192
|
+
providerId?: MemoryProviderId;
|
|
193
|
+
connection?: MemoryProviderConnection;
|
|
194
|
+
/** Candidate-specific settings used only while resolving automatic placement. */
|
|
195
|
+
providerConnections?: Partial<Record<MemoryProviderId, MemoryProviderConnection>>;
|
|
196
|
+
openViking?: OpenVikingBodyConnection;
|
|
197
|
+
placement?: AutomaticMemoryPlacementRequest;
|
|
198
|
+
}
|
|
199
|
+
interface UpdateMemoryBodyRequest {
|
|
200
|
+
name?: string;
|
|
201
|
+
description?: string;
|
|
202
|
+
active?: boolean;
|
|
203
|
+
connection?: MemoryProviderConnection;
|
|
204
|
+
clearSecrets?: string[];
|
|
205
|
+
openViking?: Partial<OpenVikingBodyConnection> & {
|
|
206
|
+
clearApiKey?: boolean;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
interface MemoryBodyMetadataUpdate {
|
|
210
|
+
memoryBodyId: string;
|
|
211
|
+
title: string;
|
|
212
|
+
description: string;
|
|
213
|
+
}
|
|
214
|
+
interface MemoryBodyMetadataMaintenanceResult {
|
|
215
|
+
delegated: true;
|
|
216
|
+
runId: string;
|
|
217
|
+
provider: string;
|
|
218
|
+
summary: string;
|
|
219
|
+
updates: MemoryBodyMetadataUpdate[];
|
|
220
|
+
}
|
|
221
|
+
type Category = 'preference' | 'decision' | 'fact' | 'insight' | 'context' | 'general';
|
|
222
|
+
declare const CATEGORIES: readonly ["preference", "decision", "fact", "insight", "context", "general"];
|
|
223
|
+
type Source = 'user' | 'agent' | 'external';
|
|
224
|
+
declare const SOURCES: readonly ["user", "agent", "external"];
|
|
225
|
+
type EdgeType = 'temporal' | 'semantic' | 'causal' | 'entity';
|
|
226
|
+
declare const EDGE_TYPES: readonly ["temporal", "semantic", "causal", "entity"];
|
|
227
|
+
type Intent = 'WHY' | 'WHEN' | 'ENTITY' | 'GENERAL';
|
|
228
|
+
declare const INTENTS: readonly ["WHY", "WHEN", "ENTITY", "GENERAL"];
|
|
229
|
+
type RecallRelevanceTier = 'high' | 'medium' | 'low' | 'unknown';
|
|
230
|
+
interface Insight {
|
|
231
|
+
id: string;
|
|
232
|
+
content: string;
|
|
233
|
+
category?: string;
|
|
234
|
+
importance?: number;
|
|
235
|
+
tags?: string[];
|
|
236
|
+
entities?: string[];
|
|
237
|
+
source?: string;
|
|
238
|
+
score?: number;
|
|
239
|
+
/** Policy-normalized query relevance; absent for unknown Provider score scales. */
|
|
240
|
+
normalizedScore?: number;
|
|
241
|
+
/** Query relevance assigned by the active deterministic recall quality policy. */
|
|
242
|
+
relevanceTier?: RecallRelevanceTier;
|
|
243
|
+
/** Comparable rank score only when results were fused across providers. */
|
|
244
|
+
federatedScore?: number;
|
|
245
|
+
confidence?: string;
|
|
246
|
+
intent?: string;
|
|
247
|
+
matchedVia?: string;
|
|
248
|
+
createdAt?: string;
|
|
249
|
+
depth?: number;
|
|
250
|
+
edgeType?: string;
|
|
251
|
+
memoryBodyId?: string;
|
|
252
|
+
memoryBodyName?: string;
|
|
253
|
+
memoryProviderId?: MemoryProviderId;
|
|
254
|
+
/** Provider label captured with the result so Client UI never needs an id catalog. */
|
|
255
|
+
memoryProviderLabel?: string;
|
|
256
|
+
/** Owning Provider capabilities at read time; safe to expose to clients. */
|
|
257
|
+
memoryCapabilities?: MemoryProviderCapabilities;
|
|
258
|
+
externalUri?: string;
|
|
259
|
+
}
|
|
260
|
+
interface SearchRequest {
|
|
261
|
+
query: string;
|
|
262
|
+
mode?: 'smart' | 'keyword' | 'basic';
|
|
263
|
+
limit?: number;
|
|
264
|
+
category?: Category;
|
|
265
|
+
source?: Source;
|
|
266
|
+
intent?: Intent;
|
|
267
|
+
memoryBodyIds?: string[];
|
|
268
|
+
}
|
|
269
|
+
interface RememberRequest {
|
|
270
|
+
content: string;
|
|
271
|
+
category?: Category;
|
|
272
|
+
importance?: number;
|
|
273
|
+
tags?: string[];
|
|
274
|
+
entities?: string[];
|
|
275
|
+
source?: Source;
|
|
276
|
+
memoryBodyId?: string;
|
|
277
|
+
}
|
|
278
|
+
interface MemoryBodyStats {
|
|
279
|
+
totalInsights: number;
|
|
280
|
+
deletedInsights: number;
|
|
281
|
+
edgeCount: number;
|
|
282
|
+
oplogCount: number;
|
|
283
|
+
dbSizeBytes: number;
|
|
284
|
+
byCategory: Record<string, number>;
|
|
285
|
+
topEntities: Array<{
|
|
286
|
+
entity: string;
|
|
287
|
+
count: number;
|
|
288
|
+
}>;
|
|
289
|
+
}
|
|
290
|
+
interface MemoryBodyView extends MemoryBody {
|
|
291
|
+
/** True when Mnemon's persisted active-file selection points to this Store. */
|
|
292
|
+
mnemonDefault: boolean;
|
|
293
|
+
/** False when an external provider is disabled while its Memory Space registration remains preserved. */
|
|
294
|
+
providerEnabled?: boolean;
|
|
295
|
+
healthy: boolean;
|
|
296
|
+
/** A fast directory response is visible while provider health resolves independently. */
|
|
297
|
+
statusLoading?: boolean;
|
|
298
|
+
error?: string;
|
|
299
|
+
stats?: MemoryBodyStats;
|
|
300
|
+
}
|
|
301
|
+
interface MemoryBodyCatalog {
|
|
302
|
+
items: MemoryBodyView[];
|
|
303
|
+
providers: MemoryProviderDescriptor[];
|
|
304
|
+
/** Sanitized policy exposed to memory workers; provider connection values are never included. */
|
|
305
|
+
persistenceStrategy?: Omit<ResolvedMemoryPersistenceStrategy, 'providerConnections'>;
|
|
306
|
+
total: number;
|
|
307
|
+
activeCount: number;
|
|
308
|
+
directory: string;
|
|
309
|
+
generatedAt: string;
|
|
310
|
+
}
|
|
311
|
+
interface MemoryGraphNode extends Insight {
|
|
312
|
+
color: string;
|
|
313
|
+
graphId?: string;
|
|
314
|
+
kind?: 'memory' | 'entity' | 'space';
|
|
315
|
+
memoryBodyIds?: string[];
|
|
316
|
+
memoryBodyNames?: string[];
|
|
317
|
+
occurrenceCount?: number;
|
|
318
|
+
}
|
|
319
|
+
interface MemoryGraphEdge {
|
|
320
|
+
sourceId: string;
|
|
321
|
+
targetId: string;
|
|
322
|
+
label: string;
|
|
323
|
+
color: string;
|
|
324
|
+
type?: EdgeType | 'scope';
|
|
325
|
+
}
|
|
326
|
+
interface MemoryGraphSnapshot {
|
|
327
|
+
nodes: MemoryGraphNode[];
|
|
328
|
+
edges: MemoryGraphEdge[];
|
|
329
|
+
generatedAt: string;
|
|
330
|
+
memoryBodies?: Array<Pick<MemoryBody, 'id' | 'name' | 'active'>>;
|
|
331
|
+
/** Per-space observation state for capability-aware overview rendering. */
|
|
332
|
+
sources?: MemoryReadSource[];
|
|
333
|
+
}
|
|
334
|
+
type MemoryReadMode = 'search' | 'graph' | 'projection' | 'enumerable' | 'query-only' | 'entities' | 'unsupported';
|
|
335
|
+
type MemoryReadStatus = 'ready' | 'empty' | 'query-required' | 'unsupported' | 'unavailable';
|
|
336
|
+
/**
|
|
337
|
+
* One provider-backed Memory Space participating in a read surface.
|
|
338
|
+
*
|
|
339
|
+
* The mode describes what the provider can truthfully expose; status describes
|
|
340
|
+
* the result of this particular read. Keeping those dimensions separate lets
|
|
341
|
+
* the UI distinguish an empty graph from a flat projection, a query-only
|
|
342
|
+
* engine, and an unavailable connection.
|
|
343
|
+
*/
|
|
344
|
+
interface MemoryReadSource {
|
|
345
|
+
memoryBodyId: string;
|
|
346
|
+
memoryBodyName: string;
|
|
347
|
+
providerId: MemoryProviderId;
|
|
348
|
+
providerLabel: string;
|
|
349
|
+
mode: MemoryReadMode;
|
|
350
|
+
status: MemoryReadStatus;
|
|
351
|
+
itemCount: number;
|
|
352
|
+
edgeCount?: number;
|
|
353
|
+
hint?: string;
|
|
354
|
+
quality?: RecallQualityStats;
|
|
355
|
+
}
|
|
356
|
+
interface RecallQualityStats {
|
|
357
|
+
policyId: string;
|
|
358
|
+
fallbackFrom?: string;
|
|
359
|
+
fetched: number;
|
|
360
|
+
retained: number;
|
|
361
|
+
selected: number;
|
|
362
|
+
droppedLowScore: number;
|
|
363
|
+
droppedNonPositiveScore: number;
|
|
364
|
+
droppedInvalidScore: number;
|
|
365
|
+
unscored: number;
|
|
366
|
+
unscaled: number;
|
|
367
|
+
}
|
|
368
|
+
interface MemoryListRequest {
|
|
369
|
+
query?: string;
|
|
370
|
+
category?: Category;
|
|
371
|
+
limit?: number;
|
|
372
|
+
memoryBodyIds?: string[];
|
|
373
|
+
}
|
|
374
|
+
interface MemoryListView {
|
|
375
|
+
items: MemoryGraphNode[];
|
|
376
|
+
total: number;
|
|
377
|
+
generatedAt: string;
|
|
378
|
+
/** Omitted only when talking to a pre-provider-aware Host. */
|
|
379
|
+
sources?: MemoryReadSource[];
|
|
380
|
+
}
|
|
381
|
+
interface MemoryBodyMetadataSample {
|
|
382
|
+
memoryBodyId: string;
|
|
383
|
+
name: string;
|
|
384
|
+
description: string;
|
|
385
|
+
providerId: MemoryBody['provider']['id'];
|
|
386
|
+
providerLabel: string;
|
|
387
|
+
method: 'native-basic' | 'browse' | 'search';
|
|
388
|
+
evidence: Array<Pick<Insight, 'content' | 'category' | 'entities'>>;
|
|
389
|
+
}
|
|
390
|
+
interface MemoryPlacementCandidate {
|
|
391
|
+
id: MemoryProviderId;
|
|
392
|
+
label: string;
|
|
393
|
+
kind: 'local' | 'remote';
|
|
394
|
+
configured: boolean;
|
|
395
|
+
summary: string;
|
|
396
|
+
capabilities: MemoryProviderCapabilities;
|
|
397
|
+
}
|
|
398
|
+
interface PreparedMemoryPlacement {
|
|
399
|
+
prompt: string;
|
|
400
|
+
candidates: MemoryPlacementCandidate[];
|
|
401
|
+
appliedRules: string[];
|
|
402
|
+
selectorBrief: string;
|
|
403
|
+
}
|
|
404
|
+
interface LlmMemoryPlacementSelection {
|
|
405
|
+
providerId: string;
|
|
406
|
+
reason: string;
|
|
407
|
+
confidence: string;
|
|
408
|
+
}
|
|
409
|
+
declare const DEFAULT_EMBEDDING_ENDPOINT = "http://localhost:11434";
|
|
410
|
+
declare const DEFAULT_EMBEDDING_MODEL = "nomic-embed-text";
|
|
411
|
+
declare const EMBEDDING_PROTOCOL_AUTO = "auto";
|
|
412
|
+
declare const EMBEDDING_PROTOCOL_OLLAMA = "ollama";
|
|
413
|
+
declare const EMBEDDING_PROTOCOL_OPENAI = "openai";
|
|
414
|
+
/** Default protocol defers to Mnemon's /v1 auto-detection. */
|
|
415
|
+
declare const DEFAULT_EMBEDDING_PROTOCOL = "auto";
|
|
416
|
+
/** Wire protocols accepted by the embedding protocol override; single source for schema, resolver, and UI validation. */
|
|
417
|
+
declare const MNEMON_EMBEDDING_PROTOCOLS: readonly ["auto", "ollama", "openai"];
|
|
418
|
+
interface RecallQualityConfig {
|
|
419
|
+
/** Registered deterministic policy id. */
|
|
420
|
+
policy?: string;
|
|
421
|
+
lowScoreThreshold?: number;
|
|
422
|
+
highScoreThreshold?: number;
|
|
423
|
+
/** Provider candidate expansion before quality filtering, from 1 through 5. */
|
|
424
|
+
candidateMultiplier?: number;
|
|
425
|
+
/** Maximum medium-relevance rows admitted by the strict policy. */
|
|
426
|
+
maxMediumResults?: number;
|
|
427
|
+
/** Maximum unknown-scale or unscored rows admitted by the strict policy. */
|
|
428
|
+
maxUnknownResults?: number;
|
|
429
|
+
}
|
|
430
|
+
interface ResolvedRecallQualityConfig {
|
|
431
|
+
policy: string;
|
|
432
|
+
lowScoreThreshold: number;
|
|
433
|
+
highScoreThreshold: number;
|
|
434
|
+
candidateMultiplier: number;
|
|
435
|
+
maxMediumResults: number;
|
|
436
|
+
maxUnknownResults: number;
|
|
437
|
+
}
|
|
438
|
+
type MnemonEmbeddingProtocol = (typeof MNEMON_EMBEDDING_PROTOCOLS)[number];
|
|
439
|
+
interface MnemonEmbeddingConfig {
|
|
440
|
+
/** When false or omitted, Mnemon keeps its inherited environment and built-in defaults. */
|
|
441
|
+
enabled?: boolean;
|
|
442
|
+
endpoint?: string;
|
|
443
|
+
model?: string;
|
|
444
|
+
/** Optional Bearer token forwarded as MNEMON_EMBED_API_KEY for OpenAI-compatible endpoints. */
|
|
445
|
+
apiKey?: string;
|
|
446
|
+
/** Explicit wire-protocol override; 'auto' keeps Mnemon's /v1 auto-detection. */
|
|
447
|
+
protocol?: MnemonEmbeddingProtocol;
|
|
448
|
+
}
|
|
449
|
+
interface ResolvedMnemonEmbeddingConfig {
|
|
450
|
+
enabled: boolean;
|
|
451
|
+
endpoint: string;
|
|
452
|
+
model: string;
|
|
453
|
+
apiKey: string;
|
|
454
|
+
protocol: MnemonEmbeddingProtocol;
|
|
455
|
+
}
|
|
456
|
+
interface MnemonEmbeddingStatus {
|
|
457
|
+
available: boolean;
|
|
458
|
+
model: string;
|
|
459
|
+
/** Protocol Mnemon resolved for the embedding endpoint; omitted when the CLI does not report one. */
|
|
460
|
+
protocol?: string;
|
|
461
|
+
totalInsights: number;
|
|
462
|
+
embedded: number;
|
|
463
|
+
coverage: string;
|
|
464
|
+
}
|
|
465
|
+
/** Domain status only; workbench/lifecycle status belongs to the default adapter. */
|
|
466
|
+
interface MemorySpacesStatus {
|
|
467
|
+
healthy: boolean;
|
|
468
|
+
error?: string;
|
|
469
|
+
version?: string;
|
|
470
|
+
cliPath: string;
|
|
471
|
+
commandFound: boolean;
|
|
472
|
+
dataDir: string;
|
|
473
|
+
store: string;
|
|
474
|
+
mnemonDefaultStore: string;
|
|
475
|
+
dshActiveStores: string[];
|
|
476
|
+
writeEnabled: boolean;
|
|
477
|
+
timeoutMs: number;
|
|
478
|
+
defaultRecallLimit: number;
|
|
479
|
+
recallQuality: ResolvedRecallQualityConfig;
|
|
480
|
+
memoryBodyDirectory: string;
|
|
481
|
+
memoryBodies: MemoryBodyView[];
|
|
482
|
+
providerServices?: MemoryProviderRuntimeStatus[];
|
|
483
|
+
stats?: MemoryBodyStats & {
|
|
484
|
+
dbPath?: string;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
interface EntityView {
|
|
488
|
+
items: Array<{
|
|
489
|
+
entity: string;
|
|
490
|
+
count: number;
|
|
491
|
+
}>;
|
|
492
|
+
insights: Insight[];
|
|
493
|
+
selected?: string;
|
|
494
|
+
/** Omitted only when talking to a pre-provider-aware Host. */
|
|
495
|
+
sources?: MemoryReadSource[];
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
export { AutomaticMemoryPlacementRequest, CATEGORIES, Category, CreateMemoryBodyRequest, DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_EMBEDDING_PROTOCOL, EDGE_TYPES, EMBEDDING_PROTOCOL_AUTO, EMBEDDING_PROTOCOL_OLLAMA, EMBEDDING_PROTOCOL_OPENAI, EdgeType, EntityView, INTENTS, Insight, Intent, type JsonValue, LlmMemoryPlacementSelection, MNEMON_EMBEDDING_PROTOCOLS, MemoryBody, MemoryBodyCatalog, MemoryBodyMetadataMaintenanceResult, MemoryBodyMetadataSample, MemoryBodyMetadataUpdate, MemoryBodyProvider, MemoryBodyStats, MemoryBodyView, MemoryGraphEdge, MemoryGraphNode, MemoryGraphSnapshot, MemoryListRequest, MemoryListView, MemoryPersistenceStrategy, MemoryPlacementCandidate, MemoryPlacementCapability, MemoryPlacementDecision, MemoryPlacementPreference, MemoryPlacementRules, MemoryProviderCapabilities, MemoryProviderConfigField, MemoryProviderConfigOption, MemoryProviderConnection, MemoryProviderConnectionValue, MemoryProviderDescriptor, MemoryProviderIcon, MemoryProviderId, MemoryProviderRuntimeStatus, MemoryProviderServiceCatalog, MemoryProviderServiceView, MemoryReadMode, MemoryReadSource, MemoryReadStatus, MemorySpacesStatus, MnemonEmbeddingConfig, MnemonEmbeddingProtocol, MnemonEmbeddingStatus, OpenVikingBodyConnection, PreparedMemoryPlacement, RecallQualityConfig, RecallQualityStats, RecallRelevanceTier, RememberRequest, ResolvedMemoryPersistenceStrategy, ResolvedMnemonEmbeddingConfig, ResolvedRecallQualityConfig, SOURCES, SearchRequest, Source, UpdateMemoryBodyRequest, UpdateMemoryProviderServiceRequest };
|
package/lib/contracts.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/contracts.ts
|
|
2
|
+
const CATEGORIES = [
|
|
3
|
+
"preference",
|
|
4
|
+
"decision",
|
|
5
|
+
"fact",
|
|
6
|
+
"insight",
|
|
7
|
+
"context",
|
|
8
|
+
"general"
|
|
9
|
+
];
|
|
10
|
+
const SOURCES = [
|
|
11
|
+
"user",
|
|
12
|
+
"agent",
|
|
13
|
+
"external"
|
|
14
|
+
];
|
|
15
|
+
const EDGE_TYPES = [
|
|
16
|
+
"temporal",
|
|
17
|
+
"semantic",
|
|
18
|
+
"causal",
|
|
19
|
+
"entity"
|
|
20
|
+
];
|
|
21
|
+
const INTENTS = [
|
|
22
|
+
"WHY",
|
|
23
|
+
"WHEN",
|
|
24
|
+
"ENTITY",
|
|
25
|
+
"GENERAL"
|
|
26
|
+
];
|
|
27
|
+
const DEFAULT_EMBEDDING_ENDPOINT = "http://localhost:11434";
|
|
28
|
+
const DEFAULT_EMBEDDING_MODEL = "nomic-embed-text";
|
|
29
|
+
const EMBEDDING_PROTOCOL_AUTO = "auto";
|
|
30
|
+
const EMBEDDING_PROTOCOL_OLLAMA = "ollama";
|
|
31
|
+
const EMBEDDING_PROTOCOL_OPENAI = "openai";
|
|
32
|
+
/** Default protocol defers to Mnemon's /v1 auto-detection. */
|
|
33
|
+
const DEFAULT_EMBEDDING_PROTOCOL = EMBEDDING_PROTOCOL_AUTO;
|
|
34
|
+
/** Wire protocols accepted by the embedding protocol override; single source for schema, resolver, and UI validation. */
|
|
35
|
+
const MNEMON_EMBEDDING_PROTOCOLS = [
|
|
36
|
+
EMBEDDING_PROTOCOL_AUTO,
|
|
37
|
+
EMBEDDING_PROTOCOL_OLLAMA,
|
|
38
|
+
EMBEDDING_PROTOCOL_OPENAI
|
|
39
|
+
];
|
|
40
|
+
//#endregion
|
|
41
|
+
export { CATEGORIES, DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_EMBEDDING_PROTOCOL, EDGE_TYPES, EMBEDDING_PROTOCOL_AUTO, EMBEDDING_PROTOCOL_OLLAMA, EMBEDDING_PROTOCOL_OPENAI, INTENTS, MNEMON_EMBEDDING_PROTOCOLS, SOURCES };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { EdgeType, Insight, JsonValue, MemoryBody, MemoryBodyStats, MemoryGraphSnapshot, MemoryListRequest, MemoryProviderCapabilities, MemoryProviderConfigField, MemoryProviderConnection, MemoryProviderDescriptor, MemoryProviderIcon, RememberRequest, SearchRequest } from "./contracts.js";
|
|
2
|
+
import { Context, Plugin } from "@deepseek-ai/cordis";
|
|
3
|
+
//#region src/providers/adapter.d.ts
|
|
4
|
+
/** Minimum parent authority a Provider needs; no private controller class. */
|
|
5
|
+
interface MemorySpaceAuthority {
|
|
6
|
+
readonly runner: {
|
|
7
|
+
effectiveDataDir(): string;
|
|
8
|
+
};
|
|
9
|
+
list(): MemoryBody[];
|
|
10
|
+
providerConnection(id: string, expectedProviderId?: string): MemoryProviderConnection;
|
|
11
|
+
}
|
|
12
|
+
/** Scoped command transport consumed by the Native Provider. */
|
|
13
|
+
interface MemorySpaceNativeRunner {
|
|
14
|
+
runJson(args: readonly string[], options?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
store?: string;
|
|
17
|
+
}): Promise<JsonValue>;
|
|
18
|
+
runText(args: readonly string[], options?: {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
store?: string;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
interface MemoryProviderAdapterFactoryContext {
|
|
24
|
+
memoryBodies: MemorySpaceAuthority;
|
|
25
|
+
config: {
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
defaultRecallLimit?: number;
|
|
28
|
+
};
|
|
29
|
+
nativeRunner?: MemorySpaceNativeRunner;
|
|
30
|
+
}
|
|
31
|
+
interface ProviderBodyStatus {
|
|
32
|
+
healthy: boolean;
|
|
33
|
+
error?: string;
|
|
34
|
+
stats?: MemoryBodyStats;
|
|
35
|
+
}
|
|
36
|
+
interface ProviderSearchResult {
|
|
37
|
+
results: Insight[];
|
|
38
|
+
hint?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ProviderScoreSemantics {
|
|
41
|
+
/** Provider promises a finite relevance score in 0..1 where larger is better. */
|
|
42
|
+
kind: 'normalized-relevance';
|
|
43
|
+
}
|
|
44
|
+
type MemoryProviderScoreSemantics = 'normalized-relevance' | 'provider-native' | 'none';
|
|
45
|
+
declare const NORMALIZED_RELEVANCE_SCORE: ProviderScoreSemantics;
|
|
46
|
+
/** One provider-owned namespace projected into DSH as a Memory Space. */
|
|
47
|
+
interface ProviderMemorySpace {
|
|
48
|
+
/** Stable identifier owned by the provider, never a DSH-generated title. */
|
|
49
|
+
externalId: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
connection: MemoryProviderConnection;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Third-layer memory data plane. DSH owns routing and lifecycle; adapters own
|
|
56
|
+
* only one body's persistence and retrieval semantics.
|
|
57
|
+
*/
|
|
58
|
+
interface MemoryProviderAdapter {
|
|
59
|
+
readonly id: MemoryBody['provider']['id'];
|
|
60
|
+
readonly scoreSemantics?: ProviderScoreSemantics;
|
|
61
|
+
/** Enumerate the complete set of namespaces visible to this service connection. */
|
|
62
|
+
discover?(connection: MemoryProviderConnection, signal?: AbortSignal): Promise<ProviderMemorySpace[]>;
|
|
63
|
+
/** Drop a short-lived health result before an explicit user reconnect. */
|
|
64
|
+
invalidateStatus?(memoryBodyId?: string): void;
|
|
65
|
+
status(body: MemoryBody, signal?: AbortSignal): Promise<ProviderBodyStatus>;
|
|
66
|
+
search(body: MemoryBody, request: SearchRequest, signal?: AbortSignal): Promise<ProviderSearchResult>;
|
|
67
|
+
graph(body: MemoryBody, signal?: AbortSignal): Promise<MemoryGraphSnapshot>;
|
|
68
|
+
list(body: MemoryBody, request: MemoryListRequest, signal?: AbortSignal): Promise<Insight[]>;
|
|
69
|
+
remember(body: MemoryBody, request: RememberRequest, signal?: AbortSignal): Promise<JsonValue>;
|
|
70
|
+
/** Optional cheap bounded metadata sampling, without a graph projection. */
|
|
71
|
+
metadataSample?(body: MemoryBody, limit: number, signal?: AbortSignal): Promise<Insight[]>;
|
|
72
|
+
/** Persist an ordered host-authorized batch and return one receipt per request. */
|
|
73
|
+
rememberMany?(body: MemoryBody, requests: readonly RememberRequest[], signal?: AbortSignal): Promise<JsonValue[]>;
|
|
74
|
+
related?(body: MemoryBody, id: string, depth: number, edge?: EdgeType, signal?: AbortSignal): Promise<Insight[]>;
|
|
75
|
+
link?(body: MemoryBody, sourceId: string, targetId: string, type: EdgeType, weight: number, reason?: string, signal?: AbortSignal): Promise<JsonValue>;
|
|
76
|
+
forget?(body: MemoryBody, id: string, signal?: AbortSignal): Promise<JsonValue>;
|
|
77
|
+
/** Release generation-owned clients, timers, pools, or subprocess handles. */
|
|
78
|
+
dispose?(): void | Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/providers/definitions.d.ts
|
|
82
|
+
declare const MEMORY_SPACE_PROVIDER_API_VERSION: "dsh-mnemon.memory-space-provider/v1";
|
|
83
|
+
type MemorySpaceProviderScoreSemantics = 'normalized-relevance' | 'provider-native' | 'none';
|
|
84
|
+
/**
|
|
85
|
+
* Complete, JSON-safe definition metadata owned by the Memory Spaces Source.
|
|
86
|
+
* It is deliberately not a Mnemon-wide contribution manifest.
|
|
87
|
+
*/
|
|
88
|
+
interface MemorySpaceProviderManifest {
|
|
89
|
+
apiVersion: typeof MEMORY_SPACE_PROVIDER_API_VERSION;
|
|
90
|
+
kind: 'provider';
|
|
91
|
+
typeId: string;
|
|
92
|
+
packageName: string;
|
|
93
|
+
version: string;
|
|
94
|
+
label: string;
|
|
95
|
+
icon?: MemoryProviderIcon | undefined;
|
|
96
|
+
summary: string;
|
|
97
|
+
summaryI18nKey?: string;
|
|
98
|
+
origin: 'native' | 'third-party';
|
|
99
|
+
locality: 'local' | 'remote';
|
|
100
|
+
workspaceBinding: MemoryProviderDescriptor['workspaceBinding'];
|
|
101
|
+
capabilities: MemoryProviderCapabilities;
|
|
102
|
+
fields: MemoryProviderConfigField[];
|
|
103
|
+
secrets: string[];
|
|
104
|
+
scoreSemantics: MemorySpaceProviderScoreSemantics;
|
|
105
|
+
}
|
|
106
|
+
interface MemorySpaceProviderRuntimeContext extends MemoryProviderAdapterFactoryContext {
|
|
107
|
+
/** Stable identity of this child mount inside one Memory Spaces Source. */
|
|
108
|
+
providerInstanceId: string;
|
|
109
|
+
manifest: MemorySpaceProviderManifest;
|
|
110
|
+
}
|
|
111
|
+
interface MemorySpaceProviderDefinition {
|
|
112
|
+
manifest: MemorySpaceProviderManifest;
|
|
113
|
+
create(context: MemorySpaceProviderRuntimeContext): MemoryProviderAdapter;
|
|
114
|
+
}
|
|
115
|
+
type MemorySpaceProviderDisposer = () => void | Promise<void>;
|
|
116
|
+
/** Capability handed directly to one child Fiber through a lexical closure. */
|
|
117
|
+
interface MemorySpaceProviderHost {
|
|
118
|
+
install(owner: Context, definition: MemorySpaceProviderDefinition): MemorySpaceProviderDisposer;
|
|
119
|
+
}
|
|
120
|
+
/** Typed child module mounted only by a Memory Spaces parent Fiber. */
|
|
121
|
+
interface MemorySpaceProviderModule<Config = undefined> {
|
|
122
|
+
readonly id: string;
|
|
123
|
+
/** Optional Cordis-compatible Standard Schema used for this child config. */
|
|
124
|
+
readonly Config?: Plugin.Base<Config>['Config'];
|
|
125
|
+
apply(ctx: Context, host: MemorySpaceProviderHost, config: Config): void | Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
interface MemorySpaceProviderEntry<Config = unknown> {
|
|
128
|
+
instanceId: string;
|
|
129
|
+
module: MemorySpaceProviderModule<Config>;
|
|
130
|
+
config: Config;
|
|
131
|
+
}
|
|
132
|
+
declare function defineMemorySpaceProvider<Config>(module: MemorySpaceProviderModule<Config>): MemorySpaceProviderModule<Config>;
|
|
133
|
+
declare function defineMemorySpaceProviderDefinition(definition: MemorySpaceProviderDefinition): MemorySpaceProviderDefinition;
|
|
134
|
+
//#endregion
|
|
135
|
+
export { NORMALIZED_RELEVANCE_SCORE as _, MemorySpaceProviderHost as a, ProviderScoreSemantics as b, MemorySpaceProviderRuntimeContext as c, defineMemorySpaceProviderDefinition as d, MemoryProviderAdapter as f, MemorySpaceNativeRunner as g, MemorySpaceAuthority as h, MemorySpaceProviderEntry as i, MemorySpaceProviderScoreSemantics as l, MemoryProviderScoreSemantics as m, MemorySpaceProviderDefinition as n, MemorySpaceProviderManifest as o, MemoryProviderAdapterFactoryContext as p, MemorySpaceProviderDisposer as r, MemorySpaceProviderModule as s, MEMORY_SPACE_PROVIDER_API_VERSION as t, defineMemorySpaceProvider as u, ProviderBodyStatus as v, ProviderSearchResult as x, ProviderMemorySpace as y };
|