@alexein/sdk 0.3.2 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3 - 2026-11-20
4
+
5
+ The same version as `alexein` on PyPI, which has the same changes.
6
+
7
+ - `add(text, { id: "diet" })` is typed now, and names the one item added. With several items it is a
8
+ `RangeError`: before, every item was sent with the same id, so they were edits of one another.
9
+ - `SearchResult.searchId`, and `user.feedback(resultOrSearchId, "wrong" | "missing" | "ok", { note })` to
10
+ say how a search went.
11
+ - The API's other routes: `user.subject(name, { limit })`, `user.related(ref)`,
12
+ `user.howTheyWork({ who, surface })`, `user.lessons(task)` and `user.refresh()`, answering `Subject`,
13
+ `Related`, `Ways`, `Lessons` and `Refreshed`.
14
+ - `context()` keeps each memory on one line: an excerpt's text is its header, a blank line, then what was
15
+ said, so its line breaks are made spaces. The memory itself keeps them.
16
+
3
17
  ## 0.3.2 - 2026-11-17
4
18
 
5
19
  - `QuotaExceededError`: a 402, when the organisation has used this month's events (on an add) or retrievals
package/README.md CHANGED
@@ -52,7 +52,7 @@ for any other, before a request is made.
52
52
  The base URL is the API's host: `http://localhost:8210`, `http://localhost:8210/` and
53
53
  `http://localhost:8210/v2` all mean the same. The environment is read where there is a
54
54
  `process.env`; elsewhere, pass the options. `integration` adds one lowercase word to the
55
- `User-Agent` (`alexein-js/0.3.0 langgraph`), so the console's request logs show where requests came
55
+ `User-Agent` (`alexein-js/0.3.3 langgraph`), so the console's request logs show where requests came
56
56
  from.
57
57
 
58
58
  Run it on your server: a key in a browser bundle can be copied, and it speaks for every user of the
@@ -71,10 +71,12 @@ await dana.add(
71
71
  { session: "trip-may" },
72
72
  );
73
73
  await dana.add("Moving house on 1 December.", { kind: "note", expires: "2026-12-31" });
74
+ await dana.add("Vegetarian, allergic to peanuts.", { id: "diet", kind: "note" }); // the one item's id
74
75
  ```
75
76
 
76
77
  The item fields are `text` (required), `kind`, `id`, `session`, `role`, `author`, `title`, `about`,
77
- `at`, `expires` and `metadata`. The same `id` again is an edit. `wait: true` answers once the items
78
+ `at`, `expires` and `metadata`. The same `id` again is an edit; as an option, `id` names the one item
79
+ added, and with several items it is a `RangeError`. `wait: true` answers once the items
78
80
  are searchable; `redact: true` replaces phone numbers, cards, keys and the like before memory keeps
79
81
  them. More than 500 items go as several requests, each with an `Idempotency-Key` its retries send
80
82
  again, so a retry never saves an item twice.
@@ -91,6 +93,12 @@ result.context(4000); // notes, then one memory per line, never longer than 4000
91
93
  for (const ref of result.refs) await dana.open(ref); // each memory whole
92
94
  ```
93
95
 
96
+ `context()` puts each memory on one line: a memory's own line breaks become spaces.
97
+
98
+ When an answer from memory turns out wrong or incomplete, say so with `dana.feedback(result, "wrong",
99
+ { note: "Dana moved to Porto in October." })` (or `"missing"`, `"ok"`): memory answers questions like it
100
+ better. It takes the result or its `result.searchId`, and needs a key that writes.
101
+
94
102
  `fast: true` answers sooner, a little less precisely, and is free. `before` and `after` (ISO dates),
95
103
  `filters`, and `provider`, `source` and `kind` narrow a search.
96
104
 
@@ -104,6 +112,10 @@ for (const ref of result.refs) await dana.open(ref); // each memory whole
104
112
  | `user.latest({ k, place, after, before, filters, ... })` | `latest` |
105
113
  | `user.around(ref, { width })` | `around` |
106
114
  | `user.open(ref)` | `open` |
115
+ | `user.subject(name, { limit })` | `subject` |
116
+ | `user.related(ref)` | `related` |
117
+ | `user.howTheyWork({ who, surface })` | `how_they_work` |
118
+ | `user.lessons(task)` | `lessons` |
107
119
  | `user.history(subject, { attribute })` | `history` |
108
120
  | `user.summary()` | `summary` |
109
121
  | `user.facts({ limit, cursor })`, `user.iterFacts()` | `facts` |
@@ -114,12 +126,16 @@ for (const ref of result.refs) await dana.open(ref); // each memory whole
114
126
  | `user.status(ids)` | `status` |
115
127
  | `user.forget({ items, sessions, refs })` | `forget` |
116
128
  | `user.correct(ref, replacement?)` | `correct` |
129
+ | `user.feedback(search, verdict, { note })` | `feedback` |
130
+ | `user.refresh()` | `refresh` |
117
131
  | `user.versions(itemId)` | `versions` |
118
132
  | `user.export({ limit, cursor })`, `user.iterExport()` | `export` |
119
133
  | `user.delete()` | `users/delete` |
120
134
 
121
135
  Every route but `me` is `POST /v2/memory/<route>`. Results are plain objects with camelCase fields
122
- (`addedAt`, `followUps`, `lastWrite`); each keeps the JSON the API sent as `.raw`. The `iter*`
136
+ (`addedAt`, `followUps`, `lastWrite`); each keeps the JSON the API sent as `.raw`. A read of an app
137
+ user nothing was ever added for throws `NotFoundError`, `item()` included; `item()` answers null for
138
+ an id an app user's memory does not hold. The `iter*`
123
139
  methods are async iterables that follow `next` from page to page:
124
140
 
125
141
  ```ts
@@ -60,12 +60,13 @@ function refsOf(memories) {
60
60
  }
61
61
 
62
62
  // src/search.ts
63
+ var BREAK = /\s*[\r\n]\s*/g;
63
64
  function line(memory) {
64
65
  const dated = memory.type === "excerpt" && memory.date ? `${memory.date.slice(0, 10)}: ` : "";
65
- return `- ${dated}${memory.text}`;
66
+ return `- ${dated}${memory.text.trim().replace(BREAK, " ")}`;
66
67
  }
67
68
  var SearchResult = class _SearchResult {
68
- constructor(query, answerable, notes, memories, sources2, failed, raw) {
69
+ constructor(query, answerable, notes, memories, sources2, failed, raw, searchId = null) {
69
70
  this.query = query;
70
71
  this.answerable = answerable;
71
72
  this.notes = notes;
@@ -73,6 +74,7 @@ var SearchResult = class _SearchResult {
73
74
  this.sources = sources2;
74
75
  this.failed = failed;
75
76
  this.raw = raw;
77
+ this.searchId = searchId;
76
78
  }
77
79
 
78
80
 
@@ -81,6 +83,7 @@ var SearchResult = class _SearchResult {
81
83
 
82
84
 
83
85
 
86
+
84
87
  static parse(value) {
85
88
  const raw = object(value);
86
89
  return new _SearchResult(
@@ -90,7 +93,8 @@ var SearchResult = class _SearchResult {
90
93
  parseMemories(raw.memories),
91
94
  Array.isArray(raw.sources) ? list(raw.sources).map(object) : null,
92
95
  false,
93
- raw
96
+ raw,
97
+ maybe(raw.search_id)
94
98
  );
95
99
  }
96
100
  /** What a `failOpen` client answers when memory could not be reached. */
@@ -112,7 +116,8 @@ var SearchResult = class _SearchResult {
112
116
  }
113
117
  /**
114
118
  * The text to paste into a prompt: each note on its own line, a blank line, then each memory on
115
- * its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`), cut at a whole
119
+ * its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`; a memory's
120
+ * own line breaks made spaces), cut at a whole
116
121
  * memory so it is never longer than `maxChars`. Empty when there are no memories, or when not
117
122
  * even the first fits. The Python client and the n8n node write the same text.
118
123
  */
@@ -240,7 +245,7 @@ function unreached(error, requestId2 = null) {
240
245
  }
241
246
 
242
247
  // src/version.ts
243
- var VERSION = "0.3.2";
248
+ var VERSION = "0.3.3";
244
249
 
245
250
  // src/settings.ts
246
251
  var DEFAULT_BASE_URL = "https://api.alexein.ai";
@@ -465,6 +470,77 @@ async function* paged(page, entries) {
465
470
  } while (cursor);
466
471
  }
467
472
 
473
+ // src/subjects.ts
474
+ var parseLink = (raw) => ({
475
+ link: text(raw.link),
476
+ ref: text(raw.ref),
477
+ date: maybe(raw.date),
478
+ source: maybe(raw.source),
479
+ raw
480
+ });
481
+ function parseSubject(value) {
482
+ const raw = object(value);
483
+ return {
484
+ name: text(raw.name),
485
+ facts: count(raw.facts),
486
+ about: objects(raw.about).map((a) => ({
487
+ text: text(a.text),
488
+ refs: strings(a.refs),
489
+ date: null,
490
+ raw: a
491
+ })),
492
+ values: objects(raw.values).map((v) => ({
493
+ attribute: text(v.attribute),
494
+ value: text(v.value),
495
+ since: maybe(v.since),
496
+ negated: v.negated === true,
497
+ raw: v
498
+ })),
499
+ timeline: objects(raw.timeline).map(parseFact),
500
+ conversations: objects(raw.conversations).map((c) => ({
501
+ text: text(c.text),
502
+ refs: c.ref ? [text(c.ref)] : [],
503
+ date: maybe(c.date),
504
+ raw: c
505
+ })),
506
+ links: objects(raw.links).map(parseLink),
507
+ suggestions: maybeStrings(raw.suggestions),
508
+ raw
509
+ };
510
+ }
511
+ function parseRelated(value) {
512
+ const raw = object(value);
513
+ const links = objects(raw.links).map(parseLink);
514
+ return { links, raw, [Symbol.iterator]: () => links[Symbol.iterator]() };
515
+ }
516
+ var parseCard = (raw) => ({
517
+ kind: text(raw.kind),
518
+ text: text(raw.text),
519
+ refs: strings(raw.refs),
520
+ surface: maybe(raw.surface),
521
+ from: strings(raw.from),
522
+ raw
523
+ });
524
+ function parseWays(value) {
525
+ const raw = object(value);
526
+ return {
527
+ who: text(raw.who),
528
+ cards: objects(raw.cards).map(parseCard),
529
+ procedures: strings(raw.procedures),
530
+ voice: maybe(raw.voice),
531
+ raw
532
+ };
533
+ }
534
+ function parseLessons(value) {
535
+ const raw = object(value);
536
+ return {
537
+ task: text(raw.task),
538
+ cards: objects(raw.cards).map(parseCard),
539
+ lessons: objects(raw.lessons).map(parseCard),
540
+ raw
541
+ };
542
+ }
543
+
468
544
  // src/writes.ts
469
545
  function addResult(items2, waiting, failed, raw) {
470
546
  return { items: items2, waiting, failed, ids: items2.map((i) => i.id), raw };
@@ -540,6 +616,19 @@ function parseDeleted(value) {
540
616
  const raw = object(value);
541
617
  return { user: text(raw.user), deleted: bool(raw.deleted), raw };
542
618
  }
619
+ function parseFeedback(value) {
620
+ const raw = object(value);
621
+ return {
622
+ searchId: text(raw.search_id),
623
+ verdict: text(raw.verdict),
624
+ status: text(raw.status),
625
+ raw
626
+ };
627
+ }
628
+ function parseRefreshed(value) {
629
+ const raw = object(value);
630
+ return { status: text(raw.status), raw };
631
+ }
543
632
 
544
633
  // src/calls.ts
545
634
  var kinds = (kind) => kind === void 0 ? void 0 : Array.isArray(kind) ? kind : [kind];
@@ -585,7 +674,11 @@ var latest = (o) => post("latest", parseMemoriesResult, {
585
674
  });
586
675
  var around = (ref, width) => post("around", parseMemoriesResult, { ref, width });
587
676
  var open = (ref) => post("open", parseOpened, { ref });
588
- var history = (subject, attribute) => post("history", parseHistory, { subject, attribute });
677
+ var subject = (name, limit) => post("subject", parseSubject, { name, limit });
678
+ var related = (ref) => post("related", parseRelated, { ref });
679
+ var howTheyWork = (o) => post("how_they_work", parseWays, { who: o.who, surface: o.surface });
680
+ var lessons = (task) => post("lessons", parseLessons, { task });
681
+ var history = (subject2, attribute) => post("history", parseHistory, { subject: subject2, attribute });
589
682
  var summary = () => post("summary", parseSummary);
590
683
  var facts = (o) => post("facts", parseFactsPage, { limit: o.limit, cursor: o.cursor });
591
684
  var openItems = (o) => post("open_items", parseOpenItems, {
@@ -612,6 +705,11 @@ function forget(named) {
612
705
  return post("forget", parseForgotten, body);
613
706
  }
614
707
  var correct = (ref, replacement) => post("correct", parseCorrection, { ref, replacement });
708
+ function feedback(searchId, verdict, note) {
709
+ if (!searchId) throw new RangeError("feedback needs the searchId a search answered with");
710
+ return post("feedback", parseFeedback, { search_id: searchId, verdict, note });
711
+ }
712
+ var refresh = () => post("refresh", parseRefreshed);
615
713
  var versions = (id) => post("versions", parseVersions, { id });
616
714
  var exportPage = (o) => post("export", parseExportPage, { limit: o.limit, cursor: o.cursor });
617
715
 
@@ -629,6 +727,11 @@ function batches(items2, options) {
629
727
  const { wait, redact, ...fields } = options;
630
728
  const defaults = compact(fields);
631
729
  const given = typeof items2 === "string" || !Array.isArray(items2) ? [items2] : items2;
730
+ if (fields.id !== void 0 && fields.id !== null && given.length > 1) {
731
+ throw new RangeError(
732
+ "id names one item, and this add has several: give each item its own id instead"
733
+ );
734
+ }
632
735
  const shaped = given.map((item2) => shape(item2, defaults));
633
736
  if (!shaped.length) return [];
634
737
  const call = crypto.randomUUID();
@@ -699,9 +802,34 @@ var User = class {
699
802
  open(ref) {
700
803
  return this.send(open(ref));
701
804
  }
805
+ /**
806
+ * One person or thing by name, whole: how it went, its values now, its facts in the order they
807
+ * were said, the conversations about it, and how it relates to others.
808
+ */
809
+ subject(name, options = {}) {
810
+ return this.send(subject(name, options.limit));
811
+ }
812
+ /** What the people and things one fact or excerpt names link to, by its ref. */
813
+ related(ref) {
814
+ return this.send(related(ref));
815
+ }
816
+ /**
817
+ * How the person works - their routines before an action and how they write on each `surface` -
818
+ * for an agent about to act or write for them. `who` names someone else.
819
+ */
820
+ howTheyWork(options = {}) {
821
+ return this.send(howTheyWork(options));
822
+ }
823
+ /**
824
+ * What an assistant should know before `task`: how the person corrected assistants and the notes
825
+ * they left on answers, most like it first.
826
+ */
827
+ lessons(task) {
828
+ return this.send(lessons(task));
829
+ }
702
830
  /** Every value a subject was stated to have, by attribute, oldest first. */
703
- history(subject, options = {}) {
704
- return this.send(history(subject, options.attribute));
831
+ history(subject2, options = {}) {
832
+ return this.send(history(subject2, options.attribute));
705
833
  }
706
834
  /** This memory in brief: its items, their span, the connected sources and the known lines. */
707
835
  summary() {
@@ -753,6 +881,22 @@ var User = class {
753
881
  correct(ref, replacement) {
754
882
  return this.send(correct(ref, replacement));
755
883
  }
884
+ /**
885
+ * Say how a search went - `wrong`, `missing` or `ok` - by its result or its `searchId`, and
886
+ * optionally what was true, so memory answers questions like it better. Kept as a note of this
887
+ * memory. Takes a key that writes.
888
+ */
889
+ async feedback(search2, verdict, options = {}) {
890
+ const searchId = typeof search2 === "string" ? search2 : search2.searchId;
891
+ return this.send(feedback(searchId, verdict, options.note));
892
+ }
893
+ /**
894
+ * Ask memory to bring what it has gathered of this app user up to date soon - after a large
895
+ * import, say. Once an hour per app user. Takes a key that writes.
896
+ */
897
+ refresh() {
898
+ return this.send(refresh());
899
+ }
756
900
  /** Every version of one added item, oldest first. Takes a key that writes. */
757
901
  versions(itemId) {
758
902
  return this.send(versions(itemId));
@@ -60,12 +60,13 @@ function refsOf(memories) {
60
60
  }
61
61
 
62
62
  // src/search.ts
63
+ var BREAK = /\s*[\r\n]\s*/g;
63
64
  function line(memory) {
64
65
  const dated = memory.type === "excerpt" && memory.date ? `${memory.date.slice(0, 10)}: ` : "";
65
- return `- ${dated}${memory.text}`;
66
+ return `- ${dated}${memory.text.trim().replace(BREAK, " ")}`;
66
67
  }
67
68
  var SearchResult = class _SearchResult {
68
- constructor(query, answerable, notes, memories, sources2, failed, raw) {
69
+ constructor(query, answerable, notes, memories, sources2, failed, raw, searchId = null) {
69
70
  this.query = query;
70
71
  this.answerable = answerable;
71
72
  this.notes = notes;
@@ -73,6 +74,7 @@ var SearchResult = class _SearchResult {
73
74
  this.sources = sources2;
74
75
  this.failed = failed;
75
76
  this.raw = raw;
77
+ this.searchId = searchId;
76
78
  }
77
79
  query;
78
80
  answerable;
@@ -81,6 +83,7 @@ var SearchResult = class _SearchResult {
81
83
  sources;
82
84
  failed;
83
85
  raw;
86
+ searchId;
84
87
  static parse(value) {
85
88
  const raw = object(value);
86
89
  return new _SearchResult(
@@ -90,7 +93,8 @@ var SearchResult = class _SearchResult {
90
93
  parseMemories(raw.memories),
91
94
  Array.isArray(raw.sources) ? list(raw.sources).map(object) : null,
92
95
  false,
93
- raw
96
+ raw,
97
+ maybe(raw.search_id)
94
98
  );
95
99
  }
96
100
  /** What a `failOpen` client answers when memory could not be reached. */
@@ -112,7 +116,8 @@ var SearchResult = class _SearchResult {
112
116
  }
113
117
  /**
114
118
  * The text to paste into a prompt: each note on its own line, a blank line, then each memory on
115
- * its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`), cut at a whole
119
+ * its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`; a memory's
120
+ * own line breaks made spaces), cut at a whole
116
121
  * memory so it is never longer than `maxChars`. Empty when there are no memories, or when not
117
122
  * even the first fits. The Python client and the n8n node write the same text.
118
123
  */
@@ -240,7 +245,7 @@ function unreached(error, requestId2 = null) {
240
245
  }
241
246
 
242
247
  // src/version.ts
243
- var VERSION = "0.3.2";
248
+ var VERSION = "0.3.3";
244
249
 
245
250
  // src/settings.ts
246
251
  var DEFAULT_BASE_URL = "https://api.alexein.ai";
@@ -465,6 +470,77 @@ async function* paged(page, entries) {
465
470
  } while (cursor);
466
471
  }
467
472
 
473
+ // src/subjects.ts
474
+ var parseLink = (raw) => ({
475
+ link: text(raw.link),
476
+ ref: text(raw.ref),
477
+ date: maybe(raw.date),
478
+ source: maybe(raw.source),
479
+ raw
480
+ });
481
+ function parseSubject(value) {
482
+ const raw = object(value);
483
+ return {
484
+ name: text(raw.name),
485
+ facts: count(raw.facts),
486
+ about: objects(raw.about).map((a) => ({
487
+ text: text(a.text),
488
+ refs: strings(a.refs),
489
+ date: null,
490
+ raw: a
491
+ })),
492
+ values: objects(raw.values).map((v) => ({
493
+ attribute: text(v.attribute),
494
+ value: text(v.value),
495
+ since: maybe(v.since),
496
+ negated: v.negated === true,
497
+ raw: v
498
+ })),
499
+ timeline: objects(raw.timeline).map(parseFact),
500
+ conversations: objects(raw.conversations).map((c) => ({
501
+ text: text(c.text),
502
+ refs: c.ref ? [text(c.ref)] : [],
503
+ date: maybe(c.date),
504
+ raw: c
505
+ })),
506
+ links: objects(raw.links).map(parseLink),
507
+ suggestions: maybeStrings(raw.suggestions),
508
+ raw
509
+ };
510
+ }
511
+ function parseRelated(value) {
512
+ const raw = object(value);
513
+ const links = objects(raw.links).map(parseLink);
514
+ return { links, raw, [Symbol.iterator]: () => links[Symbol.iterator]() };
515
+ }
516
+ var parseCard = (raw) => ({
517
+ kind: text(raw.kind),
518
+ text: text(raw.text),
519
+ refs: strings(raw.refs),
520
+ surface: maybe(raw.surface),
521
+ from: strings(raw.from),
522
+ raw
523
+ });
524
+ function parseWays(value) {
525
+ const raw = object(value);
526
+ return {
527
+ who: text(raw.who),
528
+ cards: objects(raw.cards).map(parseCard),
529
+ procedures: strings(raw.procedures),
530
+ voice: maybe(raw.voice),
531
+ raw
532
+ };
533
+ }
534
+ function parseLessons(value) {
535
+ const raw = object(value);
536
+ return {
537
+ task: text(raw.task),
538
+ cards: objects(raw.cards).map(parseCard),
539
+ lessons: objects(raw.lessons).map(parseCard),
540
+ raw
541
+ };
542
+ }
543
+
468
544
  // src/writes.ts
469
545
  function addResult(items2, waiting, failed, raw) {
470
546
  return { items: items2, waiting, failed, ids: items2.map((i) => i.id), raw };
@@ -540,6 +616,19 @@ function parseDeleted(value) {
540
616
  const raw = object(value);
541
617
  return { user: text(raw.user), deleted: bool(raw.deleted), raw };
542
618
  }
619
+ function parseFeedback(value) {
620
+ const raw = object(value);
621
+ return {
622
+ searchId: text(raw.search_id),
623
+ verdict: text(raw.verdict),
624
+ status: text(raw.status),
625
+ raw
626
+ };
627
+ }
628
+ function parseRefreshed(value) {
629
+ const raw = object(value);
630
+ return { status: text(raw.status), raw };
631
+ }
543
632
 
544
633
  // src/calls.ts
545
634
  var kinds = (kind) => kind === void 0 ? void 0 : Array.isArray(kind) ? kind : [kind];
@@ -585,7 +674,11 @@ var latest = (o) => post("latest", parseMemoriesResult, {
585
674
  });
586
675
  var around = (ref, width) => post("around", parseMemoriesResult, { ref, width });
587
676
  var open = (ref) => post("open", parseOpened, { ref });
588
- var history = (subject, attribute) => post("history", parseHistory, { subject, attribute });
677
+ var subject = (name, limit) => post("subject", parseSubject, { name, limit });
678
+ var related = (ref) => post("related", parseRelated, { ref });
679
+ var howTheyWork = (o) => post("how_they_work", parseWays, { who: o.who, surface: o.surface });
680
+ var lessons = (task) => post("lessons", parseLessons, { task });
681
+ var history = (subject2, attribute) => post("history", parseHistory, { subject: subject2, attribute });
589
682
  var summary = () => post("summary", parseSummary);
590
683
  var facts = (o) => post("facts", parseFactsPage, { limit: o.limit, cursor: o.cursor });
591
684
  var openItems = (o) => post("open_items", parseOpenItems, {
@@ -612,6 +705,11 @@ function forget(named) {
612
705
  return post("forget", parseForgotten, body);
613
706
  }
614
707
  var correct = (ref, replacement) => post("correct", parseCorrection, { ref, replacement });
708
+ function feedback(searchId, verdict, note) {
709
+ if (!searchId) throw new RangeError("feedback needs the searchId a search answered with");
710
+ return post("feedback", parseFeedback, { search_id: searchId, verdict, note });
711
+ }
712
+ var refresh = () => post("refresh", parseRefreshed);
615
713
  var versions = (id) => post("versions", parseVersions, { id });
616
714
  var exportPage = (o) => post("export", parseExportPage, { limit: o.limit, cursor: o.cursor });
617
715
 
@@ -629,6 +727,11 @@ function batches(items2, options) {
629
727
  const { wait, redact, ...fields } = options;
630
728
  const defaults = compact(fields);
631
729
  const given = typeof items2 === "string" || !Array.isArray(items2) ? [items2] : items2;
730
+ if (fields.id !== void 0 && fields.id !== null && given.length > 1) {
731
+ throw new RangeError(
732
+ "id names one item, and this add has several: give each item its own id instead"
733
+ );
734
+ }
632
735
  const shaped = given.map((item2) => shape(item2, defaults));
633
736
  if (!shaped.length) return [];
634
737
  const call = crypto.randomUUID();
@@ -699,9 +802,34 @@ var User = class {
699
802
  open(ref) {
700
803
  return this.send(open(ref));
701
804
  }
805
+ /**
806
+ * One person or thing by name, whole: how it went, its values now, its facts in the order they
807
+ * were said, the conversations about it, and how it relates to others.
808
+ */
809
+ subject(name, options = {}) {
810
+ return this.send(subject(name, options.limit));
811
+ }
812
+ /** What the people and things one fact or excerpt names link to, by its ref. */
813
+ related(ref) {
814
+ return this.send(related(ref));
815
+ }
816
+ /**
817
+ * How the person works - their routines before an action and how they write on each `surface` -
818
+ * for an agent about to act or write for them. `who` names someone else.
819
+ */
820
+ howTheyWork(options = {}) {
821
+ return this.send(howTheyWork(options));
822
+ }
823
+ /**
824
+ * What an assistant should know before `task`: how the person corrected assistants and the notes
825
+ * they left on answers, most like it first.
826
+ */
827
+ lessons(task) {
828
+ return this.send(lessons(task));
829
+ }
702
830
  /** Every value a subject was stated to have, by attribute, oldest first. */
703
- history(subject, options = {}) {
704
- return this.send(history(subject, options.attribute));
831
+ history(subject2, options = {}) {
832
+ return this.send(history(subject2, options.attribute));
705
833
  }
706
834
  /** This memory in brief: its items, their span, the connected sources and the known lines. */
707
835
  summary() {
@@ -753,6 +881,22 @@ var User = class {
753
881
  correct(ref, replacement) {
754
882
  return this.send(correct(ref, replacement));
755
883
  }
884
+ /**
885
+ * Say how a search went - `wrong`, `missing` or `ok` - by its result or its `searchId`, and
886
+ * optionally what was true, so memory answers questions like it better. Kept as a note of this
887
+ * memory. Takes a key that writes.
888
+ */
889
+ async feedback(search2, verdict, options = {}) {
890
+ const searchId = typeof search2 === "string" ? search2 : search2.searchId;
891
+ return this.send(feedback(searchId, verdict, options.note));
892
+ }
893
+ /**
894
+ * Ask memory to bring what it has gathered of this app user up to date soon - after a large
895
+ * import, say. Once an hour per app user. Takes a key that writes.
896
+ */
897
+ refresh() {
898
+ return this.send(refresh());
899
+ }
756
900
  /** Every version of one added item, oldest first. Takes a key that writes. */
757
901
  versions(itemId) {
758
902
  return this.send(versions(itemId));
@@ -2,7 +2,7 @@ import {
2
2
  AlexeinError,
3
3
  Memory,
4
4
  NotFoundError
5
- } from "./chunk-CKBVQNV5.js";
5
+ } from "./chunk-5YIOYX3J.js";
6
6
 
7
7
  // src/integrations/shared.ts
8
8
  var UNAVAILABLE = "Memory is unavailable right now; carry on without it.";
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkAJGT53UZcjs = require('./chunk-AJGT53UZ.cjs');
5
+ var _chunk34W2JJVDcjs = require('./chunk-34W2JJVD.cjs');
6
6
 
7
7
  // src/integrations/shared.ts
8
8
  var UNAVAILABLE = "Memory is unavailable right now; carry on without it.";
@@ -24,7 +24,7 @@ var LazyClient = class {
24
24
 
25
25
  #client;
26
26
  get client() {
27
- this.#client ??= new (0, _chunkAJGT53UZcjs.Memory)({
27
+ this.#client ??= new (0, _chunk34W2JJVDcjs.Memory)({
28
28
  failOpen: !this.strict,
29
29
  integration: this.integration,
30
30
  timeout: this.timeout
@@ -39,7 +39,7 @@ async function searchFor(user, query, fast) {
39
39
  try {
40
40
  return await user.search(query.slice(-MAX_QUERY), { fast });
41
41
  } catch (error) {
42
- if (error instanceof _chunkAJGT53UZcjs.NotFoundError) return void 0;
42
+ if (error instanceof _chunk34W2JJVDcjs.NotFoundError) return void 0;
43
43
  throw error;
44
44
  }
45
45
  }
@@ -69,7 +69,7 @@ function notFoundAnswer(error) {
69
69
  return /\bref\b/.test(error.detail) ? "Memory holds nothing by that ref." : NOTHING_YET;
70
70
  }
71
71
  function outageAnswer(error, strict) {
72
- if (strict || !(error instanceof _chunkAJGT53UZcjs.AlexeinError) || !error.outage) throw error;
72
+ if (strict || !(error instanceof _chunk34W2JJVDcjs.AlexeinError) || !error.outage) throw error;
73
73
  console.warn(`Alexein is unavailable: ${error.message}`);
74
74
  return UNAVAILABLE;
75
75
  }