korely-memory 0.1.16 → 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,13 +94,13 @@ 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. |
101
101
  | `update(id, { content })` | `PATCH /v1/memories/:id` | Re-runs extraction. |
102
102
  | `delete(id)` | `DELETE /v1/memories/:id` | Forget one (audited). |
103
- | `deleteAll({ user_id })` | `DELETE /v1/users/:user_id/memories` | Erase everything for a user (GDPR). The receipt counts `memories_deleted` and `facts_deleted`; `memories_forgotten` and `facts_invalidated` are deprecated aliases. |
103
+ | `deleteAll({ user_id })` | `DELETE /v1/users/:user_id/memories` | Erase everything about one end user in one call. The receipt counts `memories_deleted` and `facts_deleted`. |
104
104
  | `history(id)` | `GET /v1/memories/:id/history` | A memory's timeline + the facts it produced. |
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. |
@@ -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.16";
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
@@ -75,6 +75,8 @@ interface Memory {
75
75
  updated_at?: string;
76
76
  /** Facts extracted from this memory on the write path. */
77
77
  facts?: Fact[];
78
+ /** "note" or "session" (Korely Agent 0.1.42); absent from an older server. */
79
+ kind?: "note" | "session";
78
80
  }
79
81
  interface SearchHit {
80
82
  id?: string;
@@ -153,7 +155,14 @@ interface Context {
153
155
  */
154
156
  interface BatchMemory {
155
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
+ */
156
164
  user_id?: string;
165
+ /** The agent writing the item; see `user_id`. */
157
166
  agent_id?: string;
158
167
  run_id?: string;
159
168
  metadata?: Record<string, unknown>;
@@ -164,6 +173,8 @@ interface BatchMemory {
164
173
  * queued.
165
174
  */
166
175
  timestamp?: string;
176
+ /** "note" (default) or "session", as on `add()` (Korely Agent 0.1.42). */
177
+ kind?: "note" | "session";
167
178
  }
168
179
  interface BatchJob {
169
180
  id?: string;
@@ -360,7 +371,16 @@ interface AuditPage extends Iterable<AuditEvent> {
360
371
  total: number;
361
372
  }
362
373
  interface AddOptions {
374
+ /** The agent writing the memory; see `user_id`. */
363
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
+ */
364
384
  user_id?: string;
365
385
  run_id?: string;
366
386
  metadata?: Record<string, unknown>;
@@ -485,7 +505,12 @@ interface GetFactsOptions {
485
505
  exclude_sessions?: boolean;
486
506
  }
487
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
+ */
488
512
  user_id?: string;
513
+ /** The agent writing the fact; see `user_id`. */
489
514
  agent_id?: string;
490
515
  run_id?: string;
491
516
  subject_type?: string;
@@ -534,7 +559,7 @@ interface ForgetReceipt {
534
559
 
535
560
  /** Must equal `version` in package.json (a test checks). It goes out in the
536
561
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
537
- declare const VERSION = "0.1.16";
562
+ declare const VERSION = "0.1.18";
538
563
  interface KorelyOptions {
539
564
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
540
565
  apiKey?: string;
@@ -662,6 +687,11 @@ declare class Korely {
662
687
  * `content` is a string, or a list of chat messages (role/content), joined
663
688
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
664
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.
665
695
  */
666
696
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
667
697
  /**
@@ -764,7 +794,8 @@ declare class Korely {
764
794
  * skipping extraction. The server runs the contradiction check; the fact is
765
795
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
766
796
  * one that is over). Resolves to the written Fact, with `invalidated`
767
- * 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).
768
799
  */
769
800
  addFactTriple(subject: string, predicate: string, object: string, opts?: AddFactTripleOptions): Promise<Fact>;
770
801
  /**
@@ -833,7 +864,10 @@ declare class Korely {
833
864
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
834
865
  * asynchronously. Each object is the body of one `add()` (see
835
866
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
836
- * `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`.
837
871
  *
838
872
  * `timestamp` means what it means on `add()`: when the events happened.
839
873
  * The facts extracted from the item inherit it as `valid_from`, so a
@@ -883,7 +917,9 @@ declare class KorelyError extends Error {
883
917
  * The server answered with a non-2xx status. `status` is the HTTP status,
884
918
  * `code` the stable error code (`invalid_key`, `not_found`, `quota_exceeded`,
885
919
  * `search_unavailable` and so on). Anything without a subclass below (422
886
- * 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.
887
923
  *
888
924
  * The subclasses were siblings of this class in 0.1.6 and earlier, so the pattern the
889
925
  * public docs teach, `err instanceof APIError` and branch on `err.code`, let a
package/dist/index.d.ts CHANGED
@@ -75,6 +75,8 @@ interface Memory {
75
75
  updated_at?: string;
76
76
  /** Facts extracted from this memory on the write path. */
77
77
  facts?: Fact[];
78
+ /** "note" or "session" (Korely Agent 0.1.42); absent from an older server. */
79
+ kind?: "note" | "session";
78
80
  }
79
81
  interface SearchHit {
80
82
  id?: string;
@@ -153,7 +155,14 @@ interface Context {
153
155
  */
154
156
  interface BatchMemory {
155
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
+ */
156
164
  user_id?: string;
165
+ /** The agent writing the item; see `user_id`. */
157
166
  agent_id?: string;
158
167
  run_id?: string;
159
168
  metadata?: Record<string, unknown>;
@@ -164,6 +173,8 @@ interface BatchMemory {
164
173
  * queued.
165
174
  */
166
175
  timestamp?: string;
176
+ /** "note" (default) or "session", as on `add()` (Korely Agent 0.1.42). */
177
+ kind?: "note" | "session";
167
178
  }
168
179
  interface BatchJob {
169
180
  id?: string;
@@ -360,7 +371,16 @@ interface AuditPage extends Iterable<AuditEvent> {
360
371
  total: number;
361
372
  }
362
373
  interface AddOptions {
374
+ /** The agent writing the memory; see `user_id`. */
363
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
+ */
364
384
  user_id?: string;
365
385
  run_id?: string;
366
386
  metadata?: Record<string, unknown>;
@@ -485,7 +505,12 @@ interface GetFactsOptions {
485
505
  exclude_sessions?: boolean;
486
506
  }
487
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
+ */
488
512
  user_id?: string;
513
+ /** The agent writing the fact; see `user_id`. */
489
514
  agent_id?: string;
490
515
  run_id?: string;
491
516
  subject_type?: string;
@@ -534,7 +559,7 @@ interface ForgetReceipt {
534
559
 
535
560
  /** Must equal `version` in package.json (a test checks). It goes out in the
536
561
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
537
- declare const VERSION = "0.1.16";
562
+ declare const VERSION = "0.1.18";
538
563
  interface KorelyOptions {
539
564
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
540
565
  apiKey?: string;
@@ -662,6 +687,11 @@ declare class Korely {
662
687
  * `content` is a string, or a list of chat messages (role/content), joined
663
688
  * into one block before sending. Pass `timestamp` (ISO date/datetime) for
664
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.
665
695
  */
666
696
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
667
697
  /**
@@ -764,7 +794,8 @@ declare class Korely {
764
794
  * skipping extraction. The server runs the contradiction check; the fact is
765
795
  * bi-temporal (pass `valid_from` for a historical fact, `tense: "past"` for
766
796
  * one that is over). Resolves to the written Fact, with `invalidated`
767
- * 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).
768
799
  */
769
800
  addFactTriple(subject: string, predicate: string, object: string, opts?: AddFactTripleOptions): Promise<Fact>;
770
801
  /**
@@ -833,7 +864,10 @@ declare class Korely {
833
864
  * POST /v1/batch: bulk import, up to 500 memory objects, processed
834
865
  * asynchronously. Each object is the body of one `add()` (see
835
866
  * `BatchMemory`): `content` and optionally `user_id`, `agent_id`, `run_id`,
836
- * `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`.
837
871
  *
838
872
  * `timestamp` means what it means on `add()`: when the events happened.
839
873
  * The facts extracted from the item inherit it as `valid_from`, so a
@@ -883,7 +917,9 @@ declare class KorelyError extends Error {
883
917
  * The server answered with a non-2xx status. `status` is the HTTP status,
884
918
  * `code` the stable error code (`invalid_key`, `not_found`, `quota_exceeded`,
885
919
  * `search_unavailable` and so on). Anything without a subclass below (422
886
- * 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.
887
923
  *
888
924
  * The subclasses were siblings of this class in 0.1.6 and earlier, so the pattern the
889
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.16";
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.16",
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",