korely-memory 0.1.13 → 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 CHANGED
@@ -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 point-in-time. The array also carries `total`. |
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 did we know about this user on March 1st?
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,7 +126,7 @@ function unknownOption(method, opts, known) {
126
126
  }
127
127
 
128
128
  // src/client.ts
129
- var VERSION = "0.1.13";
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");
@@ -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()("query", "user_id", "agent_id", "token_budget");
166
- var CONTEXT_EXTRA_KEYS = keysOf()("user_id", "agent_id", "token_budget");
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);
@@ -777,8 +789,10 @@ var Korely = class {
777
789
  // ── facts ─────────────────────────────────────────────────────────────────
778
790
  /**
779
791
  * GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
780
- * validity. Pass `as_of` (ISO date) for a point-in-time query. Resolves to an
781
- * array that also carries `total`, the matches across all pages.
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.
782
796
  */
783
797
  async getFacts(opts = {}) {
784
798
  checkOptions("getFacts", opts, FACTS_KEYS);
@@ -788,6 +802,7 @@ var Korely = class {
788
802
  predicate: opts.predicate,
789
803
  predicate_family: opts.predicate_family,
790
804
  as_of: opts.as_of,
805
+ known_as_of: opts.known_as_of,
791
806
  user_id: opts.user_id,
792
807
  agent_id: opts.agent_id,
793
808
  limit: opts.limit ?? 50,
@@ -874,7 +889,8 @@ var Korely = class {
874
889
  /**
875
890
  * GET /v1/profile: the assembled profile of one end user, the active typed
876
891
  * facts known about them, the end user's own facts first, grouped by family.
877
- * 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.
878
894
  */
879
895
  async getProfile(opts) {
880
896
  checkOptions("getProfile", opts, PROFILE_KEYS);
@@ -882,14 +898,16 @@ var Korely = class {
882
898
  params: {
883
899
  user_id: opts.user_id,
884
900
  agent_id: opts.agent_id,
885
- as_of: opts.as_of
901
+ as_of: opts.as_of,
902
+ known_as_of: opts.known_as_of
886
903
  }
887
904
  });
888
905
  }
889
906
  // ── context ─────────────────────────────────────────────────────────────
890
907
  /**
891
908
  * GET /v1/context: one call that assembles a prompt-ready context block
892
- * (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.
893
911
  */
894
912
  async getContext(opts, extra = {}) {
895
913
  if (typeof opts === "string") checkOptions("getContext", extra, CONTEXT_EXTRA_KEYS);
@@ -903,7 +921,8 @@ var Korely = class {
903
921
  query: o.query,
904
922
  user_id: o.user_id,
905
923
  agent_id: o.agent_id,
906
- token_budget: o.token_budget ?? 800
924
+ token_budget: o.token_budget ?? 800,
925
+ known_as_of: o.known_as_of
907
926
  }
908
927
  });
909
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 `as_of` on getFacts() it rebuilds what an agent knew when it decided. */
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. */
@@ -437,6 +442,12 @@ interface GetFactsOptions {
437
442
  include_invalidated?: boolean;
438
443
  /** ISO date: point-in-time validity ("what was true on 2026-06-01"). */
439
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;
440
451
  user_id?: string;
441
452
  agent_id?: string;
442
453
  limit?: number;
@@ -462,12 +473,19 @@ interface GetProfileOptions {
462
473
  agent_id?: string;
463
474
  /** ISO date: the profile as it stood on that date. */
464
475
  as_of?: string;
476
+ /** ISO date: the profile as the store knew it on that date. */
477
+ known_as_of?: string;
465
478
  }
466
479
  interface GetContextOptions {
467
480
  query: string;
468
481
  user_id?: string;
469
482
  agent_id?: string;
470
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;
471
489
  }
472
490
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
473
491
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -481,7 +499,7 @@ interface ForgetReceipt {
481
499
 
482
500
  /** Must equal `version` in package.json (a test checks). It goes out in the
483
501
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
484
- declare const VERSION = "0.1.13";
502
+ declare const VERSION = "0.1.14";
485
503
  interface KorelyOptions {
486
504
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
487
505
  apiKey?: string;
@@ -682,8 +700,10 @@ declare class Korely {
682
700
  deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
683
701
  /**
684
702
  * GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
685
- * validity. Pass `as_of` (ISO date) for a point-in-time query. Resolves to an
686
- * array that also carries `total`, the matches across all pages.
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.
687
707
  */
688
708
  getFacts(opts?: GetFactsOptions): Promise<FactList>;
689
709
  /**
@@ -733,12 +753,14 @@ declare class Korely {
733
753
  /**
734
754
  * GET /v1/profile: the assembled profile of one end user, the active typed
735
755
  * facts known about them, the end user's own facts first, grouped by family.
736
- * 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.
737
758
  */
738
759
  getProfile(opts: GetProfileOptions): Promise<Profile>;
739
760
  /**
740
761
  * GET /v1/context: one call that assembles a prompt-ready context block
741
- * (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.
742
764
  */
743
765
  getContext(opts: GetContextOptions | string, extra?: Omit<GetContextOptions, "query">): Promise<Context>;
744
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 `as_of` on getFacts() it rebuilds what an agent knew when it decided. */
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. */
@@ -437,6 +442,12 @@ interface GetFactsOptions {
437
442
  include_invalidated?: boolean;
438
443
  /** ISO date: point-in-time validity ("what was true on 2026-06-01"). */
439
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;
440
451
  user_id?: string;
441
452
  agent_id?: string;
442
453
  limit?: number;
@@ -462,12 +473,19 @@ interface GetProfileOptions {
462
473
  agent_id?: string;
463
474
  /** ISO date: the profile as it stood on that date. */
464
475
  as_of?: string;
476
+ /** ISO date: the profile as the store knew it on that date. */
477
+ known_as_of?: string;
465
478
  }
466
479
  interface GetContextOptions {
467
480
  query: string;
468
481
  user_id?: string;
469
482
  agent_id?: string;
470
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;
471
489
  }
472
490
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
473
491
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -481,7 +499,7 @@ interface ForgetReceipt {
481
499
 
482
500
  /** Must equal `version` in package.json (a test checks). It goes out in the
483
501
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
484
- declare const VERSION = "0.1.13";
502
+ declare const VERSION = "0.1.14";
485
503
  interface KorelyOptions {
486
504
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
487
505
  apiKey?: string;
@@ -682,8 +700,10 @@ declare class Korely {
682
700
  deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
683
701
  /**
684
702
  * GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
685
- * validity. Pass `as_of` (ISO date) for a point-in-time query. Resolves to an
686
- * array that also carries `total`, the matches across all pages.
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.
687
707
  */
688
708
  getFacts(opts?: GetFactsOptions): Promise<FactList>;
689
709
  /**
@@ -733,12 +753,14 @@ declare class Korely {
733
753
  /**
734
754
  * GET /v1/profile: the assembled profile of one end user, the active typed
735
755
  * facts known about them, the end user's own facts first, grouped by family.
736
- * 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.
737
758
  */
738
759
  getProfile(opts: GetProfileOptions): Promise<Profile>;
739
760
  /**
740
761
  * GET /v1/context: one call that assembles a prompt-ready context block
741
- * (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.
742
764
  */
743
765
  getContext(opts: GetContextOptions | string, extra?: Omit<GetContextOptions, "query">): Promise<Context>;
744
766
  /**
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
77
77
  };
78
78
 
79
79
  // src/client.ts
80
- var VERSION = "0.1.13";
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");
@@ -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()("query", "user_id", "agent_id", "token_budget");
117
- var CONTEXT_EXTRA_KEYS = keysOf()("user_id", "agent_id", "token_budget");
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);
@@ -728,8 +740,10 @@ var Korely = class {
728
740
  // ── facts ─────────────────────────────────────────────────────────────────
729
741
  /**
730
742
  * GET /v1/facts: typed (subject, predicate, object) triples with bi-temporal
731
- * validity. Pass `as_of` (ISO date) for a point-in-time query. Resolves to an
732
- * array that also carries `total`, the matches across all pages.
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.
733
747
  */
734
748
  async getFacts(opts = {}) {
735
749
  checkOptions("getFacts", opts, FACTS_KEYS);
@@ -739,6 +753,7 @@ var Korely = class {
739
753
  predicate: opts.predicate,
740
754
  predicate_family: opts.predicate_family,
741
755
  as_of: opts.as_of,
756
+ known_as_of: opts.known_as_of,
742
757
  user_id: opts.user_id,
743
758
  agent_id: opts.agent_id,
744
759
  limit: opts.limit ?? 50,
@@ -825,7 +840,8 @@ var Korely = class {
825
840
  /**
826
841
  * GET /v1/profile: the assembled profile of one end user, the active typed
827
842
  * facts known about them, the end user's own facts first, grouped by family.
828
- * 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.
829
845
  */
830
846
  async getProfile(opts) {
831
847
  checkOptions("getProfile", opts, PROFILE_KEYS);
@@ -833,14 +849,16 @@ var Korely = class {
833
849
  params: {
834
850
  user_id: opts.user_id,
835
851
  agent_id: opts.agent_id,
836
- as_of: opts.as_of
852
+ as_of: opts.as_of,
853
+ known_as_of: opts.known_as_of
837
854
  }
838
855
  });
839
856
  }
840
857
  // ── context ─────────────────────────────────────────────────────────────
841
858
  /**
842
859
  * GET /v1/context: one call that assembles a prompt-ready context block
843
- * (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.
844
862
  */
845
863
  async getContext(opts, extra = {}) {
846
864
  if (typeof opts === "string") checkOptions("getContext", extra, CONTEXT_EXTRA_KEYS);
@@ -854,7 +872,8 @@ var Korely = class {
854
872
  query: o.query,
855
873
  user_id: o.user_id,
856
874
  agent_id: o.agent_id,
857
- token_budget: o.token_budget ?? 800
875
+ token_budget: o.token_budget ?? 800,
876
+ known_as_of: o.known_as_of
858
877
  }
859
878
  });
860
879
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",