@sol-merrai/cli 0.2.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,31 +1,38 @@
1
- import * as _orpc_client0 from "@orpc/client";
2
-
3
- //#region src/client.d.ts
4
- type RpcProcedure<Input = unknown, Output = unknown> = (input?: Input) => Promise<readonly [unknown, Output, ...unknown[]]>;
5
- type ThrowingRpcProcedure<Input = unknown, Output = unknown> = (input?: Input) => Promise<Output>;
1
+ import { Client, ClientContext, SafeClient } from "@orpc/client";
2
+ import { RPCLink } from "@orpc/client/fetch";
3
+ import { z } from "zod";
4
+ type ThrowingRpcProcedure<Input = unknown, Output = unknown> = Client<ClientContext, Input | undefined, Output, unknown>;
5
+ type RpcProcedure<Input = unknown, Output = unknown> = SafeClient<ThrowingRpcProcedure<Input, Output>>;
6
6
  type EntityType = "person" | "event" | "action" | "knowledge" | "document";
7
7
  type JsonValue = boolean | number | string | null | JsonValue[] | {
8
8
  [key: string]: JsonValue;
9
9
  };
10
10
  interface AddMemoryInput {
11
+ idempotencyKey: string;
11
12
  memory: string;
12
13
  observationDate?: string;
13
14
  source?: string;
14
15
  lobeKey?: string;
15
16
  }
16
17
  interface AddMemoryOutput {
18
+ /** Poll `ingestionStatus` with this ID to follow processing. */
19
+ ingestionId: string;
17
20
  queued: boolean;
18
- workflowId: string;
19
21
  }
20
22
  interface AddMemoryRecallInput {
23
+ idempotencyKey: string;
24
+ /** An existing lobe of the account; the main lobe when omitted. */
25
+ lobeKey?: string;
21
26
  memory: string;
22
27
  observationDate?: string;
23
28
  }
24
29
  interface AddMemoryRecallOutput {
30
+ ingestionId: string;
25
31
  processing: true;
26
32
  status: "enqueued";
27
33
  }
28
34
  interface AddMemoriesInput {
35
+ idempotencyKey: string;
29
36
  memories: {
30
37
  memory: string;
31
38
  observationDate?: string;
@@ -34,33 +41,87 @@ interface AddMemoriesInput {
34
41
  }[];
35
42
  }
36
43
  interface AddMemoriesOutput {
37
- failures: {
38
- error: string;
39
- groupKey: string | null;
40
- }[];
44
+ ingestionId: string;
41
45
  queued: number;
42
- workflowId: string;
43
46
  }
44
47
  interface FindMemoryEntitiesInput {
45
48
  name: string;
46
49
  type?: EntityType;
47
50
  limit?: number;
48
51
  }
49
- interface MemoriesByEntityInput {
50
- entityId: string;
51
- limit?: number;
52
- }
53
- interface MemoriesByDateInput {
54
- start?: string;
55
- end?: string;
56
- limit?: number;
57
- }
52
+ /**
53
+ * How a known time relates to what it dates: it took place then, it is
54
+ * planned for then, or it is due then (a deadline). Absent or null on times
55
+ * recorded before roles existed: unspecified.
56
+ */
57
+ type EventTimeRole = "happened" | "planned" | "due";
58
+ type EventTime = {
59
+ precision: "day" | "week" | "month" | "year";
60
+ value: string;
61
+ phrase: string | null;
62
+ role?: EventTimeRole | null;
63
+ } | {
64
+ /** A span of calendar days, both ends included. */
65
+ precision: "range";
66
+ start: string;
67
+ end: string;
68
+ phrase: string | null;
69
+ role?: EventTimeRole | null;
70
+ } | {
71
+ precision: "unknown";
72
+ value: null;
73
+ phrase: string | null;
74
+ role?: null;
75
+ };
76
+ type MemoryEventTime = EventTime | {
77
+ precision: "multiple";
78
+ alternatives: EventTime[];
79
+ };
58
80
  interface MemoryRecallResult {
81
+ eventTime: MemoryEventTime | null;
59
82
  category: string | null;
60
83
  content: string;
61
84
  id: string;
62
85
  lobeKey: string;
63
- recordedAt: string;
86
+ recordedAt: string | null;
87
+ }
88
+ /** The earlier value a Memory replaced: the latest Memory it supersedes. */
89
+ interface MemoryReplacement {
90
+ content: string;
91
+ eventTime: MemoryEventTime | null;
92
+ }
93
+ /**
94
+ * A current memory an update mark ties to a search result. A later value
95
+ * never retires the earlier one: both stay current.
96
+ */
97
+ interface MemoryUpdateMark {
98
+ /**
99
+ * updated_by: the linked memory is a newer value of something the result
100
+ * states, shown under it as "↳ updated by: …". updates: the result is a
101
+ * newer value of something the linked memory states, shown as
102
+ * "replaces: …".
103
+ */
104
+ relation: "updated_by" | "updates";
105
+ id: string;
106
+ content: string;
107
+ eventTime: MemoryEventTime | null;
108
+ /** The day the linked memory was last said (YYYY-MM-DD); null when unknown. */
109
+ said: string | null;
110
+ }
111
+ /** A search result: a recall result plus what it replaced. */
112
+ interface SearchMemoryRecallResult extends MemoryRecallResult {
113
+ /**
114
+ * Shown under it as "replaces: …" (renderMemoryReplacement). Null when it
115
+ * replaced none; absent from servers that predate it.
116
+ */
117
+ replaces?: MemoryReplacement | null;
118
+ /**
119
+ * The current memories update marks tie to it, newer values first
120
+ * (renderMemoryUpdateMarks). Absent from servers that predate it.
121
+ */
122
+ linked?: MemoryUpdateMark[];
123
+ /** True for a guess from what the user asked, which no source states. */
124
+ inferred?: boolean;
64
125
  }
65
126
  interface FindMemoryEntitiesOutput {
66
127
  entities: {
@@ -70,38 +131,60 @@ interface FindMemoryEntitiesOutput {
70
131
  name: string;
71
132
  type: EntityType;
72
133
  }[];
73
- suggestedNextAction: {
74
- entityIds: string[];
75
- tool: "search_memories_by_entity";
76
- when: string;
77
- } | null;
78
134
  }
79
- interface SearchMemoryRecallInput {
135
+ /**
136
+ * MCP search_memories' selectors: at least one of query, an entity (id, or
137
+ * name with an optional type), start or end. Date bounds are inclusive ISO
138
+ * 8601 bounds on when a memory was recorded.
139
+ */
140
+ interface SearchMemoriesRecallInput {
141
+ end?: string;
142
+ entityId?: string;
143
+ entityName?: string;
144
+ entityType?: EntityType;
145
+ /** 1-25; defaults to 10. */
80
146
  limit?: number;
81
- query: string;
82
- }
83
- interface SearchMemoryRecallOutput {
84
- memories: MemoryRecallResult[];
85
- suggestedNextAction: {
86
- consentRequired: true;
87
- tool: "add_memory";
88
- when: string;
89
- } | null;
90
- }
91
- interface MemoriesByEntityOutput {
92
- entity: {
93
- displayName: string;
94
- id: string;
95
- type: EntityType;
96
- };
97
- memories: MemoryRecallResult[];
147
+ /** One of the caller's lobes to search instead of the owner-recall lobes. */
148
+ lobeKey?: string;
149
+ query?: string;
150
+ start?: string;
151
+ /** Memories carrying at least one of these topic keys. */
152
+ topics?: string[];
153
+ about?: MemoryAbout;
154
+ /** Memories with one of these stances. */
155
+ stance?: MemoryStance[];
98
156
  }
99
- interface MemoriesByDateOutput {
100
- memories: MemoryRecallResult[];
101
- range: {
157
+ /** Who a memory is about: the account owner, someone else, or no one. */
158
+ type MemoryAbout = "none" | "other" | "owner";
159
+ /** A stated fact, someone's view, or a decision. */
160
+ type MemoryStance = "decision" | "inferred" | "reported" | "view";
161
+ /** MCP search_memories' reply. */
162
+ interface SearchMemoriesRecallOutput {
163
+ appliedFilters: {
102
164
  end: string | null;
165
+ entityId: string | null;
166
+ entityName: string | null;
167
+ entityType: EntityType | null;
168
+ query: string | null;
103
169
  start: string | null;
170
+ /** Absent from servers that predate label filters. */
171
+ lobeKey?: string | null;
172
+ topics?: string[];
173
+ about?: MemoryAbout | null;
174
+ stance?: MemoryStance[];
104
175
  };
176
+ /** Several entries with status needs_disambiguation: choose one by id. */
177
+ matchedEntities: {
178
+ displayName: string;
179
+ id: string;
180
+ memoryCount: number;
181
+ name: string;
182
+ type: EntityType;
183
+ }[];
184
+ memories: SearchMemoryRecallResult[];
185
+ status: "complete" | "needs_disambiguation";
186
+ /** Undated memories a start/end bound could not include. */
187
+ undatedExcludedCount: number;
105
188
  }
106
189
  interface MemoryOverviewOutput {
107
190
  account: {
@@ -112,24 +195,33 @@ interface MemoryOverviewOutput {
112
195
  workplace: string | null;
113
196
  };
114
197
  profile: {
198
+ dynamicContext: (Omit<MemoryRecallResult, "id"> & {
199
+ profileExpiresAt: string;
200
+ })[];
115
201
  facts: Omit<MemoryRecallResult, "id">[];
116
202
  ongoingContext: Omit<MemoryRecallResult, "id">[];
117
203
  scope: string;
118
- suggestions: {
119
- expiresAt: string | null;
120
- text: string;
121
- }[];
122
204
  updatedAt: string;
123
205
  } | null;
124
- suggestedNextAction: {
125
- tool: "search_memory";
126
- when: string;
206
+ refresh: {
207
+ candidateMemoryCount: number;
208
+ status: "current" | "failed" | "queued";
127
209
  };
128
210
  }
129
211
  interface ListLivingDocumentsInput {
130
212
  status?: ("enabled" | "disabled" | "archived")[];
131
213
  }
132
214
  type LivingDocumentStatus = "enabled" | "disabled" | "archived";
215
+ /**
216
+ * Which of the user's lobes a document takes Memories from: every lobe
217
+ * (including ones created later) or only the listed ones.
218
+ */
219
+ type LivingDocumentLobeScope = {
220
+ kind: "all";
221
+ } | {
222
+ kind: "selected";
223
+ lobeKeys: string[];
224
+ };
133
225
  interface LivingDocument {
134
226
  autoPublish: boolean;
135
227
  createdAt: string;
@@ -139,7 +231,30 @@ interface LivingDocument {
139
231
  entities: string[];
140
232
  extractionPrompt: string;
141
233
  id: string;
234
+ /**
235
+ * Set while saved Memories of newly added lobes are brought in: `pending`
236
+ * while running, `failed` if unfinished (`retryLivingDocumentLobeBackfill`).
237
+ * Absent from servers before lobe scopes; `status` is absent from servers
238
+ * before backfill failures, where every backfill is pending.
239
+ */
240
+ lobeBackfill?: {
241
+ lobeKeys: string[];
242
+ requestedAt: string;
243
+ status?: "failed" | "pending";
244
+ } | null;
245
+ lobeScope?: LivingDocumentLobeScope;
142
246
  patchFailureCount: number;
247
+ /**
248
+ * Set while the document is rebuilt without Memories from deleted sources
249
+ * (`memory_removed`, also when `reason` is absent) or removed lobes
250
+ * (`lobe_scope_narrowed`). `pending`/`failed` as for `lobeBackfill` (retry
251
+ * with `retryLivingDocumentRebuild`); content is withheld meanwhile.
252
+ */
253
+ rebuild: {
254
+ reason?: "lobe_scope_narrowed" | "memory_removed";
255
+ requestedAt: string | null;
256
+ status: "failed" | "pending";
257
+ } | null;
143
258
  routingSummary: string | null;
144
259
  routingSummaryDirty: boolean;
145
260
  status: LivingDocumentStatus;
@@ -184,44 +299,51 @@ interface ListLivingDocumentsOutput {
184
299
  }
185
300
  interface ListLivingDocumentsRecallOutput {
186
301
  documents: {
187
- autoPublish: boolean;
188
302
  currentVersion: {
189
303
  createdAt: string;
190
304
  number: number;
191
305
  } | null;
192
306
  id: string;
307
+ /** Absent from a server that predates lobe scopes. */
308
+ lobeScope?: LivingDocumentLobeScope;
193
309
  status: string;
194
310
  summary: string;
195
311
  title: string;
196
312
  }[];
313
+ pagination: {
314
+ limit: number;
315
+ nextOffset: number | null;
316
+ offset: number;
317
+ };
318
+ }
319
+ interface ListLivingDocumentsRecallInput {
320
+ limit?: number;
321
+ offset?: number;
197
322
  }
198
323
  interface ReadLivingDocumentRecallInput {
324
+ contentOffset?: number;
199
325
  documentId: string;
326
+ maxCharacters?: number;
200
327
  }
201
328
  interface ReadLivingDocumentRecallOutput {
202
329
  document: {
203
- activeShares: {
204
- expiresAt: string | null;
205
- mode: string;
206
- permissions: string;
207
- url: string;
208
- versionId: string | null;
209
- }[];
210
- autoPublish: boolean;
211
330
  currentVersion: {
212
331
  contentMarkdown: string;
332
+ contentOffset: number;
213
333
  createdAt: string;
214
- id: string;
334
+ nextContentOffset: number | null;
215
335
  number: number;
336
+ returnedCharacters: number;
337
+ totalCharacters: number;
216
338
  } | null;
217
339
  description: string | null;
218
- entities: string[];
219
340
  headings: string[];
220
341
  id: string;
342
+ /** Absent from a server that predates lobe scopes. */
343
+ lobeScope?: LivingDocumentLobeScope;
221
344
  status: string;
222
345
  summary: string;
223
346
  title: string;
224
- triggerKeywords: string[];
225
347
  };
226
348
  }
227
349
  interface GetLivingDocumentOutput {
@@ -238,74 +360,55 @@ interface ListLivingDocumentSharesInput {
238
360
  documentId: string;
239
361
  }
240
362
  interface AddChatSessionInput {
363
+ idempotencyKey: string;
241
364
  memories: {
242
365
  memory: string;
366
+ observationDate?: string;
243
367
  source?: string;
244
368
  }[];
245
369
  lobeKey?: string;
246
370
  source?: string;
247
- sessionMetadata?: Record<string, unknown>;
371
+ sessionMetadata?: Record<string, JsonValue>;
248
372
  }
249
373
  interface AddChatSessionOutput {
374
+ ingestionId: string;
250
375
  queued: number;
251
- workflowId: string;
252
376
  }
253
377
  interface AddChatSessionsInput {
254
378
  lobeKey?: string;
255
379
  source?: string;
256
- questionMetadata?: Record<string, unknown>;
257
- /**
258
- * Override the V3 extractor's prompt profile.
259
- * - `general` — default chat-ingest extraction.
260
- * - `agent` — agent-scoped ingests (no user, only agent_id).
261
- * - `code-personal` — coding-session bias (developer intent over
262
- * assistant scaffolding, code-specific entities).
263
- * When omitted, the server resolves a profile from `source`
264
- * (e.g. `claude-code` → `code-personal`); use this only to override
265
- * that mapping or for sources the server hasn't pre-mapped.
266
- */
267
- extractionProfile?: "general" | "agent" | "code-personal";
380
+ questionMetadata?: Record<string, JsonValue>;
268
381
  /**
269
- * Optional idempotency key (1-64 chars, [A-Za-z0-9_-]). When supplied,
270
- * retries with the same key short-circuit on the server instead of
271
- * re-running the ingest pipeline. Derive deterministically from
272
- * (sessionId, turnRange) so retries collide but distinct flushes do not.
382
+ * Idempotency key (1-64 chars, [A-Za-z0-9_-]). A retry with the same key and
383
+ * payload joins the first ingestion; reusing a key with other content is
384
+ * refused with CONFLICT (`IDEMPOTENCY_KEY_REUSED`), so derive it from content.
273
385
  */
274
- idempotencyKey?: string;
386
+ idempotencyKey: string;
275
387
  sessions: {
276
388
  sessionId: string;
277
- metadata?: Record<string, unknown>;
389
+ /**
390
+ * Opaque session metadata. `date` is the session's source time, in the
391
+ * same format as a turn's `sourceTime`; it dates every turn without its
392
+ * own time and cannot change once stored.
393
+ */
394
+ metadata?: Record<string, JsonValue>;
278
395
  turns: {
279
396
  content: string;
280
397
  role: "user" | "assistant";
398
+ /**
399
+ * When the turn was said: an ISO 8601 instant with an offset
400
+ * (`2026-03-04T09:30:00Z`) or a local calendar date (`2026-03-04`).
401
+ * Part of the turn's identity: a resent turn must repeat it exactly.
402
+ */
403
+ sourceTime?: string;
281
404
  speaker?: string;
282
405
  turnIndex: number;
283
406
  }[];
284
407
  }[];
285
408
  }
286
409
  interface AddChatSessionsOutput {
410
+ ingestionId: string;
287
411
  queuedSessions: number;
288
- workflowId: string;
289
- }
290
- interface SearchMemoriesInput {
291
- query: string;
292
- lobeKey?: string;
293
- limit?: number;
294
- threshold?: number;
295
- mode?: "fast" | "adaptive" | "reflective";
296
- graph?: {
297
- enabled?: boolean;
298
- maxNeighborsPerSeed?: number;
299
- maxTotalNeighbors?: number;
300
- };
301
- }
302
- interface SearchMemoryHit {
303
- category: string | null;
304
- content: string;
305
- id: string;
306
- memoryDate: string;
307
- score: number;
308
- summary: string | null;
309
412
  }
310
413
  interface MemoryStatusInput {
311
414
  lobeKey?: string;
@@ -316,24 +419,275 @@ interface MemoryStatusOutput {
316
419
  interface ClearLobeInput {
317
420
  lobeKey: string;
318
421
  }
422
+ /**
423
+ * A lobe clear runs as durable server work. `clearLobe` starts it (or joins
424
+ * the clear already running for the lobe); `clearLobeStatus` follows it.
425
+ */
319
426
  interface ClearLobeOutput {
427
+ clearId: string;
428
+ completedAt: string | null;
429
+ /** Memories removed so far; final once `status` is `complete`. */
320
430
  deleted: number;
431
+ deletedSources: number;
432
+ lobeKey: string;
433
+ remainingSources: number;
434
+ startedAt: string;
435
+ status: "complete" | "failed" | "running";
321
436
  }
437
+ /** Omitted `lobeKey` means every lobe of the caller. */
438
+ interface MemoryBackfillInput {
439
+ lobeKey?: string;
440
+ }
441
+ /** A label backfill: the caller's run and each requested lobe's progress. */
442
+ interface MemoryBackfillStatusOutput {
443
+ /** Why deciding views' bases last failed: retried while running, kept once given up. */
444
+ lastError: string | null;
445
+ lobes: {
446
+ completedAt: string | null;
447
+ /** Observations the current or last pass labelled. */
448
+ labelled: number;
449
+ lastError: string | null;
450
+ lobeKey: string;
451
+ /** `failed` is retried by the next start. */
452
+ state: "complete" | "failed" | "queued" | "running";
453
+ /** Observations that needed labels when that pass began. */
454
+ total: number;
455
+ updatedAt: string;
456
+ }[];
457
+ status: "complete" | "never" | "running";
458
+ }
459
+ /** Omitted `lobeKey` means every lobe of the caller. */
460
+ interface MemorySynthesisInput {
461
+ lobeKey?: string;
462
+ }
463
+ /** The caller's pattern and style synthesis and each requested lobe's state. */
464
+ interface MemorySynthesisStatusOutput {
465
+ lobes: {
466
+ lastError: string | null;
467
+ lobeKey: string;
468
+ /** The pass waits until this time; a start runs it now. */
469
+ notBefore: string;
470
+ patternCount: number;
471
+ patternsBuiltAt: string | null;
472
+ /** `failed` is retried by the next start or ingestion. */
473
+ state: "complete" | "failed" | "pending";
474
+ styleBuiltAt: string | null;
475
+ }[];
476
+ status: "complete" | "never" | "running";
477
+ }
478
+ /** Omitted `lobeKey` reads main, where the owner's own chats and notes are kept. */
479
+ interface GetStyleProfileInput {
480
+ /** Omit or true for the passages' text; false reads the summary only. */
481
+ includeExemplars?: boolean;
482
+ lobeKey?: string;
483
+ }
484
+ /** How the owner writes, built only from their own words. */
485
+ interface GetStyleProfileOutput {
486
+ lobeKey: string;
487
+ style: {
488
+ builtAt: string;
489
+ /** Passages shown as exemplars, whether or not their text was read. */
490
+ exemplarCount: number;
491
+ exemplars: {
492
+ id: string;
493
+ recordedAt: string | null;
494
+ text: string;
495
+ }[];
496
+ sampleSize: number;
497
+ summary: {
498
+ aspect: "length" | "structure" | "tone" | "vocabulary";
499
+ exemplarIds: string[];
500
+ text: string;
501
+ }[];
502
+ } | null;
503
+ }
504
+ interface ClearLobeStatusInput {
505
+ clearId: string;
506
+ }
507
+ interface RetryLivingDocumentRebuildInput {
508
+ id: string;
509
+ }
510
+ interface RetryLivingDocumentRebuildOutput {
511
+ document: LivingDocument;
512
+ }
513
+ interface RetryLivingDocumentLobeBackfillInput {
514
+ id: string;
515
+ }
516
+ interface RetryLivingDocumentLobeBackfillOutput {
517
+ document: LivingDocument;
518
+ }
519
+ interface CreateLobeInput {
520
+ lobeKey: string;
521
+ }
522
+ interface CreateLobeOutput {
523
+ lobeKey: string;
524
+ }
525
+ interface ListLobesOutput {
526
+ createdAt: string;
527
+ lobeKey: string;
528
+ /** What the lobe is called wherever it is shown. */
529
+ name: string;
530
+ /** Whether the owner's agent and default recall read this lobe. */
531
+ ownerRecall: boolean;
532
+ /** What this lobe is for, given to extraction as focus. */
533
+ purpose: string | null;
534
+ updatedAt: string;
535
+ }
536
+ /** Where a page of lobes ended; pass it back unchanged. */
537
+ interface LobesCursor {
538
+ createdAt: string;
539
+ lobeKey: string;
540
+ }
541
+ interface ListLobesPageInput {
542
+ cursor?: LobesCursor;
543
+ /** 1-50; defaults to 20. */
544
+ limit?: number;
545
+ }
546
+ /** One of the caller's lobes as a page lists it, oldest first. */
547
+ interface LobePageItem {
548
+ lobeKey: string;
549
+ /** What the lobe is called wherever it is shown. */
550
+ name: string;
551
+ /** Whether the owner's agent and default recall read this lobe. */
552
+ ownerRecall: boolean;
553
+ purpose: string | null;
554
+ }
555
+ interface ListLobesPageOutput {
556
+ lobes: LobePageItem[];
557
+ nextCursor: LobesCursor | null;
558
+ }
559
+ interface UpdateLobeInput {
560
+ lobeKey: string;
561
+ ownerRecall?: boolean;
562
+ /** Null clears the purpose. */
563
+ purpose?: string | null;
564
+ }
565
+ /** Omitted `lobeKey` means every lobe of the user. */
566
+ interface MemoryTopicScopeInput {
567
+ lobeKey?: string;
568
+ }
569
+ interface SetMemoryTopicInput extends MemoryTopicScopeInput {
570
+ description: string;
571
+ key: string;
572
+ }
573
+ interface RetireMemoryTopicInput extends MemoryTopicScopeInput {
574
+ key: string;
575
+ }
576
+ /** A lobe's topic catalogue: built-ins, then the user's and the lobe's changes. */
577
+ interface MemoryTopicCatalogueOutput {
578
+ topics: {
579
+ description: string;
580
+ key: string;
581
+ origin: "core" | "lobe" | "user";
582
+ }[];
583
+ lobeKey: string | null;
584
+ }
585
+ /** Where a page of open items ended; pass it back unchanged. */
586
+ interface OpenItemsCursor {
587
+ /** The first page's day; later pages keep counting from it. */
588
+ asOf: string;
589
+ id: string;
590
+ startsOn: string;
591
+ }
592
+ /** Omitted `lobeKey` reads the owner-recall lobes; `asOf` defaults to today in UTC. */
593
+ interface ListOpenItemsInput {
594
+ asOf?: string;
595
+ cursor?: OpenItemsCursor;
596
+ /** 1-50; defaults to 20. */
597
+ limit?: number;
598
+ lobeKey?: string;
599
+ until?: string;
600
+ }
601
+ /** A current memory planned or due ahead, or a decision still ahead. */
602
+ interface OpenItem {
603
+ category: string | null;
604
+ content: string;
605
+ eventTime: MemoryEventTime;
606
+ id: string;
607
+ lobeKey: string;
608
+ recordedAt: string | null;
609
+ role: "due" | "planned" | null;
610
+ stance: MemoryStance | null;
611
+ /** First day of its earliest time still ahead (YYYY-MM-DD). */
612
+ startsOn: string;
613
+ topics: string[];
614
+ }
615
+ interface ListOpenItemsOutput {
616
+ asOf: string;
617
+ items: OpenItem[];
618
+ nextCursor: OpenItemsCursor | null;
619
+ }
620
+ /** Where a page of judgments ended; pass it back unchanged. */
621
+ interface JudgmentsCursor {
622
+ createdAt: string;
623
+ id: string;
624
+ }
625
+ interface ListJudgmentsInput {
626
+ cursor?: JudgmentsCursor;
627
+ /** 1-50; defaults to 20. */
628
+ limit?: number;
629
+ lobeKey?: string;
630
+ reviewState?: "evidence_changed";
631
+ stance?: "decision" | "view";
632
+ }
633
+ /** A current view or decision with the facts it was formed on. */
634
+ interface Judgment {
635
+ basis: {
636
+ content: string;
637
+ /** False once the fact was replaced or expired. */
638
+ current: boolean;
639
+ id: string;
640
+ link: "rests_on" | "weighs_against";
641
+ }[];
642
+ content: string;
643
+ eventTime: MemoryEventTime | null;
644
+ holder: string | null;
645
+ id: string;
646
+ lobeKey: string;
647
+ recordedAt: string | null;
648
+ reviewState: "evidence_changed" | null;
649
+ stance: "decision" | "view";
650
+ topics: string[];
651
+ }
652
+ interface ListJudgmentsOutput {
653
+ items: Judgment[];
654
+ nextCursor: JudgmentsCursor | null;
655
+ }
656
+ /** A current memory as `memories` lists it, with its update marks. */
322
657
  interface MemoryListItem {
658
+ eventTime: MemoryEventTime | null;
323
659
  category: string | null;
324
660
  content: string;
325
661
  createdAt: string;
326
662
  expiresAt: string | null;
327
663
  id: string;
328
- isCurrent: string;
664
+ /** Current memories an update mark ties to this one. */
665
+ linked: MemoryUpdateMark[];
329
666
  lobeKey: string;
330
667
  memoryAt: string | null;
331
668
  memoryKind: string;
332
- metadata: JsonValue | null;
669
+ /** When its source recorded it; null when unknown. */
670
+ recordedAt: string | null;
671
+ /** The earlier value this memory replaced. */
672
+ replaces: MemoryReplacement | null;
333
673
  summary: string | null;
334
- supersededByMemoryId: string | null;
335
674
  updatedAt: string;
336
675
  }
676
+ /** Where a `memories` page ended; pass it back unchanged. */
677
+ interface MemoriesCursor {
678
+ createdAt: string;
679
+ id: string;
680
+ }
681
+ interface MemoriesInput {
682
+ cursor?: MemoriesCursor | null;
683
+ /** 1-100; the server's default is 50. */
684
+ limit?: number;
685
+ lobeKey?: string;
686
+ }
687
+ interface MemoriesOutput {
688
+ items: MemoryListItem[];
689
+ nextCursor: MemoriesCursor | null;
690
+ }
337
691
  interface AuthSessionOutput {
338
692
  session: {
339
693
  createdAt: string | null;
@@ -372,6 +726,8 @@ interface UsageSummaryOutput {
372
726
  billing: {
373
727
  hasPaidPlan: boolean;
374
728
  plan: UsagePlan;
729
+ /** A personal subscription or an organisation seat; null on the free plan. */
730
+ planSource: "personal" | "organisation" | null;
375
731
  scheduledDowngradeAt: string | null;
376
732
  };
377
733
  llm: {
@@ -442,7 +798,9 @@ interface GetSessionStartContextInput {
442
798
  * Caller-side budget. Server hard caps both numbers regardless.
443
799
  */
444
800
  budget?: {
445
- /** Default 15, hard cap 30. */maxMemories?: number; /** Default 2000, hard cap 4000. Char-based estimate (chars / 4). */
801
+ /** Default 15, hard cap 30. */
802
+ maxMemories?: number;
803
+ /** Default 2000, hard cap 4000. Char-based estimate (chars / 4). */
446
804
  maxTokens?: number;
447
805
  };
448
806
  }
@@ -456,6 +814,141 @@ interface GetSessionStartContextOutput {
456
814
  /** Server-side ISO 8601 timestamp the context was generated. */
457
815
  generatedAt: string;
458
816
  }
817
+ type SourceKind = "agent_conversation" | "external_chat" | "imported_chat" | "manual_entry" | "memory_source" | "upload";
818
+ /**
819
+ * pending: stored, awaiting extraction. processing: extraction or memory
820
+ * creation is running or will resume. partial: some windows failed, the rest
821
+ * created memories. failed: not fetched, converted or processed. complete:
822
+ * extraction finished and its memories were created. deleted: deleted.
823
+ */
824
+ type SourceProcessingStatus = "complete" | "deleted" | "failed" | "partial" | "pending" | "processing";
825
+ type SourceAction = "delete" | "reprocess" | "retry_blocked_windows";
826
+ /**
827
+ * Where a source came from. Agent chat: app (web, desktop or mobile), voice,
828
+ * telegram, whatsapp, slack, discord or linear. Synced or plugin-imported chat:
829
+ * its provider. Also granola and upload. Saved entry: app, mcp, api (an API
830
+ * key: this CLI, the Claude Code plugin or a script) or onboarding.
831
+ */
832
+ type SourceOrigin = string;
833
+ type SourceDetailRoute = {
834
+ entryId: string;
835
+ kind: "manual_entry";
836
+ } | {
837
+ connectionId: string;
838
+ conversationId: string;
839
+ kind: "external_chat";
840
+ provider: string;
841
+ } | {
842
+ kind: "imported_chat";
843
+ sessionKey: string;
844
+ source: string;
845
+ } | {
846
+ connectionId: string;
847
+ itemId: string;
848
+ kind: "memory_source";
849
+ provider: string;
850
+ } | {
851
+ conversationKey: string;
852
+ kind: "agent_conversation";
853
+ lobeKey: string;
854
+ } | {
855
+ kind: "upload";
856
+ uploadId: string;
857
+ };
858
+ interface SourceArtifact {
859
+ artifactId: string;
860
+ artifactType: string;
861
+ availableActions: SourceAction[];
862
+ blockedWindows: number;
863
+ createdAt: string;
864
+ detailRoute: SourceDetailRoute | null;
865
+ lastActivityAt: string;
866
+ lobeKey: string;
867
+ memoryCount: number;
868
+ /** Null when Merrai did not record it (some older sources) and once deleted. */
869
+ origin: SourceOrigin | null;
870
+ pausedReason: "quota_exceeded" | null;
871
+ retryableBlockedWindows: number;
872
+ sourceId: string;
873
+ sourceKind: SourceKind;
874
+ sourceProvider: string | null;
875
+ status: SourceProcessingStatus;
876
+ title: string;
877
+ updatedAt: string;
878
+ }
879
+ interface SourceArtifactCursor {
880
+ createdAt: string;
881
+ id: string;
882
+ }
883
+ interface SourceArtifactListInput {
884
+ cursor?: SourceArtifactCursor;
885
+ limit?: number;
886
+ lobeKey?: string;
887
+ providers?: string[];
888
+ sourceKinds?: SourceKind[];
889
+ statuses?: SourceProcessingStatus[];
890
+ }
891
+ interface SourceArtifactListOutput {
892
+ items: SourceArtifact[];
893
+ /** A status-filtered page may be short while more remain. */
894
+ nextCursor: SourceArtifactCursor | null;
895
+ }
896
+ interface SourceArtifactReferenceInput {
897
+ artifactId: string;
898
+ }
899
+ interface SourceArtifactDeleteOutput {
900
+ ok: true;
901
+ sourceKind: SourceKind;
902
+ }
903
+ interface IngestionReferenceInput {
904
+ ingestionId: string;
905
+ }
906
+ interface IngestionEnqueuedOutput {
907
+ /** Poll `ingestionStatus` with this ID to follow processing. */
908
+ ingestionId: string;
909
+ status: "enqueued";
910
+ }
911
+ type IngestionRuntimeStatus = "complete" | "errored" | "paused" | "queued" | "running" | "terminated" | "unknown" | "waiting" | "waitingForEvent" | "waitingForPause";
912
+ type IngestionMemoryResult = {
913
+ created: number;
914
+ reinforced: number;
915
+ status: "completed";
916
+ updated: number;
917
+ } | {
918
+ reason: "source_deleted" | "source_policy";
919
+ status: "skipped";
920
+ } | {
921
+ reason: "bootstrap_required" | "incomplete_observations";
922
+ status: "deferred";
923
+ } | {
924
+ created: number;
925
+ reason: "repair_scheduled";
926
+ reinforced: number;
927
+ status: "deferred";
928
+ updated: number;
929
+ };
930
+ interface IngestionResult {
931
+ artifacts: {
932
+ artifactId: string;
933
+ lobeKey: string;
934
+ sourceEntryId: string;
935
+ }[];
936
+ memory: IngestionMemoryResult;
937
+ observation: {
938
+ blockedWindows?: number;
939
+ retryableBlockedWindows?: number;
940
+ status: "completed" | "deferred" | "partial" | "skipped";
941
+ };
942
+ status: "completed";
943
+ }
944
+ interface IngestionStatusOutput {
945
+ attempt: number;
946
+ error: "INGESTION_FAILED" | null;
947
+ ingestionId: string;
948
+ pausedReason: "quota_exceeded" | null;
949
+ result: IngestionResult | null;
950
+ status: IngestionRuntimeStatus;
951
+ }
459
952
  interface MerraiProcedureContract {
460
953
  addChatSession: {
461
954
  input: AddChatSessionInput;
@@ -477,6 +970,14 @@ interface MerraiProcedureContract {
477
970
  input: ClearLobeInput;
478
971
  output: ClearLobeOutput;
479
972
  };
973
+ clearLobeStatus: {
974
+ input: ClearLobeStatusInput;
975
+ output: ClearLobeOutput;
976
+ };
977
+ createLobe: {
978
+ input: CreateLobeInput;
979
+ output: CreateLobeOutput;
980
+ };
480
981
  findMemoryEntities: {
481
982
  input: FindMemoryEntitiesInput;
482
983
  output: FindMemoryEntitiesOutput;
@@ -485,6 +986,10 @@ interface MerraiProcedureContract {
485
986
  input: GetLivingDocumentInput;
486
987
  output: GetLivingDocumentOutput;
487
988
  };
989
+ getStyleProfile: {
990
+ input: GetStyleProfileInput;
991
+ output: GetStyleProfileOutput;
992
+ };
488
993
  getSessionStartContext: {
489
994
  input: GetSessionStartContextInput;
490
995
  output: GetSessionStartContextOutput;
@@ -493,93 +998,468 @@ interface MerraiProcedureContract {
493
998
  input: undefined;
494
999
  output: "OK";
495
1000
  };
1001
+ ingestionStatus: {
1002
+ input: IngestionReferenceInput;
1003
+ output: IngestionStatusOutput;
1004
+ };
496
1005
  listLivingDocuments: {
497
1006
  input: ListLivingDocumentsInput;
498
1007
  output: ListLivingDocumentsOutput;
499
1008
  };
1009
+ listTopics: {
1010
+ input: MemoryTopicScopeInput;
1011
+ output: MemoryTopicCatalogueOutput;
1012
+ };
1013
+ listLobes: {
1014
+ input: undefined;
1015
+ output: ListLobesOutput[];
1016
+ };
1017
+ listLobesPage: {
1018
+ input: ListLobesPageInput;
1019
+ output: ListLobesPageOutput;
1020
+ };
1021
+ listJudgments: {
1022
+ input: ListJudgmentsInput;
1023
+ output: ListJudgmentsOutput;
1024
+ };
1025
+ listOpenItems: {
1026
+ input: ListOpenItemsInput;
1027
+ output: ListOpenItemsOutput;
1028
+ };
500
1029
  listLivingDocumentShares: {
501
1030
  input: ListLivingDocumentSharesInput;
502
1031
  output: ListLivingDocumentSharesOutput;
503
1032
  };
504
1033
  memories: {
505
- input: undefined;
506
- output: MemoryListItem[];
507
- };
508
- memoriesByDate: {
509
- input: MemoriesByDateInput;
510
- output: MemoriesByDateOutput;
511
- };
512
- memoriesByEntity: {
513
- input: MemoriesByEntityInput;
514
- output: MemoriesByEntityOutput;
1034
+ input: MemoriesInput | undefined;
1035
+ output: MemoriesOutput;
515
1036
  };
516
1037
  memoryOverview: {
517
- input: undefined;
1038
+ input: {
1039
+ lobeKey?: string;
1040
+ } | undefined;
518
1041
  output: MemoryOverviewOutput;
519
1042
  };
1043
+ memoryBackfillStatus: {
1044
+ input: MemoryBackfillInput;
1045
+ output: MemoryBackfillStatusOutput;
1046
+ };
520
1047
  memoryStatus: {
521
1048
  input: MemoryStatusInput;
522
1049
  output: MemoryStatusOutput;
523
1050
  };
524
- searchMemories: {
525
- input: SearchMemoriesInput;
526
- output: SearchMemoryHit[];
1051
+ memorySynthesisStatus: {
1052
+ input: MemorySynthesisInput;
1053
+ output: MemorySynthesisStatusOutput;
1054
+ };
1055
+ retireTopic: {
1056
+ input: RetireMemoryTopicInput;
1057
+ output: MemoryTopicCatalogueOutput;
1058
+ };
1059
+ retryIngestionBlockedWindows: {
1060
+ input: IngestionReferenceInput;
1061
+ output: IngestionEnqueuedOutput;
1062
+ };
1063
+ retryLivingDocumentLobeBackfill: {
1064
+ input: RetryLivingDocumentLobeBackfillInput;
1065
+ output: RetryLivingDocumentLobeBackfillOutput;
1066
+ };
1067
+ retryLivingDocumentRebuild: {
1068
+ input: RetryLivingDocumentRebuildInput;
1069
+ output: RetryLivingDocumentRebuildOutput;
527
1070
  };
528
1071
  session: {
529
1072
  input: undefined;
530
1073
  output: AuthSessionOutput | null;
531
1074
  };
1075
+ setTopic: {
1076
+ input: SetMemoryTopicInput;
1077
+ output: MemoryTopicCatalogueOutput;
1078
+ };
1079
+ startMemoryBackfill: {
1080
+ input: MemoryBackfillInput;
1081
+ output: MemoryBackfillStatusOutput;
1082
+ };
1083
+ startMemorySynthesis: {
1084
+ input: MemorySynthesisInput;
1085
+ output: MemorySynthesisStatusOutput;
1086
+ };
1087
+ sourceArtifactDelete: {
1088
+ input: SourceArtifactReferenceInput;
1089
+ output: SourceArtifactDeleteOutput;
1090
+ };
1091
+ sourceArtifactGet: {
1092
+ input: SourceArtifactReferenceInput;
1093
+ output: SourceArtifact;
1094
+ };
1095
+ sourceArtifactList: {
1096
+ input: SourceArtifactListInput;
1097
+ output: SourceArtifactListOutput;
1098
+ };
1099
+ sourceArtifactReprocess: {
1100
+ input: SourceArtifactReferenceInput;
1101
+ output: IngestionEnqueuedOutput;
1102
+ };
1103
+ sourceArtifactRetry: {
1104
+ input: SourceArtifactReferenceInput;
1105
+ output: IngestionEnqueuedOutput;
1106
+ };
1107
+ updateLobe: {
1108
+ input: UpdateLobeInput;
1109
+ output: ListLobesOutput;
1110
+ };
532
1111
  usageSummary: {
533
1112
  input: undefined;
534
1113
  output: UsageSummaryOutput;
535
1114
  };
536
1115
  }
1116
+ /** JSON an App Artifact handler takes or returns. */
1117
+ type AppArtifactJson = null | boolean | number | string | AppArtifactJson[] | {
1118
+ [key: string]: AppArtifactJson;
1119
+ };
1120
+ type AppArtifactCallKind = "query" | "mutation" | "action";
1121
+ /** One query, mutation or action a Version declares. */
1122
+ interface AppArtifactHandler {
1123
+ name: string;
1124
+ description: string;
1125
+ /** Callable only from the App Artifact's own UI, not the CLI. */
1126
+ internal: boolean;
1127
+ input: Record<string, AppArtifactJson>;
1128
+ }
1129
+ type AppArtifactSampleDataState = "valid" | "missing" | "invalid";
1130
+ interface AppArtifactVersion {
1131
+ id: string;
1132
+ number: number;
1133
+ commitOid: string;
1134
+ manifest: {
1135
+ name: string;
1136
+ description: string;
1137
+ accountSlots: {
1138
+ name: string;
1139
+ toolkit: string;
1140
+ tools: string[];
1141
+ }[];
1142
+ sync: boolean;
1143
+ };
1144
+ api: {
1145
+ tables: string[];
1146
+ queries: AppArtifactHandler[];
1147
+ mutations: AppArtifactHandler[];
1148
+ actions: AppArtifactHandler[];
1149
+ hasSync: boolean;
1150
+ };
1151
+ allowedTools: string[];
1152
+ /** Whether its `sample-data.json` loaded into a throwaway copy when published. */
1153
+ sampleData: AppArtifactSampleDataState;
1154
+ createdAt: string;
1155
+ }
1156
+ interface AppArtifact {
1157
+ id: string;
1158
+ name: string;
1159
+ status: "active" | "archived";
1160
+ currentVersion: AppArtifactVersion | null;
1161
+ /** Tools the Current Version uses that the owner has not allowed yet. */
1162
+ pendingTools: string[];
1163
+ slotAccounts: Record<string, {
1164
+ connectedAccountId: string;
1165
+ toolkit: string;
1166
+ }>;
1167
+ sync: {
1168
+ state: "off" | "never" | "ok" | "failing" | "paused";
1169
+ lastSuccessAt: string | null;
1170
+ failingSince: string | null;
1171
+ lastError: string | null;
1172
+ consecutiveFailures: number;
1173
+ nextSyncAt: string | null;
1174
+ };
1175
+ recentErrors: {
1176
+ source: "ui" | "server";
1177
+ message: string;
1178
+ at: string;
1179
+ }[];
1180
+ createdAt: string;
1181
+ updatedAt: string;
1182
+ }
1183
+ /** A handler's result; App Artifact failures are values, not errors. */
1184
+ type AppArtifactCallResult = {
1185
+ ok: true;
1186
+ value: AppArtifactJson;
1187
+ dataVersion?: number;
1188
+ } | {
1189
+ ok: false;
1190
+ error: string;
1191
+ dataVersion?: number;
1192
+ /** `app`: the App Artifact's code failed; `refused`: Merrai refused the call. */
1193
+ fault?: "app" | "refused";
1194
+ /** A share level stopped a tool: it cannot act, or it now waits for the owner. */
1195
+ code?: "needs_act" | "needs_approval";
1196
+ tool?: string;
1197
+ requestId?: string;
1198
+ };
1199
+ /** An App Artifact someone else owns and shared with the caller (ADR 0009). */
1200
+ interface SharedAppArtifact {
1201
+ id: string;
1202
+ name: string;
1203
+ description: string;
1204
+ owner: {
1205
+ id: string;
1206
+ name: string;
1207
+ };
1208
+ level: "use" | "ask" | "act";
1209
+ via: ("user" | "organization" | "link")[];
1210
+ api: AppArtifactVersion["api"] | null;
1211
+ }
1212
+ /** One action the caller asked the owner to approve, and what became of it. */
1213
+ interface AppArtifactActionRequest {
1214
+ id: string;
1215
+ appArtifactId: string;
1216
+ action: string;
1217
+ tool: string;
1218
+ status: "pending" | "approved" | "denied" | "cancelled" | "withdrawn" | "done" | "failed";
1219
+ error: string | null;
1220
+ createdAt: string;
1221
+ resolvedAt: string | null;
1222
+ }
1223
+ /** Working source: path → UTF-8 text. */
1224
+ type AppArtifactSourceFiles = Record<string, string>;
1225
+ type AppArtifactBuildingGuideTopic = "authoring" | "design";
1226
+ /** How to build an app from a folder; MCP and the public agent skill serve the same text. */
1227
+ interface AppArtifactBuildingGuide {
1228
+ topic: AppArtifactBuildingGuideTopic;
1229
+ text: string;
1230
+ }
1231
+ /** An archived app deleted for good; its stored data may still be on its way out. */
1232
+ interface AppArtifactDeleted {
1233
+ appArtifactId: string;
1234
+ dataRemoved: boolean;
1235
+ }
1236
+ interface PublishedAppArtifact {
1237
+ artifact: AppArtifact;
1238
+ version: AppArtifactVersion;
1239
+ pendingTools: string[];
1240
+ smokeRender: {
1241
+ ok: boolean;
1242
+ detail: string;
1243
+ };
1244
+ /** Reported, never blocking: why sample data is missing or did not load. */
1245
+ sampleData: {
1246
+ state: AppArtifactSampleDataState;
1247
+ detail: string;
1248
+ };
1249
+ }
1250
+ interface MerraiAppArtifactProcedureContract {
1251
+ list: {
1252
+ input: {
1253
+ status?: "active" | "archived";
1254
+ } | undefined;
1255
+ output: AppArtifact[];
1256
+ };
1257
+ get: {
1258
+ input: {
1259
+ appArtifactId: string;
1260
+ };
1261
+ output: AppArtifact;
1262
+ };
1263
+ /** Archived apps only; the server refuses an active one. */
1264
+ delete: {
1265
+ input: {
1266
+ appArtifactId: string;
1267
+ };
1268
+ output: AppArtifactDeleted;
1269
+ };
1270
+ call: {
1271
+ input: {
1272
+ appArtifactId: string;
1273
+ kind: AppArtifactCallKind;
1274
+ name: string;
1275
+ input?: AppArtifactJson;
1276
+ };
1277
+ output: AppArtifactCallResult;
1278
+ };
1279
+ openUrl: {
1280
+ input: {
1281
+ appArtifactId: string;
1282
+ mode?: "window" | "embed";
1283
+ };
1284
+ output: {
1285
+ url: string;
1286
+ };
1287
+ };
1288
+ create: {
1289
+ input: {
1290
+ name: string;
1291
+ creationKey?: string;
1292
+ };
1293
+ output: AppArtifact;
1294
+ };
1295
+ buildingGuide: {
1296
+ input: {
1297
+ topic?: AppArtifactBuildingGuideTopic;
1298
+ };
1299
+ output: AppArtifactBuildingGuide;
1300
+ };
1301
+ source: {
1302
+ input: {
1303
+ appArtifactId: string;
1304
+ };
1305
+ output: {
1306
+ files: AppArtifactSourceFiles;
1307
+ revision: string;
1308
+ };
1309
+ };
1310
+ saveSource: {
1311
+ input: {
1312
+ appArtifactId: string;
1313
+ files: AppArtifactSourceFiles;
1314
+ message: string;
1315
+ /** Refused when the Working source moved on since this revision. */
1316
+ expectedRevision?: string;
1317
+ };
1318
+ output: {
1319
+ ok: true;
1320
+ revision: string;
1321
+ };
1322
+ };
1323
+ publish: {
1324
+ input: {
1325
+ appArtifactId: string;
1326
+ message: string;
1327
+ publishKey?: string;
1328
+ expectedRevision?: string;
1329
+ };
1330
+ output: PublishedAppArtifact;
1331
+ };
1332
+ sharedWithMe: {
1333
+ input: undefined;
1334
+ output: SharedAppArtifact[];
1335
+ };
1336
+ getShared: {
1337
+ input: {
1338
+ appArtifactId: string;
1339
+ };
1340
+ output: SharedAppArtifact;
1341
+ };
1342
+ actionRequests: {
1343
+ input: {
1344
+ appArtifactId: string;
1345
+ };
1346
+ output: AppArtifactActionRequest[];
1347
+ };
1348
+ cancelActionRequest: {
1349
+ input: {
1350
+ appArtifactId: string;
1351
+ requestId: string;
1352
+ };
1353
+ output: AppArtifactActionRequest;
1354
+ };
1355
+ }
537
1356
  interface MerraiRecallProcedureContract {
538
1357
  addMemory: {
539
1358
  input: AddMemoryRecallInput;
540
1359
  output: AddMemoryRecallOutput;
541
1360
  };
542
1361
  listLivingDocuments: {
543
- input: undefined;
1362
+ input: ListLivingDocumentsRecallInput;
544
1363
  output: ListLivingDocumentsRecallOutput;
545
1364
  };
546
1365
  readLivingDocument: {
547
1366
  input: ReadLivingDocumentRecallInput;
548
1367
  output: ReadLivingDocumentRecallOutput;
549
1368
  };
550
- searchMemory: {
551
- input: SearchMemoryRecallInput;
552
- output: SearchMemoryRecallOutput;
1369
+ /** MCP search_memories over oRPC; no model call. */
1370
+ searchMemories: {
1371
+ input: SearchMemoriesRecallInput;
1372
+ output: SearchMemoriesRecallOutput;
553
1373
  };
554
1374
  }
555
- type SafeProcedureClient<Contract> = { [ProcedureName in keyof Contract]: Contract[ProcedureName] extends {
556
- input: infer Input;
557
- output: infer Output;
558
- } ? RpcProcedure<Input, Output> : never };
559
1375
  type ThrowingProcedureClient<Contract> = { [ProcedureName in keyof Contract]: Contract[ProcedureName] extends {
560
1376
  input: infer Input;
561
1377
  output: infer Output;
562
- } ? ThrowingRpcProcedure<Input, Output> : never };
563
- type MerraiClient = SafeProcedureClient<MerraiProcedureContract> & {
564
- recall: SafeProcedureClient<MerraiRecallProcedureContract>;
565
- };
1378
+ } ? ThrowingRpcProcedure<Input, Output> : never; };
1379
+ type MerraiClient = SafeClient<MerraiThrowingClient>;
566
1380
  type MerraiThrowingClient = ThrowingProcedureClient<MerraiProcedureContract> & {
567
1381
  recall: ThrowingProcedureClient<MerraiRecallProcedureContract>;
1382
+ appArtifacts: ThrowingProcedureClient<MerraiAppArtifactProcedureContract>;
568
1383
  };
569
1384
  interface MerraiClientOptions {
570
1385
  baseURL?: string;
571
1386
  apiKey?: string;
572
1387
  cookie?: string;
573
- fetch?: typeof fetch;
1388
+ fetch?: ConstructorParameters<typeof RPCLink>[0]["fetch"];
574
1389
  headers?: HeadersInit;
575
1390
  }
576
- declare const resolveBaseURL: (baseURL?: string) => string;
577
- declare const createRawMerraiClient: (options?: MerraiClientOptions) => _orpc_client0.NestedClient<any>;
578
- declare const createMerraiClient: (options?: MerraiClientOptions) => MerraiClient;
579
- declare const createMerraiThrowingClient: (options?: MerraiClientOptions) => MerraiThrowingClient;
580
- //#endregion
581
- //#region src/config.d.ts
582
- declare const DEFAULT_MERRAI_BASE_URL = "https://api.merrai.app";
1391
+ export declare const resolveBaseURL: (baseURL?: string) => string;
1392
+ export declare const createRawMerraiClient: (options?: MerraiClientOptions) => MerraiThrowingClient;
1393
+ export declare const createMerraiClient: (options?: MerraiClientOptions) => MerraiClient;
1394
+ export declare const createMerraiThrowingClient: (options?: MerraiClientOptions) => MerraiThrowingClient;
1395
+ export declare const INVALID_API_KEY_CLI_MESSAGE = "Invalid or revoked API key. Create a new key in Merrai settings, then save it with `merrai auth set-key` or set MERRAI_API_KEY.";
1396
+ declare const invalidApiKeyErrorSchema: z.ZodObject<{
1397
+ code: z.ZodLiteral<"UNAUTHORIZED">;
1398
+ data: z.ZodObject<{
1399
+ reason: z.ZodLiteral<"INVALID_API_KEY">;
1400
+ }, z.core.$strip>;
1401
+ }, z.core.$strip>;
1402
+ /**
1403
+ * True when the server refused the request's API key as unknown, malformed,
1404
+ * revoked or expired. That key will not work again.
1405
+ */
1406
+ export declare const isInvalidApiKeyError: (error: unknown) => error is z.infer<typeof invalidApiKeyErrorSchema>;
1407
+ /**
1408
+ * An event time as the server words it: a plan or a deadline names its role
1409
+ * ("due 2024-04-20"); what happened is the calendar reading alone.
1410
+ */
1411
+ export declare const describeEventTime: (time: MemoryEventTime) => string;
1412
+ /**
1413
+ * "replaces: <earlier text> (due 2024-04-20)": the line Merrai's Search and
1414
+ * recall evidence show under a Memory that replaced an earlier value (the
1415
+ * latest Memory it supersedes), so a terse update keeps its subject and the
1416
+ * old value. Null when it replaced none.
1417
+ */
1418
+ export declare const renderMemoryReplacement: (replaced: MemoryReplacement | null | undefined) => string | null;
1419
+ /**
1420
+ * "↳ updated by: …" and "replaces: …": the update marks Merrai's Search shows
1421
+ * under a memory, newer values first, one line per relation. A later value
1422
+ * never retires the earlier one; both stay current. A relation this client
1423
+ * does not know is left out rather than failing the output.
1424
+ */
1425
+ export declare const renderMemoryUpdateMarks: (marks: readonly MemoryUpdateMark[] | undefined, shownIds: ReadonlySet<string>) => string[];
1426
+ /**
1427
+ * Each search result's lines as Merrai's Search shows them: its own line
1428
+ * (`renderLine`), labelled with its id when another result's mark names it,
1429
+ * then what it replaced and its update marks.
1430
+ */
1431
+ export declare const searchResultLines: <Result extends {
1432
+ id: string;
1433
+ linked?: readonly MemoryUpdateMark[];
1434
+ replaces?: MemoryReplacement | null;
1435
+ }>(results: readonly Result[], renderLine: (result: Result) => string) => string[][];
1436
+ /** JSON-shaped request content; `undefined` object fields are omitted. */
1437
+ type IdempotencyKeyMaterial = boolean | number | string | null | undefined | readonly IdempotencyKeyMaterial[] | {
1438
+ readonly [key: string]: IdempotencyKeyMaterial;
1439
+ };
1440
+ /**
1441
+ * A stable idempotency key derived from what one write sends, so a rerun joins
1442
+ * the existing ingestion; any change to content, source, lobe or dates changes
1443
+ * it. `operation` namespaces keys by API shape. Undefined fields are omitted,
1444
+ * so an absent option and an explicit `undefined` produce the same key.
1445
+ */
1446
+ export declare const deriveIdempotencyKey: (operation: string, payload: {
1447
+ readonly [key: string]: IdempotencyKeyMaterial;
1448
+ }) => string;
1449
+ /**
1450
+ * The key for saving one memory (CLI `memory add`, the plugin's
1451
+ * `/merrai:save`). Without a supplied observation time, the same sentence
1452
+ * saved on a later day is a new occurrence ("went running"), not a retry, so
1453
+ * the UTC day joins the key; same-day reruns still collapse into one save.
1454
+ */
1455
+ export declare const deriveMemorySaveIdempotencyKey: (input: {
1456
+ lobeKey?: string;
1457
+ memory: string;
1458
+ now: Date;
1459
+ observationDate?: string;
1460
+ source?: string;
1461
+ }) => string;
1462
+ export declare const DEFAULT_MERRAI_BASE_URL = "https://api.merrai.app";
583
1463
  declare const CREDENTIALS_VERSION = 1;
584
1464
  type MerraiCliEnvironment = Readonly<Record<string, string | undefined>>;
585
1465
  interface MerraiCliConnectionOverrides {
@@ -598,20 +1478,19 @@ interface MerraiConfigPaths {
598
1478
  directory: string;
599
1479
  legacyClaudeCredentials: string;
600
1480
  }
601
- declare const resolveMerraiConfigPaths: (env: MerraiCliEnvironment) => MerraiConfigPaths;
602
- declare const loadMerraiCredentials: (env: MerraiCliEnvironment, options?: {
1481
+ export declare const resolveMerraiConfigPaths: (env: MerraiCliEnvironment) => MerraiConfigPaths;
1482
+ export declare const loadMerraiCredentials: (env: MerraiCliEnvironment, options?: {
603
1483
  strict?: boolean;
604
1484
  }) => MerraiCredentials | null;
605
- declare const saveMerraiCredentials: (env: MerraiCliEnvironment, input: {
1485
+ export declare const saveMerraiCredentials: (env: MerraiCliEnvironment, input: {
606
1486
  apiKey: string;
607
1487
  baseURL?: string;
608
1488
  }) => MerraiCredentials;
609
- declare const clearMerraiCredentials: (env: MerraiCliEnvironment, options?: {
1489
+ export declare const clearMerraiCredentials: (env: MerraiCliEnvironment, options?: {
610
1490
  includeLegacy?: boolean;
611
1491
  }) => boolean;
612
- declare const resolveMerraiClientOptions: (env: MerraiCliEnvironment, overrides: MerraiCliConnectionOverrides, options?: {
1492
+ export declare const resolveMerraiClientOptions: (env: MerraiCliEnvironment, overrides: MerraiCliConnectionOverrides, options?: {
613
1493
  strictCredentials?: boolean;
614
1494
  }) => MerraiClientOptions;
615
- //#endregion
616
- export { type AddChatSessionInput, type AddChatSessionOutput, type AddChatSessionsInput, type AddChatSessionsOutput, type AddMemoriesInput, type AddMemoriesOutput, type AddMemoryInput, type AddMemoryOutput, type AddMemoryRecallInput, type AddMemoryRecallOutput, type AuthSessionOutput, type ClearLobeInput, type ClearLobeOutput, DEFAULT_MERRAI_BASE_URL, type EntityType, type FindMemoryEntitiesInput, type FindMemoryEntitiesOutput, type GetLivingDocumentInput, type GetLivingDocumentOutput, type GetSessionStartContextInput, type GetSessionStartContextOutput, type JsonValue, type ListLivingDocumentSharesInput, type ListLivingDocumentSharesOutput, type ListLivingDocumentsInput, type ListLivingDocumentsOutput, type ListLivingDocumentsRecallOutput, type LivingDocument, type LivingDocumentShare, type LivingDocumentStatus, type LivingDocumentVersion, type MemoriesByDateInput, type MemoriesByDateOutput, type MemoriesByEntityInput, type MemoriesByEntityOutput, type MemoryListItem, type MemoryOverviewOutput, type MemoryRecallResult, type MemoryStatusOutput, type MerraiCliConnectionOverrides, type MerraiCliEnvironment, type MerraiClient, type MerraiClientOptions, type MerraiConfigPaths, type MerraiCredentials, type MerraiThrowingClient, type ReadLivingDocumentRecallInput, type ReadLivingDocumentRecallOutput, type RpcProcedure, type SearchMemoriesInput, type SearchMemoryHit, type SearchMemoryRecallInput, type SearchMemoryRecallOutput, type ThrowingRpcProcedure, type UsageMeter, type UsageMeterSummary, type UsagePlan, type UsageSummaryOutput, clearMerraiCredentials, createMerraiClient, createMerraiThrowingClient, createRawMerraiClient, loadMerraiCredentials, resolveBaseURL, resolveMerraiClientOptions, resolveMerraiConfigPaths, saveMerraiCredentials };
1495
+ export type { AddChatSessionInput, AddChatSessionOutput, AddChatSessionsInput, AddChatSessionsOutput, AddMemoriesInput, AddMemoriesOutput, AddMemoryInput, AddMemoryOutput, AddMemoryRecallInput, AddMemoryRecallOutput, AppArtifact, AppArtifactCallKind, AppArtifactCallResult, AppArtifactDeleted, AppArtifactHandler, AppArtifactJson, AppArtifactSourceFiles, AppArtifactVersion, AuthSessionOutput, ClearLobeInput, ClearLobeOutput, ClearLobeStatusInput, CreateLobeInput, CreateLobeOutput, EntityType, EventTime, EventTimeRole, FindMemoryEntitiesInput, FindMemoryEntitiesOutput, GetLivingDocumentInput, GetLivingDocumentOutput, GetSessionStartContextInput, GetSessionStartContextOutput, GetStyleProfileInput, GetStyleProfileOutput, IngestionEnqueuedOutput, IngestionMemoryResult, IngestionReferenceInput, IngestionResult, IngestionRuntimeStatus, IngestionStatusOutput, JsonValue, Judgment, JudgmentsCursor, ListJudgmentsInput, ListJudgmentsOutput, ListLivingDocumentSharesInput, ListLivingDocumentSharesOutput, ListLivingDocumentsInput, ListLivingDocumentsOutput, ListLivingDocumentsRecallOutput, ListLobesOutput, ListLobesPageInput, ListLobesPageOutput, ListOpenItemsInput, ListOpenItemsOutput, LivingDocument, LivingDocumentShare, LivingDocumentStatus, LivingDocumentVersion, LobePageItem, LobesCursor, MemoriesCursor, MemoriesInput, MemoriesOutput, MemoryAbout, MemoryEventTime, MemoryListItem, MemoryOverviewOutput, MemoryRecallResult, MemoryReplacement, MemoryStance, MemoryStatusOutput, MemoryUpdateMark, MerraiCliConnectionOverrides, MerraiCliEnvironment, MerraiClient, MerraiClientOptions, MerraiConfigPaths, MerraiCredentials, MerraiThrowingClient, OpenItem, OpenItemsCursor, PublishedAppArtifact, ReadLivingDocumentRecallInput, ReadLivingDocumentRecallOutput, RetryLivingDocumentRebuildInput, RetryLivingDocumentRebuildOutput, RpcProcedure, SearchMemoriesRecallInput, SearchMemoriesRecallOutput, SearchMemoryRecallResult, SourceAction, SourceArtifact, SourceArtifactCursor, SourceArtifactDeleteOutput, SourceArtifactListInput, SourceArtifactListOutput, SourceArtifactReferenceInput, SourceDetailRoute, SourceKind, SourceProcessingStatus, ThrowingRpcProcedure, UsageMeter, UsageMeterSummary, UsagePlan, UsageSummaryOutput };
617
1496
  //# sourceMappingURL=index.d.mts.map