memory-journal-mcp 9.0.0 → 9.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 (356) hide show
  1. package/README.md +165 -124
  2. package/dist/audit/interceptor.d.ts.map +1 -1
  3. package/dist/auth/authorization-server-discovery.d.ts.map +1 -1
  4. package/dist/auth/middleware.d.ts +11 -22
  5. package/dist/auth/middleware.d.ts.map +1 -1
  6. package/dist/auth/scope-map.d.ts.map +1 -1
  7. package/dist/auth/scopes.d.ts.map +1 -1
  8. package/dist/auth/token-validator.d.ts.map +1 -1
  9. package/dist/auth/transport-agnostic.d.ts +4 -0
  10. package/dist/auth/transport-agnostic.d.ts.map +1 -1
  11. package/dist/auth/validation.d.ts +1 -0
  12. package/dist/auth/validation.d.ts.map +1 -1
  13. package/dist/{chunk-6RCZ4IYV.js → chunk-4FZCHFB5.js} +28 -5
  14. package/dist/{chunk-AIWHVEOW.js → chunk-D2FY6XS5.js} +99 -7
  15. package/dist/chunk-FZLB6NAV.js +746 -0
  16. package/dist/{chunk-NVXCRDCO.js → chunk-LE6ZWUPK.js} +216 -138
  17. package/dist/chunk-SGJU2DHU.js +2102 -0
  18. package/dist/{chunk-2UIMA6JF.js → chunk-T7SROBBV.js} +32375 -29351
  19. package/dist/{chunk-IYZWMAA4.js → chunk-Y6MMKR2Z.js} +957 -1333
  20. package/dist/cli/commands/admin.d.ts +1 -1
  21. package/dist/cli/commands/admin.d.ts.map +1 -1
  22. package/dist/cli/commands/entry-payload.d.ts +38 -0
  23. package/dist/cli/commands/entry-payload.d.ts.map +1 -0
  24. package/dist/cli/commands/entry.d.ts +10 -0
  25. package/dist/cli/commands/entry.d.ts.map +1 -1
  26. package/dist/cli/commands/exec.d.ts.map +1 -1
  27. package/dist/cli/commands/io.d.ts +1 -0
  28. package/dist/cli/commands/io.d.ts.map +1 -1
  29. package/dist/cli/commands/visualize.d.ts.map +1 -1
  30. package/dist/cli/index.js +7 -10
  31. package/dist/cli/schemas.d.ts +14 -1
  32. package/dist/cli/schemas.d.ts.map +1 -1
  33. package/dist/cli/server-options-builder.d.ts.map +1 -1
  34. package/dist/cli.js +7 -10
  35. package/dist/codemode/api/journal-api.d.ts +5 -23
  36. package/dist/codemode/api/journal-api.d.ts.map +1 -1
  37. package/dist/codemode/api/key-normalizer.d.ts +8 -0
  38. package/dist/codemode/api/key-normalizer.d.ts.map +1 -0
  39. package/dist/codemode/api/param-normalizer.d.ts +2 -4
  40. package/dist/codemode/api/param-normalizer.d.ts.map +1 -1
  41. package/dist/codemode/api/project-registry-ops.d.ts +26 -0
  42. package/dist/codemode/api/project-registry-ops.d.ts.map +1 -0
  43. package/dist/codemode/api/sandbox-bindings.d.ts +25 -0
  44. package/dist/codemode/api/sandbox-bindings.d.ts.map +1 -0
  45. package/dist/codemode/api/types.d.ts.map +1 -1
  46. package/dist/codemode/api-constants.d.ts +3 -39
  47. package/dist/codemode/api-constants.d.ts.map +1 -1
  48. package/dist/codemode/constants/examples-and-params.d.ts +31 -0
  49. package/dist/codemode/constants/examples-and-params.d.ts.map +1 -0
  50. package/dist/codemode/constants/method-aliases.d.ts +8 -0
  51. package/dist/codemode/constants/method-aliases.d.ts.map +1 -0
  52. package/dist/codemode/normalizers/domain-tool-interceptions.d.ts +6 -0
  53. package/dist/codemode/normalizers/domain-tool-interceptions.d.ts.map +1 -0
  54. package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts +6 -0
  55. package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts.map +1 -0
  56. package/dist/codemode/normalizers/generic-interceptions.d.ts +6 -0
  57. package/dist/codemode/normalizers/generic-interceptions.d.ts.map +1 -0
  58. package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts +6 -0
  59. package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts.map +1 -0
  60. package/dist/codemode/normalizers/shared-utils.d.ts +31 -0
  61. package/dist/codemode/normalizers/shared-utils.d.ts.map +1 -0
  62. package/dist/codemode/param-normalizer.d.ts +5 -1
  63. package/dist/codemode/param-normalizer.d.ts.map +1 -1
  64. package/dist/codemode/proxy-helpers.d.ts +34 -0
  65. package/dist/codemode/proxy-helpers.d.ts.map +1 -0
  66. package/dist/codemode/proxy-namespaces.d.ts +30 -0
  67. package/dist/codemode/proxy-namespaces.d.ts.map +1 -0
  68. package/dist/codemode/security.d.ts +11 -0
  69. package/dist/codemode/security.d.ts.map +1 -1
  70. package/dist/codemode/type-generator.d.ts.map +1 -1
  71. package/dist/codemode/types.d.ts.map +1 -1
  72. package/dist/codemode/worker/mj-shim-domains.d.ts +15 -0
  73. package/dist/codemode/worker/mj-shim-domains.d.ts.map +1 -0
  74. package/dist/codemode/worker/mj-shim-proxy.d.ts +18 -0
  75. package/dist/codemode/worker/mj-shim-proxy.d.ts.map +1 -0
  76. package/dist/codemode/worker/namespace-shims.d.ts +32 -0
  77. package/dist/codemode/worker/namespace-shims.d.ts.map +1 -0
  78. package/dist/codemode/worker/node-shims.d.ts +65 -0
  79. package/dist/codemode/worker/node-shims.d.ts.map +1 -0
  80. package/dist/codemode/worker/prototype-hardening.d.ts +18 -0
  81. package/dist/codemode/worker/prototype-hardening.d.ts.map +1 -0
  82. package/dist/codemode/worker/result-compactor.d.ts +20 -0
  83. package/dist/codemode/worker/result-compactor.d.ts.map +1 -0
  84. package/dist/codemode/worker/sandbox-globals.d.ts +19 -0
  85. package/dist/codemode/worker/sandbox-globals.d.ts.map +1 -0
  86. package/dist/codemode/worker-api-proxy.d.ts +1 -6
  87. package/dist/codemode/worker-api-proxy.d.ts.map +1 -1
  88. package/dist/codemode/worker-result-proxy.d.ts.map +1 -1
  89. package/dist/codemode/worker-sandbox.d.ts.map +1 -1
  90. package/dist/constants/instructions/admin.d.ts +1 -1
  91. package/dist/constants/instructions/admin.d.ts.map +1 -1
  92. package/dist/constants/instructions/base.d.ts +2 -2
  93. package/dist/constants/instructions/base.d.ts.map +1 -1
  94. package/dist/constants/instructions/codemode.d.ts +1 -1
  95. package/dist/constants/instructions/codemode.d.ts.map +1 -1
  96. package/dist/constants/instructions/core.d.ts +1 -1
  97. package/dist/constants/instructions/core.d.ts.map +1 -1
  98. package/dist/constants/instructions/github.d.ts +1 -1
  99. package/dist/constants/instructions/github.d.ts.map +1 -1
  100. package/dist/constants/instructions/gotchas.d.ts +1 -1
  101. package/dist/constants/instructions/gotchas.d.ts.map +1 -1
  102. package/dist/constants/instructions/io.d.ts +1 -1
  103. package/dist/constants/instructions/io.d.ts.map +1 -1
  104. package/dist/constants/instructions/templates.d.ts +1 -1
  105. package/dist/constants/instructions/templates.d.ts.map +1 -1
  106. package/dist/constants/server-instructions.d.ts +2 -2
  107. package/dist/constants/server-instructions.d.ts.map +1 -1
  108. package/dist/database/core/interfaces.d.ts +6 -6
  109. package/dist/database/core/interfaces.d.ts.map +1 -1
  110. package/dist/database/sqlite-adapter/adapter-delegates.d.ts +161 -0
  111. package/dist/database/sqlite-adapter/adapter-delegates.d.ts.map +1 -0
  112. package/dist/database/sqlite-adapter/backup.d.ts.map +1 -1
  113. package/dist/database/sqlite-adapter/database-adapter.d.ts +17 -147
  114. package/dist/database/sqlite-adapter/database-adapter.d.ts.map +1 -1
  115. package/dist/database/sqlite-adapter/entries/crud-read.d.ts +16 -0
  116. package/dist/database/sqlite-adapter/entries/crud-read.d.ts.map +1 -0
  117. package/dist/database/sqlite-adapter/entries/crud-write.d.ts +62 -0
  118. package/dist/database/sqlite-adapter/entries/crud-write.d.ts.map +1 -0
  119. package/dist/database/sqlite-adapter/entries/crud.d.ts +3 -92
  120. package/dist/database/sqlite-adapter/entries/crud.d.ts.map +1 -1
  121. package/dist/database/sqlite-adapter/entries/importance.d.ts +7 -0
  122. package/dist/database/sqlite-adapter/entries/importance.d.ts.map +1 -1
  123. package/dist/database/sqlite-adapter/entries/index.d.ts +9 -4
  124. package/dist/database/sqlite-adapter/entries/index.d.ts.map +1 -1
  125. package/dist/database/sqlite-adapter/entries/revisions.d.ts +16 -0
  126. package/dist/database/sqlite-adapter/entries/revisions.d.ts.map +1 -0
  127. package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts +37 -0
  128. package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts.map +1 -0
  129. package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts +31 -0
  130. package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts.map +1 -0
  131. package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts +44 -0
  132. package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts.map +1 -0
  133. package/dist/database/sqlite-adapter/entries/search/index.d.ts +1 -1
  134. package/dist/database/sqlite-adapter/entries/search/index.d.ts.map +1 -1
  135. package/dist/database/sqlite-adapter/entries/search/query.d.ts +3 -82
  136. package/dist/database/sqlite-adapter/entries/search/query.d.ts.map +1 -1
  137. package/dist/database/sqlite-adapter/entries/statistics.d.ts.map +1 -1
  138. package/dist/database/sqlite-adapter/insights/cross-project.d.ts +42 -0
  139. package/dist/database/sqlite-adapter/insights/cross-project.d.ts.map +1 -0
  140. package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts +17 -0
  141. package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts.map +1 -0
  142. package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts +29 -0
  143. package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts.map +1 -0
  144. package/dist/database/sqlite-adapter/insights-operations.d.ts +11 -50
  145. package/dist/database/sqlite-adapter/insights-operations.d.ts.map +1 -1
  146. package/dist/database/sqlite-adapter/lifecycle-operations.d.ts.map +1 -1
  147. package/dist/database/sqlite-adapter/members.d.ts.map +1 -1
  148. package/dist/database/sqlite-adapter/native-connection.d.ts +5 -0
  149. package/dist/database/sqlite-adapter/native-connection.d.ts.map +1 -1
  150. package/dist/database/sqlite-adapter/relationships.d.ts +1 -2
  151. package/dist/database/sqlite-adapter/relationships.d.ts.map +1 -1
  152. package/dist/database/sqlite-adapter/tags.d.ts.map +1 -1
  153. package/dist/database/sqlite-adapter/vector-operations.d.ts.map +1 -1
  154. package/dist/filtering/tool-constants.d.ts +1 -1
  155. package/dist/{fts-T466O2JP.js → fts-YHUVPPYF.js} +2 -2
  156. package/dist/github/commit-references/enricher.d.ts.map +1 -1
  157. package/dist/github/github-integration/projects.d.ts.map +1 -1
  158. package/dist/handlers/prompts/adversarial-helpers.d.ts +75 -0
  159. package/dist/handlers/prompts/adversarial-helpers.d.ts.map +1 -0
  160. package/dist/handlers/prompts/adversarial.d.ts +3 -5
  161. package/dist/handlers/prompts/adversarial.d.ts.map +1 -1
  162. package/dist/handlers/prompts/cms-supervisor.d.ts +8 -0
  163. package/dist/handlers/prompts/cms-supervisor.d.ts.map +1 -0
  164. package/dist/handlers/prompts/index.d.ts.map +1 -1
  165. package/dist/handlers/prompts/optimizer.d.ts.map +1 -1
  166. package/dist/handlers/prompts/workflow.d.ts.map +1 -1
  167. package/dist/handlers/resources/core/briefing/context-section.d.ts.map +1 -1
  168. package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts +57 -0
  169. package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts.map +1 -0
  170. package/dist/handlers/resources/core/briefing/github-section.d.ts +23 -20
  171. package/dist/handlers/resources/core/briefing/github-section.d.ts.map +1 -1
  172. package/dist/handlers/resources/core/briefing/system-section.d.ts.map +1 -1
  173. package/dist/handlers/resources/core/briefing/user-message.d.ts.map +1 -1
  174. package/dist/handlers/resources/help.d.ts.map +1 -1
  175. package/dist/handlers/resources/index.d.ts.map +1 -1
  176. package/dist/handlers/resources/shared.d.ts +1 -0
  177. package/dist/handlers/resources/shared.d.ts.map +1 -1
  178. package/dist/handlers/resources/staleness.d.ts.map +1 -1
  179. package/dist/handlers/tools/admin/batch-tools.d.ts.map +1 -1
  180. package/dist/handlers/tools/admin/core-tools.d.ts.map +1 -1
  181. package/dist/handlers/tools/admin/index.d.ts.map +1 -1
  182. package/dist/handlers/tools/admin/lifecycle-tools.d.ts.map +1 -1
  183. package/dist/handlers/tools/admin/project-tools.d.ts +1 -1
  184. package/dist/handlers/tools/admin/project-tools.d.ts.map +1 -1
  185. package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts +609 -0
  186. package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts.map +1 -0
  187. package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts +136 -0
  188. package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts.map +1 -0
  189. package/dist/handlers/tools/admin/schemas.d.ts +2 -733
  190. package/dist/handlers/tools/admin/schemas.d.ts.map +1 -1
  191. package/dist/handlers/tools/admin/update_configuration.d.ts +14 -0
  192. package/dist/handlers/tools/admin/update_configuration.d.ts.map +1 -1
  193. package/dist/handlers/tools/admin/vector-tools.d.ts.map +1 -1
  194. package/dist/handlers/tools/analytics.d.ts.map +1 -1
  195. package/dist/handlers/tools/arg-interceptions.d.ts +51 -0
  196. package/dist/handlers/tools/arg-interceptions.d.ts.map +1 -0
  197. package/dist/handlers/tools/codemode/code-healer.d.ts +11 -0
  198. package/dist/handlers/tools/codemode/code-healer.d.ts.map +1 -0
  199. package/dist/handlers/tools/codemode/handler.d.ts +4 -23
  200. package/dist/handlers/tools/codemode/handler.d.ts.map +1 -1
  201. package/dist/handlers/tools/codemode/json-entry-recovery.d.ts +13 -0
  202. package/dist/handlers/tools/codemode/json-entry-recovery.d.ts.map +1 -0
  203. package/dist/handlers/tools/codemode/payload-synthesizer.d.ts +17 -0
  204. package/dist/handlers/tools/codemode/payload-synthesizer.d.ts.map +1 -0
  205. package/dist/handlers/tools/codemode/secure-dispatcher.d.ts +25 -0
  206. package/dist/handlers/tools/codemode/secure-dispatcher.d.ts.map +1 -0
  207. package/dist/handlers/tools/codemode/sql-recovery.d.ts +14 -0
  208. package/dist/handlers/tools/codemode/sql-recovery.d.ts.map +1 -0
  209. package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts +21 -0
  210. package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts.map +1 -0
  211. package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts +4 -0
  212. package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts.map +1 -0
  213. package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts +19 -0
  214. package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts.map +1 -0
  215. package/dist/handlers/tools/core/dummy-healing/index.d.ts +7 -0
  216. package/dist/handlers/tools/core/dummy-healing/index.d.ts.map +1 -0
  217. package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts +12 -0
  218. package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts.map +1 -0
  219. package/dist/handlers/tools/core/dummy-healing.d.ts +1 -29
  220. package/dist/handlers/tools/core/dummy-healing.d.ts.map +1 -1
  221. package/dist/handlers/tools/core/index.d.ts +1 -1
  222. package/dist/handlers/tools/core/index.d.ts.map +1 -1
  223. package/dist/handlers/tools/core/schemas.d.ts +33 -9
  224. package/dist/handlers/tools/core/schemas.d.ts.map +1 -1
  225. package/dist/handlers/tools/core/staleness-tools.d.ts +17 -0
  226. package/dist/handlers/tools/core/staleness-tools.d.ts.map +1 -1
  227. package/dist/handlers/tools/core/tools.d.ts.map +1 -1
  228. package/dist/handlers/tools/git.d.ts +5 -11
  229. package/dist/handlers/tools/git.d.ts.map +1 -1
  230. package/dist/handlers/tools/github/close-issue-tool.d.ts +6 -0
  231. package/dist/handlers/tools/github/close-issue-tool.d.ts.map +1 -0
  232. package/dist/handlers/tools/github/create-issue-tool.d.ts +6 -0
  233. package/dist/handlers/tools/github/create-issue-tool.d.ts.map +1 -0
  234. package/dist/handlers/tools/github/issue-tools.d.ts +3 -0
  235. package/dist/handlers/tools/github/issue-tools.d.ts.map +1 -1
  236. package/dist/handlers/tools/github/kanban-tools.d.ts.map +1 -1
  237. package/dist/handlers/tools/github/milestone-tools.d.ts.map +1 -1
  238. package/dist/handlers/tools/index.d.ts +2 -2
  239. package/dist/handlers/tools/index.d.ts.map +1 -1
  240. package/dist/handlers/tools/io/schemas.d.ts +5 -2
  241. package/dist/handlers/tools/io/schemas.d.ts.map +1 -1
  242. package/dist/handlers/tools/relationships.d.ts.map +1 -1
  243. package/dist/handlers/tools/schemas/constants-and-primitives.d.ts +53 -0
  244. package/dist/handlers/tools/schemas/constants-and-primitives.d.ts.map +1 -0
  245. package/dist/handlers/tools/schemas/hallucination-healer.d.ts +8 -0
  246. package/dist/handlers/tools/schemas/hallucination-healer.d.ts.map +1 -0
  247. package/dist/handlers/tools/schemas/output-schemas.d.ts +247 -0
  248. package/dist/handlers/tools/schemas/output-schemas.d.ts.map +1 -0
  249. package/dist/handlers/tools/schemas.d.ts +4 -306
  250. package/dist/handlers/tools/schemas.d.ts.map +1 -1
  251. package/dist/handlers/tools/search/cross-team.d.ts +14 -0
  252. package/dist/handlers/tools/search/cross-team.d.ts.map +1 -1
  253. package/dist/handlers/tools/search/helpers.d.ts.map +1 -1
  254. package/dist/handlers/tools/search/hybrid.d.ts.map +1 -1
  255. package/dist/handlers/tools/search/misc-tools.d.ts.map +1 -1
  256. package/dist/handlers/tools/search/schemas.d.ts +6 -3
  257. package/dist/handlers/tools/search/schemas.d.ts.map +1 -1
  258. package/dist/handlers/tools/search/search-entries.d.ts.map +1 -1
  259. package/dist/handlers/tools/search/semantic-search.d.ts.map +1 -1
  260. package/dist/handlers/tools/team/admin-tools/batch.d.ts.map +1 -1
  261. package/dist/handlers/tools/team/admin-tools/crud.d.ts.map +1 -1
  262. package/dist/handlers/tools/team/backup-tools.d.ts.map +1 -1
  263. package/dist/handlers/tools/team/core-tools.d.ts.map +1 -1
  264. package/dist/handlers/tools/team/helpers.d.ts.map +1 -1
  265. package/dist/handlers/tools/team/io-tools.d.ts.map +1 -1
  266. package/dist/handlers/tools/team/member-tools.d.ts.map +1 -1
  267. package/dist/handlers/tools/team/rbac.d.ts.map +1 -1
  268. package/dist/handlers/tools/team/relationship-tools.d.ts.map +1 -1
  269. package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts +618 -0
  270. package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts.map +1 -0
  271. package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts +464 -0
  272. package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts.map +1 -0
  273. package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts +525 -0
  274. package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts.map +1 -0
  275. package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts +419 -0
  276. package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts.map +1 -0
  277. package/dist/handlers/tools/team/schemas.d.ts +5 -2002
  278. package/dist/handlers/tools/team/schemas.d.ts.map +1 -1
  279. package/dist/handlers/tools/team/search-tools.d.ts.map +1 -1
  280. package/dist/handlers/tools/team/vector-tools.d.ts.map +1 -1
  281. package/dist/index.js +6 -9
  282. package/dist/markdown/exporter.d.ts.map +1 -1
  283. package/dist/markdown/importer.d.ts.map +1 -1
  284. package/dist/observability/latency-tracker.d.ts.map +1 -1
  285. package/dist/observability/metrics-server.d.ts +1 -1
  286. package/dist/observability/metrics-server.d.ts.map +1 -1
  287. package/dist/observability/token-estimator.d.ts.map +1 -1
  288. package/dist/{security-utils-HNTROJAG.js → security-utils-P4P6A2DG.js} +1 -1
  289. package/dist/server/digest-reporter.d.ts +1 -0
  290. package/dist/server/digest-reporter.d.ts.map +1 -1
  291. package/dist/server/mcp-server/core.d.ts.map +1 -1
  292. package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts +6 -0
  293. package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts.map +1 -0
  294. package/dist/server/mcp-server/tool-registration/index.d.ts +4 -0
  295. package/dist/server/mcp-server/tool-registration/index.d.ts.map +1 -0
  296. package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts +4 -0
  297. package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts.map +1 -0
  298. package/dist/server/mcp-server/tool-registration/register-tools.d.ts +18 -0
  299. package/dist/server/mcp-server/tool-registration/register-tools.d.ts.map +1 -0
  300. package/dist/server/mcp-server/tool-registration.d.ts +1 -17
  301. package/dist/server/mcp-server/tool-registration.d.ts.map +1 -1
  302. package/dist/server/registration.d.ts +2 -0
  303. package/dist/server/registration.d.ts.map +1 -1
  304. package/dist/server/scheduler.d.ts +1 -0
  305. package/dist/server/scheduler.d.ts.map +1 -1
  306. package/dist/server/subscription-manager.d.ts +2 -0
  307. package/dist/server/subscription-manager.d.ts.map +1 -1
  308. package/dist/tools-BOQV7QD3.js +6 -0
  309. package/dist/transports/http/security.d.ts.map +1 -1
  310. package/dist/transports/http/server/http-transport.d.ts +25 -0
  311. package/dist/transports/http/server/http-transport.d.ts.map +1 -0
  312. package/dist/transports/http/server/index.d.ts +3 -30
  313. package/dist/transports/http/server/index.d.ts.map +1 -1
  314. package/dist/transports/http/server/legacy-sse.d.ts.map +1 -1
  315. package/dist/transports/http/server/protocol-handlers.d.ts +9 -0
  316. package/dist/transports/http/server/protocol-handlers.d.ts.map +1 -0
  317. package/dist/types/entities.d.ts +41 -1
  318. package/dist/types/entities.d.ts.map +1 -1
  319. package/dist/types/index.d.ts +11 -4
  320. package/dist/types/index.d.ts.map +1 -1
  321. package/dist/utils/config-manager.d.ts +2 -0
  322. package/dist/utils/config-manager.d.ts.map +1 -1
  323. package/dist/utils/error-helpers.d.ts.map +1 -1
  324. package/dist/utils/issue-logger.d.ts.map +1 -1
  325. package/dist/utils/mcp-logger.d.ts +14 -2
  326. package/dist/utils/mcp-logger.d.ts.map +1 -1
  327. package/dist/utils/security-utils.d.ts.map +1 -1
  328. package/dist/utils/vector-index-helpers.d.ts +1 -1
  329. package/dist/utils/vector-index-helpers.d.ts.map +1 -1
  330. package/dist/utils/workspace-resolver.d.ts.map +1 -1
  331. package/dist/vector/vector-search-manager/manager.d.ts +2 -2
  332. package/dist/vector/vector-search-manager/manager.d.ts.map +1 -1
  333. package/dist/vector/vector-search-manager/rebuild.d.ts.map +1 -1
  334. package/dist/vendor/lib-agent-exec/interceptors/git-interceptor.d.ts.map +1 -1
  335. package/dist/vendor/lib-agent-exec/schema.d.ts +18 -18
  336. package/dist/vendor/lib-agent-exec/schema.d.ts.map +1 -1
  337. package/dist/vendor/lib-agent-exec/stream-manager.d.ts.map +1 -1
  338. package/dist/worker-script.js +2662 -2645
  339. package/package.json +3 -4
  340. package/skills/memory-journal-mcp/SKILL.md +8 -8
  341. package/dist/auth/context.d.ts +0 -7
  342. package/dist/auth/context.d.ts.map +0 -1
  343. package/dist/chunk-ELMJYRTT.js +0 -29
  344. package/dist/chunk-F6WSLZVN.js +0 -675
  345. package/dist/chunk-JVGY2GHK.js +0 -776
  346. package/dist/chunk-KWSBCSFM.js +0 -411
  347. package/dist/chunk-SP5D3XYY.js +0 -1550
  348. package/dist/chunk-XJMEPP36.js +0 -57
  349. package/dist/database/core/entry-columns.d.ts +0 -8
  350. package/dist/database/core/entry-columns.d.ts.map +0 -1
  351. package/dist/database/core/schema.d.ts +0 -69
  352. package/dist/database/core/schema.d.ts.map +0 -1
  353. package/dist/error-helpers-STR7IPUR.js +0 -2
  354. package/dist/git-runner-6OE7PVKA.js +0 -1
  355. package/dist/journal-api-UG43ZD7Y.js +0 -1289
  356. package/dist/tools-RBNFDWIE.js +0 -9
@@ -0,0 +1,746 @@
1
+ import { MAX_CONTENT_LENGTH, MAX_QUERY_LIMIT, resolveProjectContext, safeString, ENTRY_TYPES, coerceSignificanceAlias, SIGNIFICANCE_TYPES } from './chunk-D2FY6XS5.js';
2
+ import { z } from 'zod';
3
+ import * as crypto from 'crypto';
4
+ import { Buffer } from 'buffer';
5
+
6
+ // src/handlers/tools/schemas/hallucination-healer.ts
7
+ var KEY_ALIAS_MAP = {
8
+ id: "entry_id",
9
+ ids: "entry_ids",
10
+ entryId: "entry_id",
11
+ project_id: "project_number",
12
+ projectId: "project_number",
13
+ projectNumber: "project_number",
14
+ project: "project_number",
15
+ workspaceId: "workspace_id",
16
+ workspace: "workspace_id",
17
+ repo: "workspace_id",
18
+ repository: "workspace_id",
19
+ repo_name: "workspace_id",
20
+ isPersonal: "is_personal",
21
+ personal: "is_personal",
22
+ entryType: "entry_type",
23
+ significanceType: "significance_type",
24
+ significance: "significance_type",
25
+ autoContext: "auto_context",
26
+ impactScore: "impact_score",
27
+ impact: "impact_score",
28
+ trustScore: "trust_score",
29
+ trust: "trust_score",
30
+ confidence: "trust_score",
31
+ validationStatus: "validation_status",
32
+ validation: "validation_status",
33
+ workflowRunId: "workflow_run_id",
34
+ workflowName: "workflow_name",
35
+ workflowStatus: "workflow_status",
36
+ prNumber: "pr_number",
37
+ prUrl: "pr_url",
38
+ prStatus: "pr_status",
39
+ issueNumber: "issue_number",
40
+ issueUrl: "issue_url",
41
+ projectOwner: "project_owner",
42
+ shareWithTeam: "share_with_team",
43
+ share_team: "share_with_team",
44
+ team: "share_with_team",
45
+ anchorPath: "anchor_path",
46
+ anchorType: "anchor_type",
47
+ sourceTag: "source_tag",
48
+ targetTag: "target_tag",
49
+ fromEntryId: "from_entry_id",
50
+ fromId: "from_entry_id",
51
+ toEntryId: "to_entry_id",
52
+ toId: "to_entry_id",
53
+ relationshipType: "relationship_type",
54
+ session: "session_id",
55
+ sessionId: "session_id",
56
+ conversation_id: "session_id",
57
+ conversationId: "session_id",
58
+ thread_id: "session_id",
59
+ threadId: "session_id"
60
+ };
61
+ var CONTENT_ALIASES = [
62
+ "entry",
63
+ "text",
64
+ "message",
65
+ "description",
66
+ "summary",
67
+ "notes",
68
+ "body",
69
+ "instructions",
70
+ "details",
71
+ "markdown",
72
+ "post",
73
+ "journal_entry",
74
+ "journalEntry",
75
+ "entry_text",
76
+ "entryText"
77
+ ];
78
+ var PASSED_VALIDATION_ALIASES = /* @__PURE__ */ new Set([
79
+ "pass",
80
+ "success",
81
+ "ok",
82
+ "passed",
83
+ "validated",
84
+ "valid",
85
+ "verified",
86
+ "true",
87
+ "1"
88
+ ]);
89
+ var FAILED_VALIDATION_ALIASES = /* @__PURE__ */ new Set(["fail", "failed", "error", "failing", "false", "0"]);
90
+ var NONE_VALIDATION_ALIASES = /* @__PURE__ */ new Set([
91
+ "none",
92
+ "null",
93
+ "undefined",
94
+ "skip",
95
+ "skipped",
96
+ "unknown",
97
+ "pending"
98
+ ]);
99
+ var SESSION_SUMMARY_TAG_ALIASES = /* @__PURE__ */ new Set([
100
+ "session summary",
101
+ "session_summary",
102
+ "team-session-summary",
103
+ "team_session_summary",
104
+ "team session summary"
105
+ ]);
106
+ var TECHNICAL_NOTE_ALIASES = /* @__PURE__ */ new Set([
107
+ "task",
108
+ "chore",
109
+ "refactor",
110
+ "fix",
111
+ "update",
112
+ "technical",
113
+ "note",
114
+ "documentation",
115
+ "code",
116
+ "coding"
117
+ ]);
118
+ var BUG_FIX_ALIASES = /* @__PURE__ */ new Set(["bug", "bugfix", "bug_fix", "bug-fix", "hotfix", "defect"]);
119
+ function toStr(v) {
120
+ if (typeof v === "string") return v;
121
+ if (typeof v === "number" || typeof v === "boolean") return String(v);
122
+ if (v !== null && v !== void 0) {
123
+ try {
124
+ return JSON.stringify(v);
125
+ } catch {
126
+ return "";
127
+ }
128
+ }
129
+ return "";
130
+ }
131
+ function healMetadataAndContextFields(obj) {
132
+ let modified = false;
133
+ for (const extraKey of ["date", "created_at", "updated_at", "type", "status"]) {
134
+ if (extraKey in obj && extraKey !== "entry_type") {
135
+ if (extraKey === "type" && !("entry_type" in obj)) obj["entry_type"] = obj["type"];
136
+ Reflect.deleteProperty(obj, extraKey);
137
+ modified = true;
138
+ }
139
+ }
140
+ for (const [field, label] of [
141
+ ["context", "Context"],
142
+ ["focus", "Focus"],
143
+ ["resolution", "Resolution"]
144
+ ]) {
145
+ if (field in obj) {
146
+ const val = field === "context" && typeof obj[field] === "object" && obj[field] !== null ? JSON.stringify(obj[field], null, 2) : toStr(obj[field]);
147
+ if (val !== "") {
148
+ const existingContent = toStr(obj["content"]);
149
+ obj["content"] = existingContent !== "" ? `${existingContent}
150
+
151
+ **${label}:** ${val}` : val;
152
+ }
153
+ Reflect.deleteProperty(obj, field);
154
+ modified = true;
155
+ }
156
+ }
157
+ if ("artifacts" in obj) {
158
+ if (Array.isArray(obj["artifacts"]) && obj["artifacts"].length > 0) {
159
+ const artStr = obj["artifacts"].map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(", ");
160
+ const existingContent = toStr(obj["content"]);
161
+ obj["content"] = existingContent !== "" ? `${existingContent}
162
+
163
+ **Artifacts:** ${artStr}` : artStr;
164
+ }
165
+ Reflect.deleteProperty(obj, "artifacts");
166
+ modified = true;
167
+ }
168
+ if ("category" in obj) {
169
+ if (typeof obj["category"] === "string" && obj["category"].trim() !== "") {
170
+ const cat = obj["category"].trim();
171
+ obj["tags"] ??= [];
172
+ if (Array.isArray(obj["tags"]) && !obj["tags"].includes(cat)) obj["tags"].push(cat);
173
+ }
174
+ Reflect.deleteProperty(obj, "category");
175
+ modified = true;
176
+ }
177
+ return modified;
178
+ }
179
+ function healTagsAndEntryType(obj) {
180
+ let modified = false;
181
+ if ("tag" in obj && !("tags" in obj)) {
182
+ obj["tags"] = obj["tag"];
183
+ delete obj["tag"];
184
+ modified = true;
185
+ }
186
+ if ("tags" in obj && typeof obj["tags"] === "string") {
187
+ obj["tags"] = obj["tags"].split(",").map((t) => t.trim()).filter(Boolean);
188
+ modified = true;
189
+ }
190
+ if ("tags" in obj && Array.isArray(obj["tags"])) {
191
+ const healedTags = obj["tags"].map((t) => {
192
+ if (typeof t === "string") {
193
+ const lower = t.toLowerCase().trim();
194
+ if (SESSION_SUMMARY_TAG_ALIASES.has(lower)) return "session-summary";
195
+ if (lower === "commit narrative" || lower === "commit_narrative")
196
+ return "commit-narrative";
197
+ }
198
+ return t;
199
+ });
200
+ if (JSON.stringify(obj["tags"]) !== JSON.stringify(healedTags)) {
201
+ obj["tags"] = healedTags;
202
+ modified = true;
203
+ }
204
+ }
205
+ if ("entry_type" in obj && typeof obj["entry_type"] === "string") {
206
+ const etLower = obj["entry_type"].toLowerCase();
207
+ if (etLower === "session-summary" || SESSION_SUMMARY_TAG_ALIASES.has(etLower)) {
208
+ obj["entry_type"] = "retrospective";
209
+ obj["tags"] ??= [];
210
+ if (Array.isArray(obj["tags"]) && !obj["tags"].includes("session-summary")) {
211
+ obj["tags"].push("session-summary");
212
+ }
213
+ modified = true;
214
+ } else if (etLower === "progress" || etLower === "status" || etLower === "development") {
215
+ obj["entry_type"] = "development_note";
216
+ modified = true;
217
+ } else if (TECHNICAL_NOTE_ALIASES.has(etLower)) {
218
+ obj["entry_type"] = "technical_note";
219
+ obj["tags"] ??= [];
220
+ if (Array.isArray(obj["tags"]) && !obj["tags"].includes(etLower)) {
221
+ obj["tags"].push(etLower);
222
+ }
223
+ modified = true;
224
+ } else if (BUG_FIX_ALIASES.has(etLower)) {
225
+ obj["entry_type"] = "bug_fix";
226
+ modified = true;
227
+ } else if (etLower === "feature") {
228
+ obj["entry_type"] = "feature_implementation";
229
+ modified = true;
230
+ } else if (etLower === "meeting") {
231
+ obj["entry_type"] = "meeting_notes";
232
+ modified = true;
233
+ } else if (!ENTRY_TYPES.some((t) => t === obj["entry_type"])) {
234
+ obj["tags"] ??= [];
235
+ const cleanedTag = etLower.replace(/^[^a-z0-9]+/, "").replace(/_/g, "-");
236
+ if (Array.isArray(obj["tags"]) && cleanedTag.length > 0 && !obj["tags"].includes(cleanedTag)) {
237
+ obj["tags"].push(cleanedTag);
238
+ }
239
+ obj["entry_type"] = "other";
240
+ modified = true;
241
+ }
242
+ }
243
+ if ("significance_type" in obj) {
244
+ const originalSigType = obj["significance_type"];
245
+ coerceSignificanceAlias(obj);
246
+ if (typeof obj["significance_type"] === "string") {
247
+ if (!SIGNIFICANCE_TYPES.some((t) => t === obj["significance_type"])) {
248
+ const badSig = obj["significance_type"].toLowerCase().trim();
249
+ obj["tags"] ??= [];
250
+ if (Array.isArray(obj["tags"])) obj["tags"].push(`significance:${badSig}`);
251
+ delete obj["significance_type"];
252
+ }
253
+ }
254
+ if (originalSigType !== obj["significance_type"]) modified = true;
255
+ }
256
+ return modified;
257
+ }
258
+ function healWorkspaceAndProjectContext(obj) {
259
+ let modified = false;
260
+ const rawProjName = obj["project_name"] ?? obj["projectName"];
261
+ if (rawProjName !== void 0) {
262
+ if (!("project_number" in obj) || obj["project_number"] === void 0) {
263
+ const num = Number(rawProjName);
264
+ const strVal = typeof rawProjName === "string" || typeof rawProjName === "number" ? String(rawProjName) : "";
265
+ if (!Number.isNaN(num) && strVal.trim() !== "") obj["project_number"] = num;
266
+ }
267
+ delete obj["project_name"];
268
+ delete obj["projectName"];
269
+ modified = true;
270
+ }
271
+ if ("project_number" in obj && typeof obj["project_number"] === "string") {
272
+ const cleaned = obj["project_number"].trim();
273
+ let num = Number(cleaned);
274
+ if (Number.isNaN(num) && /^p-?\d+$/i.test(cleaned)) {
275
+ num = Number(cleaned.replace(/^p-?/i, ""));
276
+ }
277
+ if (!Number.isNaN(num) && cleaned !== "") {
278
+ obj["project_number"] = num;
279
+ modified = true;
280
+ } else {
281
+ if (obj["workspace_id"] === void 0 || obj["workspace_id"] === null || obj["workspace_id"] === "default") {
282
+ obj["workspace_id"] = cleaned;
283
+ }
284
+ delete obj["project_number"];
285
+ modified = true;
286
+ }
287
+ }
288
+ const wsId = typeof obj["workspace_id"] === "string" ? obj["workspace_id"] : void 0;
289
+ const projNum = typeof obj["project_number"] === "number" && !Number.isNaN(obj["project_number"]) ? obj["project_number"] : void 0;
290
+ const contentStr = typeof obj["content"] === "string" ? obj["content"] : void 0;
291
+ const tagsArr = Array.isArray(obj["tags"]) ? obj["tags"].filter((t) => typeof t === "string") : void 0;
292
+ if (wsId === void 0 || wsId === "" || wsId === "default" || projNum === void 0) {
293
+ const resolved = resolveProjectContext({
294
+ workspace_id: wsId,
295
+ project_number: projNum,
296
+ content: contentStr,
297
+ tags: tagsArr
298
+ });
299
+ if (resolved.workspaceId !== void 0 && resolved.workspaceId !== "default" && (wsId === void 0 || wsId === "default")) {
300
+ obj["workspace_id"] = resolved.workspaceId;
301
+ modified = true;
302
+ } else if (process.env["MCP_WORKSPACE_ID"] !== void 0 && process.env["MCP_WORKSPACE_ID"].trim() !== "" && (wsId === void 0 || wsId === "default")) {
303
+ obj["workspace_id"] = process.env["MCP_WORKSPACE_ID"].trim();
304
+ modified = true;
305
+ } else if (wsId === void 0) {
306
+ obj["workspace_id"] = "default";
307
+ modified = true;
308
+ }
309
+ if (obj["project_number"] === void 0 && resolved.projectNumber !== void 0) {
310
+ obj["project_number"] = resolved.projectNumber;
311
+ modified = true;
312
+ }
313
+ }
314
+ return modified;
315
+ }
316
+ function healTitleAndAutoContext(obj) {
317
+ let modified = false;
318
+ if ("title" in obj || "heading" in obj || "subject" in obj || "name" in obj) {
319
+ const rawTitle = obj["title"] ?? obj["heading"] ?? obj["subject"] ?? obj["name"];
320
+ if (rawTitle !== void 0 && rawTitle !== null) {
321
+ const titleStr = safeString(rawTitle).trim();
322
+ if (titleStr !== "") {
323
+ const cleanTitle = titleStr.replace(/^#+\s*/, "");
324
+ const currentContent = safeString(obj["content"]).trim();
325
+ if (!("content" in obj) || obj["content"] === void 0 || obj["content"] === null || currentContent === "") {
326
+ if (!("query" in obj)) obj["content"] = `# ${cleanTitle}`;
327
+ } else if (!currentContent.startsWith(`# ${cleanTitle}`)) {
328
+ obj["content"] = `# ${cleanTitle}
329
+
330
+ ${currentContent}`;
331
+ }
332
+ }
333
+ }
334
+ delete obj["title"];
335
+ delete obj["heading"];
336
+ delete obj["subject"];
337
+ delete obj["name"];
338
+ modified = true;
339
+ }
340
+ if ("auto_context" in obj) {
341
+ if (typeof obj["auto_context"] === "object" && obj["auto_context"] !== null) {
342
+ try {
343
+ obj["auto_context"] = JSON.stringify(obj["auto_context"]);
344
+ modified = true;
345
+ } catch {
346
+ }
347
+ }
348
+ if (typeof obj["auto_context"] === "string") {
349
+ const ac = obj["auto_context"].trim().toLowerCase();
350
+ if (ac === "none" || ac === "{}" || ac === '{"commits":[]}') {
351
+ delete obj["auto_context"];
352
+ modified = true;
353
+ } else if (ac.startsWith("{") && ac.includes("'")) {
354
+ try {
355
+ JSON.parse(obj["auto_context"]);
356
+ } catch {
357
+ try {
358
+ const fixed = obj["auto_context"].replace(/'/g, '"');
359
+ const parsed = JSON.parse(fixed);
360
+ obj["auto_context"] = JSON.stringify(parsed);
361
+ modified = true;
362
+ } catch {
363
+ }
364
+ }
365
+ }
366
+ }
367
+ }
368
+ return modified;
369
+ }
370
+ function healAgentHallucinations(val) {
371
+ if (typeof val !== "object" || val === null) return val;
372
+ const obj = { ...val };
373
+ let modified = false;
374
+ for (const [badKey, goodKey] of Object.entries(KEY_ALIAS_MAP)) {
375
+ if (badKey in obj) {
376
+ if (!(goodKey in obj) && obj[badKey] !== void 0) obj[goodKey] = obj[badKey];
377
+ Reflect.deleteProperty(obj, badKey);
378
+ modified = true;
379
+ }
380
+ }
381
+ for (const numField of ["trust_score", "impact_score"]) {
382
+ if (numField in obj && typeof obj[numField] === "string") {
383
+ const n = Number(obj[numField]);
384
+ if (!Number.isNaN(n)) {
385
+ obj[numField] = n;
386
+ modified = true;
387
+ }
388
+ }
389
+ }
390
+ if ("validation_status" in obj && obj["validation_status"] !== void 0 && obj["validation_status"] !== null) {
391
+ const rawVs = obj["validation_status"];
392
+ const vsStr = typeof rawVs === "string" ? rawVs.trim().toLowerCase() : typeof rawVs === "number" || typeof rawVs === "boolean" ? String(rawVs) : "";
393
+ if (rawVs === true || PASSED_VALIDATION_ALIASES.has(vsStr)) {
394
+ obj["validation_status"] = "passed";
395
+ modified = true;
396
+ } else if (rawVs === false || FAILED_VALIDATION_ALIASES.has(vsStr)) {
397
+ obj["validation_status"] = "failed";
398
+ modified = true;
399
+ } else if (NONE_VALIDATION_ALIASES.has(vsStr)) {
400
+ obj["validation_status"] = "none";
401
+ } else if (typeof rawVs === "string" && !["passed", "none", "failed"].includes(vsStr)) {
402
+ obj["validation_status"] = "none";
403
+ modified = true;
404
+ }
405
+ }
406
+ if (healWorkspaceAndProjectContext(obj)) modified = true;
407
+ if ("entry" in obj && typeof obj["entry"] === "object" && obj["entry"] !== null && !Array.isArray(obj["entry"])) {
408
+ const nested = obj["entry"];
409
+ Reflect.deleteProperty(obj, "entry");
410
+ for (const [k, v] of Object.entries(nested)) {
411
+ if (!(k in obj) && v !== void 0) obj[k] = v;
412
+ }
413
+ modified = true;
414
+ }
415
+ if ("entry" in obj) {
416
+ const entryVal = obj["entry"];
417
+ if (typeof entryVal === "number" || typeof entryVal === "string" && /^\d+$/.test(entryVal.trim()) && !("tags" in obj) && !("entry_type" in obj) && !("title" in obj)) {
418
+ if (!("entry_id" in obj)) {
419
+ obj["entry_id"] = typeof entryVal === "number" ? entryVal : Number(entryVal.trim());
420
+ modified = true;
421
+ }
422
+ Reflect.deleteProperty(obj, "entry");
423
+ }
424
+ }
425
+ for (const key of CONTENT_ALIASES) {
426
+ if (key in obj && !("content" in obj)) {
427
+ obj["content"] = obj[key];
428
+ Reflect.deleteProperty(obj, key);
429
+ modified = true;
430
+ break;
431
+ } else if (key in obj) {
432
+ Reflect.deleteProperty(obj, key);
433
+ modified = true;
434
+ }
435
+ }
436
+ if (healTitleAndAutoContext(obj)) modified = true;
437
+ if ("entry_id" in obj && typeof obj["entry_id"] === "string") {
438
+ const cleaned = obj["entry_id"].replace(/^[^0-9]+/, "");
439
+ const num = Number(cleaned);
440
+ if (!Number.isNaN(num) && cleaned.trim() !== "") {
441
+ obj["entry_id"] = num;
442
+ modified = true;
443
+ }
444
+ }
445
+ if ("entry_ids" in obj && Array.isArray(obj["entry_ids"])) {
446
+ const healedIds = obj["entry_ids"].map((id) => {
447
+ if (typeof id === "string") {
448
+ const cleaned = id.replace(/^[^0-9]+/, "");
449
+ const num = Number(cleaned);
450
+ return !Number.isNaN(num) && cleaned.trim() !== "" ? num : id;
451
+ }
452
+ return id;
453
+ });
454
+ if (JSON.stringify(obj["entry_ids"]) !== JSON.stringify(healedIds)) {
455
+ obj["entry_ids"] = healedIds;
456
+ modified = true;
457
+ }
458
+ }
459
+ if (healMetadataAndContextFields(obj)) modified = true;
460
+ if (healTagsAndEntryType(obj)) modified = true;
461
+ return modified ? obj : val;
462
+ }
463
+ var ErrorFieldsMixin = z.object({
464
+ error: z.string().optional().describe("Human-readable error message"),
465
+ code: z.string().optional().describe("Error code (e.g. VALIDATION_ERROR, INTERNAL_ERROR)"),
466
+ category: z.string().optional().describe("Error category (validation, query, connection, internal)"),
467
+ recoverable: z.boolean().optional().describe("Whether the error is recoverable"),
468
+ suggestion: z.string().optional().describe("Suggested fix for the error"),
469
+ aggregated_errors: z.array(z.object({ message: z.string() }).catchall(z.unknown())).optional().describe("Details of individual errors in a multi-step operation"),
470
+ details: z.record(z.string(), z.unknown()).optional().describe("Additional error context")
471
+ });
472
+
473
+ // src/handlers/tools/schemas/output-schemas.ts
474
+ var BatchResultOutputSchema = z.object({
475
+ success: z.boolean().optional(),
476
+ count: z.number().optional(),
477
+ error: z.string().optional()
478
+ }).extend(ErrorFieldsMixin.shape);
479
+ var EntryOutputSchema = z.object({
480
+ id: z.number(),
481
+ content: z.string().max(MAX_CONTENT_LENGTH),
482
+ entryType: z.string(),
483
+ isPersonal: z.boolean(),
484
+ timestamp: z.string(),
485
+ tags: z.array(z.string()).optional(),
486
+ significanceType: z.string().nullable().optional(),
487
+ autoContext: z.string().nullable().optional().describe("@deprecated Use author and flagMetadata instead"),
488
+ author: z.string().nullable().optional(),
489
+ flagMetadata: z.record(z.string(), z.unknown()).nullable().optional(),
490
+ deletedAt: z.string().nullable().optional(),
491
+ isArchived: z.boolean().optional(),
492
+ projectNumber: z.number().nullable().optional(),
493
+ projectName: z.string().optional().describe("Injected repository or project name resolved from projectRegistry"),
494
+ projectOwner: z.string().nullable().optional(),
495
+ issueNumber: z.number().nullable().optional(),
496
+ issueUrl: z.string().nullable().optional(),
497
+ prNumber: z.number().nullable().optional(),
498
+ prUrl: z.string().nullable().optional(),
499
+ prStatus: z.string().nullable().optional(),
500
+ workflowRunId: z.number().nullable().optional(),
501
+ workflowName: z.string().nullable().optional(),
502
+ workflowStatus: z.string().nullable().optional(),
503
+ workspaceId: z.string().optional().describe("Workspace isolation identifier"),
504
+ source: z.enum(["personal", "team"]).optional(),
505
+ importanceScore: z.number().optional().describe("Importance score (0.0-1.0), present when sort_by=importance"),
506
+ trustScore: z.number().optional(),
507
+ impactScore: z.number().optional(),
508
+ validationStatus: z.string().optional(),
509
+ version: z.number().optional(),
510
+ sessionId: z.string().nullable().optional()
511
+ }).extend(ErrorFieldsMixin.shape);
512
+ var EntriesListOutputSchema = z.object({
513
+ entries: z.array(EntryOutputSchema).optional(),
514
+ count: z.number().optional(),
515
+ searchMode: z.string().optional(),
516
+ degraded: z.boolean().optional().describe(
517
+ "True if the search degraded to a slower fallback method due to infrastructure failure"
518
+ ),
519
+ next_cursor: z.string().optional().describe("Cursor for the next page of results"),
520
+ highlights: z.array(z.object({ id: z.number(), snippet: z.string() })).optional().describe("FTS5 search snippets when include_highlights is true"),
521
+ facets: z.object({
522
+ tags: z.array(z.object({ name: z.string(), count: z.number() })),
523
+ entryTypes: z.array(z.object({ name: z.string(), count: z.number() }))
524
+ }).optional().describe("Distribution counts when include_facets is true"),
525
+ suggestions: z.array(z.string()).optional().describe("Fuzzy matches when fuzzy_match=true and no exact results were found"),
526
+ correctedQuery: z.string().optional().describe("The corrected query when auto_correct=true and a confident match was found"),
527
+ success: z.boolean().optional(),
528
+ error: z.string().optional()
529
+ }).extend(ErrorFieldsMixin.shape);
530
+ var EntryRevisionOutputSchema = z.object({
531
+ id: z.number(),
532
+ entryId: z.number(),
533
+ revisionNumber: z.number(),
534
+ contentSnapshot: z.string(),
535
+ changedAt: z.string(),
536
+ changedBy: z.string().nullable().optional()
537
+ }).extend(ErrorFieldsMixin.shape);
538
+ z.object({
539
+ revisions: z.array(EntryRevisionOutputSchema).optional(),
540
+ count: z.number().optional(),
541
+ success: z.boolean().optional(),
542
+ error: z.string().optional()
543
+ }).extend(ErrorFieldsMixin.shape);
544
+ var RelationshipOutputSchema = z.object({
545
+ id: z.number(),
546
+ fromEntryId: z.number(),
547
+ toEntryId: z.number(),
548
+ relationshipType: z.string(),
549
+ description: z.string().nullable().optional(),
550
+ createdAt: z.string()
551
+ }).extend(ErrorFieldsMixin.shape);
552
+ var ImportanceBreakdownSchema = z.object({
553
+ significance: z.number(),
554
+ relationships: z.number(),
555
+ causal: z.number(),
556
+ recency: z.number(),
557
+ trustModifier: z.number().optional()
558
+ });
559
+ var TagOutputSchema = z.object({
560
+ name: z.string(),
561
+ count: z.number().nullable()
562
+ }).extend(ErrorFieldsMixin.shape);
563
+ function calcPerDbLimit(limit, hasTeamDb) {
564
+ return hasTeamDb ? Math.min(limit * 2, MAX_QUERY_LIMIT) : limit;
565
+ }
566
+ function mergeMultipleSources(sources, limit, sortBy = "timestamp") {
567
+ const seen = /* @__PURE__ */ new Set();
568
+ const merged = [];
569
+ const all = sources.flat().sort((a, b) => {
570
+ if (sortBy === "importance") {
571
+ const scoreA = Number(a["importanceScore"]) || 0;
572
+ const scoreB = Number(b["importanceScore"]) || 0;
573
+ if (scoreA !== scoreB) {
574
+ return scoreB - scoreA;
575
+ }
576
+ }
577
+ return b.timestamp.localeCompare(a.timestamp);
578
+ });
579
+ for (const entry of all) {
580
+ const entryId = typeof entry["id"] === "number" || typeof entry["id"] === "string" ? String(entry["id"]) : "";
581
+ const sourceKey = entry.team_db ? `${entry.source}:${entry.team_db}` : entry.source;
582
+ const key = entryId ? `${sourceKey}:${entryId}` : crypto.createHash("sha256").update(`${sourceKey}:${entry.content}`).digest("hex");
583
+ if (!seen.has(key)) {
584
+ seen.add(key);
585
+ merged.push(entry);
586
+ }
587
+ }
588
+ return limit !== void 0 ? merged.slice(0, limit) : merged;
589
+ }
590
+ function mergeAndDedup(personal, team, limit, sortBy = "timestamp") {
591
+ return mergeMultipleSources([personal, team], limit, sortBy);
592
+ }
593
+ function passMetadataFilters(entry, options, db) {
594
+ if (options.workspaceId !== void 0 && options.workspaceId !== "*" && entry.workspaceId !== options.workspaceId) {
595
+ return false;
596
+ }
597
+ if (options.isPersonal !== void 0 && entry.isPersonal !== options.isPersonal) return false;
598
+ if (options.projectNumber !== void 0 && entry.projectNumber !== options.projectNumber)
599
+ return false;
600
+ if (options.issueNumber !== void 0 && entry.issueNumber !== options.issueNumber) return false;
601
+ if (options.prNumber !== void 0 && entry.prNumber !== options.prNumber) return false;
602
+ if (options.prStatus !== void 0 && entry.prStatus !== options.prStatus) return false;
603
+ if (options.workflowRunId !== void 0 && entry.workflowRunId !== options.workflowRunId)
604
+ return false;
605
+ if (options.entryType && entry.entryType !== options.entryType) return false;
606
+ if (options.startDate) {
607
+ const entryDate = entry.timestamp.split("T")[0] ?? "";
608
+ if (entryDate < options.startDate) return false;
609
+ }
610
+ if (options.endDate) {
611
+ const entryDate = entry.timestamp.split("T")[0] ?? "";
612
+ if (entryDate > options.endDate) return false;
613
+ }
614
+ if (options.tags && options.tags.length > 0) {
615
+ const entryTags = Array.isArray(entry.tags) ? entry.tags : db.getTagsForEntry(entry.id);
616
+ if (!options.tags.some((t) => entryTags.includes(t))) return false;
617
+ }
618
+ if (!options.includeArchived && entry.isArchived) return false;
619
+ return true;
620
+ }
621
+ function encodeCompoundCursor(personalCursor, teamCursor) {
622
+ return Buffer.from(JSON.stringify({ p: personalCursor, t: teamCursor })).toString("base64");
623
+ }
624
+ function decodeCompoundCursor(cursor) {
625
+ try {
626
+ const decoded = Buffer.from(cursor, "base64").toString("utf8");
627
+ return JSON.parse(decoded);
628
+ } catch {
629
+ return null;
630
+ }
631
+ }
632
+ function ftsSearch(query, db, teamDb, options) {
633
+ const hasFilters = options.projectNumber !== void 0 || options.issueNumber !== void 0 || options.prNumber !== void 0 || options.prStatus !== void 0 || options.workflowRunId !== void 0 || options.isPersonal !== void 0 || options.tags !== void 0 || options.entryType !== void 0 || options.startDate !== void 0 || options.endDate !== void 0;
634
+ let personalCursor;
635
+ let teamCursor;
636
+ if (options.cursor) {
637
+ if (teamDb && options.includeTeam === true && options.isPersonal !== true) {
638
+ const compound = decodeCompoundCursor(options.cursor);
639
+ if (compound) {
640
+ personalCursor = compound.p;
641
+ teamCursor = compound.t;
642
+ } else {
643
+ personalCursor = options.cursor;
644
+ }
645
+ } else {
646
+ personalCursor = options.cursor;
647
+ }
648
+ }
649
+ const perDbLimit = calcPerDbLimit(options.limit, !!teamDb);
650
+ let personalResult;
651
+ if (!query && !hasFilters) {
652
+ personalResult = db.getRecentEntries(perDbLimit, options.isPersonal, options.sortBy, personalCursor, options.includeArchived, options.workspaceId);
653
+ } else {
654
+ personalResult = db.searchEntries(query || "", {
655
+ limit: perDbLimit,
656
+ cursor: personalCursor,
657
+ isPersonal: options.isPersonal,
658
+ projectNumber: options.projectNumber,
659
+ issueNumber: options.issueNumber,
660
+ prNumber: options.prNumber,
661
+ prStatus: options.prStatus,
662
+ workflowRunId: options.workflowRunId,
663
+ tags: options.tags,
664
+ entryType: options.entryType,
665
+ startDate: options.startDate,
666
+ endDate: options.endDate,
667
+ sortBy: options.sortBy,
668
+ includeHighlights: options.includeHighlights,
669
+ fuzzy_match: options.fuzzy_match,
670
+ auto_correct: options.auto_correct,
671
+ includeArchived: options.includeArchived,
672
+ workspaceId: options.workspaceId
673
+ });
674
+ }
675
+ const personalEntries = personalResult.entries;
676
+ const personalNextCursor = personalResult.nextCursor;
677
+ if (teamDb && options.includeTeam === true && options.isPersonal !== true) {
678
+ let teamResult;
679
+ if (!query && !hasFilters) {
680
+ teamResult = teamDb.getRecentEntries(perDbLimit, void 0, options.sortBy, teamCursor, options.includeArchived, options.workspaceId);
681
+ } else {
682
+ teamResult = teamDb.searchEntries(query || "", {
683
+ limit: perDbLimit,
684
+ cursor: teamCursor,
685
+ projectNumber: options.projectNumber,
686
+ issueNumber: options.issueNumber,
687
+ prNumber: options.prNumber,
688
+ prStatus: options.prStatus,
689
+ workflowRunId: options.workflowRunId,
690
+ tags: options.tags,
691
+ entryType: options.entryType,
692
+ startDate: options.startDate,
693
+ endDate: options.endDate,
694
+ sortBy: options.sortBy,
695
+ includeHighlights: options.includeHighlights,
696
+ fuzzy_match: options.fuzzy_match,
697
+ auto_correct: options.auto_correct,
698
+ includeArchived: options.includeArchived,
699
+ workspaceId: options.workspaceId
700
+ });
701
+ }
702
+ const teamEntries = teamResult.entries;
703
+ const teamNextCursor = teamResult.nextCursor;
704
+ const merged = mergeAndDedup(
705
+ personalEntries.map((e) => ({ ...e, source: "personal" })),
706
+ teamEntries.map((e) => ({ ...e, source: "team" })),
707
+ options.limit,
708
+ options.sortBy
709
+ );
710
+ let compoundNextCursor;
711
+ if (personalNextCursor || teamNextCursor) {
712
+ compoundNextCursor = encodeCompoundCursor(personalNextCursor, teamNextCursor);
713
+ }
714
+ const isTeamDegraded = "degraded" in teamResult && teamResult.degraded === true;
715
+ const isPersonalDegraded2 = "degraded" in personalResult && personalResult.degraded === true;
716
+ let mergedHighlights;
717
+ if (options.includeHighlights) {
718
+ const pHighlights = personalResult.highlights ?? [];
719
+ const tHighlights = teamResult.highlights ?? [];
720
+ if (pHighlights.length > 0 || tHighlights.length > 0) {
721
+ mergedHighlights = [...pHighlights, ...tHighlights];
722
+ }
723
+ }
724
+ return {
725
+ entries: merged,
726
+ count: merged.length,
727
+ degraded: isPersonalDegraded2 || isTeamDegraded,
728
+ nextCursor: compoundNextCursor,
729
+ highlights: mergedHighlights,
730
+ suggestions: personalResult.suggestions ?? teamResult.suggestions,
731
+ correctedQuery: personalResult.correctedQuery ?? teamResult.correctedQuery
732
+ };
733
+ }
734
+ const isPersonalDegraded = "degraded" in personalResult && personalResult.degraded === true;
735
+ return {
736
+ entries: personalEntries.map((e) => ({ ...e, source: "personal" })),
737
+ count: personalEntries.length,
738
+ degraded: isPersonalDegraded,
739
+ nextCursor: personalNextCursor,
740
+ highlights: personalResult.highlights,
741
+ suggestions: personalResult.suggestions,
742
+ correctedQuery: personalResult.correctedQuery
743
+ };
744
+ }
745
+
746
+ export { BatchResultOutputSchema, EntriesListOutputSchema, EntryOutputSchema, ErrorFieldsMixin, ImportanceBreakdownSchema, RelationshipOutputSchema, TagOutputSchema, calcPerDbLimit, decodeCompoundCursor, encodeCompoundCursor, ftsSearch, healAgentHallucinations, mergeAndDedup, mergeMultipleSources, passMetadataFilters };