@remnic/core 1.0.3 → 1.1.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 (148) hide show
  1. package/dist/abort-error.d.ts +32 -0
  2. package/dist/abort-error.js +11 -0
  3. package/dist/access-cli.js +41 -40
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +3 -2
  6. package/dist/access-http.js +11 -11
  7. package/dist/access-mcp.d.ts +3 -2
  8. package/dist/access-mcp.js +7 -7
  9. package/dist/access-schema.d.ts +16 -16
  10. package/dist/access-service-HmO1Trrx.d.ts +732 -0
  11. package/dist/access-service.d.ts +11 -658
  12. package/dist/access-service.js +9 -9
  13. package/dist/bootstrap.d.ts +1 -1
  14. package/dist/briefing.js +6 -6
  15. package/dist/calibration.js +3 -3
  16. package/dist/causal-consolidation.js +10 -10
  17. package/dist/{chunk-PMB3WGDL.js → chunk-37UIFYWO.js} +64 -3
  18. package/dist/chunk-37UIFYWO.js.map +1 -0
  19. package/dist/{chunk-X4WESCKA.js → chunk-3QHL5ABG.js} +5 -5
  20. package/dist/{chunk-2VFW5K5U.js → chunk-3SV6CQHO.js} +10 -8
  21. package/dist/chunk-3SV6CQHO.js.map +1 -0
  22. package/dist/{chunk-U2IQTSBY.js → chunk-3WHVNEN7.js} +1 -1
  23. package/dist/chunk-3WHVNEN7.js.map +1 -0
  24. package/dist/{chunk-QKAH5B6E.js → chunk-44ICJRF3.js} +97 -9
  25. package/dist/chunk-44ICJRF3.js.map +1 -0
  26. package/dist/{chunk-S4LX5EBI.js → chunk-47UU5PU2.js} +48 -9
  27. package/dist/chunk-47UU5PU2.js.map +1 -0
  28. package/dist/{chunk-ECKDIK5F.js → chunk-4LACOVZX.js} +2 -2
  29. package/dist/{chunk-AYPYCLR7.js → chunk-6LX5ORAS.js} +2 -2
  30. package/dist/{chunk-GJQPH5G3.js → chunk-6UJ47TVX.js} +2 -2
  31. package/dist/{chunk-KWP7T3DP.js → chunk-7ECD5ATE.js} +2 -2
  32. package/dist/{chunk-74JR4N5J.js → chunk-7WQ6SLIE.js} +2 -2
  33. package/dist/{chunk-7PA4OZEU.js → chunk-BLKTA7MM.js} +6 -14
  34. package/dist/chunk-BLKTA7MM.js.map +1 -0
  35. package/dist/{chunk-XMGSSBFX.js → chunk-DEPL3635.js} +172 -100
  36. package/dist/chunk-DEPL3635.js.map +1 -0
  37. package/dist/{chunk-JROGC36Y.js → chunk-DHHP2Z4X.js} +2 -2
  38. package/dist/{chunk-BKQJBXXX.js → chunk-GGD5W7TB.js} +2 -2
  39. package/dist/chunk-GGD5W7TB.js.map +1 -0
  40. package/dist/{chunk-POMSFKTB.js → chunk-GV6NLQ4X.js} +14 -14
  41. package/dist/{chunk-AAI7JARD.js → chunk-HMDCOMYU.js} +8 -11
  42. package/dist/chunk-HMDCOMYU.js.map +1 -0
  43. package/dist/{chunk-POBPGDWI.js → chunk-ITRLGI2T.js} +2 -2
  44. package/dist/{chunk-MYQWXITD.js → chunk-JIU55F3X.js} +2 -2
  45. package/dist/{chunk-UPMD5XND.js → chunk-JL2PU6AI.js} +16 -5
  46. package/dist/chunk-JL2PU6AI.js.map +1 -0
  47. package/dist/{chunk-OJFGVJS6.js → chunk-MBJHSA7F.js} +65 -9
  48. package/dist/chunk-MBJHSA7F.js.map +1 -0
  49. package/dist/{chunk-V7XCAHIB.js → chunk-MVTHXUBX.js} +46 -23
  50. package/dist/chunk-MVTHXUBX.js.map +1 -0
  51. package/dist/{chunk-BTY5RRRF.js → chunk-N42IWANG.js} +5 -5
  52. package/dist/{chunk-NSB3WSYS.js → chunk-NQEVYWX6.js} +74 -3
  53. package/dist/chunk-NQEVYWX6.js.map +1 -0
  54. package/dist/chunk-OIT5QGG4.js +80 -0
  55. package/dist/chunk-OIT5QGG4.js.map +1 -0
  56. package/dist/chunk-PVGDJXVK.js +21 -0
  57. package/dist/chunk-PVGDJXVK.js.map +1 -0
  58. package/dist/{chunk-RCICHSHL.js → chunk-SYUK3VLY.js} +2 -2
  59. package/dist/{chunk-YFYL2SIJ.js → chunk-WBSAYXVI.js} +127 -39
  60. package/dist/chunk-WBSAYXVI.js.map +1 -0
  61. package/dist/{chunk-KEG4GNGI.js → chunk-XZ2TIKGC.js} +38 -8
  62. package/dist/chunk-XZ2TIKGC.js.map +1 -0
  63. package/dist/chunk-Y4FHOFJ2.js +140 -0
  64. package/dist/chunk-Y4FHOFJ2.js.map +1 -0
  65. package/dist/chunk-YNB73F22.js +137 -0
  66. package/dist/chunk-YNB73F22.js.map +1 -0
  67. package/dist/{chunk-HITJFT7E.js → chunk-ZVBB3T7V.js} +10 -5
  68. package/dist/chunk-ZVBB3T7V.js.map +1 -0
  69. package/dist/{cli-DwIBnp2g.d.ts → cli-BneVIEvh.d.ts} +2 -2
  70. package/dist/cli.d.ts +4 -3
  71. package/dist/cli.js +25 -24
  72. package/dist/config.js +1 -1
  73. package/dist/contradiction-review-WIUBAR52.js +21 -0
  74. package/dist/contradiction-review-WIUBAR52.js.map +1 -0
  75. package/dist/contradiction-scan-GR33PONM.js +376 -0
  76. package/dist/contradiction-scan-GR33PONM.js.map +1 -0
  77. package/dist/direct-answer-wiring.d.ts +77 -0
  78. package/dist/direct-answer-wiring.js +75 -0
  79. package/dist/direct-answer-wiring.js.map +1 -0
  80. package/dist/direct-answer.d.ts +106 -0
  81. package/dist/direct-answer.js +10 -0
  82. package/dist/direct-answer.js.map +1 -0
  83. package/dist/{engine-X7X3AAG3.js → engine-5TIQBYZR.js} +7 -7
  84. package/dist/engine-5TIQBYZR.js.map +1 -0
  85. package/dist/entity-retrieval.js +6 -6
  86. package/dist/explicit-capture.d.ts +1 -1
  87. package/dist/extraction.js +6 -6
  88. package/dist/fallback-llm.d.ts +11 -2
  89. package/dist/fallback-llm.js +3 -3
  90. package/dist/harmonic-retrieval.js +2 -1
  91. package/dist/index.d.ts +10 -124
  92. package/dist/index.js +74 -137
  93. package/dist/index.js.map +1 -1
  94. package/dist/intent.js +1 -1
  95. package/dist/local-llm.d.ts +10 -3
  96. package/dist/local-llm.js +1 -1
  97. package/dist/operator-toolkit.js +12 -11
  98. package/dist/{orchestrator-B9kwlCep.d.ts → orchestrator-DRYA6_lW.d.ts} +21 -2
  99. package/dist/orchestrator.d.ts +1 -1
  100. package/dist/orchestrator.js +36 -35
  101. package/dist/qmd.js +2 -1
  102. package/dist/recall-state.d.ts +28 -1
  103. package/dist/recall-state.js +1 -1
  104. package/dist/resolution-QBTDHTG7.js +100 -0
  105. package/dist/resolution-QBTDHTG7.js.map +1 -0
  106. package/dist/resolve-provider-secret.d.ts +24 -1
  107. package/dist/resolve-provider-secret.js +3 -1
  108. package/dist/resume-bundles.js +3 -3
  109. package/dist/schemas.d.ts +14 -14
  110. package/dist/semantic-consolidation.js +6 -6
  111. package/dist/semantic-rule-promotion.js +6 -6
  112. package/dist/semantic-rule-verifier.js +6 -6
  113. package/dist/storage.js +5 -5
  114. package/dist/summarizer.js +5 -5
  115. package/dist/types-DJhqDJUV.d.ts +50 -0
  116. package/dist/types.d.ts +34 -2
  117. package/dist/types.js +1 -1
  118. package/dist/verified-recall.js +6 -6
  119. package/package.json +1 -1
  120. package/dist/chunk-2VFW5K5U.js.map +0 -1
  121. package/dist/chunk-7PA4OZEU.js.map +0 -1
  122. package/dist/chunk-AAI7JARD.js.map +0 -1
  123. package/dist/chunk-BKQJBXXX.js.map +0 -1
  124. package/dist/chunk-HITJFT7E.js.map +0 -1
  125. package/dist/chunk-KEG4GNGI.js.map +0 -1
  126. package/dist/chunk-NSB3WSYS.js.map +0 -1
  127. package/dist/chunk-OJFGVJS6.js.map +0 -1
  128. package/dist/chunk-PMB3WGDL.js.map +0 -1
  129. package/dist/chunk-QKAH5B6E.js.map +0 -1
  130. package/dist/chunk-S4LX5EBI.js.map +0 -1
  131. package/dist/chunk-U2IQTSBY.js.map +0 -1
  132. package/dist/chunk-UPMD5XND.js.map +0 -1
  133. package/dist/chunk-V7XCAHIB.js.map +0 -1
  134. package/dist/chunk-XMGSSBFX.js.map +0 -1
  135. package/dist/chunk-YFYL2SIJ.js.map +0 -1
  136. /package/dist/{engine-X7X3AAG3.js.map → abort-error.js.map} +0 -0
  137. /package/dist/{chunk-X4WESCKA.js.map → chunk-3QHL5ABG.js.map} +0 -0
  138. /package/dist/{chunk-ECKDIK5F.js.map → chunk-4LACOVZX.js.map} +0 -0
  139. /package/dist/{chunk-AYPYCLR7.js.map → chunk-6LX5ORAS.js.map} +0 -0
  140. /package/dist/{chunk-GJQPH5G3.js.map → chunk-6UJ47TVX.js.map} +0 -0
  141. /package/dist/{chunk-KWP7T3DP.js.map → chunk-7ECD5ATE.js.map} +0 -0
  142. /package/dist/{chunk-74JR4N5J.js.map → chunk-7WQ6SLIE.js.map} +0 -0
  143. /package/dist/{chunk-JROGC36Y.js.map → chunk-DHHP2Z4X.js.map} +0 -0
  144. /package/dist/{chunk-POMSFKTB.js.map → chunk-GV6NLQ4X.js.map} +0 -0
  145. /package/dist/{chunk-POBPGDWI.js.map → chunk-ITRLGI2T.js.map} +0 -0
  146. /package/dist/{chunk-MYQWXITD.js.map → chunk-JIU55F3X.js.map} +0 -0
  147. /package/dist/{chunk-BTY5RRRF.js.map → chunk-N42IWANG.js.map} +0 -0
  148. /package/dist/{chunk-RCICHSHL.js.map → chunk-SYUK3VLY.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-MARWOCVP.js";
7
7
  import {
8
8
  validateBriefingFormat
9
- } from "./chunk-ECKDIK5F.js";
9
+ } from "./chunk-4LACOVZX.js";
10
10
 
11
11
  // src/access-mcp.ts
12
12
  import { readFile } from "fs/promises";
@@ -703,7 +703,45 @@ var EngramMcpServer = class {
703
703
  },
704
704
  additionalProperties: false
705
705
  }
706
- }] : []
706
+ }] : [],
707
+ // ── Contradiction Review (issue #520) ────────────────────────────────
708
+ {
709
+ name: "engram.review_list",
710
+ description: "List contradiction review items pending user resolution.",
711
+ inputSchema: {
712
+ type: "object",
713
+ properties: {
714
+ filter: { type: "string", enum: ["all", "unresolved", "contradicts", "independent", "duplicates", "needs-user"], description: "Filter by verdict type. Default: unresolved." },
715
+ namespace: { type: "string" },
716
+ limit: { type: "number", description: "Max items to return (default 50)." }
717
+ },
718
+ additionalProperties: false
719
+ }
720
+ },
721
+ {
722
+ name: "engram.review_resolve",
723
+ description: "Resolve a contradiction pair with a chosen verb.",
724
+ inputSchema: {
725
+ type: "object",
726
+ properties: {
727
+ pairId: { type: "string", description: "The contradiction pair ID to resolve." },
728
+ verb: { type: "string", enum: ["keep-a", "keep-b", "merge", "both-valid", "needs-more-context"], description: "Resolution action." }
729
+ },
730
+ required: ["pairId", "verb"],
731
+ additionalProperties: false
732
+ }
733
+ },
734
+ {
735
+ name: "engram.contradiction_scan_run",
736
+ description: "Run an on-demand contradiction scan over the memory corpus.",
737
+ inputSchema: {
738
+ type: "object",
739
+ properties: {
740
+ namespace: { type: "string" }
741
+ },
742
+ additionalProperties: false
743
+ }
744
+ }
707
745
  ].flatMap((tool) => withToolAliases(tool));
708
746
  }
709
747
  service;
@@ -1310,6 +1348,39 @@ ${body}`;
1310
1348
  principal: effectivePrincipal
1311
1349
  });
1312
1350
  }
1351
+ // ── Contradiction Review (issue #520) ──────────────────────────────────
1352
+ case "engram.review_list":
1353
+ case "remnic.review_list": {
1354
+ const { listPairs } = await import("./contradiction-review-WIUBAR52.js");
1355
+ const filter = typeof args.filter === "string" ? args.filter : "unresolved";
1356
+ const ns = typeof args.namespace === "string" ? args.namespace : void 0;
1357
+ const limit = typeof args.limit === "number" ? args.limit : 50;
1358
+ return listPairs(this.service.memoryDir, { filter, namespace: ns, limit });
1359
+ }
1360
+ case "engram.review_resolve":
1361
+ case "remnic.review_resolve": {
1362
+ const pairId = typeof args.pairId === "string" ? args.pairId : "";
1363
+ const verb = typeof args.verb === "string" ? args.verb : "";
1364
+ if (!pairId) throw new Error("pairId is required");
1365
+ if (!verb) throw new Error("verb is required");
1366
+ const { isValidResolutionVerb } = await import("./resolution-QBTDHTG7.js");
1367
+ if (!isValidResolutionVerb(verb)) throw new Error(`Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context`);
1368
+ const { executeResolution } = await import("./resolution-QBTDHTG7.js");
1369
+ return executeResolution(this.service.memoryDir, this.service.storageRef, pairId, verb);
1370
+ }
1371
+ case "engram.contradiction_scan_run":
1372
+ case "remnic.contradiction_scan_run": {
1373
+ const { runContradictionScan } = await import("./contradiction-scan-GR33PONM.js");
1374
+ return runContradictionScan({
1375
+ storage: this.service.storageRef,
1376
+ config: this.service.configRef,
1377
+ memoryDir: this.service.memoryDir,
1378
+ embeddingLookup: this.service.embeddingLookupRef,
1379
+ localLlm: this.service.localLlmRef,
1380
+ fallbackLlm: this.service.fallbackLlmRef,
1381
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0
1382
+ });
1383
+ }
1313
1384
  default:
1314
1385
  throw new Error(`unknown tool: ${name}`);
1315
1386
  }
@@ -1319,4 +1390,4 @@ ${body}`;
1319
1390
  export {
1320
1391
  EngramMcpServer
1321
1392
  };
1322
- //# sourceMappingURL=chunk-NSB3WSYS.js.map
1393
+ //# sourceMappingURL=chunk-NQEVYWX6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/access-mcp.ts"],"sourcesContent":["import type { Readable, Writable } from \"node:stream\";\nimport { readFile } from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport type { EngramAccessService, EngramAccessRecallResponse } from \"./access-service.js\";\nimport { readEnvVar } from \"./runtime/env.js\";\nimport type { RecallPlanMode } from \"./types.js\";\nimport { validateBriefingFormat } from \"./briefing.js\";\nimport { buildCitationGuidance, type CitationMetadata } from \"./citations.js\";\n\ntype JsonRpcId = string | number | null;\n\ntype JsonRpcRequest = {\n jsonrpc?: string;\n id?: JsonRpcId;\n method?: string;\n params?: Record<string, unknown>;\n};\n\ntype McpTool = {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n};\n\nconst MCP_PROTOCOL_VERSION = \"2024-11-05\";\nconst LEGACY_MCP_PREFIX = \"engram.\";\nconst CANONICAL_MCP_PREFIX = \"remnic.\";\n\nfunction toCanonicalToolName(name: string): string {\n return name.startsWith(LEGACY_MCP_PREFIX)\n ? `${CANONICAL_MCP_PREFIX}${name.slice(LEGACY_MCP_PREFIX.length)}`\n : name;\n}\n\nfunction toLegacyToolName(name: string): string {\n return name.startsWith(CANONICAL_MCP_PREFIX)\n ? `${LEGACY_MCP_PREFIX}${name.slice(CANONICAL_MCP_PREFIX.length)}`\n : name;\n}\n\nfunction withToolAliases(tool: McpTool): McpTool[] {\n const canonicalName = toCanonicalToolName(tool.name);\n const canonicalTool = canonicalName === tool.name ? tool : { ...tool, name: canonicalName };\n if (canonicalName === tool.name) return [canonicalTool];\n return [canonicalTool, tool];\n}\n\nasync function getMcpServerVersion(): Promise<string> {\n const envVersion =\n readEnvVar(\"OPENCLAW_ENGRAM_VERSION\")?.trim() ||\n readEnvVar(\"npm_package_version\")?.trim();\n if (envVersion) return envVersion;\n try {\n const pkgPath = new URL(\"../package.json\", import.meta.url);\n const raw = await readFile(pkgPath, \"utf-8\");\n const parsed = JSON.parse(raw) as { version?: string };\n return parsed.version?.trim() || \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport class EngramMcpServer {\n private buffer = Buffer.alloc(0);\n private flushTask: Promise<void> | null = null;\n private readonly tools: McpTool[];\n private readonly authenticatedPrincipal?: string;\n /**\n * MCP client info keyed by server-assigned session ID. On each `initialize`\n * handshake the server generates a UUID, stores the client's clientInfo\n * against it, and returns the ID as `Mcp-Session-Id` in the response\n * metadata. Subsequent requests from the same client include this header,\n * allowing per-session clientInfo lookup without cross-session leaks.\n */\n private clientInfoBySession = new Map<string, { name: string; version?: string }>();\n /**\n * Session IDs generated during initialize, keyed by caller-supplied correlation\n * ID (unique per HTTP request) to avoid collisions when multiple clients send\n * initialize with the same JSON-RPC id concurrently.\n */\n private initSessionIds = new Map<string, string>();\n\n /** Whether oai-mem-citation guidance is explicitly enabled via config. */\n private readonly citationsEnabled: boolean;\n /** Whether to auto-enable citations for Codex adapter connections. */\n private readonly citationsAutoDetect: boolean;\n\n constructor(\n private readonly service: EngramAccessService,\n options: { principal?: string; citationsEnabled?: boolean; citationsAutoDetect?: boolean } = {},\n ) {\n this.citationsEnabled = options.citationsEnabled === true;\n this.citationsAutoDetect = options.citationsAutoDetect !== false;\n this.authenticatedPrincipal =\n options.principal?.trim() ||\n readEnvVar(\"OPENCLAW_ENGRAM_ACCESS_PRINCIPAL\")?.trim() ||\n undefined;\n this.tools = [\n {\n name: \"engram.recall\",\n description: \"Recall Engram context for a query.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\" },\n sessionKey: { type: \"string\" },\n namespace: { type: \"string\" },\n topK: { type: \"number\" },\n mode: { type: \"string\", enum: [\"auto\", \"no_recall\", \"minimal\", \"full\", \"graph_mode\"] },\n includeDebug: { type: \"boolean\" },\n },\n required: [\"query\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.recall_explain\",\n description: \"Return the last recall snapshot for a session or the most recent one.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionKey: { type: \"string\" },\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.day_summary\",\n description:\n \"Generate a structured end-of-day summary. When memories is omitted or empty, auto-gathers today's facts and hourly summaries from storage.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memories: { type: \"string\" },\n sessionKey: { type: \"string\" },\n namespace: { type: \"string\" },\n },\n required: [],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_governance_run\",\n description: \"Run Remnic memory governance in a bounded shadow/apply pass.\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n mode: { type: \"string\", enum: [\"shadow\", \"apply\"] },\n recentDays: { type: \"number\" },\n maxMemories: { type: \"number\" },\n batchSize: { type: \"number\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.procedure_mining_run\",\n description:\n \"Run procedural memory mining from causal trajectories (issue #519). Respects procedural.enabled; writes under procedures/ when clusters qualify.\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_get\",\n description: \"Fetch one Remnic memory by id.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryId: { type: \"string\" },\n namespace: { type: \"string\" },\n },\n required: [\"memoryId\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_timeline\",\n description: \"Fetch one Remnic memory timeline by id.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryId: { type: \"string\" },\n namespace: { type: \"string\" },\n limit: { type: \"number\" },\n },\n required: [\"memoryId\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_store\",\n description: \"Store an explicit Remnic memory through the access layer.\",\n inputSchema: {\n type: \"object\",\n properties: {\n schemaVersion: { type: \"number\" },\n idempotencyKey: { type: \"string\" },\n dryRun: { type: \"boolean\" },\n sessionKey: { type: \"string\" },\n content: { type: \"string\" },\n category: { type: \"string\" },\n confidence: { type: \"number\" },\n namespace: { type: \"string\" },\n tags: { type: \"array\", items: { type: \"string\" } },\n entityRef: { type: \"string\" },\n ttl: { type: \"string\" },\n sourceReason: { type: \"string\" },\n },\n required: [\"content\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.suggestion_submit\",\n description: \"Queue a suggested Remnic memory for review.\",\n inputSchema: {\n type: \"object\",\n properties: {\n schemaVersion: { type: \"number\" },\n idempotencyKey: { type: \"string\" },\n dryRun: { type: \"boolean\" },\n sessionKey: { type: \"string\" },\n content: { type: \"string\" },\n category: { type: \"string\" },\n confidence: { type: \"number\" },\n namespace: { type: \"string\" },\n tags: { type: \"array\", items: { type: \"string\" } },\n entityRef: { type: \"string\" },\n ttl: { type: \"string\" },\n sourceReason: { type: \"string\" },\n },\n required: [\"content\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.entity_get\",\n description: \"Fetch one Engram entity by name.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n namespace: { type: \"string\" },\n },\n required: [\"name\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.review_queue_list\",\n description: \"Fetch the latest Engram review queue artifact bundle.\",\n inputSchema: {\n type: \"object\",\n properties: {\n runId: { type: \"string\" },\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.observe\",\n description: \"Feed conversation messages into Engram's memory pipeline (LCM archive + extraction).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionKey: { type: \"string\", description: \"Conversation session identifier\" },\n messages: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"user\", \"assistant\"] },\n content: { type: \"string\" },\n },\n required: [\"role\", \"content\"],\n },\n description: \"Conversation messages to observe\",\n },\n namespace: { type: \"string\" },\n skipExtraction: { type: \"boolean\" },\n },\n required: [\"sessionKey\", \"messages\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.lcm_search\",\n description: \"Search the LCM conversation archive for matching content.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n sessionKey: { type: \"string\", description: \"Optional session filter\" },\n namespace: { type: \"string\" },\n limit: { type: \"number\", description: \"Max results to return\" },\n },\n required: [\"query\"],\n additionalProperties: false,\n },\n },\n // ── Continuity / Identity tools ─────────────────────────────────────\n {\n name: \"engram.continuity_audit_generate\",\n description: \"Generate a deterministic identity continuity audit report (weekly/monthly).\",\n inputSchema: {\n type: \"object\",\n properties: {\n period: { type: \"string\", enum: [\"weekly\", \"monthly\"] },\n key: { type: \"string\", description: \"Period key (weekly: YYYY-Www, monthly: YYYY-MM). Defaults to current.\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.continuity_incident_open\",\n description: \"Create a new continuity incident record in append-only storage.\",\n inputSchema: {\n type: \"object\",\n properties: {\n symptom: { type: \"string\", description: \"Observed continuity failure symptom.\" },\n namespace: { type: \"string\" },\n triggerWindow: { type: \"string\", description: \"Time window when incident occurred.\" },\n suspectedCause: { type: \"string\" },\n },\n required: [\"symptom\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.continuity_incident_close\",\n description: \"Close an open continuity incident with verification details.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Incident ID to close.\" },\n namespace: { type: \"string\" },\n fixApplied: { type: \"string\", description: \"What fix was applied.\" },\n verificationResult: { type: \"string\", description: \"How closure was verified.\" },\n preventiveRule: { type: \"string\", description: \"Optional preventive follow-up rule.\" },\n },\n required: [\"id\", \"fixApplied\", \"verificationResult\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.continuity_incident_list\",\n description: \"List continuity incidents, optionally filtered by state.\",\n inputSchema: {\n type: \"object\",\n properties: {\n state: { type: \"string\", enum: [\"open\", \"closed\", \"all\"] },\n namespace: { type: \"string\" },\n limit: { type: \"number\", description: \"Max incidents (default 25, max 200).\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.continuity_loop_add_or_update\",\n description: \"Add or update a continuity improvement loop entry.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Stable loop identifier.\" },\n cadence: { type: \"string\", enum: [\"daily\", \"weekly\", \"monthly\", \"quarterly\"] },\n purpose: { type: \"string\", description: \"What this recurring loop improves.\" },\n status: { type: \"string\", enum: [\"active\", \"paused\", \"retired\"] },\n killCondition: { type: \"string\", description: \"Clear condition for retiring this loop.\" },\n namespace: { type: \"string\" },\n lastReviewed: { type: \"string\", description: \"ISO timestamp for last review.\" },\n notes: { type: \"string\" },\n },\n required: [\"id\", \"cadence\", \"purpose\", \"status\", \"killCondition\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.continuity_loop_review\",\n description: \"Update review metadata for an existing continuity improvement loop.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Loop ID to review.\" },\n namespace: { type: \"string\" },\n status: { type: \"string\", enum: [\"active\", \"paused\", \"retired\"] },\n notes: { type: \"string\" },\n reviewedAt: { type: \"string\", description: \"ISO timestamp for review event.\" },\n },\n required: [\"id\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.identity_anchor_get\",\n description: \"Read the identity continuity anchor document (recovery-safe identity context).\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.identity_anchor_update\",\n description: \"Conservatively merge identity anchor sections without overwriting existing material.\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n identityTraits: { type: \"string\", description: \"Updates for 'Identity Traits' section.\" },\n communicationPreferences: { type: \"string\", description: \"Updates for 'Communication Preferences' section.\" },\n operatingPrinciples: { type: \"string\", description: \"Updates for 'Operating Principles' section.\" },\n continuityNotes: { type: \"string\", description: \"Updates for 'Continuity Notes' section.\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_identity\",\n description: \"Read the agent's identity reflections from the workspace IDENTITY.md file.\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n // ── Work Layer tools ─────────────────────────────────────────────────\n {\n name: \"engram.work_task\",\n description: \"Manage work-layer tasks (create, get, list, update, transition, delete). Excluded from memory extraction.\",\n inputSchema: {\n type: \"object\",\n properties: {\n action: { type: \"string\", enum: [\"create\", \"get\", \"list\", \"update\", \"transition\", \"delete\"] },\n id: { type: \"string\" },\n title: { type: \"string\" },\n description: { type: \"string\" },\n status: { type: \"string\", enum: [\"todo\", \"in_progress\", \"blocked\", \"done\", \"cancelled\"] },\n priority: { type: \"string\", enum: [\"low\", \"medium\", \"high\"] },\n owner: { type: \"string\" },\n assignee: { type: \"string\" },\n projectId: { type: \"string\" },\n tags: { type: \"array\", items: { type: \"string\" } },\n dueAt: { type: \"string\" },\n },\n required: [\"action\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.work_project\",\n description: \"Manage work-layer projects (create, get, list, update, delete, link_task). Excluded from memory extraction.\",\n inputSchema: {\n type: \"object\",\n properties: {\n action: { type: \"string\", enum: [\"create\", \"get\", \"list\", \"update\", \"delete\", \"link_task\"] },\n id: { type: \"string\" },\n name: { type: \"string\" },\n description: { type: \"string\" },\n status: { type: \"string\", enum: [\"active\", \"on_hold\", \"completed\", \"archived\"] },\n owner: { type: \"string\" },\n tags: { type: \"array\", items: { type: \"string\" } },\n taskId: { type: \"string\", description: \"Task ID for link_task.\" },\n projectId: { type: \"string\", description: \"Project ID for link_task.\" },\n },\n required: [\"action\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.work_board\",\n description: \"Export/import work-layer board snapshots and markdown.\",\n inputSchema: {\n type: \"object\",\n properties: {\n action: { type: \"string\", enum: [\"export_markdown\", \"export_snapshot\", \"import_snapshot\"] },\n projectId: { type: \"string\" },\n snapshotJson: { type: \"string\", description: \"Snapshot JSON for import_snapshot.\" },\n linkToMemory: { type: \"boolean\", description: \"If true, output can be retained as long-term memory.\" },\n },\n required: [\"action\"],\n additionalProperties: false,\n },\n },\n // ── Shared Context / Compounding tools ────────────────────────────\n {\n name: \"engram.shared_context_write_output\",\n description: \"Write agent work product into shared-context directory for cross-agent coordination.\",\n inputSchema: {\n type: \"object\",\n properties: {\n agentId: { type: \"string\", description: \"Agent ID producing this output.\" },\n title: { type: \"string\", description: \"Short title for the output.\" },\n content: { type: \"string\", description: \"Markdown content to write.\" },\n },\n required: [\"agentId\", \"title\", \"content\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.shared_feedback_record\",\n description: \"Append approval/rejection decision into shared-context feedback inbox for compounding learning.\",\n inputSchema: {\n type: \"object\",\n properties: {\n agent: { type: \"string\", description: \"Agent name that produced the output.\" },\n decision: { type: \"string\", enum: [\"approved\", \"approved_with_feedback\", \"rejected\"] },\n reason: { type: \"string\" },\n date: { type: \"string\", description: \"ISO timestamp. Defaults to now.\" },\n learning: { type: \"string\" },\n outcome: { type: \"string\" },\n severity: { type: \"string\", enum: [\"low\", \"medium\", \"high\"] },\n confidence: { type: \"number\", description: \"Confidence 0-1.\" },\n workflow: { type: \"string\" },\n tags: { type: \"array\", items: { type: \"string\" } },\n evidenceWindowStart: { type: \"string\" },\n evidenceWindowEnd: { type: \"string\" },\n refs: { type: \"array\", items: { type: \"string\" } },\n },\n required: [\"agent\", \"decision\", \"reason\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.shared_priorities_append\",\n description: \"Append priorities text into shared-context inbox for curator merge.\",\n inputSchema: {\n type: \"object\",\n properties: {\n agentId: { type: \"string\" },\n text: { type: \"string\", description: \"Priority notes (markdown).\" },\n },\n required: [\"agentId\", \"text\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.shared_context_cross_signals_run\",\n description: \"Generate cross-signal markdown + JSON artifacts from agent outputs and feedback.\",\n inputSchema: {\n type: \"object\",\n properties: {\n date: { type: \"string\", description: \"YYYY-MM-DD. Defaults to today.\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.shared_context_curate_daily\",\n description: \"Generate daily roundtable summary (deterministic baseline aggregation).\",\n inputSchema: {\n type: \"object\",\n properties: {\n date: { type: \"string\", description: \"YYYY-MM-DD. Defaults to today.\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.compounding_weekly_synthesize\",\n description: \"Generate weekly compounding outputs: reports, mistake registry, rubrics, and promotion candidates.\",\n inputSchema: {\n type: \"object\",\n properties: {\n weekId: { type: \"string\", description: \"ISO week ID (YYYY-Www). Defaults to current week.\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.compounding_promote_candidate\",\n description: \"Promote a compounding candidate from weekly report into durable rule/principle memory.\",\n inputSchema: {\n type: \"object\",\n properties: {\n weekId: { type: \"string\" },\n candidateId: { type: \"string\" },\n dryRun: { type: \"boolean\", description: \"Preview without writing.\" },\n },\n required: [\"weekId\", \"candidateId\"],\n additionalProperties: false,\n },\n },\n // ── Compression Guidelines tools ────────────────────────────────────\n {\n name: \"engram.compression_guidelines_optimize\",\n description: \"Run compression guideline optimizer, optionally persisting new guidelines.\",\n inputSchema: {\n type: \"object\",\n properties: {\n dryRun: { type: \"boolean\" },\n eventLimit: { type: \"number\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.compression_guidelines_activate\",\n description: \"Promote staged compression guideline draft to active (after review).\",\n inputSchema: {\n type: \"object\",\n properties: {\n expectedContentHash: { type: \"string\" },\n expectedGuidelineVersion: { type: \"number\" },\n },\n additionalProperties: false,\n },\n },\n // ── Memory search & debug tools ────────────────────────────────────\n {\n name: \"engram.memory_search\",\n description: \"Direct semantic search over memory files using the QMD index. Returns matching memories with relevance scores.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\" },\n namespace: { type: \"string\" },\n maxResults: { type: \"number\" },\n collection: { type: \"string\", description: \"QMD collection (omit for memory, 'global' for all)\" },\n },\n required: [\"query\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_profile\",\n description: \"Read the user's behavioral profile — a living document of their preferences, habits, and personality.\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_entities_list\",\n description: \"List all tracked entities (people, projects, tools, companies).\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_questions\",\n description: \"List open questions the system is curious about from past conversations.\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_last_recall\",\n description: \"Return the last recall snapshot for a session (debug introspection).\",\n inputSchema: {\n type: \"object\",\n properties: { sessionKey: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_intent_debug\",\n description: \"Return the last intent classification debug snapshot.\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_qmd_debug\",\n description: \"Return QMD search index debug information from the last recall.\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_graph_explain\",\n description: \"Explain the last entity graph recall — which entities were activated and why.\",\n inputSchema: {\n type: \"object\",\n properties: { namespace: { type: \"string\" } },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_feedback\",\n description: \"Record relevance feedback (thumbs up/down) for a specific memory.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryId: { type: \"string\" },\n vote: { type: \"string\", enum: [\"up\", \"down\"] },\n note: { type: \"string\" },\n },\n required: [\"memoryId\", \"vote\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.memory_promote\",\n description: \"Promote a memory's lifecycle state (e.g. from draft to active).\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryId: { type: \"string\" },\n namespace: { type: \"string\" },\n sessionKey: { type: \"string\" },\n },\n required: [\"memoryId\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.context_checkpoint\",\n description: \"Save a structured context checkpoint for a session (preserves conversation state to disk).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionKey: { type: \"string\" },\n context: { type: \"string\", description: \"Context content to checkpoint\" },\n namespace: { type: \"string\" },\n },\n required: [\"sessionKey\", \"context\"],\n additionalProperties: false,\n },\n },\n // ── Daily Context Briefing (#370) ───────────────────────────────────\n // Uses the legacy \"engram.*\" prefix like every other tool in this array;\n // withToolAliases (applied via .flatMap below) generates the canonical\n // \"remnic.briefing\" alias automatically.\n ...(service.briefingEnabled ? [{\n name: \"engram.briefing\",\n description: \"Generate a daily context briefing by cross-referencing active entities, recent facts, open commitments, and optional calendar events.\",\n inputSchema: {\n type: \"object\",\n properties: {\n since: { type: \"string\", description: \"Lookback window (e.g. 'yesterday', '3d', '1w', '24h').\" },\n focus: { type: \"string\", description: \"Optional focus filter (e.g. 'person:Jane Doe', 'project:remnic-core', 'topic:retrieval').\" },\n namespace: { type: \"string\" },\n format: { type: \"string\", enum: [\"markdown\", \"json\"] },\n maxFollowups: { type: \"number\", description: \"Maximum LLM-suggested follow-ups (0 disables that section).\" },\n },\n additionalProperties: false,\n },\n }] : []),\n // ── Contradiction Review (issue #520) ────────────────────────────────\n {\n name: \"engram.review_list\",\n description: \"List contradiction review items pending user resolution.\",\n inputSchema: {\n type: \"object\",\n properties: {\n filter: { type: \"string\", enum: [\"all\", \"unresolved\", \"contradicts\", \"independent\", \"duplicates\", \"needs-user\"], description: \"Filter by verdict type. Default: unresolved.\" },\n namespace: { type: \"string\" },\n limit: { type: \"number\", description: \"Max items to return (default 50).\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"engram.review_resolve\",\n description: \"Resolve a contradiction pair with a chosen verb.\",\n inputSchema: {\n type: \"object\",\n properties: {\n pairId: { type: \"string\", description: \"The contradiction pair ID to resolve.\" },\n verb: { type: \"string\", enum: [\"keep-a\", \"keep-b\", \"merge\", \"both-valid\", \"needs-more-context\"], description: \"Resolution action.\" },\n },\n required: [\"pairId\", \"verb\"],\n additionalProperties: false,\n },\n },\n {\n name: \"engram.contradiction_scan_run\",\n description: \"Run an on-demand contradiction scan over the memory corpus.\",\n inputSchema: {\n type: \"object\",\n properties: {\n namespace: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n ].flatMap((tool) => withToolAliases(tool));\n }\n\n /** Get clientInfo for a specific MCP session. Returns undefined for non-MCP requests. */\n getClientInfo(sessionId?: string): { name: string; version?: string } | undefined {\n if (sessionId) {\n return this.clientInfoBySession.get(sessionId);\n }\n return undefined;\n }\n\n /** Pop the session ID generated during an initialize handshake, keyed by correlation ID. */\n popInitSessionId(correlationId: string): string | undefined {\n const sid = this.initSessionIds.get(correlationId);\n if (sid !== undefined) this.initSessionIds.delete(correlationId);\n return sid;\n }\n\n async handleRequest(request: JsonRpcRequest, options?: { principalOverride?: string; sessionId?: string; correlationId?: string }): Promise<Record<string, unknown> | null> {\n const id = request.id ?? null;\n const method = request.method ?? \"\";\n\n if (method === \"notifications/initialized\") return null;\n if (method === \"ping\") {\n return { jsonrpc: \"2.0\", id, result: {} };\n }\n if (method === \"initialize\") {\n const params = request.params ?? {};\n const rawClientInfo = params.clientInfo as { name?: string; version?: string } | undefined;\n // Generate a server-side session ID for this MCP session.\n // The caller should send this back as Mcp-Session-Id on subsequent requests.\n const newSessionId = randomUUID();\n if (rawClientInfo && typeof rawClientInfo.name === \"string\") {\n const info = { name: rawClientInfo.name, version: rawClientInfo.version as string | undefined };\n this.clientInfoBySession.set(newSessionId, info);\n // Evict oldest sessions if map exceeds limit\n if (this.clientInfoBySession.size > 1000) {\n const firstKey = this.clientInfoBySession.keys().next().value;\n if (firstKey) this.clientInfoBySession.delete(firstKey);\n }\n }\n const version = await getMcpServerVersion();\n // Store session ID keyed by correlation ID (unique per HTTP request) so\n // concurrent initializes with the same JSON-RPC id don't collide.\n const corrId = options?.correlationId;\n if (corrId) this.initSessionIds.set(corrId, newSessionId);\n return {\n jsonrpc: \"2.0\",\n id,\n result: {\n protocolVersion: MCP_PROTOCOL_VERSION,\n capabilities: {\n tools: {},\n },\n serverInfo: {\n name: \"remnic\",\n version,\n },\n },\n };\n }\n if (method === \"tools/list\") {\n return {\n jsonrpc: \"2.0\",\n id,\n result: {\n tools: this.tools,\n },\n };\n }\n if (method === \"tools/call\") {\n const params = request.params ?? {};\n const name = typeof params.name === \"string\" ? params.name : \"\";\n const argumentsObject =\n params.arguments && typeof params.arguments === \"object\" && !Array.isArray(params.arguments)\n ? (params.arguments as Record<string, unknown>)\n : {};\n\n try {\n const effectivePrincipal = options?.principalOverride ?? this.authenticatedPrincipal;\n const result = await this.callTool(name, argumentsObject, effectivePrincipal, options?.sessionId);\n return {\n jsonrpc: \"2.0\",\n id,\n result: {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }],\n structuredContent: result,\n isError: false,\n },\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n jsonrpc: \"2.0\",\n id,\n result: {\n content: [{ type: \"text\", text: message }],\n isError: true,\n },\n };\n }\n }\n\n return {\n jsonrpc: \"2.0\",\n id,\n error: {\n code: -32601,\n message: `Method not found: ${method}`,\n },\n };\n }\n\n async runStdio(input: Readable, output: Writable): Promise<void> {\n input.on(\"data\", (chunk) => {\n this.buffer = Buffer.concat([this.buffer, Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)]);\n this.scheduleFlush(output);\n });\n await new Promise<void>((resolve, reject) => {\n input.on(\"end\", resolve);\n input.on(\"error\", reject);\n });\n while (this.flushTask) {\n await this.flushTask;\n }\n }\n\n private scheduleFlush(output: Writable): void {\n if (this.flushTask) return;\n const task = this.flushBuffer(output)\n .catch((err) => {\n this.writeMessage(output, {\n jsonrpc: \"2.0\",\n id: null,\n error: {\n code: -32700,\n message: err instanceof Error ? err.message : String(err),\n },\n });\n })\n .finally(() => {\n if (this.flushTask === task) {\n this.flushTask = null;\n }\n if (this.buffer.length > 0) {\n this.scheduleFlush(output);\n }\n });\n this.flushTask = task;\n }\n\n private async flushBuffer(output: Writable): Promise<void> {\n while (true) {\n const headerEnd = this.buffer.indexOf(\"\\r\\n\\r\\n\");\n if (headerEnd < 0) return;\n const headerText = this.buffer.slice(0, headerEnd).toString(\"utf-8\");\n const headers = headerText.split(\"\\r\\n\");\n const contentLengthHeader = headers.find((line) => line.toLowerCase().startsWith(\"content-length:\"));\n if (!contentLengthHeader) {\n this.buffer = Buffer.alloc(0);\n return;\n }\n const contentLength = parseInt(contentLengthHeader.split(\":\")[1]?.trim() ?? \"0\", 10);\n if (!Number.isFinite(contentLength) || contentLength < 0) {\n this.buffer = Buffer.alloc(0);\n return;\n }\n const messageStart = headerEnd + 4;\n const messageEnd = messageStart + contentLength;\n if (this.buffer.length < messageEnd) return;\n const body = this.buffer.slice(messageStart, messageEnd).toString(\"utf-8\");\n this.buffer = this.buffer.slice(messageEnd);\n\n let parsed: JsonRpcRequest;\n try {\n parsed = JSON.parse(body) as JsonRpcRequest;\n } catch {\n this.writeMessage(output, {\n jsonrpc: \"2.0\",\n id: null,\n error: {\n code: -32700,\n message: \"Parse error\",\n },\n });\n continue;\n }\n const response = await this.handleRequest(parsed);\n if (response) {\n this.writeMessage(output, response);\n }\n }\n }\n\n private writeMessage(output: Writable, payload: Record<string, unknown>): void {\n const body = JSON.stringify(payload);\n const message = `Content-Length: ${Buffer.byteLength(body, \"utf-8\")}\\r\\n\\r\\n${body}`;\n output.write(message);\n }\n\n /**\n * Determine whether oai-mem-citation guidance should be appended to recall.\n * Returns true when explicitly enabled via config OR when auto-detect is\n * active and the current MCP session belongs to a Codex adapter client.\n *\n * When no sessionId is provided (e.g., stdio transport where there are no\n * HTTP headers carrying mcp-session-id), fall back to checking if there is\n * exactly one known session whose clientInfo matches the Codex pattern.\n * This covers the common stdio case where a single client connection exists.\n */\n private shouldEmitCitations(mcpSessionId?: string): boolean {\n if (this.citationsEnabled) return true;\n if (!this.citationsAutoDetect) return false;\n\n // Direct session lookup (HTTP transport with mcp-session-id header).\n if (mcpSessionId) {\n const info = this.clientInfoBySession.get(mcpSessionId);\n if (!info) return false;\n return this.isCodexClient(info);\n }\n\n // Stdio fallback: no session ID available. If there is exactly one session\n // registered (the typical stdio pattern), check that session's clientInfo.\n if (this.clientInfoBySession.size === 1) {\n const [info] = [...this.clientInfoBySession.values()];\n if (info) return this.isCodexClient(info);\n }\n\n return false;\n }\n\n /** Check whether a clientInfo record identifies a Codex adapter client. */\n private isCodexClient(info: { name: string; version?: string }): boolean {\n const lowerName = info.name.toLowerCase();\n return lowerName === \"codex-mcp-client\" || lowerName.includes(\"codex\");\n }\n\n /**\n * Build citation metadata for each recall result that has a path.\n * Line range defaults to 1-1 when not determinable from the summary.\n */\n private buildRecallCitations(response: EngramAccessRecallResponse): CitationMetadata[] {\n return response.results\n .filter((r) => r.path && r.path.length > 0)\n .map((r) => ({\n memoryId: r.id,\n path: r.path,\n lineStart: 1,\n lineEnd: 1,\n noteDefault: r.preview?.slice(0, 60) || r.id,\n }));\n }\n\n private async callTool(name: string, args: Record<string, unknown>, effectivePrincipal?: string, mcpSessionId?: string): Promise<unknown> {\n switch (toLegacyToolName(name)) {\n case \"engram.recall\": {\n const response = await this.service.recall({\n query: typeof args.query === \"string\" ? args.query : \"\",\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n topK: typeof args.topK === \"number\" && Number.isFinite(args.topK) ? args.topK : undefined,\n mode: typeof args.mode === \"string\" ? args.mode as RecallPlanMode | \"auto\" : undefined,\n includeDebug: args.includeDebug === true,\n });\n\n if (this.shouldEmitCitations(mcpSessionId)) {\n const citations = this.buildRecallCitations(response);\n const guidance = buildCitationGuidance(citations);\n if (guidance.length > 0) {\n return {\n ...response,\n context: response.context + guidance,\n citations,\n };\n }\n }\n return response;\n }\n case \"engram.recall_explain\":\n return this.service.recallExplain({\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n });\n case \"engram.day_summary\":\n return this.service.daySummary({\n memories: typeof args.memories === \"string\" ? args.memories : \"\",\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n });\n case \"engram.memory_governance_run\":\n return this.service.governanceRun({\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n mode: args.mode === \"apply\" ? \"apply\" : \"shadow\",\n recentDays: typeof args.recentDays === \"number\" && Number.isFinite(args.recentDays) ? args.recentDays : undefined,\n maxMemories: typeof args.maxMemories === \"number\" && Number.isFinite(args.maxMemories) ? args.maxMemories : undefined,\n batchSize: typeof args.batchSize === \"number\" && Number.isFinite(args.batchSize) ? args.batchSize : undefined,\n authenticatedPrincipal: effectivePrincipal,\n }, effectivePrincipal);\n case \"engram.procedure_mining_run\":\n return this.service.procedureMiningRun(\n {\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n authenticatedPrincipal: effectivePrincipal,\n },\n effectivePrincipal,\n );\n case \"engram.memory_get\":\n return this.service.memoryGet(\n typeof args.memoryId === \"string\" ? args.memoryId : \"\",\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n effectivePrincipal,\n );\n case \"engram.memory_timeline\": {\n const limit = typeof args.limit === \"number\" && Number.isFinite(args.limit) ? args.limit : 200;\n return this.service.memoryTimeline(\n typeof args.memoryId === \"string\" ? args.memoryId : \"\",\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n limit,\n effectivePrincipal,\n );\n }\n case \"engram.memory_store\":\n return this.service.memoryStore({\n schemaVersion: typeof args.schemaVersion === \"number\" ? args.schemaVersion : undefined,\n idempotencyKey: typeof args.idempotencyKey === \"string\" ? args.idempotencyKey : undefined,\n dryRun: args.dryRun === true,\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n authenticatedPrincipal: effectivePrincipal,\n content: typeof args.content === \"string\" ? args.content : \"\",\n category: typeof args.category === \"string\" ? args.category : undefined,\n confidence: typeof args.confidence === \"number\" ? args.confidence : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n tags: Array.isArray(args.tags) ? args.tags.filter((tag): tag is string => typeof tag === \"string\") : undefined,\n entityRef: typeof args.entityRef === \"string\" ? args.entityRef : undefined,\n ttl: typeof args.ttl === \"string\" ? args.ttl : undefined,\n sourceReason: typeof args.sourceReason === \"string\" ? args.sourceReason : undefined,\n });\n case \"engram.suggestion_submit\":\n return this.service.suggestionSubmit({\n schemaVersion: typeof args.schemaVersion === \"number\" ? args.schemaVersion : undefined,\n idempotencyKey: typeof args.idempotencyKey === \"string\" ? args.idempotencyKey : undefined,\n dryRun: args.dryRun === true,\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n authenticatedPrincipal: effectivePrincipal,\n content: typeof args.content === \"string\" ? args.content : \"\",\n category: typeof args.category === \"string\" ? args.category : undefined,\n confidence: typeof args.confidence === \"number\" ? args.confidence : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n tags: Array.isArray(args.tags) ? args.tags.filter((tag): tag is string => typeof tag === \"string\") : undefined,\n entityRef: typeof args.entityRef === \"string\" ? args.entityRef : undefined,\n ttl: typeof args.ttl === \"string\" ? args.ttl : undefined,\n sourceReason: typeof args.sourceReason === \"string\" ? args.sourceReason : undefined,\n });\n case \"engram.entity_get\":\n return this.service.entityGet(\n typeof args.name === \"string\" ? args.name : \"\",\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n );\n case \"engram.review_queue_list\":\n return this.service.reviewQueue(\n typeof args.runId === \"string\" ? args.runId : undefined,\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n effectivePrincipal,\n );\n case \"engram.observe\":\n return this.service.observe({\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : \"\",\n messages: Array.isArray(args.messages) ? args.messages : [],\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n authenticatedPrincipal: effectivePrincipal,\n skipExtraction: args.skipExtraction === true,\n });\n case \"engram.lcm_search\":\n return this.service.lcmSearch({\n query: typeof args.query === \"string\" ? args.query : \"\",\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n limit: typeof args.limit === \"number\" && Number.isFinite(args.limit) ? args.limit : undefined,\n authenticatedPrincipal: effectivePrincipal,\n });\n // ── Continuity / Identity tools ───────────────────────────────────\n case \"engram.continuity_audit_generate\":\n return this.service.continuityAuditGenerate({\n period: args.period === \"monthly\" ? \"monthly\" : args.period === \"weekly\" ? \"weekly\" : undefined,\n key: typeof args.key === \"string\" ? args.key : undefined,\n });\n case \"engram.continuity_incident_open\":\n return this.service.continuityIncidentOpen({\n symptom: typeof args.symptom === \"string\" ? args.symptom : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n triggerWindow: typeof args.triggerWindow === \"string\" ? args.triggerWindow : undefined,\n suspectedCause: typeof args.suspectedCause === \"string\" ? args.suspectedCause : undefined,\n });\n case \"engram.continuity_incident_close\":\n return this.service.continuityIncidentClose({\n id: typeof args.id === \"string\" ? args.id : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n fixApplied: typeof args.fixApplied === \"string\" ? args.fixApplied : \"\",\n verificationResult: typeof args.verificationResult === \"string\" ? args.verificationResult : \"\",\n preventiveRule: typeof args.preventiveRule === \"string\" ? args.preventiveRule : undefined,\n });\n case \"engram.continuity_incident_list\":\n return this.service.continuityIncidentList({\n state: args.state === \"closed\" ? \"closed\" : args.state === \"all\" ? \"all\" : args.state === \"open\" ? \"open\" : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n limit: typeof args.limit === \"number\" ? args.limit : undefined,\n });\n case \"engram.continuity_loop_add_or_update\":\n return this.service.continuityLoopAddOrUpdate({\n id: typeof args.id === \"string\" ? args.id : \"\",\n cadence: (args.cadence as \"daily\" | \"weekly\" | \"monthly\" | \"quarterly\") ?? \"weekly\",\n purpose: typeof args.purpose === \"string\" ? args.purpose : \"\",\n status: (args.status as \"active\" | \"paused\" | \"retired\") ?? \"active\",\n killCondition: typeof args.killCondition === \"string\" ? args.killCondition : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n lastReviewed: typeof args.lastReviewed === \"string\" ? args.lastReviewed : undefined,\n notes: typeof args.notes === \"string\" ? args.notes : undefined,\n });\n case \"engram.continuity_loop_review\":\n return this.service.continuityLoopReview({\n id: typeof args.id === \"string\" ? args.id : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n status: args.status === \"active\" || args.status === \"paused\" || args.status === \"retired\" ? args.status : undefined,\n notes: typeof args.notes === \"string\" ? args.notes : undefined,\n reviewedAt: typeof args.reviewedAt === \"string\" ? args.reviewedAt : undefined,\n });\n case \"engram.identity_anchor_get\":\n return this.service.identityAnchorGet({\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n });\n case \"engram.identity_anchor_update\":\n return this.service.identityAnchorUpdate({\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n identityTraits: typeof args.identityTraits === \"string\" ? args.identityTraits : undefined,\n communicationPreferences: typeof args.communicationPreferences === \"string\" ? args.communicationPreferences : undefined,\n operatingPrinciples: typeof args.operatingPrinciples === \"string\" ? args.operatingPrinciples : undefined,\n continuityNotes: typeof args.continuityNotes === \"string\" ? args.continuityNotes : undefined,\n });\n case \"engram.memory_identity\":\n return this.service.memoryIdentity({\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n });\n // ── Work Layer tools ──────────────────────────────────────────────\n case \"engram.work_task\":\n return this.service.workTask({\n action: (args.action as any) ?? \"list\",\n id: typeof args.id === \"string\" ? args.id : undefined,\n title: typeof args.title === \"string\" ? args.title : undefined,\n description: typeof args.description === \"string\" ? args.description : undefined,\n status: typeof args.status === \"string\" ? args.status : undefined,\n priority: typeof args.priority === \"string\" ? args.priority : undefined,\n owner: typeof args.owner === \"string\" ? args.owner : undefined,\n assignee: typeof args.assignee === \"string\" ? args.assignee : undefined,\n projectId: typeof args.projectId === \"string\" ? args.projectId : undefined,\n tags: Array.isArray(args.tags) ? args.tags.filter((x: unknown): x is string => typeof x === \"string\") : undefined,\n dueAt: typeof args.dueAt === \"string\" ? args.dueAt : undefined,\n });\n case \"engram.work_project\":\n return this.service.workProject({\n action: (args.action as any) ?? \"list\",\n id: typeof args.id === \"string\" ? args.id : undefined,\n name: typeof args.name === \"string\" ? args.name : undefined,\n description: typeof args.description === \"string\" ? args.description : undefined,\n status: typeof args.status === \"string\" ? args.status : undefined,\n owner: typeof args.owner === \"string\" ? args.owner : undefined,\n tags: Array.isArray(args.tags) ? args.tags.filter((x: unknown): x is string => typeof x === \"string\") : undefined,\n taskId: typeof args.taskId === \"string\" ? args.taskId : undefined,\n projectId: typeof args.projectId === \"string\" ? args.projectId : undefined,\n });\n case \"engram.work_board\":\n return this.service.workBoard({\n action: (args.action as any) ?? \"export_markdown\",\n projectId: typeof args.projectId === \"string\" ? args.projectId : undefined,\n snapshotJson: typeof args.snapshotJson === \"string\" ? args.snapshotJson : undefined,\n linkToMemory: args.linkToMemory === true,\n });\n // ── Shared Context / Compounding tools ─────────────────────────\n case \"engram.shared_context_write_output\":\n return this.service.sharedContextWriteOutput({\n agentId: typeof args.agentId === \"string\" ? args.agentId : \"\",\n title: typeof args.title === \"string\" ? args.title : \"\",\n content: typeof args.content === \"string\" ? args.content : \"\",\n });\n case \"engram.shared_feedback_record\":\n return this.service.sharedFeedbackRecord({\n agent: typeof args.agent === \"string\" ? args.agent : \"\",\n decision: (args.decision as any) ?? \"approved\",\n reason: typeof args.reason === \"string\" ? args.reason : \"\",\n date: typeof args.date === \"string\" ? args.date : undefined,\n learning: typeof args.learning === \"string\" ? args.learning : undefined,\n outcome: typeof args.outcome === \"string\" ? args.outcome : undefined,\n severity: args.severity === \"low\" || args.severity === \"medium\" || args.severity === \"high\" ? args.severity : undefined,\n confidence: typeof args.confidence === \"number\" ? args.confidence : undefined,\n workflow: typeof args.workflow === \"string\" ? args.workflow : undefined,\n tags: Array.isArray(args.tags) ? args.tags.filter((x: unknown): x is string => typeof x === \"string\") : undefined,\n evidenceWindowStart: typeof args.evidenceWindowStart === \"string\" ? args.evidenceWindowStart : undefined,\n evidenceWindowEnd: typeof args.evidenceWindowEnd === \"string\" ? args.evidenceWindowEnd : undefined,\n refs: Array.isArray(args.refs) ? args.refs.filter((x: unknown): x is string => typeof x === \"string\") : undefined,\n });\n case \"engram.shared_priorities_append\":\n return this.service.sharedPrioritiesAppend({\n agentId: typeof args.agentId === \"string\" ? args.agentId : \"\",\n text: typeof args.text === \"string\" ? args.text : \"\",\n });\n case \"engram.shared_context_cross_signals_run\":\n return this.service.sharedContextCrossSignalsRun({\n date: typeof args.date === \"string\" ? args.date : undefined,\n });\n case \"engram.shared_context_curate_daily\":\n return this.service.sharedContextCurateDaily({\n date: typeof args.date === \"string\" ? args.date : undefined,\n });\n case \"engram.compounding_weekly_synthesize\":\n return this.service.compoundingWeeklySynthesize({\n weekId: typeof args.weekId === \"string\" ? args.weekId : undefined,\n });\n case \"engram.compounding_promote_candidate\":\n return this.service.compoundingPromoteCandidate({\n weekId: typeof args.weekId === \"string\" ? args.weekId : \"\",\n candidateId: typeof args.candidateId === \"string\" ? args.candidateId : \"\",\n dryRun: args.dryRun === true,\n });\n // ── Compression Guidelines tools ───────────────────────────────────\n case \"engram.compression_guidelines_optimize\":\n return this.service.compressionGuidelinesOptimize({\n dryRun: args.dryRun === true,\n eventLimit: typeof args.eventLimit === \"number\" ? args.eventLimit : undefined,\n });\n case \"engram.compression_guidelines_activate\":\n return this.service.compressionGuidelinesActivate({\n expectedContentHash: typeof args.expectedContentHash === \"string\" ? args.expectedContentHash : undefined,\n expectedGuidelineVersion: typeof args.expectedGuidelineVersion === \"number\" ? args.expectedGuidelineVersion : undefined,\n });\n // ── Memory search & debug tools ──────────────────────────────────\n case \"engram.memory_search\":\n return this.service.memorySearch({\n query: typeof args.query === \"string\" ? args.query : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n maxResults: typeof args.maxResults === \"number\" && Number.isFinite(args.maxResults) ? args.maxResults : undefined,\n collection: typeof args.collection === \"string\" ? args.collection : undefined,\n principal: effectivePrincipal,\n });\n case \"engram.memory_profile\":\n return this.service.memoryProfile(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n effectivePrincipal,\n );\n case \"engram.memory_entities_list\":\n return this.service.memoryEntitiesList(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n effectivePrincipal,\n );\n case \"engram.memory_questions\":\n return this.service.memoryQuestions(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n effectivePrincipal,\n );\n case \"engram.memory_last_recall\":\n return this.service.lastRecallSnapshot(\n typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n );\n case \"engram.memory_intent_debug\":\n return this.service.intentDebug(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n );\n case \"engram.memory_qmd_debug\":\n return this.service.qmdDebug(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n );\n case \"engram.memory_graph_explain\":\n return this.service.graphExplainLastRecall(\n typeof args.namespace === \"string\" ? args.namespace : undefined,\n );\n case \"engram.memory_feedback\":\n return this.service.memoryFeedback({\n memoryId: typeof args.memoryId === \"string\" ? args.memoryId : \"\",\n vote: args.vote === \"down\" ? \"down\" : \"up\",\n note: typeof args.note === \"string\" ? args.note : undefined,\n });\n case \"engram.memory_promote\":\n return this.service.memoryPromote({\n memoryId: typeof args.memoryId === \"string\" ? args.memoryId : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : undefined,\n });\n case \"engram.context_checkpoint\":\n return this.service.contextCheckpoint({\n sessionKey: typeof args.sessionKey === \"string\" ? args.sessionKey : \"\",\n context: typeof args.context === \"string\" ? args.context : \"\",\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n principal: effectivePrincipal,\n });\n // ── Daily Context Briefing (#370) ───────────────────────────────────\n case \"engram.briefing\": {\n // Validate the format value upfront — unsupported values (e.g. \"xml\")\n // must be rejected with a descriptive error rather than silently\n // falling back to the default format.\n const rawFormat = typeof args.format === \"string\" ? args.format : undefined;\n const formatErr = validateBriefingFormat(rawFormat);\n if (formatErr) throw new Error(formatErr);\n return this.service.briefing({\n since: typeof args.since === \"string\" ? args.since : undefined,\n focus: typeof args.focus === \"string\" ? args.focus : undefined,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n format: rawFormat as \"json\" | \"markdown\" | undefined,\n maxFollowups:\n typeof args.maxFollowups === \"number\" ? args.maxFollowups : undefined,\n principal: effectivePrincipal,\n });\n }\n // ── Contradiction Review (issue #520) ──────────────────────────────────\n case \"engram.review_list\":\n case \"remnic.review_list\": {\n const { listPairs } = await import(\"./contradiction/contradiction-review.js\");\n const filter = typeof args.filter === \"string\" ? args.filter as \"all\" | \"unresolved\" | \"contradicts\" | \"independent\" | \"duplicates\" | \"needs-user\" : \"unresolved\";\n const ns = typeof args.namespace === \"string\" ? args.namespace : undefined;\n const limit = typeof args.limit === \"number\" ? args.limit : 50;\n return listPairs(this.service.memoryDir, { filter, namespace: ns, limit });\n }\n case \"engram.review_resolve\":\n case \"remnic.review_resolve\": {\n const pairId = typeof args.pairId === \"string\" ? args.pairId : \"\";\n const verb = typeof args.verb === \"string\" ? args.verb : \"\";\n if (!pairId) throw new Error(\"pairId is required\");\n if (!verb) throw new Error(\"verb is required\");\n const { isValidResolutionVerb } = await import(\"./contradiction/resolution.js\");\n if (!isValidResolutionVerb(verb)) throw new Error(`Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context`);\n const { executeResolution } = await import(\"./contradiction/resolution.js\");\n return executeResolution(this.service.memoryDir, this.service.storageRef, pairId, verb);\n }\n case \"engram.contradiction_scan_run\":\n case \"remnic.contradiction_scan_run\": {\n const { runContradictionScan } = await import(\"./contradiction/contradiction-scan.js\");\n return runContradictionScan({\n storage: this.service.storageRef,\n config: this.service.configRef,\n memoryDir: this.service.memoryDir,\n embeddingLookup: this.service.embeddingLookupRef,\n localLlm: this.service.localLlmRef,\n fallbackLlm: this.service.fallbackLlmRef,\n namespace: typeof args.namespace === \"string\" ? args.namespace : undefined,\n });\n }\n default:\n throw new Error(`unknown tool: ${name}`);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAsB3B,IAAM,uBAAuB;AAC7B,IAAM,oBAAoB;AAC1B,IAAM,uBAAuB;AAE7B,SAAS,oBAAoB,MAAsB;AACjD,SAAO,KAAK,WAAW,iBAAiB,IAC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AK,cAAc,WAAW,KAAK,YAAY;AAAA,QACnE,CAAC;AAAA,MACH;AAAA,MACA;AACE,cAAM,IAAI,MAAM,iBAAiB,IAAI,EAAE;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,80 @@
1
+ // src/taxonomy/resolver.ts
2
+ var DEFAULT_CATEGORY_ID = "facts";
3
+ function resolveCategory(content, memoryCategory, taxonomy) {
4
+ const contentLower = content.toLowerCase();
5
+ const matches = taxonomy.categories.filter(
6
+ (cat) => cat.memoryCategories.includes(memoryCategory)
7
+ );
8
+ if (matches.length === 0) {
9
+ const fallback = taxonomy.categories.find((c) => c.id === DEFAULT_CATEGORY_ID) ?? taxonomy.categories[0];
10
+ if (!fallback) {
11
+ return {
12
+ categoryId: DEFAULT_CATEGORY_ID,
13
+ confidence: 0,
14
+ reason: "Taxonomy is empty; using default category",
15
+ alternatives: []
16
+ };
17
+ }
18
+ const alternatives2 = taxonomy.categories.filter((c) => c.id !== fallback.id).map((c) => ({
19
+ categoryId: c.id,
20
+ reason: c.description
21
+ }));
22
+ return {
23
+ categoryId: fallback.id,
24
+ confidence: 0.3,
25
+ reason: `No taxonomy category maps to MemoryCategory "${memoryCategory}"; falling back to "${fallback.name}"`,
26
+ alternatives: alternatives2
27
+ };
28
+ }
29
+ if (matches.length === 1) {
30
+ const match = matches[0];
31
+ const alternatives2 = taxonomy.categories.filter((c) => c.id !== match.id).map((c) => ({
32
+ categoryId: c.id,
33
+ reason: c.description
34
+ }));
35
+ return {
36
+ categoryId: match.id,
37
+ confidence: 1,
38
+ reason: `Unique match: MemoryCategory "${memoryCategory}" maps to "${match.name}"`,
39
+ alternatives: alternatives2
40
+ };
41
+ }
42
+ const scored = matches.map((cat) => ({
43
+ cat,
44
+ keywordScore: computeKeywordScore(contentLower, cat)
45
+ }));
46
+ scored.sort((a, b) => {
47
+ if (b.keywordScore !== a.keywordScore) return b.keywordScore - a.keywordScore;
48
+ return a.cat.priority - b.cat.priority;
49
+ });
50
+ const best = scored[0];
51
+ const runnerUp = scored[1];
52
+ const confidence = best.keywordScore > 0 && (!runnerUp || best.keywordScore > runnerUp.keywordScore) ? 0.9 : 0.7;
53
+ const alternatives = taxonomy.categories.filter((c) => c.id !== best.cat.id).map((c) => ({
54
+ categoryId: c.id,
55
+ reason: c.description
56
+ }));
57
+ const reason = best.keywordScore > 0 ? `Filing rules for "${best.cat.name}" matched content keywords (priority ${best.cat.priority})` : `Priority tie-break: "${best.cat.name}" has lowest priority number (${best.cat.priority})`;
58
+ return {
59
+ categoryId: best.cat.id,
60
+ confidence,
61
+ reason,
62
+ alternatives
63
+ };
64
+ }
65
+ function computeKeywordScore(contentLower, cat) {
66
+ let score = 0;
67
+ const ruleText = [...cat.filingRules, cat.description].join(" ").toLowerCase();
68
+ const keywords = ruleText.split(/[^a-z0-9]+/).filter((w) => w.length >= 3);
69
+ for (const kw of keywords) {
70
+ if (contentLower.includes(kw)) {
71
+ score += 1;
72
+ }
73
+ }
74
+ return score;
75
+ }
76
+
77
+ export {
78
+ resolveCategory
79
+ };
80
+ //# sourceMappingURL=chunk-OIT5QGG4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/taxonomy/resolver.ts"],"sourcesContent":["/**\n * Resolver decision tree for the MECE taxonomy.\n *\n * Given extracted content and its MemoryCategory, determines which\n * taxonomy category the knowledge should be filed under.\n */\n\nimport type { MemoryCategory } from \"../types.js\";\nimport type { ResolverDecision, Taxonomy, TaxonomyCategory } from \"./types.js\";\n\nconst DEFAULT_CATEGORY_ID = \"facts\";\n\n/**\n * Resolve a piece of content to a taxonomy category.\n *\n * Algorithm:\n * 1. Find all taxonomy categories whose `memoryCategories` include\n * the given `memoryCategory`.\n * 2. If exactly one match, return it with confidence 1.0.\n * 3. If multiple matches, pick the one with the lowest priority\n * number (highest precedence). Apply keyword heuristics from\n * filing rules as a secondary signal.\n * 4. If no match, fall back to the \"facts\" category (or first\n * category if \"facts\" is absent) with low confidence.\n * 5. Always populate `alternatives` with other plausible categories.\n */\nexport function resolveCategory(\n content: string,\n memoryCategory: MemoryCategory,\n taxonomy: Taxonomy,\n): ResolverDecision {\n const contentLower = content.toLowerCase();\n\n // Step 1: find matching categories\n const matches = taxonomy.categories.filter((cat) =>\n cat.memoryCategories.includes(memoryCategory),\n );\n\n if (matches.length === 0) {\n // No taxonomy category accepts this MemoryCategory — fall back\n const fallback =\n taxonomy.categories.find((c) => c.id === DEFAULT_CATEGORY_ID) ??\n taxonomy.categories[0];\n if (!fallback) {\n return {\n categoryId: DEFAULT_CATEGORY_ID,\n confidence: 0,\n reason: \"Taxonomy is empty; using default category\",\n alternatives: [],\n };\n }\n const alternatives = taxonomy.categories\n .filter((c) => c.id !== fallback.id)\n .map((c) => ({\n categoryId: c.id,\n reason: c.description,\n }));\n return {\n categoryId: fallback.id,\n confidence: 0.3,\n reason: `No taxonomy category maps to MemoryCategory \"${memoryCategory}\"; falling back to \"${fallback.name}\"`,\n alternatives,\n };\n }\n\n if (matches.length === 1) {\n const match = matches[0]!;\n const alternatives = taxonomy.categories\n .filter((c) => c.id !== match.id)\n .map((c) => ({\n categoryId: c.id,\n reason: c.description,\n }));\n return {\n categoryId: match.id,\n confidence: 1.0,\n reason: `Unique match: MemoryCategory \"${memoryCategory}\" maps to \"${match.name}\"`,\n alternatives,\n };\n }\n\n // Multiple matches — use filing rule keyword heuristics + priority\n const scored = matches.map((cat) => ({\n cat,\n keywordScore: computeKeywordScore(contentLower, cat),\n }));\n\n // Sort by keyword score descending, then priority ascending (lower wins)\n scored.sort((a, b) => {\n if (b.keywordScore !== a.keywordScore) return b.keywordScore - a.keywordScore;\n return a.cat.priority - b.cat.priority;\n });\n\n const best = scored[0]!;\n const runnerUp = scored[1];\n\n // Confidence is higher when keyword match clearly differentiates\n const confidence =\n best.keywordScore > 0 && (!runnerUp || best.keywordScore > runnerUp.keywordScore)\n ? 0.9\n : 0.7;\n\n const alternatives = taxonomy.categories\n .filter((c) => c.id !== best.cat.id)\n .map((c) => ({\n categoryId: c.id,\n reason: c.description,\n }));\n\n const reason =\n best.keywordScore > 0\n ? `Filing rules for \"${best.cat.name}\" matched content keywords (priority ${best.cat.priority})`\n : `Priority tie-break: \"${best.cat.name}\" has lowest priority number (${best.cat.priority})`;\n\n return {\n categoryId: best.cat.id,\n confidence,\n reason,\n alternatives,\n };\n}\n\n/**\n * Compute a simple keyword overlap score between content and\n * a category's filing rules + description.\n */\nfunction computeKeywordScore(contentLower: string, cat: TaxonomyCategory): number {\n let score = 0;\n const ruleText = [...cat.filingRules, cat.description]\n .join(\" \")\n .toLowerCase();\n\n // Extract meaningful words (3+ chars) from the rule text\n const keywords = ruleText\n .split(/[^a-z0-9]+/)\n .filter((w) => w.length >= 3);\n\n for (const kw of keywords) {\n if (contentLower.includes(kw)) {\n score += 1;\n }\n }\n return score;\n}\n"],"mappings":";AAUA,IAAM,sBAAsB;AAgBrB,SAAS,gBACd,SACA,gBACA,UACkB;AAClB,QAAM,eAAe,QAAQ,YAAY;AAGzC,QAAM,UAAU,SAAS,WAAW;AAAA,IAAO,CAAC,QAC1C,IAAI,iBAAiB,SAAS,cAAc;AAAA,EAC9C;AAEA,MAAI,QAAQ,WAAW,GAAG;AAExB,UAAM,WACJ,SAAS,WAAW,KAAK,CAAC,MAAM,EAAE,OAAO,mBAAmB,KAC5D,SAAS,WAAW,CAAC;AACvB,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,QACL,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,cAAc,CAAC;AAAA,MACjB;AAAA,IACF;AACA,UAAMA,gBAAe,SAAS,WAC3B,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS,EAAE,EAClC,IAAI,CAAC,OAAO;AAAA,MACX,YAAY,EAAE;AAAA,MACd,QAAQ,EAAE;AAAA,IACZ,EAAE;AACJ,WAAO;AAAA,MACL,YAAY,SAAS;AAAA,MACrB,YAAY;AAAA,MACZ,QAAQ,gDAAgD,cAAc,uBAAuB,SAA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AAAA,EACF;AACF;AAMA,SAAS,oBAAoB,cAAsB,KAA+B;AAChF,MAAI,QAAQ;AACZ,QAAM,WAAW,CAAC,GAAG,IAAI,aAAa,IAAI,WAAW,EAClD,KAAK,GAAG,EACR,YAAY;AAGf,QAAM,WAAW,SACd,MAAM,YAAY,EAClB,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC;AAE9B,aAAW,MAAM,UAAU;AACzB,QAAI,aAAa,SAAS,EAAE,GAAG;AAC7B,eAAS;AAAA,IACX;AAAA,EACF;AACA,SAAO;AACT;","names":["alternatives"]}
@@ -0,0 +1,21 @@
1
+ // src/abort-error.ts
2
+ function abortError(message) {
3
+ const err = new Error(message);
4
+ Object.defineProperty(err, "name", { value: "AbortError" });
5
+ return err;
6
+ }
7
+ function isAbortError(err) {
8
+ return err instanceof Error && err.name === "AbortError";
9
+ }
10
+ function throwIfAborted(signal, message = "operation aborted") {
11
+ if (signal?.aborted) {
12
+ throw abortError(message);
13
+ }
14
+ }
15
+
16
+ export {
17
+ abortError,
18
+ isAbortError,
19
+ throwIfAborted
20
+ };
21
+ //# sourceMappingURL=chunk-PVGDJXVK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/abort-error.ts"],"sourcesContent":["/**\n * Shared abort-error helpers.\n *\n * Consolidates the `throwIfAborted` / `abortError` / `isAbortError`\n * patterns that were independently implemented across\n * `direct-answer-wiring.ts`, `harmonic-retrieval.ts`, and `qmd.ts`\n * (plus a private pair in `orchestrator.ts`). A single helper\n * means future changes to the abort-error convention are applied\n * consistently across the codebase.\n *\n * The convention (matching Web / Node): throw a standard `Error`\n * with `name === \"AbortError\"`. Callers dispatch on name rather\n * than a specific class so error propagation across async\n * boundaries continues to classify correctly.\n */\n\n/**\n * Build an Error whose `name` is `\"AbortError\"`. Uses\n * `Object.defineProperty` so the name is non-enumerable and\n * mirrors the shape of `DOMException(\"AbortError\")` where that\n * is available.\n */\nexport function abortError(message: string): Error {\n const err = new Error(message);\n Object.defineProperty(err, \"name\", { value: \"AbortError\" });\n return err;\n}\n\n/** Return true iff `err` is an Error whose `name` is `\"AbortError\"`. */\nexport function isAbortError(err: unknown): boolean {\n return err instanceof Error && err.name === \"AbortError\";\n}\n\n/**\n * Throw an AbortError when the given signal has fired. No-op\n * when the signal is absent or not yet aborted. The default\n * message matches the prior in-module implementations.\n */\nexport function throwIfAborted(\n signal?: AbortSignal,\n message = \"operation aborted\",\n): void {\n if (signal?.aborted) {\n throw abortError(message);\n }\n}\n"],"mappings":";AAsBO,SAAS,WAAW,SAAwB;AACjD,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,SAAO,eAAe,KAAK,QAAQ,EAAE,OAAO,aAAa,CAAC;AAC1D,SAAO;AACT;AAGO,SAAS,aAAa,KAAuB;AAClD,SAAO,eAAe,SAAS,IAAI,SAAS;AAC9C;AAOO,SAAS,eACd,QACA,UAAU,qBACJ;AACN,MAAI,QAAQ,SAAS;AACnB,UAAM,WAAW,OAAO;AAAA,EAC1B;AACF;","names":[]}
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-DT5TVLJE.js";
10
10
  import {
11
11
  StorageManager
12
- } from "./chunk-POMSFKTB.js";
12
+ } from "./chunk-GV6NLQ4X.js";
13
13
  import {
14
14
  log
15
15
  } from "./chunk-2ODBA7MQ.js";
@@ -786,4 +786,4 @@ export {
786
786
  buildExtensionsBlockForConsolidation,
787
787
  materializeAfterSemanticConsolidation
788
788
  };
789
- //# sourceMappingURL=chunk-RCICHSHL.js.map
789
+ //# sourceMappingURL=chunk-SYUK3VLY.js.map