@alexein/sdk 0.0.0-stage → 0.3.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.
@@ -0,0 +1,641 @@
1
+ /**
2
+ * Reading the API's JSON without trusting its shape: each reader answers a value of the type asked
3
+ * for, or the absent value, so a field the API leaves out or changes never throws while parsing.
4
+ */
5
+ /** A JSON object, as the API sends it. */
6
+ type Json = Record<string, unknown>;
7
+
8
+ /**
9
+ * The memories search, grep, latest, around and open answer: known lines, facts and excerpts,
10
+ * told apart by `type`. Each keeps the JSON it was read from as `raw`.
11
+ */
12
+
13
+ /** A line memory takes to be true now. */
14
+ interface Known {
15
+ readonly type: "known";
16
+ readonly text: string;
17
+ readonly raw: Json;
18
+ }
19
+ /** Something learned from what was said, with its ref. */
20
+ interface Fact {
21
+ readonly type: "fact";
22
+ /** Opens it with `user.open(ref)`; names it to `forget` and `correct`. */
23
+ readonly ref: string;
24
+ readonly text: string;
25
+ /** The ref of the excerpt it came from, or null. */
26
+ readonly source: string | null;
27
+ /** When it was said: on `facts()` only, null elsewhere. */
28
+ readonly date: string | null;
29
+ readonly raw: Json;
30
+ }
31
+ /** Part of what was said or delivered, with its ref. */
32
+ interface Excerpt {
33
+ readonly type: "excerpt";
34
+ readonly ref: string;
35
+ readonly text: string;
36
+ /** When it happened, or null when unknown. */
37
+ readonly date: string | null;
38
+ /** When memory took it. */
39
+ readonly addedAt: string | null;
40
+ readonly session: string | null;
41
+ /** The roles of who spoke in it: `user`, `assistant`. */
42
+ readonly roles: string[];
43
+ readonly raw: Json;
44
+ }
45
+ /** One memory, of whichever type. */
46
+ type MemoryEntry = Known | Fact | Excerpt;
47
+
48
+ /** What the reads other than search answer: grep, latest, around, open, history, summary and more. */
49
+
50
+ /**
51
+ * Memories in order, from grep (with `pattern` and `total`), latest (with `places` when a place
52
+ * matched nothing: the places there are) or around. Iterable.
53
+ */
54
+ interface Memories extends Iterable<MemoryEntry> {
55
+ readonly memories: MemoryEntry[];
56
+ readonly pattern: string | null;
57
+ readonly total: number | null;
58
+ readonly places: string[] | null;
59
+ readonly raw: Json;
60
+ }
61
+ /** One memory whole: an excerpt, or a fact with the excerpts it was learned from. */
62
+ interface Opened {
63
+ readonly memory: Fact | Excerpt;
64
+ readonly sources: Excerpt[];
65
+ readonly raw: Json;
66
+ }
67
+ /** One value a subject was stated to have, and since when. */
68
+ interface Value {
69
+ readonly attribute: string;
70
+ readonly value: string;
71
+ readonly since: string | null;
72
+ /** True when it was stated not to hold. */
73
+ readonly negated: boolean;
74
+ readonly raw: Json;
75
+ }
76
+ /**
77
+ * Every value a subject was stated to have, by attribute, oldest first. `suggestions` names
78
+ * subjects close to one memory does not know, and is null otherwise.
79
+ */
80
+ interface History {
81
+ readonly subject: string;
82
+ readonly values: Value[];
83
+ readonly suggestions: string[] | null;
84
+ readonly raw: Json;
85
+ }
86
+ /** What one connected app delivered through one connection. */
87
+ interface Source {
88
+ readonly provider: string;
89
+ readonly source: string;
90
+ readonly connection: string;
91
+ /** How many items it delivered. */
92
+ readonly items: number;
93
+ /** How many of them ended. */
94
+ readonly ended: number;
95
+ /** When the newest happened. */
96
+ readonly newest: string | null;
97
+ readonly raw: Json;
98
+ }
99
+ /** What each connected app delivered to this memory. */
100
+ interface Sources {
101
+ readonly sources: Source[];
102
+ readonly raw: Json;
103
+ }
104
+ /**
105
+ * This memory in brief: how many items, the span they cover, the connected sources, and the known
106
+ * lines - what memory takes to be true now.
107
+ */
108
+ interface Summary {
109
+ readonly items: number;
110
+ readonly first: string | null;
111
+ readonly last: string | null;
112
+ readonly sources: Source[];
113
+ readonly known: string[];
114
+ readonly raw: Json;
115
+ }
116
+ /** An issue or pull request still open. */
117
+ interface OpenItem {
118
+ readonly ref: string;
119
+ readonly text: string;
120
+ readonly date: string | null;
121
+ readonly addedAt: string | null;
122
+ readonly ageDays: number | null;
123
+ readonly raw: Json;
124
+ }
125
+ /** An open ask nobody answered. */
126
+ interface FollowUp {
127
+ readonly title: string | null;
128
+ readonly who: string | null;
129
+ readonly date: string | null;
130
+ readonly ageDays: number | null;
131
+ readonly raw: Json;
132
+ }
133
+ interface OpenItems {
134
+ readonly items: OpenItem[];
135
+ readonly followUps: FollowUp[];
136
+ readonly raw: Json;
137
+ }
138
+
139
+ /**
140
+ * What `add` takes - a string, an item, or a list of either - shaped into the requests it sends:
141
+ * at most 500 items each, every one with an `Idempotency-Key` its retries send again.
142
+ */
143
+
144
+ /** Who said it. `id` is your stable id for the person; `email` and `handle` join them up. */
145
+ interface Author {
146
+ id?: string | null;
147
+ name?: string | null;
148
+ email?: string | null;
149
+ handle?: string | null;
150
+ /** True when it is the app user themself. */
151
+ self?: boolean | null;
152
+ }
153
+ /**
154
+ * One thing to remember. Only `text` is required. The same `id` again is an edit of it; set
155
+ * `expires` (an ISO date) for what stops being true, or `null` to lift an expiry.
156
+ */
157
+ interface Item {
158
+ text: string;
159
+ kind?: "message" | "document" | "note";
160
+ id?: string | null;
161
+ session?: string | null;
162
+ role?: string | null;
163
+ author?: string | Author | null;
164
+ title?: string | null;
165
+ /** What it is about, as `kind:name`: `project:atlas`. */
166
+ about?: string[] | null;
167
+ /** When it happened: an ISO date or timestamp. */
168
+ at?: string | null;
169
+ expires?: string | null;
170
+ metadata?: Json | null;
171
+ }
172
+ /** The item fields `add` fills in for every item that does not set its own. */
173
+ interface ItemDefaults {
174
+ kind?: Item["kind"];
175
+ session?: string;
176
+ role?: string;
177
+ author?: string | Author;
178
+ title?: string;
179
+ about?: string[];
180
+ expires?: string;
181
+ at?: string;
182
+ metadata?: Json;
183
+ }
184
+ /** Options `add` takes besides the items. */
185
+ interface AddOptions extends ItemDefaults {
186
+ /** Answer once the items are searchable (briefly waited for). */
187
+ wait?: boolean;
188
+ /** Replace phone numbers, cards, keys and the like with their kind before memory keeps them. */
189
+ redact?: boolean;
190
+ }
191
+ type Adding = string | Item | readonly (string | Item)[];
192
+
193
+ /**
194
+ * The paged answers - facts, items, export, users - and the items, app users and key they hold.
195
+ * `next` is the cursor of the page after, null on the last; the `iter*` methods follow it.
196
+ */
197
+
198
+ interface FactsPage {
199
+ readonly facts: Fact[];
200
+ readonly next: string | null;
201
+ readonly raw: Json;
202
+ }
203
+ /** An item as `add` was given it, and whether it is searchable yet. */
204
+ interface StoredItem {
205
+ readonly id: string;
206
+ readonly kind: string | null;
207
+ readonly text: string;
208
+ readonly title: string | null;
209
+ readonly at: string | null;
210
+ readonly author: string | Author | null;
211
+ readonly role: string | null;
212
+ readonly session: string | null;
213
+ readonly about: string[] | null;
214
+ readonly metadata: Json | null;
215
+ readonly expires: string | null;
216
+ /** `queued` while it waits to be stored, then `stored`. */
217
+ readonly status: string;
218
+ readonly raw: Json;
219
+ }
220
+ interface ItemsPage {
221
+ readonly items: StoredItem[];
222
+ readonly next: string | null;
223
+ readonly raw: Json;
224
+ }
225
+ /** An app user of the key's project with memory. */
226
+ interface AppUser {
227
+ readonly user: string;
228
+ readonly items: number;
229
+ readonly facts: number;
230
+ /** When memory last took something for them; null when unknown. */
231
+ readonly lastWrite: string | null;
232
+ readonly raw: Json;
233
+ }
234
+ interface UsersPage {
235
+ readonly users: AppUser[];
236
+ readonly next: string | null;
237
+ readonly raw: Json;
238
+ }
239
+ /**
240
+ * One record of an export, as the API sent it: `type` is `item`, `version`, `event` or `fact`,
241
+ * and the rest of its fields are that record's own.
242
+ */
243
+ type ExportRecord = Json & {
244
+ type: string;
245
+ };
246
+ /**
247
+ * A page of everything memory holds for an app user. `withheld` names what a read key went
248
+ * without (`version`).
249
+ */
250
+ interface ExportPage {
251
+ readonly user: string;
252
+ readonly exportedAt: string | null;
253
+ readonly records: ExportRecord[];
254
+ readonly next: string | null;
255
+ readonly withheld: string[];
256
+ readonly raw: Json;
257
+ }
258
+ /** What the API key is. `kind` is `key` for an API key. */
259
+ interface Me {
260
+ readonly kind: string;
261
+ readonly org: string | null;
262
+ readonly project: string | null;
263
+ readonly keyId: string | null;
264
+ /** Whether the key may add, forget and correct, or only read. */
265
+ readonly writes: boolean;
266
+ readonly label: string | null;
267
+ /** Who made the key: an email, or null when unknown. */
268
+ readonly createdBy: string | null;
269
+ readonly orgName: string | null;
270
+ readonly projectName: string | null;
271
+ /** `project` for a project's key, `personal` for a member's personal space. */
272
+ readonly space: string | null;
273
+ readonly raw: Json;
274
+ }
275
+
276
+ /** What `search` answers, and the text of it to paste into a prompt. */
277
+
278
+ /**
279
+ * What memory holds for a question. `memories` come in order: known lines, then facts, then
280
+ * excerpts. `answerable` is false when memory does not seem to hold the answer, and null when it
281
+ * was not checked. `failed` is true when a `failOpen` client could not reach memory, and the
282
+ * result is empty for that reason.
283
+ */
284
+ declare class SearchResult {
285
+ readonly query: string;
286
+ readonly answerable: boolean | null;
287
+ readonly notes: string[];
288
+ readonly memories: MemoryEntry[];
289
+ readonly sources: Json[] | null;
290
+ readonly failed: boolean;
291
+ readonly raw: Json;
292
+ constructor(query: string, answerable: boolean | null, notes: string[], memories: MemoryEntry[], sources: Json[] | null, failed: boolean, raw: Json);
293
+ static parse(value: unknown): SearchResult;
294
+ /** What a `failOpen` client answers when memory could not be reached. */
295
+ static unavailable(query: string): SearchResult;
296
+ get known(): Known[];
297
+ get facts(): Fact[];
298
+ get excerpts(): Excerpt[];
299
+ /** Every ref, in order: each opens with `user.open(ref)`. */
300
+ get refs(): string[];
301
+ /**
302
+ * The text to paste into a prompt: each note on its own line, a blank line, then each memory on
303
+ * its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`), cut at a whole
304
+ * memory so it is never longer than `maxChars`. Empty when there are no memories, or when not
305
+ * even the first fits. The Python client and the n8n node write the same text.
306
+ */
307
+ context(maxChars?: number): string;
308
+ }
309
+
310
+ /** The client's settings: from its options, else the environment, else the defaults. */
311
+ declare const DEFAULT_BASE_URL = "https://api.alexein.ai";
312
+ /** Long enough for the slowest search and an add that waits; a caller that cannot wait sets less. */
313
+ declare const DEFAULT_TIMEOUT_MS = 60000;
314
+ declare const DEFAULT_RETRIES = 2;
315
+ interface MemoryOptions {
316
+ /** Defaults to `ALEXEIN_API_KEY` from the environment. */
317
+ apiKey?: string;
318
+ /** The API's host. Defaults to `ALEXEIN_API_URL`, else `https://api.alexein.ai`. */
319
+ baseUrl?: string;
320
+ /** Milliseconds one attempt may take: 60000 by default. */
321
+ timeout?: number;
322
+ /** How many more times a 429, a 503, a timeout or an unreached service is tried: 2. */
323
+ maxRetries?: number;
324
+ /**
325
+ * Ride out an outage - memory unreachable, timing out, or answering 429 or 5xx after its
326
+ * retries: `search` answers empty and `add` saves nothing, each with `failed: true` and a
327
+ * warning logged, instead of throwing. A wrong key or request still throws.
328
+ */
329
+ failOpen?: boolean;
330
+ /** A word added to the User-Agent, so the console's request logs show where calls came from. */
331
+ integration?: string;
332
+ /** Where warnings go: `console.warn` by default. */
333
+ logger?: (message: string) => void;
334
+ /** The `fetch` to send with: the global one by default. */
335
+ fetch?: typeof fetch;
336
+ }
337
+ interface Settings {
338
+ key: string;
339
+ baseUrl: string;
340
+ timeout: number;
341
+ maxRetries: number;
342
+ failOpen: boolean;
343
+ integration: string | null;
344
+ userAgent: string;
345
+ log: (message: string) => void;
346
+ fetch: typeof fetch;
347
+ }
348
+
349
+ /**
350
+ * Sending one request: its headers, a timeout per attempt, and retries - 429 and 503, a timeout
351
+ * or an unreached service - waiting as `Retry-After` says (at most 60 s) or with backoff.
352
+ */
353
+
354
+ /** One request, described once: what it sends and how to read the answer. */
355
+ interface Call<T> {
356
+ method: "GET" | "POST";
357
+ /** After `/v2`: `/memory/search`, `/me`. */
358
+ path: string;
359
+ body?: Json;
360
+ headers?: Record<string, string>;
361
+ parse: (body: unknown) => T;
362
+ }
363
+ declare class Transport {
364
+ private readonly settings;
365
+ constructor(settings: Settings);
366
+ /** Send `call` for app user `user` (none for `me` and `users`), retrying as the API asks. */
367
+ send<T>(call: Call<T>, user?: string): Promise<T>;
368
+ private attempt;
369
+ private answer;
370
+ private refusal;
371
+ }
372
+
373
+ /** What the writes answer, and the reads that say what became of them: add, status, versions. */
374
+
375
+ /** One item of an add: `stored` (searchable) or `queued` (searchable in a moment). */
376
+ interface AddedItem {
377
+ readonly id: string;
378
+ readonly status: string;
379
+ /** With `redact`: how many of each kind were replaced (`{PHONE: 1}`); null when none. */
380
+ readonly redacted: Record<string, number> | null;
381
+ readonly raw: Json;
382
+ }
383
+ /**
384
+ * An add's answer. `waiting` is how many items are not searchable yet; zero once they are.
385
+ * `failed` is true when a `failOpen` client could not reach memory, and nothing more was saved.
386
+ */
387
+ interface AddResult {
388
+ readonly items: AddedItem[];
389
+ readonly waiting: number;
390
+ readonly failed: boolean;
391
+ /** Each item's id, in order. */
392
+ readonly ids: string[];
393
+ readonly raw: Json;
394
+ }
395
+ /** How far one item has got: `queued`, `stored`, `processed` or `unknown`. */
396
+ interface ItemStatus {
397
+ readonly id: string;
398
+ readonly status: string;
399
+ /** Null unless something holds it back; then what does, in words. */
400
+ readonly reason: string | null;
401
+ readonly raw: Json;
402
+ }
403
+ interface Statuses {
404
+ readonly items: ItemStatus[];
405
+ /** Each id's status. */
406
+ readonly byId: Record<string, string>;
407
+ readonly raw: Json;
408
+ }
409
+ /**
410
+ * What a forget erased: the items, the facts learned from them, the versions an edit kept, the
411
+ * copies still on their way in; and `relearning`, the facts of other items that stay, taken to be
412
+ * learned again from what is left.
413
+ */
414
+ interface Erased {
415
+ readonly items: number;
416
+ readonly facts: number;
417
+ readonly versions: number;
418
+ readonly waiting: number;
419
+ readonly relearning: number;
420
+ }
421
+ /** `complete` is false when some copies on their way in could not be checked: ask again. */
422
+ interface Forgotten {
423
+ readonly erased: Erased;
424
+ readonly complete: boolean;
425
+ readonly raw: Json;
426
+ }
427
+ /** The fact retracted (its ref), its text, and the id of the note holding what is true instead. */
428
+ interface Correction {
429
+ readonly retracted: string;
430
+ readonly text: string | null;
431
+ readonly replacement: string | null;
432
+ readonly raw: Json;
433
+ }
434
+ /**
435
+ * One line of an item's history: a `version` (`at`, its number and the item as it was held) or,
436
+ * once it went, `gone` (`at` and `why`: `forgotten` or `expired`).
437
+ */
438
+ interface VersionEntry {
439
+ readonly event: string;
440
+ readonly at: string | null;
441
+ readonly version: number | null;
442
+ readonly item: Json | null;
443
+ readonly why: string | null;
444
+ readonly raw: Json;
445
+ }
446
+ /** Every version of one added item, oldest first. `state`: live, expired, forgotten or unknown. */
447
+ interface Versions {
448
+ readonly id: string;
449
+ readonly state: string;
450
+ readonly history: VersionEntry[];
451
+ readonly raw: Json;
452
+ }
453
+ /** An app user erased whole. */
454
+ interface Deleted {
455
+ readonly user: string;
456
+ readonly deleted: boolean;
457
+ readonly raw: Json;
458
+ }
459
+
460
+ /**
461
+ * Each route as the request it is: path, body and how to read the answer. Written once here and
462
+ * sent by the client; the same requests the Python client sends. Fields left unset are not sent.
463
+ */
464
+
465
+ /**
466
+ * Only items that match: `author`, `mentions` (`kind:name`, or `session:<id>`) and `metadata`
467
+ * keys, as `{field: value}` or `{field: {op: value}}`, in `AND`, `OR` and `NOT`.
468
+ */
469
+ type Filters = Json;
470
+ /** Narrowing to what a connected app delivered. `kind` takes one kind or several. */
471
+ interface Origin {
472
+ provider?: string;
473
+ source?: string;
474
+ kind?: string | string[];
475
+ }
476
+ interface SearchOptions extends Origin {
477
+ /** ISO date: the question is answered as of that day. */
478
+ before?: string;
479
+ /** ISO date: only memory from this day on; the answer is then the facts and excerpts that match. */
480
+ after?: string;
481
+ filters?: Filters;
482
+ /** Answer sooner, a little less precisely. Free. */
483
+ fast?: boolean;
484
+ }
485
+ interface GrepOptions extends Origin {
486
+ limit?: number;
487
+ }
488
+ interface LatestOptions extends Origin {
489
+ k?: number;
490
+ /** A connected app, a channel or a repository. */
491
+ place?: string;
492
+ after?: string;
493
+ before?: string;
494
+ filters?: Filters;
495
+ }
496
+ interface OpenItemsOptions {
497
+ kind?: string | string[];
498
+ provider?: string;
499
+ place?: string;
500
+ /** The person's own (the default), or everyone's. */
501
+ mine?: boolean;
502
+ /** Only those from the last this many days; 0 is any age. */
503
+ withinDays?: number;
504
+ limit?: number;
505
+ }
506
+ interface PageOptions {
507
+ limit?: number;
508
+ cursor?: string | null;
509
+ }
510
+ interface ItemsOptions extends PageOptions {
511
+ filters?: Filters;
512
+ }
513
+ interface ForgetOptions {
514
+ items?: string[];
515
+ sessions?: string[];
516
+ /** Refs of facts or excerpts. */
517
+ refs?: string[];
518
+ }
519
+
520
+ /** One app user's memory: every call sends their id as `X-Alexein-User`. */
521
+
522
+ declare class User {
523
+ private readonly transport;
524
+ /** Your id for this app user. */
525
+ readonly id: string;
526
+ private readonly failOpen;
527
+ private readonly log;
528
+ /** @internal Made by `memory.user(id)`. */
529
+ constructor(transport: Transport,
530
+ /** Your id for this app user. */
531
+ id: string, failOpen: boolean, log: (message: string) => void);
532
+ private send;
533
+ /**
534
+ * Remember text: a string, an item, or a list of either. The options fill in each item's unset
535
+ * fields. More than 500 items go as several requests; a retry never saves an item twice.
536
+ */
537
+ add(items: Adding, options?: AddOptions): Promise<AddResult>;
538
+ /** What memory holds for a question: known lines, facts and excerpts, in order. */
539
+ search(query: string, options?: SearchOptions): Promise<SearchResult>;
540
+ /** Excerpts holding an exact phrase, ignoring case. */
541
+ grep(pattern: string, options?: GrepOptions): Promise<Memories>;
542
+ /** The most recent excerpts, newest first; with `after` and `before`, everything between. */
543
+ latest(options?: LatestOptions): Promise<Memories>;
544
+ /** The excerpts just before and after one, from the same conversation, in order. */
545
+ around(ref: string, options?: {
546
+ width?: number;
547
+ }): Promise<Memories>;
548
+ /** One memory by its ref, whole: an excerpt, or a fact with the excerpts it came from. */
549
+ open(ref: string): Promise<Opened>;
550
+ /** Every value a subject was stated to have, by attribute, oldest first. */
551
+ history(subject: string, options?: {
552
+ attribute?: string;
553
+ }): Promise<History>;
554
+ /** This memory in brief: its items, their span, the connected sources and the known lines. */
555
+ summary(): Promise<Summary>;
556
+ /** The facts memory learned, newest first, a page at a time. */
557
+ facts(options?: PageOptions): Promise<FactsPage>;
558
+ /** Every fact, across pages. */
559
+ iterFacts(options?: {
560
+ limit?: number;
561
+ }): AsyncIterable<Fact>;
562
+ /** The issues and pull requests still open, and the asks nobody answered. */
563
+ openItems(options?: OpenItemsOptions): Promise<OpenItems>;
564
+ /** What each connected app delivered to this memory. */
565
+ sources(): Promise<Sources>;
566
+ /** The items added, newest first, as they were given, a page at a time. */
567
+ items(options?: ItemsOptions): Promise<ItemsPage>;
568
+ /** Every item, across pages. */
569
+ iterItems(options?: {
570
+ limit?: number;
571
+ filters?: Filters;
572
+ }): AsyncIterable<StoredItem>;
573
+ /** One added item by its id, whole; null when memory holds none by that id. */
574
+ item(itemId: string): Promise<StoredItem | null>;
575
+ /** How far each item has got: `queued`, `stored`, `processed` or `unknown`. */
576
+ status(ids: string[]): Promise<Statuses>;
577
+ /** Erase these items, sessions and memories (by ref), with every copy and all learned from them. */
578
+ forget(named: ForgetOptions): Promise<Forgotten>;
579
+ /** Retract one fact for good, by its ref; a `replacement` is kept as a note. */
580
+ correct(ref: string, replacement?: string): Promise<Correction>;
581
+ /** Every version of one added item, oldest first. Takes a key that writes. */
582
+ versions(itemId: string): Promise<Versions>;
583
+ /** Everything memory holds for this app user, a page at a time. */
584
+ export(options?: PageOptions): Promise<ExportPage>;
585
+ /** Every export record, across pages. */
586
+ iterExport(options?: {
587
+ limit?: number;
588
+ }): AsyncIterable<ExportRecord>;
589
+ /** Erase this app user whole: every item, fact and version. Not undone. */
590
+ delete(): Promise<Deleted>;
591
+ /**
592
+ * Throw `error` unless this client fails open and it is an outage; then log it, and the caller
593
+ * answers empty. Memory being down costs a reply its memory, not the reply.
594
+ */
595
+ private rideOut;
596
+ }
597
+
598
+ /**
599
+ * The client, `Memory`: one API key and the settings it sends with. `memory.user("dana")` is the
600
+ * memory of one of your app users.
601
+ */
602
+
603
+ /**
604
+ * An Alexein client, for one API key.
605
+ *
606
+ * ```ts
607
+ * const memory = new Memory(); // ALEXEIN_API_KEY from the environment
608
+ * const dana = memory.user("dana"); // your own id for one of your app users
609
+ * await dana.add("I moved to Lisbon for the job at Acme.");
610
+ * console.log((await dana.search("Where does Dana live?")).context());
611
+ * ```
612
+ */
613
+ declare class Memory {
614
+ #private;
615
+ /** The API's host, without `/v2`. */
616
+ readonly baseUrl: string;
617
+ /** Milliseconds one attempt may take. */
618
+ readonly timeout: number;
619
+ readonly maxRetries: number;
620
+ readonly failOpen: boolean;
621
+ /** The word in the User-Agent, or null. */
622
+ readonly integration: string | null;
623
+ constructor(options?: MemoryOptions);
624
+ /** What this key is: its organisation, project, and whether it writes. Names no app user. */
625
+ me(): Promise<Me>;
626
+ /**
627
+ * The memory of one of your app users, by your own id for them: 1 to 35 letters, digits, `.`,
628
+ * `_` and `-`, beginning with a letter or digit. A RangeError otherwise, before any request.
629
+ */
630
+ user(id: string): User;
631
+ /** The app users of this key's project with memory, a page at a time in id order. */
632
+ users(options?: PageOptions): Promise<UsersPage>;
633
+ /** Every app user with memory, across pages. */
634
+ iterUsers(options?: {
635
+ limit?: number;
636
+ }): AsyncIterable<AppUser>;
637
+ /** Nothing to release: each request is its own. Here so code written for Python reads the same. */
638
+ close(): void;
639
+ }
640
+
641
+ export { type Versions as $, type AddOptions as A, type Opened as B, type Correction as C, DEFAULT_BASE_URL as D, type Erased as E, type Fact as F, type GrepOptions as G, type History as H, type Item as I, type Json as J, type Known as K, type LatestOptions as L, type Me as M, type Origin as N, type OpenItem as O, type PageOptions as P, SearchResult as Q, type Source as R, type SearchOptions as S, type Sources as T, type Statuses as U, type StoredItem as V, type Summary as W, User as X, type UsersPage as Y, type Value as Z, type VersionEntry as _, type AddResult as a, type AddedItem as b, type Adding as c, type AppUser as d, type Author as e, DEFAULT_RETRIES as f, DEFAULT_TIMEOUT_MS as g, type Deleted as h, type Excerpt as i, type ExportPage as j, type ExportRecord as k, type FactsPage as l, type Filters as m, type FollowUp as n, type ForgetOptions as o, type Forgotten as p, type ItemDefaults as q, type ItemStatus as r, type ItemsOptions as s, type ItemsPage as t, type Memories as u, Memory as v, type MemoryEntry as w, type MemoryOptions as x, type OpenItems as y, type OpenItemsOptions as z };
package/dist/index.cjs ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ var _chunk7KPDU3YVcjs = require('./chunk-7KPDU3YV.cjs');
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ exports.APIConnectionError = _chunk7KPDU3YVcjs.APIConnectionError; exports.APITimeoutError = _chunk7KPDU3YVcjs.APITimeoutError; exports.AlexeinError = _chunk7KPDU3YVcjs.AlexeinError; exports.AuthenticationError = _chunk7KPDU3YVcjs.AuthenticationError; exports.DEFAULT_BASE_URL = _chunk7KPDU3YVcjs.DEFAULT_BASE_URL; exports.DEFAULT_RETRIES = _chunk7KPDU3YVcjs.DEFAULT_RETRIES; exports.DEFAULT_TIMEOUT_MS = _chunk7KPDU3YVcjs.DEFAULT_TIMEOUT_MS; exports.InvalidRequestError = _chunk7KPDU3YVcjs.InvalidRequestError; exports.Memory = _chunk7KPDU3YVcjs.Memory; exports.NotFoundError = _chunk7KPDU3YVcjs.NotFoundError; exports.PermissionDeniedError = _chunk7KPDU3YVcjs.PermissionDeniedError; exports.RateLimitError = _chunk7KPDU3YVcjs.RateLimitError; exports.SearchResult = _chunk7KPDU3YVcjs.SearchResult; exports.ServiceUnavailableError = _chunk7KPDU3YVcjs.ServiceUnavailableError; exports.User = _chunk7KPDU3YVcjs.User; exports.VERSION = _chunk7KPDU3YVcjs.VERSION;