korely-memory 0.1.12 → 0.1.14
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/README.md +9 -5
- package/dist/index.cjs +32 -12
- package/dist/index.d.cts +35 -6
- package/dist/index.d.ts +35 -6
- package/dist/index.js +32 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ Every method maps to one REST endpoint.
|
|
|
95
95
|
| Method | Endpoint | |
|
|
96
96
|
|---|---|---|
|
|
97
97
|
| `add(content, opts?)` | `POST /v1/memories` | Write. `content` is a string or a list of chat messages. `opts.timestamp` (ISO) backfills the past: facts inherit it as `valid_from`. |
|
|
98
|
-
| `search(query, opts?)` | `POST /v1/memories/search` | Semantic search over memories; filter by `user_id`, `agent_id`, `run_id`, `metadata
|
|
98
|
+
| `search(query, opts?)` | `POST /v1/memories/search` | Semantic search over memories; filter by `user_id`, `agent_id`, `run_id`, `metadata`; `min_score` (0 to 1) leaves out hits scored below it. |
|
|
99
99
|
| `getAll(opts?)` | `GET /v1/memories` | List a scope, newest first. The page is iterable; `limit` up to 200. |
|
|
100
100
|
| `get(id)` | `GET /v1/memories/:id` | One memory, with its facts. |
|
|
101
101
|
| `update(id, { content })` | `PATCH /v1/memories/:id` | Re-runs extraction. |
|
|
@@ -105,12 +105,12 @@ Every method maps to one REST endpoint.
|
|
|
105
105
|
| `users(opts?)` | `GET /v1/users` | Your end users, with counts. |
|
|
106
106
|
| `listAgents(opts?)` | `GET /v1/agents` | This project's agent namespaces, with counts. `total` counts this project's names, `used` the cap slots taken across the account. Call after `agent_cap_exceeded` to reuse an id. |
|
|
107
107
|
| `deleteAgent(agentId)` | `DELETE /v1/agents/:agent_id` | Purge an agent namespace of this project. `NotFoundError` for a name the project does not use; `slot_freed` says whether the cap slot is free now. |
|
|
108
|
-
| `getFacts(opts?)` | `GET /v1/facts` | Typed facts; `as_of` for
|
|
108
|
+
| `getFacts(opts?)` | `GET /v1/facts` | Typed facts; `as_of` for what was true on a date, `known_as_of` for what the store knew on it. The array also carries `total`. |
|
|
109
109
|
| `addFactTriple(s, p, o, opts?)` | `POST /v1/facts` | Write a fact directly (bi-temporal; `tense: "past"` for one that is over). |
|
|
110
110
|
| `correctFact(id, changes)` | `PATCH /v1/facts/:id` | Supersede a fact with a corrected one; `invalidated` lists what it closed. Restating the fact as it stands reconfirms it (`invalidated: []`). |
|
|
111
111
|
| `forgetFact(id, { at? })` | `POST /v1/facts/:id/forget` | Close a fact; it stays in history. |
|
|
112
|
-
| `getProfile({ user_id, as_of? })` | `GET /v1/profile` | The assembled profile of one end user. |
|
|
113
|
-
| `getContext({ query, user_id? })` | `GET /v1/context` | One call, a prompt-ready context block. |
|
|
112
|
+
| `getProfile({ user_id, as_of?, known_as_of? })` | `GET /v1/profile` | The assembled profile of one end user. |
|
|
113
|
+
| `getContext({ query, user_id?, known_as_of? })` | `GET /v1/context` | One call, a prompt-ready context block; `known_as_of` rebuilds it as the store could have built it then. |
|
|
114
114
|
| `events(opts?)` | `GET /v1/events` | Which writes are still being extracted; `limit` up to 200. |
|
|
115
115
|
| `batch(memories)` | `POST /v1/batch` | Bulk import, for migrations. Each item takes `timestamp`, as `add()` does. |
|
|
116
116
|
| `batchStatus(jobId)` | `GET /v1/batch/:id` | Poll an import job. |
|
|
@@ -126,9 +126,13 @@ Every write extracts typed `(subject, predicate, object)` facts with validity in
|
|
|
126
126
|
time. Ask what was true on a past date:
|
|
127
127
|
|
|
128
128
|
```ts
|
|
129
|
-
// What
|
|
129
|
+
// What was true for this user on March 1st, as the store knows it today?
|
|
130
130
|
const past = await korely.getProfile({ user_id: "customer-4812", as_of: "2026-03-01" });
|
|
131
131
|
|
|
132
|
+
// And what did the store know on March 1st? A change told later is not in it
|
|
133
|
+
// (Korely Agent 0.1.26).
|
|
134
|
+
const knownThen = await korely.getProfile({ user_id: "customer-4812", known_as_of: "2026-03-01" });
|
|
135
|
+
|
|
132
136
|
// Write a fact directly, dated in the past
|
|
133
137
|
await korely.addFactTriple("Marco", "works_at", "Acme GmbH", {
|
|
134
138
|
user_id: "customer-4812",
|
package/dist/index.cjs
CHANGED
|
@@ -126,12 +126,12 @@ function unknownOption(method, opts, known) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// src/client.ts
|
|
129
|
-
var VERSION = "0.1.
|
|
129
|
+
var VERSION = "0.1.14";
|
|
130
130
|
var REGIONS = { eu: "https://api.korely.ai" };
|
|
131
131
|
var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
|
|
132
132
|
var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
|
|
133
133
|
var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp");
|
|
134
|
-
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit");
|
|
134
|
+
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit", "min_score");
|
|
135
135
|
var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
|
|
136
136
|
var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
|
|
137
137
|
var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
|
|
@@ -146,6 +146,7 @@ var FACTS_KEYS = keysOf()(
|
|
|
146
146
|
"predicate_family",
|
|
147
147
|
"include_invalidated",
|
|
148
148
|
"as_of",
|
|
149
|
+
"known_as_of",
|
|
149
150
|
"user_id",
|
|
150
151
|
"agent_id",
|
|
151
152
|
"limit",
|
|
@@ -161,9 +162,20 @@ var TRIPLE_KEYS = keysOf()(
|
|
|
161
162
|
"valid_from",
|
|
162
163
|
"tense"
|
|
163
164
|
);
|
|
164
|
-
var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of");
|
|
165
|
-
var CONTEXT_KEYS = keysOf()(
|
|
166
|
-
|
|
165
|
+
var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of", "known_as_of");
|
|
166
|
+
var CONTEXT_KEYS = keysOf()(
|
|
167
|
+
"query",
|
|
168
|
+
"user_id",
|
|
169
|
+
"agent_id",
|
|
170
|
+
"token_budget",
|
|
171
|
+
"known_as_of"
|
|
172
|
+
);
|
|
173
|
+
var CONTEXT_EXTRA_KEYS = keysOf()(
|
|
174
|
+
"user_id",
|
|
175
|
+
"agent_id",
|
|
176
|
+
"token_budget",
|
|
177
|
+
"known_as_of"
|
|
178
|
+
);
|
|
167
179
|
function checkOptions(method, opts, known) {
|
|
168
180
|
const problem = unknownOption(method, opts, known);
|
|
169
181
|
if (problem) throw new KorelyError(problem);
|
|
@@ -635,7 +647,8 @@ var Korely = class {
|
|
|
635
647
|
agent_id: opts.agent_id,
|
|
636
648
|
run_id: opts.run_id,
|
|
637
649
|
metadata: opts.metadata,
|
|
638
|
-
limit: opts.limit
|
|
650
|
+
limit: opts.limit,
|
|
651
|
+
min_score: opts.min_score
|
|
639
652
|
}
|
|
640
653
|
});
|
|
641
654
|
return body.results ?? [];
|
|
@@ -776,8 +789,10 @@ var Korely = class {
|
|
|
776
789
|
// ── facts ─────────────────────────────────────────────────────────────────
|
|
777
790
|
/**
|
|
778
791
|
* GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
|
|
779
|
-
* validity. Pass `as_of` (ISO date) for a point-in-time query
|
|
780
|
-
*
|
|
792
|
+
* validity. Pass `as_of` (ISO date) for a point-in-time query, and
|
|
793
|
+
* `known_as_of` (ISO date) for what the store knew on that date (Korely
|
|
794
|
+
* Agent 0.1.26; older servers ignore it). Resolves to an array that also
|
|
795
|
+
* carries `total`, the matches across all pages.
|
|
781
796
|
*/
|
|
782
797
|
async getFacts(opts = {}) {
|
|
783
798
|
checkOptions("getFacts", opts, FACTS_KEYS);
|
|
@@ -787,6 +802,7 @@ var Korely = class {
|
|
|
787
802
|
predicate: opts.predicate,
|
|
788
803
|
predicate_family: opts.predicate_family,
|
|
789
804
|
as_of: opts.as_of,
|
|
805
|
+
known_as_of: opts.known_as_of,
|
|
790
806
|
user_id: opts.user_id,
|
|
791
807
|
agent_id: opts.agent_id,
|
|
792
808
|
limit: opts.limit ?? 50,
|
|
@@ -873,7 +889,8 @@ var Korely = class {
|
|
|
873
889
|
/**
|
|
874
890
|
* GET /v1/profile: the assembled profile of one end user, the active typed
|
|
875
891
|
* facts known about them, the end user's own facts first, grouped by family.
|
|
876
|
-
* Pass `as_of` (ISO date) for the point-in-time profile
|
|
892
|
+
* Pass `as_of` (ISO date) for the point-in-time profile, `known_as_of` for
|
|
893
|
+
* the profile as the store knew it then.
|
|
877
894
|
*/
|
|
878
895
|
async getProfile(opts) {
|
|
879
896
|
checkOptions("getProfile", opts, PROFILE_KEYS);
|
|
@@ -881,14 +898,16 @@ var Korely = class {
|
|
|
881
898
|
params: {
|
|
882
899
|
user_id: opts.user_id,
|
|
883
900
|
agent_id: opts.agent_id,
|
|
884
|
-
as_of: opts.as_of
|
|
901
|
+
as_of: opts.as_of,
|
|
902
|
+
known_as_of: opts.known_as_of
|
|
885
903
|
}
|
|
886
904
|
});
|
|
887
905
|
}
|
|
888
906
|
// ── context ─────────────────────────────────────────────────────────────
|
|
889
907
|
/**
|
|
890
908
|
* GET /v1/context: one call that assembles a prompt-ready context block
|
|
891
|
-
* (profile + relevant facts + memories) within a token budget.
|
|
909
|
+
* (profile + relevant facts + memories) within a token budget. With
|
|
910
|
+
* `known_as_of` (ISO date), the block as the store could have built it then.
|
|
892
911
|
*/
|
|
893
912
|
async getContext(opts, extra = {}) {
|
|
894
913
|
if (typeof opts === "string") checkOptions("getContext", extra, CONTEXT_EXTRA_KEYS);
|
|
@@ -902,7 +921,8 @@ var Korely = class {
|
|
|
902
921
|
query: o.query,
|
|
903
922
|
user_id: o.user_id,
|
|
904
923
|
agent_id: o.agent_id,
|
|
905
|
-
token_budget: o.token_budget ?? 800
|
|
924
|
+
token_budget: o.token_budget ?? 800,
|
|
925
|
+
known_as_of: o.known_as_of
|
|
906
926
|
}
|
|
907
927
|
});
|
|
908
928
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,9 @@ interface Fact {
|
|
|
45
45
|
object_canonical?: string;
|
|
46
46
|
/** Every memory that stated this fact. */
|
|
47
47
|
source_memory_ids?: string[];
|
|
48
|
+
/** Korely Agent 0.1.26: when the store learned the fact had ended
|
|
49
|
+
* (`created_at` is when it learned the fact); null while it is open. */
|
|
50
|
+
closed_known_at?: string | null;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* The facts of one `getFacts()` page: a plain array that also carries
|
|
@@ -173,6 +176,8 @@ interface BatchJob {
|
|
|
173
176
|
interface Profile {
|
|
174
177
|
user_id?: string;
|
|
175
178
|
as_of?: string | null;
|
|
179
|
+
/** Echoes a request for the profile as the store knew it then. */
|
|
180
|
+
known_as_of?: string | null;
|
|
176
181
|
/** The end user's own facts first, then the rest. */
|
|
177
182
|
facts: Fact[];
|
|
178
183
|
/** Facts grouped by predicate family. */
|
|
@@ -341,7 +346,7 @@ interface AuditEvent {
|
|
|
341
346
|
/** Counts and labels, never content. */
|
|
342
347
|
meta?: Record<string, unknown> | null;
|
|
343
348
|
ip?: string | null;
|
|
344
|
-
/** On a read, what it returned; with `
|
|
349
|
+
/** On a read, what it returned; with `known_as_of` on getFacts() or getContext() (Korely Agent 0.1.26) it rebuilds what an agent knew when it decided. */
|
|
345
350
|
read?: AuditRead | null;
|
|
346
351
|
}
|
|
347
352
|
/** Iterable page of the audit trail, newest first. `total` counts the matches across every page. */
|
|
@@ -370,6 +375,13 @@ interface SearchOptions {
|
|
|
370
375
|
metadata?: Record<string, unknown>;
|
|
371
376
|
/** Server default 15, max 50. */
|
|
372
377
|
limit?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Leave out the memories whose `score` is below this, 0 to 1 (a cosine
|
|
380
|
+
* similarity, compared as the response shows it). Absent: no floor. Fewer
|
|
381
|
+
* than `limit` results can come back. 0.20 is the value measured on
|
|
382
|
+
* LongMemEval with EmbeddingGemma; the right one depends on your texts.
|
|
383
|
+
*/
|
|
384
|
+
min_score?: number;
|
|
373
385
|
}
|
|
374
386
|
interface ListOptions {
|
|
375
387
|
user_id?: string;
|
|
@@ -430,6 +442,12 @@ interface GetFactsOptions {
|
|
|
430
442
|
include_invalidated?: boolean;
|
|
431
443
|
/** ISO date: point-in-time validity ("what was true on 2026-06-01"). */
|
|
432
444
|
as_of?: string;
|
|
445
|
+
/**
|
|
446
|
+
* ISO date: what the store knew on that date (Korely Agent 0.1.26). A move
|
|
447
|
+
* made in September and told in October: `as_of` September gives the new
|
|
448
|
+
* address, `known_as_of` September the old one.
|
|
449
|
+
*/
|
|
450
|
+
known_as_of?: string;
|
|
433
451
|
user_id?: string;
|
|
434
452
|
agent_id?: string;
|
|
435
453
|
limit?: number;
|
|
@@ -455,12 +473,19 @@ interface GetProfileOptions {
|
|
|
455
473
|
agent_id?: string;
|
|
456
474
|
/** ISO date: the profile as it stood on that date. */
|
|
457
475
|
as_of?: string;
|
|
476
|
+
/** ISO date: the profile as the store knew it on that date. */
|
|
477
|
+
known_as_of?: string;
|
|
458
478
|
}
|
|
459
479
|
interface GetContextOptions {
|
|
460
480
|
query: string;
|
|
461
481
|
user_id?: string;
|
|
462
482
|
agent_id?: string;
|
|
463
483
|
token_budget?: number;
|
|
484
|
+
/**
|
|
485
|
+
* ISO date: the block as the store could have built it then, the facts it
|
|
486
|
+
* knew and the memories it had received (Korely Agent 0.1.26).
|
|
487
|
+
*/
|
|
488
|
+
known_as_of?: string;
|
|
464
489
|
}
|
|
465
490
|
/** What `forgetFact` gives back. `status` is "forgotten" the first time and
|
|
466
491
|
* "already_forgotten" afterwards; `invalid_at` is the date it stopped being
|
|
@@ -474,7 +499,7 @@ interface ForgetReceipt {
|
|
|
474
499
|
|
|
475
500
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
476
501
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
477
|
-
declare const VERSION = "0.1.
|
|
502
|
+
declare const VERSION = "0.1.14";
|
|
478
503
|
interface KorelyOptions {
|
|
479
504
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
480
505
|
apiKey?: string;
|
|
@@ -675,8 +700,10 @@ declare class Korely {
|
|
|
675
700
|
deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
|
|
676
701
|
/**
|
|
677
702
|
* GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
|
|
678
|
-
* validity. Pass `as_of` (ISO date) for a point-in-time query
|
|
679
|
-
*
|
|
703
|
+
* validity. Pass `as_of` (ISO date) for a point-in-time query, and
|
|
704
|
+
* `known_as_of` (ISO date) for what the store knew on that date (Korely
|
|
705
|
+
* Agent 0.1.26; older servers ignore it). Resolves to an array that also
|
|
706
|
+
* carries `total`, the matches across all pages.
|
|
680
707
|
*/
|
|
681
708
|
getFacts(opts?: GetFactsOptions): Promise<FactList>;
|
|
682
709
|
/**
|
|
@@ -726,12 +753,14 @@ declare class Korely {
|
|
|
726
753
|
/**
|
|
727
754
|
* GET /v1/profile: the assembled profile of one end user, the active typed
|
|
728
755
|
* facts known about them, the end user's own facts first, grouped by family.
|
|
729
|
-
* Pass `as_of` (ISO date) for the point-in-time profile
|
|
756
|
+
* Pass `as_of` (ISO date) for the point-in-time profile, `known_as_of` for
|
|
757
|
+
* the profile as the store knew it then.
|
|
730
758
|
*/
|
|
731
759
|
getProfile(opts: GetProfileOptions): Promise<Profile>;
|
|
732
760
|
/**
|
|
733
761
|
* GET /v1/context: one call that assembles a prompt-ready context block
|
|
734
|
-
* (profile + relevant facts + memories) within a token budget.
|
|
762
|
+
* (profile + relevant facts + memories) within a token budget. With
|
|
763
|
+
* `known_as_of` (ISO date), the block as the store could have built it then.
|
|
735
764
|
*/
|
|
736
765
|
getContext(opts: GetContextOptions | string, extra?: Omit<GetContextOptions, "query">): Promise<Context>;
|
|
737
766
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,9 @@ interface Fact {
|
|
|
45
45
|
object_canonical?: string;
|
|
46
46
|
/** Every memory that stated this fact. */
|
|
47
47
|
source_memory_ids?: string[];
|
|
48
|
+
/** Korely Agent 0.1.26: when the store learned the fact had ended
|
|
49
|
+
* (`created_at` is when it learned the fact); null while it is open. */
|
|
50
|
+
closed_known_at?: string | null;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* The facts of one `getFacts()` page: a plain array that also carries
|
|
@@ -173,6 +176,8 @@ interface BatchJob {
|
|
|
173
176
|
interface Profile {
|
|
174
177
|
user_id?: string;
|
|
175
178
|
as_of?: string | null;
|
|
179
|
+
/** Echoes a request for the profile as the store knew it then. */
|
|
180
|
+
known_as_of?: string | null;
|
|
176
181
|
/** The end user's own facts first, then the rest. */
|
|
177
182
|
facts: Fact[];
|
|
178
183
|
/** Facts grouped by predicate family. */
|
|
@@ -341,7 +346,7 @@ interface AuditEvent {
|
|
|
341
346
|
/** Counts and labels, never content. */
|
|
342
347
|
meta?: Record<string, unknown> | null;
|
|
343
348
|
ip?: string | null;
|
|
344
|
-
/** On a read, what it returned; with `
|
|
349
|
+
/** On a read, what it returned; with `known_as_of` on getFacts() or getContext() (Korely Agent 0.1.26) it rebuilds what an agent knew when it decided. */
|
|
345
350
|
read?: AuditRead | null;
|
|
346
351
|
}
|
|
347
352
|
/** Iterable page of the audit trail, newest first. `total` counts the matches across every page. */
|
|
@@ -370,6 +375,13 @@ interface SearchOptions {
|
|
|
370
375
|
metadata?: Record<string, unknown>;
|
|
371
376
|
/** Server default 15, max 50. */
|
|
372
377
|
limit?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Leave out the memories whose `score` is below this, 0 to 1 (a cosine
|
|
380
|
+
* similarity, compared as the response shows it). Absent: no floor. Fewer
|
|
381
|
+
* than `limit` results can come back. 0.20 is the value measured on
|
|
382
|
+
* LongMemEval with EmbeddingGemma; the right one depends on your texts.
|
|
383
|
+
*/
|
|
384
|
+
min_score?: number;
|
|
373
385
|
}
|
|
374
386
|
interface ListOptions {
|
|
375
387
|
user_id?: string;
|
|
@@ -430,6 +442,12 @@ interface GetFactsOptions {
|
|
|
430
442
|
include_invalidated?: boolean;
|
|
431
443
|
/** ISO date: point-in-time validity ("what was true on 2026-06-01"). */
|
|
432
444
|
as_of?: string;
|
|
445
|
+
/**
|
|
446
|
+
* ISO date: what the store knew on that date (Korely Agent 0.1.26). A move
|
|
447
|
+
* made in September and told in October: `as_of` September gives the new
|
|
448
|
+
* address, `known_as_of` September the old one.
|
|
449
|
+
*/
|
|
450
|
+
known_as_of?: string;
|
|
433
451
|
user_id?: string;
|
|
434
452
|
agent_id?: string;
|
|
435
453
|
limit?: number;
|
|
@@ -455,12 +473,19 @@ interface GetProfileOptions {
|
|
|
455
473
|
agent_id?: string;
|
|
456
474
|
/** ISO date: the profile as it stood on that date. */
|
|
457
475
|
as_of?: string;
|
|
476
|
+
/** ISO date: the profile as the store knew it on that date. */
|
|
477
|
+
known_as_of?: string;
|
|
458
478
|
}
|
|
459
479
|
interface GetContextOptions {
|
|
460
480
|
query: string;
|
|
461
481
|
user_id?: string;
|
|
462
482
|
agent_id?: string;
|
|
463
483
|
token_budget?: number;
|
|
484
|
+
/**
|
|
485
|
+
* ISO date: the block as the store could have built it then, the facts it
|
|
486
|
+
* knew and the memories it had received (Korely Agent 0.1.26).
|
|
487
|
+
*/
|
|
488
|
+
known_as_of?: string;
|
|
464
489
|
}
|
|
465
490
|
/** What `forgetFact` gives back. `status` is "forgotten" the first time and
|
|
466
491
|
* "already_forgotten" afterwards; `invalid_at` is the date it stopped being
|
|
@@ -474,7 +499,7 @@ interface ForgetReceipt {
|
|
|
474
499
|
|
|
475
500
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
476
501
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
477
|
-
declare const VERSION = "0.1.
|
|
502
|
+
declare const VERSION = "0.1.14";
|
|
478
503
|
interface KorelyOptions {
|
|
479
504
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
480
505
|
apiKey?: string;
|
|
@@ -675,8 +700,10 @@ declare class Korely {
|
|
|
675
700
|
deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
|
|
676
701
|
/**
|
|
677
702
|
* GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
|
|
678
|
-
* validity. Pass `as_of` (ISO date) for a point-in-time query
|
|
679
|
-
*
|
|
703
|
+
* validity. Pass `as_of` (ISO date) for a point-in-time query, and
|
|
704
|
+
* `known_as_of` (ISO date) for what the store knew on that date (Korely
|
|
705
|
+
* Agent 0.1.26; older servers ignore it). Resolves to an array that also
|
|
706
|
+
* carries `total`, the matches across all pages.
|
|
680
707
|
*/
|
|
681
708
|
getFacts(opts?: GetFactsOptions): Promise<FactList>;
|
|
682
709
|
/**
|
|
@@ -726,12 +753,14 @@ declare class Korely {
|
|
|
726
753
|
/**
|
|
727
754
|
* GET /v1/profile: the assembled profile of one end user, the active typed
|
|
728
755
|
* facts known about them, the end user's own facts first, grouped by family.
|
|
729
|
-
* Pass `as_of` (ISO date) for the point-in-time profile
|
|
756
|
+
* Pass `as_of` (ISO date) for the point-in-time profile, `known_as_of` for
|
|
757
|
+
* the profile as the store knew it then.
|
|
730
758
|
*/
|
|
731
759
|
getProfile(opts: GetProfileOptions): Promise<Profile>;
|
|
732
760
|
/**
|
|
733
761
|
* GET /v1/context: one call that assembles a prompt-ready context block
|
|
734
|
-
* (profile + relevant facts + memories) within a token budget.
|
|
762
|
+
* (profile + relevant facts + memories) within a token budget. With
|
|
763
|
+
* `known_as_of` (ISO date), the block as the store could have built it then.
|
|
735
764
|
*/
|
|
736
765
|
getContext(opts: GetContextOptions | string, extra?: Omit<GetContextOptions, "query">): Promise<Context>;
|
|
737
766
|
/**
|
package/dist/index.js
CHANGED
|
@@ -77,12 +77,12 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// src/client.ts
|
|
80
|
-
var VERSION = "0.1.
|
|
80
|
+
var VERSION = "0.1.14";
|
|
81
81
|
var REGIONS = { eu: "https://api.korely.ai" };
|
|
82
82
|
var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
|
|
83
83
|
var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
|
|
84
84
|
var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp");
|
|
85
|
-
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit");
|
|
85
|
+
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit", "min_score");
|
|
86
86
|
var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
|
|
87
87
|
var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
|
|
88
88
|
var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
|
|
@@ -97,6 +97,7 @@ var FACTS_KEYS = keysOf()(
|
|
|
97
97
|
"predicate_family",
|
|
98
98
|
"include_invalidated",
|
|
99
99
|
"as_of",
|
|
100
|
+
"known_as_of",
|
|
100
101
|
"user_id",
|
|
101
102
|
"agent_id",
|
|
102
103
|
"limit",
|
|
@@ -112,9 +113,20 @@ var TRIPLE_KEYS = keysOf()(
|
|
|
112
113
|
"valid_from",
|
|
113
114
|
"tense"
|
|
114
115
|
);
|
|
115
|
-
var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of");
|
|
116
|
-
var CONTEXT_KEYS = keysOf()(
|
|
117
|
-
|
|
116
|
+
var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of", "known_as_of");
|
|
117
|
+
var CONTEXT_KEYS = keysOf()(
|
|
118
|
+
"query",
|
|
119
|
+
"user_id",
|
|
120
|
+
"agent_id",
|
|
121
|
+
"token_budget",
|
|
122
|
+
"known_as_of"
|
|
123
|
+
);
|
|
124
|
+
var CONTEXT_EXTRA_KEYS = keysOf()(
|
|
125
|
+
"user_id",
|
|
126
|
+
"agent_id",
|
|
127
|
+
"token_budget",
|
|
128
|
+
"known_as_of"
|
|
129
|
+
);
|
|
118
130
|
function checkOptions(method, opts, known) {
|
|
119
131
|
const problem = unknownOption(method, opts, known);
|
|
120
132
|
if (problem) throw new KorelyError(problem);
|
|
@@ -586,7 +598,8 @@ var Korely = class {
|
|
|
586
598
|
agent_id: opts.agent_id,
|
|
587
599
|
run_id: opts.run_id,
|
|
588
600
|
metadata: opts.metadata,
|
|
589
|
-
limit: opts.limit
|
|
601
|
+
limit: opts.limit,
|
|
602
|
+
min_score: opts.min_score
|
|
590
603
|
}
|
|
591
604
|
});
|
|
592
605
|
return body.results ?? [];
|
|
@@ -727,8 +740,10 @@ var Korely = class {
|
|
|
727
740
|
// ── facts ─────────────────────────────────────────────────────────────────
|
|
728
741
|
/**
|
|
729
742
|
* GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
|
|
730
|
-
* validity. Pass `as_of` (ISO date) for a point-in-time query
|
|
731
|
-
*
|
|
743
|
+
* validity. Pass `as_of` (ISO date) for a point-in-time query, and
|
|
744
|
+
* `known_as_of` (ISO date) for what the store knew on that date (Korely
|
|
745
|
+
* Agent 0.1.26; older servers ignore it). Resolves to an array that also
|
|
746
|
+
* carries `total`, the matches across all pages.
|
|
732
747
|
*/
|
|
733
748
|
async getFacts(opts = {}) {
|
|
734
749
|
checkOptions("getFacts", opts, FACTS_KEYS);
|
|
@@ -738,6 +753,7 @@ var Korely = class {
|
|
|
738
753
|
predicate: opts.predicate,
|
|
739
754
|
predicate_family: opts.predicate_family,
|
|
740
755
|
as_of: opts.as_of,
|
|
756
|
+
known_as_of: opts.known_as_of,
|
|
741
757
|
user_id: opts.user_id,
|
|
742
758
|
agent_id: opts.agent_id,
|
|
743
759
|
limit: opts.limit ?? 50,
|
|
@@ -824,7 +840,8 @@ var Korely = class {
|
|
|
824
840
|
/**
|
|
825
841
|
* GET /v1/profile: the assembled profile of one end user, the active typed
|
|
826
842
|
* facts known about them, the end user's own facts first, grouped by family.
|
|
827
|
-
* Pass `as_of` (ISO date) for the point-in-time profile
|
|
843
|
+
* Pass `as_of` (ISO date) for the point-in-time profile, `known_as_of` for
|
|
844
|
+
* the profile as the store knew it then.
|
|
828
845
|
*/
|
|
829
846
|
async getProfile(opts) {
|
|
830
847
|
checkOptions("getProfile", opts, PROFILE_KEYS);
|
|
@@ -832,14 +849,16 @@ var Korely = class {
|
|
|
832
849
|
params: {
|
|
833
850
|
user_id: opts.user_id,
|
|
834
851
|
agent_id: opts.agent_id,
|
|
835
|
-
as_of: opts.as_of
|
|
852
|
+
as_of: opts.as_of,
|
|
853
|
+
known_as_of: opts.known_as_of
|
|
836
854
|
}
|
|
837
855
|
});
|
|
838
856
|
}
|
|
839
857
|
// ── context ─────────────────────────────────────────────────────────────
|
|
840
858
|
/**
|
|
841
859
|
* GET /v1/context: one call that assembles a prompt-ready context block
|
|
842
|
-
* (profile + relevant facts + memories) within a token budget.
|
|
860
|
+
* (profile + relevant facts + memories) within a token budget. With
|
|
861
|
+
* `known_as_of` (ISO date), the block as the store could have built it then.
|
|
843
862
|
*/
|
|
844
863
|
async getContext(opts, extra = {}) {
|
|
845
864
|
if (typeof opts === "string") checkOptions("getContext", extra, CONTEXT_EXTRA_KEYS);
|
|
@@ -853,7 +872,8 @@ var Korely = class {
|
|
|
853
872
|
query: o.query,
|
|
854
873
|
user_id: o.user_id,
|
|
855
874
|
agent_id: o.agent_id,
|
|
856
|
-
token_budget: o.token_budget ?? 800
|
|
875
|
+
token_budget: o.token_budget ?? 800,
|
|
876
|
+
known_as_of: o.known_as_of
|
|
857
877
|
}
|
|
858
878
|
});
|
|
859
879
|
}
|