korely-memory 0.1.11 → 0.1.12

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
@@ -163,7 +163,9 @@ try {
163
163
 
164
164
  `AuthenticationError` (401) · `NamespaceForbiddenError` (403, e.g.
165
165
  `agent_cap_exceeded`) · `NotFoundError` (404) · `ConflictError` (409, e.g.
166
- `account_has_login`; `stale_write` is its subclass `StaleWriteError`) ·
166
+ `account_has_login`; `fact_not_current` from `correctFact()` of a fact that is
167
+ history, with `currentFactId` the fact to correct instead; `stale_write` is its
168
+ subclass `StaleWriteError`) ·
167
169
  `QuotaExceededError` (429: `retryAfter` is set for `rate_limit_exceeded`,
168
170
  undefined for the monthly `quota_exceeded`) · `TooManyBatchesError` (a
169
171
  `QuotaExceededError`: `too_many_batches` from `batch()`, Cloud only, three
package/dist/index.cjs CHANGED
@@ -77,6 +77,7 @@ var ConflictError = class extends APIError {
77
77
  constructor(message = "", opts = {}) {
78
78
  super(message, opts);
79
79
  this.name = "ConflictError";
80
+ this.currentFactId = opts.currentFactId;
80
81
  Object.setPrototypeOf(this, new.target.prototype);
81
82
  }
82
83
  };
@@ -91,6 +92,9 @@ var QuotaExceededError = class extends APIError {
91
92
  constructor(message = "", opts = {}) {
92
93
  super(message, opts);
93
94
  this.name = "QuotaExceededError";
95
+ this.limit = opts.limit;
96
+ this.used = opts.used;
97
+ this.resetsAt = opts.resetsAt;
94
98
  Object.setPrototypeOf(this, new.target.prototype);
95
99
  }
96
100
  };
@@ -122,7 +126,7 @@ function unknownOption(method, opts, known) {
122
126
  }
123
127
 
124
128
  // src/client.ts
125
- var VERSION = "0.1.11";
129
+ var VERSION = "0.1.12";
126
130
  var REGIONS = { eu: "https://api.korely.ai" };
127
131
  var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
128
132
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
@@ -239,6 +243,23 @@ function errorFields(status, body) {
239
243
  const message = text2(b.message) ?? text2(pair.message) ?? detailLine(b.detail) ?? code ?? `HTTP ${status}`;
240
244
  return { code, message };
241
245
  }
246
+ function quotaFields(body) {
247
+ const b = body && typeof body === "object" ? body : {};
248
+ const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
249
+ const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
250
+ const str = (v) => typeof v === "string" && v ? v : void 0;
251
+ return {
252
+ limit: num(b.limit ?? d.limit),
253
+ used: num(b.used ?? d.used),
254
+ resetsAt: str(b.resets_at ?? d.resets_at)
255
+ };
256
+ }
257
+ function conflictFields(body) {
258
+ const b = body && typeof body === "object" ? body : {};
259
+ const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
260
+ const v = b.current_fact_id ?? d.current_fact_id;
261
+ return { currentFactId: typeof v === "string" && v ? v : void 0 };
262
+ }
242
263
  function retryAfterSeconds(raw) {
243
264
  if (raw == null) return void 0;
244
265
  const n = Math.ceil(Number(raw));
@@ -360,11 +381,12 @@ function raiseFor(status, body, retryAfter) {
360
381
  if (status === 404) throw new NotFoundError(msg, opts);
361
382
  if (status === 409) {
362
383
  if (code === "stale_write") throw new StaleWriteError(msg, opts);
363
- throw new ConflictError(msg, opts);
384
+ throw new ConflictError(msg, { ...opts, ...conflictFields(body) });
364
385
  }
365
386
  if (status === 429) {
366
- if (code === "too_many_batches") throw new TooManyBatchesError(msg, opts);
367
- throw new QuotaExceededError(msg, opts);
387
+ const quota = { ...opts, ...quotaFields(body) };
388
+ if (code === "too_many_batches") throw new TooManyBatchesError(msg, quota);
389
+ throw new QuotaExceededError(msg, quota);
368
390
  }
369
391
  throw new APIError(msg, opts);
370
392
  }
package/dist/index.d.cts CHANGED
@@ -474,7 +474,7 @@ interface ForgetReceipt {
474
474
 
475
475
  /** Must equal `version` in package.json (a test checks). It goes out in the
476
476
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
477
- declare const VERSION = "0.1.11";
477
+ declare const VERSION = "0.1.12";
478
478
  interface KorelyOptions {
479
479
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
480
480
  apiKey?: string;
@@ -838,12 +838,18 @@ declare class NamespaceForbiddenError extends APIError {
838
838
  declare class NotFoundError extends APIError {
839
839
  constructor(message?: string, opts?: APIErrorOptions);
840
840
  }
841
+ interface ConflictErrorOptions extends APIErrorOptions {
842
+ currentFactId?: string;
843
+ }
841
844
  /**
842
845
  * 409: the request conflicts with what the server holds. `code` names the
843
846
  * conflict: `stale_write` (update() with an expected_updated_at older than the
844
847
  * record, thrown as the subclass StaleWriteError), `account_has_login`
845
848
  * (`deleteAccount()` with the key of an account somebody signs in to, Cloud
846
- * only) or `conflict` (the Self-hosted's code for a 409 that names no other).
849
+ * only), `fact_not_current` (`correctFact()` of a fact that is history:
850
+ * superseded, forgotten or ended; `currentFactId` is the fact to correct
851
+ * instead) or `conflict` (the Self-hosted's code for a 409 that names no
852
+ * other).
847
853
  *
848
854
  * Until 2026-10-06 every 409 was a StaleWriteError, so a refusal that has
849
855
  * nothing to do with an update read as a lost write, and code written to
@@ -851,7 +857,15 @@ declare class NotFoundError extends APIError {
851
857
  * changes.
852
858
  */
853
859
  declare class ConflictError extends APIError {
854
- constructor(message?: string, opts?: APIErrorOptions);
860
+ /**
861
+ * On `fact_not_current` (2026-10-07): the id of the fact that holds now, the
862
+ * one to correct instead. Undefined when nothing superseded the fact asked
863
+ * (it was forgotten or ended: write the value of now with `addFactTriple()`),
864
+ * on any other conflict, and from a server that does not send it. Read
865
+ * this, never the message.
866
+ */
867
+ readonly currentFactId?: string;
868
+ constructor(message?: string, opts?: ConflictErrorOptions);
855
869
  }
856
870
  /**
857
871
  * 409 `stale_write`: update() with an expected_updated_at older than the
@@ -869,8 +883,22 @@ declare class StaleWriteError extends ConflictError {
869
883
  * `retryAfter` comes from APIError, which every error the server answers with
870
884
  * carries.
871
885
  */
886
+ interface QuotaErrorOptions extends APIErrorOptions {
887
+ limit?: number;
888
+ used?: number;
889
+ resetsAt?: string;
890
+ }
872
891
  declare class QuotaExceededError extends APIError {
873
- constructor(message?: string, opts?: APIErrorOptions);
892
+ /**
893
+ * On the Cloud's `quota_exceeded` (2026-10-07): the month's allowance (the
894
+ * plan plus the month's top-ups), what was used, and when it starts again
895
+ * (ISO date). Undefined from a server that does not send them. Read these,
896
+ * never the message, which says the same in words that change.
897
+ */
898
+ readonly limit?: number;
899
+ readonly used?: number;
900
+ readonly resetsAt?: string;
901
+ constructor(message?: string, opts?: QuotaErrorOptions);
874
902
  }
875
903
  /**
876
904
  * 429 `too_many_batches` (Cloud only): three `batch()` imports of the account
@@ -884,7 +912,7 @@ declare class QuotaExceededError extends APIError {
884
912
  * docs tell you to stop on that one, while this one clears in minutes.
885
913
  */
886
914
  declare class TooManyBatchesError extends QuotaExceededError {
887
- constructor(message?: string, opts?: APIErrorOptions);
915
+ constructor(message?: string, opts?: QuotaErrorOptions);
888
916
  }
889
917
 
890
918
  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 };
package/dist/index.d.ts CHANGED
@@ -474,7 +474,7 @@ interface ForgetReceipt {
474
474
 
475
475
  /** Must equal `version` in package.json (a test checks). It goes out in the
476
476
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
477
- declare const VERSION = "0.1.11";
477
+ declare const VERSION = "0.1.12";
478
478
  interface KorelyOptions {
479
479
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
480
480
  apiKey?: string;
@@ -838,12 +838,18 @@ declare class NamespaceForbiddenError extends APIError {
838
838
  declare class NotFoundError extends APIError {
839
839
  constructor(message?: string, opts?: APIErrorOptions);
840
840
  }
841
+ interface ConflictErrorOptions extends APIErrorOptions {
842
+ currentFactId?: string;
843
+ }
841
844
  /**
842
845
  * 409: the request conflicts with what the server holds. `code` names the
843
846
  * conflict: `stale_write` (update() with an expected_updated_at older than the
844
847
  * record, thrown as the subclass StaleWriteError), `account_has_login`
845
848
  * (`deleteAccount()` with the key of an account somebody signs in to, Cloud
846
- * only) or `conflict` (the Self-hosted's code for a 409 that names no other).
849
+ * only), `fact_not_current` (`correctFact()` of a fact that is history:
850
+ * superseded, forgotten or ended; `currentFactId` is the fact to correct
851
+ * instead) or `conflict` (the Self-hosted's code for a 409 that names no
852
+ * other).
847
853
  *
848
854
  * Until 2026-10-06 every 409 was a StaleWriteError, so a refusal that has
849
855
  * nothing to do with an update read as a lost write, and code written to
@@ -851,7 +857,15 @@ declare class NotFoundError extends APIError {
851
857
  * changes.
852
858
  */
853
859
  declare class ConflictError extends APIError {
854
- constructor(message?: string, opts?: APIErrorOptions);
860
+ /**
861
+ * On `fact_not_current` (2026-10-07): the id of the fact that holds now, the
862
+ * one to correct instead. Undefined when nothing superseded the fact asked
863
+ * (it was forgotten or ended: write the value of now with `addFactTriple()`),
864
+ * on any other conflict, and from a server that does not send it. Read
865
+ * this, never the message.
866
+ */
867
+ readonly currentFactId?: string;
868
+ constructor(message?: string, opts?: ConflictErrorOptions);
855
869
  }
856
870
  /**
857
871
  * 409 `stale_write`: update() with an expected_updated_at older than the
@@ -869,8 +883,22 @@ declare class StaleWriteError extends ConflictError {
869
883
  * `retryAfter` comes from APIError, which every error the server answers with
870
884
  * carries.
871
885
  */
886
+ interface QuotaErrorOptions extends APIErrorOptions {
887
+ limit?: number;
888
+ used?: number;
889
+ resetsAt?: string;
890
+ }
872
891
  declare class QuotaExceededError extends APIError {
873
- constructor(message?: string, opts?: APIErrorOptions);
892
+ /**
893
+ * On the Cloud's `quota_exceeded` (2026-10-07): the month's allowance (the
894
+ * plan plus the month's top-ups), what was used, and when it starts again
895
+ * (ISO date). Undefined from a server that does not send them. Read these,
896
+ * never the message, which says the same in words that change.
897
+ */
898
+ readonly limit?: number;
899
+ readonly used?: number;
900
+ readonly resetsAt?: string;
901
+ constructor(message?: string, opts?: QuotaErrorOptions);
874
902
  }
875
903
  /**
876
904
  * 429 `too_many_batches` (Cloud only): three `batch()` imports of the account
@@ -884,7 +912,7 @@ declare class QuotaExceededError extends APIError {
884
912
  * docs tell you to stop on that one, while this one clears in minutes.
885
913
  */
886
914
  declare class TooManyBatchesError extends QuotaExceededError {
887
- constructor(message?: string, opts?: APIErrorOptions);
915
+ constructor(message?: string, opts?: QuotaErrorOptions);
888
916
  }
889
917
 
890
918
  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 };
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ var ConflictError = class extends APIError {
47
47
  constructor(message = "", opts = {}) {
48
48
  super(message, opts);
49
49
  this.name = "ConflictError";
50
+ this.currentFactId = opts.currentFactId;
50
51
  Object.setPrototypeOf(this, new.target.prototype);
51
52
  }
52
53
  };
@@ -61,6 +62,9 @@ var QuotaExceededError = class extends APIError {
61
62
  constructor(message = "", opts = {}) {
62
63
  super(message, opts);
63
64
  this.name = "QuotaExceededError";
65
+ this.limit = opts.limit;
66
+ this.used = opts.used;
67
+ this.resetsAt = opts.resetsAt;
64
68
  Object.setPrototypeOf(this, new.target.prototype);
65
69
  }
66
70
  };
@@ -73,7 +77,7 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
73
77
  };
74
78
 
75
79
  // src/client.ts
76
- var VERSION = "0.1.11";
80
+ var VERSION = "0.1.12";
77
81
  var REGIONS = { eu: "https://api.korely.ai" };
78
82
  var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
79
83
  var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
@@ -190,6 +194,23 @@ function errorFields(status, body) {
190
194
  const message = text2(b.message) ?? text2(pair.message) ?? detailLine(b.detail) ?? code ?? `HTTP ${status}`;
191
195
  return { code, message };
192
196
  }
197
+ function quotaFields(body) {
198
+ const b = body && typeof body === "object" ? body : {};
199
+ const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
200
+ const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
201
+ const str = (v) => typeof v === "string" && v ? v : void 0;
202
+ return {
203
+ limit: num(b.limit ?? d.limit),
204
+ used: num(b.used ?? d.used),
205
+ resetsAt: str(b.resets_at ?? d.resets_at)
206
+ };
207
+ }
208
+ function conflictFields(body) {
209
+ const b = body && typeof body === "object" ? body : {};
210
+ const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
211
+ const v = b.current_fact_id ?? d.current_fact_id;
212
+ return { currentFactId: typeof v === "string" && v ? v : void 0 };
213
+ }
193
214
  function retryAfterSeconds(raw) {
194
215
  if (raw == null) return void 0;
195
216
  const n = Math.ceil(Number(raw));
@@ -311,11 +332,12 @@ function raiseFor(status, body, retryAfter) {
311
332
  if (status === 404) throw new NotFoundError(msg, opts);
312
333
  if (status === 409) {
313
334
  if (code === "stale_write") throw new StaleWriteError(msg, opts);
314
- throw new ConflictError(msg, opts);
335
+ throw new ConflictError(msg, { ...opts, ...conflictFields(body) });
315
336
  }
316
337
  if (status === 429) {
317
- if (code === "too_many_batches") throw new TooManyBatchesError(msg, opts);
318
- throw new QuotaExceededError(msg, opts);
338
+ const quota = { ...opts, ...quotaFields(body) };
339
+ if (code === "too_many_batches") throw new TooManyBatchesError(msg, quota);
340
+ throw new QuotaExceededError(msg, quota);
319
341
  }
320
342
  throw new APIError(msg, opts);
321
343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",