@rubytech/create-maxy-code 0.1.59 → 0.1.61

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 (284) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/PLUGIN.md +1 -1
  3. package/payload/platform/plugins/brochures/skills/property-brochure/SKILL.md +26 -3
  4. package/payload/platform/plugins/brochures/skills/property-brochure/references/registers.md +1 -1
  5. package/payload/platform/plugins/docs/references/admin-session.md +2 -2
  6. package/payload/platform/plugins/docs/references/internals.md +1 -1
  7. package/payload/platform/plugins/docs/references/plugins-guide.md +1 -1
  8. package/payload/platform/plugins/epc/.claude-plugin/plugin.json +17 -0
  9. package/payload/platform/plugins/epc/PLUGIN.md +85 -0
  10. package/payload/platform/plugins/epc/mcp/dist/index.d.ts +2 -0
  11. package/payload/platform/plugins/epc/mcp/dist/index.d.ts.map +1 -0
  12. package/payload/platform/plugins/epc/mcp/dist/index.js +117 -0
  13. package/payload/platform/plugins/epc/mcp/dist/index.js.map +1 -0
  14. package/payload/platform/plugins/epc/mcp/dist/lib/crypto.d.ts +3 -0
  15. package/payload/platform/plugins/epc/mcp/dist/lib/crypto.d.ts.map +1 -0
  16. package/payload/platform/plugins/epc/mcp/dist/lib/crypto.js +72 -0
  17. package/payload/platform/plugins/epc/mcp/dist/lib/crypto.js.map +1 -0
  18. package/payload/platform/plugins/epc/mcp/dist/lib/epc-api.d.ts +60 -0
  19. package/payload/platform/plugins/epc/mcp/dist/lib/epc-api.d.ts.map +1 -0
  20. package/payload/platform/plugins/epc/mcp/dist/lib/epc-api.js +181 -0
  21. package/payload/platform/plugins/epc/mcp/dist/lib/epc-api.js.map +1 -0
  22. package/payload/platform/plugins/epc/mcp/dist/lib/file-crypto.d.ts +3 -0
  23. package/payload/platform/plugins/epc/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  24. package/payload/platform/plugins/epc/mcp/dist/lib/file-crypto.js +49 -0
  25. package/payload/platform/plugins/epc/mcp/dist/lib/file-crypto.js.map +1 -0
  26. package/payload/platform/plugins/epc/mcp/dist/lib/key-store.d.ts +15 -0
  27. package/payload/platform/plugins/epc/mcp/dist/lib/key-store.d.ts.map +1 -0
  28. package/payload/platform/plugins/epc/mcp/dist/lib/key-store.js +130 -0
  29. package/payload/platform/plugins/epc/mcp/dist/lib/key-store.js.map +1 -0
  30. package/payload/platform/plugins/epc/mcp/dist/lib/neo4j.d.ts +5 -0
  31. package/payload/platform/plugins/epc/mcp/dist/lib/neo4j.d.ts.map +1 -0
  32. package/payload/platform/plugins/epc/mcp/dist/lib/neo4j.js +38 -0
  33. package/payload/platform/plugins/epc/mcp/dist/lib/neo4j.js.map +1 -0
  34. package/payload/platform/plugins/epc/mcp/dist/tools/key-deregister.d.ts +4 -0
  35. package/payload/platform/plugins/epc/mcp/dist/tools/key-deregister.d.ts.map +1 -0
  36. package/payload/platform/plugins/epc/mcp/dist/tools/key-deregister.js +9 -0
  37. package/payload/platform/plugins/epc/mcp/dist/tools/key-deregister.js.map +1 -0
  38. package/payload/platform/plugins/epc/mcp/dist/tools/key-list.d.ts +4 -0
  39. package/payload/platform/plugins/epc/mcp/dist/tools/key-list.d.ts.map +1 -0
  40. package/payload/platform/plugins/epc/mcp/dist/tools/key-list.js +10 -0
  41. package/payload/platform/plugins/epc/mcp/dist/tools/key-list.js.map +1 -0
  42. package/payload/platform/plugins/epc/mcp/dist/tools/key-register.d.ts +5 -0
  43. package/payload/platform/plugins/epc/mcp/dist/tools/key-register.d.ts.map +1 -0
  44. package/payload/platform/plugins/epc/mcp/dist/tools/key-register.js +36 -0
  45. package/payload/platform/plugins/epc/mcp/dist/tools/key-register.js.map +1 -0
  46. package/payload/platform/plugins/epc/mcp/dist/tools/lookup.d.ts +10 -0
  47. package/payload/platform/plugins/epc/mcp/dist/tools/lookup.d.ts.map +1 -0
  48. package/payload/platform/plugins/epc/mcp/dist/tools/lookup.js +30 -0
  49. package/payload/platform/plugins/epc/mcp/dist/tools/lookup.js.map +1 -0
  50. package/payload/platform/plugins/epc/mcp/package-lock.json +2566 -0
  51. package/payload/platform/plugins/epc/mcp/package.json +21 -0
  52. package/payload/platform/plugins/epc/mcp/src/__tests__/epc-api.test.ts +251 -0
  53. package/payload/platform/plugins/epc/mcp/src/__tests__/key-roundtrip.test.ts +113 -0
  54. package/payload/platform/plugins/epc/mcp/src/__tests__/lookup.test.ts +181 -0
  55. package/payload/platform/plugins/epc/mcp/src/__tests__/schema-parity.test.ts +54 -0
  56. package/payload/platform/plugins/epc/mcp/src/index.ts +156 -0
  57. package/payload/platform/plugins/epc/mcp/src/lib/crypto.ts +79 -0
  58. package/payload/platform/plugins/epc/mcp/src/lib/epc-api.ts +241 -0
  59. package/payload/platform/plugins/epc/mcp/src/lib/file-crypto.ts +55 -0
  60. package/payload/platform/plugins/epc/mcp/src/lib/key-store.ts +172 -0
  61. package/payload/platform/plugins/epc/mcp/src/lib/neo4j.ts +47 -0
  62. package/payload/platform/plugins/epc/mcp/src/tools/key-deregister.ts +9 -0
  63. package/payload/platform/plugins/epc/mcp/src/tools/key-list.ts +10 -0
  64. package/payload/platform/plugins/epc/mcp/src/tools/key-register.ts +44 -0
  65. package/payload/platform/plugins/epc/mcp/src/tools/lookup.ts +43 -0
  66. package/payload/platform/plugins/epc/mcp/tsconfig.json +20 -0
  67. package/payload/platform/plugins/epc/mcp/vitest.config.ts +8 -0
  68. package/payload/platform/plugins/loop/PLUGIN.md +13 -1
  69. package/payload/platform/plugins/loop/mcp/dist/index.js +8 -7
  70. package/payload/platform/plugins/loop/mcp/dist/index.js.map +1 -1
  71. package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
  72. package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  73. package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
  74. package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
  75. package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
  76. package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
  77. package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js +165 -0
  78. package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
  79. package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
  80. package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
  81. package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
  82. package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
  83. package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
  84. package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
  85. package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
  86. package/payload/platform/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
  87. package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js +11 -28
  88. package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
  89. package/payload/platform/plugins/loop/mcp/src/index.ts +10 -7
  90. package/payload/platform/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
  91. package/payload/platform/plugins/loop/mcp/src/lib/key-store.ts +221 -0
  92. package/payload/platform/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
  93. package/payload/platform/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
  94. package/payload/platform/plugins/loop/mcp/src/tools/key-register.ts +14 -39
  95. package/payload/platform/plugins/preval/.claude-plugin/plugin.json +1 -1
  96. package/payload/platform/plugins/preval/PLUGIN.md +23 -17
  97. package/payload/platform/plugins/preval/skills/property-preval/SKILL.md +78 -38
  98. package/payload/platform/plugins/preval/skills/property-preval/references/render.py +288 -81
  99. package/payload/platform/plugins/preval/skills/property-preval/references/template-inputs.schema.json +125 -80
  100. package/payload/platform/plugins/preval/skills/property-preval/references/template.html +184 -124
  101. package/payload/platform/plugins/property-data/PLUGIN.md +14 -1
  102. package/payload/platform/plugins/property-data/mcp/dist/index.js +14 -11
  103. package/payload/platform/plugins/property-data/mcp/dist/index.js.map +1 -1
  104. package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
  105. package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  106. package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
  107. package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
  108. package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
  109. package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
  110. package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
  111. package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
  112. package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
  113. package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
  114. package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
  115. package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
  116. package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
  117. package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js +2 -2
  118. package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
  119. package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
  120. package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
  121. package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
  122. package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
  123. package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
  124. package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
  125. package/payload/platform/plugins/property-data/mcp/src/index.ts +16 -11
  126. package/payload/platform/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
  127. package/payload/platform/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
  128. package/payload/platform/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
  129. package/payload/platform/plugins/property-data/mcp/src/tools/endpoints.ts +2 -2
  130. package/payload/platform/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
  131. package/payload/platform/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
  132. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  133. package/payload/platform/services/claude-session-manager/dist/http-server.js +6 -1
  134. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  135. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +7 -0
  136. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  137. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +8 -0
  138. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  139. package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
  140. package/payload/platform/templates/agents/admin/SOUL.md +1 -1
  141. package/payload/premium-plugins/real-agent/BUNDLE.md +4 -2
  142. package/payload/premium-plugins/real-agent/agents/valuer.md +1 -1
  143. package/payload/premium-plugins/real-agent/plugins/.claude-plugin/marketplace.json +5 -0
  144. package/payload/premium-plugins/real-agent/plugins/brochures/skills/property-brochure/SKILL.md +26 -3
  145. package/payload/premium-plugins/real-agent/plugins/brochures/skills/property-brochure/references/registers.md +1 -1
  146. package/payload/premium-plugins/real-agent/plugins/epc/.claude-plugin/plugin.json +17 -0
  147. package/payload/premium-plugins/real-agent/plugins/epc/PLUGIN.md +85 -0
  148. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/index.d.ts +2 -0
  149. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/index.d.ts.map +1 -0
  150. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/index.js +117 -0
  151. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/index.js.map +1 -0
  152. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/crypto.d.ts +3 -0
  153. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/crypto.d.ts.map +1 -0
  154. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/crypto.js +72 -0
  155. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/crypto.js.map +1 -0
  156. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/epc-api.d.ts +60 -0
  157. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/epc-api.d.ts.map +1 -0
  158. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/epc-api.js +181 -0
  159. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/epc-api.js.map +1 -0
  160. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/file-crypto.d.ts +3 -0
  161. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  162. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/file-crypto.js +49 -0
  163. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/file-crypto.js.map +1 -0
  164. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/key-store.d.ts +15 -0
  165. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/key-store.d.ts.map +1 -0
  166. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/key-store.js +130 -0
  167. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/key-store.js.map +1 -0
  168. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/neo4j.d.ts +5 -0
  169. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/neo4j.d.ts.map +1 -0
  170. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/neo4j.js +38 -0
  171. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/lib/neo4j.js.map +1 -0
  172. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-deregister.d.ts +4 -0
  173. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-deregister.d.ts.map +1 -0
  174. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-deregister.js +9 -0
  175. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-deregister.js.map +1 -0
  176. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-list.d.ts +4 -0
  177. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-list.d.ts.map +1 -0
  178. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-list.js +10 -0
  179. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-list.js.map +1 -0
  180. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-register.d.ts +5 -0
  181. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-register.d.ts.map +1 -0
  182. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-register.js +36 -0
  183. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/key-register.js.map +1 -0
  184. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/lookup.d.ts +10 -0
  185. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/lookup.d.ts.map +1 -0
  186. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/lookup.js +30 -0
  187. package/payload/premium-plugins/real-agent/plugins/epc/mcp/dist/tools/lookup.js.map +1 -0
  188. package/payload/premium-plugins/real-agent/plugins/epc/mcp/package-lock.json +2566 -0
  189. package/payload/premium-plugins/real-agent/plugins/epc/mcp/package.json +21 -0
  190. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/__tests__/epc-api.test.ts +251 -0
  191. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/__tests__/key-roundtrip.test.ts +113 -0
  192. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/__tests__/lookup.test.ts +181 -0
  193. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/__tests__/schema-parity.test.ts +54 -0
  194. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/index.ts +156 -0
  195. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/lib/crypto.ts +79 -0
  196. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/lib/epc-api.ts +241 -0
  197. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/lib/file-crypto.ts +55 -0
  198. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/lib/key-store.ts +172 -0
  199. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/lib/neo4j.ts +47 -0
  200. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/tools/key-deregister.ts +9 -0
  201. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/tools/key-list.ts +10 -0
  202. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/tools/key-register.ts +44 -0
  203. package/payload/premium-plugins/real-agent/plugins/epc/mcp/src/tools/lookup.ts +43 -0
  204. package/payload/premium-plugins/real-agent/plugins/epc/mcp/tsconfig.json +20 -0
  205. package/payload/premium-plugins/real-agent/plugins/epc/mcp/vitest.config.ts +8 -0
  206. package/payload/premium-plugins/real-agent/plugins/loop/PLUGIN.md +13 -1
  207. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js +8 -7
  208. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js.map +1 -1
  209. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
  210. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  211. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
  212. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
  213. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
  214. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
  215. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js +165 -0
  216. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
  217. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
  218. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
  219. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
  220. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
  221. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
  222. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
  223. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
  224. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
  225. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js +11 -28
  226. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
  227. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/index.ts +10 -7
  228. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
  229. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/key-store.ts +221 -0
  230. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
  231. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
  232. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-register.ts +14 -39
  233. package/payload/premium-plugins/real-agent/plugins/preval/.claude-plugin/plugin.json +1 -1
  234. package/payload/premium-plugins/real-agent/plugins/preval/PLUGIN.md +23 -17
  235. package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/SKILL.md +78 -38
  236. package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/render.py +288 -81
  237. package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template-inputs.schema.json +125 -80
  238. package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template.html +184 -124
  239. package/payload/premium-plugins/real-agent/plugins/property-data/PLUGIN.md +14 -1
  240. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js +14 -11
  241. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js.map +1 -1
  242. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
  243. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
  244. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
  245. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
  246. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
  247. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
  248. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
  249. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
  250. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
  251. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
  252. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
  253. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
  254. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
  255. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js +2 -2
  256. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
  257. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
  258. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
  259. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
  260. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
  261. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
  262. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
  263. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/index.ts +16 -11
  264. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
  265. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
  266. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
  267. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/endpoints.ts +2 -2
  268. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
  269. package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
  270. package/payload/server/public/assets/{admin-nqCBFiSl.js → admin-DhN3G8W7.js} +51 -51
  271. package/payload/server/public/assets/{data-BGUAGVkV.js → data-B2ZVXOcE.js} +1 -1
  272. package/payload/server/public/assets/{graph-MvYxZOBF.js → graph-BAMGPHrK.js} +1 -1
  273. package/payload/server/public/assets/{graph-labels-D865qb3K.js → graph-labels-D9eBbvxo.js} +1 -1
  274. package/payload/server/public/assets/{page-C2b1nlOc.js → page-CV27Al6Z.js} +1 -1
  275. package/payload/server/public/assets/{page--hOVRrgN.js → page-DjdVMWCz.js} +1 -1
  276. package/payload/server/public/data.html +3 -3
  277. package/payload/server/public/graph.html +3 -3
  278. package/payload/server/public/index.html +4 -4
  279. package/payload/server/server.js +7 -19
  280. package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
  281. package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
  282. package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js +0 -196
  283. package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js.map +0 -1
  284. package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/package.json +0 -7
@@ -0,0 +1,181 @@
1
+ import { selectKeyStore } from "./key-store.js";
2
+ // gov.uk EPC register HTTP client. The register lives at
3
+ // epc.opendatacommunities.org and is reached via Basic auth where the
4
+ // credential is `<email>:<api-key>` (the email is the account that
5
+ // generated the key on the dashboard). We store the credential as a single
6
+ // colon-joined string so the key-management surface mirrors property-data
7
+ // exactly (one `apiKey` field per account).
8
+ //
9
+ // Response shape (domestic/search):
10
+ // { "column-names": [...], "rows": [ { "lmk-key": "...",
11
+ // "address1": "...", "address2": "...", "address3": "...",
12
+ // "posttown": "...", "postcode": "...", "uprn": "...",
13
+ // "current-energy-rating": "C", "potential-energy-rating": "B",
14
+ // "lodgement-date": "2023-05-15", "total-floor-area": "75.0", ... } ] }
15
+ //
16
+ // Multiple EPCs per property appear as separate rows (one per lodgement).
17
+ // Callers group by UPRN (or address fallback) and pick the most-recent
18
+ // row per property.
19
+ export const BASE_URL = "https://epc.opendatacommunities.org/api/v1";
20
+ export const REQUEST_TIMEOUT_MS = 15_000;
21
+ export const M2_TO_SQFT = 10.7639;
22
+ export class KeyNotRegisteredError extends Error {
23
+ constructor() {
24
+ super("key-not-registered");
25
+ this.name = "KeyNotRegisteredError";
26
+ }
27
+ }
28
+ export class EpcError extends Error {
29
+ status;
30
+ endpoint;
31
+ upstreamMessage;
32
+ constructor(status, endpoint, upstreamMessage) {
33
+ super(`http-${status} from EPC endpoint=${endpoint}: ${upstreamMessage}`);
34
+ this.status = status;
35
+ this.endpoint = endpoint;
36
+ this.upstreamMessage = upstreamMessage;
37
+ this.name = "EpcError";
38
+ }
39
+ }
40
+ export class BadResponseError extends Error {
41
+ endpoint;
42
+ length;
43
+ constructor(endpoint, length) {
44
+ super(`bad-response from EPC endpoint=${endpoint} (non-JSON, length=${length})`);
45
+ this.endpoint = endpoint;
46
+ this.length = length;
47
+ this.name = "BadResponseError";
48
+ }
49
+ }
50
+ export async function loadAccountKey(accountId) {
51
+ const stored = await selectKeyStore().load(accountId);
52
+ if (!stored)
53
+ return null;
54
+ return { createdAt: stored.createdAt, updatedAt: stored.updatedAt };
55
+ }
56
+ export async function resolveAccountApiKey(accountId) {
57
+ const envKey = process.env.EPC_API_KEY;
58
+ if (envKey && envKey.trim())
59
+ return envKey.trim();
60
+ const stored = await selectKeyStore().load(accountId);
61
+ if (!stored)
62
+ throw new KeyNotRegisteredError();
63
+ return stored.apiKey;
64
+ }
65
+ function basicAuthHeader(credential) {
66
+ return `Basic ${Buffer.from(credential, "utf-8").toString("base64")}`;
67
+ }
68
+ export async function epcSearch(opts) {
69
+ const { toolName, accountId, identifier, params } = opts;
70
+ const credential = await resolveAccountApiKey(accountId);
71
+ const search = new URLSearchParams();
72
+ for (const [k, v] of Object.entries(params)) {
73
+ if (v === undefined || v === null || v === "")
74
+ continue;
75
+ search.set(k, String(v));
76
+ }
77
+ const endpoint = "domestic/search";
78
+ const url = `${BASE_URL}/${endpoint}?${search.toString()}`;
79
+ const start = Date.now();
80
+ const response = await fetch(url, {
81
+ headers: {
82
+ Accept: "application/json",
83
+ Authorization: basicAuthHeader(credential),
84
+ },
85
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
86
+ });
87
+ const ms = Date.now() - start;
88
+ const statusTag = response.ok
89
+ ? "ok"
90
+ : response.status === 404
91
+ ? "http-404"
92
+ : `http-${Math.floor(response.status / 100)}xx`;
93
+ console.error(`[epc] tool=${toolName} account=${accountId} address="${identifier}" status=${statusTag} ms=${ms}`);
94
+ // 404 is a valid outcome — no EPC on file for the address. Surface to the
95
+ // caller as an empty result set; the wrapper turns it into ok+[].
96
+ if (response.status === 404) {
97
+ return { status: 404, rows: [] };
98
+ }
99
+ if (!response.ok) {
100
+ const body = await response.text().catch(() => "");
101
+ throw new EpcError(response.status, endpoint, body.slice(0, 200));
102
+ }
103
+ const text = await response.text();
104
+ let parsed;
105
+ try {
106
+ parsed = JSON.parse(text);
107
+ }
108
+ catch {
109
+ throw new BadResponseError(endpoint, text.length);
110
+ }
111
+ if (!parsed ||
112
+ typeof parsed !== "object" ||
113
+ Array.isArray(parsed) ||
114
+ !("rows" in parsed)) {
115
+ throw new BadResponseError(endpoint, text.length);
116
+ }
117
+ const rows = parsed.rows;
118
+ if (!Array.isArray(rows)) {
119
+ throw new BadResponseError(endpoint, text.length);
120
+ }
121
+ return { status: response.status, rows: rows };
122
+ }
123
+ // Compose the human-readable address from the upstream row's parts. Empty
124
+ // segments are dropped; segments are uppercase in the API and join with
125
+ // ", ".
126
+ function rowAddress(row) {
127
+ const parts = [row.address1, row.address2, row.address3, row.posttown, row.postcode]
128
+ .map((s) => (typeof s === "string" ? s.trim() : ""))
129
+ .filter((s) => s.length > 0);
130
+ return parts.join(", ");
131
+ }
132
+ function parseFloorArea(row) {
133
+ const raw = row["total-floor-area"];
134
+ if (raw == null || raw === "")
135
+ return null;
136
+ const n = Number(raw);
137
+ return Number.isFinite(n) ? n : null;
138
+ }
139
+ // Group rows by UPRN (or address1+postcode when UPRN is absent), then pick
140
+ // the most-recent EPC per group by lodgement date. Rows with no lodgement
141
+ // date sort last.
142
+ export function groupAndPickMostRecent(rows) {
143
+ const buckets = new Map();
144
+ for (const row of rows) {
145
+ const uprn = typeof row.uprn === "string" ? row.uprn.trim() : "";
146
+ const key = uprn || `${row.address1 ?? ""}|${row.postcode ?? ""}`.toLowerCase();
147
+ const existing = buckets.get(key);
148
+ if (existing)
149
+ existing.push(row);
150
+ else
151
+ buckets.set(key, [row]);
152
+ }
153
+ const out = [];
154
+ for (const bucket of buckets.values()) {
155
+ bucket.sort((a, b) => {
156
+ const da = String(a["lodgement-date"] ?? "");
157
+ const db = String(b["lodgement-date"] ?? "");
158
+ // Most-recent first: ISO dates string-sort correctly.
159
+ return db.localeCompare(da);
160
+ });
161
+ const winner = bucket[0];
162
+ const m2 = parseFloorArea(winner);
163
+ out.push({
164
+ total_floor_area_m2: m2,
165
+ total_floor_area_sqft: m2 == null ? null : Number((m2 * M2_TO_SQFT).toFixed(2)),
166
+ current_energy_rating: typeof winner["current-energy-rating"] === "string"
167
+ ? winner["current-energy-rating"]
168
+ : null,
169
+ potential_energy_rating: typeof winner["potential-energy-rating"] === "string"
170
+ ? winner["potential-energy-rating"]
171
+ : null,
172
+ lodgement_date: typeof winner["lodgement-date"] === "string"
173
+ ? winner["lodgement-date"]
174
+ : null,
175
+ address: rowAddress(winner),
176
+ uprn: typeof winner.uprn === "string" && winner.uprn.length > 0 ? winner.uprn : null,
177
+ });
178
+ }
179
+ return out;
180
+ }
181
+ //# sourceMappingURL=epc-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epc-api.js","sourceRoot":"","sources":["../../src/lib/epc-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,yDAAyD;AACzD,sEAAsE;AACtE,mEAAmE;AACnE,2EAA2E;AAC3E,0EAA0E;AAC1E,4CAA4C;AAC5C,EAAE;AACF,oCAAoC;AACpC,2DAA2D;AAC3D,+DAA+D;AAC/D,2DAA2D;AAC3D,oEAAoE;AACpE,4EAA4E;AAC5E,EAAE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AAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function encryptWith(plaintext: string, keyFilePath: string, label: string): string;
2
+ export declare function decryptWith(encryptedValue: string, keyFilePath: string, label: string): string;
3
+ //# sourceMappingURL=file-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-crypto.d.ts","sourceRoot":"","sources":["../../src/lib/file-crypto.ts"],"names":[],"mappings":"AA8BA,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQzF;AAED,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAc9F"}
@@ -0,0 +1,49 @@
1
+ import { randomBytes, createCipheriv, createDecipheriv } from "node:crypto";
2
+ import { readFileSync, writeFileSync, existsSync } from "node:fs";
3
+ // Standalone-mode crypto. Same AES-256-GCM envelope as crypto.ts, but the
4
+ // encryption-key file path is passed in (not derived from PLATFORM_ROOT /
5
+ // brand.json), so it can live under ~/.claude/ when the MCP is spawned by
6
+ // Claude Code natively.
7
+ const ALGORITHM = "aes-256-gcm";
8
+ const KEY_LENGTH = 32;
9
+ const IV_LENGTH = 12;
10
+ const AUTH_TAG_LENGTH = 16;
11
+ function loadOrGenerateKey(keyFilePath, label) {
12
+ if (existsSync(keyFilePath)) {
13
+ const hex = readFileSync(keyFilePath, "utf-8").trim();
14
+ const buf = Buffer.from(hex, "hex");
15
+ if (buf.length !== KEY_LENGTH) {
16
+ throw new Error(`[${label}] encryption key at ${keyFilePath} is ${buf.length} bytes, expected ${KEY_LENGTH}.`);
17
+ }
18
+ return buf;
19
+ }
20
+ const key = randomBytes(KEY_LENGTH);
21
+ writeFileSync(keyFilePath, key.toString("hex"), { mode: 0o600 });
22
+ console.error(`[${label}] encryption key generated at ${keyFilePath}`);
23
+ return key;
24
+ }
25
+ export function encryptWith(plaintext, keyFilePath, label) {
26
+ const key = loadOrGenerateKey(keyFilePath, label);
27
+ const iv = randomBytes(IV_LENGTH);
28
+ const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
29
+ let encrypted = cipher.update(plaintext, "utf-8", "hex");
30
+ encrypted += cipher.final("hex");
31
+ const authTag = cipher.getAuthTag().toString("hex");
32
+ return `${iv.toString("hex")}:${encrypted}:${authTag}`;
33
+ }
34
+ export function decryptWith(encryptedValue, keyFilePath, label) {
35
+ const parts = encryptedValue.split(":");
36
+ if (parts.length !== 3) {
37
+ throw new Error(`[${label}] bad encrypted envelope (expected iv:ct:tag)`);
38
+ }
39
+ const key = loadOrGenerateKey(keyFilePath, label);
40
+ const iv = Buffer.from(parts[0], "hex");
41
+ const ciphertext = parts[1];
42
+ const authTag = Buffer.from(parts[2], "hex");
43
+ const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
44
+ decipher.setAuthTag(authTag);
45
+ let plaintext = decipher.update(ciphertext, "hex", "utf-8");
46
+ plaintext += decipher.final("utf-8");
47
+ return plaintext;
48
+ }
49
+ //# sourceMappingURL=file-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-crypto.js","sourceRoot":"","sources":["../../src/lib/file-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElE,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,wBAAwB;AAExB,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,SAAS,i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AE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,cAAsB,EAAE,WAAmB,EAAE,KAAa;IACpF,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,+CAA+C,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,GAAG,GAAG,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAClD,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,CAAC;IAC1F,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5D,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface StoredKey {
2
+ apiKey: string;
3
+ createdAt: string;
4
+ updatedAt: string;
5
+ }
6
+ export interface KeyStore {
7
+ readonly backendName: string;
8
+ readonly backendPath: string;
9
+ load(accountId: string): Promise<StoredKey | null>;
10
+ save(accountId: string, apiKey: string): Promise<void>;
11
+ delete(accountId: string): Promise<boolean>;
12
+ }
13
+ export declare function selectKeyStore(): KeyStore;
14
+ export declare function _resetKeyStoreForTests(): void;
15
+ //# sourceMappingURL=key-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-store.d.ts","sourceRoot":"","sources":["../../src/lib/key-store.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C;AA0ID,wBAAgB,cAAc,IAAI,QAAQ,CAIzC;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -0,0 +1,130 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
2
+ import { resolve, dirname } from "node:path";
3
+ import { homedir } from "node:os";
4
+ import { getSession } from "./neo4j.js";
5
+ import { encrypt, decrypt } from "./crypto.js";
6
+ import { encryptWith, decryptWith } from "./file-crypto.js";
7
+ class Neo4jKeyStore {
8
+ backendName = "neo4j";
9
+ backendPath = process.env.NEO4J_URI ?? "<unset>";
10
+ async load(accountId) {
11
+ const session = getSession();
12
+ try {
13
+ const result = await session.run(`MATCH (k:EpcApiKey {accountId: $accountId})
14
+ RETURN k.encryptedKey AS encryptedKey,
15
+ k.createdAt AS createdAt,
16
+ k.updatedAt AS updatedAt`, { accountId });
17
+ if (result.records.length === 0)
18
+ return null;
19
+ const r = result.records[0];
20
+ return {
21
+ apiKey: decrypt(r.get("encryptedKey")),
22
+ createdAt: r.get("createdAt") ?? "",
23
+ updatedAt: r.get("updatedAt") ?? "",
24
+ };
25
+ }
26
+ finally {
27
+ await session.close();
28
+ }
29
+ }
30
+ async save(accountId, apiKey) {
31
+ const encryptedKey = encrypt(apiKey);
32
+ const now = new Date().toISOString();
33
+ const session = getSession();
34
+ try {
35
+ await session.run(`CREATE INDEX epc_api_key_account IF NOT EXISTS
36
+ FOR (k:EpcApiKey) ON (k.accountId)`, {});
37
+ await session.run(`MERGE (k:EpcApiKey {accountId: $accountId})
38
+ ON CREATE SET k.encryptedKey = $encryptedKey, k.createdAt = $now, k.updatedAt = $now
39
+ ON MATCH SET k.encryptedKey = $encryptedKey, k.updatedAt = $now`, { accountId, encryptedKey, now });
40
+ }
41
+ finally {
42
+ await session.close();
43
+ }
44
+ }
45
+ async delete(accountId) {
46
+ const session = getSession();
47
+ try {
48
+ const result = await session.run(`MATCH (k:EpcApiKey {accountId: $accountId})
49
+ DELETE k
50
+ RETURN count(k) AS deleted`, { accountId });
51
+ const deleted = result.records[0]?.get("deleted")?.toNumber?.() ?? 0;
52
+ return deleted > 0;
53
+ }
54
+ finally {
55
+ await session.close();
56
+ }
57
+ }
58
+ }
59
+ const LABEL = "epc";
60
+ class FileKeyStore {
61
+ backendName = "file";
62
+ backendPath;
63
+ storePath;
64
+ keyFilePath;
65
+ constructor() {
66
+ const home = homedir();
67
+ this.storePath = resolve(home, ".claude/.realagent-epc-key.enc");
68
+ this.keyFilePath = resolve(home, ".claude/.realagent-epc-encryption-key");
69
+ this.backendPath = this.storePath;
70
+ }
71
+ ensureDir() {
72
+ mkdirSync(dirname(this.storePath), { recursive: true });
73
+ }
74
+ readAll() {
75
+ if (!existsSync(this.storePath))
76
+ return {};
77
+ const blob = readFileSync(this.storePath, "utf-8").trim();
78
+ if (!blob)
79
+ return {};
80
+ const json = decryptWith(blob, this.keyFilePath, LABEL);
81
+ return JSON.parse(json);
82
+ }
83
+ writeAll(env) {
84
+ this.ensureDir();
85
+ const blob = encryptWith(JSON.stringify(env), this.keyFilePath, LABEL);
86
+ writeFileSync(this.storePath, blob, { mode: 0o600 });
87
+ }
88
+ async load(accountId) {
89
+ const env = this.readAll();
90
+ const entry = env[accountId];
91
+ if (!entry)
92
+ return null;
93
+ return {
94
+ apiKey: decryptWith(entry.encryptedKey, this.keyFilePath, LABEL),
95
+ createdAt: entry.createdAt,
96
+ updatedAt: entry.updatedAt,
97
+ };
98
+ }
99
+ async save(accountId, apiKey) {
100
+ const env = this.readAll();
101
+ const now = new Date().toISOString();
102
+ const encryptedKey = encryptWith(apiKey, this.keyFilePath, LABEL);
103
+ const prev = env[accountId];
104
+ env[accountId] = {
105
+ encryptedKey,
106
+ createdAt: prev?.createdAt ?? now,
107
+ updatedAt: now,
108
+ };
109
+ this.writeAll(env);
110
+ }
111
+ async delete(accountId) {
112
+ const env = this.readAll();
113
+ if (!(accountId in env))
114
+ return false;
115
+ delete env[accountId];
116
+ this.writeAll(env);
117
+ return true;
118
+ }
119
+ }
120
+ let cached = null;
121
+ export function selectKeyStore() {
122
+ if (cached)
123
+ return cached;
124
+ cached = process.env.EPC_STANDALONE === "1" ? new FileKeyStore() : new Neo4jKeyStore();
125
+ return cached;
126
+ }
127
+ export function _resetKeyStoreForTests() {
128
+ cached = null;
129
+ }
130
+ //# sourceMappingURL=key-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-store.js","sourceRoot":"","sources":["../../src/lib/key-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO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,EAAE,CAAC;QACrC,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5B,GAAG,CAAC,SAAS,CAAC,GAAG;YACf,YAAY;YACZ,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,GAAG;YACjC,SAAS,EAAE,GAAG;SACf,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACtC,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,IAAI,MAAM,GAAoB,IAAI,CAAC;AAEnC,MAAM,UAAU,cAAc;IAC5B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAC;IACvF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Driver, Session } from "neo4j-driver";
2
+ export declare function getDriver(): Driver;
3
+ export declare function getSession(): Session;
4
+ export declare function closeDriver(): Promise<void>;
5
+ //# sourceMappingURL=neo4j.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neo4j.d.ts","sourceRoot":"","sources":["../../src/lib/neo4j.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAqBtD,wBAAgB,SAAS,IAAI,MAAM,CAclC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD"}
@@ -0,0 +1,38 @@
1
+ import neo4j from "neo4j-driver";
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ let driver = null;
5
+ function readPassword() {
6
+ if (process.env.NEO4J_PASSWORD)
7
+ return process.env.NEO4J_PASSWORD;
8
+ const passwordFile = resolve(process.env.PLATFORM_ROOT ?? resolve(import.meta.dirname, "../../../.."), "config/.neo4j-password");
9
+ try {
10
+ return readFileSync(passwordFile, "utf-8").trim();
11
+ }
12
+ catch {
13
+ throw new Error(`Neo4j password not found. Expected at ${passwordFile} or in NEO4J_PASSWORD env var.`);
14
+ }
15
+ }
16
+ export function getDriver() {
17
+ if (!driver) {
18
+ const uri = process.env.NEO4J_URI;
19
+ if (!uri) {
20
+ throw new Error("[epc] NEO4J_URI unset — refusing to default to bolt://localhost:7687");
21
+ }
22
+ const user = process.env.NEO4J_USER ?? "neo4j";
23
+ const password = readPassword();
24
+ console.error(`[epc] resolved neo4j_uri=${uri}`);
25
+ driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
26
+ }
27
+ return driver;
28
+ }
29
+ export function getSession() {
30
+ return getDriver().session();
31
+ }
32
+ export async function closeDriver() {
33
+ if (driver) {
34
+ await driver.close();
35
+ driver = null;
36
+ }
37
+ }
38
+ //# sourceMappingURL=neo4j.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neo4j.js","sourceRoot":"","sources":["../../src/lib/neo4j.ts"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,C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AC;QACX,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function keyDeregister(params: {
2
+ accountId: string;
3
+ }): Promise<void>;
4
+ //# sourceMappingURL=key-deregister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-deregister.d.ts","sourceRoot":"","sources":["../../src/tools/key-deregister.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF"}
@@ -0,0 +1,9 @@
1
+ import { selectKeyStore } from "../lib/key-store.js";
2
+ export async function keyDeregister(params) {
3
+ const deleted = await selectKeyStore().delete(params.accountId);
4
+ if (!deleted) {
5
+ throw new Error("No EPC API key is registered for this account.");
6
+ }
7
+ console.error(`[epc] key-op op=deregister account=${params.accountId}`);
8
+ }
9
+ //# sourceMappingURL=key-deregister.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-deregister.js","sourceRoot":"","sources":["../../src/tools/key-deregister.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAA6B;IAC/D,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,sCAAsC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function keyList(params: {
2
+ accountId: string;
3
+ }): Promise<string>;
4
+ //# sourceMappingURL=key-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-list.d.ts","sourceRoot":"","sources":["../../src/tools/key-list.ts"],"names":[],"mappings":"AAEA,wBAAsB,OAAO,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5E"}
@@ -0,0 +1,10 @@
1
+ import { loadAccountKey } from "../lib/epc-api.js";
2
+ export async function keyList(params) {
3
+ const key = await loadAccountKey(params.accountId);
4
+ console.error(`[epc] key-op op=list account=${params.accountId}`);
5
+ if (!key) {
6
+ return "No EPC API key registered. Use epc-key-register to add one.";
7
+ }
8
+ return `EPC API key registered (created: ${key.createdAt}, updated: ${key.updatedAt}). Key value is encrypted and cannot be retrieved.`;
9
+ }
10
+ //# sourceMappingURL=key-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-list.js","sourceRoot":"","sources":["../../src/tools/key-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAA6B;IACzD,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,CAAC,KAAK,CAAC,gCAAgC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,6DAA6D,CAAC;IACvE,CAAC;IACD,OAAO,oCAAoC,GAAG,CAAC,SAAS,cAAc,GAAG,CAAC,SAAS,oDAAoD,CAAC;AAC1I,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function keyRegister(params: {
2
+ apiKey: string;
3
+ accountId: string;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=key-register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-register.d.ts","sourceRoot":"","sources":["../../src/tools/key-register.ts"],"names":[],"mappings":"AA8BA,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB"}
@@ -0,0 +1,36 @@
1
+ import { selectKeyStore } from "../lib/key-store.js";
2
+ import { BASE_URL, REQUEST_TIMEOUT_MS, EpcError } from "../lib/epc-api.js";
3
+ // Probe the EPC register with the supplied credential against
4
+ // /domestic/search constrained to a tiny page so we do not pull a real
5
+ // payload. A valid credential returns HTTP 200 (rows may be empty for a
6
+ // nonsense postcode, which is fine — authentication is what we test).
7
+ // An invalid credential returns HTTP 401 Unauthorized.
8
+ async function validateApiKey(credential) {
9
+ const url = `${BASE_URL}/domestic/search?postcode=SW1A1AA&size=1`;
10
+ const response = await fetch(url, {
11
+ headers: {
12
+ Accept: "application/json",
13
+ Authorization: `Basic ${Buffer.from(credential, "utf-8").toString("base64")}`,
14
+ },
15
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
16
+ });
17
+ if (response.status === 401 || response.status === 403) {
18
+ throw new Error(`EPC register rejected the credential (HTTP ${response.status}). Expected format is email:api-key.`);
19
+ }
20
+ // 200, 404 (no rows for that postcode), and 200-with-rows all prove the
21
+ // credential was accepted. Anything else surfaces as the upstream code.
22
+ if (response.status === 200 || response.status === 404)
23
+ return;
24
+ const body = await response.text().catch(() => "");
25
+ throw new EpcError(response.status, "domestic/search", body.slice(0, 200));
26
+ }
27
+ export async function keyRegister(params) {
28
+ const { apiKey, accountId } = params;
29
+ if (!apiKey.includes(":")) {
30
+ throw new Error("EPC credential must be in the form email:api-key (email of the account that generated the key, then a colon, then the API key).");
31
+ }
32
+ await validateApiKey(apiKey);
33
+ await selectKeyStore().save(accountId, apiKey);
34
+ console.error(`[epc] key-op op=register account=${accountId}`);
35
+ }
36
+ //# sourceMappingURL=key-register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-register.js","sourceRoot":"","sources":["../../src/tools/key-register.ts"],"names":[],"mappings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E,GAAG,MAAM,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,cAAc,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,CAAC,KAAK,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare function epcLookupByAddress(args: {
2
+ accountId: string;
3
+ address: string;
4
+ postcode?: string;
5
+ }): Promise<string>;
6
+ export declare function epcLookupByUprn(args: {
7
+ accountId: string;
8
+ uprn: string;
9
+ }): Promise<string>;
10
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/tools/lookup.ts"],"names":[],"mappings":"AAOA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAalB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAalB"}
@@ -0,0 +1,30 @@
1
+ import { epcSearch, groupAndPickMostRecent } from "../lib/epc-api.js";
2
+ export async function epcLookupByAddress(args) {
3
+ const { accountId, address, postcode } = args;
4
+ const { rows } = await epcSearch({
5
+ toolName: "epc-lookup-by-address",
6
+ accountId,
7
+ identifier: address,
8
+ params: { address, postcode, size: 25 },
9
+ });
10
+ const result = {
11
+ status: "ok",
12
+ matches: groupAndPickMostRecent(rows),
13
+ };
14
+ return JSON.stringify(result, null, 2);
15
+ }
16
+ export async function epcLookupByUprn(args) {
17
+ const { accountId, uprn } = args;
18
+ const { rows } = await epcSearch({
19
+ toolName: "epc-lookup-by-uprn",
20
+ accountId,
21
+ identifier: uprn,
22
+ params: { uprn, size: 25 },
23
+ });
24
+ const result = {
25
+ status: "ok",
26
+ matches: groupAndPickMostRecent(rows),
27
+ };
28
+ return JSON.stringify(result, null, 2);
29
+ }
30
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/tools/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAY,MAAM,mBAAmB,CAAC;AAOhF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAIxC;IACC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC;QAC/B,QAAQ,EAAE,uBAAuB;QACjC,SAAS;QACT,UAAU,EAAE,OAAO;QACnB,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;KACxC,CAAC,CAAC;IACH,MAAM,MAAM,GAAiB;QAC3B,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC;KACtC,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAGrC;IACC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC;QAC/B,QAAQ,EAAE,oBAAoB;QAC9B,SAAS;QACT,UAAU,EAAE,IAAI;QAChB,MAAM,EAA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