shabti 2.9.0 → 2.10.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shabti",
3
- "version": "2.9.0",
3
+ "version": "2.10.1",
4
4
  "description": "Agent Memory OS — semantic memory for AI agents",
5
5
  "type": "module",
6
6
  "main": "native.cjs",
package/src/a2a/server.js CHANGED
@@ -3,6 +3,7 @@ import { randomUUID } from "crypto";
3
3
  import { buildAgentCard } from "./agentCard.js";
4
4
  import { createEngine } from "../core/engine.js";
5
5
  import { logger } from "../utils/logger.js";
6
+ import { normalizeText } from "../utils/normalize.js";
6
7
 
7
8
  // ============================================================
8
9
  // Task Store (in-memory)
@@ -62,7 +63,7 @@ async function handleMemoryStore(engine, parts) {
62
63
  throw Object.assign(new Error("Missing content in message parts"), { code: -32602 });
63
64
  }
64
65
 
65
- const result = await engine.store(content, opts);
66
+ const result = await engine.store(normalizeText(content), opts);
66
67
  return {
67
68
  artifactId: randomUUID(),
68
69
  name: "store_result",
@@ -87,7 +88,7 @@ async function handleMemorySearch(engine, parts) {
87
88
  throw Object.assign(new Error("Missing query in message parts"), { code: -32602 });
88
89
  }
89
90
 
90
- const results = await engine.executeQuery({ text: query, limit });
91
+ const results = await engine.executeQuery({ text: normalizeText(query), limit });
91
92
  const formatted = results.map((r) => ({
92
93
  id: r.id,
93
94
  content: r.content,
@@ -3,6 +3,7 @@ import Table from "cli-table3";
3
3
  import { createEngine } from "../core/engine.js";
4
4
  import { error, heading } from "../utils/style.js";
5
5
  import { parsePositiveInt, parseScore } from "../utils/validate.js";
6
+ import { normalizeText } from "../utils/normalize.js";
6
7
 
7
8
  export function registerSearch(program) {
8
9
  program
@@ -23,7 +24,7 @@ export function registerSearch(program) {
23
24
  try {
24
25
  const engine = createEngine();
25
26
 
26
- const query = { text: queryText };
27
+ const query = { text: normalizeText(queryText) };
27
28
  query.limit = parsePositiveInt(opts.limit, "--limit");
28
29
  if (opts.namespace) query.namespace = opts.namespace;
29
30
  if (opts.timeStart) query.timeStart = parsePositiveInt(opts.timeStart, "--time-start");
@@ -1,6 +1,7 @@
1
1
  import { createEngine, loadConfig, saveConfig } from "../core/engine.js";
2
2
  import { success, error, info, warn } from "../utils/style.js";
3
3
  import { parsePositiveInt } from "../utils/validate.js";
4
+ import { normalizeText } from "../utils/normalize.js";
4
5
 
5
6
  export function registerStore(program) {
6
7
  program
@@ -31,7 +32,7 @@ export function registerStore(program) {
31
32
  }
32
33
  }
33
34
 
34
- const result = await engine.store(content, options);
35
+ const result = await engine.store(normalizeText(content), options);
35
36
 
36
37
  if (result.status === "stored") {
37
38
  success(`Stored: ${result.id}`);
package/src/mcp/server.js CHANGED
@@ -3,6 +3,7 @@ import { createInterface } from "readline";
3
3
  import { createEngine, loadConfig } from "../core/engine.js";
4
4
  import { createEngineWithRetry } from "../core/retry.js";
5
5
  import { logger } from "../utils/logger.js";
6
+ import { normalizeText } from "../utils/normalize.js";
6
7
 
7
8
  const SERVER_INFO = {
8
9
  name: "shabti-memory",
@@ -228,7 +229,7 @@ async function handleToolsCall(id, params) {
228
229
  if (args.namespace) opts.namespace = args.namespace;
229
230
  if (args.tags) opts.tags = args.tags;
230
231
  if (args.ttl) opts.ttlSeconds = args.ttl;
231
- const result = await eng.store(content, opts);
232
+ const result = await eng.store(normalizeText(content), opts);
232
233
  return respond(id, {
233
234
  content: [
234
235
  {
@@ -256,7 +257,7 @@ async function handleToolsCall(id, params) {
256
257
  }
257
258
  try {
258
259
  const limit = args.limit || 10;
259
- const queryObj = { text: query, limit };
260
+ const queryObj = { text: normalizeText(query), limit };
260
261
  if (args.namespace) queryObj.namespace = args.namespace;
261
262
  const results = await eng.executeQuery(queryObj);
262
263
  const formatted = results.map((r) => ({
@@ -1,5 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import { success, info, warn, error } from "../utils/style.js";
3
+ import { normalizeText } from "../utils/normalize.js";
3
4
 
4
5
  const COMMANDS = {
5
6
  "/help": "Show this help message",
@@ -98,7 +99,7 @@ async function handleRemember(text, engine) {
98
99
  return true;
99
100
  }
100
101
  try {
101
- const result = await engine.store(text, {});
102
+ const result = await engine.store(normalizeText(text), {});
102
103
  if (result.status === "stored") {
103
104
  success(`Remembered: ${result.id}`);
104
105
  } else {
@@ -125,7 +126,7 @@ async function handleRecall(query, engine) {
125
126
  return true;
126
127
  }
127
128
  try {
128
- const results = await engine.executeQuery({ text: query, limit: 5 });
129
+ const results = await engine.executeQuery({ text: normalizeText(query), limit: 5 });
129
130
  console.log();
130
131
  if (results.length === 0) {
131
132
  console.log(chalk.dim(" No memories found."));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Normalize text for consistent storage and search.
3
+ * Applies NFKC Unicode normalization, trims, and collapses whitespace.
4
+ *
5
+ * NFKC normalizes:
6
+ * - Full-width ASCII → half-width (A → A, 0 → 0)
7
+ * - Half-width katakana → full-width (カ → カ)
8
+ * - Compatibility characters (① → 1, ㍻ → 平成)
9
+ */
10
+ export function normalizeText(text) {
11
+ if (!text) return "";
12
+ return text.normalize("NFKC").replace(/\s+/g, " ").trim();
13
+ }