@agentmemory/agentmemory 0.9.31 → 0.9.32

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 (138) hide show
  1. package/.env.example +18 -15
  2. package/AGENTS.md +4 -4
  3. package/README.md +92 -270
  4. package/dist/.env.example +18 -15
  5. package/dist/cli.d.mts.map +1 -1
  6. package/dist/cli.mjs +530 -75
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/{compression-recovery-CnhLQC6N.mjs → compression-recovery-CZh63Jmz.mjs} +174 -89
  9. package/dist/compression-recovery-CZh63Jmz.mjs.map +1 -0
  10. package/dist/{connect-BSLIAMpw.mjs → connect-BX3njQ3Y.mjs} +28 -14
  11. package/dist/connect-BX3njQ3Y.mjs.map +1 -0
  12. package/dist/hooks/_capture.d.mts +3 -2
  13. package/dist/hooks/_capture.d.mts.map +1 -1
  14. package/dist/hooks/_capture.mjs +87 -8
  15. package/dist/hooks/_capture.mjs.map +1 -1
  16. package/dist/hooks/post-commit.mjs +58 -5
  17. package/dist/hooks/post-commit.mjs.map +1 -1
  18. package/dist/hooks/post-tool-failure.mjs +7 -2
  19. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  20. package/dist/hooks/post-tool-use.mjs +7 -2
  21. package/dist/hooks/post-tool-use.mjs.map +1 -1
  22. package/dist/hooks/pre-compact.mjs +67 -12
  23. package/dist/hooks/pre-compact.mjs.map +1 -1
  24. package/dist/hooks/pre-tool-use.mjs +58 -5
  25. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  26. package/dist/hooks/session-end.mjs +14 -3
  27. package/dist/hooks/session-end.mjs.map +1 -1
  28. package/dist/hooks/session-start.mjs +58 -5
  29. package/dist/hooks/session-start.mjs.map +1 -1
  30. package/dist/hooks/stop.mjs +2 -1
  31. package/dist/hooks/stop.mjs.map +1 -1
  32. package/dist/hooks/subagent-stop.mjs +15 -5
  33. package/dist/hooks/subagent-stop.mjs.map +1 -1
  34. package/dist/hooks/task-completed.mjs +8 -1
  35. package/dist/hooks/task-completed.mjs.map +1 -1
  36. package/dist/index.mjs +724 -200
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/integrations/dsh.mjs +31 -4
  39. package/dist/integrations/dsh.mjs.map +1 -1
  40. package/dist/{secret-store-D9GwO0xp.mjs → secret-store-iYXRcrO8.mjs} +197 -55
  41. package/dist/secret-store-iYXRcrO8.mjs.map +1 -0
  42. package/dist/{src-DaMtDzt_.mjs → src-C23nMpda.mjs} +359 -62
  43. package/dist/src-C23nMpda.mjs.map +1 -0
  44. package/dist/{standalone-BlqshyZ5.mjs → standalone-BYo5USDb.mjs} +169 -10
  45. package/dist/standalone-BYo5USDb.mjs.map +1 -0
  46. package/dist/standalone.d.mts.map +1 -1
  47. package/dist/standalone.mjs +240 -10
  48. package/dist/standalone.mjs.map +1 -1
  49. package/dist/viewer/index.html +49 -28
  50. package/integrations/hermes/README.md +11 -1
  51. package/integrations/hermes/__init__.py +1 -0
  52. package/integrations/hermes/plugin.yaml +1 -1
  53. package/integrations/omp/dist/index.mjs +31 -4
  54. package/integrations/omp/package.json +1 -1
  55. package/integrations/omp/skills/agentmemory-agents/REFERENCE.md +1 -1
  56. package/integrations/omp/skills/agentmemory-architecture/SKILL.md +5 -1
  57. package/integrations/omp/skills/agentmemory-config/REFERENCE.md +2 -1
  58. package/integrations/omp/skills/agentmemory-config/SKILL.md +29 -9
  59. package/integrations/omp/skills/agentmemory-hooks/SKILL.md +17 -6
  60. package/integrations/omp/skills/agentmemory-mcp-tools/REFERENCE.md +1 -1
  61. package/integrations/omp/skills/agentmemory-mcp-tools/SKILL.md +10 -0
  62. package/integrations/omp/skills/agentmemory-rest-api/REFERENCE.md +2 -1
  63. package/integrations/omp/skills/agentmemory-rest-api/SKILL.md +1 -1
  64. package/integrations/openclaw/README.md +10 -0
  65. package/integrations/openclaw/openclaw.plugin.json +1 -1
  66. package/integrations/openclaw/package.json +1 -1
  67. package/integrations/openclaw/plugin.yaml +1 -1
  68. package/integrations/openclaw/skills/agentmemory-agents/REFERENCE.md +1 -1
  69. package/integrations/openclaw/skills/agentmemory-architecture/SKILL.md +5 -1
  70. package/integrations/openclaw/skills/agentmemory-config/REFERENCE.md +2 -1
  71. package/integrations/openclaw/skills/agentmemory-config/SKILL.md +29 -9
  72. package/integrations/openclaw/skills/agentmemory-hooks/SKILL.md +17 -6
  73. package/integrations/openclaw/skills/agentmemory-mcp-tools/REFERENCE.md +1 -1
  74. package/integrations/openclaw/skills/agentmemory-mcp-tools/SKILL.md +10 -0
  75. package/integrations/openclaw/skills/agentmemory-rest-api/REFERENCE.md +2 -1
  76. package/integrations/openclaw/skills/agentmemory-rest-api/SKILL.md +1 -1
  77. package/integrations/pi/README.md +1 -0
  78. package/integrations/pi/dist/index.mjs +92 -11
  79. package/integrations/pi/index.ts +56 -6
  80. package/integrations/pi/package.json +1 -1
  81. package/integrations/pi/skills/agentmemory-agents/REFERENCE.md +1 -1
  82. package/integrations/pi/skills/agentmemory-architecture/SKILL.md +5 -1
  83. package/integrations/pi/skills/agentmemory-config/REFERENCE.md +2 -1
  84. package/integrations/pi/skills/agentmemory-config/SKILL.md +29 -9
  85. package/integrations/pi/skills/agentmemory-hooks/SKILL.md +17 -6
  86. package/integrations/pi/skills/agentmemory-mcp-tools/REFERENCE.md +1 -1
  87. package/integrations/pi/skills/agentmemory-mcp-tools/SKILL.md +10 -0
  88. package/integrations/pi/skills/agentmemory-rest-api/REFERENCE.md +2 -1
  89. package/integrations/pi/skills/agentmemory-rest-api/SKILL.md +1 -1
  90. package/package.json +4 -3
  91. package/plugin/.claude-plugin/plugin.json +16 -3
  92. package/plugin/.codex-plugin/plugin.json +1 -1
  93. package/plugin/.devin-plugin/plugin.json +3 -4
  94. package/plugin/.mcp.json +5 -1
  95. package/plugin/README.md +71 -0
  96. package/plugin/hooks/hooks.json +24 -12
  97. package/plugin/opencode/plugin.json +1 -1
  98. package/plugin/plugin.json +1 -1
  99. package/plugin/scripts/_capture.d.mts +3 -2
  100. package/plugin/scripts/_capture.d.mts.map +1 -1
  101. package/plugin/scripts/_capture.mjs +87 -8
  102. package/plugin/scripts/_capture.mjs.map +1 -1
  103. package/plugin/scripts/plugin-bridge.mjs +25 -6
  104. package/plugin/scripts/post-tool-failure.mjs +7 -2
  105. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  106. package/plugin/scripts/post-tool-use.mjs +7 -2
  107. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  108. package/plugin/scripts/pre-compact.mjs +67 -12
  109. package/plugin/scripts/pre-compact.mjs.map +1 -1
  110. package/plugin/scripts/pre-tool-use.mjs +58 -5
  111. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  112. package/plugin/scripts/session-end.mjs +14 -3
  113. package/plugin/scripts/session-end.mjs.map +1 -1
  114. package/plugin/scripts/session-start.mjs +58 -5
  115. package/plugin/scripts/session-start.mjs.map +1 -1
  116. package/plugin/scripts/stop.mjs +2 -1
  117. package/plugin/scripts/stop.mjs.map +1 -1
  118. package/plugin/scripts/subagent-stop.mjs +15 -5
  119. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  120. package/plugin/scripts/task-completed.mjs +8 -1
  121. package/plugin/scripts/task-completed.mjs.map +1 -1
  122. package/plugin/skills/agentmemory-agents/REFERENCE.md +1 -1
  123. package/plugin/skills/agentmemory-architecture/SKILL.md +5 -1
  124. package/plugin/skills/agentmemory-config/REFERENCE.md +2 -1
  125. package/plugin/skills/agentmemory-config/SKILL.md +29 -9
  126. package/plugin/skills/agentmemory-hooks/SKILL.md +17 -6
  127. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +1 -1
  128. package/plugin/skills/agentmemory-mcp-tools/SKILL.md +10 -0
  129. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +2 -1
  130. package/plugin/skills/agentmemory-rest-api/SKILL.md +1 -1
  131. package/dist/compression-recovery-CnhLQC6N.mjs.map +0 -1
  132. package/dist/connect-BSLIAMpw.mjs.map +0 -1
  133. package/dist/secret-store-D9GwO0xp.mjs.map +0 -1
  134. package/dist/src-DaMtDzt_.mjs.map +0 -1
  135. package/dist/standalone-BlqshyZ5.mjs.map +0 -1
  136. package/plugin/scripts/post-commit.d.mts +0 -1
  137. package/plugin/scripts/post-commit.mjs +0 -204
  138. package/plugin/scripts/post-commit.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { chmodSync, closeSync, existsSync, fchmodSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
- import { homedir } from "node:os";
5
+ import { homedir, tmpdir } from "node:os";
6
6
  import "picocolors";
7
7
  import { AsyncLocalStorage } from "node:async_hooks";
8
8
  //#region src/mcp/in-memory-kv.ts
@@ -41,7 +41,19 @@ var InMemoryKV = class {
41
41
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
42
42
  const data = {};
43
43
  for (const [scope, entries] of this.store) data[scope] = Object.fromEntries(entries);
44
- writeFileSync(this.persistPath, JSON.stringify(data), "utf-8");
44
+ const tmpPath = `${this.persistPath}.${process.pid}.tmp`;
45
+ try {
46
+ writeFileSync(tmpPath, JSON.stringify(data), {
47
+ encoding: "utf-8",
48
+ mode: 384
49
+ });
50
+ renameSync(tmpPath, this.persistPath);
51
+ } catch (err) {
52
+ try {
53
+ rmSync(tmpPath, { force: true });
54
+ } catch {}
55
+ throw err;
56
+ }
45
57
  return true;
46
58
  } catch (err) {
47
59
  process.stderr.write(`[@agentmemory/mcp] Persist failed: ${err instanceof Error ? err.message : String(err)}\n`);
@@ -240,7 +252,190 @@ function createStdioTransport(handler) {
240
252
  };
241
253
  }
242
254
  //#endregion
255
+ //#region src/cli/engine-launch.ts
256
+ const CREDENTIAL_URL_PATTERN = /:\/\/[^@\s/]*@/g;
257
+ function redactCredentialUrls(text) {
258
+ return text.replace(CREDENTIAL_URL_PATTERN, "://***@");
259
+ }
260
+ const MAX_CRASH_LINE_BYTES = 64 * 1024;
261
+ function writeStderr(text) {
262
+ process.stderr.write(text);
263
+ }
264
+ function stderrWriteMayBlock(platform = process.platform, isTTY = process.stderr.isTTY) {
265
+ return platform === "win32" && !isTTY;
266
+ }
267
+ function mcpCrashLogPath(env = process.env) {
268
+ return join(env["AGENTMEMORY_DATA_DIR"] || join(homedir(), ".agentmemory"), "mcp-crash.log");
269
+ }
270
+ function formatFatal(kind, reason, now = /* @__PURE__ */ new Date()) {
271
+ const detail = reason instanceof Error ? reason.stack || reason.message : String(reason);
272
+ return redactCredentialUrls(`[${now.toISOString()}] pid=${process.pid} ${kind}: ${detail}\n`);
273
+ }
274
+ function safeFormat(kind, reason) {
275
+ try {
276
+ return formatFatal(kind, reason);
277
+ } catch {
278
+ return `[${(/* @__PURE__ */ new Date()).toISOString()}] pid=${process.pid} ${kind}: (the error could not be formatted)\n`;
279
+ }
280
+ }
281
+ function describe(err) {
282
+ return err instanceof Error ? err.message : String(err);
283
+ }
284
+ function rotateCrashLog(logPath, notices) {
285
+ const rotated = `${logPath}.1`;
286
+ try {
287
+ renameSync(logPath, rotated);
288
+ } catch (err) {
289
+ if (err.code === "ENOENT") return;
290
+ throw err;
291
+ }
292
+ try {
293
+ chmodSync(rotated, 384);
294
+ } catch (err) {
295
+ notices.push(`[@agentmemory/mcp] rotated crash log ${rotated} could not be made owner-only: ${describe(err)}\n`);
296
+ }
297
+ }
298
+ function boundCrashLine(line, maxBytes = MAX_CRASH_LINE_BYTES) {
299
+ const bytes = Buffer.from(line, "utf8");
300
+ if (bytes.length <= maxBytes) return line;
301
+ const marker = " ...(truncated)\n";
302
+ const markerBytes = Buffer.byteLength(marker);
303
+ if (maxBytes <= markerBytes) return bytes.subarray(0, Math.max(0, maxBytes)).toString("utf8").replace(/�+$/, "");
304
+ return `${bytes.subarray(0, maxBytes - markerBytes).toString("utf8").replace(/�+$/, "")}${marker}`;
305
+ }
306
+ function writeAll(fd, data, write = writeSync) {
307
+ let offset = 0;
308
+ while (offset < data.length) {
309
+ const n = write(fd, data, offset, data.length - offset);
310
+ if (!(n > 0)) throw new Error(`crash log write stopped after ${offset} of ${data.length} bytes`);
311
+ offset += n;
312
+ }
313
+ }
314
+ function writeCrashLog(line, logPath = mcpCrashLogPath()) {
315
+ const notices = [];
316
+ const bounded = boundCrashLine(line);
317
+ let fd;
318
+ try {
319
+ mkdirSync(dirname(logPath), {
320
+ recursive: true,
321
+ mode: 448
322
+ });
323
+ if (existsSync(logPath) && statSync(logPath).size + Buffer.byteLength(bounded) > 1048576) rotateCrashLog(logPath, notices);
324
+ fd = openSync(logPath, "a", 384);
325
+ try {
326
+ fchmodSync(fd, 384);
327
+ } catch (err) {
328
+ notices.push(`[@agentmemory/mcp] crash log ${logPath} could not be made owner-only, so it was not written: ${describe(err)}\n`);
329
+ return {
330
+ written: false,
331
+ notices
332
+ };
333
+ }
334
+ writeAll(fd, Buffer.from(bounded, "utf8"));
335
+ notices.push(`[@agentmemory/mcp] crash log: ${logPath}\n`);
336
+ return {
337
+ written: true,
338
+ notices
339
+ };
340
+ } catch (err) {
341
+ notices.push(`[@agentmemory/mcp] crash log not written to ${logPath}: ${describe(err)}\n`);
342
+ return {
343
+ written: false,
344
+ notices
345
+ };
346
+ } finally {
347
+ if (fd !== void 0) try {
348
+ closeSync(fd);
349
+ } catch {}
350
+ }
351
+ }
352
+ function fallbackCrashLogPath() {
353
+ return join(tmpdir(), "agentmemory-mcp-crash.log");
354
+ }
355
+ function handleFatal(kind, reason, hooks) {
356
+ const line = safeFormat(kind, reason);
357
+ const stderrMayBlock = hooks.stderrMayBlock ?? stderrWriteMayBlock();
358
+ let result = {
359
+ written: false,
360
+ notices: []
361
+ };
362
+ try {
363
+ result = writeCrashLog(line, hooks.logPath ?? mcpCrashLogPath());
364
+ } catch {}
365
+ const notices = result.notices;
366
+ if (!result.written && stderrMayBlock) try {
367
+ writeCrashLog(line + notices.join(""), hooks.fallbackLogPath ?? fallbackCrashLogPath());
368
+ } catch {}
369
+ try {
370
+ hooks.persist();
371
+ } catch {}
372
+ if (!stderrMayBlock) {
373
+ const write = hooks.write ?? writeStderr;
374
+ for (const text of [`[@agentmemory/mcp] fatal ${line}`, ...notices]) try {
375
+ write(text);
376
+ } catch {}
377
+ }
378
+ (hooks.exit ?? ((code) => process.exit(code)))(1);
379
+ }
380
+ function installCrashHandlers(hooks) {
381
+ process.on("uncaughtException", (err) => handleFatal("uncaughtException", err, hooks));
382
+ process.on("unhandledRejection", (reason) => handleFatal("unhandledRejection", reason, hooks));
383
+ }
384
+ //#endregion
243
385
  //#region src/mcp/tools-registry.ts
386
+ const READ_ONLY_TOOLS = new Set([
387
+ "memory_recall",
388
+ "memory_file_history",
389
+ "memory_patterns",
390
+ "memory_sessions",
391
+ "memory_smart_search",
392
+ "memory_vision_search",
393
+ "memory_timeline",
394
+ "memory_export",
395
+ "memory_relations",
396
+ "memory_commit_lookup",
397
+ "memory_commits",
398
+ "memory_graph_query",
399
+ "memory_team_feed",
400
+ "memory_audit",
401
+ "memory_frontier",
402
+ "memory_next",
403
+ "memory_diagnose",
404
+ "memory_facet_query",
405
+ "memory_verify",
406
+ "memory_lesson_recall",
407
+ "memory_insight_list",
408
+ "memory_slot_list",
409
+ "memory_slot_get"
410
+ ]);
411
+ const DESTRUCTIVE_TOOLS = new Set([
412
+ "memory_action_update",
413
+ "memory_compress_file",
414
+ "memory_claude_bridge_sync",
415
+ "memory_governance_delete",
416
+ "memory_heal",
417
+ "memory_lesson_delete",
418
+ "memory_obsidian_export",
419
+ "memory_slot_replace",
420
+ "memory_slot_delete"
421
+ ]);
422
+ const IDEMPOTENT_WRITE_TOOLS = new Set([
423
+ "memory_governance_delete",
424
+ "memory_lesson_delete",
425
+ "memory_slot_replace",
426
+ "memory_slot_delete",
427
+ "memory_claude_bridge_sync"
428
+ ]);
429
+ const OPEN_WORLD_TOOLS = new Set(["memory_mesh_sync"]);
430
+ function toolAnnotations(name) {
431
+ const readOnly = READ_ONLY_TOOLS.has(name);
432
+ return {
433
+ readOnlyHint: readOnly,
434
+ destructiveHint: !readOnly && DESTRUCTIVE_TOOLS.has(name),
435
+ idempotentHint: readOnly || IDEMPOTENT_WRITE_TOOLS.has(name),
436
+ openWorldHint: OPEN_WORLD_TOOLS.has(name)
437
+ };
438
+ }
244
439
  const CORE_TOOLS = [
245
440
  {
246
441
  name: "memory_recall",
@@ -1221,6 +1416,11 @@ const V070_TOOLS = [
1221
1416
  tags: {
1222
1417
  type: "string",
1223
1418
  description: "Comma-separated tags"
1419
+ },
1420
+ sourceIds: {
1421
+ type: "array",
1422
+ items: { type: "string" },
1423
+ description: "Ids of the session, memory, observation or crystal this lesson came from (max 50)"
1224
1424
  }
1225
1425
  },
1226
1426
  required: ["content"]
@@ -1433,7 +1633,10 @@ function getAllTools() {
1433
1633
  ...V070_TOOLS,
1434
1634
  ...V073_TOOLS,
1435
1635
  ...V010_SLOTS_TOOLS
1436
- ];
1636
+ ].map((tool) => ({
1637
+ ...tool,
1638
+ annotations: toolAnnotations(tool.name)
1639
+ }));
1437
1640
  }
1438
1641
  process.env["AGENTMEMORY_DATA_DIR"] || join(homedir(), ".agentmemory");
1439
1642
  const ENV_FILE = process.env["AGENTMEMORY_ENV_FILE"] || join(homedir(), ".agentmemory", ".env");
@@ -1508,6 +1711,7 @@ function memoryToObservation(memory) {
1508
1711
  sessionId: memory.sessionIds?.[0] ?? "memory",
1509
1712
  timestamp: memory.createdAt,
1510
1713
  type: "decision",
1714
+ memoryType: memory.type,
1511
1715
  title: memory.title,
1512
1716
  facts: [memory.content],
1513
1717
  narrative: memory.content,
@@ -1545,6 +1749,7 @@ function formatResult(result, format) {
1545
1749
  sessionId: result.sessionId,
1546
1750
  title: observation.title,
1547
1751
  type: observation.type,
1752
+ ...observation.memoryType !== void 0 && { memoryType: observation.memoryType },
1548
1753
  score: result.score,
1549
1754
  timestamp: observation.timestamp,
1550
1755
  ...result.layer !== void 0 && { layer: result.layer }
@@ -1565,6 +1770,7 @@ function clipResult(result, format, budget) {
1565
1770
  sessionId: result.sessionId,
1566
1771
  title: "",
1567
1772
  type: observation.type,
1773
+ ...observation.memoryType !== void 0 && { memoryType: observation.memoryType },
1568
1774
  score: result.score,
1569
1775
  timestamp: observation.timestamp,
1570
1776
  ...layer,
@@ -1586,6 +1792,7 @@ function clipResult(result, format, budget) {
1586
1792
  sessionId: result.sessionId,
1587
1793
  title,
1588
1794
  narrative,
1795
+ ...observation.memoryType !== void 0 && { memoryType: observation.memoryType },
1589
1796
  score: result.score,
1590
1797
  timestamp: observation.timestamp,
1591
1798
  ...layer,
@@ -1597,6 +1804,7 @@ function clipResult(result, format, budget) {
1597
1804
  sessionId: observation.sessionId,
1598
1805
  timestamp: observation.timestamp,
1599
1806
  type: observation.type,
1807
+ ...observation.memoryType !== void 0 && { memoryType: observation.memoryType },
1600
1808
  title,
1601
1809
  facts: [],
1602
1810
  narrative,
@@ -1766,7 +1974,7 @@ function parseSessionArguments(args) {
1766
1974
  }
1767
1975
  //#endregion
1768
1976
  //#region src/version.ts
1769
- const VERSION = "0.9.31";
1977
+ const VERSION = "0.9.32";
1770
1978
  createRequire(import.meta.url);
1771
1979
  //#endregion
1772
1980
  //#region src/state/schema.ts
@@ -2004,6 +2212,28 @@ function canonicalSecretPath() {
2004
2212
  return join(homedir(), ".agentmemory", "secret");
2005
2213
  }
2006
2214
  //#endregion
2215
+ //#region src/hooks/_endpoint.ts
2216
+ const OPTION_PREFIX = "CLAUDE_PLUGIN_OPTION_";
2217
+ function filled(value) {
2218
+ const trimmed = value?.trim();
2219
+ if (!trimmed || trimmed.startsWith("${") && trimmed.endsWith("}")) return void 0;
2220
+ return value;
2221
+ }
2222
+ function hookSetting(name, env = process.env) {
2223
+ const optionKey = `${OPTION_PREFIX}${name}`;
2224
+ const option = filled(env[optionKey])?.trim();
2225
+ if (option) return option;
2226
+ if (name === "AGENTMEMORY_SECRET" && optionKey in env) return void 0;
2227
+ return filled(env[name]);
2228
+ }
2229
+ function resolveSettingSecret(url, env = process.env) {
2230
+ const secretEnv = { ...env };
2231
+ const explicit = hookSetting("AGENTMEMORY_SECRET", env);
2232
+ if (explicit === void 0) delete secretEnv["AGENTMEMORY_SECRET"];
2233
+ else secretEnv["AGENTMEMORY_SECRET"] = explicit;
2234
+ return resolveClientSecret(url, secretEnv);
2235
+ }
2236
+ //#endregion
2007
2237
  //#region src/mcp/rest-proxy.ts
2008
2238
  const DEFAULT_URL = "http://localhost:3111";
2009
2239
  const DEFAULT_HEALTH_PROBE_TIMEOUT_MS = 2e3;
@@ -2034,10 +2264,7 @@ let cachedUrl = null;
2034
2264
  let cachedAt = 0;
2035
2265
  let probeInFlight = null;
2036
2266
  function resolveEnvOrEmpty(name) {
2037
- const raw = process.env[name];
2038
- if (!raw) return "";
2039
- if (raw.startsWith("${") && raw.endsWith("}")) return "";
2040
- return raw;
2267
+ return hookSetting(name) ?? "";
2041
2268
  }
2042
2269
  function baseUrl() {
2043
2270
  const value = resolveEnvOrEmpty("AGENTMEMORY_URL") || DEFAULT_URL;
@@ -2050,7 +2277,7 @@ function baseUrl() {
2050
2277
  }
2051
2278
  }
2052
2279
  function authHeader(url) {
2053
- const secret = resolveClientSecret(url);
2280
+ const secret = resolveSettingSecret(url);
2054
2281
  return secret ? { authorization: `Bearer ${secret}` } : {};
2055
2282
  }
2056
2283
  const defaultLivezProbe = async (url, timeoutMs, headers) => {
@@ -2447,6 +2674,8 @@ async function handleLocal(v, kvInstance) {
2447
2674
  mode: "compact",
2448
2675
  results: results.map((memory) => ({
2449
2676
  ...memory,
2677
+ type: "decision",
2678
+ memoryType: memory.type,
2450
2679
  obsId: memory.id,
2451
2680
  sessionId: memory.sessionIds?.[0] ?? "memory",
2452
2681
  layer: "memory"
@@ -2589,6 +2818,7 @@ const transport = createStdioTransport(async (method, params) => {
2589
2818
  default: throw new Error(`Unknown method: ${method}`);
2590
2819
  }
2591
2820
  });
2821
+ installCrashHandlers({ persist: () => kv.persist() });
2592
2822
  process.stderr.write(`[@agentmemory/mcp] Standalone MCP server v${SERVER_INFO.version} starting...\n`);
2593
2823
  transport.start();
2594
2824
  process.on("SIGINT", () => {