@alexein/sdk 0.3.1 → 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 +23 -0
- package/README.md +30 -13
- package/dist/{chunk-BIGISYZR.cjs → chunk-34W2JJVD.cjs} +177 -17
- package/dist/{chunk-DADXKQLZ.js → chunk-5YIOYX3J.js} +176 -16
- package/dist/{chunk-3LJEU4WL.js → chunk-HDNKPJS2.js} +1 -1
- package/dist/{chunk-PSATR3NL.cjs → chunk-LWBADF3F.cjs} +4 -4
- package/dist/{client-YKZ4fkK-.d.cts → client-Bz10lVYG.d.cts} +158 -5
- package/dist/{client-YKZ4fkK-.d.ts → client-Bz10lVYG.d.ts} +158 -5
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +20 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.js +3 -1
- package/dist/langgraph.cjs +15 -15
- package/dist/langgraph.d.cts +1 -1
- package/dist/langgraph.d.ts +1 -1
- package/dist/langgraph.js +2 -2
- package/dist/openai-agents.cjs +18 -18
- package/dist/openai-agents.d.cts +1 -1
- package/dist/openai-agents.d.ts +1 -1
- package/dist/openai-agents.js +2 -2
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ function parseExcerpt(value) {
|
|
|
36
36
|
date: maybe(raw.date),
|
|
37
37
|
addedAt: maybe(raw.added_at),
|
|
38
38
|
session: maybe(raw.session),
|
|
39
|
-
roles: strings(raw.roles),
|
|
39
|
+
roles: raw.roles === void 0 ? ["other"] : strings(raw.roles),
|
|
40
40
|
raw
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -44,7 +44,7 @@ function parseMemory(value) {
|
|
|
44
44
|
const raw = object(value);
|
|
45
45
|
if (raw.type === "known") return { type: "known", text: text(raw.text), raw };
|
|
46
46
|
if (raw.type === "fact") return parseFact(raw);
|
|
47
|
-
if (raw.type === "excerpt") return parseExcerpt(raw);
|
|
47
|
+
if (raw.type === "excerpt" || raw.type === void 0) return parseExcerpt(raw);
|
|
48
48
|
return void 0;
|
|
49
49
|
}
|
|
50
50
|
function parseMemories(value) {
|
|
@@ -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
|
|
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
|
*/
|
|
@@ -168,6 +173,21 @@ var NotFoundError = class extends AlexeinError {
|
|
|
168
173
|
};
|
|
169
174
|
var InvalidRequestError = class extends AlexeinError {
|
|
170
175
|
};
|
|
176
|
+
var QuotaExceededError = class extends AlexeinError {
|
|
177
|
+
limit;
|
|
178
|
+
used;
|
|
179
|
+
included;
|
|
180
|
+
resetsAt;
|
|
181
|
+
upgrade;
|
|
182
|
+
constructor(message, fields = {}, body = {}) {
|
|
183
|
+
super(message, fields);
|
|
184
|
+
this.limit = maybe(body.limit);
|
|
185
|
+
this.used = maybeCount(body.used);
|
|
186
|
+
this.included = maybeCount(body.included);
|
|
187
|
+
this.resetsAt = maybe(body.resets_at);
|
|
188
|
+
this.upgrade = maybe(body.upgrade);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
171
191
|
var RateLimitError = class extends AlexeinError {
|
|
172
192
|
};
|
|
173
193
|
var ServiceUnavailableError = class extends AlexeinError {
|
|
@@ -181,6 +201,7 @@ var APITimeoutError = class extends APIConnectionError {
|
|
|
181
201
|
};
|
|
182
202
|
function kindOf(status2) {
|
|
183
203
|
if (status2 === 401) return AuthenticationError;
|
|
204
|
+
if (status2 === 402) return QuotaExceededError;
|
|
184
205
|
if (status2 === 403) return PermissionDeniedError;
|
|
185
206
|
if (status2 === 404) return NotFoundError;
|
|
186
207
|
if (status2 === 429) return RateLimitError;
|
|
@@ -202,12 +223,11 @@ function errorFor(status2, body, requestId2) {
|
|
|
202
223
|
const errors = fieldErrors(body.errors ?? (Array.isArray(body.detail) ? body.detail : []));
|
|
203
224
|
const detail = typeof body.detail === "string" ? body.detail : errors.map((e) => e.field ? `${e.field}: ${e.message}` : e.message).join("; ");
|
|
204
225
|
const Kind = kindOf(status2);
|
|
205
|
-
return new Kind(
|
|
206
|
-
|
|
207
|
-
detail,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
});
|
|
226
|
+
return new Kind(
|
|
227
|
+
detail ? `${status2}: ${detail}` : String(status2),
|
|
228
|
+
{ status: status2, detail, errors, requestId: requestId2 },
|
|
229
|
+
body
|
|
230
|
+
);
|
|
211
231
|
}
|
|
212
232
|
function unreached(error, requestId2 = null) {
|
|
213
233
|
const name = error instanceof Error ? error.name : "";
|
|
@@ -225,7 +245,7 @@ function unreached(error, requestId2 = null) {
|
|
|
225
245
|
}
|
|
226
246
|
|
|
227
247
|
// src/version.ts
|
|
228
|
-
var VERSION = "0.3.
|
|
248
|
+
var VERSION = "0.3.3";
|
|
229
249
|
|
|
230
250
|
// src/settings.ts
|
|
231
251
|
var DEFAULT_BASE_URL = "https://api.alexein.ai";
|
|
@@ -450,6 +470,77 @@ async function* paged(page, entries) {
|
|
|
450
470
|
} while (cursor);
|
|
451
471
|
}
|
|
452
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
|
+
|
|
453
544
|
// src/writes.ts
|
|
454
545
|
function addResult(items2, waiting, failed, raw) {
|
|
455
546
|
return { items: items2, waiting, failed, ids: items2.map((i) => i.id), raw };
|
|
@@ -525,6 +616,19 @@ function parseDeleted(value) {
|
|
|
525
616
|
const raw = object(value);
|
|
526
617
|
return { user: text(raw.user), deleted: bool(raw.deleted), raw };
|
|
527
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
|
+
}
|
|
528
632
|
|
|
529
633
|
// src/calls.ts
|
|
530
634
|
var kinds = (kind) => kind === void 0 ? void 0 : Array.isArray(kind) ? kind : [kind];
|
|
@@ -570,7 +674,11 @@ var latest = (o) => post("latest", parseMemoriesResult, {
|
|
|
570
674
|
});
|
|
571
675
|
var around = (ref, width) => post("around", parseMemoriesResult, { ref, width });
|
|
572
676
|
var open = (ref) => post("open", parseOpened, { ref });
|
|
573
|
-
var
|
|
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 });
|
|
574
682
|
var summary = () => post("summary", parseSummary);
|
|
575
683
|
var facts = (o) => post("facts", parseFactsPage, { limit: o.limit, cursor: o.cursor });
|
|
576
684
|
var openItems = (o) => post("open_items", parseOpenItems, {
|
|
@@ -597,6 +705,11 @@ function forget(named) {
|
|
|
597
705
|
return post("forget", parseForgotten, body);
|
|
598
706
|
}
|
|
599
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);
|
|
600
713
|
var versions = (id) => post("versions", parseVersions, { id });
|
|
601
714
|
var exportPage = (o) => post("export", parseExportPage, { limit: o.limit, cursor: o.cursor });
|
|
602
715
|
|
|
@@ -614,6 +727,11 @@ function batches(items2, options) {
|
|
|
614
727
|
const { wait, redact, ...fields } = options;
|
|
615
728
|
const defaults = compact(fields);
|
|
616
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
|
+
}
|
|
617
735
|
const shaped = given.map((item2) => shape(item2, defaults));
|
|
618
736
|
if (!shaped.length) return [];
|
|
619
737
|
const call = crypto.randomUUID();
|
|
@@ -684,9 +802,34 @@ var User = class {
|
|
|
684
802
|
open(ref) {
|
|
685
803
|
return this.send(open(ref));
|
|
686
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
|
+
}
|
|
687
830
|
/** Every value a subject was stated to have, by attribute, oldest first. */
|
|
688
|
-
history(
|
|
689
|
-
return this.send(history(
|
|
831
|
+
history(subject2, options = {}) {
|
|
832
|
+
return this.send(history(subject2, options.attribute));
|
|
690
833
|
}
|
|
691
834
|
/** This memory in brief: its items, their span, the connected sources and the known lines. */
|
|
692
835
|
summary() {
|
|
@@ -738,6 +881,22 @@ var User = class {
|
|
|
738
881
|
correct(ref, replacement) {
|
|
739
882
|
return this.send(correct(ref, replacement));
|
|
740
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
|
+
}
|
|
741
900
|
/** Every version of one added item, oldest first. Takes a key that writes. */
|
|
742
901
|
versions(itemId) {
|
|
743
902
|
return this.send(versions(itemId));
|
|
@@ -907,6 +1066,7 @@ export {
|
|
|
907
1066
|
PermissionDeniedError,
|
|
908
1067
|
NotFoundError,
|
|
909
1068
|
InvalidRequestError,
|
|
1069
|
+
QuotaExceededError,
|
|
910
1070
|
RateLimitError,
|
|
911
1071
|
ServiceUnavailableError,
|
|
912
1072
|
APIConnectionError,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
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,
|
|
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
|
|
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
|
|
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
|
}
|
|
@@ -38,7 +38,11 @@ interface Excerpt {
|
|
|
38
38
|
/** When memory took it. */
|
|
39
39
|
readonly addedAt: string | null;
|
|
40
40
|
readonly session: string | null;
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The roles of who spoke in it: `user`, `assistant`, `other` for someone else. A line from
|
|
43
|
+
* grep or latest carries roles only when the person or an assistant spoke, so one without is
|
|
44
|
+
* read as `["other"]`.
|
|
45
|
+
*/
|
|
42
46
|
readonly roles: string[];
|
|
43
47
|
readonly raw: Json;
|
|
44
48
|
}
|
|
@@ -183,6 +187,11 @@ interface ItemDefaults {
|
|
|
183
187
|
}
|
|
184
188
|
/** Options `add` takes besides the items. */
|
|
185
189
|
interface AddOptions extends ItemDefaults {
|
|
190
|
+
/**
|
|
191
|
+
* The id of the one item added, so the same id again edits it. With several items, give each
|
|
192
|
+
* its own `id`: here it is a RangeError, since one id would make them edits of one another.
|
|
193
|
+
*/
|
|
194
|
+
id?: string;
|
|
186
195
|
/** Answer once the items are searchable (briefly waited for). */
|
|
187
196
|
wait?: boolean;
|
|
188
197
|
/** Replace phone numbers, cards, keys and the like with their kind before memory keeps them. */
|
|
@@ -279,7 +288,8 @@ interface Me {
|
|
|
279
288
|
* What memory holds for a question. `memories` come in order: known lines, then facts, then
|
|
280
289
|
* excerpts. `answerable` is false when memory does not seem to hold the answer, and null when it
|
|
281
290
|
* was not checked. `failed` is true when a `failOpen` client could not reach memory, and the
|
|
282
|
-
* result is empty for that reason.
|
|
291
|
+
* result is empty for that reason. `searchId` is what `feedback()` takes to say how the search
|
|
292
|
+
* went (null when failed).
|
|
283
293
|
*/
|
|
284
294
|
declare class SearchResult {
|
|
285
295
|
readonly query: string;
|
|
@@ -289,7 +299,8 @@ declare class SearchResult {
|
|
|
289
299
|
readonly sources: Json[] | null;
|
|
290
300
|
readonly failed: boolean;
|
|
291
301
|
readonly raw: Json;
|
|
292
|
-
|
|
302
|
+
readonly searchId: string | null;
|
|
303
|
+
constructor(query: string, answerable: boolean | null, notes: string[], memories: MemoryEntry[], sources: Json[] | null, failed: boolean, raw: Json, searchId?: string | null);
|
|
293
304
|
static parse(value: unknown): SearchResult;
|
|
294
305
|
/** What a `failOpen` client answers when memory could not be reached. */
|
|
295
306
|
static unavailable(query: string): SearchResult;
|
|
@@ -300,13 +311,100 @@ declare class SearchResult {
|
|
|
300
311
|
get refs(): string[];
|
|
301
312
|
/**
|
|
302
313
|
* 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
|
|
314
|
+
* its own line as `- <text>` (an excerpt with a date as `- <YYYY-MM-DD>: <text>`; a memory's
|
|
315
|
+
* own line breaks made spaces), cut at a whole
|
|
304
316
|
* memory so it is never longer than `maxChars`. Empty when there are no memories, or when not
|
|
305
317
|
* even the first fits. The Python client and the n8n node write the same text.
|
|
306
318
|
*/
|
|
307
319
|
context(maxChars?: number): string;
|
|
308
320
|
}
|
|
309
321
|
|
|
322
|
+
/**
|
|
323
|
+
* What the routes about people and things answer: one subject whole, what a memory links to, how
|
|
324
|
+
* the person works, and the lessons they taught assistants. Each keeps its JSON in `raw`.
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* How one person or thing relates to another, in words (`link`): the day it was said, the ref of
|
|
329
|
+
* the fact that says it, and the ref of the excerpt that fact was learned from (null when unknown,
|
|
330
|
+
* and on `subject()` links).
|
|
331
|
+
*/
|
|
332
|
+
interface Link {
|
|
333
|
+
readonly link: string;
|
|
334
|
+
readonly ref: string;
|
|
335
|
+
readonly date: string | null;
|
|
336
|
+
readonly source: string | null;
|
|
337
|
+
readonly raw: Json;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* A line for a model, with the refs of the facts it rests on: a subject's `about`, and a
|
|
341
|
+
* conversation about it (whose one ref is an excerpt of that conversation).
|
|
342
|
+
*/
|
|
343
|
+
interface Line {
|
|
344
|
+
readonly text: string;
|
|
345
|
+
readonly refs: string[];
|
|
346
|
+
readonly date: string | null;
|
|
347
|
+
readonly raw: Json;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* One person or thing by name, whole: `about`, a few lines on how it went; `values`, each
|
|
351
|
+
* property's newest value; `timeline`, its facts oldest first; `conversations` about it; `links`
|
|
352
|
+
* to other people and things. `facts` is 0 when memory holds nothing by that name, and then
|
|
353
|
+
* `suggestions` names the nearest it does.
|
|
354
|
+
*/
|
|
355
|
+
interface Subject {
|
|
356
|
+
readonly name: string;
|
|
357
|
+
readonly facts: number;
|
|
358
|
+
readonly about: Line[];
|
|
359
|
+
readonly values: Value[];
|
|
360
|
+
readonly timeline: Fact[];
|
|
361
|
+
readonly conversations: Line[];
|
|
362
|
+
readonly links: Link[];
|
|
363
|
+
readonly suggestions: string[] | null;
|
|
364
|
+
readonly raw: Json;
|
|
365
|
+
}
|
|
366
|
+
/** What the people and things one memory names link to, newest said first. Iterable. */
|
|
367
|
+
interface Related extends Iterable<Link> {
|
|
368
|
+
readonly links: Link[];
|
|
369
|
+
readonly raw: Json;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* A plain line for a model, and the refs of the facts it cites. `kind` says what it is: `routine`
|
|
373
|
+
* or `style` from `howTheyWork()` (`surface` names where a style is for), `lesson` from
|
|
374
|
+
* `lessons()` (`from` says what it came from: `correction`, `feedback` or `said`), or `strategy`,
|
|
375
|
+
* `failure` or `workflow` among a `Lessons`' `lessons`. The counts a card rests on are in `raw`.
|
|
376
|
+
*/
|
|
377
|
+
interface Card {
|
|
378
|
+
readonly kind: string;
|
|
379
|
+
readonly text: string;
|
|
380
|
+
readonly refs: string[];
|
|
381
|
+
readonly surface: string | null;
|
|
382
|
+
readonly from: string[];
|
|
383
|
+
readonly raw: Json;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* How someone works: `cards`, each a routine or a writing style; `procedures`, each routine's
|
|
387
|
+
* counts written out for a model; `voice`, how they write, or null when memory has too few of
|
|
388
|
+
* their messages to say.
|
|
389
|
+
*/
|
|
390
|
+
interface Ways {
|
|
391
|
+
readonly who: string;
|
|
392
|
+
readonly cards: Card[];
|
|
393
|
+
readonly procedures: string[];
|
|
394
|
+
readonly voice: string | null;
|
|
395
|
+
readonly raw: Json;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* What an assistant should know before a task like `task`: `cards`, the lessons the person taught,
|
|
399
|
+
* most like it first; `lessons`, what earlier attempts at similar tasks taught.
|
|
400
|
+
*/
|
|
401
|
+
interface Lessons {
|
|
402
|
+
readonly task: string;
|
|
403
|
+
readonly cards: Card[];
|
|
404
|
+
readonly lessons: Card[];
|
|
405
|
+
readonly raw: Json;
|
|
406
|
+
}
|
|
407
|
+
|
|
310
408
|
/** The client's settings: from its options, else the environment, else the defaults. */
|
|
311
409
|
declare const DEFAULT_BASE_URL = "https://api.alexein.ai";
|
|
312
410
|
/** Long enough for the slowest search and an add that waits; a caller that cannot wait sets less. */
|
|
@@ -456,6 +554,21 @@ interface Deleted {
|
|
|
456
554
|
readonly deleted: boolean;
|
|
457
555
|
readonly raw: Json;
|
|
458
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Feedback on one search, kept as a note of this app user's memory: the search id and verdict as
|
|
559
|
+
* sent, and the note's `status`, `queued` or `stored` as an add answers it.
|
|
560
|
+
*/
|
|
561
|
+
interface Feedback {
|
|
562
|
+
readonly searchId: string;
|
|
563
|
+
readonly verdict: string;
|
|
564
|
+
readonly status: string;
|
|
565
|
+
readonly raw: Json;
|
|
566
|
+
}
|
|
567
|
+
/** A refresh asked for: `queued`, or `already_queued` when one was already waiting or under way. */
|
|
568
|
+
interface Refreshed {
|
|
569
|
+
readonly status: string;
|
|
570
|
+
readonly raw: Json;
|
|
571
|
+
}
|
|
459
572
|
|
|
460
573
|
/**
|
|
461
574
|
* Each route as the request it is: path, body and how to read the answer. Written once here and
|
|
@@ -510,6 +623,14 @@ interface PageOptions {
|
|
|
510
623
|
interface ItemsOptions extends PageOptions {
|
|
511
624
|
filters?: Filters;
|
|
512
625
|
}
|
|
626
|
+
interface HowTheyWorkOptions {
|
|
627
|
+
/** Someone in this memory, by name; absent, the person. */
|
|
628
|
+
who?: string;
|
|
629
|
+
/** Where the writing is for, such as a channel or a repository; absent, where they write most. */
|
|
630
|
+
surface?: string;
|
|
631
|
+
}
|
|
632
|
+
/** How a search went: wrong, the answer missing from it, or fine. */
|
|
633
|
+
type Verdict = "wrong" | "missing" | "ok";
|
|
513
634
|
interface ForgetOptions {
|
|
514
635
|
items?: string[];
|
|
515
636
|
sessions?: string[];
|
|
@@ -547,6 +668,25 @@ declare class User {
|
|
|
547
668
|
}): Promise<Memories>;
|
|
548
669
|
/** One memory by its ref, whole: an excerpt, or a fact with the excerpts it came from. */
|
|
549
670
|
open(ref: string): Promise<Opened>;
|
|
671
|
+
/**
|
|
672
|
+
* One person or thing by name, whole: how it went, its values now, its facts in the order they
|
|
673
|
+
* were said, the conversations about it, and how it relates to others.
|
|
674
|
+
*/
|
|
675
|
+
subject(name: string, options?: {
|
|
676
|
+
limit?: number;
|
|
677
|
+
}): Promise<Subject>;
|
|
678
|
+
/** What the people and things one fact or excerpt names link to, by its ref. */
|
|
679
|
+
related(ref: string): Promise<Related>;
|
|
680
|
+
/**
|
|
681
|
+
* How the person works - their routines before an action and how they write on each `surface` -
|
|
682
|
+
* for an agent about to act or write for them. `who` names someone else.
|
|
683
|
+
*/
|
|
684
|
+
howTheyWork(options?: HowTheyWorkOptions): Promise<Ways>;
|
|
685
|
+
/**
|
|
686
|
+
* What an assistant should know before `task`: how the person corrected assistants and the notes
|
|
687
|
+
* they left on answers, most like it first.
|
|
688
|
+
*/
|
|
689
|
+
lessons(task: string): Promise<Lessons>;
|
|
550
690
|
/** Every value a subject was stated to have, by attribute, oldest first. */
|
|
551
691
|
history(subject: string, options?: {
|
|
552
692
|
attribute?: string;
|
|
@@ -578,6 +718,19 @@ declare class User {
|
|
|
578
718
|
forget(named: ForgetOptions): Promise<Forgotten>;
|
|
579
719
|
/** Retract one fact for good, by its ref; a `replacement` is kept as a note. */
|
|
580
720
|
correct(ref: string, replacement?: string): Promise<Correction>;
|
|
721
|
+
/**
|
|
722
|
+
* Say how a search went - `wrong`, `missing` or `ok` - by its result or its `searchId`, and
|
|
723
|
+
* optionally what was true, so memory answers questions like it better. Kept as a note of this
|
|
724
|
+
* memory. Takes a key that writes.
|
|
725
|
+
*/
|
|
726
|
+
feedback(search: SearchResult | string, verdict: Verdict, options?: {
|
|
727
|
+
note?: string;
|
|
728
|
+
}): Promise<Feedback>;
|
|
729
|
+
/**
|
|
730
|
+
* Ask memory to bring what it has gathered of this app user up to date soon - after a large
|
|
731
|
+
* import, say. Once an hour per app user. Takes a key that writes.
|
|
732
|
+
*/
|
|
733
|
+
refresh(): Promise<Refreshed>;
|
|
581
734
|
/** Every version of one added item, oldest first. Takes a key that writes. */
|
|
582
735
|
versions(itemId: string): Promise<Versions>;
|
|
583
736
|
/** Everything memory holds for this app user, a page at a time. */
|
|
@@ -638,4 +791,4 @@ declare class Memory {
|
|
|
638
791
|
close(): void;
|
|
639
792
|
}
|
|
640
793
|
|
|
641
|
-
export { type
|
|
794
|
+
export { type Sources as $, type AddOptions as A, type Memories as B, type Card 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, Memory as N, type MemoryEntry as O, type MemoryOptions as P, type OpenItem as Q, type OpenItems as R, type OpenItemsOptions as S, type Opened as T, type Origin as U, type PageOptions as V, type Refreshed as W, type Related as X, type SearchOptions as Y, SearchResult as Z, type Source as _, type AddResult as a, type Statuses as a0, type StoredItem as a1, type Subject as a2, type Summary as a3, User as a4, type UsersPage as a5, type Value as a6, type Verdict as a7, type VersionEntry as a8, type Versions as a9, type Ways as aa, type AddedItem as b, type Adding as c, type AppUser as d, type Author as e, type Correction as f, DEFAULT_RETRIES as g, DEFAULT_TIMEOUT_MS as h, type Deleted as i, type Excerpt as j, type ExportPage as k, type ExportRecord as l, type FactsPage as m, type Feedback as n, type Filters as o, type FollowUp as p, type ForgetOptions as q, type Forgotten as r, type HowTheyWorkOptions as s, type ItemDefaults as t, type ItemStatus as u, type ItemsOptions as v, type ItemsPage as w, type Lessons as x, type Line as y, type Link as z };
|