korely-memory 0.1.17 → 0.1.18

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
@@ -94,7 +94,7 @@ Every method maps to one REST endpoint.
94
94
 
95
95
  | Method | Endpoint | |
96
96
  |---|---|---|
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`. |
97
+ | `add(content, opts?)` | `POST /v1/memories` | Write. `content` is a string or a list of chat messages. `opts.user_id` or `opts.agent_id` says whose memory it is (Korely 1.0.19 and later refuse neither). `opts.timestamp` (ISO) backfills the past: facts inherit it as `valid_from`. |
98
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. |
@@ -112,7 +112,7 @@ Every method maps to one REST endpoint.
112
112
  | `getProfile({ user_id, as_of?, known_as_of? })` | `GET /v1/profile` | The assembled profile of one end user. |
113
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
- | `batch(memories)` | `POST /v1/batch` | Bulk import, for migrations. Each item takes `timestamp`, as `add()` does. |
115
+ | `batch(memories)` | `POST /v1/batch` | Bulk import, for migrations. Each item takes `user_id` or `agent_id` and `timestamp`, as `add()` does. |
116
116
  | `batchStatus(jobId)` | `GET /v1/batch/:id` | Poll an import job. |
117
117
  | `ping()` | `GET /v1/ping` | Check a key without spending anything (no scope, rate limit or quota): its `tier`, `region` and `scopes`. Both products. |
118
118
  | `Korely.initAgent(agentCaller?, opts?)` | `POST /v1/agents/init` | Cloud only. Static, no key needed: sign up for a free hobby key (shown once, save it), then `new Korely({ apiKey: result.api_key })`. `opts` takes `baseUrl`, `region`, `timeoutMs`, `fetch`. |
@@ -174,7 +174,9 @@ subclass `StaleWriteError`) ·
174
174
  undefined for the monthly `quota_exceeded`) · `TooManyBatchesError` (a
175
175
  `QuotaExceededError`: `too_many_batches` from `batch()`, Cloud only, three
176
176
  imports still running; send again when one finishes) · `APIError` (the base
177
- of all of these, and everything else: 422, 503). Every `APIError` has
177
+ of all of these, and everything else: 422, 503; a write that names neither
178
+ `user_id` nor `agent_id` is a 422 `identity_required` on Korely 1.0.19 and
179
+ later, and this client sends only the ids each call names). Every `APIError` has
178
180
  `retryAfter` when the server sent `Retry-After`: a rate limit, and the Cloud's
179
181
  503 `writes_paused` (writes that need a model are paused until 00:00 UTC). The
180
182
  SDK does not retry on its own.
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.17";
129
+ var VERSION = "0.1.18";
130
130
  var REGIONS = { eu: "https://api.korely.ai" };
131
131
  var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch", "client");
132
132
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
@@ -638,6 +638,11 @@ var Korely = class {
638
638
  * `content` is a string, or a list of chat messages (role/content), joined
639
639
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
640
640
  * backfill: facts extracted inherit it as `valid_from`.
641
+ *
642
+ * Say whose memory it is with `user_id` or `agent_id` (or both): Korely
643
+ * 1.0.19 and later refuse a write with neither, a 422 APIError with
644
+ * `code === "identity_required"`. This client sends the ids each call names
645
+ * and no others.
641
646
  */
642
647
  async add(content, opts = {}) {
643
648
  checkOptions("add", opts, ADD_KEYS);
@@ -872,7 +877,8 @@ var Korely = class {
872
877
  * skipping extraction. The server runs the contradiction check; the fact is
873
878
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
874
879
  * one that is over). Resolves to the written Fact, with `invalidated`
875
- * listing any fact ids it superseded.
880
+ * listing any fact ids it superseded. `user_id` or `agent_id` says whose
881
+ * fact it is, as on `add()` (Korely 1.0.19 and later refuse neither).
876
882
  */
877
883
  async addFactTriple(subject, predicate, object, opts = {}) {
878
884
  checkOptions("addFactTriple", opts, TRIPLE_KEYS);
@@ -1006,7 +1012,10 @@ var Korely = class {
1006
1012
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
1007
1013
  * asynchronously. Each object is the body of one `add()` (see
1008
1014
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
1009
- * `metadata` and `timestamp`.
1015
+ * `metadata` and `timestamp`. On Korely 1.0.19 and later each object needs
1016
+ * `user_id` or `agent_id`: one with neither refuses the whole batch before
1017
+ * anything is queued, a 422 (`code === "identity_required"`) whose message
1018
+ * names it, `memories[3].user_id or memories[3].agent_id is required`.
1010
1019
  *
1011
1020
  * `timestamp` means what it means on `add()`: when the events happened.
1012
1021
  * The facts extracted from the item inherit it as `valid_from`, so a
package/dist/index.d.cts CHANGED
@@ -155,7 +155,14 @@ interface Context {
155
155
  */
156
156
  interface BatchMemory {
157
157
  content: string;
158
+ /**
159
+ * Whose memory the item is: `user_id`, the end user it belongs to, or
160
+ * `agent_id`, the agent writing it. Korely 1.0.19 and later need one of the
161
+ * two in every item: an item with neither refuses the whole batch with a
162
+ * 422 (`code === "identity_required"`) naming `memories[i]`.
163
+ */
158
164
  user_id?: string;
165
+ /** The agent writing the item; see `user_id`. */
159
166
  agent_id?: string;
160
167
  run_id?: string;
161
168
  metadata?: Record<string, unknown>;
@@ -364,7 +371,16 @@ interface AuditPage extends Iterable<AuditEvent> {
364
371
  total: number;
365
372
  }
366
373
  interface AddOptions {
374
+ /** The agent writing the memory; see `user_id`. */
367
375
  agent_id?: string;
376
+ /**
377
+ * Whose memory it is: `user_id`, the end user it belongs to, or `agent_id`,
378
+ * the agent writing it (or both: that agent's memory of that user). Korely
379
+ * 1.0.19 and later refuse a write with neither, and store nothing: a 422
380
+ * APIError with `code === "identity_required"` and the server's message.
381
+ * An older server accepts it. `run_id` alone is not an identity. Optional in
382
+ * the type so that a program talking to an older server still compiles.
383
+ */
368
384
  user_id?: string;
369
385
  run_id?: string;
370
386
  metadata?: Record<string, unknown>;
@@ -489,7 +505,12 @@ interface GetFactsOptions {
489
505
  exclude_sessions?: boolean;
490
506
  }
491
507
  interface AddFactTripleOptions {
508
+ /**
509
+ * Whose fact it is, as on `add()`: `user_id` or `agent_id`. Korely 1.0.19
510
+ * and later refuse a fact with neither (422, `code === "identity_required"`).
511
+ */
492
512
  user_id?: string;
513
+ /** The agent writing the fact; see `user_id`. */
493
514
  agent_id?: string;
494
515
  run_id?: string;
495
516
  subject_type?: string;
@@ -538,7 +559,7 @@ interface ForgetReceipt {
538
559
 
539
560
  /** Must equal `version` in package.json (a test checks). It goes out in the
540
561
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
541
- declare const VERSION = "0.1.17";
562
+ declare const VERSION = "0.1.18";
542
563
  interface KorelyOptions {
543
564
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
544
565
  apiKey?: string;
@@ -666,6 +687,11 @@ declare class Korely {
666
687
  * `content` is a string, or a list of chat messages (role/content), joined
667
688
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
668
689
  * backfill: facts extracted inherit it as `valid_from`.
690
+ *
691
+ * Say whose memory it is with `user_id` or `agent_id` (or both): Korely
692
+ * 1.0.19 and later refuse a write with neither, a 422 APIError with
693
+ * `code === "identity_required"`. This client sends the ids each call names
694
+ * and no others.
669
695
  */
670
696
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
671
697
  /**
@@ -768,7 +794,8 @@ declare class Korely {
768
794
  * skipping extraction. The server runs the contradiction check; the fact is
769
795
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
770
796
  * one that is over). Resolves to the written Fact, with `invalidated`
771
- * listing any fact ids it superseded.
797
+ * listing any fact ids it superseded. `user_id` or `agent_id` says whose
798
+ * fact it is, as on `add()` (Korely 1.0.19 and later refuse neither).
772
799
  */
773
800
  addFactTriple(subject: string, predicate: string, object: string, opts?: AddFactTripleOptions): Promise<Fact>;
774
801
  /**
@@ -837,7 +864,10 @@ declare class Korely {
837
864
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
838
865
  * asynchronously. Each object is the body of one `add()` (see
839
866
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
840
- * `metadata` and `timestamp`.
867
+ * `metadata` and `timestamp`. On Korely 1.0.19 and later each object needs
868
+ * `user_id` or `agent_id`: one with neither refuses the whole batch before
869
+ * anything is queued, a 422 (`code === "identity_required"`) whose message
870
+ * names it, `memories[3].user_id or memories[3].agent_id is required`.
841
871
  *
842
872
  * `timestamp` means what it means on `add()`: when the events happened.
843
873
  * The facts extracted from the item inherit it as `valid_from`, so a
@@ -887,7 +917,9 @@ declare class KorelyError extends Error {
887
917
  * The server answered with a non-2xx status. `status` is the HTTP status,
888
918
  * `code` the stable error code (`invalid_key`, `not_found`, `quota_exceeded`,
889
919
  * `search_unavailable` and so on). Anything without a subclass below (422
890
- * validation, 503 unavailable, other 5xx) is a plain APIError.
920
+ * validation, 503 unavailable, other 5xx) is a plain APIError. A write that
921
+ * names neither `user_id` nor `agent_id` is a 422 with
922
+ * `code === "identity_required"` on Korely 1.0.19 and later.
891
923
  *
892
924
  * The subclasses were siblings of this class in 0.1.6 and earlier, so the pattern the
893
925
  * public docs teach, `err instanceof APIError` and branch on `err.code`, let a
package/dist/index.d.ts CHANGED
@@ -155,7 +155,14 @@ interface Context {
155
155
  */
156
156
  interface BatchMemory {
157
157
  content: string;
158
+ /**
159
+ * Whose memory the item is: `user_id`, the end user it belongs to, or
160
+ * `agent_id`, the agent writing it. Korely 1.0.19 and later need one of the
161
+ * two in every item: an item with neither refuses the whole batch with a
162
+ * 422 (`code === "identity_required"`) naming `memories[i]`.
163
+ */
158
164
  user_id?: string;
165
+ /** The agent writing the item; see `user_id`. */
159
166
  agent_id?: string;
160
167
  run_id?: string;
161
168
  metadata?: Record<string, unknown>;
@@ -364,7 +371,16 @@ interface AuditPage extends Iterable<AuditEvent> {
364
371
  total: number;
365
372
  }
366
373
  interface AddOptions {
374
+ /** The agent writing the memory; see `user_id`. */
367
375
  agent_id?: string;
376
+ /**
377
+ * Whose memory it is: `user_id`, the end user it belongs to, or `agent_id`,
378
+ * the agent writing it (or both: that agent's memory of that user). Korely
379
+ * 1.0.19 and later refuse a write with neither, and store nothing: a 422
380
+ * APIError with `code === "identity_required"` and the server's message.
381
+ * An older server accepts it. `run_id` alone is not an identity. Optional in
382
+ * the type so that a program talking to an older server still compiles.
383
+ */
368
384
  user_id?: string;
369
385
  run_id?: string;
370
386
  metadata?: Record<string, unknown>;
@@ -489,7 +505,12 @@ interface GetFactsOptions {
489
505
  exclude_sessions?: boolean;
490
506
  }
491
507
  interface AddFactTripleOptions {
508
+ /**
509
+ * Whose fact it is, as on `add()`: `user_id` or `agent_id`. Korely 1.0.19
510
+ * and later refuse a fact with neither (422, `code === "identity_required"`).
511
+ */
492
512
  user_id?: string;
513
+ /** The agent writing the fact; see `user_id`. */
493
514
  agent_id?: string;
494
515
  run_id?: string;
495
516
  subject_type?: string;
@@ -538,7 +559,7 @@ interface ForgetReceipt {
538
559
 
539
560
  /** Must equal `version` in package.json (a test checks). It goes out in the
540
561
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
541
- declare const VERSION = "0.1.17";
562
+ declare const VERSION = "0.1.18";
542
563
  interface KorelyOptions {
543
564
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
544
565
  apiKey?: string;
@@ -666,6 +687,11 @@ declare class Korely {
666
687
  * `content` is a string, or a list of chat messages (role/content), joined
667
688
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
668
689
  * backfill: facts extracted inherit it as `valid_from`.
690
+ *
691
+ * Say whose memory it is with `user_id` or `agent_id` (or both): Korely
692
+ * 1.0.19 and later refuse a write with neither, a 422 APIError with
693
+ * `code === "identity_required"`. This client sends the ids each call names
694
+ * and no others.
669
695
  */
670
696
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
671
697
  /**
@@ -768,7 +794,8 @@ declare class Korely {
768
794
  * skipping extraction. The server runs the contradiction check; the fact is
769
795
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
770
796
  * one that is over). Resolves to the written Fact, with `invalidated`
771
- * listing any fact ids it superseded.
797
+ * listing any fact ids it superseded. `user_id` or `agent_id` says whose
798
+ * fact it is, as on `add()` (Korely 1.0.19 and later refuse neither).
772
799
  */
773
800
  addFactTriple(subject: string, predicate: string, object: string, opts?: AddFactTripleOptions): Promise<Fact>;
774
801
  /**
@@ -837,7 +864,10 @@ declare class Korely {
837
864
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
838
865
  * asynchronously. Each object is the body of one `add()` (see
839
866
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
840
- * `metadata` and `timestamp`.
867
+ * `metadata` and `timestamp`. On Korely 1.0.19 and later each object needs
868
+ * `user_id` or `agent_id`: one with neither refuses the whole batch before
869
+ * anything is queued, a 422 (`code === "identity_required"`) whose message
870
+ * names it, `memories[3].user_id or memories[3].agent_id is required`.
841
871
  *
842
872
  * `timestamp` means what it means on `add()`: when the events happened.
843
873
  * The facts extracted from the item inherit it as `valid_from`, so a
@@ -887,7 +917,9 @@ declare class KorelyError extends Error {
887
917
  * The server answered with a non-2xx status. `status` is the HTTP status,
888
918
  * `code` the stable error code (`invalid_key`, `not_found`, `quota_exceeded`,
889
919
  * `search_unavailable` and so on). Anything without a subclass below (422
890
- * validation, 503 unavailable, other 5xx) is a plain APIError.
920
+ * validation, 503 unavailable, other 5xx) is a plain APIError. A write that
921
+ * names neither `user_id` nor `agent_id` is a 422 with
922
+ * `code === "identity_required"` on Korely 1.0.19 and later.
891
923
  *
892
924
  * The subclasses were siblings of this class in 0.1.6 and earlier, so the pattern the
893
925
  * public docs teach, `err instanceof APIError` and branch on `err.code`, let a
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.17";
80
+ var VERSION = "0.1.18";
81
81
  var REGIONS = { eu: "https://api.korely.ai" };
82
82
  var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch", "client");
83
83
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
@@ -589,6 +589,11 @@ var Korely = class {
589
589
  * `content` is a string, or a list of chat messages (role/content), joined
590
590
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
591
591
  * backfill: facts extracted inherit it as `valid_from`.
592
+ *
593
+ * Say whose memory it is with `user_id` or `agent_id` (or both): Korely
594
+ * 1.0.19 and later refuse a write with neither, a 422 APIError with
595
+ * `code === "identity_required"`. This client sends the ids each call names
596
+ * and no others.
592
597
  */
593
598
  async add(content, opts = {}) {
594
599
  checkOptions("add", opts, ADD_KEYS);
@@ -823,7 +828,8 @@ var Korely = class {
823
828
  * skipping extraction. The server runs the contradiction check; the fact is
824
829
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
825
830
  * one that is over). Resolves to the written Fact, with `invalidated`
826
- * listing any fact ids it superseded.
831
+ * listing any fact ids it superseded. `user_id` or `agent_id` says whose
832
+ * fact it is, as on `add()` (Korely 1.0.19 and later refuse neither).
827
833
  */
828
834
  async addFactTriple(subject, predicate, object, opts = {}) {
829
835
  checkOptions("addFactTriple", opts, TRIPLE_KEYS);
@@ -957,7 +963,10 @@ var Korely = class {
957
963
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
958
964
  * asynchronously. Each object is the body of one `add()` (see
959
965
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
960
- * `metadata` and `timestamp`.
966
+ * `metadata` and `timestamp`. On Korely 1.0.19 and later each object needs
967
+ * `user_id` or `agent_id`: one with neither refuses the whole batch before
968
+ * anything is queued, a 422 (`code === "identity_required"`) whose message
969
+ * names it, `memories[3].user_id or memories[3].agent_id is required`.
961
970
  *
962
971
  * `timestamp` means what it means on `add()`: when the events happened.
963
972
  * The facts extracted from the item inherit it as `valid_from`, so a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",