@sol-merrai/cli 0.1.4 → 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,58 +1,1496 @@
1
- import * as _orpc_client0 from "@orpc/client";
2
-
3
- //#region src/client.d.ts
4
- type RpcProcedure<Input = unknown> = (input?: Input) => Promise<readonly [unknown, unknown, ...unknown[]]>;
5
- type AddMemoryInput = {
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
+ type EntityType = "person" | "event" | "action" | "knowledge" | "document";
7
+ type JsonValue = boolean | number | string | null | JsonValue[] | {
8
+ [key: string]: JsonValue;
9
+ };
10
+ interface AddMemoryInput {
11
+ idempotencyKey: string;
6
12
  memory: string;
13
+ observationDate?: string;
7
14
  source?: string;
8
15
  lobeKey?: string;
9
- };
10
- type AddMemoriesInput = {
11
- memories: Array<{
16
+ }
17
+ interface AddMemoryOutput {
18
+ /** Poll `ingestionStatus` with this ID to follow processing. */
19
+ ingestionId: string;
20
+ queued: boolean;
21
+ }
22
+ interface AddMemoryRecallInput {
23
+ idempotencyKey: string;
24
+ /** An existing lobe of the account; the main lobe when omitted. */
25
+ lobeKey?: string;
26
+ memory: string;
27
+ observationDate?: string;
28
+ }
29
+ interface AddMemoryRecallOutput {
30
+ ingestionId: string;
31
+ processing: true;
32
+ status: "enqueued";
33
+ }
34
+ interface AddMemoriesInput {
35
+ idempotencyKey: string;
36
+ memories: {
12
37
  memory: string;
38
+ observationDate?: string;
13
39
  source?: string;
14
40
  lobeKey?: string;
15
- }>;
41
+ }[];
42
+ }
43
+ interface AddMemoriesOutput {
44
+ ingestionId: string;
45
+ queued: number;
46
+ }
47
+ interface FindMemoryEntitiesInput {
48
+ name: string;
49
+ type?: EntityType;
50
+ limit?: number;
51
+ }
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;
16
75
  };
17
- type SearchMemoriesInput = {
18
- query: string;
19
- lobeKey?: string;
76
+ type MemoryEventTime = EventTime | {
77
+ precision: "multiple";
78
+ alternatives: EventTime[];
79
+ };
80
+ interface MemoryRecallResult {
81
+ eventTime: MemoryEventTime | null;
82
+ category: string | null;
83
+ content: string;
84
+ id: string;
85
+ lobeKey: 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;
125
+ }
126
+ interface FindMemoryEntitiesOutput {
127
+ entities: {
128
+ displayName: string;
129
+ id: string;
130
+ memoryCount: number;
131
+ name: string;
132
+ type: EntityType;
133
+ }[];
134
+ }
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. */
20
146
  limit?: number;
21
- threshold?: number;
22
- mode?: "fast" | "adaptive" | "reflective";
23
- graph?: {
24
- enabled?: boolean;
25
- maxNeighborsPerSeed?: number;
26
- maxTotalNeighbors?: number;
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[];
156
+ }
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: {
164
+ end: string | null;
165
+ entityId: string | null;
166
+ entityName: string | null;
167
+ entityType: EntityType | null;
168
+ query: string | null;
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[];
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;
188
+ }
189
+ interface MemoryOverviewOutput {
190
+ account: {
191
+ name: string;
192
+ numberOfAiTools: number | null;
193
+ preferredMessagingChannel: string | null;
194
+ primaryRole: string | null;
195
+ workplace: string | null;
27
196
  };
197
+ profile: {
198
+ dynamicContext: (Omit<MemoryRecallResult, "id"> & {
199
+ profileExpiresAt: string;
200
+ })[];
201
+ facts: Omit<MemoryRecallResult, "id">[];
202
+ ongoingContext: Omit<MemoryRecallResult, "id">[];
203
+ scope: string;
204
+ updatedAt: string;
205
+ } | null;
206
+ refresh: {
207
+ candidateMemoryCount: number;
208
+ status: "current" | "failed" | "queued";
209
+ };
210
+ }
211
+ interface ListLivingDocumentsInput {
212
+ status?: ("enabled" | "disabled" | "archived")[];
213
+ }
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[];
28
224
  };
29
- type MemoryStatusInput = {
225
+ interface LivingDocument {
226
+ autoPublish: boolean;
227
+ createdAt: string;
228
+ currentApprovedVersionId: string | null;
229
+ currentVersionId: string | null;
230
+ description: string | null;
231
+ entities: string[];
232
+ extractionPrompt: string;
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;
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;
258
+ routingSummary: string | null;
259
+ routingSummaryDirty: boolean;
260
+ status: LivingDocumentStatus;
261
+ title: string;
262
+ triggerKeywords: string[];
263
+ updatedAt: string;
264
+ }
265
+ interface LivingDocumentVersion {
266
+ causedByMemoryIds: string[];
267
+ causedByRunId: string | null;
268
+ contentMd: string;
269
+ contentMdSummary: string | null;
270
+ createdAt: string;
271
+ documentId: string;
272
+ extractorModel: string | null;
273
+ id: string;
274
+ parentVersionId: string | null;
275
+ patch: JsonValue;
276
+ updatedAt: string;
277
+ versionNumber: number;
278
+ }
279
+ interface LivingDocumentShare {
280
+ createdAt: string;
281
+ documentId: string;
282
+ expiresAt: string | null;
283
+ id: string;
284
+ mode: "pinned" | "live";
285
+ permissions: "view" | "view+comment";
286
+ revokedAt: string | null;
287
+ shareToken: string;
288
+ updatedAt: string;
289
+ versionId: string | null;
290
+ }
291
+ interface ListLivingDocumentsOutput {
292
+ documents: LivingDocument[];
293
+ slots: {
294
+ limit: number;
295
+ plan: string;
296
+ remaining: number;
297
+ used: number;
298
+ };
299
+ }
300
+ interface ListLivingDocumentsRecallOutput {
301
+ documents: {
302
+ currentVersion: {
303
+ createdAt: string;
304
+ number: number;
305
+ } | null;
306
+ id: string;
307
+ /** Absent from a server that predates lobe scopes. */
308
+ lobeScope?: LivingDocumentLobeScope;
309
+ status: string;
310
+ summary: string;
311
+ title: string;
312
+ }[];
313
+ pagination: {
314
+ limit: number;
315
+ nextOffset: number | null;
316
+ offset: number;
317
+ };
318
+ }
319
+ interface ListLivingDocumentsRecallInput {
320
+ limit?: number;
321
+ offset?: number;
322
+ }
323
+ interface ReadLivingDocumentRecallInput {
324
+ contentOffset?: number;
325
+ documentId: string;
326
+ maxCharacters?: number;
327
+ }
328
+ interface ReadLivingDocumentRecallOutput {
329
+ document: {
330
+ currentVersion: {
331
+ contentMarkdown: string;
332
+ contentOffset: number;
333
+ createdAt: string;
334
+ nextContentOffset: number | null;
335
+ number: number;
336
+ returnedCharacters: number;
337
+ totalCharacters: number;
338
+ } | null;
339
+ description: string | null;
340
+ headings: string[];
341
+ id: string;
342
+ /** Absent from a server that predates lobe scopes. */
343
+ lobeScope?: LivingDocumentLobeScope;
344
+ status: string;
345
+ summary: string;
346
+ title: string;
347
+ };
348
+ }
349
+ interface GetLivingDocumentOutput {
350
+ currentVersion: LivingDocumentVersion | null;
351
+ document: LivingDocument;
352
+ }
353
+ interface ListLivingDocumentSharesOutput {
354
+ shares: LivingDocumentShare[];
355
+ }
356
+ interface GetLivingDocumentInput {
357
+ id: string;
358
+ }
359
+ interface ListLivingDocumentSharesInput {
360
+ documentId: string;
361
+ }
362
+ interface AddChatSessionInput {
363
+ idempotencyKey: string;
364
+ memories: {
365
+ memory: string;
366
+ observationDate?: string;
367
+ source?: string;
368
+ }[];
369
+ lobeKey?: string;
370
+ source?: string;
371
+ sessionMetadata?: Record<string, JsonValue>;
372
+ }
373
+ interface AddChatSessionOutput {
374
+ ingestionId: string;
375
+ queued: number;
376
+ }
377
+ interface AddChatSessionsInput {
378
+ lobeKey?: string;
379
+ source?: string;
380
+ questionMetadata?: Record<string, JsonValue>;
381
+ /**
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.
385
+ */
386
+ idempotencyKey: string;
387
+ sessions: {
388
+ sessionId: string;
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>;
395
+ turns: {
396
+ content: string;
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;
404
+ speaker?: string;
405
+ turnIndex: number;
406
+ }[];
407
+ }[];
408
+ }
409
+ interface AddChatSessionsOutput {
410
+ ingestionId: string;
411
+ queuedSessions: number;
412
+ }
413
+ interface MemoryStatusInput {
414
+ lobeKey?: string;
415
+ }
416
+ interface MemoryStatusOutput {
417
+ count: number;
418
+ }
419
+ interface ClearLobeInput {
420
+ lobeKey: string;
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
+ */
426
+ interface ClearLobeOutput {
427
+ clearId: string;
428
+ completedAt: string | null;
429
+ /** Memories removed so far; final once `status` is `complete`. */
430
+ deleted: number;
431
+ deletedSources: number;
432
+ lobeKey: string;
433
+ remainingSources: number;
434
+ startedAt: string;
435
+ status: "complete" | "failed" | "running";
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;
30
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. */
657
+ interface MemoryListItem {
658
+ eventTime: MemoryEventTime | null;
659
+ category: string | null;
660
+ content: string;
661
+ createdAt: string;
662
+ expiresAt: string | null;
663
+ id: string;
664
+ /** Current memories an update mark ties to this one. */
665
+ linked: MemoryUpdateMark[];
666
+ lobeKey: string;
667
+ memoryAt: string | null;
668
+ memoryKind: string;
669
+ /** When its source recorded it; null when unknown. */
670
+ recordedAt: string | null;
671
+ /** The earlier value this memory replaced. */
672
+ replaces: MemoryReplacement | null;
673
+ summary: string | null;
674
+ updatedAt: string;
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
+ }
691
+ interface AuthSessionOutput {
692
+ session: {
693
+ createdAt: string | null;
694
+ expiresAt: string | null;
695
+ id: string;
696
+ ipAddress: string | null;
697
+ token: string;
698
+ updatedAt: string | null;
699
+ userAgent: string | null;
700
+ userId: string;
701
+ };
702
+ user: {
703
+ createdAt: string | null;
704
+ email: string;
705
+ emailVerified: boolean;
706
+ id: string;
707
+ image: string | null;
708
+ name: string;
709
+ onboardingComplete: boolean;
710
+ updatedAt: string | null;
711
+ };
712
+ }
713
+ type UsagePlan = "free" | "beta";
714
+ type UsageMeter = "assistant_messages" | "automation_executions" | "llm_tokens" | "memory_processed";
715
+ interface UsageMeterSummary {
716
+ allowed: boolean;
717
+ current: number;
718
+ limit: number | null;
719
+ meter: UsageMeter;
720
+ periodKey: string;
721
+ plan: UsagePlan;
722
+ remaining: number | null;
723
+ userId: string;
724
+ }
725
+ interface UsageSummaryOutput {
726
+ billing: {
727
+ hasPaidPlan: boolean;
728
+ plan: UsagePlan;
729
+ /** A personal subscription or an organisation seat; null on the free plan. */
730
+ planSource: "personal" | "organisation" | null;
731
+ scheduledDowngradeAt: string | null;
732
+ };
733
+ llm: {
734
+ byModel: {
735
+ inputTokens: number;
736
+ model: string;
737
+ outputTokens: number;
738
+ provider: string;
739
+ requests: number;
740
+ totalTokens: number;
741
+ }[];
742
+ bySurface: {
743
+ inputTokens: number;
744
+ outputTokens: number;
745
+ requests: number;
746
+ surface: string;
747
+ totalTokens: number;
748
+ }[];
749
+ recentRequests: {
750
+ cachedInputTokens: number;
751
+ createdAt: string;
752
+ id: string;
753
+ inputTokens: number;
754
+ model: string;
755
+ outputTokens: number;
756
+ provider: string;
757
+ reasoningTokens: number;
758
+ requestId: string | null;
759
+ surface: string;
760
+ totalTokens: number;
761
+ }[];
762
+ totals: {
763
+ cachedInputTokens: number;
764
+ inputTokens: number;
765
+ outputTokens: number;
766
+ reasoningTokens: number;
767
+ requests: number;
768
+ totalTokens: number;
769
+ };
770
+ };
771
+ meters: {
772
+ automationExecutions: UsageMeterSummary;
773
+ llmTokens: UsageMeterSummary;
774
+ memoryProcessed: UsageMeterSummary;
775
+ };
776
+ periodStart: string;
777
+ plan: UsagePlan;
778
+ plans: {
779
+ automations: number | null;
780
+ id: UsagePlan;
781
+ memories: number | null;
782
+ tokens: number | null;
783
+ }[];
784
+ }
785
+ interface GetSessionStartContextInput {
786
+ /**
787
+ * Restrict to a single lobe. Plugin callers pass `cc:<repo-slug>` so memory
788
+ * is scoped to the active project. Omit to read across every lobe.
789
+ */
790
+ lobeKey?: string;
791
+ /**
792
+ * Short retrieval hints biased toward what the caller is about to do
793
+ * (e.g. current git branch name, last commit subject, cwd basename).
794
+ * Cap: 5 hints × 200 chars.
795
+ */
796
+ recentHints?: string[];
797
+ /**
798
+ * Caller-side budget. Server hard caps both numbers regardless.
799
+ */
800
+ budget?: {
801
+ /** Default 15, hard cap 30. */
802
+ maxMemories?: number;
803
+ /** Default 2000, hard cap 4000. Char-based estimate (chars / 4). */
804
+ maxTokens?: number;
805
+ };
806
+ }
807
+ interface GetSessionStartContextOutput {
808
+ /** Markdown block ready to drop into a hook's `additionalContext`. */
809
+ markdown: string;
810
+ /** IDs of every memory referenced in the markdown. */
811
+ memoryIds: string[];
812
+ /** True when the response was truncated by the budget. */
813
+ hasMore: boolean;
814
+ /** Server-side ISO 8601 timestamp the context was generated. */
815
+ generatedAt: string;
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;
31
857
  };
32
- type ClearLobeInput = {
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;
33
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;
34
929
  };
35
- type MerraiClient = Record<string, RpcProcedure> & {
36
- addMemory: RpcProcedure<AddMemoryInput>;
37
- addMemories: RpcProcedure<AddMemoriesInput>;
38
- clearLobe: RpcProcedure<ClearLobeInput>;
39
- healthCheck: RpcProcedure;
40
- memories: RpcProcedure;
41
- memoryStatus: RpcProcedure<MemoryStatusInput>;
42
- searchMemories: RpcProcedure<SearchMemoriesInput>;
43
- session: RpcProcedure;
44
- usageSummary: RpcProcedure;
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
+ }
952
+ interface MerraiProcedureContract {
953
+ addChatSession: {
954
+ input: AddChatSessionInput;
955
+ output: AddChatSessionOutput;
956
+ };
957
+ addChatSessions: {
958
+ input: AddChatSessionsInput;
959
+ output: AddChatSessionsOutput;
960
+ };
961
+ addMemories: {
962
+ input: AddMemoriesInput;
963
+ output: AddMemoriesOutput;
964
+ };
965
+ addMemory: {
966
+ input: AddMemoryInput;
967
+ output: AddMemoryOutput;
968
+ };
969
+ clearLobe: {
970
+ input: ClearLobeInput;
971
+ output: ClearLobeOutput;
972
+ };
973
+ clearLobeStatus: {
974
+ input: ClearLobeStatusInput;
975
+ output: ClearLobeOutput;
976
+ };
977
+ createLobe: {
978
+ input: CreateLobeInput;
979
+ output: CreateLobeOutput;
980
+ };
981
+ findMemoryEntities: {
982
+ input: FindMemoryEntitiesInput;
983
+ output: FindMemoryEntitiesOutput;
984
+ };
985
+ getLivingDocument: {
986
+ input: GetLivingDocumentInput;
987
+ output: GetLivingDocumentOutput;
988
+ };
989
+ getStyleProfile: {
990
+ input: GetStyleProfileInput;
991
+ output: GetStyleProfileOutput;
992
+ };
993
+ getSessionStartContext: {
994
+ input: GetSessionStartContextInput;
995
+ output: GetSessionStartContextOutput;
996
+ };
997
+ healthCheck: {
998
+ input: undefined;
999
+ output: "OK";
1000
+ };
1001
+ ingestionStatus: {
1002
+ input: IngestionReferenceInput;
1003
+ output: IngestionStatusOutput;
1004
+ };
1005
+ listLivingDocuments: {
1006
+ input: ListLivingDocumentsInput;
1007
+ output: ListLivingDocumentsOutput;
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
+ };
1029
+ listLivingDocumentShares: {
1030
+ input: ListLivingDocumentSharesInput;
1031
+ output: ListLivingDocumentSharesOutput;
1032
+ };
1033
+ memories: {
1034
+ input: MemoriesInput | undefined;
1035
+ output: MemoriesOutput;
1036
+ };
1037
+ memoryOverview: {
1038
+ input: {
1039
+ lobeKey?: string;
1040
+ } | undefined;
1041
+ output: MemoryOverviewOutput;
1042
+ };
1043
+ memoryBackfillStatus: {
1044
+ input: MemoryBackfillInput;
1045
+ output: MemoryBackfillStatusOutput;
1046
+ };
1047
+ memoryStatus: {
1048
+ input: MemoryStatusInput;
1049
+ output: MemoryStatusOutput;
1050
+ };
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;
1070
+ };
1071
+ session: {
1072
+ input: undefined;
1073
+ output: AuthSessionOutput | null;
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
+ };
1111
+ usageSummary: {
1112
+ input: undefined;
1113
+ output: UsageSummaryOutput;
1114
+ };
1115
+ }
1116
+ /** JSON an App Artifact handler takes or returns. */
1117
+ type AppArtifactJson = null | boolean | number | string | AppArtifactJson[] | {
1118
+ [key: string]: AppArtifactJson;
45
1119
  };
46
- type MerraiClientOptions = {
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
+ }
1356
+ interface MerraiRecallProcedureContract {
1357
+ addMemory: {
1358
+ input: AddMemoryRecallInput;
1359
+ output: AddMemoryRecallOutput;
1360
+ };
1361
+ listLivingDocuments: {
1362
+ input: ListLivingDocumentsRecallInput;
1363
+ output: ListLivingDocumentsRecallOutput;
1364
+ };
1365
+ readLivingDocument: {
1366
+ input: ReadLivingDocumentRecallInput;
1367
+ output: ReadLivingDocumentRecallOutput;
1368
+ };
1369
+ /** MCP search_memories over oRPC; no model call. */
1370
+ searchMemories: {
1371
+ input: SearchMemoriesRecallInput;
1372
+ output: SearchMemoriesRecallOutput;
1373
+ };
1374
+ }
1375
+ type ThrowingProcedureClient<Contract> = { [ProcedureName in keyof Contract]: Contract[ProcedureName] extends {
1376
+ input: infer Input;
1377
+ output: infer Output;
1378
+ } ? ThrowingRpcProcedure<Input, Output> : never; };
1379
+ type MerraiClient = SafeClient<MerraiThrowingClient>;
1380
+ type MerraiThrowingClient = ThrowingProcedureClient<MerraiProcedureContract> & {
1381
+ recall: ThrowingProcedureClient<MerraiRecallProcedureContract>;
1382
+ appArtifacts: ThrowingProcedureClient<MerraiAppArtifactProcedureContract>;
1383
+ };
1384
+ interface MerraiClientOptions {
47
1385
  baseURL?: string;
48
1386
  apiKey?: string;
49
1387
  cookie?: string;
50
- fetch?: typeof fetch;
1388
+ fetch?: ConstructorParameters<typeof RPCLink>[0]["fetch"];
51
1389
  headers?: HeadersInit;
1390
+ }
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;
52
1439
  };
53
- declare const resolveBaseURL: (baseURL?: string) => string;
54
- declare const createRawMerraiClient: (options?: MerraiClientOptions) => _orpc_client0.NestedClient<any>;
55
- declare const createMerraiClient: (options?: MerraiClientOptions) => MerraiClient;
56
- //#endregion
57
- export { type AddMemoryInput, type MerraiClient, type MerraiClientOptions, type RpcProcedure, createMerraiClient, createRawMerraiClient, resolveBaseURL };
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";
1463
+ declare const CREDENTIALS_VERSION = 1;
1464
+ type MerraiCliEnvironment = Readonly<Record<string, string | undefined>>;
1465
+ interface MerraiCliConnectionOverrides {
1466
+ apiKey?: string;
1467
+ baseURL?: string;
1468
+ cookie?: string;
1469
+ }
1470
+ interface MerraiCredentials {
1471
+ apiKey: string;
1472
+ baseURL?: string;
1473
+ savedAt: string;
1474
+ version: typeof CREDENTIALS_VERSION;
1475
+ }
1476
+ interface MerraiConfigPaths {
1477
+ credentials: string;
1478
+ directory: string;
1479
+ legacyClaudeCredentials: string;
1480
+ }
1481
+ export declare const resolveMerraiConfigPaths: (env: MerraiCliEnvironment) => MerraiConfigPaths;
1482
+ export declare const loadMerraiCredentials: (env: MerraiCliEnvironment, options?: {
1483
+ strict?: boolean;
1484
+ }) => MerraiCredentials | null;
1485
+ export declare const saveMerraiCredentials: (env: MerraiCliEnvironment, input: {
1486
+ apiKey: string;
1487
+ baseURL?: string;
1488
+ }) => MerraiCredentials;
1489
+ export declare const clearMerraiCredentials: (env: MerraiCliEnvironment, options?: {
1490
+ includeLegacy?: boolean;
1491
+ }) => boolean;
1492
+ export declare const resolveMerraiClientOptions: (env: MerraiCliEnvironment, overrides: MerraiCliConnectionOverrides, options?: {
1493
+ strictCredentials?: boolean;
1494
+ }) => MerraiClientOptions;
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 };
58
1496
  //# sourceMappingURL=index.d.mts.map