@memtensor/memos-local-openclaw-plugin 1.0.2-beta.5 → 1.0.2

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 (86) hide show
  1. package/dist/capture/index.js +52 -8
  2. package/dist/capture/index.js.map +1 -1
  3. package/dist/ingest/chunker.d.ts +3 -4
  4. package/dist/ingest/chunker.d.ts.map +1 -1
  5. package/dist/ingest/chunker.js +19 -24
  6. package/dist/ingest/chunker.js.map +1 -1
  7. package/dist/ingest/providers/anthropic.d.ts +3 -1
  8. package/dist/ingest/providers/anthropic.d.ts.map +1 -1
  9. package/dist/ingest/providers/anthropic.js +79 -39
  10. package/dist/ingest/providers/anthropic.js.map +1 -1
  11. package/dist/ingest/providers/bedrock.d.ts +3 -1
  12. package/dist/ingest/providers/bedrock.d.ts.map +1 -1
  13. package/dist/ingest/providers/bedrock.js +79 -39
  14. package/dist/ingest/providers/bedrock.js.map +1 -1
  15. package/dist/ingest/providers/gemini.d.ts +3 -1
  16. package/dist/ingest/providers/gemini.d.ts.map +1 -1
  17. package/dist/ingest/providers/gemini.js +77 -39
  18. package/dist/ingest/providers/gemini.js.map +1 -1
  19. package/dist/ingest/providers/index.d.ts +3 -1
  20. package/dist/ingest/providers/index.d.ts.map +1 -1
  21. package/dist/ingest/providers/index.js +70 -30
  22. package/dist/ingest/providers/index.js.map +1 -1
  23. package/dist/ingest/providers/openai.d.ts +3 -1
  24. package/dist/ingest/providers/openai.d.ts.map +1 -1
  25. package/dist/ingest/providers/openai.js +80 -39
  26. package/dist/ingest/providers/openai.js.map +1 -1
  27. package/dist/ingest/task-processor.d.ts +1 -0
  28. package/dist/ingest/task-processor.d.ts.map +1 -1
  29. package/dist/ingest/task-processor.js +33 -9
  30. package/dist/ingest/task-processor.js.map +1 -1
  31. package/dist/ingest/worker.d.ts.map +1 -1
  32. package/dist/ingest/worker.js +29 -13
  33. package/dist/ingest/worker.js.map +1 -1
  34. package/dist/recall/engine.d.ts.map +1 -1
  35. package/dist/recall/engine.js +19 -14
  36. package/dist/recall/engine.js.map +1 -1
  37. package/dist/skill/bundled-memory-guide.d.ts +1 -5
  38. package/dist/skill/bundled-memory-guide.d.ts.map +1 -1
  39. package/dist/skill/bundled-memory-guide.js +38 -97
  40. package/dist/skill/bundled-memory-guide.js.map +1 -1
  41. package/dist/skill/evaluator.js +1 -1
  42. package/dist/storage/sqlite.d.ts +1 -2
  43. package/dist/storage/sqlite.d.ts.map +1 -1
  44. package/dist/storage/sqlite.js +90 -17
  45. package/dist/storage/sqlite.js.map +1 -1
  46. package/dist/tools/memory-get.d.ts.map +1 -1
  47. package/dist/tools/memory-get.js +1 -3
  48. package/dist/tools/memory-get.js.map +1 -1
  49. package/dist/types.d.ts +2 -2
  50. package/dist/types.d.ts.map +1 -1
  51. package/dist/types.js +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/dist/update-check.d.ts +21 -0
  54. package/dist/update-check.d.ts.map +1 -0
  55. package/dist/update-check.js +111 -0
  56. package/dist/update-check.js.map +1 -0
  57. package/dist/viewer/html.d.ts.map +1 -1
  58. package/dist/viewer/html.js +444 -182
  59. package/dist/viewer/html.js.map +1 -1
  60. package/dist/viewer/server.d.ts +1 -1
  61. package/dist/viewer/server.d.ts.map +1 -1
  62. package/dist/viewer/server.js +142 -78
  63. package/dist/viewer/server.js.map +1 -1
  64. package/index.ts +206 -198
  65. package/openclaw.plugin.json +3 -0
  66. package/package.json +5 -1
  67. package/scripts/postinstall.cjs +69 -2
  68. package/skill/memos-memory-guide/SKILL.md +73 -36
  69. package/src/capture/index.ts +52 -8
  70. package/src/ingest/chunker.ts +22 -30
  71. package/src/ingest/providers/anthropic.ts +89 -41
  72. package/src/ingest/providers/bedrock.ts +90 -41
  73. package/src/ingest/providers/gemini.ts +89 -41
  74. package/src/ingest/providers/index.ts +81 -35
  75. package/src/ingest/providers/openai.ts +90 -41
  76. package/src/ingest/task-processor.ts +29 -8
  77. package/src/ingest/worker.ts +31 -13
  78. package/src/recall/engine.ts +20 -13
  79. package/src/skill/bundled-memory-guide.ts +5 -96
  80. package/src/skill/evaluator.ts +1 -1
  81. package/src/storage/sqlite.ts +93 -21
  82. package/src/tools/memory-get.ts +1 -4
  83. package/src/types.ts +2 -9
  84. package/src/update-check.ts +96 -0
  85. package/src/viewer/html.ts +444 -182
  86. package/src/viewer/server.ts +101 -66
@@ -1,100 +1,9 @@
1
1
  /**
2
2
  * Bundled MemOS memory-guide skill content.
3
- * Written to workspace/skills/memos-memory-guide on plugin register so OpenClaw loads it.
3
+ * Reads from skill/memos-memory-guide/SKILL.md at runtime (single source of truth).
4
4
  */
5
- export const MEMORY_GUIDE_SKILL_MD = `---
6
- name: memos-memory-guide
7
- description: Use the MemOS Local memory system to search and use the user's past conversations. Use this skill whenever the user refers to past chats, their own preferences or history, or when you need to answer from prior context. When auto-recall returns nothing (long or unclear user query), generate your own short search query and call memory_search. Use task_summary when you need full task context, skill_get for experience guides, and memory_timeline to expand around a memory hit.
8
- ---
5
+ import * as fs from "fs";
6
+ import * as path from "path";
9
7
 
10
- # MemOS Local Memory Agent Guide
11
-
12
- This skill describes how to use the MemOS memory tools so you can reliably search and use the user's long-term conversation history.
13
-
14
- ## How memory is provided each turn
15
-
16
- - **Automatic recall (hook):** At the start of each turn, the system runs a memory search using the user's current message and injects relevant past memories into your context. You do not need to call any tool for that.
17
- - **When that is not enough:** If the user's message is very long, vague, or the automatic search returns **no memories**, you should **generate your own short, focused query** and call \`memory_search\` yourself. For example:
18
- - User sent a long paragraph → extract 1–2 key topics or a short question and search with that.
19
- - Auto-recall said "no memories" or you see no memory block → call \`memory_search\` with a query you derive (e.g. the user's name, a topic they often mention, or a rephrased question).
20
- - **When you need more detail:** Search results only give excerpts and IDs. Use the tools below to fetch full task context, skill content, or surrounding messages.
21
-
22
- ## Tools — what they do and when to call
23
-
24
- ### memory_search
25
-
26
- - **What it does:** Searches the user's stored conversation memory by a natural-language query. Returns a list of relevant excerpts with \`chunkId\` and optionally \`task_id\`.
27
- - **When to call:**
28
- - The automatic recall did not run or returned nothing (e.g. no \`<memory_context>\` block, or a note that no memories were found).
29
- - The user's query is long or unclear — **generate a short query yourself** (keywords, rephrased question, or a clear sub-question) and call \`memory_search(query="...")\`.
30
- - You need to search with a different angle (e.g. filter by \`role='user'\` to find what the user said, or use a more specific query).
31
- - **Parameters:** \`query\` (required), optional \`minScore\`, \`role\` (e.g. \`"user"\`).
32
- - **Output:** List of items with role, excerpt, \`chunkId\`, and sometimes \`task_id\`. Use those IDs with the tools below when you need more context.
33
-
34
- ### task_summary
35
-
36
- - **What it does:** Returns the full task summary for a given \`task_id\`: title, status, and the complete narrative summary of that conversation task (steps, decisions, URLs, commands, etc.).
37
- - **When to call:** A \`memory_search\` hit included a \`task_id\` and you need the full story of that task (e.g. what was done, what the user decided, what failed or succeeded).
38
- - **Parameters:** \`taskId\` (from a search hit).
39
- - **Effect:** You get one coherent summary of the whole task instead of isolated excerpts.
40
-
41
- ### skill_get
42
-
43
- - **What it does:** Returns the content of a learned skill (experience guide) by \`skillId\` or by \`taskId\`. If you pass \`taskId\`, the system finds the skill linked to that task.
44
- - **When to call:** A search hit has a \`task_id\` and the task is the kind that has a "how to do this again" guide (e.g. a workflow the user has run before). Use this to follow the same approach or reuse steps.
45
- - **Parameters:** \`skillId\` (direct) or \`taskId\` (lookup).
46
- - **Effect:** You receive the full SKILL.md-style guide. You can then call \`skill_install(skillId)\` if the user or you want that skill loaded for future turns.
47
-
48
- ### skill_install
49
-
50
- - **What it does:** Installs a skill (by \`skillId\`) into the workspace so it is loaded in future sessions.
51
- - **When to call:** After \`skill_get\` when the skill is useful for ongoing use (e.g. the user's recurring workflow). Optional; only when you want the skill to be permanently available.
52
- - **Parameters:** \`skillId\`.
53
-
54
- ### memory_timeline
55
-
56
- - **What it does:** Expands context around a single memory chunk: returns the surrounding conversation messages (±N turns) so you see what was said before and after that excerpt.
57
- - **When to call:** A \`memory_search\` hit is relevant but you need the surrounding dialogue (e.g. who said what next, or the exact follow-up question).
58
- - **Parameters:** \`chunkId\` (from a search hit), optional \`window\` (default 2).
59
- - **Effect:** You get a short, linear slice of the conversation around that chunk.
60
-
61
- ### memory_viewer
62
-
63
- - **What it does:** Returns the URL of the MemOS Memory Viewer (web UI) where the user can browse, search, and manage their memories.
64
- - **When to call:** The user asks how to view their memories, open the memory dashboard, or manage stored data.
65
- - **Parameters:** None.
66
- - **Effect:** You can tell the user to open that URL in a browser.
67
-
68
- ## Quick decision flow
69
-
70
- 1. **No memories in context or auto-recall reported nothing**
71
- → Call \`memory_search\` with a **self-generated short query** (e.g. key topic or rephrased question).
72
-
73
- 2. **Search returned hits with \`task_id\` and you need full context**
74
- → Call \`task_summary(taskId)\`.
75
-
76
- 3. **Task has an experience guide you want to follow**
77
- → Call \`skill_get(taskId=...)\` (or \`skill_get(skillId=...)\` if you have the id). Optionally \`skill_install(skillId)\` for future use.
78
-
79
- 4. **You need the exact surrounding conversation of a hit**
80
- → Call \`memory_timeline(chunkId=...)\`.
81
-
82
- 5. **User asks where to see or manage their memories**
83
- → Call \`memory_viewer()\` and share the URL.
84
-
85
- ## Writing good search queries
86
-
87
- - Prefer **short, focused** queries (a few words or one clear question).
88
- - Use **concrete terms**: names, topics, tools, or decisions (e.g. "preferred editor", "deploy script", "API key setup").
89
- - If the user's message is long, **derive one or two sub-queries** rather than pasting the whole message.
90
- - Use \`role='user'\` when you specifically want to find what the user said (e.g. preferences, past questions).
91
-
92
- ## Memory ownership and agent isolation
93
-
94
- Each memory is tagged with an \`owner\` (e.g. \`agent:main\`, \`agent:sales-bot\`). This is handled **automatically** — you do not need to pass any owner parameter.
95
-
96
- - **Your memories:** All tools (\`memory_search\`, \`memory_get\`, \`memory_timeline\`) automatically scope queries to your agent's own memories.
97
- - **Public memories:** Memories marked as \`public\` are visible to all agents. Use \`memory_write_public\` to write shared knowledge.
98
- - **Cross-agent isolation:** You cannot see memories owned by other agents (unless they are public).
99
- - **How it works:** The system identifies your agent ID from the OpenClaw runtime context and applies owner filtering automatically on every search, recall, and retrieval.
100
- `;
8
+ const skillPath = path.join(__dirname, "..", "..", "skill", "memos-memory-guide", "SKILL.md");
9
+ export const MEMORY_GUIDE_SKILL_MD: string = fs.readFileSync(skillPath, "utf-8");
@@ -52,7 +52,7 @@ Task title: {TITLE}
52
52
  Task summary:
53
53
  {SUMMARY}
54
54
 
55
- LANGUAGE RULE: The "reason" field MUST use the SAME language as the task title/summary. Chinese input Chinese reason. English input English reason. "suggestedName" stays in English kebab-case.
55
+ LANGUAGE RULE (MUST FOLLOW): Detect the language of the task title/summary. If it is Chinese, the "reason" field MUST be in Chinese. If English, reason in English. Only "suggestedName" stays in English kebab-case. 如果任务标题/摘要是中文,reason 必须用中文。
56
56
 
57
57
  Reply in JSON only, no extra text:
58
58
  {
@@ -46,7 +46,7 @@ export class SqliteStore {
46
46
  content,
47
47
  content='chunks',
48
48
  content_rowid='rowid',
49
- tokenize='porter unicode61'
49
+ tokenize='trigram'
50
50
  );
51
51
 
52
52
  CREATE TRIGGER IF NOT EXISTS chunks_ai AFTER INSERT ON chunks BEGIN
@@ -109,6 +109,7 @@ export class SqliteStore {
109
109
  this.migrateOwnerFields();
110
110
  this.migrateSkillVisibility();
111
111
  this.migrateSkillEmbeddingsAndFts();
112
+ this.migrateFtsToTrigram();
112
113
  this.log.debug("Database schema initialized");
113
114
  }
114
115
 
@@ -159,7 +160,7 @@ export class SqliteStore {
159
160
  description,
160
161
  content='skills',
161
162
  content_rowid='rowid',
162
- tokenize='porter unicode61'
163
+ tokenize='trigram'
163
164
  );
164
165
  `);
165
166
 
@@ -195,6 +196,81 @@ export class SqliteStore {
195
196
  } catch { /* best-effort */ }
196
197
  }
197
198
 
199
+ private migrateFtsToTrigram(): void {
200
+ // Check if chunks_fts still uses the old tokenizer (porter unicode61)
201
+ try {
202
+ const row = this.db.prepare(
203
+ "SELECT sql FROM sqlite_master WHERE name='chunks_fts'"
204
+ ).get() as { sql: string } | undefined;
205
+ if (row && row.sql && !row.sql.includes("trigram")) {
206
+ this.log.info("Migrating chunks_fts from porter/unicode61 to trigram tokenizer...");
207
+ this.db.exec("DROP TRIGGER IF EXISTS chunks_ai");
208
+ this.db.exec("DROP TRIGGER IF EXISTS chunks_ad");
209
+ this.db.exec("DROP TRIGGER IF EXISTS chunks_au");
210
+ this.db.exec("DROP TABLE IF EXISTS chunks_fts");
211
+ this.db.exec(`
212
+ CREATE VIRTUAL TABLE chunks_fts USING fts5(
213
+ summary, content, content='chunks', content_rowid='rowid',
214
+ tokenize='trigram'
215
+ )
216
+ `);
217
+ this.db.exec(`
218
+ CREATE TRIGGER chunks_ai AFTER INSERT ON chunks BEGIN
219
+ INSERT INTO chunks_fts(rowid, summary, content) VALUES (new.rowid, new.summary, new.content);
220
+ END;
221
+ CREATE TRIGGER chunks_ad AFTER DELETE ON chunks BEGIN
222
+ INSERT INTO chunks_fts(chunks_fts, rowid, summary, content) VALUES ('delete', old.rowid, old.summary, old.content);
223
+ END;
224
+ CREATE TRIGGER chunks_au AFTER UPDATE ON chunks BEGIN
225
+ INSERT INTO chunks_fts(chunks_fts, rowid, summary, content) VALUES ('delete', old.rowid, old.summary, old.content);
226
+ INSERT INTO chunks_fts(rowid, summary, content) VALUES (new.rowid, new.summary, new.content);
227
+ END
228
+ `);
229
+ this.db.exec("INSERT INTO chunks_fts(rowid, summary, content) SELECT rowid, summary, content FROM chunks");
230
+ const count = (this.db.prepare("SELECT COUNT(*) as c FROM chunks_fts").get() as { c: number }).c;
231
+ this.log.info(`Migrated chunks_fts to trigram: ${count} rows indexed`);
232
+ }
233
+ } catch (err) {
234
+ this.log.warn(`Failed to migrate chunks_fts to trigram: ${err}`);
235
+ }
236
+
237
+ // Same for skills_fts
238
+ try {
239
+ const row = this.db.prepare(
240
+ "SELECT sql FROM sqlite_master WHERE name='skills_fts'"
241
+ ).get() as { sql: string } | undefined;
242
+ if (row && row.sql && !row.sql.includes("trigram")) {
243
+ this.log.info("Migrating skills_fts to trigram tokenizer...");
244
+ this.db.exec("DROP TRIGGER IF EXISTS skills_ai");
245
+ this.db.exec("DROP TRIGGER IF EXISTS skills_ad");
246
+ this.db.exec("DROP TRIGGER IF EXISTS skills_au");
247
+ this.db.exec("DROP TABLE IF EXISTS skills_fts");
248
+ this.db.exec(`
249
+ CREATE VIRTUAL TABLE skills_fts USING fts5(
250
+ name, description, content='skills', content_rowid='rowid',
251
+ tokenize='trigram'
252
+ )
253
+ `);
254
+ this.db.exec(`
255
+ CREATE TRIGGER skills_ai AFTER INSERT ON skills BEGIN
256
+ INSERT INTO skills_fts(rowid, name, description) VALUES (new.rowid, new.name, new.description);
257
+ END;
258
+ CREATE TRIGGER skills_ad AFTER DELETE ON skills BEGIN
259
+ INSERT INTO skills_fts(skills_fts, rowid, name, description) VALUES ('delete', old.rowid, old.name, old.description);
260
+ END;
261
+ CREATE TRIGGER skills_au AFTER UPDATE ON skills BEGIN
262
+ INSERT INTO skills_fts(skills_fts, rowid, name, description) VALUES ('delete', old.rowid, old.name, old.description);
263
+ INSERT INTO skills_fts(rowid, name, description) VALUES (new.rowid, new.name, new.description);
264
+ END
265
+ `);
266
+ this.db.exec("INSERT INTO skills_fts(rowid, name, description) SELECT rowid, name, description FROM skills");
267
+ this.log.info("Migrated skills_fts to trigram");
268
+ }
269
+ } catch (err) {
270
+ this.log.warn(`Failed to migrate skills_fts to trigram: ${err}`);
271
+ }
272
+ }
273
+
198
274
  private migrateTaskId(): void {
199
275
  const cols = this.db.prepare("PRAGMA table_info(chunks)").all() as Array<{ name: string }>;
200
276
  if (!cols.some((c) => c.name === "task_id")) {
@@ -530,8 +606,6 @@ export class SqliteStore {
530
606
  getMetrics(days: number): {
531
607
  writesPerDay: Array<{ date: string; count: number }>;
532
608
  viewerCallsPerDay: Array<{ date: string; list: number; search: number; total: number }>;
533
- roleBreakdown: Record<string, number>;
534
- kindBreakdown: Record<string, number>;
535
609
  totals: { memories: number; sessions: number; embeddings: number; todayWrites: number; todayViewerCalls: number };
536
610
  } {
537
611
  const since = Date.now() - days * 86400 * 1000;
@@ -566,11 +640,6 @@ export class SqliteStore {
566
640
  .sort((a, b) => a[0].localeCompare(b[0]))
567
641
  .map(([date, v]) => ({ date, list: v.list, search: v.search, total: v.list + v.search }));
568
642
 
569
- const roles = this.db.prepare("SELECT role, COUNT(*) as count FROM chunks GROUP BY role").all() as Array<{ role: string; count: number }>;
570
- const kinds = this.db.prepare("SELECT kind, COUNT(*) as count FROM chunks GROUP BY kind").all() as Array<{ kind: string; count: number }>;
571
- const roleBreakdown = Object.fromEntries(roles.map((r) => [r.role, r.count]));
572
- const kindBreakdown = Object.fromEntries(kinds.map((k) => [k.kind, k.count]));
573
-
574
643
  const totalChunks = (this.db.prepare("SELECT COUNT(*) as c FROM chunks").get() as { c: number }).c;
575
644
  const totalSessions = (this.db.prepare("SELECT COUNT(DISTINCT session_key) as c FROM chunks").get() as { c: number }).c;
576
645
  const totalEmbeddings = (this.db.prepare("SELECT COUNT(*) as c FROM embeddings").get() as { c: number }).c;
@@ -580,8 +649,6 @@ export class SqliteStore {
580
649
  return {
581
650
  writesPerDay,
582
651
  viewerCallsPerDay,
583
- roleBreakdown,
584
- kindBreakdown,
585
652
  totals: {
586
653
  memories: totalChunks,
587
654
  sessions: totalSessions,
@@ -870,6 +937,10 @@ export class SqliteStore {
870
937
  { sql: "content LIKE '%=== MemOS LONG-TERM MEMORY%'", reason: "MemOS legacy injection" },
871
938
  { sql: "content LIKE '%[MemOS Auto-Recall]%'", reason: "MemOS Auto-Recall injection" },
872
939
  { sql: "content LIKE '%## Memory system%No memories were automatically recalled%'", reason: "Memory system no-recall hint" },
940
+ { sql: "content LIKE '%## Retrieved memories from past conversations%CRITICAL INSTRUCTION%'", reason: "prependContext recall injection" },
941
+ { sql: "content LIKE '%VERIFIED facts the user previously shared%'", reason: "VERIFIED facts injection" },
942
+ { sql: "content LIKE '%<memos_system_instruction>%'", reason: "memos_system_instruction injection" },
943
+ { sql: "content LIKE '%📝 Related memories:%'", reason: "Related memories injection" },
873
944
  ];
874
945
  for (const { sql, reason } of patterns) {
875
946
  const rows = this.db.prepare(
@@ -1103,14 +1174,16 @@ export class SqliteStore {
1103
1174
  */
1104
1175
  findActiveChunkByHash(content: string, owner?: string): string | null {
1105
1176
  const hash = contentHash(content);
1177
+ // Check ANY existing chunk with the same hash (regardless of dedup_status)
1178
+ // to prevent re-creating duplicates when all prior copies have been marked duplicate/merged.
1106
1179
  if (owner) {
1107
1180
  const row = this.db.prepare(
1108
- "SELECT id FROM chunks WHERE content_hash = ? AND dedup_status = 'active' AND owner = ? LIMIT 1",
1181
+ "SELECT id FROM chunks WHERE content_hash = ? AND owner = ? ORDER BY CASE dedup_status WHEN 'active' THEN 0 ELSE 1 END LIMIT 1",
1109
1182
  ).get(hash, owner) as { id: string } | undefined;
1110
1183
  return row?.id ?? null;
1111
1184
  }
1112
1185
  const row = this.db.prepare(
1113
- "SELECT id FROM chunks WHERE content_hash = ? AND dedup_status = 'active' LIMIT 1",
1186
+ "SELECT id FROM chunks WHERE content_hash = ? ORDER BY CASE dedup_status WHEN 'active' THEN 0 ELSE 1 END LIMIT 1",
1114
1187
  ).get(hash) as { id: string } | undefined;
1115
1188
  return row?.id ?? null;
1116
1189
  }
@@ -1365,14 +1438,13 @@ export class SqliteStore {
1365
1438
  * with implicit AND (space-separated) for safe querying.
1366
1439
  */
1367
1440
  function sanitizeFtsQuery(raw: string): string {
1368
- const tokens = raw
1369
- .replace(/[."""(){}[\]*:^~!@#$%&\\/<>,;'`]/g, " ")
1370
- .split(/\s+/)
1371
- .map((t) => t.trim().replace(/^-+|-+$/g, ""))
1372
- .filter((t) => t.length > 1)
1373
- .filter((t) => !FTS_RESERVED.has(t.toUpperCase()));
1374
-
1375
- return tokens.join(" ");
1441
+ // With trigram tokenizer, the query string is matched as a substring.
1442
+ // Clean special chars but keep the text as-is (trigram needs >= 3 chars).
1443
+ const cleaned = raw
1444
+ .replace(/[."""(){}[\]*:^~!@#$%&\\/<>,;'`??。,!、:""''()【】《》]/g, " ")
1445
+ .trim();
1446
+ if (cleaned.length < 3) return "";
1447
+ return cleaned;
1376
1448
  }
1377
1449
 
1378
1450
  const FTS_RESERVED = new Set(["AND", "OR", "NOT", "NEAR"]);
@@ -47,10 +47,7 @@ export function createMemoryGetTool(store: SqliteStore): ToolDefinition {
47
47
  return { error: `Chunk not found: ${ref.chunkId}` };
48
48
  }
49
49
 
50
- const content =
51
- chunk.content.length > maxChars
52
- ? chunk.content.slice(0, maxChars) + "…"
53
- : chunk.content;
50
+ const content = chunk.content;
54
51
 
55
52
  const result: GetResult = {
56
53
  content,
package/src/types.ts CHANGED
@@ -55,14 +55,7 @@ export interface Task {
55
55
  updatedAt: number;
56
56
  }
57
57
 
58
- export type ChunkKind =
59
- | "paragraph"
60
- | "code_block"
61
- | "error_stack"
62
- | "command"
63
- | "list"
64
- | "mixed"
65
- | "tool_result";
58
+ export type ChunkKind = "paragraph";
66
59
 
67
60
  export interface ChunkRef {
68
61
  sessionKey: string;
@@ -294,7 +287,7 @@ export const DEFAULTS = {
294
287
  mmrLambda: 0.7,
295
288
  recencyHalfLifeDays: 14,
296
289
  vectorSearchMaxChunks: 0,
297
- dedupSimilarityThreshold: 0.60,
290
+ dedupSimilarityThreshold: 0.80,
298
291
  evidenceWrapperTag: "STORED_MEMORY",
299
292
  excerptMinChars: 200,
300
293
  excerptMaxChars: 500,
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Channel-aware update check against npm registry dist-tags.
3
+ * - Prerelease users (e.g. 1.0.2-beta.x) compare against beta tag only (semver gt).
4
+ * - Stable users compare against latest tag only (semver gt).
5
+ * - Beta users get optional stableChannel hint to install @latest when stable exists.
6
+ */
7
+ // @ts-ignore — semver has no bundled types
8
+ import * as semver from "semver";
9
+
10
+ export interface UpdateCheckResult {
11
+ updateAvailable: boolean;
12
+ current: string;
13
+ /** Version on the channel we compared against (beta tag or latest tag). */
14
+ latest: string;
15
+ packageName: string;
16
+ /** Channel used for the primary comparison. */
17
+ channel: "beta" | "latest";
18
+ /** Full install command (includes @beta when updating on beta channel). */
19
+ installCommand: string;
20
+ /** When current is prerelease and registry has a stable latest — how to switch to stable. */
21
+ stableChannel?: { version: string; installCommand: string };
22
+ }
23
+
24
+ function isPrerelease(v: string): boolean {
25
+ return semver.prerelease(v) != null;
26
+ }
27
+
28
+ /**
29
+ * Fetch registry package doc and compute update state.
30
+ */
31
+ export async function computeUpdateCheck(
32
+ packageName: string,
33
+ current: string,
34
+ fetchImpl: typeof fetch,
35
+ timeoutMs = 8_000,
36
+ ): Promise<UpdateCheckResult | null> {
37
+ if (!semver.valid(current)) return null;
38
+
39
+ const url = `https://registry.npmjs.org/${encodeURIComponent(packageName)}`;
40
+ const resp = await fetchImpl(url, { signal: AbortSignal.timeout(timeoutMs) });
41
+ if (!resp.ok) return null;
42
+
43
+ const data = (await resp.json()) as { "dist-tags"?: Record<string, string> };
44
+ const tags = data["dist-tags"] ?? {};
45
+ const latestTag = tags.latest;
46
+ const betaTag = tags.beta;
47
+
48
+ const onBeta = isPrerelease(current);
49
+ let updateAvailable = false;
50
+ let channel: "beta" | "latest" = "latest";
51
+ let targetVersion = current;
52
+ let installCommand = `openclaw plugins install ${packageName}`;
53
+
54
+ if (onBeta) {
55
+ channel = "beta";
56
+ // Beta users: only compare against beta tag; never suggest "updating" to stable via gt confusion.
57
+ if (betaTag && semver.valid(betaTag) && semver.gt(betaTag, current)) {
58
+ updateAvailable = true;
59
+ targetVersion = betaTag;
60
+ installCommand = `openclaw plugins install ${packageName}@beta`;
61
+ } else {
62
+ targetVersion = betaTag && semver.valid(betaTag) ? betaTag : current;
63
+ if (betaTag && semver.valid(betaTag) && semver.eq(betaTag, current)) {
64
+ installCommand = `openclaw plugins install ${packageName}@beta`;
65
+ }
66
+ }
67
+ } else {
68
+ // Stable users: compare against latest only.
69
+ if (latestTag && semver.valid(latestTag) && semver.gt(latestTag, current)) {
70
+ updateAvailable = true;
71
+ targetVersion = latestTag;
72
+ installCommand = `openclaw plugins install ${packageName}`;
73
+ } else {
74
+ targetVersion = latestTag && semver.valid(latestTag) ? latestTag : current;
75
+ }
76
+ }
77
+
78
+ // Beta user + stable exists on latest: optional hint to switch to stable (not counted as "update").
79
+ let stableChannel: UpdateCheckResult["stableChannel"];
80
+ if (onBeta && latestTag && semver.valid(latestTag) && !isPrerelease(latestTag)) {
81
+ stableChannel = {
82
+ version: latestTag,
83
+ installCommand: `openclaw plugins install ${packageName}@latest`,
84
+ };
85
+ }
86
+
87
+ return {
88
+ updateAvailable,
89
+ current,
90
+ latest: targetVersion,
91
+ packageName,
92
+ channel,
93
+ installCommand,
94
+ stableChannel,
95
+ };
96
+ }