korely-memory 0.2.2 → 0.3.0

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
@@ -204,6 +204,9 @@ The data is stored in the EU (Helsinki). Which model reads a memory, and
204
204
  where, is the project's region, chosen per project in the dashboard: Europe
205
205
  (gpt-oss-120b on Scaleway, in Paris) or Global (Gemini, by Google), the
206
206
  default. A memory written to a Global project is read by Google's model.
207
+ `region` names the API, and `"eu"` is the only one: any other value, `"global"`
208
+ among them, throws a `KorelyError`, even with `baseUrl` set (since 0.3.0; up to 0.2.2
209
+ it fell back to `"eu"` in silence).
207
210
 
208
211
  In Node, `new Korely()` with no key and no `KORELY_API_KEY` reads what
209
212
  `korely init` saved (the key and the server, in `~/.korely/config.json`, or
@@ -78,8 +78,17 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
78
78
  };
79
79
 
80
80
  // src/client.ts
81
- var VERSION = "0.2.2";
81
+ var VERSION = "0.3.0";
82
82
  var REGIONS = { eu: "https://api.korely.ai" };
83
+ function regionUrl(region = "eu") {
84
+ const url = typeof region === "string" && Object.prototype.hasOwnProperty.call(REGIONS, region) ? REGIONS[region] : void 0;
85
+ if (url === void 0) {
86
+ throw new KorelyError(
87
+ `region is "eu", the only API today, not ${JSON.stringify(region)}. Where a model reads the memories is the project's processing region: processingRegion in initAgent, or the project's region in the dashboard.`
88
+ );
89
+ }
90
+ return url;
91
+ }
83
92
  var CLIENT_KEYS = keysOf()(
84
93
  "apiKey",
85
94
  "region",
@@ -502,7 +511,8 @@ var Korely = class {
502
511
  this.apiKey = key;
503
512
  const envClient = typeof process !== "undefined" ? process.env?.KORELY_CLIENT : void 0;
504
513
  this.client = (opts.client ?? envClient ?? "").trim() || void 0;
505
- this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
514
+ const hosted = regionUrl(opts.region ?? "eu");
515
+ this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? hosted).replace(/\/+$/, "");
506
516
  refuseAMismatchedPair(this.apiKey, this.baseUrl);
507
517
  this.timeoutMs = opts.timeoutMs ?? 3e4;
508
518
  this.retryWrites = opts.retryWrites ?? true;
@@ -547,7 +557,8 @@ var Korely = class {
547
557
  );
548
558
  }
549
559
  const envBase = typeof process !== "undefined" ? process.env?.KORELY_BASE_URL : void 0;
550
- const baseUrl = (opts.baseUrl ?? envBase ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
560
+ const hosted = regionUrl(opts.region ?? "eu");
561
+ const baseUrl = (opts.baseUrl ?? envBase ?? hosted).replace(/\/+$/, "");
551
562
  const fetchImpl = opts.fetch ?? globalThis.fetch;
552
563
  if (!fetchImpl) {
553
564
  throw new KorelyError(
package/dist/index.cjs CHANGED
@@ -127,8 +127,17 @@ function unknownOption(method, opts, known) {
127
127
  var DEFAULT_TOKEN_BUDGET = 1500;
128
128
 
129
129
  // src/client.ts
130
- var VERSION = "0.2.2";
130
+ var VERSION = "0.3.0";
131
131
  var REGIONS = { eu: "https://api.korely.ai" };
132
+ function regionUrl(region = "eu") {
133
+ const url = typeof region === "string" && Object.prototype.hasOwnProperty.call(REGIONS, region) ? REGIONS[region] : void 0;
134
+ if (url === void 0) {
135
+ throw new KorelyError(
136
+ `region is "eu", the only API today, not ${JSON.stringify(region)}. Where a model reads the memories is the project's processing region: processingRegion in initAgent, or the project's region in the dashboard.`
137
+ );
138
+ }
139
+ return url;
140
+ }
132
141
  var CLIENT_KEYS = keysOf()(
133
142
  "apiKey",
134
143
  "region",
@@ -548,7 +557,8 @@ var Korely = class {
548
557
  this.apiKey = key;
549
558
  const envClient = typeof process !== "undefined" ? process.env?.KORELY_CLIENT : void 0;
550
559
  this.client = (opts.client ?? envClient ?? "").trim() || void 0;
551
- this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
560
+ const hosted = regionUrl(opts.region ?? "eu");
561
+ this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? hosted).replace(/\/+$/, "");
552
562
  refuseAMismatchedPair(this.apiKey, this.baseUrl);
553
563
  this.timeoutMs = opts.timeoutMs ?? 3e4;
554
564
  this.retryWrites = opts.retryWrites ?? true;
@@ -593,7 +603,8 @@ var Korely = class {
593
603
  );
594
604
  }
595
605
  const envBase = typeof process !== "undefined" ? process.env?.KORELY_BASE_URL : void 0;
596
- const baseUrl = (opts.baseUrl ?? envBase ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
606
+ const hosted = regionUrl(opts.region ?? "eu");
607
+ const baseUrl = (opts.baseUrl ?? envBase ?? hosted).replace(/\/+$/, "");
597
608
  const fetchImpl = opts.fetch ?? globalThis.fetch;
598
609
  if (!fetchImpl) {
599
610
  throw new KorelyError(
package/dist/index.d.cts CHANGED
@@ -629,7 +629,7 @@ interface ForgetReceipt {
629
629
 
630
630
  /** Must equal `version` in package.json (a test checks). It goes out in the
631
631
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
632
- declare const VERSION = "0.2.2";
632
+ declare const VERSION = "0.3.0";
633
633
  interface KorelyOptions {
634
634
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
635
635
  apiKey?: string;
@@ -637,7 +637,8 @@ interface KorelyOptions {
637
637
  * The API to call: "eu" (api.korely.ai), the only one today. The data is
638
638
  * stored in the EU (Helsinki). The model that reads a memory is the
639
639
  * project's region, set per project in the dashboard: Europe (gpt-oss-120b
640
- * on Scaleway, in Paris) or Global (Gemini, by Google), the default.
640
+ * on Scaleway, in Paris) or Global (Gemini, by Google), the default. Any
641
+ * other value throws a KorelyError.
641
642
  */
642
643
  region?: "eu";
643
644
  /** Override the base URL (a self-hosted install, or testing). */
package/dist/index.d.ts CHANGED
@@ -629,7 +629,7 @@ interface ForgetReceipt {
629
629
 
630
630
  /** Must equal `version` in package.json (a test checks). It goes out in the
631
631
  * X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
632
- declare const VERSION = "0.2.2";
632
+ declare const VERSION = "0.3.0";
633
633
  interface KorelyOptions {
634
634
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
635
635
  apiKey?: string;
@@ -637,7 +637,8 @@ interface KorelyOptions {
637
637
  * The API to call: "eu" (api.korely.ai), the only one today. The data is
638
638
  * stored in the EU (Helsinki). The model that reads a memory is the
639
639
  * project's region, set per project in the dashboard: Europe (gpt-oss-120b
640
- * on Scaleway, in Paris) or Global (Gemini, by Google), the default.
640
+ * on Scaleway, in Paris) or Global (Gemini, by Google), the default. Any
641
+ * other value throws a KorelyError.
641
642
  */
642
643
  region?: "eu";
643
644
  /** Override the base URL (a self-hosted install, or testing). */
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  StaleWriteError,
11
11
  TooManyBatchesError,
12
12
  VERSION
13
- } from "./chunk-UW36NLA6.js";
13
+ } from "./chunk-E6ER37KI.js";
14
14
  import "./chunk-EQTA322A.js";
15
15
  export {
16
16
  APIError,
@@ -130,8 +130,17 @@ function unknownOption(method, opts, known) {
130
130
  var DEFAULT_TOKEN_BUDGET = 1500;
131
131
 
132
132
  // src/client.ts
133
- var VERSION = "0.2.2";
133
+ var VERSION = "0.3.0";
134
134
  var REGIONS = { eu: "https://api.korely.ai" };
135
+ function regionUrl(region = "eu") {
136
+ const url = typeof region === "string" && Object.prototype.hasOwnProperty.call(REGIONS, region) ? REGIONS[region] : void 0;
137
+ if (url === void 0) {
138
+ throw new KorelyError(
139
+ `region is "eu", the only API today, not ${JSON.stringify(region)}. Where a model reads the memories is the project's processing region: processingRegion in initAgent, or the project's region in the dashboard.`
140
+ );
141
+ }
142
+ return url;
143
+ }
135
144
  var CLIENT_KEYS = keysOf()(
136
145
  "apiKey",
137
146
  "region",
@@ -554,7 +563,8 @@ var Korely = class {
554
563
  this.apiKey = key;
555
564
  const envClient = typeof process !== "undefined" ? process.env?.KORELY_CLIENT : void 0;
556
565
  this.client = (opts.client ?? envClient ?? "").trim() || void 0;
557
- this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
566
+ const hosted = regionUrl(opts.region ?? "eu");
567
+ this.baseUrl = (opts.baseUrl ?? envBase ?? text(saved.base_url) ?? hosted).replace(/\/+$/, "");
558
568
  refuseAMismatchedPair(this.apiKey, this.baseUrl);
559
569
  this.timeoutMs = opts.timeoutMs ?? 3e4;
560
570
  this.retryWrites = opts.retryWrites ?? true;
@@ -599,7 +609,8 @@ var Korely = class {
599
609
  );
600
610
  }
601
611
  const envBase = typeof process !== "undefined" ? process.env?.KORELY_BASE_URL : void 0;
602
- const baseUrl = (opts.baseUrl ?? envBase ?? REGIONS[opts.region ?? "eu"] ?? REGIONS.eu).replace(/\/+$/, "");
612
+ const hosted = regionUrl(opts.region ?? "eu");
613
+ const baseUrl = (opts.baseUrl ?? envBase ?? hosted).replace(/\/+$/, "");
603
614
  const fetchImpl = opts.fetch ?? globalThis.fetch;
604
615
  if (!fetchImpl) {
605
616
  throw new KorelyError(
@@ -11,7 +11,7 @@ import {
11
11
  TooManyBatchesError,
12
12
  VERSION,
13
13
  useNodeFiles
14
- } from "./chunk-UW36NLA6.js";
14
+ } from "./chunk-E6ER37KI.js";
15
15
  import "./chunk-EQTA322A.js";
16
16
 
17
17
  // src/node.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents: memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",