@todoforai/tfa-memory 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/cli.js +24 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -462,7 +462,7 @@ function checkForUpdates(pkg) {
462
462
  // package.json
463
463
  var package_default = {
464
464
  name: "@todoforai/tfa-memory",
465
- version: "0.1.0",
465
+ version: "0.2.0",
466
466
  description: "Zero-config TODOforAI memory CLI — add/search/ls/get/rm text memory rows addressed as source/ref, with full-text and semantic search. Reuses bridge credentials.",
467
467
  type: "module",
468
468
  bin: {
@@ -520,7 +520,8 @@ Options:
520
520
  -n, --limit <n> Max rows (default 10, max 50)
521
521
  -j, --json Machine-readable output
522
522
  --api-token <token> Override API token
523
- --api-url <url> Override backend URL
523
+ --api-url <url> Override backend URL (used to derive memory URL)
524
+ --memory-url <url> Override memory-manager URL (default: derived — api.<d> → memory.<d>; localhost/IP → :8900)
524
525
  -h, --help Show this help
525
526
  -v, --version Show version
526
527
 
@@ -547,13 +548,27 @@ function splitAddr(addr) {
547
548
  die(`invalid address "${addr}" — expected source/ref`);
548
549
  return [addr.slice(0, i), addr.slice(i + 1)];
549
550
  }
551
+ function deriveMemoryUrl(apiUrl) {
552
+ const u = new URL(apiUrl);
553
+ if (u.hostname === "localhost" || u.hostname === "127.0.0.1" || /^\d{1,3}(\.\d{1,3}){3}$/.test(u.hostname)) {
554
+ u.port = "8900";
555
+ } else if (u.hostname.startsWith("api.")) {
556
+ u.hostname = "memory." + u.hostname.slice(4);
557
+ } else {
558
+ u.hostname = "memory." + u.hostname;
559
+ }
560
+ return u.origin;
561
+ }
562
+ function resolveMemoryUrl(flag, apiUrl) {
563
+ return flag || process.env.MEMORY_URL || deriveMemoryUrl(apiUrl);
564
+ }
550
565
  async function api(ctx, method, path2, body) {
551
566
  const init = {
552
567
  method,
553
568
  headers: body !== undefined ? { "content-type": "application/json" } : {},
554
569
  body: body !== undefined ? JSON.stringify(body) : undefined
555
570
  };
556
- const { res, token } = await fetchWithRenew(`${ctx.apiUrl}/dst/v1${path2}`, init, { apiUrl: ctx.apiUrl, token: ctx.token });
571
+ const { res, token } = await fetchWithRenew(`${ctx.memoryUrl}/v1${path2}`, init, { apiUrl: ctx.apiUrl, token: ctx.token });
557
572
  ctx.token = token;
558
573
  if (!res.ok) {
559
574
  const text = await res.text();
@@ -594,6 +609,7 @@ async function main() {
594
609
  json: { type: "boolean", short: "j", default: false },
595
610
  "api-token": { type: "string" },
596
611
  "api-url": { type: "string" },
612
+ "memory-url": { type: "string" },
597
613
  help: { type: "boolean", short: "h", default: false },
598
614
  version: { type: "boolean", short: "v", default: false }
599
615
  },
@@ -625,7 +641,7 @@ async function main() {
625
641
  apiUrl: values["api-url"],
626
642
  apiToken: values["api-token"]
627
643
  });
628
- ctx = { apiUrl, token: apiToken };
644
+ ctx = { apiUrl, memoryUrl: resolveMemoryUrl(values["memory-url"], apiUrl), token: apiToken };
629
645
  } catch (e) {
630
646
  die(e?.message ?? String(e));
631
647
  }
@@ -713,3 +729,7 @@ if (isEntrypoint) {
713
729
  checkForUpdates({ name: package_default.name, version: package_default.version });
714
730
  main();
715
731
  }
732
+ export {
733
+ resolveMemoryUrl,
734
+ deriveMemoryUrl
735
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/tfa-memory",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Zero-config TODOforAI memory CLI \u2014 add/search/ls/get/rm text memory rows addressed as source/ref, with full-text and semantic search. Reuses bridge credentials.",
5
5
  "type": "module",
6
6
  "bin": {