@mnemo-ai/client-ts 0.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/LICENSE +201 -0
- package/README.es.md +181 -0
- package/README.md +181 -0
- package/dist/index.cjs +2778 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4176 -0
- package/dist/index.d.ts +4176 -0
- package/dist/index.js +2772 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type contracts for the Mnemosyne HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* These shapes mirror the zod schemas that @mnemo-ai/server validates
|
|
5
|
+
* incoming/outgoing payloads against. They are duplicated here (rather
|
|
6
|
+
* than imported as a runtime dependency) so that:
|
|
7
|
+
* 1. The client SDK has ZERO runtime dependencies — installing it
|
|
8
|
+
* doesn't pull in the entire server graph (Drizzle, pg, pgvector
|
|
9
|
+
* bindings, etc.).
|
|
10
|
+
* 2. The client can be used in browsers, Cloudflare Workers, Bun,
|
|
11
|
+
* Deno, etc. — environments where the server package would refuse
|
|
12
|
+
* to install.
|
|
13
|
+
*
|
|
14
|
+
* If you bump a server schema, update the matching type here. We rely
|
|
15
|
+
* on the API contract test (`packages/server/__tests__/contract.test.ts`)
|
|
16
|
+
* to catch drift between the two copies.
|
|
17
|
+
*
|
|
18
|
+
* For type-only sharing of richer domain types (e.g. Attribution, Kind),
|
|
19
|
+
* users can `import type` from @mnemo-ai/core — it's an optional peer.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Provenance bag attached to a fact. The server stores this as a free-form
|
|
23
|
+
* record (recommended fields: source, actor, message_id, timestamp), so we
|
|
24
|
+
* type it loosely rather than freezing a union that would drift from the
|
|
25
|
+
* server's `z.record(z.unknown())`.
|
|
26
|
+
*/
|
|
27
|
+
type Attribution = Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Per-request observation metadata sent as headers. Versions that are not
|
|
30
|
+
* declared are omitted (the server records them as "unknown").
|
|
31
|
+
*/
|
|
32
|
+
interface RequestObservation {
|
|
33
|
+
/** Caller-chosen `X-Request-Id`; generated once per logical request when omitted. */
|
|
34
|
+
requestId?: string;
|
|
35
|
+
/** Declared writer/reader identity, sent as `X-Mnemo-Caller`. */
|
|
36
|
+
caller?: string;
|
|
37
|
+
/** SDK version, sent as `X-Mnemo-Client-Version`. */
|
|
38
|
+
clientVersion?: string;
|
|
39
|
+
/** Plugin version, sent as `X-Mnemo-Plugin-Version`. */
|
|
40
|
+
pluginVersion?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Sensitivity classification for a memory element. */
|
|
43
|
+
type Sensitivity = "public" | "internal" | "confidential" | "restricted";
|
|
44
|
+
/**
|
|
45
|
+
* The canonical fact shape returned by the API.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors the server's `FactSchema` (packages/server/src/routes/facts.ts)
|
|
48
|
+
* exactly: bitemporal facts are never hard-deleted — `validTo` is set to
|
|
49
|
+
* the close time instead, so it's nullable.
|
|
50
|
+
*/
|
|
51
|
+
interface Fact {
|
|
52
|
+
id: string;
|
|
53
|
+
workspaceId: string;
|
|
54
|
+
content: string;
|
|
55
|
+
attribution: Attribution;
|
|
56
|
+
tags: string[];
|
|
57
|
+
pinned: boolean;
|
|
58
|
+
/** ISO 8601 string — JSON has no native Date. */
|
|
59
|
+
validFrom: string;
|
|
60
|
+
/** ISO 8601 string, or null while the fact is still open. */
|
|
61
|
+
validTo: string | null;
|
|
62
|
+
/** ISO 8601 string — JSON has no native Date. */
|
|
63
|
+
createdAt: string;
|
|
64
|
+
/**
|
|
65
|
+
* Provenance fields, returned only by `GET /facts/{id}?provenance=true`.
|
|
66
|
+
* `supersededById` is null for a closed fact with no successor or one above
|
|
67
|
+
* the caller's sensitivity ceiling (`supersededAt` is then absent); both are
|
|
68
|
+
* omitted for active facts. `sessionId` is null when there is none or the
|
|
69
|
+
* source episode is above the ceiling.
|
|
70
|
+
*/
|
|
71
|
+
sessionId?: string | null;
|
|
72
|
+
supersededById?: string | null;
|
|
73
|
+
supersededAt?: string | null;
|
|
74
|
+
/** Ids of the facts this one superseded, newest first. */
|
|
75
|
+
supersedesIds?: string[];
|
|
76
|
+
/** How many times recall has served this fact. Optional: older servers omit it. */
|
|
77
|
+
hitCount?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Input shape for `client.recall(...)`.
|
|
81
|
+
*
|
|
82
|
+
* Mirrors the server's `POST /recall` request schema EXACTLY (see
|
|
83
|
+
* packages/server/src/routes/recall.ts → RecallRequestSchema). The wire
|
|
84
|
+
* body is this object verbatim — field names must not drift or the
|
|
85
|
+
* server rejects with a 400.
|
|
86
|
+
*/
|
|
87
|
+
interface RecallInput {
|
|
88
|
+
/** Free-text query — used for lexical match and (if no vector) embedding. */
|
|
89
|
+
query: string;
|
|
90
|
+
/**
|
|
91
|
+
* Optional pre-embedded query vector. When supplied, the server skips
|
|
92
|
+
* its own embedding pass and uses this directly — no LLM round-trip,
|
|
93
|
+
* deterministic. Useful when the caller already has the vector cached.
|
|
94
|
+
*/
|
|
95
|
+
vector?: number[];
|
|
96
|
+
/** Max number of hits to return. Server default 10, clamps to 100. */
|
|
97
|
+
topK?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Point-in-time recall (ISO 8601, not in the future): rank what memory held
|
|
100
|
+
* at that instant, including rows superseded since.
|
|
101
|
+
*/
|
|
102
|
+
asOf?: string;
|
|
103
|
+
/** Opt-in HyDE pre-step: one LLM call that writes a hypothetical answer to search with. Default false. */
|
|
104
|
+
hyde?: boolean;
|
|
105
|
+
/** Return each hit's relations and hyperedges. Default false. */
|
|
106
|
+
includeGraph?: boolean;
|
|
107
|
+
/** B5.1 Explicit search mode: "lexical" | "semantic" | "hybrid" | "auto". */
|
|
108
|
+
mode?: "lexical" | "semantic" | "hybrid" | "auto";
|
|
109
|
+
minSimilarity?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Blend factor: 0 = pure lexical, 1 = pure vector. Server default 0.5. Deprecated in favor of mode.
|
|
112
|
+
*/
|
|
113
|
+
vectorWeight?: number;
|
|
114
|
+
/** Filter recall to facts with this scope. */
|
|
115
|
+
scope?: "global" | "conversation" | "personal";
|
|
116
|
+
/** Filter recall to facts with this scopeRef (e.g. 'mnemosyne', 'project:abc'). */
|
|
117
|
+
scopeRef?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Filter recall to facts whose stored actorId equals this value exactly —
|
|
120
|
+
* the namespaced credential reference (e.g. "key:<id>") that wrote the
|
|
121
|
+
* fact, NOT reliably a userId. There is no userId-based recall filter yet
|
|
122
|
+
* (the server doesn't accept one — see RecallHit.userId for reading, not
|
|
123
|
+
* filtering, the platform account on a hit).
|
|
124
|
+
*/
|
|
125
|
+
actorId?: string;
|
|
126
|
+
/**
|
|
127
|
+
* autonomous-memory session-correlation id (the Mnemosyne session/episode
|
|
128
|
+
* id, e.g. from {@link MnemosyneClient.createSession}). When supplied, the
|
|
129
|
+
* server best-effort-stamps `metadata.lastRecallAt` on that session so a
|
|
130
|
+
* later `getSession` call can confirm recall happened during it. A stale
|
|
131
|
+
* or unknown id is silently ignored — never fails the recall itself.
|
|
132
|
+
*/
|
|
133
|
+
sessionId?: string;
|
|
134
|
+
/**
|
|
135
|
+
* P67 — how much of each hit to return. `full` (default over HTTP) sends the
|
|
136
|
+
* whole `content`; `compact` sends a 300-character preview plus
|
|
137
|
+
* `truncated: true`, and you fetch the rest per-hit with `getFact(id)`.
|
|
138
|
+
*/
|
|
139
|
+
projection?: "full" | "compact";
|
|
140
|
+
/**
|
|
141
|
+
* P67 — which primitive kinds to search. Omit for the default set. `task`,
|
|
142
|
+
* `event` and `reasoning` are indexed but not returned by default.
|
|
143
|
+
*/
|
|
144
|
+
kinds?: string[];
|
|
145
|
+
/** When true the response's `debug.trace` lists the pipeline stages that ran. */
|
|
146
|
+
debug?: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* One hit from a recall response. Mirrors the server's `RecallHitSchema`
|
|
150
|
+
* (packages/server/src/routes/recall.ts) EXACTLY.
|
|
151
|
+
*
|
|
152
|
+
* `score` is the blended ranking score (higher = more relevant); it
|
|
153
|
+
* combines vector similarity and lexical match per `vectorWeight`. Don't
|
|
154
|
+
* compare scores across queries — they're only meaningful within a single
|
|
155
|
+
* response. `lexicalScore` / `vectorScore` expose the two un-blended
|
|
156
|
+
* components for debugging recall quality.
|
|
157
|
+
*/
|
|
158
|
+
interface RecallHit {
|
|
159
|
+
id: string;
|
|
160
|
+
content: string;
|
|
161
|
+
/**
|
|
162
|
+
* P67 — present and true only when `projection: 'compact'` cut this hit's
|
|
163
|
+
* `content` to a 300-character preview. Fetch the full text with
|
|
164
|
+
* `getFact(id)`, and only for the hits you will actually use.
|
|
165
|
+
*/
|
|
166
|
+
truncated?: boolean;
|
|
167
|
+
score: number;
|
|
168
|
+
/** Raw semantic cosine, when this fact was found by the vector arm. */
|
|
169
|
+
similarity?: number;
|
|
170
|
+
/** Un-blended lexical (BM25) component, when available. */
|
|
171
|
+
lexicalScore?: number;
|
|
172
|
+
/** Un-blended vector-similarity component, when available. */
|
|
173
|
+
vectorScore?: number;
|
|
174
|
+
/** Valid-time start (bitemporal). ISO 8601. */
|
|
175
|
+
validFrom: string;
|
|
176
|
+
/** Valid-time end, or null if still valid. ISO 8601. */
|
|
177
|
+
validTo: string | null;
|
|
178
|
+
attribution?: Attribution;
|
|
179
|
+
tags?: string[];
|
|
180
|
+
/**
|
|
181
|
+
* The namespaced actor reference that stored this fact (e.g. "key:<id>")
|
|
182
|
+
* — the credential, NOT reliably a userId. Use `userId` below for the
|
|
183
|
+
* platform account, when present.
|
|
184
|
+
*/
|
|
185
|
+
actorId?: string | null;
|
|
186
|
+
/** The platform account (mnemo_user.id) that stored this fact, when one exists. */
|
|
187
|
+
userId?: string | null;
|
|
188
|
+
/**
|
|
189
|
+
* topicKey-suggest-and-hit-freshness slice (c): staleness bucket of this
|
|
190
|
+
* hit's `validFrom` (valid-time), computed at recall time — "current"
|
|
191
|
+
* (<7d), "recent" (<30d), "aging" (<90d), "stale" (>=90d). NOT the same
|
|
192
|
+
* concept as `memory_introspect`'s entity-level
|
|
193
|
+
* `SelfModel.confidenceMap[].freshness` (a transaction-time aggregate).
|
|
194
|
+
*/
|
|
195
|
+
hitFreshness?: "current" | "recent" | "aging" | "stale";
|
|
196
|
+
/** Only with `includeGraph: true`: outgoing relations of this memory. */
|
|
197
|
+
relations?: Array<{
|
|
198
|
+
id: string;
|
|
199
|
+
targetId: string;
|
|
200
|
+
targetKind: string;
|
|
201
|
+
verb: string;
|
|
202
|
+
weight: number;
|
|
203
|
+
}>;
|
|
204
|
+
/** Only with `includeGraph: true`: groups this memory belongs to; co-members are ids, not hits. */
|
|
205
|
+
hyperedges?: Array<{
|
|
206
|
+
id: string;
|
|
207
|
+
coMembers: string[];
|
|
208
|
+
label?: string;
|
|
209
|
+
worth?: number;
|
|
210
|
+
}>;
|
|
211
|
+
/**
|
|
212
|
+
* Only on an item pulled from a federation peer: the id this server registered
|
|
213
|
+
* that peer under, and the fixed trust given to federated items.
|
|
214
|
+
*/
|
|
215
|
+
federation?: {
|
|
216
|
+
peer: string;
|
|
217
|
+
trustScore: number;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Wire response from `POST /recall`. Mirrors the server's
|
|
222
|
+
* `RecallResponseSchema`.
|
|
223
|
+
*/
|
|
224
|
+
interface RecallResponse {
|
|
225
|
+
hits: RecallHit[];
|
|
226
|
+
/** Present when the server had to embed the query (no `vector` supplied). */
|
|
227
|
+
debug?: {
|
|
228
|
+
embedded: boolean;
|
|
229
|
+
latencyMs?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Which ranking path actually produced these hits. `"fts"` means the
|
|
232
|
+
* request fell back to full-text/`ts_rank` ranking (no embedder
|
|
233
|
+
* configured); anything else means the HNSW vector cascade ran. This
|
|
234
|
+
* field was always present on the wire (packages/server/src/routes/
|
|
235
|
+
* recall.ts) but missing from this type — callers (e.g. the
|
|
236
|
+
* `memory_search` MCP tool) that only trust the TypeScript surface
|
|
237
|
+
* silently dropped it instead of surfacing it to the calling agent.
|
|
238
|
+
* NOTE: this is NOT the same thing as the request's own `mode` field —
|
|
239
|
+
* the server route does not currently forward `mode`/`vectorWeight`
|
|
240
|
+
* from the request into the ranking pipeline (see MCP-1 in
|
|
241
|
+
* docs/archive/openspec/tool-promise-remediation/spec.md), so `searchMode` here
|
|
242
|
+
* will read `"auto"` even when the caller explicitly asked for
|
|
243
|
+
* `mode: "semantic"` or `vectorWeight: 1`.
|
|
244
|
+
*/
|
|
245
|
+
searchMode?: "vector" | "fts" | "lexical" | "semantic" | "hybrid" | "auto";
|
|
246
|
+
/**
|
|
247
|
+
* Per-stage trace, present only when the request set `debug: true`.
|
|
248
|
+
* `ms` is the time since the previous stage in execution order; a tier
|
|
249
|
+
* miss reports 0 candidates. Counts are null for every stage before
|
|
250
|
+
* `eligibility` unless the caller's sensitivity ceiling admits every tier
|
|
251
|
+
* (they would count memories the caller cannot read); `eligibility` then
|
|
252
|
+
* reports only the candidates that passed it, in and out.
|
|
253
|
+
*/
|
|
254
|
+
trace?: Array<{
|
|
255
|
+
name: string;
|
|
256
|
+
candidatesIn: number | null;
|
|
257
|
+
candidatesOut: number | null;
|
|
258
|
+
ms: number;
|
|
259
|
+
}>;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* REMIND-1: reminders whose trigger fired on this recall call. Already
|
|
263
|
+
* transitioned to status='triggered' server-side — surface them to the user
|
|
264
|
+
* or they are effectively lost (re-readable via
|
|
265
|
+
* `listReminders({ status: "triggered" })`).
|
|
266
|
+
*/
|
|
267
|
+
reminders?: Array<{
|
|
268
|
+
id: string;
|
|
269
|
+
content: string;
|
|
270
|
+
condition: string | null;
|
|
271
|
+
triggeredBy: "time" | "semantic" | "both";
|
|
272
|
+
}>;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Input shape for `client.createFact(...)`.
|
|
276
|
+
*
|
|
277
|
+
* Matches the server's `CreateFactSchema` (POST /facts) exactly:
|
|
278
|
+
* `{ content, attribution, tags }`. There is no statement/subject/kind/
|
|
279
|
+
* confidence on the wire — friendlier names belong to higher layers
|
|
280
|
+
* (e.g. the MCP `memory_remember` tool) which map onto these fields
|
|
281
|
+
* before calling this method.
|
|
282
|
+
*/
|
|
283
|
+
interface CreateFactInput {
|
|
284
|
+
/** The fact content. Free-form text; keep it atomic — one claim per fact. */
|
|
285
|
+
content: string;
|
|
286
|
+
/** Provenance bag. Recommended fields: source, actor, message_id, timestamp. */
|
|
287
|
+
attribution?: Attribution;
|
|
288
|
+
/** Optional tags for filtering and rollups. Server defaults to []. */
|
|
289
|
+
tags?: string[];
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Input shape for `client.remember(...)`.
|
|
293
|
+
*
|
|
294
|
+
* Calls POST /memory/remember — the cognitive engine endpoint that supports
|
|
295
|
+
* scope/scopeRef for project-namespaced memory.
|
|
296
|
+
*/
|
|
297
|
+
interface RememberInput {
|
|
298
|
+
statement: string;
|
|
299
|
+
subject?: string;
|
|
300
|
+
kind?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Type-specific subtype, used only when kind is 'fact', 'decision', or
|
|
303
|
+
* 'entity'. See RememberInput.kind for the primitive taxonomy — this
|
|
304
|
+
* field is the taxonomy *within* that primitive (for kind='fact':
|
|
305
|
+
* {@link MemoryFactKind}). A value outside the kind's list is stored as
|
|
306
|
+
* 'other' (a decision: 'decision') and reported in
|
|
307
|
+
* {@link RememberResponse.warnings}; an empty value is a 400.
|
|
308
|
+
*/
|
|
309
|
+
subtype?: string;
|
|
310
|
+
confidence?: number;
|
|
311
|
+
agentId?: string;
|
|
312
|
+
conversationId?: string;
|
|
313
|
+
sensitivity?: Sensitivity;
|
|
314
|
+
tags?: string[];
|
|
315
|
+
/**
|
|
316
|
+
* The session this write happened during. Correlation only (no FK).
|
|
317
|
+
* Passing it is what lets the episodic collapse back-fill `episodeId` — the
|
|
318
|
+
* canonical origin link — for every fact written during the session, so a
|
|
319
|
+
* caller that supplies only this still ends up with real origin context.
|
|
320
|
+
*/
|
|
321
|
+
sessionId?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Attach the fact to an episode that ALREADY exists (post-hoc correction,
|
|
324
|
+
* backfill, import). The normal path is `sessionId` + collapse.
|
|
325
|
+
* An id that names no episode is dropped with a server-side warning and the
|
|
326
|
+
* fact is still written — never a rejected write.
|
|
327
|
+
*/
|
|
328
|
+
episodeId?: string;
|
|
329
|
+
/**
|
|
330
|
+
* kind 'fact' only: when the fact became true in the world (valid time), as
|
|
331
|
+
* an ISO 8601 instant. Omitted, the server uses the time of the write. A
|
|
332
|
+
* future instant answers 400; other kinds ignore it.
|
|
333
|
+
*/
|
|
334
|
+
validFrom?: string;
|
|
335
|
+
metadata?: Record<string, unknown>;
|
|
336
|
+
/** Scope of the fact — default 'global'. */
|
|
337
|
+
scope?: "global" | "conversation" | "personal";
|
|
338
|
+
/** Project/entity ref for scoped recall (e.g. 'mnemosyne', 'project:abc'). */
|
|
339
|
+
scopeRef?: string;
|
|
340
|
+
/** Ownership level: 'workspace:<id>' | 'user:<id>' | 'tenant:<id>'. Default: workspace. */
|
|
341
|
+
scopeOwner?: string;
|
|
342
|
+
/**
|
|
343
|
+
* Write to a different workspace than the one in the API key.
|
|
344
|
+
* The key's user must be a member (write/admin/owner) of the target workspace.
|
|
345
|
+
* Use memory_context to discover available workspace IDs.
|
|
346
|
+
*/
|
|
347
|
+
targetWorkspaceId?: string;
|
|
348
|
+
/**
|
|
349
|
+
* Host-side pre-computed embedding. When supplied, the server skips its own
|
|
350
|
+
* LLM embed pass and stores this vector directly. Must match the workspace's
|
|
351
|
+
* recall embedding model (default: text-embedding-3-small, 1536 dims).
|
|
352
|
+
*/
|
|
353
|
+
vector?: number[];
|
|
354
|
+
/**
|
|
355
|
+
* Idempotency key: a second `remember()` call with the same `topicKey`
|
|
356
|
+
* updates the existing active row in place (revision bumped) instead of
|
|
357
|
+
* creating a duplicate. Works for `kind: "fact"` and `kind: "decision"`.
|
|
358
|
+
*/
|
|
359
|
+
topicKey?: string;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* One of the 3 verdict actions the server's §33 deterministic conflict
|
|
363
|
+
* resolver can produce for a contradicting fact.
|
|
364
|
+
*
|
|
365
|
+
* Structural copy of `ConflictVerdictAction` (`@mnemo-ai/types`) — `client-ts`
|
|
366
|
+
* does not depend on `@mnemo-ai/types`, it talks to the server over HTTP.
|
|
367
|
+
*/
|
|
368
|
+
type ConflictVerdictAction = "supersede" | "reject" | "review";
|
|
369
|
+
/**
|
|
370
|
+
* Structural copy of `RememberConflictCandidate` (`@mnemo-ai/types`).
|
|
371
|
+
*/
|
|
372
|
+
interface RememberConflictCandidate {
|
|
373
|
+
/** The EXISTING contradicting fact's id — never the newly written fact. */
|
|
374
|
+
id: string;
|
|
375
|
+
subject: string;
|
|
376
|
+
statement: string;
|
|
377
|
+
action: ConflictVerdictAction;
|
|
378
|
+
/**
|
|
379
|
+
* The pending `conflicts_with` relation id. THIS is the judgmentId passed
|
|
380
|
+
* to `memory_judge action="resolve"` / `POST /conflicts/:id/resolve`.
|
|
381
|
+
* Present only for "reject" | "review". Absent for "supersede" (already
|
|
382
|
+
* auto-resolved).
|
|
383
|
+
*/
|
|
384
|
+
relationId?: string;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Structural copy of `RememberConflict` (`@mnemo-ai/types`).
|
|
388
|
+
*/
|
|
389
|
+
interface RememberConflict {
|
|
390
|
+
/** true iff at least one emitted candidate has action !== "supersede". */
|
|
391
|
+
judgmentRequired: boolean;
|
|
392
|
+
candidates: RememberConflictCandidate[];
|
|
393
|
+
}
|
|
394
|
+
/** Response from POST /memory/remember. */
|
|
395
|
+
interface RememberResponse {
|
|
396
|
+
id: string;
|
|
397
|
+
workspaceId: string;
|
|
398
|
+
actorId?: string;
|
|
399
|
+
/**
|
|
400
|
+
* The text that was STORED, which is not always the text you sent.
|
|
401
|
+
*
|
|
402
|
+
* P121: PII is redacted before the row is written, so a statement carrying a
|
|
403
|
+
* phone number comes back with `[REDACTED-phone]` in its place. This used to
|
|
404
|
+
* echo the request instead, which meant a later recall returned different
|
|
405
|
+
* text than the write appeared to confirm — and the original is kept
|
|
406
|
+
* nowhere, so there was no way to reconcile the two.
|
|
407
|
+
*/
|
|
408
|
+
statement: string;
|
|
409
|
+
status: string;
|
|
410
|
+
/**
|
|
411
|
+
* P121: present ONLY when PII was redacted out of `statement`. Its presence
|
|
412
|
+
* is the signal — there is no empty-array case, so check existence, not
|
|
413
|
+
* length.
|
|
414
|
+
*/
|
|
415
|
+
redactedCategories?: string[];
|
|
416
|
+
/** Omitted entirely when no contradiction was detected (not null, not {}). */
|
|
417
|
+
conflict?: RememberConflict;
|
|
418
|
+
/**
|
|
419
|
+
* Q-3: present ONLY when part of the request was stored differently from
|
|
420
|
+
* how it was sent. The write itself succeeded.
|
|
421
|
+
*/
|
|
422
|
+
warnings?: RememberWarning[];
|
|
423
|
+
[key: string]: unknown;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* One entry of {@link RememberResponse.warnings}. `subtype_substituted`: the
|
|
427
|
+
* `subtype` is not in its kind's list and was stored as `storedAs`.
|
|
428
|
+
*/
|
|
429
|
+
interface RememberWarning {
|
|
430
|
+
code: "subtype_substituted";
|
|
431
|
+
field: "subtype";
|
|
432
|
+
received: string;
|
|
433
|
+
storedAs: string;
|
|
434
|
+
message: string;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Input shape for `client.suggestTopicKey(...)`.
|
|
438
|
+
*
|
|
439
|
+
* Matches the server's `POST /topic-key/suggest` body exactly: both fields
|
|
440
|
+
* optional, mirroring the fact `subject`/`statement` or decision
|
|
441
|
+
* `title`/`body` shapes. Pure derivation — no I/O, no LLM/embedding call.
|
|
442
|
+
*/
|
|
443
|
+
interface SuggestTopicKeyInput {
|
|
444
|
+
subject?: string;
|
|
445
|
+
body?: string;
|
|
446
|
+
/**
|
|
447
|
+
* What the fact is about, not its current value (e.g. "deploy method").
|
|
448
|
+
* When given, the key comes from subject + attribute and `body` is ignored,
|
|
449
|
+
* so an updated value gets the same key and supersedes the old one.
|
|
450
|
+
*/
|
|
451
|
+
attribute?: string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Response from `POST /topic-key/suggest`. `topicKey` is deterministic and
|
|
455
|
+
* idempotent: feeding a previously-suggested `topicKey` back in as `subject`
|
|
456
|
+
* (with no `body`) returns it unchanged.
|
|
457
|
+
*/
|
|
458
|
+
interface SuggestTopicKeyResponse {
|
|
459
|
+
topicKey: string;
|
|
460
|
+
/** 1 or 2 entries — the levels `topicKey` was assembled from. */
|
|
461
|
+
levels: string[];
|
|
462
|
+
source: "identity" | "subject+body" | "subject" | "body" | "fallback" | "subject+attribute" | "attribute";
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Input shape for `client.compareFacts(...)`.
|
|
466
|
+
*
|
|
467
|
+
* Matches the server's `POST /facts/compare` body exactly: both ids
|
|
468
|
+
* required, mirroring `memory_compare`'s `factIdA`/`factIdB` input.
|
|
469
|
+
*/
|
|
470
|
+
interface CompareFactsInput {
|
|
471
|
+
factIdA: string;
|
|
472
|
+
factIdB: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* The suggested relation verb `compareFacts` can return. Deliberately a
|
|
476
|
+
* 4-value subset of the full `RelationVerb` union — see
|
|
477
|
+
* `packages/server/src/facts/compare.ts`'s doc comment for the decision
|
|
478
|
+
* tree (`related` is never suggested, docs/archive/openspec/complete-mcp-tools B6).
|
|
479
|
+
*/
|
|
480
|
+
type SuggestableVerb = "supersedes" | "conflicts_with" | "compatible" | "scoped";
|
|
481
|
+
/**
|
|
482
|
+
* Response from `POST /facts/compare`. Both facts are returned in full
|
|
483
|
+
* (the same `Fact` shape `getFact` returns) alongside the structured diff.
|
|
484
|
+
*/
|
|
485
|
+
interface CompareFactsResponse {
|
|
486
|
+
factA: Fact;
|
|
487
|
+
factB: Fact;
|
|
488
|
+
differences: string[];
|
|
489
|
+
suggestedVerb: SuggestableVerb;
|
|
490
|
+
sameSubject: boolean;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Response from `client.createFact(...)`.
|
|
494
|
+
*
|
|
495
|
+
* `POST /facts` was deleted (flatten-legacy-dual-core D2 step 2) —
|
|
496
|
+
* `createFact` now calls `POST /remember` under the hood and remaps its
|
|
497
|
+
* `V3Fact` response back onto this legacy `Fact`-shaped contract
|
|
498
|
+
* (`statement` -> `content`) so existing callers don't break. Widened
|
|
499
|
+
* (flatten-legacy-dual-core D2 / task 5.6) with the optional `conflict`
|
|
500
|
+
* field `V3Fact` carries — surfacing write-time §33 contradiction verdicts
|
|
501
|
+
* is a capability gain, not something the old `POST /facts` route ever
|
|
502
|
+
* returned, so it's additive-only.
|
|
503
|
+
*/
|
|
504
|
+
interface CreateFactResponse extends Fact {
|
|
505
|
+
/**
|
|
506
|
+
* Write-time §33 contradiction verdicts. Present only when the server
|
|
507
|
+
* detected a contradicting fact. When `judgmentRequired` is true, resolve
|
|
508
|
+
* each candidate via `POST /conflicts/:id/resolve` (its `relationId`).
|
|
509
|
+
*/
|
|
510
|
+
conflict?: RememberConflict;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Input shape for `client.timeline(...)`.
|
|
514
|
+
*
|
|
515
|
+
* Mirrors the server's `TimelineQuerySchema` (GET /timeline), which
|
|
516
|
+
* only reads `since` + `limit`. The server does NOT support kind/status
|
|
517
|
+
* filters on this route, so we don't advertise no-op params.
|
|
518
|
+
*/
|
|
519
|
+
interface TimelineInput {
|
|
520
|
+
/** Server defaults to 100, caps at 500. */
|
|
521
|
+
limit?: number;
|
|
522
|
+
/** ISO 8601 — returns events strictly after this instant. Defaults to 24h ago. */
|
|
523
|
+
since?: string;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* One event from `client.timeline()`.
|
|
527
|
+
*
|
|
528
|
+
* Mirrors the server's `TimelineEventSchema`: a fact-lifecycle event
|
|
529
|
+
* (created / pinned / unpinned / closed / updated), NOT a fact snapshot.
|
|
530
|
+
*/
|
|
531
|
+
interface TimelineEvent {
|
|
532
|
+
id: string;
|
|
533
|
+
/** ISO 8601 string — when the event happened. */
|
|
534
|
+
at: string;
|
|
535
|
+
kind: "created" | "pinned" | "unpinned" | "closed" | "updated" | "decision_created" | "decision_superseded" | "decision_withdrawn";
|
|
536
|
+
/** Present on fact events, absent on decision events. */
|
|
537
|
+
factId?: string;
|
|
538
|
+
/** Present on decision events only. */
|
|
539
|
+
decisionId?: string;
|
|
540
|
+
actor?: string;
|
|
541
|
+
summary?: string;
|
|
542
|
+
/** The userId of the key owner who originally stored the underlying fact (P11 attribution). */
|
|
543
|
+
actorId?: string | null;
|
|
544
|
+
}
|
|
545
|
+
/** Response from `GET /timeline`. */
|
|
546
|
+
interface TimelineResponse {
|
|
547
|
+
events: TimelineEvent[];
|
|
548
|
+
/** Opaque cursor for the next page — may be a timestamp or an id, or null. */
|
|
549
|
+
nextCursor: string | null;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Snapshot from `GET /health`. Includes more than a binary "ok" so
|
|
553
|
+
* that operators can wire it into existing dashboards without a
|
|
554
|
+
* separate metrics endpoint.
|
|
555
|
+
*/
|
|
556
|
+
interface HealthSnapshot {
|
|
557
|
+
status: "ok" | "degraded" | "down";
|
|
558
|
+
version: string;
|
|
559
|
+
/** Server-side time at response generation. ISO 8601. */
|
|
560
|
+
timestamp: string;
|
|
561
|
+
/** Optional sub-component statuses (db, embedder, queue, …). */
|
|
562
|
+
components?: Record<string, "ok" | "degraded" | "down">;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Response from `GET /health/ready`. Unauthenticated, instance-wide (not
|
|
566
|
+
* scoped to any single workspace) — this is the ACTUAL per-dependency
|
|
567
|
+
* (postgres/vector/cache) probe; `HealthSnapshot` above does not describe
|
|
568
|
+
* any real route's wire shape.
|
|
569
|
+
*/
|
|
570
|
+
interface HealthReadySnapshot {
|
|
571
|
+
status: "ready" | "not_ready";
|
|
572
|
+
/** Present only when status is "ready". True if vector or cache is non-ok (postgres down always maps to not_ready). */
|
|
573
|
+
degraded?: boolean;
|
|
574
|
+
checks?: {
|
|
575
|
+
postgres: string;
|
|
576
|
+
vector: string;
|
|
577
|
+
cache: string;
|
|
578
|
+
};
|
|
579
|
+
/** Present only when status is "not_ready" (e.g. "postgres_unavailable"). */
|
|
580
|
+
reason?: string;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Response from `POST /facts/:id/pin`.
|
|
584
|
+
*
|
|
585
|
+
* The server returns the updated `Fact` (with the new `pinned` value),
|
|
586
|
+
* not a minimal {id, pinned} pair — match it.
|
|
587
|
+
*/
|
|
588
|
+
type PinResponse = Fact;
|
|
589
|
+
/**
|
|
590
|
+
* Result of `client.forgetFact(...)`.
|
|
591
|
+
*
|
|
592
|
+
* Forget maps to the server's soft-delete: DELETE /facts/:id, which
|
|
593
|
+
* returns 204 No Content (empty body). There is nothing to parse, so the
|
|
594
|
+
* method resolves to `void`.
|
|
595
|
+
*/
|
|
596
|
+
type ForgetResponse = void;
|
|
597
|
+
/** Retry configuration for transient failures. */
|
|
598
|
+
interface RetryConfig {
|
|
599
|
+
/** Number of attempts INCLUDING the original. Default 3. */
|
|
600
|
+
attempts?: number;
|
|
601
|
+
/** Initial backoff in ms (doubles each attempt + jitter). Default 200. */
|
|
602
|
+
initialDelayMs?: number;
|
|
603
|
+
/**
|
|
604
|
+
* Optional override of which errors are retryable. Default: 5xx and
|
|
605
|
+
* network errors retry; 4xx and timeouts do not.
|
|
606
|
+
*/
|
|
607
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Input shape for `client.graph(...)`.
|
|
611
|
+
*
|
|
612
|
+
* Mirrors the server's `GraphQuerySchema` (GET /graph). When `focus`
|
|
613
|
+
* is supplied, the server filters the returned set to that entity plus
|
|
614
|
+
* its 1-hop neighbours (and the edges between them). Without it, the
|
|
615
|
+
* full canonical workspace graph comes back.
|
|
616
|
+
*/
|
|
617
|
+
interface GraphInput {
|
|
618
|
+
/**
|
|
619
|
+
* Optional entity id to centre the graph on: a `mnemo_entity.id`, which is
|
|
620
|
+
* a UUID (e.g. `d0522e17-bd87-4ced-bc38-2b9a499beea7`), or a legacy
|
|
621
|
+
* `ment_<slug>` seed id. Anything else is rejected with 400 by the server.
|
|
622
|
+
*/
|
|
623
|
+
focus?: string;
|
|
624
|
+
/** Overlay precomputed semantic-neighbor edges onto the graph. */
|
|
625
|
+
includeSemantic?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* ISO 8601 timestamp. When supplied, returns the graph as it stood at
|
|
628
|
+
* that instant — nodes and relations are filtered bitemporally so only
|
|
629
|
+
* those that existed at `asOf` are included.
|
|
630
|
+
*/
|
|
631
|
+
asOf?: string;
|
|
632
|
+
}
|
|
633
|
+
/** Input for `graphTraverse` — multi-hop BFS from a root node. */
|
|
634
|
+
interface GraphTraverseInput {
|
|
635
|
+
/** Entity/node id to start BFS traversal from. */
|
|
636
|
+
root: string;
|
|
637
|
+
/** Maximum hops (default 3, capped server-side at 5). */
|
|
638
|
+
maxHops?: number;
|
|
639
|
+
/** Restrict to these relation verbs; omit for all. */
|
|
640
|
+
relations?: string[];
|
|
641
|
+
/**
|
|
642
|
+
* ISO 8601 timestamp for bitemporal reconstruction — only edges live at
|
|
643
|
+
* this instant are followed.
|
|
644
|
+
*/
|
|
645
|
+
asOf?: string;
|
|
646
|
+
}
|
|
647
|
+
/** One hit from a multi-hop traversal. */
|
|
648
|
+
interface TraverseHit {
|
|
649
|
+
/** Node id. */
|
|
650
|
+
id: string;
|
|
651
|
+
/** Minimum hop count from the root. */
|
|
652
|
+
hop: number;
|
|
653
|
+
/** decay^hop relevance score (default decay = 0.6). */
|
|
654
|
+
relevance: number;
|
|
655
|
+
}
|
|
656
|
+
/** Input for `graphPath` — shortest path between two nodes. */
|
|
657
|
+
interface GraphPathInput {
|
|
658
|
+
/** Source node id. */
|
|
659
|
+
from: string;
|
|
660
|
+
/** Target node id. */
|
|
661
|
+
to: string;
|
|
662
|
+
/** Maximum hops to search (default 4, capped server-side at 6). */
|
|
663
|
+
maxHops?: number;
|
|
664
|
+
/** ISO 8601 timestamp for bitemporal reconstruction. */
|
|
665
|
+
asOf?: string;
|
|
666
|
+
}
|
|
667
|
+
/** Response from `graphPath`. */
|
|
668
|
+
interface GraphPathResponse {
|
|
669
|
+
/** Node ids from `from` to `to` inclusive. Empty array if unreachable. */
|
|
670
|
+
path: string[];
|
|
671
|
+
/** The relation verb traversed for each consecutive pair on the path. */
|
|
672
|
+
edges: Array<{
|
|
673
|
+
source: string;
|
|
674
|
+
target: string;
|
|
675
|
+
relation: string;
|
|
676
|
+
}>;
|
|
677
|
+
}
|
|
678
|
+
/** One node in the Memory Graph. Mirrors `GraphNodeSchema`. */
|
|
679
|
+
interface GraphNode {
|
|
680
|
+
id: string;
|
|
681
|
+
kind: "entity" | "episode" | "decision";
|
|
682
|
+
entityKind?: "person" | "organization" | "project" | "concept" | "place" | "other";
|
|
683
|
+
label: string;
|
|
684
|
+
description?: string | null;
|
|
685
|
+
/** Total mentions across conversation history. Drives node radius in the UI. */
|
|
686
|
+
mentionCount: number;
|
|
687
|
+
/** Linked-fact count. Drives the aura intensity in the UI. */
|
|
688
|
+
factCount: number;
|
|
689
|
+
/**
|
|
690
|
+
* Average `memory_strength` across this node's facts (Hebbian
|
|
691
|
+
* potentiation). Higher = more salient.
|
|
692
|
+
*/
|
|
693
|
+
avgMemoryStrength: number;
|
|
694
|
+
createdAt: string;
|
|
695
|
+
}
|
|
696
|
+
/** One edge in the Memory Graph. Mirrors `GraphEdgeSchema`. */
|
|
697
|
+
interface GraphEdge {
|
|
698
|
+
id: string;
|
|
699
|
+
source: string;
|
|
700
|
+
target: string;
|
|
701
|
+
/** Relation verb: related / conflicts_with / derived_from / supersedes / part_of / member_of / scoped / compatible / not_conflict. */
|
|
702
|
+
relation: string;
|
|
703
|
+
confidence: number;
|
|
704
|
+
/** Free-form provenance string. May be null for system-inferred edges. */
|
|
705
|
+
provenance: string | null;
|
|
706
|
+
}
|
|
707
|
+
/** Response from `GET /graph`. Mirrors `GraphResponseSchema`. */
|
|
708
|
+
interface GraphResponse {
|
|
709
|
+
nodes: GraphNode[];
|
|
710
|
+
edges: GraphEdge[];
|
|
711
|
+
meta: {
|
|
712
|
+
entityCount: number;
|
|
713
|
+
episodeCount: number;
|
|
714
|
+
decisionCount: number;
|
|
715
|
+
relationCount: number;
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* The 6 entity kinds enforced by `mnemo_entity.kind` (Mnemosyne v1.6 G2).
|
|
720
|
+
* Mirrors the server's `EntityKindEnum`. Intentionally narrow — broader
|
|
721
|
+
* taxonomies (employee / vendor / customer / …) belong on the host side.
|
|
722
|
+
*/
|
|
723
|
+
type EntityKind = "person" | "organization" | "project" | "concept" | "place" | "other";
|
|
724
|
+
/**
|
|
725
|
+
* Canonical entity row. Mirrors `EntitySchema` in
|
|
726
|
+
* `packages/server/src/routes/entities.ts`. Timestamps are ISO 8601
|
|
727
|
+
* strings — JSON has no native Date.
|
|
728
|
+
*/
|
|
729
|
+
interface MnemoEntity {
|
|
730
|
+
id: string;
|
|
731
|
+
workspaceId: string;
|
|
732
|
+
name: string;
|
|
733
|
+
kind: EntityKind;
|
|
734
|
+
aliases: string[];
|
|
735
|
+
/** Self-reference for merge. NULL = this row is canonical. */
|
|
736
|
+
canonicalId: string | null;
|
|
737
|
+
description: string | null;
|
|
738
|
+
/** Access sensitivity tier — bumped to at least 'internal' automatically once linkedUserId is set. */
|
|
739
|
+
sensitivity: "public" | "internal" | "confidential" | "restricted";
|
|
740
|
+
metadata: Record<string, unknown>;
|
|
741
|
+
/**
|
|
742
|
+
* The platform account (mnemo_user.id) this entity is ABOUT, when kind is
|
|
743
|
+
* 'person' and it's been linked via `linkEntityUser`/`unlinkEntityUser`.
|
|
744
|
+
* Deliberately distinct from provenance ("who wrote this row") — this is
|
|
745
|
+
* "who this row is about". Only ever settable through those two calls,
|
|
746
|
+
* never through `createEntity`/`updateEntity`.
|
|
747
|
+
*/
|
|
748
|
+
linkedUserId?: string | null;
|
|
749
|
+
firstSeenAt: string;
|
|
750
|
+
lastSeenAt: string;
|
|
751
|
+
/** Total mentions across conversation history. */
|
|
752
|
+
mentionCount: number;
|
|
753
|
+
createdAt: string;
|
|
754
|
+
updatedAt: string;
|
|
755
|
+
}
|
|
756
|
+
/** Input shape for `client.listEntities(...)`. */
|
|
757
|
+
interface ListEntitiesInput {
|
|
758
|
+
/** Optional kind filter. */
|
|
759
|
+
kind?: EntityKind;
|
|
760
|
+
/** Case-insensitive substring search across name + aliases. */
|
|
761
|
+
q?: string;
|
|
762
|
+
/** Max rows. Server caps at 200. */
|
|
763
|
+
limit?: number;
|
|
764
|
+
}
|
|
765
|
+
/** Response from `GET /entities`. */
|
|
766
|
+
interface ListEntitiesResponse {
|
|
767
|
+
items: MnemoEntity[];
|
|
768
|
+
}
|
|
769
|
+
/** Response from `GET /entities/:id` (entity + linked-fact count). */
|
|
770
|
+
interface EntityWithCount {
|
|
771
|
+
entity: MnemoEntity;
|
|
772
|
+
linkedFactCount: number;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Rich fact projection — what entity- and episode-detail views render.
|
|
776
|
+
* Distinct from the simplified {@link Fact} exposed by `GET /facts/:id`:
|
|
777
|
+
* the rich shape carries the full cognitive fields (subject/statement/
|
|
778
|
+
* kind/confidence) the Inspector UI needs. Mirrors the server's
|
|
779
|
+
* `MemoryFactSchema`.
|
|
780
|
+
*/
|
|
781
|
+
interface MemoryFact {
|
|
782
|
+
id: string;
|
|
783
|
+
workspaceId: string;
|
|
784
|
+
agentId: string | null;
|
|
785
|
+
scope: "global" | "conversation";
|
|
786
|
+
scopeRef: string | null;
|
|
787
|
+
kind: MemoryFactKind;
|
|
788
|
+
subject: string;
|
|
789
|
+
statement: string;
|
|
790
|
+
confidence: number;
|
|
791
|
+
pinned: boolean;
|
|
792
|
+
relevance: number;
|
|
793
|
+
hitCount: number;
|
|
794
|
+
/** ISO 8601 or null if this fact has never been recalled yet. */
|
|
795
|
+
lastRecalledAt: string | null;
|
|
796
|
+
sourceMessageIds: string[];
|
|
797
|
+
attributedTo: "user" | "assistant" | "system" | null;
|
|
798
|
+
linkedMemoryIds: string[];
|
|
799
|
+
metadata: Record<string, unknown>;
|
|
800
|
+
status: "active" | "merged" | "forgotten";
|
|
801
|
+
mergedIntoId: string | null;
|
|
802
|
+
validFrom: string;
|
|
803
|
+
validTo: string | null;
|
|
804
|
+
createdAt: string;
|
|
805
|
+
updatedAt: string;
|
|
806
|
+
/**
|
|
807
|
+
* v1.4 — cognitive classification. Optional because legacy rows
|
|
808
|
+
* predate the column; downstream consumers treat absence as 'semantic'.
|
|
809
|
+
*/
|
|
810
|
+
memoryType?: "semantic" | "episodic" | "procedural" | "working";
|
|
811
|
+
/**
|
|
812
|
+
* v1.4 — per-conversation actor isolation. NULL = workspace-shared.
|
|
813
|
+
* Optional because legacy rows predate the column.
|
|
814
|
+
*/
|
|
815
|
+
actorId?: string | null;
|
|
816
|
+
}
|
|
817
|
+
/** Response from `GET /entities/:id/facts`. */
|
|
818
|
+
interface EntityFactsResponse {
|
|
819
|
+
entity: MnemoEntity;
|
|
820
|
+
facts: MemoryFact[];
|
|
821
|
+
}
|
|
822
|
+
/** Input shape for `client.listEntityFacts(...)`. */
|
|
823
|
+
interface ListEntityFactsInput {
|
|
824
|
+
/** Max facts. Server caps at 500. */
|
|
825
|
+
limit?: number;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Episode (Mnemosyne v1.4 timeline primitive). Mirrors `EpisodeSchema`.
|
|
829
|
+
* `occurredAt` is the canonical timestamp for sorting/filtering;
|
|
830
|
+
* `createdAt` is when the extractor (or operator) inserted the row.
|
|
831
|
+
*/
|
|
832
|
+
interface MnemoEpisode {
|
|
833
|
+
id: string;
|
|
834
|
+
workspaceId: string;
|
|
835
|
+
title: string;
|
|
836
|
+
narrative: string;
|
|
837
|
+
occurredAt: string;
|
|
838
|
+
durationMinutes: number | null;
|
|
839
|
+
participants: string[];
|
|
840
|
+
topics: string[];
|
|
841
|
+
linkedFactIds: string[];
|
|
842
|
+
sourceConversationId: string | null;
|
|
843
|
+
metadata: Record<string, unknown>;
|
|
844
|
+
createdAt: string;
|
|
845
|
+
updatedAt: string;
|
|
846
|
+
/**
|
|
847
|
+
* v2 — true for episodes auto-created by the extraction pipeline
|
|
848
|
+
* (one per message turn / document / day). Inspector UI defaults to
|
|
849
|
+
* hiding these; recall scoring still uses them.
|
|
850
|
+
*/
|
|
851
|
+
isSynthetic: boolean;
|
|
852
|
+
}
|
|
853
|
+
/** Input shape for `client.listEpisodes(...)`. */
|
|
854
|
+
interface ListEpisodesInput {
|
|
855
|
+
/** ISO 8601. Server defaults to now-30d when omitted. */
|
|
856
|
+
from?: string;
|
|
857
|
+
/** ISO 8601. Server defaults to now when omitted. */
|
|
858
|
+
to?: string;
|
|
859
|
+
/** Single-topic filter via the GIN-indexed `topics` array. */
|
|
860
|
+
topic?: string;
|
|
861
|
+
/** Max episodes. Server caps at 200. */
|
|
862
|
+
limit?: number;
|
|
863
|
+
/** Include extractor-synthesised episodes. Defaults to false. */
|
|
864
|
+
includeSynthetic?: boolean;
|
|
865
|
+
}
|
|
866
|
+
/** Response from `GET /episodes`. */
|
|
867
|
+
interface ListEpisodesResponse {
|
|
868
|
+
items: MnemoEpisode[];
|
|
869
|
+
}
|
|
870
|
+
/** Response from `GET /episodes/:id` (episode + linked facts). */
|
|
871
|
+
interface EpisodeWithLinkedFacts {
|
|
872
|
+
episode: MnemoEpisode;
|
|
873
|
+
linkedFacts: MemoryFact[];
|
|
874
|
+
}
|
|
875
|
+
/** One entry in the response from `GET /episodes/:id/timeline`. */
|
|
876
|
+
interface EpisodeTimelineEvent {
|
|
877
|
+
kind: "episode_created" | "fact_linked" | "episode_closed";
|
|
878
|
+
occurredAt: string;
|
|
879
|
+
detail: Record<string, unknown>;
|
|
880
|
+
}
|
|
881
|
+
/** Response from `GET /episodes/:id/timeline`. */
|
|
882
|
+
interface EpisodeTimelineResponse {
|
|
883
|
+
events: EpisodeTimelineEvent[];
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Input shape for `client.createEntity(...)`. Mirrors the server's
|
|
887
|
+
* `CreateEntitySchema`. Aliases ≤ 50 × ≤ 200 chars; the server
|
|
888
|
+
* 400-rejects anything outside.
|
|
889
|
+
*/
|
|
890
|
+
interface CreateEntityInput {
|
|
891
|
+
name: string;
|
|
892
|
+
kind: EntityKind;
|
|
893
|
+
aliases?: string[];
|
|
894
|
+
description?: string | null;
|
|
895
|
+
metadata?: Record<string, unknown>;
|
|
896
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
897
|
+
targetWorkspaceId?: string;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Input shape for `client.updateEntity(...)`. An empty patch (every
|
|
901
|
+
* key undefined) is rejected with 400 — bailing early beats issuing
|
|
902
|
+
* a no-op UPDATE that bumps `updatedAt`.
|
|
903
|
+
*/
|
|
904
|
+
interface UpdateEntityInput {
|
|
905
|
+
name?: string;
|
|
906
|
+
kind?: EntityKind;
|
|
907
|
+
aliases?: string[];
|
|
908
|
+
/**
|
|
909
|
+
* canonicalId is the merge knob: set to another entity's id to
|
|
910
|
+
* mark this row as a redirect, set to null to mark it canonical
|
|
911
|
+
* itself. Must exist in the same workspace and must NOT equal
|
|
912
|
+
* the row being patched.
|
|
913
|
+
*/
|
|
914
|
+
canonicalId?: string | null;
|
|
915
|
+
description?: string | null;
|
|
916
|
+
metadata?: Record<string, unknown>;
|
|
917
|
+
}
|
|
918
|
+
/** Input shape for `client.linkEntityUser(...)`. */
|
|
919
|
+
interface LinkEntityUserInput {
|
|
920
|
+
/** The platform account (mnemo_user.id) to link. Must be a member of this workspace. */
|
|
921
|
+
userId: string;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Why a row was queued for human review. Mirrors the server's
|
|
925
|
+
* `ReviewReasonEnum` (and the SQL CHECK on `mnemo_review_queue.reason`).
|
|
926
|
+
*/
|
|
927
|
+
type ReviewReason = "low_confidence" | "contradiction" | "manual";
|
|
928
|
+
/** How the reviewer closed a queue row. */
|
|
929
|
+
type ReviewResolution = "kept" | "edited" | "forgotten" | "dismissed";
|
|
930
|
+
/**
|
|
931
|
+
* One row from the active-learning queue. Mirrors the server's
|
|
932
|
+
* `ReviewQueueRowSchema` exactly. Either `factId` or `decisionId` is
|
|
933
|
+
* non-null (fact-sourced vs decision-sourced row).
|
|
934
|
+
*/
|
|
935
|
+
interface ReviewQueueRow {
|
|
936
|
+
id: string;
|
|
937
|
+
workspaceId: string;
|
|
938
|
+
factId: string | null;
|
|
939
|
+
decisionId: string | null;
|
|
940
|
+
reason: ReviewReason;
|
|
941
|
+
createdAt: string;
|
|
942
|
+
resolvedAt: string | null;
|
|
943
|
+
resolvedBy: string | null;
|
|
944
|
+
resolution: ReviewResolution | null;
|
|
945
|
+
}
|
|
946
|
+
/** Input shape for `client.listReview(...)`. */
|
|
947
|
+
interface ListReviewInput {
|
|
948
|
+
/** Filter by reason. Omit for all reasons. */
|
|
949
|
+
reason?: ReviewReason;
|
|
950
|
+
/**
|
|
951
|
+
* When true, include resolved rows in addition to open ones.
|
|
952
|
+
* Defaults to false (queue only).
|
|
953
|
+
*/
|
|
954
|
+
all?: boolean;
|
|
955
|
+
/** Max rows. Server caps at 200. */
|
|
956
|
+
limit?: number;
|
|
957
|
+
}
|
|
958
|
+
/** Response from `GET /review`. */
|
|
959
|
+
interface ListReviewResponse {
|
|
960
|
+
items: ReviewQueueRow[];
|
|
961
|
+
}
|
|
962
|
+
/** Response from `GET /review/count`. */
|
|
963
|
+
interface ReviewCountResponse {
|
|
964
|
+
count: number;
|
|
965
|
+
}
|
|
966
|
+
/** Input shape for `client.resolveReview(...)`. */
|
|
967
|
+
interface ResolveReviewInput {
|
|
968
|
+
resolution: ReviewResolution;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Response from `POST /review/:id/resolve`. `cascaded:true` only
|
|
972
|
+
* when the reviewer picked 'forgotten' AND the row was fact-sourced —
|
|
973
|
+
* the server atomically flips the fact's status to 'forgotten' in the
|
|
974
|
+
* same tx so the fact leaves the recall pool without a follow-up
|
|
975
|
+
* round-trip.
|
|
976
|
+
*/
|
|
977
|
+
interface ResolveReviewResponse {
|
|
978
|
+
id: string;
|
|
979
|
+
resolution: ReviewResolution;
|
|
980
|
+
factId: string | null;
|
|
981
|
+
cascaded: boolean;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* One entry in the inspector's "Undo log" feed. Mirrors the server's
|
|
985
|
+
* `AuditEntrySchema`. Synthesised from two sources (user-forgotten
|
|
986
|
+
* facts and janitor-archived facts); the discriminant is `actorKind`.
|
|
987
|
+
*/
|
|
988
|
+
interface AuditEntry {
|
|
989
|
+
/** Prefixed key: `forget_<factId>` (live row) or `archive_<archiveId>`. */
|
|
990
|
+
id: string;
|
|
991
|
+
factId: string;
|
|
992
|
+
factStatement: string;
|
|
993
|
+
factSubject: string;
|
|
994
|
+
factKind: string;
|
|
995
|
+
/** Currently always 'forgotten' — only action synthesised today. */
|
|
996
|
+
action: "forgotten";
|
|
997
|
+
/** 'user' = clicked Forget; 'system' = janitor merge/prune. */
|
|
998
|
+
actorKind: "user" | "system";
|
|
999
|
+
actorName: string | null;
|
|
1000
|
+
/** ISO 8601 — fact.updatedAt or archive.archivedAt. */
|
|
1001
|
+
timestamp: string;
|
|
1002
|
+
/** True iff `client.restoreFact()` can reverse this entry. */
|
|
1003
|
+
revertible: boolean;
|
|
1004
|
+
}
|
|
1005
|
+
/** Input shape for `client.audit(...)`. */
|
|
1006
|
+
interface AuditInput {
|
|
1007
|
+
/** Max entries. Server caps at 100. */
|
|
1008
|
+
limit?: number;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Response from `GET /audit`. `available:true` is always set — when
|
|
1012
|
+
* the underlying query fails the server returns a 5xx, not a degraded
|
|
1013
|
+
* payload. The legacy orchester surface used `available:false` for the
|
|
1014
|
+
* graceful-degrade UI state; the helper layers that on after the call.
|
|
1015
|
+
*/
|
|
1016
|
+
interface AuditResponse {
|
|
1017
|
+
items: AuditEntry[];
|
|
1018
|
+
total: number;
|
|
1019
|
+
available: true;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Response from `GET /export`. `meta` describes the dump; the four
|
|
1023
|
+
* data arrays carry raw row objects (snake_case columns from the
|
|
1024
|
+
* underlying SELECTs). Embeddings are excluded.
|
|
1025
|
+
*/
|
|
1026
|
+
interface ExportResponse {
|
|
1027
|
+
meta: {
|
|
1028
|
+
workspaceId: string;
|
|
1029
|
+
exportedAt: string;
|
|
1030
|
+
rowCapPerResource: number;
|
|
1031
|
+
embeddingsExcluded: true;
|
|
1032
|
+
};
|
|
1033
|
+
facts: Array<Record<string, unknown>>;
|
|
1034
|
+
decisions: Array<Record<string, unknown>>;
|
|
1035
|
+
relations: Array<Record<string, unknown>>;
|
|
1036
|
+
citations: Array<Record<string, unknown>>;
|
|
1037
|
+
}
|
|
1038
|
+
/** Response from `POST /facts/:id/restore` — minimal {id, status}. */
|
|
1039
|
+
interface RestoreFactResponse {
|
|
1040
|
+
id: string;
|
|
1041
|
+
status: "active";
|
|
1042
|
+
}
|
|
1043
|
+
/** Decision kind — mirrors the SQL CHECK on `mnemo_decision.kind`. */
|
|
1044
|
+
type DecisionKind = "decision" | "architecture" | "policy" | "process" | "bugfix" | "learning" | "discovery" | "config";
|
|
1045
|
+
/** Decision lifecycle status. */
|
|
1046
|
+
type DecisionStatus = "active" | "superseded" | "withdrawn";
|
|
1047
|
+
/**
|
|
1048
|
+
* Decision row (Mnemosyne v1.5 — decisions as first-class memory
|
|
1049
|
+
* primitives). Mirrors the server's `DecisionSchema`. Embedding
|
|
1050
|
+
* vectors are NOT exposed (heavy + the client never needs them).
|
|
1051
|
+
*/
|
|
1052
|
+
interface MnemoDecision {
|
|
1053
|
+
id: string;
|
|
1054
|
+
workspaceId: string;
|
|
1055
|
+
agentId: string | null;
|
|
1056
|
+
conversationId: string | null;
|
|
1057
|
+
kind: DecisionKind;
|
|
1058
|
+
title: string;
|
|
1059
|
+
body: string;
|
|
1060
|
+
topicKey: string | null;
|
|
1061
|
+
revisionCount: number;
|
|
1062
|
+
normalizedHash: string;
|
|
1063
|
+
decidedByUserId: string | null;
|
|
1064
|
+
status: DecisionStatus;
|
|
1065
|
+
supersededById: string | null;
|
|
1066
|
+
metadata: Record<string, unknown>;
|
|
1067
|
+
validFrom: string;
|
|
1068
|
+
validTo: string | null;
|
|
1069
|
+
createdAt: string;
|
|
1070
|
+
updatedAt: string;
|
|
1071
|
+
}
|
|
1072
|
+
/** Input shape for `client.listDecisions(...)`. */
|
|
1073
|
+
interface ListDecisionsInput {
|
|
1074
|
+
status?: DecisionStatus;
|
|
1075
|
+
/** Max rows. Server caps at 500. */
|
|
1076
|
+
limit?: number;
|
|
1077
|
+
}
|
|
1078
|
+
/** Response from `GET /decisions`. */
|
|
1079
|
+
interface ListDecisionsResponse {
|
|
1080
|
+
items: MnemoDecision[];
|
|
1081
|
+
}
|
|
1082
|
+
/** Mirrors `mnemo_fact.kind` (SQL CHECK). */
|
|
1083
|
+
type MemoryFactKind = "preference" | "trait" | "event" | "relationship" | "skill" | "concern" | "architecture" | "bugfix" | "config" | "discovery" | "policy" | "process" | "other";
|
|
1084
|
+
/** Mirrors `mnemo_fact.scope`. */
|
|
1085
|
+
type MemoryFactScope = "global" | "conversation" | "personal";
|
|
1086
|
+
/** Input shape for `client.listFacts(...)`. */
|
|
1087
|
+
interface ListFactsInput {
|
|
1088
|
+
kind?: MemoryFactKind;
|
|
1089
|
+
scope?: MemoryFactScope;
|
|
1090
|
+
scopeRef?: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* `'active'` (default) returns only currently-active facts. `'merged'`
|
|
1093
|
+
* / `'forgotten'` filter to that single status; `'all'` exposes the
|
|
1094
|
+
* full bitemporal view.
|
|
1095
|
+
*/
|
|
1096
|
+
status?: "active" | "forgotten" | "merged" | "all";
|
|
1097
|
+
pinned?: boolean;
|
|
1098
|
+
/**
|
|
1099
|
+
* Optional full-text query. Matches `text_lemmatized` via
|
|
1100
|
+
* `plainto_tsquery(mnemosyne.mnemo_fts, q)` server-side, with an ILIKE fallback
|
|
1101
|
+
* on `statement` for legacy rows whose lemma column is null.
|
|
1102
|
+
*/
|
|
1103
|
+
q?: string;
|
|
1104
|
+
/** Defaults to `'updated_at'`. */
|
|
1105
|
+
sortBy?: "created_at" | "updated_at" | "relevance" | "hit_count";
|
|
1106
|
+
/** Defaults to `'desc'`. */
|
|
1107
|
+
order?: "asc" | "desc";
|
|
1108
|
+
/**
|
|
1109
|
+
* Opaque base64url cursor returned by the previous page in
|
|
1110
|
+
* `nextCursor`. Omit to start from the top.
|
|
1111
|
+
*/
|
|
1112
|
+
cursor?: string;
|
|
1113
|
+
/**
|
|
1114
|
+
* ISO 8601 bitemporal snapshot. Returns facts whose
|
|
1115
|
+
* `[validFrom, validTo)` interval contained `asOf`. Future timestamps
|
|
1116
|
+
* are rejected (400).
|
|
1117
|
+
*/
|
|
1118
|
+
asOf?: string;
|
|
1119
|
+
/** Max rows. Server caps at 500. */
|
|
1120
|
+
limit?: number;
|
|
1121
|
+
}
|
|
1122
|
+
/** Response from `GET /facts`. */
|
|
1123
|
+
interface ListFactsResponse {
|
|
1124
|
+
items: MemoryFact[];
|
|
1125
|
+
/** Non-null when more rows follow this page. */
|
|
1126
|
+
nextCursor: string | null;
|
|
1127
|
+
/** Cheap COUNT(*) of rows matching the filter set (without the cursor). */
|
|
1128
|
+
total: number;
|
|
1129
|
+
}
|
|
1130
|
+
/** Input shape for `client.patchFact(...)`. */
|
|
1131
|
+
interface PatchFactInput {
|
|
1132
|
+
subject?: string;
|
|
1133
|
+
statement?: string;
|
|
1134
|
+
kind?: MemoryFactKind;
|
|
1135
|
+
pinned?: boolean;
|
|
1136
|
+
confidence?: number;
|
|
1137
|
+
relevance?: number;
|
|
1138
|
+
metadata?: Record<string, unknown>;
|
|
1139
|
+
}
|
|
1140
|
+
/** Response from `GET /facts/:id/citations`. */
|
|
1141
|
+
interface FactCitationsResponse {
|
|
1142
|
+
factId: string;
|
|
1143
|
+
/** Raw `source_message_ids` list — hosts join against their own message table. */
|
|
1144
|
+
sourceMessageIds: string[];
|
|
1145
|
+
}
|
|
1146
|
+
/** Input shape for `client.createDecision(...)`. */
|
|
1147
|
+
interface CreateDecisionInput {
|
|
1148
|
+
kind: DecisionKind;
|
|
1149
|
+
title: string;
|
|
1150
|
+
body: string;
|
|
1151
|
+
topicKey?: string | null;
|
|
1152
|
+
conversationId?: string | null;
|
|
1153
|
+
agentId?: string | null;
|
|
1154
|
+
decidedByUserId?: string | null;
|
|
1155
|
+
/** Project/entity scope reference — mirrors mnemo_fact.scope_ref. */
|
|
1156
|
+
scopeRef?: string | null;
|
|
1157
|
+
metadata?: Record<string, unknown>;
|
|
1158
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
1159
|
+
targetWorkspaceId?: string;
|
|
1160
|
+
}
|
|
1161
|
+
/** Input shape for `client.supersedeDecision(...)`. */
|
|
1162
|
+
interface SupersedeDecisionInput {
|
|
1163
|
+
/** Id of the new decision that supersedes this one. */
|
|
1164
|
+
supersededById: string;
|
|
1165
|
+
}
|
|
1166
|
+
/** Locked vocabulary of 9 relation verbs. */
|
|
1167
|
+
type RelationVerb = "related" | "compatible" | "scoped" | "conflicts_with" | "supersedes" | "not_conflict" | "derived_from" | "part_of" | "member_of";
|
|
1168
|
+
/** Mirrors `mnemo_relation.judgment_status`. */
|
|
1169
|
+
type JudgmentStatus = "pending" | "judged" | "dismissed";
|
|
1170
|
+
/** Memory primitive a relation can connect. */
|
|
1171
|
+
type RelationKind = "fact" | "decision" | "entity" | "episode";
|
|
1172
|
+
/** Who marked a relation. */
|
|
1173
|
+
type MarkerKind = "user" | "agent" | "system" | "llm_judge";
|
|
1174
|
+
/**
|
|
1175
|
+
* Relation row. Mirrors the server's `RelationSchema`. Provenance is
|
|
1176
|
+
* NULL by default (LLM-derived); `'heuristic'` is reserved for system-
|
|
1177
|
+
* synthesised edges.
|
|
1178
|
+
*/
|
|
1179
|
+
interface MnemoRelation {
|
|
1180
|
+
id: string;
|
|
1181
|
+
workspaceId: string;
|
|
1182
|
+
sourceKind: RelationKind;
|
|
1183
|
+
sourceId: string;
|
|
1184
|
+
targetKind: RelationKind;
|
|
1185
|
+
targetId: string;
|
|
1186
|
+
relation: RelationVerb;
|
|
1187
|
+
judgmentStatus: JudgmentStatus;
|
|
1188
|
+
reason: string | null;
|
|
1189
|
+
evidence: Record<string, unknown> | null;
|
|
1190
|
+
confidence: number | null;
|
|
1191
|
+
markedByUserId: string | null;
|
|
1192
|
+
markedByKind: MarkerKind;
|
|
1193
|
+
markedByModel: string | null;
|
|
1194
|
+
markedByPromptVersion: string | null;
|
|
1195
|
+
provenance: string | null;
|
|
1196
|
+
conversationId: string | null;
|
|
1197
|
+
supersededByRelationId: string | null;
|
|
1198
|
+
validFrom: string;
|
|
1199
|
+
validTo: string | null;
|
|
1200
|
+
createdAt: string;
|
|
1201
|
+
updatedAt: string;
|
|
1202
|
+
}
|
|
1203
|
+
/** Input shape for `client.listRelations(...)`. */
|
|
1204
|
+
interface ListRelationsInput {
|
|
1205
|
+
judgmentStatus?: JudgmentStatus;
|
|
1206
|
+
/** Only relations whose source is this id (CLIENTS-8). */
|
|
1207
|
+
sourceId?: string;
|
|
1208
|
+
/** Only relations whose target is this id; with `sourceId`, both must match. */
|
|
1209
|
+
targetId?: string;
|
|
1210
|
+
/** Include relations closed by a delete (history). Default: current only. */
|
|
1211
|
+
includeClosed?: boolean;
|
|
1212
|
+
/** Max rows. Server caps at 500. */
|
|
1213
|
+
limit?: number;
|
|
1214
|
+
}
|
|
1215
|
+
/** Response from `GET /relations`. */
|
|
1216
|
+
interface ListRelationsResponse {
|
|
1217
|
+
items: MnemoRelation[];
|
|
1218
|
+
}
|
|
1219
|
+
/** Input shape for `client.createRelation(...)`. */
|
|
1220
|
+
interface CreateRelationInput {
|
|
1221
|
+
sourceKind: RelationKind;
|
|
1222
|
+
sourceId: string;
|
|
1223
|
+
targetKind: RelationKind;
|
|
1224
|
+
targetId: string;
|
|
1225
|
+
relation: RelationVerb;
|
|
1226
|
+
judgmentStatus?: JudgmentStatus;
|
|
1227
|
+
reason?: string;
|
|
1228
|
+
evidence?: Record<string, unknown>;
|
|
1229
|
+
confidence?: number;
|
|
1230
|
+
markedByKind: MarkerKind;
|
|
1231
|
+
markedByUserId?: string | null;
|
|
1232
|
+
markedByModel?: string;
|
|
1233
|
+
markedByPromptVersion?: string;
|
|
1234
|
+
conversationId?: string | null;
|
|
1235
|
+
}
|
|
1236
|
+
/** Input shape for `client.patchRelation(...)` (judgment application). */
|
|
1237
|
+
interface PatchRelationInput {
|
|
1238
|
+
relation: RelationVerb;
|
|
1239
|
+
reason?: string;
|
|
1240
|
+
evidence?: Record<string, unknown>;
|
|
1241
|
+
confidence?: number;
|
|
1242
|
+
markedByKind: MarkerKind;
|
|
1243
|
+
markedByUserId?: string | null;
|
|
1244
|
+
markedByModel?: string;
|
|
1245
|
+
markedByPromptVersion?: string;
|
|
1246
|
+
}
|
|
1247
|
+
interface TraverseRelationsInput {
|
|
1248
|
+
rootId: string;
|
|
1249
|
+
rootKind: RelationKind;
|
|
1250
|
+
maxDepth?: number;
|
|
1251
|
+
verbs?: RelationVerb[];
|
|
1252
|
+
}
|
|
1253
|
+
interface TraverseRelationsResponse {
|
|
1254
|
+
nodes: Array<{
|
|
1255
|
+
id: string;
|
|
1256
|
+
kind: RelationKind;
|
|
1257
|
+
}>;
|
|
1258
|
+
edges: MnemoRelation[];
|
|
1259
|
+
}
|
|
1260
|
+
/** Memory primitive a citation can attach to. */
|
|
1261
|
+
type CitationMemoryKind = "fact" | "decision" | "entity" | "episode";
|
|
1262
|
+
/** Where the citation came from. */
|
|
1263
|
+
type CitationSourceKind = "message" | "document" | "tool_call" | "llm_extraction" | "user_edit" | "agent_save" | "imported";
|
|
1264
|
+
/** Citation row. Mirrors the server's `CitationSchema`. */
|
|
1265
|
+
interface MnemoCitation {
|
|
1266
|
+
id: string;
|
|
1267
|
+
workspaceId: string;
|
|
1268
|
+
memoryKind: CitationMemoryKind;
|
|
1269
|
+
memoryId: string;
|
|
1270
|
+
sourceKind: CitationSourceKind;
|
|
1271
|
+
sourceId: string | null;
|
|
1272
|
+
extractorModel: string | null;
|
|
1273
|
+
extractorPromptVersion: string | null;
|
|
1274
|
+
judgeModel: string | null;
|
|
1275
|
+
judgeRelationId: string | null;
|
|
1276
|
+
evidenceExcerpt: string | null;
|
|
1277
|
+
createdAt: string;
|
|
1278
|
+
}
|
|
1279
|
+
/** Input shape for `client.listCitations(...)`. */
|
|
1280
|
+
interface ListCitationsInput {
|
|
1281
|
+
memoryKind?: CitationMemoryKind;
|
|
1282
|
+
memoryId?: string;
|
|
1283
|
+
/** Max rows. Server caps at 500. */
|
|
1284
|
+
limit?: number;
|
|
1285
|
+
}
|
|
1286
|
+
/** Response from `GET /citations`. */
|
|
1287
|
+
interface ListCitationsResponse {
|
|
1288
|
+
items: MnemoCitation[];
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Input shape for `client.enqueueReview(...)`. Exactly one of
|
|
1292
|
+
* `factId`/`decisionId` must be supplied — the server 400-rejects
|
|
1293
|
+
* both-or-neither.
|
|
1294
|
+
*/
|
|
1295
|
+
interface EnqueueReviewInput {
|
|
1296
|
+
factId?: string;
|
|
1297
|
+
decisionId?: string;
|
|
1298
|
+
reason: ReviewReason;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Response from `POST /review/enqueue`. `inserted:false` means the
|
|
1302
|
+
* row was already open — the helper returns the existing id rather
|
|
1303
|
+
* than creating a duplicate (idempotent via the partial index).
|
|
1304
|
+
*/
|
|
1305
|
+
interface EnqueueReviewResponse {
|
|
1306
|
+
id: string;
|
|
1307
|
+
inserted: boolean;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Input shape for `client.createSession(...)`.
|
|
1311
|
+
*
|
|
1312
|
+
* Mirrors the server's `POST /session/start` request body
|
|
1313
|
+
* (StartSessionRequest in packages/server/src/routes/index.ts).
|
|
1314
|
+
*/
|
|
1315
|
+
type TrafficOrigin = "organic" | "installer_verify" | "evaluation" | "unknown";
|
|
1316
|
+
type TurnOrigin = "human" | "agent_message" | "task_notification" | "pasted_content" | "assistant" | "unknown";
|
|
1317
|
+
interface CreateSessionInput {
|
|
1318
|
+
trafficOrigin?: TrafficOrigin;
|
|
1319
|
+
sourceSessionId?: string;
|
|
1320
|
+
sourceClientInstanceId?: string;
|
|
1321
|
+
sourceGeneration?: number;
|
|
1322
|
+
predecessorSessionId?: string;
|
|
1323
|
+
/** Agent identifier. Omit to use the workspace default. */
|
|
1324
|
+
agentId?: string;
|
|
1325
|
+
/** Human-readable label for the session, e.g. "Meeting 2026-06-13". */
|
|
1326
|
+
label?: string;
|
|
1327
|
+
/** Arbitrary metadata attached to the session row. */
|
|
1328
|
+
metadata?: Record<string, unknown>;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Response from `POST /session/start`.
|
|
1332
|
+
*
|
|
1333
|
+
* Mirrors the server's `V3Session` output shape.
|
|
1334
|
+
*/
|
|
1335
|
+
interface CreateSessionResponse {
|
|
1336
|
+
trafficOrigin?: TrafficOrigin;
|
|
1337
|
+
sourceSessionId?: string | null;
|
|
1338
|
+
sourceClientInstanceId?: string | null;
|
|
1339
|
+
sourceGeneration?: number | null;
|
|
1340
|
+
predecessorSessionId?: string | null;
|
|
1341
|
+
id: string;
|
|
1342
|
+
agentId: string | null;
|
|
1343
|
+
status: string;
|
|
1344
|
+
createdAt: string;
|
|
1345
|
+
label: string | null;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Input shape for `client.collapseSession(...)`.
|
|
1349
|
+
*
|
|
1350
|
+
* Mirrors the server's `POST /session/:id/collapse` request body.
|
|
1351
|
+
*/
|
|
1352
|
+
interface CollapseSessionInput {
|
|
1353
|
+
/**
|
|
1354
|
+
* "auto" — let the pipeline decide collapse strategy based on turn
|
|
1355
|
+
* recurrence signal (default). "explicit" — force full LLM extraction
|
|
1356
|
+
* even when the recurrence signal is below the threshold.
|
|
1357
|
+
*/
|
|
1358
|
+
strategy?: "auto" | "explicit";
|
|
1359
|
+
/** Natural-language hint to guide LLM extraction during collapse. */
|
|
1360
|
+
collapseHint?: string;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Response from `POST /session/:id/collapse`.
|
|
1364
|
+
*
|
|
1365
|
+
* The server returns 202 Accepted — collapse runs synchronously but
|
|
1366
|
+
* the response shape signals that the work is complete when it arrives.
|
|
1367
|
+
*/
|
|
1368
|
+
interface CollapseSessionResponse {
|
|
1369
|
+
/**
|
|
1370
|
+
* The request was PROCESSED. It does not mean knowledge was extracted —
|
|
1371
|
+
* read `status` for that. P115 exists because these two were conflated.
|
|
1372
|
+
*/
|
|
1373
|
+
accepted: boolean;
|
|
1374
|
+
sessionId: string;
|
|
1375
|
+
/**
|
|
1376
|
+
* `collapse_pending` — an archived managed session was accepted for retry.
|
|
1377
|
+
* `completed` — the pipeline extracted knowledge. `skipped` — it did NOT,
|
|
1378
|
+
* and `skipReason` says why. `failed` — extraction errored.
|
|
1379
|
+
*
|
|
1380
|
+
* Optional only for wire-compatibility with a server older than P115;
|
|
1381
|
+
* every current server sends it. Treat a missing value as `completed`.
|
|
1382
|
+
*/
|
|
1383
|
+
status?: "collapse_pending" | "skipped" | "completed" | "failed";
|
|
1384
|
+
/** Present when the collapse pipeline was skipped. */
|
|
1385
|
+
skipReason?: "too_few_turns" | "low_recurrence_signal" | "llm_unavailable" | "no_pin";
|
|
1386
|
+
/** True when an idempotent retry short-circuited already-completed phases (§RDD9). */
|
|
1387
|
+
resumed?: boolean;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Response from `GET /session/:id` and each entry of
|
|
1391
|
+
* `GET /session/list`. Mirrors the server's `SessionOut` schema.
|
|
1392
|
+
*/
|
|
1393
|
+
interface SessionWire {
|
|
1394
|
+
id: string;
|
|
1395
|
+
agentId: string | null;
|
|
1396
|
+
status: string;
|
|
1397
|
+
createdAt: string;
|
|
1398
|
+
label: string | null;
|
|
1399
|
+
/**
|
|
1400
|
+
* autonomous-memory Requirement 1/4: ISO timestamp of the most recent
|
|
1401
|
+
* `POST /recall` call that supplied this session's id as `sessionId`,
|
|
1402
|
+
* or `null` if none has.
|
|
1403
|
+
*/
|
|
1404
|
+
lastRecallAt?: string | null;
|
|
1405
|
+
}
|
|
1406
|
+
/** Response from `GET /session/list`. */
|
|
1407
|
+
interface ListSessionsResponse {
|
|
1408
|
+
sessions: SessionWire[];
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Input shape for `client.appendTurn(...)`.
|
|
1412
|
+
*
|
|
1413
|
+
* Maps to `POST /session/:id/turn`. Returns 204 No Content (void).
|
|
1414
|
+
*/
|
|
1415
|
+
interface AppendTurnInput {
|
|
1416
|
+
sourceMessageId?: string;
|
|
1417
|
+
sourceGeneration?: number;
|
|
1418
|
+
turnOrigin?: TurnOrigin;
|
|
1419
|
+
turnOriginEvidence?: string;
|
|
1420
|
+
/** Conversation role — typically "user" or "assistant". */
|
|
1421
|
+
role: string;
|
|
1422
|
+
/** Text content of the turn. */
|
|
1423
|
+
content: string;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Input shape for `client.pinSessionTurn(...)`.
|
|
1427
|
+
*
|
|
1428
|
+
* Maps to `POST /session/:id/pin`. Returns 204 No Content (void).
|
|
1429
|
+
*/
|
|
1430
|
+
interface PinSessionTurnInput {
|
|
1431
|
+
/**
|
|
1432
|
+
* The ID of the turn to pin or unpin. Supply this OR `turnIndex`, never both
|
|
1433
|
+
* and never neither — the route rejects any other combination.
|
|
1434
|
+
*/
|
|
1435
|
+
turnId?: string;
|
|
1436
|
+
/**
|
|
1437
|
+
* The turn's ordinal position in the session (0-based). The alternative
|
|
1438
|
+
* selector to `turnId`, for callers that have a position rather than an id.
|
|
1439
|
+
*/
|
|
1440
|
+
turnIndex?: number;
|
|
1441
|
+
/** `true` to pin the turn; `false` to unpin. */
|
|
1442
|
+
pinned: boolean;
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Input for `client.triggerConsolidation(...)`.
|
|
1446
|
+
*
|
|
1447
|
+
* Maps to the body of `POST /consolidation/trigger`.
|
|
1448
|
+
*/
|
|
1449
|
+
interface TriggerConsolidationInput {
|
|
1450
|
+
/**
|
|
1451
|
+
* `fast` (default): process a bounded low-worth candidate set.
|
|
1452
|
+
*
|
|
1453
|
+
* Manual `deep` requests currently return HTTP 422 with code
|
|
1454
|
+
* `deep_mode_not_supported`. The field remains public for compatibility.
|
|
1455
|
+
*/
|
|
1456
|
+
mode?: "fast" | "deep";
|
|
1457
|
+
/**
|
|
1458
|
+
* Must currently be false. A true value returns HTTP 422 with code
|
|
1459
|
+
* `dry_run_not_supported` without running consolidation. The field remains
|
|
1460
|
+
* public for compatibility.
|
|
1461
|
+
*/
|
|
1462
|
+
dryRun?: boolean;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Response from `POST /consolidation/trigger`.
|
|
1466
|
+
*/
|
|
1467
|
+
interface TriggerConsolidationResponse {
|
|
1468
|
+
accepted: boolean;
|
|
1469
|
+
workspaceId: string;
|
|
1470
|
+
mode: "fast";
|
|
1471
|
+
dryRun: false;
|
|
1472
|
+
/** Gate-passed pairs merged this tick. */
|
|
1473
|
+
mergedPairs: number;
|
|
1474
|
+
/** Gate-failed or ineligible pairs skipped. */
|
|
1475
|
+
skippedPairs: number;
|
|
1476
|
+
/** Total candidate facts fetched and inspected. */
|
|
1477
|
+
candidatesProcessed: number;
|
|
1478
|
+
/** Number of non-fatal per-fact errors encountered. */
|
|
1479
|
+
errors: number;
|
|
1480
|
+
/** Wall-clock time the server spent on the pass (milliseconds). */
|
|
1481
|
+
tookMs: number;
|
|
1482
|
+
}
|
|
1483
|
+
interface TaskWire {
|
|
1484
|
+
id: string;
|
|
1485
|
+
workspaceId: string;
|
|
1486
|
+
title: string;
|
|
1487
|
+
description?: string;
|
|
1488
|
+
status: "pending" | "in_progress" | "blocked" | "delegated" | "completed" | "cancelled";
|
|
1489
|
+
priority: "critical" | "high" | "medium" | "low";
|
|
1490
|
+
assignedTo: string;
|
|
1491
|
+
delegatedBy?: string;
|
|
1492
|
+
parentTaskId?: string;
|
|
1493
|
+
blockedBy: string[];
|
|
1494
|
+
subtaskIds: string[];
|
|
1495
|
+
relatedFacts: string[];
|
|
1496
|
+
relatedEntities: string[];
|
|
1497
|
+
sessionId?: string;
|
|
1498
|
+
outcome?: string;
|
|
1499
|
+
lessonsLearned?: string;
|
|
1500
|
+
delegatedAt?: string;
|
|
1501
|
+
startedAt?: string;
|
|
1502
|
+
completedAt?: string;
|
|
1503
|
+
dueAt?: string;
|
|
1504
|
+
createdAt: string;
|
|
1505
|
+
updatedAt: string;
|
|
1506
|
+
metadata: Record<string, unknown>;
|
|
1507
|
+
}
|
|
1508
|
+
interface PaginatedTasksResponse {
|
|
1509
|
+
items: TaskWire[];
|
|
1510
|
+
total: number;
|
|
1511
|
+
offset: number;
|
|
1512
|
+
limit: number;
|
|
1513
|
+
hasMore: boolean;
|
|
1514
|
+
}
|
|
1515
|
+
interface EventAnnotationWire {
|
|
1516
|
+
author: string;
|
|
1517
|
+
content: string;
|
|
1518
|
+
at: string;
|
|
1519
|
+
}
|
|
1520
|
+
interface EventWire {
|
|
1521
|
+
id: string;
|
|
1522
|
+
workspaceId: string;
|
|
1523
|
+
type: "system" | "external" | "user" | "agent" | "scheduled";
|
|
1524
|
+
name: string;
|
|
1525
|
+
description: string;
|
|
1526
|
+
occurredAt: string;
|
|
1527
|
+
durationS?: number;
|
|
1528
|
+
source: string;
|
|
1529
|
+
relatedEntities: string[];
|
|
1530
|
+
annotations: EventAnnotationWire[];
|
|
1531
|
+
sensitivity: "public" | "internal" | "confidential" | "restricted";
|
|
1532
|
+
createdAt: string;
|
|
1533
|
+
metadata: Record<string, unknown>;
|
|
1534
|
+
}
|
|
1535
|
+
/** Input shape for `client.updateEventSensitivity(...)`. Raise-only — the server 422s a lowering attempt. */
|
|
1536
|
+
interface UpdateEventSensitivityInput {
|
|
1537
|
+
sensitivity: "public" | "internal" | "confidential" | "restricted";
|
|
1538
|
+
}
|
|
1539
|
+
interface PaginatedEventsResponse {
|
|
1540
|
+
items: EventWire[];
|
|
1541
|
+
total: number;
|
|
1542
|
+
offset: number;
|
|
1543
|
+
limit: number;
|
|
1544
|
+
hasMore: boolean;
|
|
1545
|
+
}
|
|
1546
|
+
interface ChainStepWire {
|
|
1547
|
+
step: number;
|
|
1548
|
+
reasoning: string;
|
|
1549
|
+
conclusion?: string;
|
|
1550
|
+
}
|
|
1551
|
+
interface ReasoningWire {
|
|
1552
|
+
id: string;
|
|
1553
|
+
workspaceId: string;
|
|
1554
|
+
agentId?: string;
|
|
1555
|
+
question: string;
|
|
1556
|
+
chain: ChainStepWire[];
|
|
1557
|
+
conclusion: string;
|
|
1558
|
+
successCount: number;
|
|
1559
|
+
failureCount: number;
|
|
1560
|
+
worth: number;
|
|
1561
|
+
topicKey?: string;
|
|
1562
|
+
status: "active" | "archived" | "pruned";
|
|
1563
|
+
lastUsedAt?: string;
|
|
1564
|
+
usageCount: number;
|
|
1565
|
+
validFrom?: string;
|
|
1566
|
+
validTo?: string | null;
|
|
1567
|
+
createdAt: string;
|
|
1568
|
+
updatedAt: string;
|
|
1569
|
+
metadata: Record<string, unknown>;
|
|
1570
|
+
}
|
|
1571
|
+
interface PaginatedReasoningResponse {
|
|
1572
|
+
items: ReasoningWire[];
|
|
1573
|
+
total: number;
|
|
1574
|
+
offset: number;
|
|
1575
|
+
limit: number;
|
|
1576
|
+
hasMore: boolean;
|
|
1577
|
+
}
|
|
1578
|
+
interface CreateTaskInput {
|
|
1579
|
+
title: string;
|
|
1580
|
+
description?: string;
|
|
1581
|
+
priority?: "critical" | "high" | "medium" | "low";
|
|
1582
|
+
assignedTo: string;
|
|
1583
|
+
sessionId?: string;
|
|
1584
|
+
parentTaskId?: string;
|
|
1585
|
+
dueAt?: string;
|
|
1586
|
+
metadata?: Record<string, unknown>;
|
|
1587
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
1588
|
+
targetWorkspaceId?: string;
|
|
1589
|
+
}
|
|
1590
|
+
interface PatchTaskInput {
|
|
1591
|
+
title?: string;
|
|
1592
|
+
description?: string;
|
|
1593
|
+
status?: "pending" | "in_progress" | "blocked" | "delegated" | "completed" | "cancelled";
|
|
1594
|
+
priority?: "critical" | "high" | "medium" | "low";
|
|
1595
|
+
assignedTo?: string;
|
|
1596
|
+
blockedBy?: string[];
|
|
1597
|
+
subtaskIds?: string[];
|
|
1598
|
+
outcome?: string;
|
|
1599
|
+
lessonsLearned?: string;
|
|
1600
|
+
startedAt?: string;
|
|
1601
|
+
completedAt?: string;
|
|
1602
|
+
dueAt?: string;
|
|
1603
|
+
metadata?: Record<string, unknown>;
|
|
1604
|
+
}
|
|
1605
|
+
interface CreateEventInput {
|
|
1606
|
+
type: "system" | "external" | "user" | "agent" | "scheduled";
|
|
1607
|
+
name: string;
|
|
1608
|
+
description: string;
|
|
1609
|
+
occurredAt: string;
|
|
1610
|
+
durationS?: number;
|
|
1611
|
+
source: string;
|
|
1612
|
+
relatedEntities?: string[];
|
|
1613
|
+
annotations?: {
|
|
1614
|
+
author: string;
|
|
1615
|
+
content: string;
|
|
1616
|
+
at: string;
|
|
1617
|
+
}[];
|
|
1618
|
+
metadata?: Record<string, unknown>;
|
|
1619
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
1620
|
+
targetWorkspaceId?: string;
|
|
1621
|
+
}
|
|
1622
|
+
interface CreateReasoningInput {
|
|
1623
|
+
question: string;
|
|
1624
|
+
chain: ChainStepWire[];
|
|
1625
|
+
conclusion: string;
|
|
1626
|
+
agentId?: string;
|
|
1627
|
+
topicKey?: string;
|
|
1628
|
+
metadata?: Record<string, unknown>;
|
|
1629
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
1630
|
+
targetWorkspaceId?: string;
|
|
1631
|
+
}
|
|
1632
|
+
interface PatchReasoningInput {
|
|
1633
|
+
status?: "active" | "archived" | "pruned";
|
|
1634
|
+
chain?: ChainStepWire[];
|
|
1635
|
+
conclusion?: string;
|
|
1636
|
+
metadata?: Record<string, unknown>;
|
|
1637
|
+
}
|
|
1638
|
+
interface ResolveReasoningInput {
|
|
1639
|
+
query: string;
|
|
1640
|
+
topicKey?: string;
|
|
1641
|
+
}
|
|
1642
|
+
interface ResolveReasoningResponse {
|
|
1643
|
+
action: "hit" | "execute";
|
|
1644
|
+
reasoning_id?: string;
|
|
1645
|
+
cached_cot?: ChainStepWire[];
|
|
1646
|
+
conclusion?: string;
|
|
1647
|
+
suggested_model?: "haiku";
|
|
1648
|
+
similar_attempts?: Array<{
|
|
1649
|
+
reasoning_id: string;
|
|
1650
|
+
cosine: number;
|
|
1651
|
+
}>;
|
|
1652
|
+
}
|
|
1653
|
+
interface RecordReasoningInput {
|
|
1654
|
+
agentId?: string;
|
|
1655
|
+
question: string;
|
|
1656
|
+
chain: ChainStepWire[];
|
|
1657
|
+
conclusion: string;
|
|
1658
|
+
topicKey?: string;
|
|
1659
|
+
outcome?: "success" | "fail";
|
|
1660
|
+
metadata?: Record<string, unknown>;
|
|
1661
|
+
/** Stored on a new chain; a near-duplicate upsert keeps the existing one's. */
|
|
1662
|
+
sensitivity?: Sensitivity;
|
|
1663
|
+
}
|
|
1664
|
+
interface ReasoningFeedbackInput {
|
|
1665
|
+
reasoning_id: string;
|
|
1666
|
+
outcome: "success" | "fail";
|
|
1667
|
+
}
|
|
1668
|
+
interface ListTasksParams {
|
|
1669
|
+
status?: "pending" | "in_progress" | "blocked" | "delegated" | "completed" | "cancelled";
|
|
1670
|
+
assignedTo?: string;
|
|
1671
|
+
parentTaskId?: string;
|
|
1672
|
+
limit?: number;
|
|
1673
|
+
offset?: number;
|
|
1674
|
+
}
|
|
1675
|
+
interface ListEventsParams {
|
|
1676
|
+
type?: "system" | "external" | "user" | "agent" | "scheduled";
|
|
1677
|
+
source?: string;
|
|
1678
|
+
after?: string;
|
|
1679
|
+
before?: string;
|
|
1680
|
+
limit?: number;
|
|
1681
|
+
offset?: number;
|
|
1682
|
+
}
|
|
1683
|
+
interface ListReasoningParams {
|
|
1684
|
+
status?: "active" | "archived" | "pruned";
|
|
1685
|
+
topicKey?: string;
|
|
1686
|
+
limit?: number;
|
|
1687
|
+
offset?: number;
|
|
1688
|
+
}
|
|
1689
|
+
interface StrategyWire {
|
|
1690
|
+
id: string;
|
|
1691
|
+
workspaceId: string;
|
|
1692
|
+
agentId?: string;
|
|
1693
|
+
trigger: string;
|
|
1694
|
+
action: string;
|
|
1695
|
+
context?: string;
|
|
1696
|
+
successCount: number;
|
|
1697
|
+
failureCount: number;
|
|
1698
|
+
worth: number;
|
|
1699
|
+
supersedesId?: string;
|
|
1700
|
+
status: "active" | "superseded" | "archived";
|
|
1701
|
+
embeddingStale: boolean;
|
|
1702
|
+
validFrom: string;
|
|
1703
|
+
validTo?: string;
|
|
1704
|
+
createdAt: string;
|
|
1705
|
+
updatedAt: string;
|
|
1706
|
+
metadata: Record<string, unknown>;
|
|
1707
|
+
}
|
|
1708
|
+
interface PaginatedStrategiesResponse {
|
|
1709
|
+
items: StrategyWire[];
|
|
1710
|
+
total: number;
|
|
1711
|
+
offset: number;
|
|
1712
|
+
limit: number;
|
|
1713
|
+
hasMore: boolean;
|
|
1714
|
+
}
|
|
1715
|
+
interface CreateStrategyInput {
|
|
1716
|
+
agentId?: string;
|
|
1717
|
+
trigger: string;
|
|
1718
|
+
action: string;
|
|
1719
|
+
context?: string;
|
|
1720
|
+
/** Project/entity scope reference — mirrors mnemo_fact.scope_ref. */
|
|
1721
|
+
scopeRef?: string;
|
|
1722
|
+
supersedesId?: string;
|
|
1723
|
+
validFrom?: string;
|
|
1724
|
+
metadata?: Record<string, unknown>;
|
|
1725
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
1726
|
+
targetWorkspaceId?: string;
|
|
1727
|
+
}
|
|
1728
|
+
interface PatchStrategyInput {
|
|
1729
|
+
trigger?: string;
|
|
1730
|
+
action?: string;
|
|
1731
|
+
context?: string;
|
|
1732
|
+
status?: "active" | "superseded" | "archived";
|
|
1733
|
+
validTo?: string;
|
|
1734
|
+
metadata?: Record<string, unknown>;
|
|
1735
|
+
}
|
|
1736
|
+
interface ListStrategiesParams {
|
|
1737
|
+
status?: "active" | "superseded" | "archived";
|
|
1738
|
+
/** When set, return records with scope_ref = X OR scope_ref IS NULL. */
|
|
1739
|
+
scopeRef?: string;
|
|
1740
|
+
validAt?: string;
|
|
1741
|
+
offset?: number;
|
|
1742
|
+
limit?: number;
|
|
1743
|
+
}
|
|
1744
|
+
interface HyperedgeWire {
|
|
1745
|
+
id: string;
|
|
1746
|
+
workspaceId: string;
|
|
1747
|
+
memberIds: string[];
|
|
1748
|
+
label?: string;
|
|
1749
|
+
description?: string;
|
|
1750
|
+
contextQuery?: string;
|
|
1751
|
+
activationCount: number;
|
|
1752
|
+
worth: number;
|
|
1753
|
+
validFrom: string;
|
|
1754
|
+
validTo: string | null;
|
|
1755
|
+
createdAt: string;
|
|
1756
|
+
}
|
|
1757
|
+
interface PaginatedHyperedgesResponse {
|
|
1758
|
+
items: HyperedgeWire[];
|
|
1759
|
+
total: number;
|
|
1760
|
+
offset: number;
|
|
1761
|
+
limit: number;
|
|
1762
|
+
hasMore: boolean;
|
|
1763
|
+
}
|
|
1764
|
+
interface CreateHyperedgeInput {
|
|
1765
|
+
memberIds: string[];
|
|
1766
|
+
label?: string;
|
|
1767
|
+
description?: string;
|
|
1768
|
+
contextQuery?: string;
|
|
1769
|
+
}
|
|
1770
|
+
interface PatchHyperedgeInput {
|
|
1771
|
+
label?: string;
|
|
1772
|
+
description?: string;
|
|
1773
|
+
contextQuery?: string;
|
|
1774
|
+
}
|
|
1775
|
+
interface ListHyperedgesParams {
|
|
1776
|
+
memberId?: string;
|
|
1777
|
+
label?: string;
|
|
1778
|
+
limit?: number;
|
|
1779
|
+
offset?: number;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* One remote Mnemosyne peer as `GET /memory/federation/peers` shows it. The
|
|
1783
|
+
* server never returns the peer's pull key or symmetric key, only whether they
|
|
1784
|
+
* are set.
|
|
1785
|
+
*/
|
|
1786
|
+
interface PeerConfig {
|
|
1787
|
+
peerId: string;
|
|
1788
|
+
/** SHA-256 (hex) of the pinned DER certificate. */
|
|
1789
|
+
certFingerprint: string;
|
|
1790
|
+
/** Local voting weight, 0 to 1. */
|
|
1791
|
+
trustWeight: number;
|
|
1792
|
+
/** ISO 8601 — when the current pin was approved. */
|
|
1793
|
+
approvedAt: string;
|
|
1794
|
+
enabled: boolean;
|
|
1795
|
+
url?: string;
|
|
1796
|
+
/** The peer's Ed25519 public key, PEM. */
|
|
1797
|
+
signingPublicKey?: string;
|
|
1798
|
+
hasApiKey: boolean;
|
|
1799
|
+
hasSymmetricKey: boolean;
|
|
1800
|
+
}
|
|
1801
|
+
/** Response from `GET /memory/federation/peers`. */
|
|
1802
|
+
interface ListPeersResponse {
|
|
1803
|
+
peers: PeerConfig[];
|
|
1804
|
+
}
|
|
1805
|
+
/** Response from `GET /memory/federation/peers/pending`. */
|
|
1806
|
+
interface ListPendingPeersResponse {
|
|
1807
|
+
peers: PeerConfig[];
|
|
1808
|
+
discovery: {
|
|
1809
|
+
enabled: boolean;
|
|
1810
|
+
reason?: string;
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
/** Body for `POST /memory/federation/peers`. Unknown fields are refused. */
|
|
1814
|
+
interface CreatePeerInput {
|
|
1815
|
+
/** Domain or UUID, e.g. `"acme.example"`. */
|
|
1816
|
+
peerId: string;
|
|
1817
|
+
/** The peer's pinned DER certificate (or SPKI key), base64. */
|
|
1818
|
+
pinnedCertDer: string;
|
|
1819
|
+
/** Local voting weight, 0 to 1. */
|
|
1820
|
+
trustWeight: number;
|
|
1821
|
+
/** Defaults to true. */
|
|
1822
|
+
enabled?: boolean;
|
|
1823
|
+
/** The peer's base URL (https), used to pull its items. */
|
|
1824
|
+
url?: string;
|
|
1825
|
+
/** API key this server sends when pulling from the peer. */
|
|
1826
|
+
apiKey?: string;
|
|
1827
|
+
/** The peer's Ed25519 public key, PEM. Goes with `symmetricKey`. */
|
|
1828
|
+
signingPublicKey?: string;
|
|
1829
|
+
/** Shared 32-byte key, base64. Goes with `signingPublicKey`. */
|
|
1830
|
+
symmetricKey?: string;
|
|
1831
|
+
}
|
|
1832
|
+
/** Response from `POST /memory/federation/peers` (201). */
|
|
1833
|
+
interface CreatePeerResponse {
|
|
1834
|
+
created: true;
|
|
1835
|
+
peerId: string;
|
|
1836
|
+
/** ISO 8601, server time. */
|
|
1837
|
+
approvedAt: string;
|
|
1838
|
+
}
|
|
1839
|
+
/** Body for `POST /memory/federation/peers/:id/approve` and `/approve-key`. */
|
|
1840
|
+
interface ApprovePeerInput {
|
|
1841
|
+
/** DER-encoded new certificate, base64. */
|
|
1842
|
+
newCertDer: string;
|
|
1843
|
+
/** ISO 8601. Defaults to server time if omitted. */
|
|
1844
|
+
issuedAt?: string;
|
|
1845
|
+
}
|
|
1846
|
+
/** Response from `POST /memory/federation/peers/:id/approve-key`. */
|
|
1847
|
+
interface ApprovePeerKeyResponse {
|
|
1848
|
+
approved: boolean;
|
|
1849
|
+
peerId: string;
|
|
1850
|
+
approvedAt: string;
|
|
1851
|
+
}
|
|
1852
|
+
/** Response from `DELETE /memory/federation/peers/:id`. */
|
|
1853
|
+
interface DeletePeerResponse {
|
|
1854
|
+
deleted: true;
|
|
1855
|
+
peerId: string;
|
|
1856
|
+
}
|
|
1857
|
+
/** One fact as `GET /memory/federation/items` serves it to a peer. */
|
|
1858
|
+
interface FederationItem {
|
|
1859
|
+
/** The fact's id on the serving server. */
|
|
1860
|
+
remoteId: string;
|
|
1861
|
+
/** The fact's revisionCount: every edit raises it. 0 on a hard-deleted fact's tombstone. */
|
|
1862
|
+
version: number;
|
|
1863
|
+
/** Host name of the request URL on the serving server. */
|
|
1864
|
+
peerDomain: string;
|
|
1865
|
+
/** Set on a tombstone (forgotten, merged or deleted fact): the day, ISO 8601 at UTC midnight. */
|
|
1866
|
+
deletedAt?: string;
|
|
1867
|
+
/** Empty on a tombstone. */
|
|
1868
|
+
payload: FederationItemPayload | Record<string, never>;
|
|
1869
|
+
}
|
|
1870
|
+
interface FederationItemPayload {
|
|
1871
|
+
statement: string;
|
|
1872
|
+
kind: "objective_fact";
|
|
1873
|
+
attribution: "federation_received";
|
|
1874
|
+
sensitivity: string;
|
|
1875
|
+
/** ISO 8601 */
|
|
1876
|
+
validFrom: string;
|
|
1877
|
+
/** ISO 8601, or null while the fact is current. */
|
|
1878
|
+
validTo: string | null;
|
|
1879
|
+
}
|
|
1880
|
+
/** An item of the signed envelope: `payload` is sealed (AES-256-GCM). */
|
|
1881
|
+
interface SealedFederationItem extends Omit<FederationItem, "payload"> {
|
|
1882
|
+
sealed: {
|
|
1883
|
+
iv: string;
|
|
1884
|
+
tag: string;
|
|
1885
|
+
ct: string;
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Response from `GET /memory/federation/items`: plaintext, or a signed envelope
|
|
1890
|
+
* with sealed payloads when the serving server has app-layer crypto configured.
|
|
1891
|
+
* `nextCursor` resumes after the page (pass it as `cursor`); null when the page
|
|
1892
|
+
* read nothing.
|
|
1893
|
+
*/
|
|
1894
|
+
type ListFederationItemsResponse = {
|
|
1895
|
+
items: FederationItem[];
|
|
1896
|
+
nextCursor: string | null;
|
|
1897
|
+
} | {
|
|
1898
|
+
alg: "ed25519+aes-256-gcm";
|
|
1899
|
+
signature: string;
|
|
1900
|
+
items: SealedFederationItem[];
|
|
1901
|
+
nextCursor: string | null;
|
|
1902
|
+
};
|
|
1903
|
+
/** Body for `POST /memory/federation/sync`. */
|
|
1904
|
+
interface TriggerFederationSyncInput {
|
|
1905
|
+
peerId: string;
|
|
1906
|
+
}
|
|
1907
|
+
/** Response from `POST /memory/federation/sync` (202 Accepted). */
|
|
1908
|
+
interface TriggerFederationSyncResponse {
|
|
1909
|
+
jobId: string;
|
|
1910
|
+
status: "pending";
|
|
1911
|
+
}
|
|
1912
|
+
/** One federation sync job record. */
|
|
1913
|
+
interface FederationSyncJob {
|
|
1914
|
+
jobId: string;
|
|
1915
|
+
peerId: string;
|
|
1916
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
1917
|
+
startedAt?: string | null;
|
|
1918
|
+
completedAt?: string | null;
|
|
1919
|
+
error?: string | null;
|
|
1920
|
+
itemsProcessed?: number;
|
|
1921
|
+
}
|
|
1922
|
+
/** One conflict claim for `POST /memory/federation/resolve`. */
|
|
1923
|
+
interface FederationClaim {
|
|
1924
|
+
id: string;
|
|
1925
|
+
content: string;
|
|
1926
|
+
version: number;
|
|
1927
|
+
attribution?: Record<string, unknown>;
|
|
1928
|
+
worth?: number;
|
|
1929
|
+
}
|
|
1930
|
+
/** Body for `POST /memory/federation/resolve` — two-item shorthand. */
|
|
1931
|
+
interface ResolveFederationConflictPairInput {
|
|
1932
|
+
itemA: FederationClaim;
|
|
1933
|
+
itemB: FederationClaim;
|
|
1934
|
+
}
|
|
1935
|
+
/** Body for `POST /memory/federation/resolve` — batch form. */
|
|
1936
|
+
interface ResolveFederationConflictBatchInput {
|
|
1937
|
+
items: FederationClaim[];
|
|
1938
|
+
}
|
|
1939
|
+
/** Response from `POST /memory/federation/resolve`. */
|
|
1940
|
+
interface ResolveFederationConflictResponse {
|
|
1941
|
+
/** Present when a clear winner was determined. */
|
|
1942
|
+
winner?: FederationClaim;
|
|
1943
|
+
/** Present when a clear loser was determined. */
|
|
1944
|
+
loser?: FederationClaim;
|
|
1945
|
+
/** When batch form resolves to a single outcome. */
|
|
1946
|
+
outcome?: FederationClaim;
|
|
1947
|
+
strategy: string;
|
|
1948
|
+
/** ISO 8601 */
|
|
1949
|
+
resolvedAt: string;
|
|
1950
|
+
}
|
|
1951
|
+
/** One anticipated memory from the Anticipation Engine (§30). */
|
|
1952
|
+
interface AnticipatedMemory {
|
|
1953
|
+
factId: string;
|
|
1954
|
+
score: number;
|
|
1955
|
+
source: "sequential" | "periodic" | "conditional" | "co-occurrence" | "blended";
|
|
1956
|
+
confidence: number;
|
|
1957
|
+
/** Optional short explanation for why this memory was surfaced. */
|
|
1958
|
+
reason?: string;
|
|
1959
|
+
}
|
|
1960
|
+
/** Response from `GET /anticipation`. */
|
|
1961
|
+
interface AnticipationFeedResponse {
|
|
1962
|
+
items: AnticipatedMemory[];
|
|
1963
|
+
generatedAt: string;
|
|
1964
|
+
}
|
|
1965
|
+
/** One composition rule in the workspace. */
|
|
1966
|
+
interface CompositionRule {
|
|
1967
|
+
id: string;
|
|
1968
|
+
workspaceId: string;
|
|
1969
|
+
name: string;
|
|
1970
|
+
description?: string | null;
|
|
1971
|
+
conditionDsl: unknown;
|
|
1972
|
+
actionDsl: unknown;
|
|
1973
|
+
priority: number;
|
|
1974
|
+
isActive: boolean;
|
|
1975
|
+
source: "manual" | "mined" | "imported";
|
|
1976
|
+
executionCount: number;
|
|
1977
|
+
metadata: Record<string, unknown>;
|
|
1978
|
+
createdAt: string;
|
|
1979
|
+
updatedAt: string;
|
|
1980
|
+
}
|
|
1981
|
+
/** Paginated list of composition rules. */
|
|
1982
|
+
interface ListCompositionRulesResponse {
|
|
1983
|
+
items: CompositionRule[];
|
|
1984
|
+
total: number;
|
|
1985
|
+
offset: number;
|
|
1986
|
+
limit: number;
|
|
1987
|
+
}
|
|
1988
|
+
/** One derived inference from the dry-run endpoint. */
|
|
1989
|
+
interface DerivedInference {
|
|
1990
|
+
type: "fact" | "warning";
|
|
1991
|
+
statement: string;
|
|
1992
|
+
confidence: number;
|
|
1993
|
+
ruleId: string;
|
|
1994
|
+
ruleName: string;
|
|
1995
|
+
hop: number;
|
|
1996
|
+
premises: string[];
|
|
1997
|
+
}
|
|
1998
|
+
/** Response from `POST /composition/dry-run`. */
|
|
1999
|
+
interface CompositionDryRunResponse {
|
|
2000
|
+
fired: number;
|
|
2001
|
+
inferences: DerivedInference[];
|
|
2002
|
+
conflicts: Array<{
|
|
2003
|
+
winner: DerivedInference;
|
|
2004
|
+
dropped: DerivedInference[];
|
|
2005
|
+
}>;
|
|
2006
|
+
}
|
|
2007
|
+
type SelfEditAction = "append" | "replace" | "strengthen" | "weaken"
|
|
2008
|
+
/**
|
|
2009
|
+
* @deprecated Server-side gated (422 `self_edit_forget_unsupported`) as of
|
|
2010
|
+
* B4 — no approval flow exists to resolve it. Kept in the type so the 422
|
|
2011
|
+
* response stays typed/observable for existing callers instead of a hard
|
|
2012
|
+
* compile break. Use `forgetFact`/`forgetPrimitive` (kind: "fact" | "strategy") instead.
|
|
2013
|
+
*/
|
|
2014
|
+
| "forget" | "reflect" | "link";
|
|
2015
|
+
type SelfEditTargetKind = "fact" | "strategy" | "profile";
|
|
2016
|
+
interface AppliedSelfEditBase {
|
|
2017
|
+
applied: true;
|
|
2018
|
+
target: string;
|
|
2019
|
+
targetKind: SelfEditTargetKind;
|
|
2020
|
+
countsAsEdit: boolean;
|
|
2021
|
+
countsAsDelete: boolean;
|
|
2022
|
+
}
|
|
2023
|
+
interface AppliedFactReplaceResponse extends AppliedSelfEditBase {
|
|
2024
|
+
action: "replace";
|
|
2025
|
+
targetKind: "fact";
|
|
2026
|
+
replacementId: string;
|
|
2027
|
+
}
|
|
2028
|
+
interface AppliedNonFactReplaceResponse extends AppliedSelfEditBase {
|
|
2029
|
+
action: "replace";
|
|
2030
|
+
targetKind: "strategy" | "profile";
|
|
2031
|
+
replacementId?: never;
|
|
2032
|
+
}
|
|
2033
|
+
interface AppliedNonReplaceResponse extends AppliedSelfEditBase {
|
|
2034
|
+
action: Exclude<SelfEditAction, "replace" | "reflect">;
|
|
2035
|
+
replacementId?: never;
|
|
2036
|
+
}
|
|
2037
|
+
interface SelfEditApprovalResponse {
|
|
2038
|
+
applied: false;
|
|
2039
|
+
action: SelfEditAction;
|
|
2040
|
+
target: string;
|
|
2041
|
+
targetKind: SelfEditTargetKind;
|
|
2042
|
+
approvalRequired: true;
|
|
2043
|
+
scope: "delete_fact" | "edit_entity";
|
|
2044
|
+
reason: string;
|
|
2045
|
+
replacementId?: never;
|
|
2046
|
+
}
|
|
2047
|
+
interface SelfEditReflectionResponse {
|
|
2048
|
+
applied: true;
|
|
2049
|
+
action: "reflect";
|
|
2050
|
+
episode_id: string;
|
|
2051
|
+
strengthened: string[];
|
|
2052
|
+
weakened: string[];
|
|
2053
|
+
replacementId?: never;
|
|
2054
|
+
}
|
|
2055
|
+
/** Discriminated response from `POST /self/edit`. */
|
|
2056
|
+
type SelfEditResponse = AppliedFactReplaceResponse | AppliedNonFactReplaceResponse | AppliedNonReplaceResponse | SelfEditApprovalResponse | SelfEditReflectionResponse;
|
|
2057
|
+
/**
|
|
2058
|
+
* Options for `client.subscribe(channel, handler, opts?)`.
|
|
2059
|
+
*
|
|
2060
|
+
* Internally the SDK opens a WebSocket to `ws[s]://…/memory/ws?token=<apiKey>`.
|
|
2061
|
+
* Requires the runtime to support `WebSocket` (Node ≥ 22 ships a native global;
|
|
2062
|
+
* older environments must polyfill with e.g. `ws`).
|
|
2063
|
+
*/
|
|
2064
|
+
interface SubscribeOptions {
|
|
2065
|
+
/** Optional entity/agent/memoryType filter forwarded to the server. */
|
|
2066
|
+
filter?: {
|
|
2067
|
+
entityId?: string;
|
|
2068
|
+
agentId?: string;
|
|
2069
|
+
memoryType?: string;
|
|
2070
|
+
};
|
|
2071
|
+
/**
|
|
2072
|
+
* Called when the WS disconnects. Return `true` to attempt a reconnect
|
|
2073
|
+
* (the SDK will NOT reconnect automatically by default).
|
|
2074
|
+
*/
|
|
2075
|
+
onDisconnect?: (reason: string) => boolean | undefined;
|
|
2076
|
+
/** Optional WebSocket constructor — inject for Node < 22 or testing. */
|
|
2077
|
+
WebSocketImpl?: typeof WebSocket;
|
|
2078
|
+
}
|
|
2079
|
+
/** Handle returned by `client.subscribe(...)`. */
|
|
2080
|
+
interface SubscribeHandle {
|
|
2081
|
+
/** Close the WebSocket subscription. */
|
|
2082
|
+
close(): void;
|
|
2083
|
+
/** True while the socket is open. */
|
|
2084
|
+
readonly connected: boolean;
|
|
2085
|
+
}
|
|
2086
|
+
type SelfModelAspect = "coverage" | "trends" | "gaps" | "strengths" | "all";
|
|
2087
|
+
interface SelfModelResponse {
|
|
2088
|
+
workspaceId: string;
|
|
2089
|
+
generatedAt: string;
|
|
2090
|
+
strongTopics: Array<{
|
|
2091
|
+
topicKey: string;
|
|
2092
|
+
memoryCount: number;
|
|
2093
|
+
avgWorth: number;
|
|
2094
|
+
evidenceVolume: number;
|
|
2095
|
+
}>;
|
|
2096
|
+
gaps: Array<{
|
|
2097
|
+
topicKey: string;
|
|
2098
|
+
gapScore: number;
|
|
2099
|
+
recallHits30d: number;
|
|
2100
|
+
avgWorth: number;
|
|
2101
|
+
memoryCount: number;
|
|
2102
|
+
}>;
|
|
2103
|
+
summary: {
|
|
2104
|
+
totalTopics: number;
|
|
2105
|
+
strongTopicsCount: number;
|
|
2106
|
+
gapsCount: number;
|
|
2107
|
+
avgWorthAcrossWorkspace: number;
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Status for a single diagnostic check.
|
|
2112
|
+
* `"ok"` — check passed. `"warn"` — check returned a warning. `"error"` — check
|
|
2113
|
+
* failed. `"unknown"` — check could not determine its own result (e.g. permission
|
|
2114
|
+
* denied before the query ran).
|
|
2115
|
+
*/
|
|
2116
|
+
type DoctorCheckStatus = "ok" | "warn" | "error" | "unknown";
|
|
2117
|
+
/**
|
|
2118
|
+
* One diagnostic check result in a `DoctorReport`.
|
|
2119
|
+
*/
|
|
2120
|
+
interface DoctorCheck {
|
|
2121
|
+
/** Stable machine-readable check identifier (e.g. "connectivity", "app_user_grants"). */
|
|
2122
|
+
name: string;
|
|
2123
|
+
/** Check outcome. */
|
|
2124
|
+
status: DoctorCheckStatus;
|
|
2125
|
+
/** Human-readable explanation of the outcome. */
|
|
2126
|
+
message: string;
|
|
2127
|
+
/** Optional numeric / structured detail (e.g. backlog count, migration filename). */
|
|
2128
|
+
detail?: Record<string, unknown>;
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2131
|
+
* Full operational diagnostic report returned by `GET /doctor` and the
|
|
2132
|
+
* `memory_doctor` MCP tool.
|
|
2133
|
+
*
|
|
2134
|
+
* `status` is the worst-of all checks: if any check is `"error"` the overall
|
|
2135
|
+
* status is `"error"`; if any is `"warn"` (and none are `"error"`) the overall
|
|
2136
|
+
* status is `"warn"`; otherwise `"ok"`.
|
|
2137
|
+
*/
|
|
2138
|
+
interface DoctorReport {
|
|
2139
|
+
/** Worst-of status across all checks. */
|
|
2140
|
+
status: DoctorCheckStatus;
|
|
2141
|
+
/** Individual check results. */
|
|
2142
|
+
checks: DoctorCheck[];
|
|
2143
|
+
/** ISO 8601 timestamp of report generation. */
|
|
2144
|
+
timestamp: string;
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* Condensed fact summary inside a conflict pair.
|
|
2148
|
+
* Mirrors `ConflictFact` from `packages/server/src/routes/conflicts.ts`.
|
|
2149
|
+
*/
|
|
2150
|
+
interface ConflictFact {
|
|
2151
|
+
id: string;
|
|
2152
|
+
subject: string;
|
|
2153
|
+
statement: string;
|
|
2154
|
+
worth: number;
|
|
2155
|
+
validFrom: string;
|
|
2156
|
+
validTo: string | null;
|
|
2157
|
+
}
|
|
2158
|
+
/**
|
|
2159
|
+
* One unresolved conflict pair — two facts linked by a `conflicts_with`
|
|
2160
|
+
* relation, surfaced for interactive LLM judgment.
|
|
2161
|
+
*/
|
|
2162
|
+
interface ConflictPair {
|
|
2163
|
+
relationId: string;
|
|
2164
|
+
confidence: number | null;
|
|
2165
|
+
factA: ConflictFact;
|
|
2166
|
+
factB: ConflictFact;
|
|
2167
|
+
}
|
|
2168
|
+
/** Response from `GET /conflicts`. */
|
|
2169
|
+
interface ListConflictsResponse {
|
|
2170
|
+
pairs: ConflictPair[];
|
|
2171
|
+
/** Every unresolved pair the caller can see, `limit` aside. Optional: older servers omit it. */
|
|
2172
|
+
total?: number;
|
|
2173
|
+
}
|
|
2174
|
+
/** Input to `POST /conflicts/:id/resolve`. */
|
|
2175
|
+
interface ResolveConflictInput {
|
|
2176
|
+
/** How to resolve the conflict. */
|
|
2177
|
+
action: "supersede_a" | "supersede_b" | "keep_both" | "merge";
|
|
2178
|
+
/**
|
|
2179
|
+
* Required when `action='merge'`. The statement for the new merged fact
|
|
2180
|
+
* that replaces both conflicting facts.
|
|
2181
|
+
*/
|
|
2182
|
+
mergedStatement?: string;
|
|
2183
|
+
}
|
|
2184
|
+
/** Response from `POST /conflicts/:id/resolve`. */
|
|
2185
|
+
interface ResolveConflictResponse {
|
|
2186
|
+
resolved: boolean;
|
|
2187
|
+
action: "supersede_a" | "supersede_b" | "keep_both" | "merge";
|
|
2188
|
+
relationId: string;
|
|
2189
|
+
/** ID of the newly created merged fact; null unless action='merge'. */
|
|
2190
|
+
mergedFactId: string | null;
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Aggregate workspace statistics returned by `GET /admin/stats` and the
|
|
2194
|
+
* `memory_stats` MCP tool.
|
|
2195
|
+
*
|
|
2196
|
+
* Mirrors the `AdminStatsSchema` from `packages/server/src/routes/admin-stats.ts`.
|
|
2197
|
+
*/
|
|
2198
|
+
interface AdminStats {
|
|
2199
|
+
workspaceId: string;
|
|
2200
|
+
/** ISO 8601 timestamp of when the stats snapshot was generated. */
|
|
2201
|
+
generatedAt: string;
|
|
2202
|
+
facts: {
|
|
2203
|
+
/** Active facts with an open validity interval (validTo IS NULL). */
|
|
2204
|
+
live: number;
|
|
2205
|
+
/** Facts whose validity was closed by a `forget()` call. */
|
|
2206
|
+
closed: number;
|
|
2207
|
+
/** Facts with `pinned = true`. */
|
|
2208
|
+
pinned: number;
|
|
2209
|
+
/**
|
|
2210
|
+
* Facts archived by the janitor, or null when no usable snapshot exists
|
|
2211
|
+
* (cold start / stale). make-primitives-recallable Requirement 5: this
|
|
2212
|
+
* count MUST NOT fall back to `0` when the snapshot is absent — check
|
|
2213
|
+
* `snapshot.available` to tell "zero" apart from "unavailable".
|
|
2214
|
+
*/
|
|
2215
|
+
archived: number | null;
|
|
2216
|
+
/**
|
|
2217
|
+
* Active facts that have never been recalled (hit_count = 0), or null
|
|
2218
|
+
* when no usable snapshot exists. See `archived`'s doc comment.
|
|
2219
|
+
* Admin only (omitted for memory:read callers).
|
|
2220
|
+
*/
|
|
2221
|
+
withZeroHits?: number | null;
|
|
2222
|
+
/**
|
|
2223
|
+
* Live fact counts per scopeRef. Only entries with a non-null scopeRef.
|
|
2224
|
+
* Admin only (omitted for memory:read callers).
|
|
2225
|
+
*/
|
|
2226
|
+
byScopeRef?: Array<{
|
|
2227
|
+
scopeRef: string;
|
|
2228
|
+
count: number;
|
|
2229
|
+
}>;
|
|
2230
|
+
};
|
|
2231
|
+
decisions: {
|
|
2232
|
+
/**
|
|
2233
|
+
* Decisions with status = 'active', or null when no usable snapshot
|
|
2234
|
+
* exists. See `facts.archived`'s doc comment.
|
|
2235
|
+
*/
|
|
2236
|
+
active: number | null;
|
|
2237
|
+
};
|
|
2238
|
+
relations: {
|
|
2239
|
+
/**
|
|
2240
|
+
* Relations with verb = 'conflicts_with', or null when no usable
|
|
2241
|
+
* snapshot exists. See `facts.archived`'s doc comment.
|
|
2242
|
+
*/
|
|
2243
|
+
conflicts: number | null;
|
|
2244
|
+
};
|
|
2245
|
+
/** Admin only (omitted for memory:read callers). */
|
|
2246
|
+
embeddings?: {
|
|
2247
|
+
/** Facts with an up-to-date embedding vector. */
|
|
2248
|
+
indexed: number;
|
|
2249
|
+
/** Facts awaiting embedding. */
|
|
2250
|
+
pending: number;
|
|
2251
|
+
};
|
|
2252
|
+
/**
|
|
2253
|
+
* The `mnemo_health` snapshot backing the four nullable counts above.
|
|
2254
|
+
* make-primitives-recallable Requirement 5.
|
|
2255
|
+
* Admin only (omitted for memory:read callers).
|
|
2256
|
+
*/
|
|
2257
|
+
snapshot?: {
|
|
2258
|
+
/** ISO 8601 timestamp the snapshot was computed at, or null if absent. */
|
|
2259
|
+
at: string | null;
|
|
2260
|
+
/** Snapshot age in seconds, or null if absent. */
|
|
2261
|
+
ageSeconds: number | null;
|
|
2262
|
+
/** False when no usable snapshot exists (cold start / stale read). */
|
|
2263
|
+
available: boolean;
|
|
2264
|
+
};
|
|
2265
|
+
recall: {
|
|
2266
|
+
/** 30-day recall hit rate (0–1), or null if no recall data yet. */
|
|
2267
|
+
hitRate30d: number | null;
|
|
2268
|
+
/** ISO 8601 timestamp of the last recall query, or null. */
|
|
2269
|
+
lastRecallAt: string | null;
|
|
2270
|
+
/**
|
|
2271
|
+
* Recall latency percentiles over the last 7 days, null with no samples.
|
|
2272
|
+
* One sample per served memory, not per request; recalls that served
|
|
2273
|
+
* nothing are not counted.
|
|
2274
|
+
*/
|
|
2275
|
+
latencyP50Ms7d?: number | null;
|
|
2276
|
+
latencyP95Ms7d?: number | null;
|
|
2277
|
+
};
|
|
2278
|
+
/** Facts created per UTC day, last 14 days, oldest first, zero-filled. */
|
|
2279
|
+
writesPerDay14d?: Array<{
|
|
2280
|
+
day: string;
|
|
2281
|
+
count: number;
|
|
2282
|
+
}>;
|
|
2283
|
+
/** ISO 8601 timestamp of the last write to the workspace, or null. */
|
|
2284
|
+
lastWriteAt: string | null;
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Response from `DELETE /facts/:id/hard`.
|
|
2288
|
+
* Hard-deletes a single fact by ID (requires `memory:hard_delete` scope).
|
|
2289
|
+
*/
|
|
2290
|
+
interface PurgeFactResponse {
|
|
2291
|
+
deleted: true;
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Response from `DELETE /facts/purge`.
|
|
2295
|
+
* Bulk-deletes all closed (forgotten) facts in the workspace.
|
|
2296
|
+
* Requires `memory:hard_delete` scope.
|
|
2297
|
+
*/
|
|
2298
|
+
interface PurgeClosedFactsResponse {
|
|
2299
|
+
deleted: number;
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Body of `POST /admin/erasure` (GDPR crypto-erasure). Exactly one of
|
|
2303
|
+
* `userId`/`actorId`; `confirm` must repeat it.
|
|
2304
|
+
*/
|
|
2305
|
+
interface EraseSubjectInput {
|
|
2306
|
+
userId?: string;
|
|
2307
|
+
actorId?: string;
|
|
2308
|
+
confirm: string;
|
|
2309
|
+
}
|
|
2310
|
+
/** Response from `POST /admin/erasure`. */
|
|
2311
|
+
interface EraseSubjectResponse {
|
|
2312
|
+
subject: {
|
|
2313
|
+
kind: "user" | "actor";
|
|
2314
|
+
id: string;
|
|
2315
|
+
};
|
|
2316
|
+
keysDestroyed: number;
|
|
2317
|
+
}
|
|
2318
|
+
/** Metadata for an API key in the list response. */
|
|
2319
|
+
interface KeyListItem {
|
|
2320
|
+
id: string;
|
|
2321
|
+
label: string;
|
|
2322
|
+
prefix: string;
|
|
2323
|
+
scopes: string[];
|
|
2324
|
+
plan: string;
|
|
2325
|
+
ipAllowlist: string[];
|
|
2326
|
+
expiresAt: string | null;
|
|
2327
|
+
createdAt: string;
|
|
2328
|
+
lastUsedAt: string | null;
|
|
2329
|
+
revokedAt: string | null;
|
|
2330
|
+
maxSensitivity?: string | null;
|
|
2331
|
+
}
|
|
2332
|
+
/** Input payload for creating a new API key. */
|
|
2333
|
+
interface CreateKeyInput {
|
|
2334
|
+
label: string;
|
|
2335
|
+
scopes: string[];
|
|
2336
|
+
expiresIn?: string;
|
|
2337
|
+
ipAllowlist?: string[];
|
|
2338
|
+
plan?: "free" | "pro" | "enterprise";
|
|
2339
|
+
test?: boolean;
|
|
2340
|
+
maxSensitivity?: Sensitivity;
|
|
2341
|
+
/**
|
|
2342
|
+
* Issue an `mk_fed_` key: the bearer a federation peer pulls from this server
|
|
2343
|
+
* with. Scopes must be exactly `["memory:federation"]`.
|
|
2344
|
+
*/
|
|
2345
|
+
federation?: boolean;
|
|
2346
|
+
/** workspace (default, single workspace) or user (multi-workspace user token). */
|
|
2347
|
+
keyKind?: "workspace" | "user" | "tenant" | "admin";
|
|
2348
|
+
}
|
|
2349
|
+
/** Response from API key creation — plaintext key is shown ONCE. */
|
|
2350
|
+
interface CreateKeyResponse {
|
|
2351
|
+
id: string;
|
|
2352
|
+
key: string;
|
|
2353
|
+
label: string;
|
|
2354
|
+
scopes: string[];
|
|
2355
|
+
plan: string;
|
|
2356
|
+
expiresAt: string | null;
|
|
2357
|
+
createdAt: string;
|
|
2358
|
+
maxSensitivity?: string | null;
|
|
2359
|
+
}
|
|
2360
|
+
/** Metadata for a single API key detail response. */
|
|
2361
|
+
interface KeyDetailResponse {
|
|
2362
|
+
id: string;
|
|
2363
|
+
label: string;
|
|
2364
|
+
scopes: string[];
|
|
2365
|
+
ipAllowlist: string[];
|
|
2366
|
+
expiresAt: string | null;
|
|
2367
|
+
lastUsedAt: string | null;
|
|
2368
|
+
revokedAt: string | null;
|
|
2369
|
+
deprecatedAt: string | null;
|
|
2370
|
+
rotatedFromId: string | null;
|
|
2371
|
+
createdAt: string;
|
|
2372
|
+
maxSensitivity?: string | null;
|
|
2373
|
+
}
|
|
2374
|
+
/** Response from key rotation. */
|
|
2375
|
+
interface RotateKeyResponse {
|
|
2376
|
+
newKey: string;
|
|
2377
|
+
newKeyId: string;
|
|
2378
|
+
oldKeySunsetAt: string;
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Input for `issueScopedKey` (`POST /admin/scoped-keys`): a key of the scoped
|
|
2382
|
+
* scheme MNEMO_SCOPED_AUTH=1 verifies. `type` defaults to "live".
|
|
2383
|
+
*/
|
|
2384
|
+
interface IssueScopedKeyInput {
|
|
2385
|
+
/** live: mk_live_ (90 days at most), sess: mk_sess_ (24 h), admin: mk_admin_ (24 h, TOTP). */
|
|
2386
|
+
type?: "live" | "sess" | "admin";
|
|
2387
|
+
scopes: string[];
|
|
2388
|
+
/** 30d, 8h, 60m. Defaults to the type's maximum. */
|
|
2389
|
+
expiresIn?: string;
|
|
2390
|
+
ipAllowlist?: string[];
|
|
2391
|
+
maxSensitivity?: Sensitivity;
|
|
2392
|
+
}
|
|
2393
|
+
/** Response of `issueScopedKey`: `key` and `mfaSecret` are shown once. */
|
|
2394
|
+
interface IssueScopedKeyResponse {
|
|
2395
|
+
/** Public id, `{prefix}{keyId}`: what rotate and revoke take. */
|
|
2396
|
+
id: string;
|
|
2397
|
+
key: string;
|
|
2398
|
+
prefix: string;
|
|
2399
|
+
scopes: string[];
|
|
2400
|
+
expiresAt: string;
|
|
2401
|
+
createdAt: string;
|
|
2402
|
+
maxSensitivity: string | null;
|
|
2403
|
+
/** mk_admin_ only: base32 TOTP secret; send codes in `x-mnemo-mfa`. */
|
|
2404
|
+
mfaSecret?: string;
|
|
2405
|
+
/** mk_admin_ only: the secret as an otpauth:// URI. */
|
|
2406
|
+
otpauthUri?: string;
|
|
2407
|
+
}
|
|
2408
|
+
/** Response of `rotateScopedKey`. The old key works until `oldKeySunsetAt`. */
|
|
2409
|
+
interface RotateScopedKeyResponse {
|
|
2410
|
+
newKey: string;
|
|
2411
|
+
newId: string;
|
|
2412
|
+
oldKeySunsetAt: string;
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* The RBAC policy of one agent (its API key id), written whole by
|
|
2416
|
+
* `putAgentPolicy` (`PUT /admin/agent-policy`). Scopes are the §6 memory
|
|
2417
|
+
* scopes (`memory:read`, `memory:write`, ...); a limit of 0 means unlimited.
|
|
2418
|
+
*/
|
|
2419
|
+
interface AgentPolicyInput {
|
|
2420
|
+
agentId: string;
|
|
2421
|
+
readScopes: string[];
|
|
2422
|
+
writeScopes: string[];
|
|
2423
|
+
selfEdit: {
|
|
2424
|
+
enabled: boolean;
|
|
2425
|
+
maxWorthDelta?: number;
|
|
2426
|
+
};
|
|
2427
|
+
taskScopes: {
|
|
2428
|
+
canCreate: boolean;
|
|
2429
|
+
canDelegate: boolean;
|
|
2430
|
+
canDelegateTo: string[];
|
|
2431
|
+
};
|
|
2432
|
+
limits: {
|
|
2433
|
+
maxRecallsPerMinute: number;
|
|
2434
|
+
maxWritesPerMinute: number;
|
|
2435
|
+
maxSessionsConcurrent: number;
|
|
2436
|
+
maxSelfEditsPerSession: number;
|
|
2437
|
+
};
|
|
2438
|
+
requireApprovalFor: string[];
|
|
2439
|
+
federationAccess: "none" | "read" | "read_write";
|
|
2440
|
+
namespaces?: string[];
|
|
2441
|
+
}
|
|
2442
|
+
/** A stored agent policy: the input plus the workspace it belongs to. */
|
|
2443
|
+
interface AgentPolicy extends AgentPolicyInput {
|
|
2444
|
+
workspaceId: string;
|
|
2445
|
+
}
|
|
2446
|
+
/** Wire representation of an agent Skill (stored prompt template). */
|
|
2447
|
+
interface SkillWire {
|
|
2448
|
+
id: string;
|
|
2449
|
+
workspaceId: string;
|
|
2450
|
+
name: string;
|
|
2451
|
+
promptTemplate: string;
|
|
2452
|
+
variables: string[];
|
|
2453
|
+
requiredContext: string[];
|
|
2454
|
+
qualityScore: number;
|
|
2455
|
+
usageCount: number;
|
|
2456
|
+
lastUsedAt?: string;
|
|
2457
|
+
embeddingModel?: string;
|
|
2458
|
+
embeddingStale: boolean;
|
|
2459
|
+
sensitivity: Sensitivity;
|
|
2460
|
+
createdAt: string;
|
|
2461
|
+
updatedAt: string;
|
|
2462
|
+
metadata: Record<string, unknown>;
|
|
2463
|
+
}
|
|
2464
|
+
/** Input payload for creating a skill. */
|
|
2465
|
+
interface CreateSkillClientInput {
|
|
2466
|
+
name: string;
|
|
2467
|
+
promptTemplate: string;
|
|
2468
|
+
variables?: string[];
|
|
2469
|
+
requiredContext?: string[];
|
|
2470
|
+
sensitivity?: Sensitivity;
|
|
2471
|
+
metadata?: Record<string, unknown>;
|
|
2472
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
2473
|
+
targetWorkspaceId?: string;
|
|
2474
|
+
}
|
|
2475
|
+
/** Paginated list response for skills. */
|
|
2476
|
+
interface SkillListResponse {
|
|
2477
|
+
items: SkillWire[];
|
|
2478
|
+
total: number;
|
|
2479
|
+
offset: number;
|
|
2480
|
+
limit: number;
|
|
2481
|
+
hasMore: boolean;
|
|
2482
|
+
}
|
|
2483
|
+
/** Constructor options for `MnemosyneClient`. */
|
|
2484
|
+
interface MnemosyneClientOptions {
|
|
2485
|
+
/** Base URL of the Mnemosyne HTTP server, e.g. `https://memory.example.com`. */
|
|
2486
|
+
url: string;
|
|
2487
|
+
/** API key minted in the Mnemosyne control plane. Scoped to a workspace. */
|
|
2488
|
+
apiKey: string;
|
|
2489
|
+
/** Optional fetch implementation. Defaults to the global `fetch`. */
|
|
2490
|
+
fetch?: typeof fetch;
|
|
2491
|
+
/** Request timeout in milliseconds. Default 30_000. */
|
|
2492
|
+
timeout?: number;
|
|
2493
|
+
/** Retry policy. Default: 3 attempts, exponential backoff with jitter. */
|
|
2494
|
+
retry?: RetryConfig;
|
|
2495
|
+
/**
|
|
2496
|
+
* Optional User-Agent suffix. Useful for operators to distinguish
|
|
2497
|
+
* traffic from different consumer apps in their logs.
|
|
2498
|
+
*/
|
|
2499
|
+
userAgent?: string;
|
|
2500
|
+
/**
|
|
2501
|
+
* Default `X-Workspace-Id` sent on every request — only meaningful
|
|
2502
|
+
* when `apiKey` is a `uk_live_*` user token (a plain workspace key
|
|
2503
|
+
* ignores it server-side; see auth.ts's multi-workspace resolution).
|
|
2504
|
+
* Prefer `MnemosyneClient.forWorkspace(id)` over setting this directly
|
|
2505
|
+
* when one process serves multiple concurrent callers, since a shared
|
|
2506
|
+
* client's `workspaceId` here applies to every call made through it.
|
|
2507
|
+
*/
|
|
2508
|
+
workspaceId?: string;
|
|
2509
|
+
/**
|
|
2510
|
+
* Locale tag (e.g. `es-419`) sent as `Accept-Language` on every request so
|
|
2511
|
+
* the server can localize error messages. Passed through as-is; omit to
|
|
2512
|
+
* send no header.
|
|
2513
|
+
*/
|
|
2514
|
+
locale?: string;
|
|
2515
|
+
}
|
|
2516
|
+
/** Tenant-plane membership role — mnemo_tenant_member.role. */
|
|
2517
|
+
type TenantRole = "owner" | "admin" | "member";
|
|
2518
|
+
/** Workspace-plane membership role — mnemo_workspace_member.role. */
|
|
2519
|
+
type WorkspaceRole = "owner" | "admin" | "write" | "read";
|
|
2520
|
+
interface Tenant {
|
|
2521
|
+
id: string;
|
|
2522
|
+
name: string;
|
|
2523
|
+
kind: string;
|
|
2524
|
+
plan: string;
|
|
2525
|
+
createdAt: string | null;
|
|
2526
|
+
}
|
|
2527
|
+
interface TenantMember {
|
|
2528
|
+
userId: string;
|
|
2529
|
+
role: TenantRole;
|
|
2530
|
+
joinedAt: string | null;
|
|
2531
|
+
}
|
|
2532
|
+
interface MnemosyneUser {
|
|
2533
|
+
id: string;
|
|
2534
|
+
email: string;
|
|
2535
|
+
displayName: string | null;
|
|
2536
|
+
personalTenantId: string;
|
|
2537
|
+
createdAt: string | null;
|
|
2538
|
+
}
|
|
2539
|
+
interface Workspace {
|
|
2540
|
+
id: string;
|
|
2541
|
+
name: string;
|
|
2542
|
+
slug: string | null;
|
|
2543
|
+
tenantId: string;
|
|
2544
|
+
visibility: string;
|
|
2545
|
+
createdAt: string | null;
|
|
2546
|
+
}
|
|
2547
|
+
interface WorkspaceListItem {
|
|
2548
|
+
id: string;
|
|
2549
|
+
name: string;
|
|
2550
|
+
slug: string | null;
|
|
2551
|
+
visibility: string;
|
|
2552
|
+
memberCount: number;
|
|
2553
|
+
}
|
|
2554
|
+
interface WorkspaceListItemWithRole {
|
|
2555
|
+
workspaceId: string;
|
|
2556
|
+
workspaceName: string;
|
|
2557
|
+
role: WorkspaceRole;
|
|
2558
|
+
visibility: string;
|
|
2559
|
+
}
|
|
2560
|
+
interface WorkspaceMember {
|
|
2561
|
+
userId: string;
|
|
2562
|
+
role: WorkspaceRole;
|
|
2563
|
+
joinedAt: string | null;
|
|
2564
|
+
}
|
|
2565
|
+
interface CreateTenantInput {
|
|
2566
|
+
name: string;
|
|
2567
|
+
kind?: "personal" | "organization";
|
|
2568
|
+
plan?: string;
|
|
2569
|
+
/**
|
|
2570
|
+
* Also create the tenant's first workspace, owned by the caller's user, and
|
|
2571
|
+
* return `ownerToken`: a token bound to the new tenant and workspace. The
|
|
2572
|
+
* caller's own key keeps acting in its old tenant, so without it nothing can
|
|
2573
|
+
* act in the new one. Needs a key bound to a user.
|
|
2574
|
+
*/
|
|
2575
|
+
issueOwnerToken?: boolean;
|
|
2576
|
+
/** Name of the first workspace with `issueOwnerToken`. Defaults to the tenant name. */
|
|
2577
|
+
workspaceName?: string;
|
|
2578
|
+
}
|
|
2579
|
+
/** A token for the new tenant's owner, from `issueOwnerToken`. The plaintext `key` is shown once. */
|
|
2580
|
+
interface TenantOwnerToken {
|
|
2581
|
+
id: string;
|
|
2582
|
+
key: string;
|
|
2583
|
+
label: string;
|
|
2584
|
+
scopes: string[];
|
|
2585
|
+
userId: string;
|
|
2586
|
+
tenantId: string;
|
|
2587
|
+
workspaceId: string;
|
|
2588
|
+
maxSensitivity: string | null;
|
|
2589
|
+
createdAt: string;
|
|
2590
|
+
}
|
|
2591
|
+
/** Response from `POST /tenants`: the tenant, plus its first workspace and owner token with `issueOwnerToken`. */
|
|
2592
|
+
interface CreateTenantResponse extends Tenant {
|
|
2593
|
+
workspace?: Workspace;
|
|
2594
|
+
ownerToken?: TenantOwnerToken;
|
|
2595
|
+
}
|
|
2596
|
+
interface InviteTenantMemberInput {
|
|
2597
|
+
email: string;
|
|
2598
|
+
role?: TenantRole;
|
|
2599
|
+
/**
|
|
2600
|
+
* When true, auto-provisions a user (+ personal tenant + personal
|
|
2601
|
+
* workspace, same as `createUser`) if no account exists for `email`
|
|
2602
|
+
* yet, then adds the tenant membership in the same call. Default
|
|
2603
|
+
* false preserves the original 404-on-unknown-email behavior.
|
|
2604
|
+
*/
|
|
2605
|
+
createIfMissing?: boolean;
|
|
2606
|
+
}
|
|
2607
|
+
interface CreateUserInput {
|
|
2608
|
+
email: string;
|
|
2609
|
+
displayName?: string;
|
|
2610
|
+
}
|
|
2611
|
+
interface CreateUserResponse {
|
|
2612
|
+
user: MnemosyneUser;
|
|
2613
|
+
personalTenant: Tenant;
|
|
2614
|
+
personalWorkspace: Workspace;
|
|
2615
|
+
}
|
|
2616
|
+
interface CreateWorkspaceInput {
|
|
2617
|
+
name: string;
|
|
2618
|
+
slug?: string;
|
|
2619
|
+
ownerUserId?: string;
|
|
2620
|
+
visibility?: "private" | "public";
|
|
2621
|
+
}
|
|
2622
|
+
interface InviteWorkspaceMemberInput {
|
|
2623
|
+
userId: string;
|
|
2624
|
+
role?: WorkspaceRole;
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* `GET /me` response. Widened over time as auth.ts grew workspace-role
|
|
2628
|
+
* narrowing (S4/S5) — every field beyond `workspaceId`/`scopes` is
|
|
2629
|
+
* optional so older servers' responses still parse.
|
|
2630
|
+
*/
|
|
2631
|
+
interface MeResponse {
|
|
2632
|
+
workspaceId: string;
|
|
2633
|
+
workspaceName?: string | null;
|
|
2634
|
+
/**
|
|
2635
|
+
* The authenticating API key's own row id (mnemo_api_keys.id) — the
|
|
2636
|
+
* credential, NOT reliably a userId. Use `userId` below for the platform
|
|
2637
|
+
* account, when present. Renamed from `actorId` for accuracy (pre-1.0,
|
|
2638
|
+
* no alias — see CLAUDE.md "Provenance identity").
|
|
2639
|
+
*/
|
|
2640
|
+
keyId: string;
|
|
2641
|
+
/** What kind of principal this key authenticates as. */
|
|
2642
|
+
actorType: "agent" | "user" | "system" | "federation";
|
|
2643
|
+
scopes: string[];
|
|
2644
|
+
plan: string;
|
|
2645
|
+
keyPrefix: string;
|
|
2646
|
+
expiresAt: string | null;
|
|
2647
|
+
ipAllowlist: string[];
|
|
2648
|
+
userId: string | null;
|
|
2649
|
+
personalWorkspaceId: string | null;
|
|
2650
|
+
personalFactsLive: number | null;
|
|
2651
|
+
tenantId: string | null;
|
|
2652
|
+
/**
|
|
2653
|
+
* Caller's membership role in the CURRENT workspace (owner/admin/write/
|
|
2654
|
+
* read), when resolvable. Null for keys with no user binding, or when
|
|
2655
|
+
* the user has no membership row for this workspace — narrowing then
|
|
2656
|
+
* degrades to the key's own static scopes (see `effectiveScopes`).
|
|
2657
|
+
*/
|
|
2658
|
+
workspaceRole?: WorkspaceRole | null;
|
|
2659
|
+
/**
|
|
2660
|
+
* Same value as `scopes` — named explicitly so callers don't need to
|
|
2661
|
+
* know that `scopes` is already the workspace-role-narrowed set, not
|
|
2662
|
+
* the key's raw static scope list.
|
|
2663
|
+
*/
|
|
2664
|
+
effectiveScopes?: string[];
|
|
2665
|
+
}
|
|
2666
|
+
interface CreateUserTokenInput {
|
|
2667
|
+
label: string;
|
|
2668
|
+
/** Must be in the same tenant; the target user must already be a member. */
|
|
2669
|
+
homeWorkspaceId: string;
|
|
2670
|
+
/** Must be a subset of the CALLER's own scopes. Omit to inherit them. */
|
|
2671
|
+
scopes?: string[];
|
|
2672
|
+
/** TTL, e.g. "90d", "8h", "60m". */
|
|
2673
|
+
expiresIn?: string;
|
|
2674
|
+
ipAllowlist?: string[];
|
|
2675
|
+
maxSensitivity?: "public" | "internal" | "confidential" | "restricted";
|
|
2676
|
+
/** Use the `uk_test_` prefix instead of `uk_live_`. */
|
|
2677
|
+
test?: boolean;
|
|
2678
|
+
}
|
|
2679
|
+
interface CreateUserTokenResponse {
|
|
2680
|
+
id: string;
|
|
2681
|
+
/** Full plaintext token — shown ONCE, never retrievable again. */
|
|
2682
|
+
key: string;
|
|
2683
|
+
label: string;
|
|
2684
|
+
scopes: string[];
|
|
2685
|
+
userId: string;
|
|
2686
|
+
tenantId: string;
|
|
2687
|
+
workspaceId: string;
|
|
2688
|
+
expiresAt: string | null;
|
|
2689
|
+
createdAt: string;
|
|
2690
|
+
}
|
|
2691
|
+
interface UserTokenListItem {
|
|
2692
|
+
id: string;
|
|
2693
|
+
label: string;
|
|
2694
|
+
scopes: string[];
|
|
2695
|
+
workspaceId: string;
|
|
2696
|
+
expiresAt: string | null;
|
|
2697
|
+
createdAt: string;
|
|
2698
|
+
lastUsedAt: string | null;
|
|
2699
|
+
revokedAt: string | null;
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
/**
|
|
2703
|
+
* Typed SDK for the Mnemosyne HTTP API.
|
|
2704
|
+
*
|
|
2705
|
+
* Designed as a drop-in alternative to importing `@mnemo-ai/core`
|
|
2706
|
+
* directly. Pick this when:
|
|
2707
|
+
* - You want to talk to a centralized memory server from many apps
|
|
2708
|
+
* (microservices, edge functions, CLI tools).
|
|
2709
|
+
* - You can't (or don't want to) install the core package and its
|
|
2710
|
+
* Drizzle / pg / pgvector graph in your runtime.
|
|
2711
|
+
* - You need a stable wire contract that survives memory-engine
|
|
2712
|
+
* internal refactors.
|
|
2713
|
+
*
|
|
2714
|
+
* Pick `@mnemo-ai/core` directly when:
|
|
2715
|
+
* - You want sub-millisecond in-process recall.
|
|
2716
|
+
* - You're already running a Postgres connection pool you'd rather
|
|
2717
|
+
* reuse than proxy through HTTP.
|
|
2718
|
+
*
|
|
2719
|
+
* @example
|
|
2720
|
+
* ```ts
|
|
2721
|
+
* import { MnemosyneClient } from "@mnemo-ai/client-ts";
|
|
2722
|
+
*
|
|
2723
|
+
* const memory = new MnemosyneClient({
|
|
2724
|
+
* url: "https://memory.example.com",
|
|
2725
|
+
* apiKey: process.env.MNEMO_KEY!,
|
|
2726
|
+
* });
|
|
2727
|
+
*
|
|
2728
|
+
* const { hits } = await memory.recall({ query: "user email preferences" });
|
|
2729
|
+
* ```
|
|
2730
|
+
*/
|
|
2731
|
+
declare class MnemosyneClient {
|
|
2732
|
+
private readonly http;
|
|
2733
|
+
constructor(options: MnemosyneClientOptions);
|
|
2734
|
+
/**
|
|
2735
|
+
* Return a NEW MnemosyneClient bound to a different `X-Workspace-Id`,
|
|
2736
|
+
* without mutating this instance or its config. Use this instead of
|
|
2737
|
+
* constructing a second client from scratch when you already hold one
|
|
2738
|
+
* (e.g. inside an MCP server process, where the client is long-lived
|
|
2739
|
+
* and shared across concurrent tool calls — each call that needs a
|
|
2740
|
+
* non-home workspace should clone, not mutate, the shared instance).
|
|
2741
|
+
*
|
|
2742
|
+
* Only meaningful with a `uk_live_*` user token; a plain workspace key
|
|
2743
|
+
* gets a 403 Forbidden from the server, not a silent ignore (`auth.ts`'s
|
|
2744
|
+
* `isUserKind` check).
|
|
2745
|
+
*/
|
|
2746
|
+
forWorkspace(workspaceId: string): MnemosyneClient;
|
|
2747
|
+
/**
|
|
2748
|
+
* Return a NEW MnemosyneClient that declares `observation` (request id,
|
|
2749
|
+
* caller, versions) as headers on every request. Like `forWorkspace()`, it
|
|
2750
|
+
* never mutates the shared instance, so concurrent callers (e.g. MCP tool
|
|
2751
|
+
* calls) cannot leak metadata into each other. The server records these as
|
|
2752
|
+
* declared, unverified fields; the actor always comes from the API key.
|
|
2753
|
+
*/
|
|
2754
|
+
withObservation(observation: RequestObservation): MnemosyneClient;
|
|
2755
|
+
/**
|
|
2756
|
+
* Return a NEW MnemosyneClient whose requests time out after `timeoutMs`,
|
|
2757
|
+
* for the one slow call (a session collapse runs an LLM pass) that should not
|
|
2758
|
+
* raise the budget of every other call. Never mutates the shared instance.
|
|
2759
|
+
*/
|
|
2760
|
+
withTimeout(timeoutMs: number): MnemosyneClient;
|
|
2761
|
+
/**
|
|
2762
|
+
* Recall facts relevant to a query.
|
|
2763
|
+
*
|
|
2764
|
+
* The server returns top-K hits ranked by a blended score
|
|
2765
|
+
* (`(tanh(A(t)) × 0.4 + cosine × 0.6) × worth`). Don't compare scores
|
|
2766
|
+
* across queries — they're only meaningful within a response.
|
|
2767
|
+
*
|
|
2768
|
+
* NOTE: `pinned` is NOT a scoring signal on this path. `POST /recall`
|
|
2769
|
+
* resolves to `recallCold()`, whose `viewFact()` projection never copies
|
|
2770
|
+
* `fact.pinned` onto the PrimitiveView the score formula reads — a pinned
|
|
2771
|
+
* fact and an otherwise identical unpinned fact rank IDENTICALLY. (The
|
|
2772
|
+
* `pin_bonus` column in the legacy `packages/core/src/recall/search.ts` is
|
|
2773
|
+
* real but backs `deps.core.recall`, not this route.) Proof:
|
|
2774
|
+
* `packages/core/src/cognitive/__tests__/recall-cold-pin-priority.test.ts`.
|
|
2775
|
+
*
|
|
2776
|
+
* Trade-off: we accept an optional pre-embedded `embedding` so the
|
|
2777
|
+
* caller can BYO embedder. Most callers should omit it and let the
|
|
2778
|
+
* server handle embedding — that's what keeps recall behavior
|
|
2779
|
+
* consistent across consumer apps.
|
|
2780
|
+
*/
|
|
2781
|
+
recall(input: RecallInput, signal?: AbortSignal): Promise<RecallResponse>;
|
|
2782
|
+
/**
|
|
2783
|
+
* P72 — move a fact to another workspace (POST /facts/:id/relocate).
|
|
2784
|
+
*
|
|
2785
|
+
* There is no "change the workspace_id" operation, and there should not be:
|
|
2786
|
+
* it would rewrite history and leave a hole in the audit trail. This closes
|
|
2787
|
+
* the fact where it was misfiled and creates a successor in the right place,
|
|
2788
|
+
* linked by `supersedes`, in one transaction.
|
|
2789
|
+
*
|
|
2790
|
+
* Rejects with 409 for confidential/restricted facts: their ciphertext is
|
|
2791
|
+
* bound to the source workspace's DEK and cannot cross the boundary.
|
|
2792
|
+
*/
|
|
2793
|
+
relocateFact(id: string, targetWorkspaceId: string, reason?: string, signal?: AbortSignal): Promise<{
|
|
2794
|
+
previousId: string;
|
|
2795
|
+
newId: string;
|
|
2796
|
+
}>;
|
|
2797
|
+
/**
|
|
2798
|
+
* Store a fact via the cognitive engine endpoint (POST /remember).
|
|
2799
|
+
* Supports scope/scopeRef for project-namespaced memory — use this instead
|
|
2800
|
+
* of createFact when you need to isolate facts by project or context.
|
|
2801
|
+
*/
|
|
2802
|
+
remember(input: RememberInput, signal?: AbortSignal, idempotencyKey?: string): Promise<RememberResponse>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Derive a deterministic `topicKey` from a subject/body pair without
|
|
2805
|
+
* writing anything (POST /topic-key/suggest). Pure and idempotent —
|
|
2806
|
+
* feeding the returned `topicKey` back in as `subject` (no `body`)
|
|
2807
|
+
* returns it unchanged. Use before `remember()`/`decide()` to get a
|
|
2808
|
+
* stable idempotency key instead of hand-rolling one.
|
|
2809
|
+
*/
|
|
2810
|
+
suggestTopicKey(input: SuggestTopicKeyInput, signal?: AbortSignal): Promise<SuggestTopicKeyResponse>;
|
|
2811
|
+
/**
|
|
2812
|
+
* Compare two facts by id (POST /facts/compare): field differences,
|
|
2813
|
+
* a same-subject judgment, and a suggested relation verb. Server-owned
|
|
2814
|
+
* relocation of what `memory_compare` used to compute locally
|
|
2815
|
+
* (docs/archive/openspec/decompose-recall-and-compare) — either id missing or above
|
|
2816
|
+
* the caller's sensitivity ceiling resolves to a 404 `MnemosyneAPIError`.
|
|
2817
|
+
*/
|
|
2818
|
+
compareFacts(input: CompareFactsInput, signal?: AbortSignal): Promise<CompareFactsResponse>;
|
|
2819
|
+
/**
|
|
2820
|
+
* Persist a new fact.
|
|
2821
|
+
*
|
|
2822
|
+
* `POST /facts` was deleted (flatten-legacy-dual-core D2 step 2) — this
|
|
2823
|
+
* now calls `POST /remember` under the hood, a lossless body remap
|
|
2824
|
+
* (`/remember` already accepts `tags` + `attribution`):
|
|
2825
|
+
* `{ content, attribution, tags }` -> `{ statement: content, attribution, tags }`.
|
|
2826
|
+
* The response is remapped back (`statement` -> `content`) so this
|
|
2827
|
+
* method's name, input shape, and output shape stay the same — the wire
|
|
2828
|
+
* route is the breaking part, not this SDK surface. See
|
|
2829
|
+
* {@link CreateFactInput}/{@link CreateFactResponse}.
|
|
2830
|
+
*/
|
|
2831
|
+
createFact(input: CreateFactInput, signal?: AbortSignal, idempotencyKey?: string): Promise<CreateFactResponse>;
|
|
2832
|
+
/**
|
|
2833
|
+
* Fetch one fact by id. Returns 404 → MnemosyneAPIError if not found.
|
|
2834
|
+
* `includeClosed` returns a closed fact instead of 404; `provenance` adds
|
|
2835
|
+
* `sessionId`, `supersededById`, `supersededAt` and `supersedesIds`.
|
|
2836
|
+
*/
|
|
2837
|
+
getFact(id: string, signal?: AbortSignal, opts?: {
|
|
2838
|
+
includeClosed?: boolean;
|
|
2839
|
+
provenance?: boolean;
|
|
2840
|
+
}): Promise<Fact>;
|
|
2841
|
+
/**
|
|
2842
|
+
* Pin a fact — protects it from automated prune/forget and gives it
|
|
2843
|
+
* a recall boost. Use for canonical, never-forget knowledge.
|
|
2844
|
+
*
|
|
2845
|
+
* The server models pin/unpin as a single route that takes a boolean
|
|
2846
|
+
* flag (POST /facts/:id/pin with `{ pinned }`) rather than two
|
|
2847
|
+
* verbs, so we send `{ pinned: true }`.
|
|
2848
|
+
*/
|
|
2849
|
+
pinFact(id: string, signal?: AbortSignal, idempotencyKey?: string): Promise<PinResponse>;
|
|
2850
|
+
/** Inverse of {@link pinFact} — same route, `{ pinned: false }`. */
|
|
2851
|
+
unpinFact(id: string, signal?: AbortSignal, idempotencyKey?: string): Promise<PinResponse>;
|
|
2852
|
+
/**
|
|
2853
|
+
* Forget a fact. This is the server's bitemporal soft-delete:
|
|
2854
|
+
* DELETE /facts/:id sets `valid_to = now` rather than hard-deleting,
|
|
2855
|
+
* so the fact stays auditable/recoverable. Returns 204 No Content, so
|
|
2856
|
+
* this resolves to `void`.
|
|
2857
|
+
*/
|
|
2858
|
+
forgetFact(id: string, signal?: AbortSignal, idempotencyKey?: string, reason?: string): Promise<ForgetResponse>;
|
|
2859
|
+
/**
|
|
2860
|
+
* P18 — Soft-delete (archive) any cognitive primitive by kind and id.
|
|
2861
|
+
* Maps to `DELETE /forget/:kind/:id`.
|
|
2862
|
+
* Supports idempotency keys for every kind (§34.9) — for facts,
|
|
2863
|
+
* {@link forgetFact} remains the preferred backward-compat path.
|
|
2864
|
+
* A repeat on an already-forgotten row succeeds with `alreadyForgotten: true`.
|
|
2865
|
+
*/
|
|
2866
|
+
forgetPrimitive(kind: "fact" | "decision" | "episode" | "entity" | "strategy" | "workflow" | "skill" | "task" | "event" | "reasoning" | "hyperedge", id: string, signal?: AbortSignal, reason?: string, idempotencyKey?: string): Promise<{
|
|
2867
|
+
forgotten: boolean;
|
|
2868
|
+
alreadyForgotten?: boolean;
|
|
2869
|
+
}>;
|
|
2870
|
+
/**
|
|
2871
|
+
* Recent fact-lifecycle events for the workspace (created / pinned /
|
|
2872
|
+
* unpinned / closed / updated), newest-first. Useful for diff views
|
|
2873
|
+
* ("what did my AI learn this week?") and the Mnemosyne Studio
|
|
2874
|
+
* inspector. Paginate with `nextCursor` via the `since` param.
|
|
2875
|
+
*/
|
|
2876
|
+
timeline(input?: TimelineInput, signal?: AbortSignal): Promise<TimelineResponse>;
|
|
2877
|
+
/**
|
|
2878
|
+
* Liveness + readiness snapshot. Returns more than a binary "ok"
|
|
2879
|
+
* so operators can wire it into existing dashboards (db / embedder /
|
|
2880
|
+
* queue sub-components are surfaced individually when degraded).
|
|
2881
|
+
*/
|
|
2882
|
+
health(signal?: AbortSignal): Promise<HealthSnapshot>;
|
|
2883
|
+
/**
|
|
2884
|
+
* Readiness probe with real per-dependency (postgres/vector/cache)
|
|
2885
|
+
* status. Unauthenticated + instance-wide server-side, unlike `health()`
|
|
2886
|
+
* above which is workspace-scoped vitals. Maps to `GET /health/ready`.
|
|
2887
|
+
*/
|
|
2888
|
+
healthReady(signal?: AbortSignal): Promise<HealthReadySnapshot>;
|
|
2889
|
+
/**
|
|
2890
|
+
* Generic request escape hatch for un-wrapped or dynamic routes.
|
|
2891
|
+
*/
|
|
2892
|
+
request<T>(opts: {
|
|
2893
|
+
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
2894
|
+
path: string;
|
|
2895
|
+
body?: unknown;
|
|
2896
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
2897
|
+
signal?: AbortSignal;
|
|
2898
|
+
}): Promise<T>;
|
|
2899
|
+
/**
|
|
2900
|
+
* Introspect the current API key — returns workspace, user, tenant,
|
|
2901
|
+
* scopes, plan, workspace role, and effective (role-narrowed) scopes.
|
|
2902
|
+
* Maps to `GET /me`.
|
|
2903
|
+
*/
|
|
2904
|
+
getMe(signal?: AbortSignal): Promise<MeResponse>;
|
|
2905
|
+
/**
|
|
2906
|
+
* List workspaces available in the current tenant.
|
|
2907
|
+
* Maps to `GET /tenants/:tenantId/workspaces`.
|
|
2908
|
+
* Returns empty array when the key has no tenant binding (there is
|
|
2909
|
+
* genuinely nothing to list) — this is the one case that stays a
|
|
2910
|
+
* silent `[]` rather than a thrown error, since "no tenant bound" is
|
|
2911
|
+
* a normal, expected key shape (a plain workspace key), not a failure.
|
|
2912
|
+
*/
|
|
2913
|
+
listWorkspacesForCurrentTenant(signal?: AbortSignal): Promise<WorkspaceListItem[]>;
|
|
2914
|
+
/**
|
|
2915
|
+
* List workspaces the active user belongs to, with the caller's role
|
|
2916
|
+
* in each. Maps to `GET /workspaces/mine`.
|
|
2917
|
+
*
|
|
2918
|
+
* Throws `MnemosyneAPIError` on a real failure (403/500/etc) — this
|
|
2919
|
+
* used to silently swallow every error to `[]`, which is why the CLI
|
|
2920
|
+
* grew its own raw-fetch bypass instead of trusting this method (see
|
|
2921
|
+
* CLI-PARITY-1 follow-up, L1). A 404 ("no user associated with this
|
|
2922
|
+
* key") is the one genuinely-empty case and still resolves to `[]`.
|
|
2923
|
+
*/
|
|
2924
|
+
listMyWorkspaces(signal?: AbortSignal): Promise<WorkspaceListItemWithRole[]>;
|
|
2925
|
+
/**
|
|
2926
|
+
* List members of a workspace, with each member's role.
|
|
2927
|
+
* Maps to `GET /workspaces/:workspaceId/members`.
|
|
2928
|
+
*
|
|
2929
|
+
* Throws `MnemosyneAPIError` on a real failure — see {@link listMyWorkspaces}'s
|
|
2930
|
+
* doc for why this no longer swallows errors to `[]`.
|
|
2931
|
+
*/
|
|
2932
|
+
listWorkspaceMembers(workspaceId: string, signal?: AbortSignal): Promise<WorkspaceMember[]>;
|
|
2933
|
+
/**
|
|
2934
|
+
* Get a single workspace by id. Membership required — the server
|
|
2935
|
+
* returns 404 (not 403) for a non-member, per the anti-probing
|
|
2936
|
+
* invariant (CLAUDE.md S6), so this throws `MnemosyneAPIError` with
|
|
2937
|
+
* status 404 in that case too, indistinguishable from "doesn't exist".
|
|
2938
|
+
* Maps to `GET /workspaces/:workspaceId`.
|
|
2939
|
+
*/
|
|
2940
|
+
getWorkspaceById(workspaceId: string, signal?: AbortSignal): Promise<Workspace>;
|
|
2941
|
+
/**
|
|
2942
|
+
* Create a workspace inside a tenant. Requires `memory:admin` (tenant
|
|
2943
|
+
* owner/admin, or a workspace-role-narrowed admin — see security.ts's
|
|
2944
|
+
* `WORKSPACE_ROLE_SCOPES`). Maps to `POST /tenants/:tenantId/workspaces`.
|
|
2945
|
+
*/
|
|
2946
|
+
createWorkspace(tenantId: string, input: CreateWorkspaceInput, signal?: AbortSignal): Promise<Workspace>;
|
|
2947
|
+
/**
|
|
2948
|
+
* Add a user as a member of a workspace with a given role (default
|
|
2949
|
+
* `read`). The invited user must already belong to the workspace's
|
|
2950
|
+
* tenant (403 otherwise — this is same-tenant enforcement, distinct
|
|
2951
|
+
* from the anti-probing 404 elsewhere in this route family).
|
|
2952
|
+
* Maps to `POST /workspaces/:workspaceId/members`.
|
|
2953
|
+
*/
|
|
2954
|
+
inviteWorkspaceMember(workspaceId: string, input: InviteWorkspaceMemberInput, signal?: AbortSignal): Promise<{
|
|
2955
|
+
ok: boolean;
|
|
2956
|
+
}>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Remove a user from a workspace. Requires workspace owner/admin.
|
|
2959
|
+
* Maps to `DELETE /workspaces/:workspaceId/members/:userId`.
|
|
2960
|
+
*/
|
|
2961
|
+
removeWorkspaceMember(workspaceId: string, userId: string, signal?: AbortSignal): Promise<{
|
|
2962
|
+
ok: boolean;
|
|
2963
|
+
}>;
|
|
2964
|
+
/**
|
|
2965
|
+
* Change a workspace member's role. Requires workspace owner/admin.
|
|
2966
|
+
* Maps to `PATCH /workspaces/:workspaceId/members/:userId`.
|
|
2967
|
+
*/
|
|
2968
|
+
updateWorkspaceMemberRole(workspaceId: string, userId: string, role: WorkspaceRole, signal?: AbortSignal): Promise<{
|
|
2969
|
+
ok: boolean;
|
|
2970
|
+
}>;
|
|
2971
|
+
/**
|
|
2972
|
+
* List workspaces in a tenant by EXPLICIT id — for an operator managing a
|
|
2973
|
+
* tenant that isn't necessarily their own key's home tenant (e.g. the CLI's
|
|
2974
|
+
* `mnemo tenant workspaces <tenantId>`). Requires `admin:tenant` on that
|
|
2975
|
+
* tenant. See {@link listWorkspacesForCurrentTenant} for the "my own
|
|
2976
|
+
* tenant, derived from GET /me" convenience wrapper.
|
|
2977
|
+
* Maps to `GET /tenants/:tenantId/workspaces`.
|
|
2978
|
+
*/
|
|
2979
|
+
listWorkspacesForTenant(tenantId: string, signal?: AbortSignal): Promise<WorkspaceListItem[]>;
|
|
2980
|
+
/**
|
|
2981
|
+
* Create a new tenant (an organization, typically). Requires
|
|
2982
|
+
* `admin:tenant`. Maps to `POST /tenants`.
|
|
2983
|
+
*/
|
|
2984
|
+
createTenant(input: CreateTenantInput, signal?: AbortSignal): Promise<CreateTenantResponse>;
|
|
2985
|
+
/**
|
|
2986
|
+
* Get tenant info by id. Cross-tenant access (key bound to a
|
|
2987
|
+
* different tenant) throws `MnemosyneAPIError` (403).
|
|
2988
|
+
* Maps to `GET /tenants/:tenantId`.
|
|
2989
|
+
*/
|
|
2990
|
+
getTenant(tenantId: string, signal?: AbortSignal): Promise<Tenant>;
|
|
2991
|
+
/**
|
|
2992
|
+
* List members of a tenant, with each member's tenant-plane role.
|
|
2993
|
+
* Maps to `GET /tenants/:tenantId/members`.
|
|
2994
|
+
*/
|
|
2995
|
+
listTenantMembers(tenantId: string, signal?: AbortSignal): Promise<TenantMember[]>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Invite a user (by email) to a tenant. Requires the caller to be a
|
|
2998
|
+
* tenant owner/admin. Pass `createIfMissing: true` to auto-provision
|
|
2999
|
+
* an account (+ personal tenant + personal workspace) for an email
|
|
3000
|
+
* that has never used Mnemosyne, in the same call.
|
|
3001
|
+
* Maps to `POST /tenants/:tenantId/members`.
|
|
3002
|
+
*/
|
|
3003
|
+
inviteTenantMember(tenantId: string, input: InviteTenantMemberInput, signal?: AbortSignal): Promise<{
|
|
3004
|
+
ok: boolean;
|
|
3005
|
+
}>;
|
|
3006
|
+
/**
|
|
3007
|
+
* Remove a user from a tenant. Requires the caller to be a tenant
|
|
3008
|
+
* owner/admin. Maps to `DELETE /tenants/:tenantId/members/:userId`.
|
|
3009
|
+
*/
|
|
3010
|
+
removeTenantMember(tenantId: string, userId: string, signal?: AbortSignal): Promise<{
|
|
3011
|
+
ok: boolean;
|
|
3012
|
+
}>;
|
|
3013
|
+
/**
|
|
3014
|
+
* Create a user (auto-creates their personal tenant + personal
|
|
3015
|
+
* workspace). Maps to `POST /users`. 400s if the email is already
|
|
3016
|
+
* registered.
|
|
3017
|
+
*/
|
|
3018
|
+
createUser(input: CreateUserInput, signal?: AbortSignal): Promise<CreateUserResponse>;
|
|
3019
|
+
/**
|
|
3020
|
+
* Mint a `uk_live_*` user token for ANOTHER member of a tenant (not the
|
|
3021
|
+
* caller). Requires the caller to be a tenant owner/admin. The target
|
|
3022
|
+
* user must already be a member of `input.homeWorkspaceId`, and
|
|
3023
|
+
* `input.scopes` (if given) must be a subset of the CALLER's own
|
|
3024
|
+
* scopes — a tenant admin can never mint a token more powerful than
|
|
3025
|
+
* themselves. The plaintext key is returned ONCE, in this response only.
|
|
3026
|
+
* Maps to `POST /tenants/:tenantId/users/:userId/tokens`.
|
|
3027
|
+
*/
|
|
3028
|
+
createUserToken(tenantId: string, userId: string, input: CreateUserTokenInput, signal?: AbortSignal): Promise<CreateUserTokenResponse>;
|
|
3029
|
+
/**
|
|
3030
|
+
* List a tenant member's user tokens (secrets masked — never
|
|
3031
|
+
* retrievable after creation). Requires the caller to be a tenant
|
|
3032
|
+
* owner/admin. Maps to `GET /tenants/:tenantId/users/:userId/tokens`.
|
|
3033
|
+
*/
|
|
3034
|
+
listUserTokens(tenantId: string, userId: string, signal?: AbortSignal): Promise<UserTokenListItem[]>;
|
|
3035
|
+
/**
|
|
3036
|
+
* Revoke a user token. Requires the caller to be a tenant owner/admin.
|
|
3037
|
+
* Maps to `DELETE /tenants/:tenantId/users/:userId/tokens/:keyId`.
|
|
3038
|
+
*/
|
|
3039
|
+
revokeUserToken(tenantId: string, userId: string, keyId: string, signal?: AbortSignal): Promise<{
|
|
3040
|
+
ok: boolean;
|
|
3041
|
+
revokedAt: string;
|
|
3042
|
+
}>;
|
|
3043
|
+
/**
|
|
3044
|
+
* Run the 6 server-side operational diagnostic checks (connectivity,
|
|
3045
|
+
* app_user_grants, schema_shadows, migration_version, embedding_backlog,
|
|
3046
|
+
* workspace_id_valid) and return a structured `DoctorReport`.
|
|
3047
|
+
*
|
|
3048
|
+
* The `memory_doctor` MCP tool calls this and appends 2 additional
|
|
3049
|
+
* client-side checks (env_config, mcp_tools) before returning the merged
|
|
3050
|
+
* report to the LLM caller.
|
|
3051
|
+
*
|
|
3052
|
+
* Maps to `GET /doctor`.
|
|
3053
|
+
*/
|
|
3054
|
+
doctor(signal?: AbortSignal): Promise<DoctorReport>;
|
|
3055
|
+
/**
|
|
3056
|
+
* Aggregate workspace statistics: fact counts (live / closed / pinned /
|
|
3057
|
+
* archived / zero-hits), decision count, conflict relations, embedding
|
|
3058
|
+
* coverage, recall hit rate, and last activity timestamps.
|
|
3059
|
+
*
|
|
3060
|
+
* Delegates to `GET /admin/stats` on the Mnemosyne server.
|
|
3061
|
+
* No parameters — all stats are scoped to the authenticated workspace
|
|
3062
|
+
* by RLS.
|
|
3063
|
+
*/
|
|
3064
|
+
getStats(signal?: AbortSignal): Promise<AdminStats>;
|
|
3065
|
+
/**
|
|
3066
|
+
* Memory Graph snapshot. With no input, returns the workspace's full
|
|
3067
|
+
* canonical graph (entities + episodes + decisions, plus typed
|
|
3068
|
+
* relations between them). When `focus` is supplied (an entity id: a
|
|
3069
|
+
* UUID, or a legacy `ment_<slug>` seed id), returns only that entity and its 1-hop neighbourhood
|
|
3070
|
+
* — cheaper to compute and much cheaper to render.
|
|
3071
|
+
*
|
|
3072
|
+
* The server caches with `Cache-Control: private, max-age=30`, so
|
|
3073
|
+
* repeated calls within that window are short-circuited by any
|
|
3074
|
+
* standards-conformant fetch implementation.
|
|
3075
|
+
*/
|
|
3076
|
+
graph(input?: GraphInput, signal?: AbortSignal): Promise<GraphResponse>;
|
|
3077
|
+
/**
|
|
3078
|
+
* Multi-hop BFS traversal over `mnemo_relation` starting from a root entity.
|
|
3079
|
+
* Returns reachable nodes with their minimum hop distance and a relevance
|
|
3080
|
+
* score (decay^hop). Supports optional verb filtering and bitemporal as-of
|
|
3081
|
+
* reconstruction.
|
|
3082
|
+
*
|
|
3083
|
+
* Maps to `GET /graph/traverse`.
|
|
3084
|
+
*/
|
|
3085
|
+
graphTraverse(input: GraphTraverseInput, signal?: AbortSignal): Promise<{
|
|
3086
|
+
hits: TraverseHit[];
|
|
3087
|
+
}>;
|
|
3088
|
+
/**
|
|
3089
|
+
* Low-level BFS relation edge traversal from a root node over `mnemo_relation`.
|
|
3090
|
+
* Returns reachable nodes and raw edge objects.
|
|
3091
|
+
*
|
|
3092
|
+
* Maps to `POST /relations/traverse`.
|
|
3093
|
+
*/
|
|
3094
|
+
relationsTraverse(input: TraverseRelationsInput, signal?: AbortSignal): Promise<TraverseRelationsResponse>;
|
|
3095
|
+
/**
|
|
3096
|
+
* Shortest path between two nodes over `mnemo_relation` via a recursive
|
|
3097
|
+
* CTE with cycle detection. Returns the node id chain from `from` to `to`
|
|
3098
|
+
* and the relation verbs traversed at each step. Returns an empty path
|
|
3099
|
+
* when the nodes are unreachable within `maxHops`.
|
|
3100
|
+
*
|
|
3101
|
+
* Maps to `GET /graph/path`.
|
|
3102
|
+
*/
|
|
3103
|
+
graphPath(input: GraphPathInput, signal?: AbortSignal): Promise<GraphPathResponse>;
|
|
3104
|
+
/**
|
|
3105
|
+
* List entities in the workspace (Mnemosyne v1.6 G2 entity browser).
|
|
3106
|
+
* Filters by `kind` (one of 6 enum values) and/or `q` (case-insensitive
|
|
3107
|
+
* substring across name + aliases). Server-cap on `limit` is 200.
|
|
3108
|
+
*
|
|
3109
|
+
* Sorted newest-mentioned first (most likely interesting for the
|
|
3110
|
+
* inspector header).
|
|
3111
|
+
*/
|
|
3112
|
+
listEntities(input?: ListEntitiesInput, signal?: AbortSignal): Promise<ListEntitiesResponse>;
|
|
3113
|
+
/**
|
|
3114
|
+
* Fetch a single entity by id plus its active-fact count. The count
|
|
3115
|
+
* powers the inspector header chip ("12 linked facts") without
|
|
3116
|
+
* forcing a second round-trip. Throws {@link MnemosyneAPIError} (404)
|
|
3117
|
+
* when the entity doesn't exist in this workspace.
|
|
3118
|
+
*/
|
|
3119
|
+
getEntity(id: string, signal?: AbortSignal): Promise<EntityWithCount>;
|
|
3120
|
+
/**
|
|
3121
|
+
* List the facts the extraction pipeline linked to a given entity
|
|
3122
|
+
* (via `mnemo_fact.entity_id`). Active facts only — forgotten/merged
|
|
3123
|
+
* stay hidden from the entity-detail view. Server-cap on `limit` is
|
|
3124
|
+
* 500. Throws 404 when the entity itself doesn't exist.
|
|
3125
|
+
*/
|
|
3126
|
+
listEntityFacts(id: string, input?: ListEntityFactsInput, signal?: AbortSignal): Promise<EntityFactsResponse>;
|
|
3127
|
+
/**
|
|
3128
|
+
* List episodes in a date window (Mnemosyne v1.4 timeline). When
|
|
3129
|
+
* `from`/`to` are omitted the server defaults to the last 30 days —
|
|
3130
|
+
* the inspector rarely cares about older slices unless explicitly
|
|
3131
|
+
* requested. `topic` filters via the GIN-indexed `topics` array
|
|
3132
|
+
* (single-topic only by design). Server-cap on `limit` is 200.
|
|
3133
|
+
*
|
|
3134
|
+
* `includeSynthetic` defaults to false — extractor-synthesised
|
|
3135
|
+
* episodes are hidden from the inspector view but visible to operator
|
|
3136
|
+
* tools that opt in.
|
|
3137
|
+
*/
|
|
3138
|
+
listEpisodes(input?: ListEpisodesInput, signal?: AbortSignal): Promise<ListEpisodesResponse>;
|
|
3139
|
+
/**
|
|
3140
|
+
* Fetch a single episode plus its linked facts. Linked facts that
|
|
3141
|
+
* have since been archived are silently filtered out (an episode
|
|
3142
|
+
* legitimately outlives some of its constituent facts). Throws 404
|
|
3143
|
+
* when the episode itself doesn't exist.
|
|
3144
|
+
*/
|
|
3145
|
+
getEpisode(id: string, signal?: AbortSignal): Promise<EpisodeWithLinkedFacts>;
|
|
3146
|
+
/**
|
|
3147
|
+
* Chronological timeline for one episode: its creation plus every fact
|
|
3148
|
+
* linked to it, in `occurredAt` order.
|
|
3149
|
+
*
|
|
3150
|
+
* Maps to `GET /episodes/:id/timeline`.
|
|
3151
|
+
*/
|
|
3152
|
+
getEpisodeTimeline(id: string, signal?: AbortSignal): Promise<EpisodeTimelineResponse>;
|
|
3153
|
+
/**
|
|
3154
|
+
* Manual entity create. The extraction pipeline auto-creates via
|
|
3155
|
+
* `findOrCreate`; this method exists so an operator can bootstrap
|
|
3156
|
+
* the entity table before any conversation has happened or
|
|
3157
|
+
* backfill an out-of-band mention.
|
|
3158
|
+
*
|
|
3159
|
+
* The server enforces a `(workspace_id, name, kind)` unique
|
|
3160
|
+
* constraint — a duplicate surfaces as a {@link MnemosyneAPIError}
|
|
3161
|
+
* with status 409.
|
|
3162
|
+
*/
|
|
3163
|
+
createEntity(input: CreateEntityInput, signal?: AbortSignal, idempotencyKey?: string): Promise<MnemoEntity>;
|
|
3164
|
+
/**
|
|
3165
|
+
* Patch an existing entity (rename / alias edits / kind change /
|
|
3166
|
+
* canonical merge). An empty patch (every key undefined) gets
|
|
3167
|
+
* 400; canonicalId targets that don't exist (or equal the row
|
|
3168
|
+
* being patched) get 400. 404 when the row itself doesn't exist.
|
|
3169
|
+
*/
|
|
3170
|
+
updateEntity(id: string, input: UpdateEntityInput, signal?: AbortSignal): Promise<MnemoEntity>;
|
|
3171
|
+
/**
|
|
3172
|
+
* Link a 'person' entity to a real platform account (`linkedUserId`).
|
|
3173
|
+
* Self-link (your own userId) is always allowed. Linking a DIFFERENT
|
|
3174
|
+
* user — or reassigning an entity already linked to someone else —
|
|
3175
|
+
* requires the caller to hold `memory:admin` AND an owner/admin role in
|
|
3176
|
+
* this workspace; reassignment closes the old link and creates a new
|
|
3177
|
+
* successor row linked via a `supersedes` relation rather than
|
|
3178
|
+
* overwriting it in place, so the prior link is preserved for audit.
|
|
3179
|
+
* 400 when the entity's `kind` isn't `'person'`. 404 when the entity
|
|
3180
|
+
* doesn't exist, the caller's sensitivity ceiling can't read it
|
|
3181
|
+
* (anti-probing — same response as nonexistent), or the target user
|
|
3182
|
+
* isn't a member of this workspace.
|
|
3183
|
+
*/
|
|
3184
|
+
linkEntityUser(id: string, input: LinkEntityUserInput, signal?: AbortSignal): Promise<MnemoEntity>;
|
|
3185
|
+
/**
|
|
3186
|
+
* Unlink a 'person' entity from its linked platform account. Bitemporal:
|
|
3187
|
+
* closes the linked row and creates an unlinked successor (never blanks
|
|
3188
|
+
* `linkedUserId` in place), mirroring this API's `forget()` convention.
|
|
3189
|
+
* Same self-or-admin+role permission as {@link linkEntityUser}. 404 when
|
|
3190
|
+
* the entity doesn't exist or isn't currently linked.
|
|
3191
|
+
*/
|
|
3192
|
+
unlinkEntityUser(id: string, signal?: AbortSignal): Promise<MnemoEntity>;
|
|
3193
|
+
/**
|
|
3194
|
+
* List active-learning queue rows (Mnemosyne v1.3+). Defaults to
|
|
3195
|
+
* unresolved only — pass `all:true` to include resolved rows for
|
|
3196
|
+
* the full history. Editor-tier surface; the queue is an
|
|
3197
|
+
* operational concern.
|
|
3198
|
+
*/
|
|
3199
|
+
listReview(input?: ListReviewInput, signal?: AbortSignal): Promise<ListReviewResponse>;
|
|
3200
|
+
/**
|
|
3201
|
+
* Cheap COUNT(*) of unresolved queue rows. Powers the inspector
|
|
3202
|
+
* header badge ("12 to review") — uses the partial index
|
|
3203
|
+
* `idx_mnemo_review_queue_workspace_unresolved` so it's
|
|
3204
|
+
* constant-time at queue depths the inspector cares about.
|
|
3205
|
+
*/
|
|
3206
|
+
reviewCount(signal?: AbortSignal): Promise<ReviewCountResponse>;
|
|
3207
|
+
/**
|
|
3208
|
+
* Close a queue row. When `resolution='forgotten'` AND the row is
|
|
3209
|
+
* fact-sourced, the server atomically cascades the fact's status
|
|
3210
|
+
* to 'forgotten' in the same tx so the fact leaves the recall pool
|
|
3211
|
+
* without a follow-up round-trip. The response's `cascaded` field
|
|
3212
|
+
* confirms this happened.
|
|
3213
|
+
*
|
|
3214
|
+
* Throws 404 if the row doesn't exist; 409 if it was already
|
|
3215
|
+
* resolved (idempotent re-resolve is intentionally NOT silent so
|
|
3216
|
+
* the caller can decide whether to retry or surface a warning).
|
|
3217
|
+
*/
|
|
3218
|
+
resolveReview(id: string, input: ResolveReviewInput, signal?: AbortSignal): Promise<ResolveReviewResponse>;
|
|
3219
|
+
/**
|
|
3220
|
+
* "Undo log" feed — most recent fact-mutation events. Synthesised
|
|
3221
|
+
* from two sources: user-driven Forget (revertible via
|
|
3222
|
+
* {@link restoreFact}) and janitor-driven archive (not revertible).
|
|
3223
|
+
* Newest first. Powers the inspector's undo surface.
|
|
3224
|
+
*/
|
|
3225
|
+
audit(input?: AuditInput, signal?: AbortSignal): Promise<AuditResponse>;
|
|
3226
|
+
/**
|
|
3227
|
+
* Full workspace memory dump (admin-tier surface). Returns the four
|
|
3228
|
+
* mnemo_* tables (facts, decisions, relations, citations) in a
|
|
3229
|
+
* single buffered JSON payload. Embeddings are excluded.
|
|
3230
|
+
*
|
|
3231
|
+
* v1.3 caps at 100k rows per resource. Large workspaces should
|
|
3232
|
+
* wait for the v1.4 streaming endpoint rather than chunk by hand.
|
|
3233
|
+
*/
|
|
3234
|
+
exportWorkspace(signal?: AbortSignal): Promise<ExportResponse>;
|
|
3235
|
+
/**
|
|
3236
|
+
* Restore a forgotten fact — flips `status` back to 'active' so the
|
|
3237
|
+
* fact rejoins the recall pool. Companion to {@link forgetFact}.
|
|
3238
|
+
* Returns the minimal `{id, status}` pair; chain {@link getFact}
|
|
3239
|
+
* if you need the full body.
|
|
3240
|
+
*
|
|
3241
|
+
* 404 when the fact doesn't exist (or RLS hides it).
|
|
3242
|
+
*/
|
|
3243
|
+
restoreFact(id: string, signal?: AbortSignal): Promise<RestoreFactResponse>;
|
|
3244
|
+
/**
|
|
3245
|
+
* List decisions in the workspace (Mnemosyne v1.5). Decisions are
|
|
3246
|
+
* durable, audited statements of "we are going to do X because Y"
|
|
3247
|
+
* — distinct from facts (transient observations). Newest first.
|
|
3248
|
+
*/
|
|
3249
|
+
listDecisions(input?: ListDecisionsInput, signal?: AbortSignal): Promise<ListDecisionsResponse>;
|
|
3250
|
+
/**
|
|
3251
|
+
* Fetch a single decision by id. Throws 404 if it doesn't exist.
|
|
3252
|
+
*
|
|
3253
|
+
* Note: orchester's `/api/mnemo/decisions/[traceId]` route is the
|
|
3254
|
+
* Decision BOM (Bill-of-Materials) endpoint, which joins mnemo
|
|
3255
|
+
* decision data with orchester's audit_log table — this method
|
|
3256
|
+
* returns ONLY the mnemo decision row, not the BOM composition.
|
|
3257
|
+
*
|
|
3258
|
+
* `includeClosed` asks for a superseded or withdrawn decision the way
|
|
3259
|
+
* {@link getFact} asks for a closed fact.
|
|
3260
|
+
*/
|
|
3261
|
+
getDecision(id: string, signal?: AbortSignal, opts?: {
|
|
3262
|
+
includeClosed?: boolean;
|
|
3263
|
+
}): Promise<MnemoDecision>;
|
|
3264
|
+
/**
|
|
3265
|
+
* Paginated fact list (rich projection — subject/statement/kind, not
|
|
3266
|
+
* the simplified content shape `/facts/:id` returns).
|
|
3267
|
+
*
|
|
3268
|
+
* Tramo 5 surface:
|
|
3269
|
+
* - Filters: kind, scope, scopeRef, status, pinned, asOf (bitemporal).
|
|
3270
|
+
* - Search: `q` runs `plainto_tsquery` on the lemmatized column with
|
|
3271
|
+
* an ILIKE fallback for facts whose lemma column is null.
|
|
3272
|
+
* - Sort: `sortBy` ∈ {created_at, updated_at, relevance, hit_count},
|
|
3273
|
+
* `order` ∈ {asc, desc}. Tied rows are broken by id.
|
|
3274
|
+
* - Pagination: pass back the previous response's `nextCursor` to
|
|
3275
|
+
* keyset-paginate. Cursors are opaque — do not parse them.
|
|
3276
|
+
*
|
|
3277
|
+
* Response envelope `{ items, nextCursor, total }`. `total` is the
|
|
3278
|
+
* COUNT(*) for the filter set (sans cursor) so an inspector header
|
|
3279
|
+
* can render "X of Y" without a separate request.
|
|
3280
|
+
*/
|
|
3281
|
+
listFacts(input?: ListFactsInput, signal?: AbortSignal): Promise<ListFactsResponse>;
|
|
3282
|
+
/**
|
|
3283
|
+
* Patch a fact's editable columns (subject/statement/kind/pinned/
|
|
3284
|
+
* confidence/relevance/metadata). An empty patch (every field
|
|
3285
|
+
* undefined) returns 400; 404 when the row doesn't exist.
|
|
3286
|
+
*
|
|
3287
|
+
* Bitemporal note: PATCH does NOT close the interval — `validFrom`
|
|
3288
|
+
* stays put, `validTo` stays null. Use {@link forgetFact} to mark
|
|
3289
|
+
* the fact as no-longer-valid at a point in time.
|
|
3290
|
+
*/
|
|
3291
|
+
patchFact(id: string, input: PatchFactInput, signal?: AbortSignal): Promise<MemoryFact>;
|
|
3292
|
+
/**
|
|
3293
|
+
* Source-message ids for a fact. Returns just the id list —
|
|
3294
|
+
* Mnemosyne doesn't own the message table that orchester joins
|
|
3295
|
+
* against, so hosts wanting `{role, content, timestamp}` per message
|
|
3296
|
+
* do that join on their side.
|
|
3297
|
+
*/
|
|
3298
|
+
getFactCitations(id: string, signal?: AbortSignal): Promise<FactCitationsResponse>;
|
|
3299
|
+
/**
|
|
3300
|
+
* Create a decision (Mnemosyne v1.5). Topic-key upsert + normalized-
|
|
3301
|
+
* hash dedup happen server-side — re-creating a decision with the
|
|
3302
|
+
* same (workspace_id, topic_key) returns the existing row (201
|
|
3303
|
+
* status either way; the client cannot distinguish first-create
|
|
3304
|
+
* from upsert without comparing the returned id).
|
|
3305
|
+
*/
|
|
3306
|
+
createDecision(input: CreateDecisionInput, signal?: AbortSignal, idempotencyKey?: string): Promise<MnemoDecision>;
|
|
3307
|
+
/**
|
|
3308
|
+
* Supersede a decision: marks `id` as status='superseded' and
|
|
3309
|
+
* points its supersededById at `input.supersededById`. Returns
|
|
3310
|
+
* the updated decision. Caller is responsible for the matching
|
|
3311
|
+
* `supersedes` relation row (via {@link createRelation}).
|
|
3312
|
+
*/
|
|
3313
|
+
supersedeDecision(id: string, input: SupersedeDecisionInput, signal?: AbortSignal): Promise<MnemoDecision>;
|
|
3314
|
+
/**
|
|
3315
|
+
* List relations in the workspace (Mnemosyne v1.0 — LOCKED 9-verb
|
|
3316
|
+
* vocabulary). Filter by `judgmentStatus`: typical inspector use is
|
|
3317
|
+
* `judgmentStatus: 'pending'` for the judge queue.
|
|
3318
|
+
*/
|
|
3319
|
+
listRelations(input?: ListRelationsInput, signal?: AbortSignal): Promise<ListRelationsResponse>;
|
|
3320
|
+
/**
|
|
3321
|
+
* Create a relation between two memory primitives. `relation` MUST
|
|
3322
|
+
* be one of the 9 LOCKED verbs; the server 400-rejects unknown verbs.
|
|
3323
|
+
*
|
|
3324
|
+
* Multi-actor disagreement is captured by creating a SECOND relation
|
|
3325
|
+
* row with the same source/target but a different markedBy* —
|
|
3326
|
+
* the server has no UNIQUE constraint preventing this (intentional,
|
|
3327
|
+
* see migration 0020).
|
|
3328
|
+
*/
|
|
3329
|
+
createRelation(input: CreateRelationInput, signal?: AbortSignal, idempotencyKey?: string): Promise<MnemoRelation>;
|
|
3330
|
+
/**
|
|
3331
|
+
* Retract a relation. Maps to `DELETE /relations/:id`.
|
|
3332
|
+
*
|
|
3333
|
+
* P111 — relations were creatable and removable through no surface at all,
|
|
3334
|
+
* which mattered because P74's dangling-write path could create them against
|
|
3335
|
+
* ids matching no row.
|
|
3336
|
+
*
|
|
3337
|
+
* This CLOSES the bitemporal interval; the row and its judgment provenance
|
|
3338
|
+
* survive, matching `forgetFact`'s semantics rather than a physical delete.
|
|
3339
|
+
* Throws 404 when the relation does not exist OR was already closed — neither
|
|
3340
|
+
* is a state this call changed.
|
|
3341
|
+
*/
|
|
3342
|
+
closeRelation(id: string, signal?: AbortSignal): Promise<void>;
|
|
3343
|
+
/**
|
|
3344
|
+
* Apply a judgment to a pending relation: replace the verb, flip
|
|
3345
|
+
* `judgmentStatus` to 'judged', stamp the marker. Returns the
|
|
3346
|
+
* updated row, or throws 404 when the relation does not exist.
|
|
3347
|
+
*/
|
|
3348
|
+
patchRelation(id: string, input: PatchRelationInput, signal?: AbortSignal): Promise<MnemoRelation>;
|
|
3349
|
+
/**
|
|
3350
|
+
* List citations attached to memory primitives. Filter by
|
|
3351
|
+
* `memoryKind` (fact/decision/entity/episode) and/or `memoryId`
|
|
3352
|
+
* for a specific row's provenance trail. Newest first.
|
|
3353
|
+
*/
|
|
3354
|
+
listCitations(input?: ListCitationsInput, signal?: AbortSignal): Promise<ListCitationsResponse>;
|
|
3355
|
+
/**
|
|
3356
|
+
* Manually enqueue a fact (or decision) for human review.
|
|
3357
|
+
* Idempotent via the server-side partial index: re-enqueuing an
|
|
3358
|
+
* open row returns the existing id with `inserted:false` instead
|
|
3359
|
+
* of creating a duplicate. Exactly one of `factId`/`decisionId`
|
|
3360
|
+
* MUST be supplied; the server 400-rejects both-or-neither, and answers
|
|
3361
|
+
* 404 when the fact or decision does not exist or is above the caller's
|
|
3362
|
+
* sensitivity ceiling.
|
|
3363
|
+
*/
|
|
3364
|
+
enqueueReview(input: EnqueueReviewInput, signal?: AbortSignal): Promise<EnqueueReviewResponse>;
|
|
3365
|
+
/**
|
|
3366
|
+
* Create a prospective memory reminder. The reminder will surface during
|
|
3367
|
+
* recall when its time condition (`triggerAt`) is met, when the query
|
|
3368
|
+
* embedding is semantically close to the reminder's condition, or both.
|
|
3369
|
+
*
|
|
3370
|
+
* Returns the created reminder with its assigned `id`.
|
|
3371
|
+
*/
|
|
3372
|
+
createReminder(input: {
|
|
3373
|
+
content: string;
|
|
3374
|
+
condition?: string;
|
|
3375
|
+
triggerAt?: string;
|
|
3376
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
3377
|
+
targetWorkspaceId?: string;
|
|
3378
|
+
}, signal?: AbortSignal, idempotencyKey?: string): Promise<{
|
|
3379
|
+
id: string;
|
|
3380
|
+
content: string;
|
|
3381
|
+
condition: string | null;
|
|
3382
|
+
triggerAt: string | null;
|
|
3383
|
+
status: string;
|
|
3384
|
+
createdAt: string;
|
|
3385
|
+
workspaceId: string;
|
|
3386
|
+
}>;
|
|
3387
|
+
/**
|
|
3388
|
+
* List reminders for the workspace. Defaults to `status=pending`.
|
|
3389
|
+
*
|
|
3390
|
+
* @param status - 'pending' | 'triggered' | 'dismissed' | 'all' (default: 'pending')
|
|
3391
|
+
* @param limit - Max rows to return (default: 50, max: 200)
|
|
3392
|
+
*/
|
|
3393
|
+
listReminders(input?: {
|
|
3394
|
+
status?: "pending" | "triggered" | "dismissed" | "all";
|
|
3395
|
+
limit?: number;
|
|
3396
|
+
}, signal?: AbortSignal): Promise<{
|
|
3397
|
+
reminders: Array<{
|
|
3398
|
+
id: string;
|
|
3399
|
+
content: string;
|
|
3400
|
+
condition: string | null;
|
|
3401
|
+
triggerAt: string | null;
|
|
3402
|
+
status: string;
|
|
3403
|
+
createdAt: string;
|
|
3404
|
+
}>;
|
|
3405
|
+
}>;
|
|
3406
|
+
/**
|
|
3407
|
+
* Dismiss a reminder by id. Sets status to 'dismissed' (no row deleted).
|
|
3408
|
+
* Throws MnemosyneAPIError (404) when the reminder does not exist.
|
|
3409
|
+
*/
|
|
3410
|
+
dismissReminder(id: string, signal?: AbortSignal): Promise<void>;
|
|
3411
|
+
/**
|
|
3412
|
+
* Start a new ephemeral session (episode). Use the returned `id` with
|
|
3413
|
+
* {@link collapseSession} when the conversation ends.
|
|
3414
|
+
*
|
|
3415
|
+
* Maps to `POST /session/start` on the Mnemosyne server.
|
|
3416
|
+
*/
|
|
3417
|
+
createSession(input?: CreateSessionInput, signal?: AbortSignal, idempotencyKey?: string): Promise<CreateSessionResponse>;
|
|
3418
|
+
/**
|
|
3419
|
+
* Collapse an active session into durable knowledge units (facts,
|
|
3420
|
+
* decisions, strategies). The server returns 202 Accepted after the
|
|
3421
|
+
* collapse pipeline completes.
|
|
3422
|
+
*
|
|
3423
|
+
* Throws `MnemosyneAPIError` with status 404 when the session does not
|
|
3424
|
+
* exist or has already been collapsed.
|
|
3425
|
+
*
|
|
3426
|
+
* Maps to `POST /session/:id/collapse` on the Mnemosyne server.
|
|
3427
|
+
*/
|
|
3428
|
+
collapseSession(id: string, input?: CollapseSessionInput, signal?: AbortSignal, idempotencyKey?: string): Promise<CollapseSessionResponse>;
|
|
3429
|
+
/**
|
|
3430
|
+
* Append a conversation turn to an active session's transcript.
|
|
3431
|
+
*
|
|
3432
|
+
* Both user and assistant turns should be recorded here so the collapse
|
|
3433
|
+
* pipeline can extract facts from the full conversation context.
|
|
3434
|
+
*
|
|
3435
|
+
* Maps to `POST /session/:id/turn`. Returns 204 No Content (void).
|
|
3436
|
+
*/
|
|
3437
|
+
appendTurn(id: string, input: AppendTurnInput, signal?: AbortSignal): Promise<void>;
|
|
3438
|
+
/**
|
|
3439
|
+
* Pin or unpin a specific turn within an active session.
|
|
3440
|
+
*
|
|
3441
|
+
* Pinned turns are given higher weight during the collapse extraction pass
|
|
3442
|
+
* and are more likely to become durable facts.
|
|
3443
|
+
*
|
|
3444
|
+
* Maps to `POST /session/:id/pin`. Returns 204 No Content (void).
|
|
3445
|
+
*/
|
|
3446
|
+
pinSessionTurn(id: string, input: PinSessionTurnInput, signal?: AbortSignal): Promise<void>;
|
|
3447
|
+
/**
|
|
3448
|
+
* Submit explicit user feedback (thumbs up/down rating) for a session.
|
|
3449
|
+
*
|
|
3450
|
+
* Maps to `POST /session/:id/feedback`. Returns 204 No Content (void).
|
|
3451
|
+
*/
|
|
3452
|
+
sessionFeedback(id: string, rating: "up" | "down", signal?: AbortSignal): Promise<void>;
|
|
3453
|
+
/**
|
|
3454
|
+
* Fetch a single session by id (status, label, `lastRecallAt`).
|
|
3455
|
+
*
|
|
3456
|
+
* Maps to `GET /session/:id` on the Mnemosyne server.
|
|
3457
|
+
*/
|
|
3458
|
+
getSession(id: string, signal?: AbortSignal): Promise<SessionWire>;
|
|
3459
|
+
/**
|
|
3460
|
+
* List every session in the workspace.
|
|
3461
|
+
*
|
|
3462
|
+
* Maps to `GET /session/list` on the Mnemosyne server.
|
|
3463
|
+
*/
|
|
3464
|
+
listSessions(signal?: AbortSignal): Promise<ListSessionsResponse>;
|
|
3465
|
+
/**
|
|
3466
|
+
* Namespaced session helpers — convenience wrapper that satisfies the
|
|
3467
|
+
* spec's chaining example with zero client state.
|
|
3468
|
+
*
|
|
3469
|
+
* @example
|
|
3470
|
+
* ```ts
|
|
3471
|
+
* const { id } = await client.sessions.create();
|
|
3472
|
+
* await client.sessions.addTurn(id, { role: "user", content: "Hello!" });
|
|
3473
|
+
* await client.sessions.pinTurn(id, { turnIndex: 0, pinned: true }); // or { turnId: "<uuid>" }
|
|
3474
|
+
* await client.sessions.collapse(id);
|
|
3475
|
+
* ```
|
|
3476
|
+
*/
|
|
3477
|
+
get sessions(): {
|
|
3478
|
+
create: (input?: CreateSessionInput, signal?: AbortSignal, idempotencyKey?: string) => Promise<CreateSessionResponse>;
|
|
3479
|
+
addTurn: (id: string, input: AppendTurnInput, signal?: AbortSignal) => Promise<void>;
|
|
3480
|
+
pinTurn: (id: string, input: PinSessionTurnInput, signal?: AbortSignal) => Promise<void>;
|
|
3481
|
+
collapse: (id: string, input?: CollapseSessionInput, signal?: AbortSignal, idempotencyKey?: string) => Promise<CollapseSessionResponse>;
|
|
3482
|
+
feedback: (id: string, rating: "up" | "down", signal?: AbortSignal) => Promise<void>;
|
|
3483
|
+
};
|
|
3484
|
+
/**
|
|
3485
|
+
* Write a scratch note (ephemeral working-memory entry) to an active session.
|
|
3486
|
+
*
|
|
3487
|
+
* The `scratch` object is stored under the session's working-memory context.
|
|
3488
|
+
* The `note` key conventionally carries the human-readable text; additional
|
|
3489
|
+
* arbitrary keys are passed through as metadata (e.g. `{ role, metadata }`).
|
|
3490
|
+
*
|
|
3491
|
+
* Maps to `POST /session/:id/scratch` (not `/turn` — they are different
|
|
3492
|
+
* endpoints: `/scratch` is ephemeral working-memory, `/turn` is transcript).
|
|
3493
|
+
* Returns 204 No Content, so this resolves to `void`.
|
|
3494
|
+
*/
|
|
3495
|
+
updateSessionScratch(id: string, scratch: Record<string, unknown>, signal?: AbortSignal): Promise<void>;
|
|
3496
|
+
/**
|
|
3497
|
+
* Discard an active session without collapsing it into durable memory.
|
|
3498
|
+
*
|
|
3499
|
+
* Use when the conversation should be abandoned (e.g. user cancelled or
|
|
3500
|
+
* the context is irrelevant) rather than collapsed into knowledge units.
|
|
3501
|
+
* The server marks the session as discarded; no extraction pass is run.
|
|
3502
|
+
*
|
|
3503
|
+
* Maps to `POST /session/:id/discard`. Returns 204 No Content, so this
|
|
3504
|
+
* resolves to `void`.
|
|
3505
|
+
*/
|
|
3506
|
+
discardSession(id: string, signal?: AbortSignal): Promise<void>;
|
|
3507
|
+
/**
|
|
3508
|
+
* Trigger an on-demand consolidation pass for the workspace.
|
|
3509
|
+
*
|
|
3510
|
+
* The background scheduler already runs on its own interval. Use this
|
|
3511
|
+
* method when you want to force a consolidation immediately — e.g. after
|
|
3512
|
+
* a large batch of `remember` calls, or when the `memory_consolidate`
|
|
3513
|
+
* MCP tool is invoked.
|
|
3514
|
+
*
|
|
3515
|
+
* Only `mode: "fast"` (default) with `dryRun: false` is currently
|
|
3516
|
+
* supported and processes a bounded low-worth candidate set. Manual `mode: "deep"`
|
|
3517
|
+
* requests throw `MnemosyneAPIError` with status 422 and code
|
|
3518
|
+
* `deep_mode_not_supported`. Requests with `dryRun: true` throw status 422
|
|
3519
|
+
* with code `dry_run_not_supported`, without running consolidation.
|
|
3520
|
+
*
|
|
3521
|
+
* Throws `MnemosyneAPIError` with status 503 when required server-side
|
|
3522
|
+
* consolidation or storage services are unavailable.
|
|
3523
|
+
*
|
|
3524
|
+
* Maps to `POST /consolidation/trigger`.
|
|
3525
|
+
*/
|
|
3526
|
+
triggerConsolidation(input?: TriggerConsolidationInput, signal?: AbortSignal, idempotencyKey?: string): Promise<TriggerConsolidationResponse>;
|
|
3527
|
+
/** List tasks for the workspace. Maps to `GET /tasks`. */
|
|
3528
|
+
listTasks(params?: ListTasksParams, signal?: AbortSignal): Promise<PaginatedTasksResponse>;
|
|
3529
|
+
/** Create a new task. Maps to `POST /tasks`. */
|
|
3530
|
+
createTask(body: CreateTaskInput, signal?: AbortSignal, idempotencyKey?: string): Promise<TaskWire>;
|
|
3531
|
+
/** Get a single task by ID. Maps to `GET /tasks/:id`. */
|
|
3532
|
+
getTask(id: string, signal?: AbortSignal): Promise<TaskWire>;
|
|
3533
|
+
/** Update fields on an existing task. Maps to `PATCH /tasks/:id`. */
|
|
3534
|
+
patchTask(id: string, body: PatchTaskInput, signal?: AbortSignal): Promise<TaskWire>;
|
|
3535
|
+
/** Archive (soft-delete) a task. Maps to `DELETE /tasks/:id`. */
|
|
3536
|
+
archiveTask(id: string, signal?: AbortSignal): Promise<void>;
|
|
3537
|
+
/** List events for the workspace. Maps to `GET /events`. */
|
|
3538
|
+
listEvents(params?: ListEventsParams, signal?: AbortSignal): Promise<PaginatedEventsResponse>;
|
|
3539
|
+
/** Create a new event (immutable append). Maps to `POST /events`. */
|
|
3540
|
+
createEvent(body: CreateEventInput, signal?: AbortSignal, idempotencyKey?: string): Promise<EventWire>;
|
|
3541
|
+
/** Get a single event by ID. Maps to `GET /events/:id`. */
|
|
3542
|
+
getEvent(id: string, signal?: AbortSignal): Promise<EventWire>;
|
|
3543
|
+
/**
|
|
3544
|
+
* EVENT-1: this is a NO-OP. `mnemo_event` has no status/valid_to column, so
|
|
3545
|
+
* `DELETE /events/:id` returns 204 without reading or writing the row —
|
|
3546
|
+
* kept only for API symmetry with the other primitives' DELETE routes.
|
|
3547
|
+
* Maps to `DELETE /events/:id`.
|
|
3548
|
+
*/
|
|
3549
|
+
archiveEvent(id: string, signal?: AbortSignal): Promise<void>;
|
|
3550
|
+
/** Append a human annotation to an immutable event. Maps to `POST /events/:id/annotations`. */
|
|
3551
|
+
annotateEvent(id: string, body: {
|
|
3552
|
+
author: string;
|
|
3553
|
+
content: string;
|
|
3554
|
+
at?: string;
|
|
3555
|
+
}, signal?: AbortSignal): Promise<EventWire>;
|
|
3556
|
+
/**
|
|
3557
|
+
* Raise an event's sensitivity tier (raise-only — cannot lower).
|
|
3558
|
+
* Throws `MnemosyneAPIError` with status 422 if `sensitivity` is below
|
|
3559
|
+
* the event's current tier, and with status 404 if the event does not
|
|
3560
|
+
* exist or is above the caller's sensitivity ceiling, or (code
|
|
3561
|
+
* `sensitivity_above_ceiling`) if `sensitivity` is above that ceiling: the
|
|
3562
|
+
* caller could not read the event afterwards, so nothing is changed.
|
|
3563
|
+
*
|
|
3564
|
+
* Maps to `PATCH /events/:id/sensitivity`.
|
|
3565
|
+
*/
|
|
3566
|
+
updateEventSensitivity(id: string, input: UpdateEventSensitivityInput, signal?: AbortSignal): Promise<EventWire>;
|
|
3567
|
+
/** List workflows in the workspace. Maps to `GET /workflows`. */
|
|
3568
|
+
listWorkflows(params?: {
|
|
3569
|
+
status?: string;
|
|
3570
|
+
scopeRef?: string;
|
|
3571
|
+
offset?: number;
|
|
3572
|
+
limit?: number;
|
|
3573
|
+
}, signal?: AbortSignal): Promise<{
|
|
3574
|
+
items: unknown[];
|
|
3575
|
+
total: number;
|
|
3576
|
+
hasMore: boolean;
|
|
3577
|
+
}>;
|
|
3578
|
+
/** Create a new workflow. Maps to `POST /workflows`. */
|
|
3579
|
+
createWorkflow(body: {
|
|
3580
|
+
name: string;
|
|
3581
|
+
description?: string;
|
|
3582
|
+
steps: unknown[];
|
|
3583
|
+
scopeRef?: string;
|
|
3584
|
+
metadata?: Record<string, unknown>;
|
|
3585
|
+
/** Write into a different workspace than the caller's own (requires a write/admin member). */
|
|
3586
|
+
targetWorkspaceId?: string;
|
|
3587
|
+
}, signal?: AbortSignal): Promise<unknown>;
|
|
3588
|
+
/** Get a single workflow by ID. Maps to `GET /workflows/:id`. */
|
|
3589
|
+
getWorkflow(id: string, signal?: AbortSignal): Promise<unknown>;
|
|
3590
|
+
/**
|
|
3591
|
+
* Update a workflow's name, description, steps, status or metadata.
|
|
3592
|
+
* Maps to `PATCH /workflows/:id`.
|
|
3593
|
+
*
|
|
3594
|
+
* P111 — same gap as skills: `updateWorkflow` was implemented on every adapter
|
|
3595
|
+
* and reachable from nowhere. `status` is the real enum
|
|
3596
|
+
* (active | deprecated | draft), not the archived/active pair a reader might
|
|
3597
|
+
* assume. At least one field must be supplied.
|
|
3598
|
+
*/
|
|
3599
|
+
updateWorkflow(id: string, input: {
|
|
3600
|
+
name?: string;
|
|
3601
|
+
description?: string;
|
|
3602
|
+
steps?: Array<{
|
|
3603
|
+
order: number;
|
|
3604
|
+
action: string;
|
|
3605
|
+
condition?: string;
|
|
3606
|
+
expectedDurationMs: number;
|
|
3607
|
+
tools?: string[];
|
|
3608
|
+
}>;
|
|
3609
|
+
status?: "active" | "deprecated" | "draft";
|
|
3610
|
+
metadata?: Record<string, unknown>;
|
|
3611
|
+
}, signal?: AbortSignal): Promise<unknown>;
|
|
3612
|
+
/** List reasoning chains for the workspace. Maps to `GET /reasoning`. */
|
|
3613
|
+
listReasoning(params?: ListReasoningParams, signal?: AbortSignal): Promise<PaginatedReasoningResponse>;
|
|
3614
|
+
/** Create a new reasoning chain. Maps to `POST /reasoning`. */
|
|
3615
|
+
createReasoning(body: CreateReasoningInput, signal?: AbortSignal): Promise<ReasoningWire>;
|
|
3616
|
+
/** Get a single reasoning chain by ID. Maps to `GET /reasoning/:id`. */
|
|
3617
|
+
getReasoning(id: string, signal?: AbortSignal): Promise<ReasoningWire>;
|
|
3618
|
+
/** Update fields on an existing reasoning chain. Maps to `PATCH /reasoning/:id`. */
|
|
3619
|
+
patchReasoning(id: string, body: PatchReasoningInput, signal?: AbortSignal): Promise<ReasoningWire>;
|
|
3620
|
+
/** Archive (soft-delete) a reasoning chain. Maps to `DELETE /reasoning/:id`. */
|
|
3621
|
+
archiveReasoning(id: string, signal?: AbortSignal): Promise<void>;
|
|
3622
|
+
/** Resolve a reasoning query against the CoT cache. Maps to `POST /reasoning/resolve`. */
|
|
3623
|
+
resolveReasoning(body: ResolveReasoningInput, signal?: AbortSignal): Promise<ResolveReasoningResponse>;
|
|
3624
|
+
/** Record a completed reasoning chain into the CoT cache. Maps to `POST /reasoning/record`. */
|
|
3625
|
+
recordReasoning(body: RecordReasoningInput, signal?: AbortSignal): Promise<ReasoningWire>;
|
|
3626
|
+
/** Submit outcome feedback for a cached reasoning chain. Maps to `POST /reasoning/feedback`. */
|
|
3627
|
+
reasoningFeedback(body: ReasoningFeedbackInput, signal?: AbortSignal): Promise<ReasoningWire>;
|
|
3628
|
+
/** List strategies for the workspace. */
|
|
3629
|
+
listStrategies(params?: ListStrategiesParams, signal?: AbortSignal): Promise<PaginatedStrategiesResponse>;
|
|
3630
|
+
/** Create a new strategy. */
|
|
3631
|
+
createStrategy(body: CreateStrategyInput, signal?: AbortSignal, idempotencyKey?: string): Promise<StrategyWire>;
|
|
3632
|
+
/** Get a single strategy by ID. */
|
|
3633
|
+
getStrategy(id: string, signal?: AbortSignal): Promise<StrategyWire>;
|
|
3634
|
+
/** Patch an existing strategy. */
|
|
3635
|
+
patchStrategy(id: string, body: PatchStrategyInput, signal?: AbortSignal): Promise<StrategyWire>;
|
|
3636
|
+
/** Archive a strategy (soft-delete). */
|
|
3637
|
+
archiveStrategy(id: string, signal?: AbortSignal): Promise<void>;
|
|
3638
|
+
/**
|
|
3639
|
+
* §24 Record the outcome of executing a strategy.
|
|
3640
|
+
* Triggers a Beta-Bernoulli recompute on the server:
|
|
3641
|
+
* alpha = 2 + successCount, beta = 2 + failureCount, worth = alpha / (alpha + beta).
|
|
3642
|
+
* Not idempotent — each call increments successCount or failureCount.
|
|
3643
|
+
*/
|
|
3644
|
+
rateStrategy(id: string, outcome: "success" | "failure", signal?: AbortSignal): Promise<StrategyWire>;
|
|
3645
|
+
/** List hyperedges for this workspace. */
|
|
3646
|
+
listHyperedges(params?: ListHyperedgesParams, signal?: AbortSignal): Promise<PaginatedHyperedgesResponse>;
|
|
3647
|
+
/** Create a new hyperedge (n-ary relation with ≥3 members). */
|
|
3648
|
+
createHyperedge(body: CreateHyperedgeInput, signal?: AbortSignal, idempotencyKey?: string): Promise<HyperedgeWire>;
|
|
3649
|
+
/** Get a single hyperedge by ID. */
|
|
3650
|
+
getHyperedge(id: string, signal?: AbortSignal): Promise<HyperedgeWire>;
|
|
3651
|
+
/** Patch an existing hyperedge (label, description, contextQuery). */
|
|
3652
|
+
patchHyperedge(id: string, body: PatchHyperedgeInput, signal?: AbortSignal): Promise<HyperedgeWire>;
|
|
3653
|
+
/** Archive a hyperedge (soft-delete). */
|
|
3654
|
+
archiveHyperedge(id: string, signal?: AbortSignal): Promise<void>;
|
|
3655
|
+
/** Return the workspace SelfModel (§31 meta-cognition). */
|
|
3656
|
+
getSelfModel(opts?: {
|
|
3657
|
+
aspect?: SelfModelAspect;
|
|
3658
|
+
entity?: string;
|
|
3659
|
+
limit?: number;
|
|
3660
|
+
}, signal?: AbortSignal): Promise<SelfModelResponse>;
|
|
3661
|
+
/**
|
|
3662
|
+
* Return ranked anticipated memories (§8 Anticipation Engine).
|
|
3663
|
+
*
|
|
3664
|
+
* The `GET /anticipation` route honors four query params:
|
|
3665
|
+
* - `recentlyRecalledId` — drives the sequential ("when I recall X I
|
|
3666
|
+
* usually recall Y") branch. Without it, only periodicity counts.
|
|
3667
|
+
* - `context` — free-text query context for conditional anticipation
|
|
3668
|
+
* patterns (§30). Server caps length at 500 chars.
|
|
3669
|
+
* - `lookAhead` — minutes to anticipate ahead (§30); shifts the
|
|
3670
|
+
* periodic slot. Server default 30, range 0–10080 (one week).
|
|
3671
|
+
* - `limit` — max items, server default 20, range 1–100.
|
|
3672
|
+
*/
|
|
3673
|
+
getAnticipationFeed(opts?: {
|
|
3674
|
+
recentlyRecalledId?: string;
|
|
3675
|
+
context?: string;
|
|
3676
|
+
lookAhead?: number;
|
|
3677
|
+
limit?: number;
|
|
3678
|
+
}): Promise<AnticipationFeedResponse>;
|
|
3679
|
+
/**
|
|
3680
|
+
* Namespace getter for §32 Compositionality Engine admin routes.
|
|
3681
|
+
*
|
|
3682
|
+
* @example
|
|
3683
|
+
* ```ts
|
|
3684
|
+
* const page = await client.composition.listRules({ isActive: true });
|
|
3685
|
+
* const rule = await client.composition.createRule({ name: "My Rule", ... });
|
|
3686
|
+
* const dryRun = await client.composition.dryRun({ ruleId: "r-1", hits });
|
|
3687
|
+
* ```
|
|
3688
|
+
*/
|
|
3689
|
+
get composition(): {
|
|
3690
|
+
listRules(opts?: {
|
|
3691
|
+
isActive?: boolean;
|
|
3692
|
+
offset?: number;
|
|
3693
|
+
limit?: number;
|
|
3694
|
+
signal?: AbortSignal;
|
|
3695
|
+
}): Promise<ListCompositionRulesResponse>;
|
|
3696
|
+
createRule(input: {
|
|
3697
|
+
name: string;
|
|
3698
|
+
conditionDsl: unknown;
|
|
3699
|
+
actionDsl: unknown;
|
|
3700
|
+
description?: string;
|
|
3701
|
+
priority?: number;
|
|
3702
|
+
isActive?: boolean;
|
|
3703
|
+
source?: "manual" | "mined" | "imported";
|
|
3704
|
+
metadata?: Record<string, unknown>;
|
|
3705
|
+
}, signal?: AbortSignal): Promise<CompositionRule>;
|
|
3706
|
+
getRule(id: string, signal?: AbortSignal): Promise<CompositionRule>;
|
|
3707
|
+
/**
|
|
3708
|
+
* P111 — read the append-only inference log. `compositionality.ts` writes an
|
|
3709
|
+
* entry on every derivation and nothing could read them back, so "why does
|
|
3710
|
+
* this fact exist?" had no answer outside the database. Filter by
|
|
3711
|
+
* `derivedId` to trace one primitive's provenance, or by `ruleId` to see
|
|
3712
|
+
* what a rule has actually produced.
|
|
3713
|
+
*/
|
|
3714
|
+
listInferences(opts?: {
|
|
3715
|
+
ruleId?: string;
|
|
3716
|
+
derivedId?: string;
|
|
3717
|
+
since?: string;
|
|
3718
|
+
offset?: number;
|
|
3719
|
+
limit?: number;
|
|
3720
|
+
signal?: AbortSignal;
|
|
3721
|
+
}): Promise<{
|
|
3722
|
+
items: Array<Record<string, unknown>>;
|
|
3723
|
+
total: number;
|
|
3724
|
+
offset: number;
|
|
3725
|
+
limit: number;
|
|
3726
|
+
hasMore: boolean;
|
|
3727
|
+
}>;
|
|
3728
|
+
patchRule(id: string, patch: {
|
|
3729
|
+
name?: string;
|
|
3730
|
+
description?: string;
|
|
3731
|
+
conditionDsl?: unknown;
|
|
3732
|
+
actionDsl?: unknown;
|
|
3733
|
+
priority?: number;
|
|
3734
|
+
isActive?: boolean;
|
|
3735
|
+
metadata?: Record<string, unknown>;
|
|
3736
|
+
}, signal?: AbortSignal): Promise<CompositionRule>;
|
|
3737
|
+
dryRun(input: {
|
|
3738
|
+
ruleId?: string;
|
|
3739
|
+
rule?: {
|
|
3740
|
+
name: string;
|
|
3741
|
+
conditionDsl: unknown;
|
|
3742
|
+
actionDsl: unknown;
|
|
3743
|
+
priority?: number;
|
|
3744
|
+
};
|
|
3745
|
+
hits: Array<{
|
|
3746
|
+
id: string;
|
|
3747
|
+
primitive: string;
|
|
3748
|
+
content: string;
|
|
3749
|
+
score: number;
|
|
3750
|
+
factKind?: string;
|
|
3751
|
+
worth?: number;
|
|
3752
|
+
tags?: string[];
|
|
3753
|
+
}>;
|
|
3754
|
+
}, signal?: AbortSignal): Promise<CompositionDryRunResponse>;
|
|
3755
|
+
};
|
|
3756
|
+
/**
|
|
3757
|
+
* Edit the agent's own memory using one of six live actions:
|
|
3758
|
+
* append | replace | strengthen | weaken | reflect | link.
|
|
3759
|
+
* `target` is polymorphic: fact_id | "profile" | "strategy:{id}".
|
|
3760
|
+
* `reason` is required policy and log context, but is not durably audited yet.
|
|
3761
|
+
* link: creates an n-ary hyperedge; target=anchor, content=comma-separated co-members (total ≥3).
|
|
3762
|
+
*
|
|
3763
|
+
* `action: "forget"` is `@deprecated` — the server gates it with a 422
|
|
3764
|
+
* (`self_edit_forget_unsupported`) since no approval flow exists to
|
|
3765
|
+
* resolve it. Use {@link forgetFact}/{@link forgetPrimitive} instead.
|
|
3766
|
+
*/
|
|
3767
|
+
selfEdit(input: {
|
|
3768
|
+
action: "append" | "replace" | "strengthen" | "weaken"
|
|
3769
|
+
/**
|
|
3770
|
+
* @deprecated Server-side gated (422 `self_edit_forget_unsupported`) as of
|
|
3771
|
+
* B4 — no approval flow exists to resolve it. Kept so the 422 response
|
|
3772
|
+
* stays typed/observable instead of a hard compile break. Use
|
|
3773
|
+
* `forgetFact`/`forgetPrimitive` (kind: "fact" | "strategy") instead.
|
|
3774
|
+
*/
|
|
3775
|
+
| "forget" | "reflect" | "link";
|
|
3776
|
+
target: string;
|
|
3777
|
+
content?: string;
|
|
3778
|
+
reason: string;
|
|
3779
|
+
agentId?: string;
|
|
3780
|
+
sessionId?: string;
|
|
3781
|
+
}, signal?: AbortSignal, idempotencyKey?: string): Promise<SelfEditResponse>;
|
|
3782
|
+
/**
|
|
3783
|
+
* Trigger the reflection cycle immediately for an agent.
|
|
3784
|
+
* Returns the episode_id of the synthetic reflection episode plus
|
|
3785
|
+
* the lists of strengthened / weakened strategy ids.
|
|
3786
|
+
*/
|
|
3787
|
+
selfReflect(input?: {
|
|
3788
|
+
agentId?: string;
|
|
3789
|
+
}, signal?: AbortSignal): Promise<{
|
|
3790
|
+
episode_id: string;
|
|
3791
|
+
strengthened: string[];
|
|
3792
|
+
weakened: string[];
|
|
3793
|
+
}>;
|
|
3794
|
+
/**
|
|
3795
|
+
* Retrieve the current agent profile (self-model).
|
|
3796
|
+
* Returns an empty profile (summary: "") when none exists yet.
|
|
3797
|
+
*/
|
|
3798
|
+
getSelfProfile(agentId?: string, signal?: AbortSignal): Promise<{
|
|
3799
|
+
workspaceId: string;
|
|
3800
|
+
agentId: string;
|
|
3801
|
+
summary: string;
|
|
3802
|
+
metadata: Record<string, unknown>;
|
|
3803
|
+
createdAt: string | null;
|
|
3804
|
+
updatedAt: string | null;
|
|
3805
|
+
}>;
|
|
3806
|
+
/**
|
|
3807
|
+
* List all approved peers in the federation mesh.
|
|
3808
|
+
* Maps to `GET /memory/federation/peers`.
|
|
3809
|
+
*/
|
|
3810
|
+
listFederationPeers(signal?: AbortSignal): Promise<ListPeersResponse>;
|
|
3811
|
+
/**
|
|
3812
|
+
* Provision a federation peer (the only way a peer is created).
|
|
3813
|
+
* Maps to `POST /memory/federation/peers`. Requires `federation:admin`;
|
|
3814
|
+
* answers 409 when the peerId already exists.
|
|
3815
|
+
*/
|
|
3816
|
+
createFederationPeer(input: CreatePeerInput, signal?: AbortSignal): Promise<CreatePeerResponse>;
|
|
3817
|
+
/**
|
|
3818
|
+
* List peers awaiting approval plus discovery state.
|
|
3819
|
+
* Maps to `GET /memory/federation/peers/pending`.
|
|
3820
|
+
*/
|
|
3821
|
+
listPendingFederationPeers(signal?: AbortSignal): Promise<ListPendingPeersResponse>;
|
|
3822
|
+
/**
|
|
3823
|
+
* Approve a pending peer (certificate rotation).
|
|
3824
|
+
* Maps to `POST /memory/federation/peers/:id/approve`.
|
|
3825
|
+
*/
|
|
3826
|
+
approveFederationPeer(id: string, input: ApprovePeerInput, signal?: AbortSignal): Promise<void>;
|
|
3827
|
+
/**
|
|
3828
|
+
* Approve a peer's public key specifically.
|
|
3829
|
+
* Maps to `POST /memory/federation/peers/:id/approve-key`.
|
|
3830
|
+
*/
|
|
3831
|
+
approveFederationPeerKey(id: string, input: ApprovePeerInput, signal?: AbortSignal): Promise<ApprovePeerKeyResponse>;
|
|
3832
|
+
/**
|
|
3833
|
+
* Remove a peer from the federation mesh.
|
|
3834
|
+
* Maps to `DELETE /memory/federation/peers/:id`.
|
|
3835
|
+
*/
|
|
3836
|
+
deleteFederationPeer(id: string, signal?: AbortSignal): Promise<DeletePeerResponse>;
|
|
3837
|
+
/**
|
|
3838
|
+
* Read this workspace's facts as a peer pulls them (needs an `mk_fed_` key
|
|
3839
|
+
* and the federation peer headers). Maps to `GET /memory/federation/items`.
|
|
3840
|
+
* `cursor` is the `nextCursor` of an earlier page; `knownCursor` is where the
|
|
3841
|
+
* caller's previous sync ended, and turns on tombstones for facts created by then.
|
|
3842
|
+
*/
|
|
3843
|
+
listFederationItems(opts?: {
|
|
3844
|
+
since?: string;
|
|
3845
|
+
limit?: number;
|
|
3846
|
+
cursor?: string;
|
|
3847
|
+
knownCursor?: string;
|
|
3848
|
+
}, signal?: AbortSignal): Promise<ListFederationItemsResponse>;
|
|
3849
|
+
/**
|
|
3850
|
+
* Trigger an immediate sync pull from a peer.
|
|
3851
|
+
* Maps to `POST /memory/federation/sync` (returns 202 Accepted).
|
|
3852
|
+
*/
|
|
3853
|
+
triggerFederationSync(input: TriggerFederationSyncInput, signal?: AbortSignal): Promise<TriggerFederationSyncResponse>;
|
|
3854
|
+
/**
|
|
3855
|
+
* Get status of a federation sync job by its jobId.
|
|
3856
|
+
* Maps to `GET /memory/federation/sync/:jobId`.
|
|
3857
|
+
*/
|
|
3858
|
+
getFederationSyncJob(jobId: string, signal?: AbortSignal): Promise<FederationSyncJob>;
|
|
3859
|
+
/**
|
|
3860
|
+
* Resolve a conflict between federated claims. Accepts either a
|
|
3861
|
+
* two-item pair (`{ itemA, itemB }`) or a batch (`{ items: [...] }`).
|
|
3862
|
+
*
|
|
3863
|
+
* Maps to `POST /memory/federation/resolve`.
|
|
3864
|
+
*/
|
|
3865
|
+
resolveFederationConflict(input: ResolveFederationConflictPairInput | ResolveFederationConflictBatchInput, signal?: AbortSignal): Promise<ResolveFederationConflictResponse>;
|
|
3866
|
+
/**
|
|
3867
|
+
* List unresolved conflict pairs in the workspace.
|
|
3868
|
+
*
|
|
3869
|
+
* Conflicts are `conflicts_with` relations between active facts that have
|
|
3870
|
+
* not yet been resolved. The list is sorted newest-first. Use
|
|
3871
|
+
* `resolveConflict` to apply a resolution action to each pair.
|
|
3872
|
+
*
|
|
3873
|
+
* @param limit - Max pairs to return. Default 5, max 20.
|
|
3874
|
+
* Maps to `GET /conflicts`.
|
|
3875
|
+
*/
|
|
3876
|
+
judge(opts?: {
|
|
3877
|
+
limit?: number;
|
|
3878
|
+
}, signal?: AbortSignal): Promise<ListConflictsResponse>;
|
|
3879
|
+
/**
|
|
3880
|
+
* Resolve a specific conflict pair by its `relationId`.
|
|
3881
|
+
*
|
|
3882
|
+
* Four resolution strategies:
|
|
3883
|
+
* - `supersede_a`: forget factA, relation becomes `supersedes`.
|
|
3884
|
+
* - `supersede_b`: forget factB, relation becomes `supersedes`.
|
|
3885
|
+
* - `keep_both`: mark as `not_conflict` (both facts stay active).
|
|
3886
|
+
* - `merge`: forget both, create a new merged fact, relation becomes `supersedes`.
|
|
3887
|
+
* `mergedStatement` is required for this action.
|
|
3888
|
+
*
|
|
3889
|
+
* Maps to `POST /conflicts/:id/resolve`.
|
|
3890
|
+
*/
|
|
3891
|
+
resolveConflict(relationId: string, input: ResolveConflictInput, signal?: AbortSignal): Promise<ResolveConflictResponse>;
|
|
3892
|
+
/**
|
|
3893
|
+
* Subscribe to a Mnemosyne event channel via WebSocket.
|
|
3894
|
+
*
|
|
3895
|
+
* Opens a WebSocket to `/memory/ws?token=<apiKey>`, sends a subscribe
|
|
3896
|
+
* frame for `channel`, and calls `handler` for each matching event.
|
|
3897
|
+
*
|
|
3898
|
+
* Requires a `WebSocket` global (native in Node ≥ 22 and browsers; inject
|
|
3899
|
+
* via `opts.WebSocketImpl` for older environments):
|
|
3900
|
+
*
|
|
3901
|
+
* ```ts
|
|
3902
|
+
* import WebSocket from "ws"; // npm install ws
|
|
3903
|
+
* const handle = client.subscribe("facts.*", console.log, { WebSocketImpl: WebSocket });
|
|
3904
|
+
* ```
|
|
3905
|
+
*
|
|
3906
|
+
* Live server integration requires Wave Q WS wiring to be confirmed.
|
|
3907
|
+
* Tests are skipped until then.
|
|
3908
|
+
*
|
|
3909
|
+
* @param channel - Glob channel, e.g. `"facts.*"`, `"session.abc123"`.
|
|
3910
|
+
* @param handler - Called with each raw bus event payload (JSON).
|
|
3911
|
+
* @param opts - Optional filter / disconnect / WebSocketImpl.
|
|
3912
|
+
*/
|
|
3913
|
+
subscribe(channel: string, handler: (event: Record<string, unknown>) => void, opts?: SubscribeOptions): SubscribeHandle;
|
|
3914
|
+
/**
|
|
3915
|
+
* Passive capture — send subagent or pipeline output to Mnemosyne for
|
|
3916
|
+
* automatic fact extraction.
|
|
3917
|
+
*
|
|
3918
|
+
* The server extracts 0-3 durable facts from `content`. When an LLM is
|
|
3919
|
+
* configured server-side it uses guided extraction; otherwise regex
|
|
3920
|
+
* heuristics detect decision/bugfix/config patterns. Identical content
|
|
3921
|
+
* within the same workspace is deduplicated via content-hash.
|
|
3922
|
+
*
|
|
3923
|
+
* Designed for fire-and-forget use from Claude Code hooks:
|
|
3924
|
+
* ```ts
|
|
3925
|
+
* await client.capture({ content: agentStdout, source: "subagent-stop" });
|
|
3926
|
+
* ```
|
|
3927
|
+
*
|
|
3928
|
+
* Maps to `POST /capture`.
|
|
3929
|
+
*/
|
|
3930
|
+
capture(opts: {
|
|
3931
|
+
content: string;
|
|
3932
|
+
source: string;
|
|
3933
|
+
}, signal?: AbortSignal): Promise<{
|
|
3934
|
+
extracted: number;
|
|
3935
|
+
skipped: number;
|
|
3936
|
+
}>;
|
|
3937
|
+
/**
|
|
3938
|
+
* Hard-delete a single fact by ID (GDPR / test-workspace cleanup).
|
|
3939
|
+
*
|
|
3940
|
+
* Performs a physical DELETE on `mnemo_fact`. The row is permanently removed —
|
|
3941
|
+
* this bypasses the bitemporal model and cannot be undone. Use only in
|
|
3942
|
+
* test workspaces or when legally required.
|
|
3943
|
+
*
|
|
3944
|
+
* Requires `memory:hard_delete` scope on the API key. Returns 403 when the
|
|
3945
|
+
* key lacks that scope.
|
|
3946
|
+
*
|
|
3947
|
+
* Maps to `DELETE /facts/:id/hard`.
|
|
3948
|
+
*/
|
|
3949
|
+
purgeFact(id: string, signal?: AbortSignal): Promise<PurgeFactResponse>;
|
|
3950
|
+
/**
|
|
3951
|
+
* GDPR crypto-erasure: destroy every encryption key of a user (`userId`) or
|
|
3952
|
+
* the key of one actor (`actorId`) in the workspace, so their confidential
|
|
3953
|
+
* and restricted memory can never be decrypted again. Irreversible;
|
|
3954
|
+
* `confirm` must repeat the subject id.
|
|
3955
|
+
*
|
|
3956
|
+
* Requires `memory:hard_delete` scope on the API key.
|
|
3957
|
+
*
|
|
3958
|
+
* Maps to `POST /admin/erasure`.
|
|
3959
|
+
*/
|
|
3960
|
+
eraseSubject(input: EraseSubjectInput, signal?: AbortSignal): Promise<EraseSubjectResponse>;
|
|
3961
|
+
/**
|
|
3962
|
+
* Bulk hard-delete all closed (forgotten) facts in the workspace.
|
|
3963
|
+
*
|
|
3964
|
+
* Deletes every fact whose `status = 'forgotten'` (i.e. facts that were
|
|
3965
|
+
* soft-deleted via `memory_forget`). Useful for reclaiming space in test
|
|
3966
|
+
* workspaces after a test run.
|
|
3967
|
+
*
|
|
3968
|
+
* Requires `memory:hard_delete` scope on the API key. Returns 403 when the
|
|
3969
|
+
* key lacks that scope.
|
|
3970
|
+
*
|
|
3971
|
+
* Maps to `DELETE /facts/purge`.
|
|
3972
|
+
*/
|
|
3973
|
+
purgeClosedFacts(signal?: AbortSignal): Promise<PurgeClosedFactsResponse>;
|
|
3974
|
+
/**
|
|
3975
|
+
* List API keys for the current workspace.
|
|
3976
|
+
* Requires `admin:keys` scope.
|
|
3977
|
+
*/
|
|
3978
|
+
listKeys(options?: {
|
|
3979
|
+
expired?: boolean;
|
|
3980
|
+
}, signal?: AbortSignal): Promise<{
|
|
3981
|
+
keys: KeyListItem[];
|
|
3982
|
+
}>;
|
|
3983
|
+
/**
|
|
3984
|
+
* Create a new API key for the current workspace.
|
|
3985
|
+
* Plaintext key is returned ONCE in the response.
|
|
3986
|
+
* Requires `admin:keys` scope.
|
|
3987
|
+
*/
|
|
3988
|
+
createKey(input: CreateKeyInput, signal?: AbortSignal): Promise<CreateKeyResponse>;
|
|
3989
|
+
/**
|
|
3990
|
+
* Get metadata for a single API key (secret is never returned).
|
|
3991
|
+
* Requires `admin:keys` scope.
|
|
3992
|
+
*/
|
|
3993
|
+
getKey(keyId: string, signal?: AbortSignal): Promise<KeyDetailResponse>;
|
|
3994
|
+
/**
|
|
3995
|
+
* Revoke an API key by ID.
|
|
3996
|
+
* Requires `admin:keys` scope.
|
|
3997
|
+
*/
|
|
3998
|
+
revokeKey(keyId: string, signal?: AbortSignal): Promise<{
|
|
3999
|
+
ok: boolean;
|
|
4000
|
+
revokedAt: string;
|
|
4001
|
+
}>;
|
|
4002
|
+
/**
|
|
4003
|
+
* Rotate an API key by ID. Generates a new key with 7 days sunset grace for the old key.
|
|
4004
|
+
* Requires `admin:keys` scope.
|
|
4005
|
+
*/
|
|
4006
|
+
rotateKey(keyId: string, input?: {
|
|
4007
|
+
reason?: string;
|
|
4008
|
+
}, signal?: AbortSignal): Promise<RotateKeyResponse>;
|
|
4009
|
+
/**
|
|
4010
|
+
* Issue a scoped-scheme key (`mk_live_`, `mk_sess_` or `mk_admin_`), the kind
|
|
4011
|
+
* `MNEMO_SCOPED_AUTH=1` verifies. An `mk_admin_` key also returns its TOTP
|
|
4012
|
+
* secret, once. Requires `admin:keys`.
|
|
4013
|
+
*/
|
|
4014
|
+
issueScopedKey(input: IssueScopedKeyInput, signal?: AbortSignal): Promise<IssueScopedKeyResponse>;
|
|
4015
|
+
/** Rotate a scoped-scheme key by its id; the old key keeps 7 days. Requires `admin:keys`. */
|
|
4016
|
+
rotateScopedKey(id: string, input?: {
|
|
4017
|
+
reason?: string;
|
|
4018
|
+
}, signal?: AbortSignal): Promise<RotateScopedKeyResponse>;
|
|
4019
|
+
/** Revoke a scoped-scheme key by its id, at once. Requires `admin:keys`. */
|
|
4020
|
+
revokeScopedKey(id: string, signal?: AbortSignal): Promise<{
|
|
4021
|
+
ok: boolean;
|
|
4022
|
+
revokedAt: string;
|
|
4023
|
+
}>;
|
|
4024
|
+
/** List every agent policy of the workspace. Requires `memory:admin`. */
|
|
4025
|
+
listAgentPolicies(signal?: AbortSignal): Promise<{
|
|
4026
|
+
policies: AgentPolicy[];
|
|
4027
|
+
}>;
|
|
4028
|
+
/** Read one agent's policy; 404 when it has none. Requires `memory:admin`. */
|
|
4029
|
+
getAgentPolicy(agentId: string, signal?: AbortSignal): Promise<AgentPolicy>;
|
|
4030
|
+
/**
|
|
4031
|
+
* Create or replace one agent's policy in the workspace. Requires
|
|
4032
|
+
* `memory:admin`; a key cannot change its own policy (403).
|
|
4033
|
+
*/
|
|
4034
|
+
putAgentPolicy(input: AgentPolicyInput, signal?: AbortSignal): Promise<AgentPolicy>;
|
|
4035
|
+
/** Delete one agent's policy; 404 when it has none. Requires `memory:admin`. */
|
|
4036
|
+
deleteAgentPolicy(agentId: string, signal?: AbortSignal): Promise<void>;
|
|
4037
|
+
/**
|
|
4038
|
+
* Create a new Skill (stored prompt template).
|
|
4039
|
+
* Maps to `POST /skills`.
|
|
4040
|
+
*/
|
|
4041
|
+
createSkill(input: CreateSkillClientInput, signal?: AbortSignal): Promise<SkillWire>;
|
|
4042
|
+
/**
|
|
4043
|
+
* List skills for the current workspace.
|
|
4044
|
+
* Maps to `GET /skills`.
|
|
4045
|
+
*/
|
|
4046
|
+
listSkills(options?: {
|
|
4047
|
+
offset?: number;
|
|
4048
|
+
limit?: number;
|
|
4049
|
+
}, signal?: AbortSignal): Promise<SkillListResponse>;
|
|
4050
|
+
/**
|
|
4051
|
+
* Get a single skill by ID.
|
|
4052
|
+
* Maps to `GET /skills/:id`.
|
|
4053
|
+
*/
|
|
4054
|
+
getSkill(id: string, signal?: AbortSignal): Promise<SkillWire>;
|
|
4055
|
+
/**
|
|
4056
|
+
* Update a skill's template, name, variables or metadata.
|
|
4057
|
+
* Maps to `PATCH /skills/:id`.
|
|
4058
|
+
*
|
|
4059
|
+
* P111 — skills were creatable and never editable: `updateSkill` existed on
|
|
4060
|
+
* every storage adapter with no route and no caller above it. At least one
|
|
4061
|
+
* field must be supplied; the server rejects an empty body rather than
|
|
4062
|
+
* issuing a no-op write.
|
|
4063
|
+
*/
|
|
4064
|
+
updateSkill(id: string, input: {
|
|
4065
|
+
name?: string;
|
|
4066
|
+
promptTemplate?: string;
|
|
4067
|
+
variables?: string[];
|
|
4068
|
+
requiredContext?: string[];
|
|
4069
|
+
metadata?: Record<string, unknown>;
|
|
4070
|
+
}, signal?: AbortSignal): Promise<SkillWire>;
|
|
4071
|
+
/**
|
|
4072
|
+
* Delegate a task to another agent, setting delegatedBy and delegatedAt provenance fields.
|
|
4073
|
+
* Maps to `POST /tasks/:id/delegate`.
|
|
4074
|
+
*/
|
|
4075
|
+
delegateTask(id: string, input: {
|
|
4076
|
+
assignedTo: string;
|
|
4077
|
+
}, signal?: AbortSignal): Promise<TaskWire>;
|
|
4078
|
+
/**
|
|
4079
|
+
* Create a gRPC/ConnectRPC transport for typed streaming calls.
|
|
4080
|
+
*
|
|
4081
|
+
* **This is a stub.** The real implementation requires the optional peer
|
|
4082
|
+
* dependency `@connectrpc/connect`. Install it with:
|
|
4083
|
+
*
|
|
4084
|
+
* ```sh
|
|
4085
|
+
* npm install @connectrpc/connect @connectrpc/connect-web
|
|
4086
|
+
* ```
|
|
4087
|
+
*
|
|
4088
|
+
* Once installed, replace this stub by importing and returning
|
|
4089
|
+
* `createConnectTransport(...)` from `@connectrpc/connect-web`.
|
|
4090
|
+
*
|
|
4091
|
+
* @throws Error — always, until `@connectrpc/connect` is installed.
|
|
4092
|
+
*/
|
|
4093
|
+
createGrpcTransport(): never;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* Typed error hierarchy for the Mnemosyne client SDK.
|
|
4098
|
+
*
|
|
4099
|
+
* Why a class hierarchy instead of plain Error objects:
|
|
4100
|
+
* - Consumers want to `catch` and branch on cause (timeout vs. server
|
|
4101
|
+
* 500 vs. validation 4xx). Discriminating by string-matching `.message`
|
|
4102
|
+
* is brittle across versions.
|
|
4103
|
+
* - We surface the server's `requestId` so support tickets are
|
|
4104
|
+
* immediately greppable in server logs.
|
|
4105
|
+
* - `code` mirrors the server's machine-readable error code (e.g.
|
|
4106
|
+
* "FACT_NOT_FOUND", "RATE_LIMITED") so retry/auth recovery logic
|
|
4107
|
+
* can be written without parsing English prose.
|
|
4108
|
+
*
|
|
4109
|
+
* All three errors extend `MnemosyneError` so `catch (e) { if (e
|
|
4110
|
+
* instanceof MnemosyneError) ... }` covers the whole surface.
|
|
4111
|
+
*/
|
|
4112
|
+
declare class MnemosyneError extends Error {
|
|
4113
|
+
/** A failed mutation may already have committed; inspect before replaying it. */
|
|
4114
|
+
outcomeUnknown: boolean;
|
|
4115
|
+
constructor(message: string);
|
|
4116
|
+
}
|
|
4117
|
+
/**
|
|
4118
|
+
* Thrown when the server responded with a non-2xx HTTP status.
|
|
4119
|
+
*
|
|
4120
|
+
* Includes the parsed error body (status, code, message, requestId)
|
|
4121
|
+
* so the caller can:
|
|
4122
|
+
* - Decide whether to retry (5xx vs 4xx)
|
|
4123
|
+
* - Show a useful error to the end-user (message)
|
|
4124
|
+
* - File a bug with the operator (requestId)
|
|
4125
|
+
*/
|
|
4126
|
+
declare class MnemosyneAPIError extends MnemosyneError {
|
|
4127
|
+
/** HTTP status code returned by the server (e.g. 404, 429, 500). */
|
|
4128
|
+
readonly status: number;
|
|
4129
|
+
/** Machine-readable error code from the server, when present. */
|
|
4130
|
+
readonly code: string | undefined;
|
|
4131
|
+
/** Server-generated request id for log correlation, when present. */
|
|
4132
|
+
readonly requestId: string | undefined;
|
|
4133
|
+
/** Raw parsed JSON body, in case callers need details we didn't surface. */
|
|
4134
|
+
readonly body: unknown;
|
|
4135
|
+
readonly details: unknown;
|
|
4136
|
+
readonly retryable: boolean | undefined;
|
|
4137
|
+
readonly retryAfterSeconds: number | undefined;
|
|
4138
|
+
constructor(opts: {
|
|
4139
|
+
status: number;
|
|
4140
|
+
message: string;
|
|
4141
|
+
code?: string | undefined;
|
|
4142
|
+
requestId?: string | undefined;
|
|
4143
|
+
body?: unknown;
|
|
4144
|
+
details?: unknown;
|
|
4145
|
+
retryable?: boolean;
|
|
4146
|
+
retryAfterSeconds?: number;
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* Thrown when the underlying fetch failed at the transport layer (DNS,
|
|
4151
|
+
* connection refused, TLS error, etc.). NOT thrown for HTTP error
|
|
4152
|
+
* statuses — those are MnemosyneAPIError.
|
|
4153
|
+
*
|
|
4154
|
+
* The retry layer treats this as retryable by default.
|
|
4155
|
+
*/
|
|
4156
|
+
declare class MnemosyneNetworkError extends MnemosyneError {
|
|
4157
|
+
/** The original error from fetch (or wherever the failure surfaced). */
|
|
4158
|
+
readonly cause: unknown;
|
|
4159
|
+
readonly retryable: boolean;
|
|
4160
|
+
constructor(message: string, cause: unknown, retryable?: boolean);
|
|
4161
|
+
}
|
|
4162
|
+
/**
|
|
4163
|
+
* Thrown when a request exceeded its timeout budget.
|
|
4164
|
+
*
|
|
4165
|
+
* Distinct from MnemosyneNetworkError because timeouts often indicate
|
|
4166
|
+
* the server IS working but slow — the retry policy may want to back
|
|
4167
|
+
* off more aggressively rather than hammering with rapid retries.
|
|
4168
|
+
*/
|
|
4169
|
+
declare class MnemosyneTimeoutError extends MnemosyneError {
|
|
4170
|
+
/** Configured timeout in milliseconds when the request was abandoned. */
|
|
4171
|
+
readonly timeoutMs: number;
|
|
4172
|
+
constructor(timeoutMs: number);
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
export { MnemosyneAPIError, MnemosyneClient, MnemosyneError, MnemosyneNetworkError, MnemosyneTimeoutError };
|
|
4176
|
+
export type { AgentPolicy, AgentPolicyInput, AnticipatedMemory, AnticipationFeedResponse, AppendTurnInput, AppliedFactReplaceResponse, AppliedNonFactReplaceResponse, AppliedNonReplaceResponse, ApprovePeerInput, ApprovePeerKeyResponse, Attribution, AuditEntry, AuditInput, AuditResponse, ChainStepWire, CitationMemoryKind, CitationSourceKind, CollapseSessionInput, CollapseSessionResponse, CompositionDryRunResponse, CompositionRule, ConflictFact, ConflictPair, ConflictVerdictAction, CreateDecisionInput, CreateEntityInput, CreateEventInput, CreateFactInput, CreateFactResponse, CreateHyperedgeInput, CreateKeyInput, CreateKeyResponse, CreatePeerInput, CreatePeerResponse, CreateReasoningInput, CreateRelationInput, CreateSessionInput, CreateSessionResponse, CreateSkillClientInput, CreateStrategyInput, CreateTaskInput, CreateTenantInput, CreateTenantResponse, CreateUserInput, CreateUserResponse, CreateUserTokenInput, CreateUserTokenResponse, CreateWorkspaceInput, DecisionKind, DecisionStatus, DeletePeerResponse, DerivedInference, DoctorCheck, DoctorCheckStatus, DoctorReport, EnqueueReviewInput, EnqueueReviewResponse, EntityFactsResponse, EntityKind, EntityWithCount, EpisodeWithLinkedFacts, EraseSubjectInput, EraseSubjectResponse, EventAnnotationWire, EventWire, ExportResponse, Fact, FactCitationsResponse, FederationClaim, FederationItem, FederationItemPayload, FederationSyncJob, ForgetResponse, GraphEdge, GraphInput, GraphNode, GraphResponse, HealthReadySnapshot, HealthSnapshot, HyperedgeWire, InviteTenantMemberInput, InviteWorkspaceMemberInput, IssueScopedKeyInput, IssueScopedKeyResponse, JudgmentStatus, KeyDetailResponse, KeyListItem, ListCitationsInput, ListCitationsResponse, ListConflictsResponse, ListDecisionsInput, ListDecisionsResponse, ListEntitiesInput, ListEntitiesResponse, ListEntityFactsInput, ListEpisodesInput, ListEpisodesResponse, ListEventsParams, ListFactsInput, ListFactsResponse, ListFederationItemsResponse, ListHyperedgesParams, ListPeersResponse, ListPendingPeersResponse, ListReasoningParams, ListRelationsInput, ListRelationsResponse, ListReviewInput, ListReviewResponse, ListStrategiesParams, ListTasksParams, MarkerKind, MeResponse, MemoryFact, MemoryFactKind, MemoryFactScope, MnemoCitation, MnemoDecision, MnemoEntity, MnemoEpisode, MnemoRelation, MnemosyneClientOptions, MnemosyneUser, PaginatedEventsResponse, PaginatedHyperedgesResponse, PaginatedReasoningResponse, PaginatedStrategiesResponse, PaginatedTasksResponse, PatchFactInput, PatchHyperedgeInput, PatchReasoningInput, PatchRelationInput, PatchStrategyInput, PatchTaskInput, PeerConfig, PinResponse, PinSessionTurnInput, PurgeClosedFactsResponse, PurgeFactResponse, ReasoningFeedbackInput, ReasoningWire, RecallHit, RecallInput, RecallResponse, RecordReasoningInput, RelationKind, RelationVerb, RememberConflict, RememberConflictCandidate, RequestObservation, ResolveConflictInput, ResolveConflictResponse, ResolveFederationConflictBatchInput, ResolveFederationConflictPairInput, ResolveFederationConflictResponse, ResolveReasoningInput, ResolveReasoningResponse, ResolveReviewInput, ResolveReviewResponse, RestoreFactResponse, RetryConfig, ReviewCountResponse, ReviewQueueRow, ReviewReason, ReviewResolution, RotateKeyResponse, RotateScopedKeyResponse, SealedFederationItem, SelfEditAction, SelfEditApprovalResponse, SelfEditReflectionResponse, SelfEditResponse, SelfEditTargetKind, SelfModelAspect, SelfModelResponse, SkillListResponse, SkillWire, StrategyWire, SubscribeHandle, SubscribeOptions, SupersedeDecisionInput, TaskWire, Tenant, TenantMember, TenantOwnerToken, TenantRole, TimelineEvent, TimelineInput, TimelineResponse, TraverseRelationsInput, TraverseRelationsResponse, TriggerConsolidationInput, TriggerConsolidationResponse, TriggerFederationSyncInput, TriggerFederationSyncResponse, UpdateEntityInput, UserTokenListItem, Workspace, WorkspaceListItem, WorkspaceListItemWithRole, WorkspaceMember, WorkspaceRole };
|