korely-memory 0.1.14 → 0.1.16

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/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.14";
129
+ var VERSION = "0.1.16";
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
@@ -306,6 +306,11 @@ interface AgentInitResult {
306
306
  scopes: string[];
307
307
  /** The hobby allowance: writes_per_month, queries_per_month, agents, the monthly AI budget. */
308
308
  quotas: Record<string, unknown>;
309
+ /** The Terms of Service that creating the account accepts. Absent from a
310
+ * server older than Korely Agent 0.1.27. */
311
+ terms_url?: string;
312
+ /** The Privacy Policy, likewise. */
313
+ privacy_url?: string;
309
314
  }
310
315
  /**
311
316
  * What `deleteAccount()` removed. `deleted` is true: the account and every key
@@ -365,6 +370,26 @@ interface AddOptions {
365
370
  * reflect when things were true, not when they were ingested. Defaults to now.
366
371
  */
367
372
  timestamp?: string;
373
+ /**
374
+ * What the text is: "note" (the default) or "session", the log of a work
375
+ * session (Korely Agent 0.1.42). A read with `exclude_sessions` leaves the
376
+ * sessions and the facts only they stated out. An older server refuses the
377
+ * field with a 422.
378
+ */
379
+ kind?: "note" | "session";
380
+ }
381
+ /** What `declareName` declared: in `user_id`'s memory (`agent_id` the
382
+ * namespace, none for the end user's own) the facts about `name` read as the
383
+ * end user's, since `since`. */
384
+ interface DeclaredName {
385
+ user_id: string;
386
+ name: string;
387
+ agent_id?: string | null;
388
+ since?: string | null;
389
+ }
390
+ interface DeclareNameOptions {
391
+ user_id: string;
392
+ agent_id?: string;
368
393
  }
369
394
  interface SearchOptions {
370
395
  user_id?: string;
@@ -382,6 +407,8 @@ interface SearchOptions {
382
407
  * LongMemEval with EmbeddingGemma; the right one depends on your texts.
383
408
  */
384
409
  min_score?: number;
410
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
411
+ exclude_sessions?: boolean;
385
412
  }
386
413
  interface ListOptions {
387
414
  user_id?: string;
@@ -391,6 +418,8 @@ interface ListOptions {
391
418
  /** Default 50, up to 200. */
392
419
  limit?: number;
393
420
  offset?: number;
421
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
422
+ exclude_sessions?: boolean;
394
423
  }
395
424
  interface UpdateOptions {
396
425
  content: string;
@@ -452,6 +481,8 @@ interface GetFactsOptions {
452
481
  agent_id?: string;
453
482
  limit?: number;
454
483
  offset?: number;
484
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
485
+ exclude_sessions?: boolean;
455
486
  }
456
487
  interface AddFactTripleOptions {
457
488
  user_id?: string;
@@ -475,6 +506,8 @@ interface GetProfileOptions {
475
506
  as_of?: string;
476
507
  /** ISO date: the profile as the store knew it on that date. */
477
508
  known_as_of?: string;
509
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
510
+ exclude_sessions?: boolean;
478
511
  }
479
512
  interface GetContextOptions {
480
513
  query: string;
@@ -486,6 +519,8 @@ interface GetContextOptions {
486
519
  * knew and the memories it had received (Korely Agent 0.1.26).
487
520
  */
488
521
  known_as_of?: string;
522
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
523
+ exclude_sessions?: boolean;
489
524
  }
490
525
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
491
526
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -499,7 +534,7 @@ interface ForgetReceipt {
499
534
 
500
535
  /** Must equal `version` in package.json (a test checks). It goes out in the
501
536
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
502
- declare const VERSION = "0.1.14";
537
+ declare const VERSION = "0.1.16";
503
538
  interface KorelyOptions {
504
539
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
505
540
  apiKey?: string;
@@ -516,6 +551,12 @@ interface KorelyOptions {
516
551
  timeoutMs?: number;
517
552
  /** Inject a fetch implementation (mainly for testing / older runtimes). */
518
553
  fetch?: typeof fetch;
554
+ /**
555
+ * The tool writing, e.g. "claude-code" (else KORELY_CLIENT): sent as
556
+ * `X-Korely-Client`, which Korely Agent keeps on each memory as `client`, a
557
+ * label no agent cap counts. Left out, the header names this library.
558
+ */
559
+ client?: string;
519
560
  }
520
561
  /** Where and how `Korely.initAgent()` signs up: the client options a call
521
562
  * without a key can use. */
@@ -531,6 +572,7 @@ declare class Korely {
531
572
  readonly apiKey: string;
532
573
  readonly baseUrl: string;
533
574
  readonly timeoutMs: number;
575
+ readonly client?: string;
534
576
  private readonly fetchImpl;
535
577
  constructor(opts?: KorelyOptions);
536
578
  /**
@@ -635,6 +677,17 @@ declare class Korely {
635
677
  * `total` and `offset` walk the rest.
636
678
  */
637
679
  getAll(opts?: ListOptions): Promise<MemoryPage>;
680
+ /**
681
+ * POST /v1/users/:user_id/names: declare that this end user is also called
682
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
683
+ * 0.1.42. The store never merges two names of a person by itself, since two
684
+ * people can share one; after this the facts about `name` in the end user's
685
+ * memory read as the end user's, those already written included. In the
686
+ * key's project. Declaring the same name again answers the same; a name
687
+ * already declared for somebody else in that memory rejects with a
688
+ * ConflictError. Call it once per name the person is called by.
689
+ */
690
+ declareName(name: string, opts: DeclareNameOptions): Promise<DeclaredName>;
638
691
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
639
692
  get(memoryId: string): Promise<Memory>;
640
693
  /**
@@ -944,4 +997,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
944
997
  constructor(message?: string, opts?: QuotaErrorOptions);
945
998
  }
946
999
 
947
- 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 };
1000
+ 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
@@ -306,6 +306,11 @@ interface AgentInitResult {
306
306
  scopes: string[];
307
307
  /** The hobby allowance: writes_per_month, queries_per_month, agents, the monthly AI budget. */
308
308
  quotas: Record<string, unknown>;
309
+ /** The Terms of Service that creating the account accepts. Absent from a
310
+ * server older than Korely Agent 0.1.27. */
311
+ terms_url?: string;
312
+ /** The Privacy Policy, likewise. */
313
+ privacy_url?: string;
309
314
  }
310
315
  /**
311
316
  * What `deleteAccount()` removed. `deleted` is true: the account and every key
@@ -365,6 +370,26 @@ interface AddOptions {
365
370
  * reflect when things were true, not when they were ingested. Defaults to now.
366
371
  */
367
372
  timestamp?: string;
373
+ /**
374
+ * What the text is: "note" (the default) or "session", the log of a work
375
+ * session (Korely Agent 0.1.42). A read with `exclude_sessions` leaves the
376
+ * sessions and the facts only they stated out. An older server refuses the
377
+ * field with a 422.
378
+ */
379
+ kind?: "note" | "session";
380
+ }
381
+ /** What `declareName` declared: in `user_id`'s memory (`agent_id` the
382
+ * namespace, none for the end user's own) the facts about `name` read as the
383
+ * end user's, since `since`. */
384
+ interface DeclaredName {
385
+ user_id: string;
386
+ name: string;
387
+ agent_id?: string | null;
388
+ since?: string | null;
389
+ }
390
+ interface DeclareNameOptions {
391
+ user_id: string;
392
+ agent_id?: string;
368
393
  }
369
394
  interface SearchOptions {
370
395
  user_id?: string;
@@ -382,6 +407,8 @@ interface SearchOptions {
382
407
  * LongMemEval with EmbeddingGemma; the right one depends on your texts.
383
408
  */
384
409
  min_score?: number;
410
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
411
+ exclude_sessions?: boolean;
385
412
  }
386
413
  interface ListOptions {
387
414
  user_id?: string;
@@ -391,6 +418,8 @@ interface ListOptions {
391
418
  /** Default 50, up to 200. */
392
419
  limit?: number;
393
420
  offset?: number;
421
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
422
+ exclude_sessions?: boolean;
394
423
  }
395
424
  interface UpdateOptions {
396
425
  content: string;
@@ -452,6 +481,8 @@ interface GetFactsOptions {
452
481
  agent_id?: string;
453
482
  limit?: number;
454
483
  offset?: number;
484
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
485
+ exclude_sessions?: boolean;
455
486
  }
456
487
  interface AddFactTripleOptions {
457
488
  user_id?: string;
@@ -475,6 +506,8 @@ interface GetProfileOptions {
475
506
  as_of?: string;
476
507
  /** ISO date: the profile as the store knew it on that date. */
477
508
  known_as_of?: string;
509
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
510
+ exclude_sessions?: boolean;
478
511
  }
479
512
  interface GetContextOptions {
480
513
  query: string;
@@ -486,6 +519,8 @@ interface GetContextOptions {
486
519
  * knew and the memories it had received (Korely Agent 0.1.26).
487
520
  */
488
521
  known_as_of?: string;
522
+ /** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
523
+ exclude_sessions?: boolean;
489
524
  }
490
525
  /** What `forgetFact` gives back. `status` is "forgotten" the first time and
491
526
  * "already_forgotten" afterwards; `invalid_at` is the date it stopped being
@@ -499,7 +534,7 @@ interface ForgetReceipt {
499
534
 
500
535
  /** Must equal `version` in package.json (a test checks). It goes out in the
501
536
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
502
- declare const VERSION = "0.1.14";
537
+ declare const VERSION = "0.1.16";
503
538
  interface KorelyOptions {
504
539
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
505
540
  apiKey?: string;
@@ -516,6 +551,12 @@ interface KorelyOptions {
516
551
  timeoutMs?: number;
517
552
  /** Inject a fetch implementation (mainly for testing / older runtimes). */
518
553
  fetch?: typeof fetch;
554
+ /**
555
+ * The tool writing, e.g. "claude-code" (else KORELY_CLIENT): sent as
556
+ * `X-Korely-Client`, which Korely Agent keeps on each memory as `client`, a
557
+ * label no agent cap counts. Left out, the header names this library.
558
+ */
559
+ client?: string;
519
560
  }
520
561
  /** Where and how `Korely.initAgent()` signs up: the client options a call
521
562
  * without a key can use. */
@@ -531,6 +572,7 @@ declare class Korely {
531
572
  readonly apiKey: string;
532
573
  readonly baseUrl: string;
533
574
  readonly timeoutMs: number;
575
+ readonly client?: string;
534
576
  private readonly fetchImpl;
535
577
  constructor(opts?: KorelyOptions);
536
578
  /**
@@ -635,6 +677,17 @@ declare class Korely {
635
677
  * `total` and `offset` walk the rest.
636
678
  */
637
679
  getAll(opts?: ListOptions): Promise<MemoryPage>;
680
+ /**
681
+ * POST /v1/users/:user_id/names: declare that this end user is also called
682
+ * `name` (`declareName("Maria Rossi", { user_id: "maria" })`), Korely Agent
683
+ * 0.1.42. The store never merges two names of a person by itself, since two
684
+ * people can share one; after this the facts about `name` in the end user's
685
+ * memory read as the end user's, those already written included. In the
686
+ * key's project. Declaring the same name again answers the same; a name
687
+ * already declared for somebody else in that memory rejects with a
688
+ * ConflictError. Call it once per name the person is called by.
689
+ */
690
+ declareName(name: string, opts: DeclareNameOptions): Promise<DeclaredName>;
638
691
  /** GET /v1/memories/:id: full content, metadata, extracted facts. */
639
692
  get(memoryId: string): Promise<Memory>;
640
693
  /**
@@ -944,4 +997,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
944
997
  constructor(message?: string, opts?: QuotaErrorOptions);
945
998
  }
946
999
 
947
- 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 };
1000
+ 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.14";
80
+ var VERSION = "0.1.16";
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.14",
3
+ "version": "0.1.16",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",