total-recall-brain 3.43.3 → 3.45.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 (252) hide show
  1. package/bin/total-recall.mjs +6 -4
  2. package/docs/ARCHITECTURE.md +10 -7
  3. package/docs/reference/cli-reference.md +16 -9
  4. package/frontend/dist/assets/index-DACh1dhx.js +5613 -0
  5. package/frontend/dist/index.html +1 -1
  6. package/frontend/src/App.tsx +2 -2
  7. package/frontend/src/pages/PluginsPage.tsx +1 -1
  8. package/package.json +3 -3
  9. package/scaffold/.agent/skills/plugin/SKILL.md +7 -2
  10. package/scaffold/.agent/skills/plugin/evals/README.md +5 -0
  11. package/scaffold/.agent/skills/plugin/evals/cases/01-fabricated-seed.mjs +1 -0
  12. package/scaffold/.agent/skills/plugin/evals/cases/02-reassuring-default.mjs +1 -0
  13. package/scaffold/.agent/skills/plugin/evals/cases/03-declared-template.mjs +1 -0
  14. package/scaffold/.agent/skills/plugin/evals/cases/04-card-collects-credential.mjs +1 -0
  15. package/scaffold/.agent/skills/plugin/evals/cases/05-host-leak-in-scaffold.mjs +1 -0
  16. package/scaffold/.agent/skills/plugin/evals/cases/06-correct-plugin.mjs +1 -0
  17. package/scaffold/.agent/skills/plugin/evals/cases/07-missing-reuse.mjs +11 -0
  18. package/scaffold/.agent/skills/plugin/evals/cases/08-unresolved-owner-command.mjs +12 -0
  19. package/scaffold/.agent/skills/plugin/evals/cases/09-missing-brick.mjs +12 -0
  20. package/scaffold/.agent/skills/plugin/prompts/01-function.md +4 -3
  21. package/scaffold/.agent/skills/plugin/prompts/08-verify.md +1 -0
  22. package/scaffold/.agent/skills/plugin/references/surfaces.md +12 -2
  23. package/scaffold/.agent/skills/plugin/scripts/record.mjs +59 -2
  24. package/scaffold/.agent/skills/total-recall/plugins/auth/README.md +8 -0
  25. package/scaffold/.agent/skills/total-recall/plugins/auth/package-lock.json +15 -14
  26. package/scaffold/.agent/skills/total-recall/plugins/auth/package.json +3 -3
  27. package/scaffold/.agent/skills/total-recall/plugins/auth/plugin.json +1 -1
  28. package/scaffold/.agent/skills/total-recall/plugins/auth/src/cli-gh-login.mjs +102 -0
  29. package/scaffold/.agent/skills/total-recall/plugins/auth/src/cli-secret.mjs +38 -2
  30. package/scaffold/.agent/skills/total-recall/plugins/auth/src/login-projections.mjs +157 -13
  31. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-store.mjs +12 -1
  32. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-sync.mjs +161 -17
  33. package/scaffold/.agent/skills/total-recall/plugins/automations/BRICK.md +7 -0
  34. package/scaffold/.agent/skills/total-recall/plugins/automations/LICENSE +21 -0
  35. package/scaffold/.agent/skills/total-recall/plugins/automations/README.md +66 -0
  36. package/scaffold/.agent/skills/total-recall/plugins/automations/adapters.mjs +231 -0
  37. package/scaffold/.agent/skills/total-recall/plugins/automations/capability/index.mjs +16 -0
  38. package/scaffold/.agent/skills/total-recall/plugins/automations/cli.mjs +121 -0
  39. package/{src/core/plugin-cron.mjs → scaffold/.agent/skills/total-recall/plugins/automations/cron.mjs} +1 -3
  40. package/scaffold/.agent/skills/total-recall/plugins/automations/inventory.mjs +88 -0
  41. package/scaffold/.agent/skills/total-recall/plugins/automations/package-lock.json +7661 -0
  42. package/scaffold/.agent/skills/total-recall/plugins/automations/package.json +35 -0
  43. package/scaffold/.agent/skills/total-recall/plugins/automations/plugin.json +167 -0
  44. package/scaffold/.agent/skills/total-recall/plugins/automations/scheduler.mjs +246 -0
  45. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/DESIGN.md +42 -0
  46. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/automations.js +2 -0
  47. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/card.js +273 -0
  48. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/run-core.mjs +1 -1
  49. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/check.mjs +57 -5
  50. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report-data.mjs +40 -14
  51. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report.mjs +15 -40
  52. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package-lock.json +15 -14
  53. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package.json +3 -3
  54. package/scaffold/.agent/skills/total-recall/plugins/code-quality/plugin.json +1 -1
  55. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package-lock.json +15 -14
  56. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package.json +3 -3
  57. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/plugin.json +1 -1
  58. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package-lock.json +15 -14
  59. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package.json +3 -3
  60. package/scaffold/.agent/skills/total-recall/plugins/embeddings/plugin.json +1 -1
  61. package/scaffold/.agent/skills/total-recall/plugins/git/README.md +112 -0
  62. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/cli.mjs +135 -23
  63. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package-lock.json +17 -16
  64. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package.json +5 -4
  65. package/scaffold/.agent/skills/total-recall/plugins/git/plugin.json +161 -0
  66. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/context.mjs +94 -0
  67. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/phase3-spec-support.mjs +50 -0
  68. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/runtime.mjs +40 -0
  69. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/spec-support.mjs +51 -0
  70. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/_support.mjs +195 -0
  71. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/auth.mjs +201 -0
  72. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/bisect.mjs +40 -0
  73. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/cli-meta.mjs +159 -0
  74. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit-memory.mjs +30 -0
  75. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit.mjs +46 -0
  76. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/fleet.mjs +156 -0
  77. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/force-push.mjs +58 -0
  78. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/group.mjs +119 -0
  79. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/handoff.mjs +59 -0
  80. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/message.mjs +22 -0
  81. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/resolve.mjs +60 -0
  82. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/rules.mjs +81 -0
  83. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/secret-firewall.mjs +66 -0
  84. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/undo.mjs +132 -0
  85. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/why.mjs +16 -0
  86. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/ui/card.js +2 -2
  87. package/scaffold/.agent/skills/total-recall/plugins/mesh/package-lock.json +15 -14
  88. package/scaffold/.agent/skills/total-recall/plugins/mesh/package.json +3 -3
  89. package/scaffold/.agent/skills/total-recall/plugins/mesh/plugin.json +1 -1
  90. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/README.md +59 -10
  91. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/BRICK.md +1 -1
  92. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/index.mjs +18 -6
  93. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/cli.mjs +160 -29
  94. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package-lock.json +15 -14
  95. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package.json +4 -4
  96. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/plugin.json +231 -16
  97. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/skills/meta-harness/SKILL.md +19 -4
  98. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/adoption.mjs +104 -0
  99. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/alerts.mjs +3 -3
  100. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/cascade.mjs +101 -16
  101. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/control.mjs +145 -0
  102. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/coordinator.mjs +54 -21
  103. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch-request.mjs +40 -0
  104. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch.mjs +68 -13
  105. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/documentation.mjs +55 -11
  106. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/executor.mjs +64 -15
  107. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/hermes.mjs +29 -1
  108. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/index.mjs +1 -1
  109. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/included-usage.mjs +249 -0
  110. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/jobs.mjs +84 -0
  111. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/learner.mjs +6 -12
  112. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/maintenance.mjs +17 -0
  113. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/mcp-server.mjs +228 -0
  114. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/pool.mjs +16 -8
  115. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/process-manager.mjs +26 -2
  116. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reasoning.mjs +6 -1
  117. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/remote-operation.mjs +6 -2
  118. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/review.mjs +34 -3
  119. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reviews.mjs +25 -0
  120. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/router.mjs +28 -12
  121. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/runtime.mjs +28 -6
  122. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/claude.mjs +319 -0
  123. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/codex.mjs +387 -0
  124. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/result.mjs +67 -0
  125. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/resume.mjs +373 -0
  126. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/run.mjs +223 -0
  127. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session-jobs.mjs +72 -0
  128. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/setup.mjs +6 -3
  129. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/termination.mjs +16 -12
  130. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/threads.mjs +32 -1
  131. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/usage-queue.mjs +110 -0
  132. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/verify-ssss.mjs +3 -3
  133. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worker.mjs +597 -70
  134. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worktree.mjs +76 -9
  135. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/DESIGN.md +5 -5
  136. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/card.js +3 -3
  137. package/scaffold/.agent/skills/total-recall/plugins/openwiki/cli.mjs +47 -18
  138. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package-lock.json +15 -14
  139. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package.json +3 -3
  140. package/scaffold/.agent/skills/total-recall/plugins/openwiki/plugin.json +1 -1
  141. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh-diagnostics.mjs +44 -0
  142. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh.mjs +120 -113
  143. package/scaffold/.agent/skills/total-recall/plugins/security/package-lock.json +15 -14
  144. package/scaffold/.agent/skills/total-recall/plugins/security/package.json +3 -3
  145. package/scaffold/.agent/skills/total-recall/plugins/security/plugin.json +1 -1
  146. package/scaffold/.agent/skills/total-recall/plugins/ssss/assets/scaffold.json +5 -5
  147. package/scaffold/.agent/skills/total-recall/plugins/ssss/package-lock.json +6 -6
  148. package/scaffold/.agent/skills/total-recall/plugins/ssss/package.json +2 -2
  149. package/scaffold/.agent/skills/total-recall/plugins/ssss/plugin.json +1 -1
  150. package/scaffold/.agent/skills/total-recall/references/operations.md +1 -1
  151. package/src/cli/agent.mjs +1 -1
  152. package/src/cli/command.mjs +41 -2
  153. package/src/cli/connect.mjs +2 -29
  154. package/src/cli/context.mjs +1 -0
  155. package/src/cli/dream.mjs +93 -69
  156. package/src/cli/harness.mjs +4 -4
  157. package/src/cli/help.mjs +1 -1
  158. package/src/cli/ingest-okf.mjs +4 -4
  159. package/src/cli/init.mjs +0 -25
  160. package/src/cli/lessons.mjs +51 -0
  161. package/src/cli/memory-plugin.mjs +1 -1
  162. package/src/cli/plugin/copies.mjs +64 -14
  163. package/src/cli/plugin/create.mjs +6 -7
  164. package/src/cli/plugin/index.mjs +11 -7
  165. package/src/cli/plugin/install.mjs +10 -15
  166. package/src/cli/plugin/remove.mjs +1 -1
  167. package/src/cli/plugin/search.mjs +2 -2
  168. package/src/cli/preflight.mjs +19 -6
  169. package/src/cli/proposals.mjs +1 -1
  170. package/src/cli/recall.mjs +66 -23
  171. package/src/cli/release.mjs +4 -1
  172. package/src/cli/remember.mjs +3 -14
  173. package/src/cli/server.mjs +18 -0
  174. package/src/cli/startup.mjs +1 -0
  175. package/src/cli/task.mjs +9 -2
  176. package/src/cli/update.mjs +10 -3
  177. package/src/core/access-ledger.mjs +78 -0
  178. package/src/core/agent-manager.mjs +2 -2
  179. package/src/core/automatic-brain-updates.mjs +11 -6
  180. package/src/core/brain-locate.mjs +15 -0
  181. package/src/core/brain-updates.mjs +42 -12
  182. package/src/core/claude-hooks.mjs +3 -1
  183. package/src/core/cleanup-task.mjs +15 -0
  184. package/src/core/cli-commands.mjs +2 -0
  185. package/src/core/cli-maintenance.mjs +4 -1
  186. package/src/core/cli-semantic-index.mjs +23 -3
  187. package/src/core/context-compactor.mjs +7 -2
  188. package/src/core/context-compiler.mjs +26 -1
  189. package/src/core/context-policy.mjs +7 -3
  190. package/src/core/daemon-control.mjs +22 -0
  191. package/src/core/daemon-loop.mjs +39 -62
  192. package/src/core/default-plugins.mjs +1 -1
  193. package/src/core/dream.mjs +33 -105
  194. package/src/core/ensure-dependencies.mjs +148 -0
  195. package/src/core/fast-recall.mjs +2 -2
  196. package/src/core/field-evaluation.mjs +23 -0
  197. package/src/core/gate-mode.mjs +1 -1
  198. package/src/core/global-brain-updates.mjs +1 -1
  199. package/src/core/harness-hooks.mjs +14 -2
  200. package/src/core/lesson-hooks.mjs +74 -0
  201. package/src/core/lesson-memory.mjs +24 -0
  202. package/src/core/lesson-sessions.mjs +52 -0
  203. package/src/core/lessons.mjs +96 -0
  204. package/src/core/mesh-brain-updates.mjs +2 -1
  205. package/src/core/meta-harness.mjs +2 -2
  206. package/src/core/optimizer.mjs +66 -165
  207. package/src/core/plugin-contracts/card.mjs +3 -0
  208. package/src/core/plugin-loader.mjs +12 -3
  209. package/src/core/plugin-runtime.mjs +40 -1
  210. package/src/core/plugin-store.mjs +35 -23
  211. package/src/core/post-mortem.mjs +52 -36
  212. package/src/core/preflight-gate.mjs +23 -2
  213. package/src/core/proposal-applier.mjs +31 -2
  214. package/src/core/repo-sync.mjs +4 -6
  215. package/src/core/required-plugins.mjs +26 -4
  216. package/src/core/rule-length.mjs +23 -0
  217. package/src/core/runtime.mjs +1 -1
  218. package/src/core/scheduler.mjs +35 -43
  219. package/src/core/schema.mjs +1 -2
  220. package/src/core/search.mjs +4 -3
  221. package/src/core/server-restart.mjs +128 -7
  222. package/src/core/server-service.mjs +148 -0
  223. package/src/core/session-watcher.mjs +19 -1
  224. package/src/core/skill-gap.mjs +16 -0
  225. package/src/core/ssss-kernel-bridge.mjs +33 -6
  226. package/src/core/startup-health.mjs +6 -1
  227. package/src/core/surface.mjs +68 -57
  228. package/src/core/task-context.mjs +9 -8
  229. package/src/core/task-executors.mjs +54 -106
  230. package/src/core/validated-write.mjs +5 -0
  231. package/src/core/vault-files.mjs +8 -2
  232. package/src/core/vault.mjs +1 -1
  233. package/src/core/vector-field.mjs +134 -192
  234. package/src/server/index.mjs +3 -1
  235. package/src/server/invoke-core-child.mjs +24 -0
  236. package/src/server/invoke-core-operations.mjs +102 -0
  237. package/src/server/route-manifest.json +0 -56
  238. package/src/server/routes/brains.mjs +0 -18
  239. package/src/server/routes/context.mjs +0 -41
  240. package/src/server/routes/invoke.mjs +26 -1
  241. package/src/server/routes/ssss.mjs +0 -169
  242. package/src/server/routes/system.mjs +0 -15
  243. package/src/server/routes/tasks.mjs +0 -26
  244. package/src/server/routes/vault.mjs +2 -23
  245. package/frontend/dist/assets/index-DD4qONvH.js +0 -5607
  246. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/README.md +0 -53
  247. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/plugin.json +0 -129
  248. package/src/core/append-log.mjs +0 -131
  249. package/src/core/plugin-tasks.mjs +0 -173
  250. package/templates/onboarding-interview.md +0 -82
  251. /package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/LICENSE +0 -0
  252. /package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/ui/DESIGN.md +0 -0
@@ -19,10 +19,6 @@
19
19
  "method": "GET",
20
20
  "path": "/api/brains/:id/nodes"
21
21
  },
22
- {
23
- "method": "POST",
24
- "path": "/api/brains/sync"
25
- },
26
22
  {
27
23
  "method": "POST",
28
24
  "path": "/api/capture/:source"
@@ -91,18 +87,6 @@
91
87
  "method": "POST",
92
88
  "path": "/api/context"
93
89
  },
94
- {
95
- "method": "GET",
96
- "path": "/api/context/flash/health"
97
- },
98
- {
99
- "method": "GET",
100
- "path": "/api/context/preview"
101
- },
102
- {
103
- "method": "POST",
104
- "path": "/api/context/stream"
105
- },
106
90
  {
107
91
  "method": "POST",
108
92
  "path": "/api/daemon/restart"
@@ -807,14 +791,6 @@
807
791
  "method": "GET",
808
792
  "path": "/api/ssss"
809
793
  },
810
- {
811
- "method": "GET",
812
- "path": "/api/ssss"
813
- },
814
- {
815
- "method": "GET",
816
- "path": "/api/ssss/instructions"
817
- },
818
794
  {
819
795
  "method": "GET",
820
796
  "path": "/api/ssss/instructions"
@@ -823,22 +799,10 @@
823
799
  "method": "GET",
824
800
  "path": "/api/ssss/references"
825
801
  },
826
- {
827
- "method": "GET",
828
- "path": "/api/ssss/references"
829
- },
830
802
  {
831
803
  "method": "GET",
832
804
  "path": "/api/ssss/references/:name"
833
805
  },
834
- {
835
- "method": "GET",
836
- "path": "/api/ssss/references/:name"
837
- },
838
- {
839
- "method": "GET",
840
- "path": "/api/ssss/skill/ssss"
841
- },
842
806
  {
843
807
  "method": "GET",
844
808
  "path": "/api/ssss/skill/ssss"
@@ -847,10 +811,6 @@
847
811
  "method": "GET",
848
812
  "path": "/api/ssss/spec"
849
813
  },
850
- {
851
- "method": "GET",
852
- "path": "/api/ssss/spec"
853
- },
854
814
  {
855
815
  "method": "POST",
856
816
  "path": "/api/sync/remote-vault/proposals/:id/decision"
@@ -875,14 +835,6 @@
875
835
  "method": "POST",
876
836
  "path": "/api/tasks/:id/retry"
877
837
  },
878
- {
879
- "method": "DELETE",
880
- "path": "/api/tasks/cleanup"
881
- },
882
- {
883
- "method": "GET",
884
- "path": "/api/tasks/failed"
885
- },
886
838
  {
887
839
  "method": "POST",
888
840
  "path": "/api/tts"
@@ -911,18 +863,10 @@
911
863
  "method": "POST",
912
864
  "path": "/api/v1/ssss"
913
865
  },
914
- {
915
- "method": "POST",
916
- "path": "/api/vault/compact"
917
- },
918
866
  {
919
867
  "method": "POST",
920
868
  "path": "/api/vault/compile"
921
869
  },
922
- {
923
- "method": "GET",
924
- "path": "/api/vault/hash"
925
- },
926
870
  {
927
871
  "method": "GET",
928
872
  "path": "/api/vault/status"
@@ -210,22 +210,4 @@ router.get('/api/brains/:id/nodes', requireAuth, requireScope('ssss:read', 'memo
210
210
  } catch (err) { serverError(res, err); }
211
211
  });
212
212
 
213
- /**
214
- * POST /api/brains/sync
215
- * Trigger a repo-sync across all registered repos.
216
- * Returns sync results per repo.
217
- */
218
- router.post('/api/brains/sync', requireAuth, requireScope('memory:write'), async (req, res) => {
219
- try {
220
- const { syncAllRepos } = await import('../../core/repo-sync.mjs');
221
- const result = await syncAllRepos();
222
- res.json({
223
- ok: true,
224
- totalIngested: result.totalIngested,
225
- totalSkipped: result.totalSkipped,
226
- repos: result.repos,
227
- });
228
- } catch (err) { serverError(res, err); }
229
- });
230
-
231
213
  export default router;
@@ -49,45 +49,4 @@ router.post('/api/context', requireAuth, requireScope('memory:read'), async (req
49
49
  }
50
50
  });
51
51
 
52
- router.get('/api/context/preview', requireAuth, requireScope('memory:read'), async (req, res) => {
53
- try {
54
- const { previewContext } = await import('../../core/context-compiler.mjs');
55
- const vaultDir = resolveVaultFromQuery(req, { strict: true });
56
- const result = previewContext({ vaultDir });
57
- res.json(result);
58
- } catch (err) {
59
- serverError(res, err);
60
- }
61
- });
62
-
63
- router.post('/api/context/stream', requireAuth, requireScope('memory:read'), async (req, res) => {
64
- try {
65
- const { streamParallelContext } = await import('../../core/parallel-context.mjs');
66
- const { query, budget_tokens, batch_size, concurrency, min_score } = req.body || {};
67
- if (!query) return badRequest(res, 'query is required');
68
- const vaultDir = resolveVaultFromQuery(req, { strict: true });
69
- const result = await streamParallelContext({
70
- query,
71
- vaultDir,
72
- budgetTokens: budget_tokens,
73
- batchSize: batch_size,
74
- concurrency,
75
- minScore: min_score,
76
- });
77
- res.json(result);
78
- } catch (err) {
79
- serverError(res, err);
80
- }
81
- });
82
-
83
- router.get('/api/context/flash/health', requireAuth, requireScope('memory:read'), async (req, res) => {
84
- try {
85
- const { checkFlashHealth } = await import('../../core/parallel-context.mjs');
86
- const result = await checkFlashHealth();
87
- res.json(result);
88
- } catch (err) {
89
- serverError(res, err);
90
- }
91
- });
92
-
93
52
  export default router;
@@ -16,6 +16,7 @@ import { invokeAuthority, authorizeInvoke, operationAllowed } from '../invoke-po
16
16
  import { restrictedBrainTargets } from '../invoke-targets.mjs';
17
17
  import { INVOKE_LIMITS, InvokeError, executeInvokeChild, requireSuccessfulRun, invokeEnvironment, absoluteTarget } from '../invoke-execution.mjs';
18
18
  import { syncChangedFiles } from '../invoke-durability.mjs';
19
+ import { CORE_OPERATIONS, validateCoreParams } from '../invoke-core-operations.mjs';
19
20
 
20
21
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
21
22
  // Share across router instances in this server; do not race projection refreshes.
@@ -29,6 +30,7 @@ export const OPERATIONS = Object.freeze(Object.fromEntries(Object.entries({
29
30
  'composable.run': { scope: 'sandbox:run', family: 'composable' },
30
31
  'decision.run': { scope: 'memory:read', family: 'decision' },
31
32
  'decision.predict': { scope: 'memory:read', family: 'decision' },
33
+ ...CORE_OPERATIONS,
32
34
  }).map(([name, def]) => [name, Object.freeze(def)])));
33
35
 
34
36
  const fail = (res, status, operation, code, message, extra = {}) => res.status(status).json({
@@ -106,13 +108,14 @@ export function createInvokeRouter({ auth = requireAuth, store = { loadKeys, key
106
108
  };
107
109
  revalidate();
108
110
  timer = setInterval(revalidate, 250); timer.unref?.();
109
- const context = { authority, target, serverBrain, selectedBrain, signal: controller.signal, limits, commandScopes,
111
+ const context = { authority, target, serverBrain, registryBrain, selectedBrain, signal: controller.signal, limits, commandScopes,
110
112
  run: options => {
111
113
  revalidate();
112
114
  return execute({ ...options, signal: controller.signal, limits });
113
115
  } };
114
116
  let result;
115
117
  if (operation === 'capabilities') result = capabilitiesFor(authority, limits, targetNames);
118
+ else if (Object.hasOwn(CORE_OPERATIONS, operation)) result = await runCoreOperation(operation, params, context);
116
119
  else result = await HANDLERS[operation](params, context);
117
120
  if (operation === 'ssss.write' && authority.mode === 'restricted') mutationResult = result;
118
121
  revalidate();
@@ -143,6 +146,28 @@ export function createInvokeRouter({ auth = requireAuth, store = { loadKeys, key
143
146
 
144
147
  export const invokeRouter = createInvokeRouter();
145
148
 
149
+ async function runCoreOperation(operation, params, context) {
150
+ validateCoreParams(operation, params);
151
+ const run = await context.run({ entry: path.join(root, 'src/server/invoke-core-child.mjs'),
152
+ cwd: context.target, env: invokeEnvironment(true), timeoutMs: params.timeoutMs,
153
+ input: JSON.stringify({ operation, params, brain: context.serverBrain, registryBrain: context.registryBrain }) });
154
+ if (run.termination_reason || run.truncated) {
155
+ const code = run.termination_reason || 'output-limit';
156
+ throw new InvokeError(code === 'timeout' ? 504 : code === 'authority-ended' ? 403 : 422,
157
+ code, 'Owner execution did not complete; a mutation may already have committed.');
158
+ }
159
+ let response;
160
+ try { response = JSON.parse(run.stdout); } catch { /* reject below */ }
161
+ if (response?.ok === false) {
162
+ const code = ['brain-unavailable', 'sync-failed'].includes(response.error) ? response.error : 'operation-failed';
163
+ throw new InvokeError(code === 'brain-unavailable' ? 404 : 502, code, 'Owner operation failed.');
164
+ }
165
+ if (run.exit_code !== 0 || response?.ok !== true || !response.result || typeof response.result !== 'object' || Array.isArray(response.result)) {
166
+ throw new InvokeError(502, 'invalid-owner-output', 'Owner returned invalid output.');
167
+ }
168
+ return response.result;
169
+ }
170
+
146
171
  /** The categories `total-recall remember` documents. Singular, and closed. */
147
172
  const MEMORY_CATEGORIES = new Set(['invariant', 'preference', 'correction', 'fact', 'concept', 'pattern', 'anti-pattern', 'decision', 'lore']);
148
173
 
@@ -3,184 +3,15 @@
3
3
  * Extracted from rest.mjs
4
4
  */
5
5
  import { Router } from 'express';
6
- import fs from 'node:fs';
7
- import path from 'node:path';
8
- import crypto from 'node:crypto';
9
6
  import { requireAuth, requireScope } from '../auth.mjs';
10
7
  import { processOperationAsync } from '../../core/operation-validator.mjs';
11
8
  import { invalidate } from '../../core/vault-cache.mjs';
12
9
  import {
13
- ROOT,
14
- INSTRUCTIONS,
15
- SKILLS_DIR,
16
10
  resolveVaultFromQuery,
17
11
  } from './_shared.mjs';
18
12
 
19
13
  const router = Router();
20
14
 
21
- // ─── SSSS Resources (sync and integration consumers) ─────────────────────────
22
-
23
- function sha256(content) {
24
- return crypto.createHash('sha256').update(content).digest('hex');
25
- }
26
-
27
- function readTextResource(filePath, name) {
28
- if (!fs.existsSync(filePath)) return null;
29
- const content = fs.readFileSync(filePath, 'utf8');
30
- const stat = fs.statSync(filePath);
31
- return {
32
- name,
33
- content,
34
- sha256: sha256(content),
35
- bytes: stat.size,
36
- modified: stat.mtime.toISOString()
37
- };
38
- }
39
-
40
- function sendTextResource(res, filePath, name) {
41
- const resource = readTextResource(filePath, name);
42
- if (!resource) {
43
- return res.status(404).json({ error: `${name} is not available` });
44
- }
45
- return res.json(resource);
46
- }
47
-
48
- function baseUrl(req) {
49
- return `${req.protocol}://${req.get('host')}`;
50
- }
51
-
52
- function absoluteUrl(req, routePath) {
53
- return new URL(routePath, baseUrl(req)).toString();
54
- }
55
-
56
- function ssssReferenceDir() {
57
- // Prefer compact TR references; fall back to legacy nested module paths.
58
- const candidates = [
59
- path.join(SKILLS_DIR, 'total-recall', 'references'),
60
- path.join(SKILLS_DIR, 'total-recall', 'modules', 'ssss', 'references'),
61
- path.join(SKILLS_DIR, 'okf', 'references'),
62
- ];
63
- return candidates.find((p) => fs.existsSync(p)) || candidates[0];
64
- }
65
-
66
- function ssssSkillDocPath() {
67
- const candidates = [
68
- path.join(SKILLS_DIR, 'total-recall', 'references', 'ssss-reference.md'),
69
- path.join(SKILLS_DIR, 'total-recall', 'SKILL.md'),
70
- path.join(SKILLS_DIR, 'total-recall', 'modules', 'ssss', 'MODULE.md'),
71
- path.join(SKILLS_DIR, 'okf', 'SKILL.md'),
72
- ];
73
- return candidates.find((p) => fs.existsSync(p)) || candidates[0];
74
- }
75
-
76
- function listSsssReferences(req) {
77
- const refsDir = ssssReferenceDir();
78
- if (!fs.existsSync(refsDir)) return [];
79
- return fs.readdirSync(refsDir)
80
- .filter(file => file.endsWith('.md'))
81
- .sort()
82
- .map((file) => {
83
- const name = file.replace(/\.md$/, '');
84
- const resource = readTextResource(path.join(refsDir, file), name);
85
- return {
86
- name,
87
- url: absoluteUrl(req, `/api/ssss/references/${name}`),
88
- sha256: resource?.sha256 || null,
89
- bytes: resource?.bytes || 0,
90
- modified: resource?.modified || null
91
- };
92
- });
93
- }
94
-
95
- function safeReferencePath(name) {
96
- if (!/^[a-zA-Z0-9_-]+$/.test(String(name || ''))) return null;
97
- return path.join(ssssReferenceDir(), `${name}.md`);
98
- }
99
-
100
- router.get('/api/ssss', requireAuth, requireScope('ssss:read'), (req, res) => {
101
- const resources = {
102
- instructions: {
103
- name: 'instructions',
104
- url: absoluteUrl(req, '/api/ssss/instructions'),
105
- ...(() => {
106
- const r = readTextResource(INSTRUCTIONS, 'instructions');
107
- return r ? { sha256: r.sha256, bytes: r.bytes, modified: r.modified } : { sha256: null, bytes: 0, modified: null };
108
- })()
109
- },
110
- skill: {
111
- name: 'ssss-skill',
112
- url: absoluteUrl(req, '/api/ssss/skill/ssss'),
113
- ...(() => {
114
- const r = readTextResource(ssssSkillDocPath(), 'ssss-skill');
115
- return r ? { sha256: r.sha256, bytes: r.bytes, modified: r.modified } : { sha256: null, bytes: 0, modified: null };
116
- })()
117
- },
118
- spec: {
119
- name: 'ssss-spec',
120
- url: absoluteUrl(req, '/api/ssss/spec'),
121
- ...(() => {
122
- const refs = ssssReferenceDir();
123
- const specPath = ['ssss-reference.md', 'ssss-spec.md']
124
- .map((n) => path.join(refs, n))
125
- .find((p) => fs.existsSync(p));
126
- const r = specPath ? readTextResource(specPath, 'ssss-spec') : null;
127
- return r ? { sha256: r.sha256, bytes: r.bytes, modified: r.modified } : { sha256: null, bytes: 0, modified: null };
128
- })()
129
- },
130
- references: listSsssReferences(req)
131
- };
132
-
133
- res.json({
134
- name: 'ssss',
135
- schema_version: 2,
136
- resources
137
- });
138
- });
139
-
140
- router.get('/api/ssss/instructions', requireAuth, requireScope('ssss:read', 'instructions:read'), (req, res) => {
141
- const surface = req.query.surface;
142
- // Prefer live INSTRUCTIONS constant (agent brain), then package ROOT fallback
143
- const instructionsPath = fs.existsSync(INSTRUCTIONS)
144
- ? INSTRUCTIONS
145
- : path.join(ROOT, 'INSTRUCTIONS.md');
146
- if (surface) {
147
- if (surface === 'INSTRUCTIONS.md') {
148
- return sendTextResource(res, instructionsPath, 'instructions');
149
- }
150
- const safeSurface = path.basename(surface);
151
- const candidates = [
152
- path.join(path.dirname(instructionsPath), safeSurface),
153
- path.join(ROOT, safeSurface),
154
- ];
155
- const surfacePath = candidates.find(p => fs.existsSync(p)) || candidates[0];
156
- return sendTextResource(res, surfacePath, safeSurface);
157
- }
158
- return sendTextResource(res, instructionsPath, 'instructions');
159
- });
160
-
161
- router.get('/api/ssss/skill/ssss', requireAuth, requireScope('ssss:read'), (_req, res) => {
162
- return sendTextResource(res, ssssSkillDocPath(), 'ssss-skill');
163
- });
164
-
165
- router.get('/api/ssss/spec', requireAuth, requireScope('ssss:read'), (_req, res) => {
166
- const refs = ssssReferenceDir();
167
- const specPath = ['ssss-reference.md', 'ssss-spec.md']
168
- .map((n) => path.join(refs, n))
169
- .find((p) => fs.existsSync(p));
170
- return sendTextResource(res, specPath || path.join(refs, 'ssss-reference.md'), 'ssss-spec');
171
- });
172
-
173
- router.get('/api/ssss/references', requireAuth, requireScope('ssss:read'), (req, res) => {
174
- res.json({ references: listSsssReferences(req) });
175
- });
176
-
177
- router.get('/api/ssss/references/:name', requireAuth, requireScope('ssss:read'), (req, res) => {
178
- const filePath = safeReferencePath(req.params.name);
179
- if (!filePath) return res.status(400).json({ error: 'Invalid reference name' });
180
- return sendTextResource(res, filePath, req.params.name);
181
- });
182
-
183
-
184
15
  export const ssssOperationHandler = async (req, res) => {
185
16
  try {
186
17
  const vaultRoot = resolveVaultFromQuery(req);
@@ -4,7 +4,6 @@
4
4
  * GET /api/logs/:type — Read last 200 lines of server or daemon log
5
5
  * POST /api/diagnostics/agents — Run upgrade --agents diagnostics
6
6
  * GET /api/pairing — Reachable URLs for the mobile pairing QR
7
- * GET /api/tasks/failed — List failed tasks from the DLQ
8
7
  * POST /api/tasks/:id/retry — Re-queue a failed task
9
8
  * GET /api/usage — Usage ledger + cost summary
10
9
  * GET /api/usage/providers — Spend as the providers report it
@@ -144,20 +143,6 @@ router.get('/api/pairing', requireAuth, requireScope('config:read'), async (_req
144
143
  }
145
144
  });
146
145
 
147
- /**
148
- * GET /api/tasks/failed
149
- * List failed tasks from the scheduler DLQ.
150
- */
151
- router.get('/api/tasks/failed', requireAuth, async (req, res) => {
152
- try {
153
- const { listTasks } = await import('../../core/task-envelope.mjs');
154
- const failed = listTasks(QUEUE_DIR, { status: 'failed' });
155
- res.json({ total: failed.length, tasks: failed });
156
- } catch (err) {
157
- serverError(res, err);
158
- }
159
- });
160
-
161
146
  /**
162
147
  * POST /api/tasks/:id/retry
163
148
  * Re-queue a failed task.
@@ -38,32 +38,6 @@ router.get('/api/tasks', requireAuth, requireScope('tasks:read'), (req, res) =>
38
38
  } catch (err) { serverError(res, err); }
39
39
  });
40
40
 
41
- router.delete('/api/tasks/cleanup', requireAuth, requireScope('tasks:write'), (req, res) => {
42
- try {
43
- if (!fs.existsSync(TASKS_DIR)) {
44
- return res.json({ deleted: 0 });
45
- }
46
- let deleted = 0;
47
- const files = fs.readdirSync(TASKS_DIR);
48
- for (const file of files) {
49
- if (!file.endsWith('.md')) continue;
50
- const filePath = path.join(TASKS_DIR, file);
51
- try {
52
- const raw = fs.readFileSync(filePath, 'utf8');
53
- const { data } = matter(raw);
54
- if (data.status === 'completed') {
55
- fs.unlinkSync(filePath);
56
- deleted++;
57
- }
58
- } catch (e) {
59
- // skip
60
- }
61
- }
62
- res.json({ deleted });
63
-
64
- } catch (err) { serverError(res, err); }
65
- });
66
-
67
41
  router.post('/api/tasks', requireAuth, requireScope('tasks:write'), (req, res) => {
68
42
  try {
69
43
  const { category, target, body, priority = 5 } = req.body || {};
@@ -1,6 +1,5 @@
1
1
  import { Router } from 'express';
2
2
  import fs from 'node:fs';
3
- import path from 'node:path';
4
3
  import { requireAuth, requireScope } from '../auth.mjs';
5
4
  import {
6
5
  serverError,
@@ -16,6 +15,7 @@ import { compileSurface } from '../../core/surface.mjs';
16
15
  import { getNodes, invalidate } from '../../core/vault-cache.mjs';
17
16
  import { loadEmbeddingsIndex, loadSessionEmbeddingsIndex } from '../../core/embeddings.mjs';
18
17
  import { logger } from '../../core/logger.mjs';
18
+ import { ruleLengthStats } from '../../core/rule-length.mjs';
19
19
 
20
20
  const router = Router();
21
21
 
@@ -63,28 +63,6 @@ router.post('/api/vault/compile', requireAuth, requireScope('memory:recompile'),
63
63
  }
64
64
  });
65
65
 
66
- router.post('/api/vault/compact', requireAuth, requireScope('memory:write'), async (req, res) => {
67
- try {
68
- const { compactAppendLogs } = await import('../../core/append-log.mjs');
69
- const result = compactAppendLogs();
70
- res.json({ compacted: true, ...result });
71
- } catch (err) {
72
- serverError(res, err);
73
- }
74
- });
75
-
76
- router.get('/api/vault/hash', requireAuth, requireScope('memory:read'), (req, res) => {
77
- try {
78
- const vaultDir = resolveVaultFromQuery(req);
79
- const { derivedDir } = pathsForVault(vaultDir);
80
- const hashFile = path.join(derivedDir, 'vault-hash.txt');
81
- const hash = fs.existsSync(hashFile) ? fs.readFileSync(hashFile, 'utf8').trim() : null;
82
- res.json({ vault_hash: hash, vault_dir: vaultDir });
83
- } catch (err) {
84
- serverError(res, err);
85
- }
86
- });
87
-
88
66
  router.get('/api/vault/status', requireAuth, requireScope('memory:read'), async (req, res) => {
89
67
  try {
90
68
  const vaultDir = resolveVaultFromQuery(req);
@@ -116,6 +94,7 @@ router.get('/api/vault/status', requireAuth, requireScope('memory:read'), async
116
94
 
117
95
  res.json({
118
96
  vault_dir: vaultDir,
97
+ rule_length: ruleLengthStats(),
119
98
  node_count: nodeCount,
120
99
  skill_count: skillCount,
121
100
  derived_files: derivedFiles,