korely-memory 0.1.15 → 0.1.17

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
@@ -100,7 +100,7 @@ Every method maps to one REST endpoint.
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. |
package/dist/index.cjs CHANGED
@@ -126,13 +126,22 @@ function unknownOption(method, opts, known) {
126
126
  }
127
127
 
128
128
  // src/client.ts
129
- var VERSION = "0.1.15";
129
+ var VERSION = "0.1.17";
130
130
  var REGIONS = { eu: "https://api.korely.ai" };
131
- var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
131
+ var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch", "client");
132
132
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
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", "min_score");
135
- var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
133
+ var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp", "kind");
134
+ var SEARCH_KEYS = keysOf()(
135
+ "user_id",
136
+ "agent_id",
137
+ "run_id",
138
+ "metadata",
139
+ "limit",
140
+ "min_score",
141
+ "exclude_sessions"
142
+ );
143
+ var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset", "exclude_sessions");
144
+ var NAME_KEYS = keysOf()("user_id", "agent_id");
136
145
  var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
137
146
  var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
138
147
  var AGENTS_KEYS = keysOf()("limit", "offset");
@@ -150,7 +159,8 @@ var FACTS_KEYS = keysOf()(
150
159
  "user_id",
151
160
  "agent_id",
152
161
  "limit",
153
- "offset"
162
+ "offset",
163
+ "exclude_sessions"
154
164
  );
155
165
  var TRIPLE_KEYS = keysOf()(
156
166
  "user_id",
@@ -162,19 +172,27 @@ var TRIPLE_KEYS = keysOf()(
162
172
  "valid_from",
163
173
  "tense"
164
174
  );
165
- var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of", "known_as_of");
175
+ var PROFILE_KEYS = keysOf()(
176
+ "user_id",
177
+ "agent_id",
178
+ "as_of",
179
+ "known_as_of",
180
+ "exclude_sessions"
181
+ );
166
182
  var CONTEXT_KEYS = keysOf()(
167
183
  "query",
168
184
  "user_id",
169
185
  "agent_id",
170
186
  "token_budget",
171
- "known_as_of"
187
+ "known_as_of",
188
+ "exclude_sessions"
172
189
  );
173
190
  var CONTEXT_EXTRA_KEYS = keysOf()(
174
191
  "user_id",
175
192
  "agent_id",
176
193
  "token_budget",
177
- "known_as_of"
194
+ "known_as_of",
195
+ "exclude_sessions"
178
196
  );
179
197
  function checkOptions(method, opts, known) {
180
198
  const problem = unknownOption(method, opts, known);
@@ -324,7 +342,7 @@ async function exchange(t, method, path, opts = {}) {
324
342
  }
325
343
  const headers = {
326
344
  Accept: "application/json",
327
- "X-Korely-Client": `korely-js/${VERSION}`
345
+ "X-Korely-Client": t.client || `korely-js/${VERSION}`
328
346
  };
329
347
  if (t.apiKey) headers.Authorization = `Bearer ${t.apiKey}`;
330
348
  let body;
@@ -434,6 +452,8 @@ var Korely = class {
434
452
  );
435
453
  }
436
454
  this.apiKey = key;
455
+ const envClient = typeof process !== "undefined" ? process.env?.KORELY_CLIENT : void 0;
456
+ this.client = (opts.client ?? envClient ?? "").trim() || void 0;
437
457
  this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
438
458
  refuseAMismatchedPair(this.apiKey, this.baseUrl);
439
459
  this.timeoutMs = opts.timeoutMs ?? 3e4;
@@ -494,7 +514,13 @@ var Korely = class {
494
514
  // ── transport ─────────────────────────────────────────────────────────────
495
515
  request(method, path, opts = {}) {
496
516
  return exchange(
497
- { baseUrl: this.baseUrl, timeoutMs: this.timeoutMs, fetchImpl: this.fetchImpl, apiKey: this.apiKey },
517
+ {
518
+ baseUrl: this.baseUrl,
519
+ timeoutMs: this.timeoutMs,
520
+ fetchImpl: this.fetchImpl,
521
+ apiKey: this.apiKey,
522
+ client: this.client
523
+ },
498
524
  method,
499
525
  path,
500
526
  opts
@@ -628,7 +654,8 @@ var Korely = class {
628
654
  user_id: opts.user_id,
629
655
  run_id: opts.run_id,
630
656
  metadata: opts.metadata,
631
- timestamp: opts.timestamp
657
+ timestamp: opts.timestamp,
658
+ kind: opts.kind
632
659
  }
633
660
  });
634
661
  }
@@ -648,7 +675,9 @@ var Korely = class {
648
675
  run_id: opts.run_id,
649
676
  metadata: opts.metadata,
650
677
  limit: opts.limit,
651
- min_score: opts.min_score
678
+ min_score: opts.min_score,
679
+ // Sent only when true: an older server does not know the field.
680
+ exclude_sessions: opts.exclude_sessions ? true : void 0
652
681
  }
653
682
  });
654
683
  return body.results ?? [];
@@ -669,12 +698,32 @@ var Korely = class {
669
698
  agent_id: opts.agent_id,
670
699
  run_id: opts.run_id,
671
700
  limit: opts.limit ?? 50,
672
- offset: opts.offset ?? 0
701
+ offset: opts.offset ?? 0,
702
+ exclude_sessions: opts.exclude_sessions ? "true" : void 0
673
703
  }
674
704
  }
675
705
  );
676
706
  return iterableOver(page, "memories");
677
707
  }
708
+ /**
709
+ * POST /v1/users/:user_id/names: declare that this end user is also called
710
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
711
+ * 0.1.42. The store never merges two names of a person by itself, since two
712
+ * people can share one; after this the facts about `name` in the end user's
713
+ * memory read as the end user's, those already written included. In the
714
+ * key's project. Declaring the same name again answers the same; a name
715
+ * already declared for somebody else in that memory rejects with a
716
+ * ConflictError. Call it once per name the person is called by.
717
+ */
718
+ async declareName(name, opts) {
719
+ checkOptions("declareName", opts, NAME_KEYS);
720
+ if (typeof name !== "string" || !name.trim()) {
721
+ throw new KorelyError("declareName needs a name.");
722
+ }
723
+ return this.request("POST", `/v1/users/${seg(opts.user_id, "user_id")}/names`, {
724
+ body: { name, agent_id: opts.agent_id }
725
+ });
726
+ }
678
727
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
679
728
  async get(memoryId) {
680
729
  return this.request("GET", `/v1/memories/${seg(memoryId, "memoryId")}`);
@@ -809,6 +858,7 @@ var Korely = class {
809
858
  offset: opts.offset ?? 0
810
859
  };
811
860
  if (opts.include_invalidated) params.include_invalidated = "true";
861
+ if (opts.exclude_sessions) params.exclude_sessions = "true";
812
862
  const body = await this.request("GET", "/v1/facts", { params });
813
863
  const facts = [...body.facts ?? []];
814
864
  Object.defineProperty(facts, "total", {
@@ -899,7 +949,8 @@ var Korely = class {
899
949
  user_id: opts.user_id,
900
950
  agent_id: opts.agent_id,
901
951
  as_of: opts.as_of,
902
- known_as_of: opts.known_as_of
952
+ known_as_of: opts.known_as_of,
953
+ exclude_sessions: opts.exclude_sessions ? "true" : void 0
903
954
  }
904
955
  });
905
956
  }
@@ -922,7 +973,8 @@ var Korely = class {
922
973
  user_id: o.user_id,
923
974
  agent_id: o.agent_id,
924
975
  token_budget: o.token_budget ?? 800,
925
- known_as_of: o.known_as_of
976
+ known_as_of: o.known_as_of,
977
+ exclude_sessions: o.exclude_sessions ? "true" : void 0
926
978
  }
927
979
  });
928
980
  }
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;
@@ -164,6 +166,8 @@ interface BatchMemory {
164
166
  * queued.
165
167
  */
166
168
  timestamp?: string;
169
+ /** "note" (default) or "session", as on `add()` (Korely Agent 0.1.42). */
170
+ kind?: "note" | "session";
167
171
  }
168
172
  interface BatchJob {
169
173
  id?: string;
@@ -370,6 +374,26 @@ interface AddOptions {
370
374
  * reflect when things were true, not when they were ingested. Defaults to now.
371
375
  */
372
376
  timestamp?: string;
377
+ /**
378
+ * What the text is: "note" (the default) or "session", the log of a work
379
+ * session (Korely Agent 0.1.42). A read with `exclude_sessions` leaves the
380
+ * sessions and the facts only they stated out. An older server refuses the
381
+ * field with a 422.
382
+ */
383
+ kind?: "note" | "session";
384
+ }
385
+ /** What `declareName` declared: in `user_id`'s memory (`agent_id` the
386
+ * namespace, none for the end user's own) the facts about `name` read as the
387
+ * end user's, since `since`. */
388
+ interface DeclaredName {
389
+ user_id: string;
390
+ name: string;
391
+ agent_id?: string | null;
392
+ since?: string | null;
393
+ }
394
+ interface DeclareNameOptions {
395
+ user_id: string;
396
+ agent_id?: string;
373
397
  }
374
398
  interface SearchOptions {
375
399
  user_id?: string;
@@ -387,6 +411,8 @@ interface SearchOptions {
387
411
  * LongMemEval with EmbeddingGemma; the right one depends on your texts.
388
412
  */
389
413
  min_score?: number;
414
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
415
+ exclude_sessions?: boolean;
390
416
  }
391
417
  interface ListOptions {
392
418
  user_id?: string;
@@ -396,6 +422,8 @@ interface ListOptions {
396
422
  /** Default 50, up to 200. */
397
423
  limit?: number;
398
424
  offset?: number;
425
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
426
+ exclude_sessions?: boolean;
399
427
  }
400
428
  interface UpdateOptions {
401
429
  content: string;
@@ -457,6 +485,8 @@ interface GetFactsOptions {
457
485
  agent_id?: string;
458
486
  limit?: number;
459
487
  offset?: number;
488
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
489
+ exclude_sessions?: boolean;
460
490
  }
461
491
  interface AddFactTripleOptions {
462
492
  user_id?: string;
@@ -480,6 +510,8 @@ interface GetProfileOptions {
480
510
  as_of?: string;
481
511
  /** ISO date: the profile as the store knew it on that date. */
482
512
  known_as_of?: string;
513
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
514
+ exclude_sessions?: boolean;
483
515
  }
484
516
  interface GetContextOptions {
485
517
  query: string;
@@ -491,6 +523,8 @@ interface GetContextOptions {
491
523
  * knew and the memories it had received (Korely Agent 0.1.26).
492
524
  */
493
525
  known_as_of?: string;
526
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
527
+ exclude_sessions?: boolean;
494
528
  }
495
529
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
496
530
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -504,7 +538,7 @@ interface ForgetReceipt {
504
538
 
505
539
  /** Must equal `version` in package.json (a test checks). It goes out in the
506
540
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
507
- declare const VERSION = "0.1.15";
541
+ declare const VERSION = "0.1.17";
508
542
  interface KorelyOptions {
509
543
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
510
544
  apiKey?: string;
@@ -521,6 +555,12 @@ interface KorelyOptions {
521
555
  timeoutMs?: number;
522
556
  /** Inject a fetch implementation (mainly for testing / older runtimes). */
523
557
  fetch?: typeof fetch;
558
+ /**
559
+ * The tool writing, e.g. "claude-code" (else KORELY_CLIENT): sent as
560
+ * `X-Korely-Client`, which Korely Agent keeps on each memory as `client`, a
561
+ * label no agent cap counts. Left out, the header names this library.
562
+ */
563
+ client?: string;
524
564
  }
525
565
  /** Where and how `Korely.initAgent()` signs up: the client options a call
526
566
  * without a key can use. */
@@ -536,6 +576,7 @@ declare class Korely {
536
576
  readonly apiKey: string;
537
577
  readonly baseUrl: string;
538
578
  readonly timeoutMs: number;
579
+ readonly client?: string;
539
580
  private readonly fetchImpl;
540
581
  constructor(opts?: KorelyOptions);
541
582
  /**
@@ -640,6 +681,17 @@ declare class Korely {
640
681
  * `total` and `offset` walk the rest.
641
682
  */
642
683
  getAll(opts?: ListOptions): Promise<MemoryPage>;
684
+ /**
685
+ * POST /v1/users/:user_id/names: declare that this end user is also called
686
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
687
+ * 0.1.42. The store never merges two names of a person by itself, since two
688
+ * people can share one; after this the facts about `name` in the end user's
689
+ * memory read as the end user's, those already written included. In the
690
+ * key's project. Declaring the same name again answers the same; a name
691
+ * already declared for somebody else in that memory rejects with a
692
+ * ConflictError. Call it once per name the person is called by.
693
+ */
694
+ declareName(name: string, opts: DeclareNameOptions): Promise<DeclaredName>;
643
695
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
644
696
  get(memoryId: string): Promise<Memory>;
645
697
  /**
@@ -949,4 +1001,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
949
1001
  constructor(message?: string, opts?: QuotaErrorOptions);
950
1002
  }
951
1003
 
952
- export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
1004
+ export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
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;
@@ -164,6 +166,8 @@ interface BatchMemory {
164
166
  * queued.
165
167
  */
166
168
  timestamp?: string;
169
+ /** "note" (default) or "session", as on `add()` (Korely Agent 0.1.42). */
170
+ kind?: "note" | "session";
167
171
  }
168
172
  interface BatchJob {
169
173
  id?: string;
@@ -370,6 +374,26 @@ interface AddOptions {
370
374
  * reflect when things were true, not when they were ingested. Defaults to now.
371
375
  */
372
376
  timestamp?: string;
377
+ /**
378
+ * What the text is: "note" (the default) or "session", the log of a work
379
+ * session (Korely Agent 0.1.42). A read with `exclude_sessions` leaves the
380
+ * sessions and the facts only they stated out. An older server refuses the
381
+ * field with a 422.
382
+ */
383
+ kind?: "note" | "session";
384
+ }
385
+ /** What `declareName` declared: in `user_id`'s memory (`agent_id` the
386
+ * namespace, none for the end user's own) the facts about `name` read as the
387
+ * end user's, since `since`. */
388
+ interface DeclaredName {
389
+ user_id: string;
390
+ name: string;
391
+ agent_id?: string | null;
392
+ since?: string | null;
393
+ }
394
+ interface DeclareNameOptions {
395
+ user_id: string;
396
+ agent_id?: string;
373
397
  }
374
398
  interface SearchOptions {
375
399
  user_id?: string;
@@ -387,6 +411,8 @@ interface SearchOptions {
387
411
  * LongMemEval with EmbeddingGemma; the right one depends on your texts.
388
412
  */
389
413
  min_score?: number;
414
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
415
+ exclude_sessions?: boolean;
390
416
  }
391
417
  interface ListOptions {
392
418
  user_id?: string;
@@ -396,6 +422,8 @@ interface ListOptions {
396
422
  /** Default 50, up to 200. */
397
423
  limit?: number;
398
424
  offset?: number;
425
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
426
+ exclude_sessions?: boolean;
399
427
  }
400
428
  interface UpdateOptions {
401
429
  content: string;
@@ -457,6 +485,8 @@ interface GetFactsOptions {
457
485
  agent_id?: string;
458
486
  limit?: number;
459
487
  offset?: number;
488
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
489
+ exclude_sessions?: boolean;
460
490
  }
461
491
  interface AddFactTripleOptions {
462
492
  user_id?: string;
@@ -480,6 +510,8 @@ interface GetProfileOptions {
480
510
  as_of?: string;
481
511
  /** ISO date: the profile as the store knew it on that date. */
482
512
  known_as_of?: string;
513
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
514
+ exclude_sessions?: boolean;
483
515
  }
484
516
  interface GetContextOptions {
485
517
  query: string;
@@ -491,6 +523,8 @@ interface GetContextOptions {
491
523
  * knew and the memories it had received (Korely Agent 0.1.26).
492
524
  */
493
525
  known_as_of?: string;
526
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
527
+ exclude_sessions?: boolean;
494
528
  }
495
529
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
496
530
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -504,7 +538,7 @@ interface ForgetReceipt {
504
538
 
505
539
  /** Must equal `version` in package.json (a test checks). It goes out in the
506
540
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
507
- declare const VERSION = "0.1.15";
541
+ declare const VERSION = "0.1.17";
508
542
  interface KorelyOptions {
509
543
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
510
544
  apiKey?: string;
@@ -521,6 +555,12 @@ interface KorelyOptions {
521
555
  timeoutMs?: number;
522
556
  /** Inject a fetch implementation (mainly for testing / older runtimes). */
523
557
  fetch?: typeof fetch;
558
+ /**
559
+ * The tool writing, e.g. "claude-code" (else KORELY_CLIENT): sent as
560
+ * `X-Korely-Client`, which Korely Agent keeps on each memory as `client`, a
561
+ * label no agent cap counts. Left out, the header names this library.
562
+ */
563
+ client?: string;
524
564
  }
525
565
  /** Where and how `Korely.initAgent()` signs up: the client options a call
526
566
  * without a key can use. */
@@ -536,6 +576,7 @@ declare class Korely {
536
576
  readonly apiKey: string;
537
577
  readonly baseUrl: string;
538
578
  readonly timeoutMs: number;
579
+ readonly client?: string;
539
580
  private readonly fetchImpl;
540
581
  constructor(opts?: KorelyOptions);
541
582
  /**
@@ -640,6 +681,17 @@ declare class Korely {
640
681
  * `total` and `offset` walk the rest.
641
682
  */
642
683
  getAll(opts?: ListOptions): Promise<MemoryPage>;
684
+ /**
685
+ * POST /v1/users/:user_id/names: declare that this end user is also called
686
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
687
+ * 0.1.42. The store never merges two names of a person by itself, since two
688
+ * people can share one; after this the facts about `name` in the end user's
689
+ * memory read as the end user's, those already written included. In the
690
+ * key's project. Declaring the same name again answers the same; a name
691
+ * already declared for somebody else in that memory rejects with a
692
+ * ConflictError. Call it once per name the person is called by.
693
+ */
694
+ declareName(name: string, opts: DeclareNameOptions): Promise<DeclaredName>;
643
695
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
644
696
  get(memoryId: string): Promise<Memory>;
645
697
  /**
@@ -949,4 +1001,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
949
1001
  constructor(message?: string, opts?: QuotaErrorOptions);
950
1002
  }
951
1003
 
952
- export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
1004
+ export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
package/dist/index.js CHANGED
@@ -77,13 +77,22 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
77
77
  };
78
78
 
79
79
  // src/client.ts
80
- var VERSION = "0.1.15";
80
+ var VERSION = "0.1.17";
81
81
  var REGIONS = { eu: "https://api.korely.ai" };
82
- var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
82
+ var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch", "client");
83
83
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
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", "min_score");
86
- var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
84
+ var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp", "kind");
85
+ var SEARCH_KEYS = keysOf()(
86
+ "user_id",
87
+ "agent_id",
88
+ "run_id",
89
+ "metadata",
90
+ "limit",
91
+ "min_score",
92
+ "exclude_sessions"
93
+ );
94
+ var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset", "exclude_sessions");
95
+ var NAME_KEYS = keysOf()("user_id", "agent_id");
87
96
  var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
88
97
  var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
89
98
  var AGENTS_KEYS = keysOf()("limit", "offset");
@@ -101,7 +110,8 @@ var FACTS_KEYS = keysOf()(
101
110
  "user_id",
102
111
  "agent_id",
103
112
  "limit",
104
- "offset"
113
+ "offset",
114
+ "exclude_sessions"
105
115
  );
106
116
  var TRIPLE_KEYS = keysOf()(
107
117
  "user_id",
@@ -113,19 +123,27 @@ var TRIPLE_KEYS = keysOf()(
113
123
  "valid_from",
114
124
  "tense"
115
125
  );
116
- var PROFILE_KEYS = keysOf()("user_id", "agent_id", "as_of", "known_as_of");
126
+ var PROFILE_KEYS = keysOf()(
127
+ "user_id",
128
+ "agent_id",
129
+ "as_of",
130
+ "known_as_of",
131
+ "exclude_sessions"
132
+ );
117
133
  var CONTEXT_KEYS = keysOf()(
118
134
  "query",
119
135
  "user_id",
120
136
  "agent_id",
121
137
  "token_budget",
122
- "known_as_of"
138
+ "known_as_of",
139
+ "exclude_sessions"
123
140
  );
124
141
  var CONTEXT_EXTRA_KEYS = keysOf()(
125
142
  "user_id",
126
143
  "agent_id",
127
144
  "token_budget",
128
- "known_as_of"
145
+ "known_as_of",
146
+ "exclude_sessions"
129
147
  );
130
148
  function checkOptions(method, opts, known) {
131
149
  const problem = unknownOption(method, opts, known);
@@ -275,7 +293,7 @@ async function exchange(t, method, path, opts = {}) {
275
293
  }
276
294
  const headers = {
277
295
  Accept: "application/json",
278
- "X-Korely-Client": `korely-js/${VERSION}`
296
+ "X-Korely-Client": t.client || `korely-js/${VERSION}`
279
297
  };
280
298
  if (t.apiKey) headers.Authorization = `Bearer ${t.apiKey}`;
281
299
  let body;
@@ -385,6 +403,8 @@ var Korely = class {
385
403
  );
386
404
  }
387
405
  this.apiKey = key;
406
+ const envClient = typeof process !== "undefined" ? process.env?.KORELY_CLIENT : void 0;
407
+ this.client = (opts.client ?? envClient ?? "").trim() || void 0;
388
408
  this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
389
409
  refuseAMismatchedPair(this.apiKey, this.baseUrl);
390
410
  this.timeoutMs = opts.timeoutMs ?? 3e4;
@@ -445,7 +465,13 @@ var Korely = class {
445
465
  // ── transport ─────────────────────────────────────────────────────────────
446
466
  request(method, path, opts = {}) {
447
467
  return exchange(
448
- { baseUrl: this.baseUrl, timeoutMs: this.timeoutMs, fetchImpl: this.fetchImpl, apiKey: this.apiKey },
468
+ {
469
+ baseUrl: this.baseUrl,
470
+ timeoutMs: this.timeoutMs,
471
+ fetchImpl: this.fetchImpl,
472
+ apiKey: this.apiKey,
473
+ client: this.client
474
+ },
449
475
  method,
450
476
  path,
451
477
  opts
@@ -579,7 +605,8 @@ var Korely = class {
579
605
  user_id: opts.user_id,
580
606
  run_id: opts.run_id,
581
607
  metadata: opts.metadata,
582
- timestamp: opts.timestamp
608
+ timestamp: opts.timestamp,
609
+ kind: opts.kind
583
610
  }
584
611
  });
585
612
  }
@@ -599,7 +626,9 @@ var Korely = class {
599
626
  run_id: opts.run_id,
600
627
  metadata: opts.metadata,
601
628
  limit: opts.limit,
602
- min_score: opts.min_score
629
+ min_score: opts.min_score,
630
+ // Sent only when true: an older server does not know the field.
631
+ exclude_sessions: opts.exclude_sessions ? true : void 0
603
632
  }
604
633
  });
605
634
  return body.results ?? [];
@@ -620,12 +649,32 @@ var Korely = class {
620
649
  agent_id: opts.agent_id,
621
650
  run_id: opts.run_id,
622
651
  limit: opts.limit ?? 50,
623
- offset: opts.offset ?? 0
652
+ offset: opts.offset ?? 0,
653
+ exclude_sessions: opts.exclude_sessions ? "true" : void 0
624
654
  }
625
655
  }
626
656
  );
627
657
  return iterableOver(page, "memories");
628
658
  }
659
+ /**
660
+ * POST /v1/users/:user_id/names: declare that this end user is also called
661
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
662
+ * 0.1.42. The store never merges two names of a person by itself, since two
663
+ * people can share one; after this the facts about `name` in the end user's
664
+ * memory read as the end user's, those already written included. In the
665
+ * key's project. Declaring the same name again answers the same; a name
666
+ * already declared for somebody else in that memory rejects with a
667
+ * ConflictError. Call it once per name the person is called by.
668
+ */
669
+ async declareName(name, opts) {
670
+ checkOptions("declareName", opts, NAME_KEYS);
671
+ if (typeof name !== "string" || !name.trim()) {
672
+ throw new KorelyError("declareName needs a name.");
673
+ }
674
+ return this.request("POST", `/v1/users/${seg(opts.user_id, "user_id")}/names`, {
675
+ body: { name, agent_id: opts.agent_id }
676
+ });
677
+ }
629
678
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
630
679
  async get(memoryId) {
631
680
  return this.request("GET", `/v1/memories/${seg(memoryId, "memoryId")}`);
@@ -760,6 +809,7 @@ var Korely = class {
760
809
  offset: opts.offset ?? 0
761
810
  };
762
811
  if (opts.include_invalidated) params.include_invalidated = "true";
812
+ if (opts.exclude_sessions) params.exclude_sessions = "true";
763
813
  const body = await this.request("GET", "/v1/facts", { params });
764
814
  const facts = [...body.facts ?? []];
765
815
  Object.defineProperty(facts, "total", {
@@ -850,7 +900,8 @@ var Korely = class {
850
900
  user_id: opts.user_id,
851
901
  agent_id: opts.agent_id,
852
902
  as_of: opts.as_of,
853
- known_as_of: opts.known_as_of
903
+ known_as_of: opts.known_as_of,
904
+ exclude_sessions: opts.exclude_sessions ? "true" : void 0
854
905
  }
855
906
  });
856
907
  }
@@ -873,7 +924,8 @@ var Korely = class {
873
924
  user_id: o.user_id,
874
925
  agent_id: o.agent_id,
875
926
  token_budget: o.token_budget ?? 800,
876
- known_as_of: o.known_as_of
927
+ known_as_of: o.known_as_of,
928
+ exclude_sessions: o.exclude_sessions ? "true" : void 0
877
929
  }
878
930
  });
879
931
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",