@alan512/experienceengine 0.1.2 → 0.2.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 (642) hide show
  1. package/.claude-plugin/marketplace.json +0 -0
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.env.example +0 -0
  4. package/.mcp.json +4 -8
  5. package/LICENSE +21 -0
  6. package/README.md +288 -95
  7. package/README.zh-CN.md +316 -65
  8. package/dist/adapters/claude-code/event-store.d.ts +0 -0
  9. package/dist/adapters/claude-code/event-store.js +0 -0
  10. package/dist/adapters/claude-code/event-store.js.map +0 -0
  11. package/dist/adapters/claude-code/hook-normalizer.d.ts +0 -0
  12. package/dist/adapters/claude-code/hook-normalizer.js +0 -0
  13. package/dist/adapters/claude-code/hook-normalizer.js.map +0 -0
  14. package/dist/adapters/claude-code/runtime-projection.d.ts +0 -0
  15. package/dist/adapters/claude-code/runtime-projection.js +0 -0
  16. package/dist/adapters/claude-code/runtime-projection.js.map +0 -0
  17. package/dist/adapters/claude-code/session-store.d.ts +1 -0
  18. package/dist/adapters/claude-code/session-store.js +24 -1
  19. package/dist/adapters/claude-code/session-store.js.map +1 -1
  20. package/dist/adapters/codex/action-registry.d.ts +84 -0
  21. package/dist/adapters/codex/action-registry.js +277 -0
  22. package/dist/adapters/codex/action-registry.js.map +1 -0
  23. package/dist/adapters/codex/broker-tools.d.ts +114 -0
  24. package/dist/adapters/codex/broker-tools.js +130 -0
  25. package/dist/adapters/codex/broker-tools.js.map +1 -0
  26. package/dist/adapters/codex/instruction-template.d.ts +3 -0
  27. package/dist/adapters/codex/instruction-template.js +12 -0
  28. package/dist/adapters/codex/instruction-template.js.map +1 -0
  29. package/dist/adapters/codex/mcp-server.d.ts +59 -41
  30. package/dist/adapters/codex/mcp-server.js +177 -728
  31. package/dist/adapters/codex/mcp-server.js.map +1 -1
  32. package/dist/analyzer/candidate-signals.d.ts +3 -1
  33. package/dist/analyzer/candidate-signals.js +159 -0
  34. package/dist/analyzer/candidate-signals.js.map +1 -1
  35. package/dist/analyzer/experience-analyzer.d.ts +0 -0
  36. package/dist/analyzer/experience-analyzer.js +0 -0
  37. package/dist/analyzer/experience-analyzer.js.map +0 -0
  38. package/dist/analyzer/extraction-evidence.d.ts +0 -0
  39. package/dist/analyzer/extraction-evidence.js +0 -0
  40. package/dist/analyzer/extraction-evidence.js.map +0 -0
  41. package/dist/analyzer/llm-learning-gate.d.ts +12 -1
  42. package/dist/analyzer/llm-learning-gate.js +672 -16
  43. package/dist/analyzer/llm-learning-gate.js.map +1 -1
  44. package/dist/analyzer/node-deduper.d.ts +0 -0
  45. package/dist/analyzer/node-deduper.js +0 -0
  46. package/dist/analyzer/node-deduper.js.map +0 -0
  47. package/dist/analyzer/node-normalizer.d.ts +0 -0
  48. package/dist/analyzer/node-normalizer.js +0 -0
  49. package/dist/analyzer/node-normalizer.js.map +0 -0
  50. package/dist/analyzer/storage-gate.d.ts +0 -0
  51. package/dist/analyzer/storage-gate.js +0 -0
  52. package/dist/analyzer/storage-gate.js.map +0 -0
  53. package/dist/analyzer/strategy-extractor.d.ts +0 -0
  54. package/dist/analyzer/strategy-extractor.js +0 -0
  55. package/dist/analyzer/strategy-extractor.js.map +0 -0
  56. package/dist/analyzer/warning-extractor.d.ts +0 -0
  57. package/dist/analyzer/warning-extractor.js +0 -0
  58. package/dist/analyzer/warning-extractor.js.map +0 -0
  59. package/dist/cli/commands/backup.d.ts +0 -0
  60. package/dist/cli/commands/backup.js +0 -0
  61. package/dist/cli/commands/backup.js.map +0 -0
  62. package/dist/cli/commands/claude-hook.d.ts +0 -0
  63. package/dist/cli/commands/claude-hook.js +23 -7
  64. package/dist/cli/commands/claude-hook.js.map +1 -1
  65. package/dist/cli/commands/codex-mcp-server.d.ts +0 -0
  66. package/dist/cli/commands/codex-mcp-server.js +0 -0
  67. package/dist/cli/commands/codex-mcp-server.js.map +0 -0
  68. package/dist/cli/commands/codex.d.ts +60 -0
  69. package/dist/cli/commands/codex.js +188 -0
  70. package/dist/cli/commands/codex.js.map +1 -0
  71. package/dist/cli/commands/config.d.ts +0 -0
  72. package/dist/cli/commands/config.js +88 -2
  73. package/dist/cli/commands/config.js.map +1 -1
  74. package/dist/cli/commands/cool.d.ts +0 -0
  75. package/dist/cli/commands/cool.js +0 -0
  76. package/dist/cli/commands/cool.js.map +0 -0
  77. package/dist/cli/commands/disable.d.ts +0 -0
  78. package/dist/cli/commands/disable.js +0 -0
  79. package/dist/cli/commands/disable.js.map +0 -0
  80. package/dist/cli/commands/doctor.d.ts +4 -28
  81. package/dist/cli/commands/doctor.js +156 -68
  82. package/dist/cli/commands/doctor.js.map +1 -1
  83. package/dist/cli/commands/enable.d.ts +0 -0
  84. package/dist/cli/commands/enable.js +0 -0
  85. package/dist/cli/commands/enable.js.map +0 -0
  86. package/dist/cli/commands/evaluate.d.ts +9 -3
  87. package/dist/cli/commands/evaluate.js +31 -5
  88. package/dist/cli/commands/evaluate.js.map +1 -1
  89. package/dist/cli/commands/export.d.ts +0 -0
  90. package/dist/cli/commands/export.js +0 -0
  91. package/dist/cli/commands/export.js.map +0 -0
  92. package/dist/cli/commands/feedback.d.ts +0 -0
  93. package/dist/cli/commands/feedback.js +4 -0
  94. package/dist/cli/commands/feedback.js.map +1 -1
  95. package/dist/cli/commands/import.d.ts +0 -0
  96. package/dist/cli/commands/import.js +0 -0
  97. package/dist/cli/commands/import.js.map +0 -0
  98. package/dist/cli/commands/init.d.ts +28 -0
  99. package/dist/cli/commands/init.js +432 -0
  100. package/dist/cli/commands/init.js.map +1 -0
  101. package/dist/cli/commands/inspect.d.ts +0 -0
  102. package/dist/cli/commands/inspect.js +271 -37
  103. package/dist/cli/commands/inspect.js.map +1 -1
  104. package/dist/cli/commands/install.d.ts +0 -0
  105. package/dist/cli/commands/install.js +9 -0
  106. package/dist/cli/commands/install.js.map +1 -1
  107. package/dist/cli/commands/maintenance.d.ts +0 -0
  108. package/dist/cli/commands/maintenance.js +1 -1
  109. package/dist/cli/commands/maintenance.js.map +1 -1
  110. package/dist/cli/commands/mcp-server.d.ts +0 -0
  111. package/dist/cli/commands/mcp-server.js +4 -0
  112. package/dist/cli/commands/mcp-server.js.map +1 -1
  113. package/dist/cli/commands/models.d.ts +0 -0
  114. package/dist/cli/commands/models.js +0 -0
  115. package/dist/cli/commands/models.js.map +0 -0
  116. package/dist/cli/commands/repair.d.ts +0 -0
  117. package/dist/cli/commands/repair.js +3 -3
  118. package/dist/cli/commands/repair.js.map +1 -1
  119. package/dist/cli/commands/retire.d.ts +0 -0
  120. package/dist/cli/commands/retire.js +0 -0
  121. package/dist/cli/commands/retire.js.map +0 -0
  122. package/dist/cli/commands/rollback.d.ts +0 -0
  123. package/dist/cli/commands/rollback.js +0 -0
  124. package/dist/cli/commands/rollback.js.map +0 -0
  125. package/dist/cli/commands/stats.d.ts +0 -0
  126. package/dist/cli/commands/stats.js +0 -0
  127. package/dist/cli/commands/stats.js.map +0 -0
  128. package/dist/cli/commands/status.d.ts +0 -0
  129. package/dist/cli/commands/status.js +89 -7
  130. package/dist/cli/commands/status.js.map +1 -1
  131. package/dist/cli/commands/upgrade.d.ts +0 -0
  132. package/dist/cli/commands/upgrade.js +0 -0
  133. package/dist/cli/commands/upgrade.js.map +0 -0
  134. package/dist/cli/dispatch.d.ts +0 -0
  135. package/dist/cli/dispatch.js +36 -9
  136. package/dist/cli/dispatch.js.map +1 -1
  137. package/dist/cli/index.d.ts +0 -0
  138. package/dist/cli/index.js.map +0 -0
  139. package/dist/cli/state-model.d.ts +14 -0
  140. package/dist/cli/state-model.js +23 -0
  141. package/dist/cli/state-model.js.map +1 -0
  142. package/dist/config/config-schema.d.ts +209 -0
  143. package/dist/config/config-schema.js +168 -1
  144. package/dist/config/config-schema.js.map +1 -1
  145. package/dist/config/default-config.d.ts +0 -0
  146. package/dist/config/default-config.js +22 -1
  147. package/dist/config/default-config.js.map +1 -1
  148. package/dist/config/load-config.d.ts +0 -0
  149. package/dist/config/load-config.js +91 -2
  150. package/dist/config/load-config.js.map +1 -1
  151. package/dist/config/path-resolver.d.ts +0 -1
  152. package/dist/config/path-resolver.js +0 -2
  153. package/dist/config/path-resolver.js.map +1 -1
  154. package/dist/config/runtime-env.d.ts +8 -0
  155. package/dist/config/runtime-env.js +14 -0
  156. package/dist/config/runtime-env.js.map +1 -0
  157. package/dist/config/secrets-store.d.ts +15 -0
  158. package/dist/config/secrets-store.js +56 -0
  159. package/dist/config/secrets-store.js.map +1 -0
  160. package/dist/config/settings-store.d.ts +29 -0
  161. package/dist/config/settings-store.js +55 -0
  162. package/dist/config/settings-store.js.map +1 -1
  163. package/dist/controller/candidate-retriever.d.ts +49 -2
  164. package/dist/controller/candidate-retriever.js +258 -125
  165. package/dist/controller/candidate-retriever.js.map +1 -1
  166. package/dist/controller/injection-renderer.d.ts +0 -0
  167. package/dist/controller/injection-renderer.js +52 -1
  168. package/dist/controller/injection-renderer.js.map +1 -1
  169. package/dist/controller/injection-scorecard.d.ts +2 -2
  170. package/dist/controller/injection-scorecard.js +47 -1
  171. package/dist/controller/injection-scorecard.js.map +1 -1
  172. package/dist/controller/inline-notice.d.ts +0 -0
  173. package/dist/controller/inline-notice.js +0 -0
  174. package/dist/controller/inline-notice.js.map +0 -0
  175. package/dist/controller/intervention-controller.d.ts +3 -2
  176. package/dist/controller/intervention-controller.js +339 -17
  177. package/dist/controller/intervention-controller.js.map +1 -1
  178. package/dist/controller/lexical-retriever.d.ts +14 -0
  179. package/dist/controller/lexical-retriever.js +117 -0
  180. package/dist/controller/lexical-retriever.js.map +1 -0
  181. package/dist/controller/model-reranker.d.ts +20 -0
  182. package/dist/controller/model-reranker.js +187 -0
  183. package/dist/controller/model-reranker.js.map +1 -0
  184. package/dist/controller/node-ranker.d.ts +0 -0
  185. package/dist/controller/node-ranker.js +1 -0
  186. package/dist/controller/node-ranker.js.map +1 -1
  187. package/dist/controller/policy-enricher.d.ts +10 -0
  188. package/dist/controller/policy-enricher.js +186 -0
  189. package/dist/controller/policy-enricher.js.map +1 -0
  190. package/dist/controller/query-rewrite.d.ts +8 -0
  191. package/dist/controller/query-rewrite.js +69 -0
  192. package/dist/controller/query-rewrite.js.map +1 -0
  193. package/dist/controller/retrieval-context.d.ts +3 -0
  194. package/dist/controller/retrieval-context.js +37 -0
  195. package/dist/controller/retrieval-context.js.map +1 -0
  196. package/dist/controller/second-opinion-gate.d.ts +41 -0
  197. package/dist/controller/second-opinion-gate.js +225 -0
  198. package/dist/controller/second-opinion-gate.js.map +1 -0
  199. package/dist/controller/trigger-evaluator.d.ts +27 -2
  200. package/dist/controller/trigger-evaluator.js +63 -3
  201. package/dist/controller/trigger-evaluator.js.map +1 -1
  202. package/dist/distillation/errors.d.ts +0 -0
  203. package/dist/distillation/errors.js +0 -0
  204. package/dist/distillation/errors.js.map +0 -0
  205. package/dist/distillation/experience-family.d.ts +4 -0
  206. package/dist/distillation/experience-family.js +14 -0
  207. package/dist/distillation/experience-family.js.map +1 -0
  208. package/dist/distillation/host-llm.d.ts +1 -0
  209. package/dist/distillation/host-llm.js +5 -1
  210. package/dist/distillation/host-llm.js.map +1 -1
  211. package/dist/distillation/llm-distiller.d.ts +0 -0
  212. package/dist/distillation/llm-distiller.js +4 -0
  213. package/dist/distillation/llm-distiller.js.map +1 -1
  214. package/dist/distillation/merge-decider.d.ts +0 -0
  215. package/dist/distillation/merge-decider.js +4 -0
  216. package/dist/distillation/merge-decider.js.map +1 -1
  217. package/dist/distillation/model-catalog.d.ts +0 -0
  218. package/dist/distillation/model-catalog.js +0 -0
  219. package/dist/distillation/model-catalog.js.map +0 -0
  220. package/dist/distillation/prompt-contract.d.ts +1 -1
  221. package/dist/distillation/prompt-contract.js +6 -1
  222. package/dist/distillation/prompt-contract.js.map +1 -1
  223. package/dist/distillation/providers/anthropic.d.ts +0 -0
  224. package/dist/distillation/providers/anthropic.js +0 -0
  225. package/dist/distillation/providers/anthropic.js.map +0 -0
  226. package/dist/distillation/providers/azure-openai.d.ts +0 -0
  227. package/dist/distillation/providers/azure-openai.js +0 -0
  228. package/dist/distillation/providers/azure-openai.js.map +0 -0
  229. package/dist/distillation/providers/baidu-qianfan.d.ts +0 -0
  230. package/dist/distillation/providers/baidu-qianfan.js +0 -0
  231. package/dist/distillation/providers/baidu-qianfan.js.map +0 -0
  232. package/dist/distillation/providers/bedrock.d.ts +0 -0
  233. package/dist/distillation/providers/bedrock.js +0 -0
  234. package/dist/distillation/providers/bedrock.js.map +0 -0
  235. package/dist/distillation/providers/dashscope.d.ts +0 -0
  236. package/dist/distillation/providers/dashscope.js +0 -0
  237. package/dist/distillation/providers/dashscope.js.map +0 -0
  238. package/dist/distillation/providers/deepseek.d.ts +0 -0
  239. package/dist/distillation/providers/deepseek.js +0 -0
  240. package/dist/distillation/providers/deepseek.js.map +0 -0
  241. package/dist/distillation/providers/gemini.d.ts +0 -0
  242. package/dist/distillation/providers/gemini.js +5 -1
  243. package/dist/distillation/providers/gemini.js.map +1 -1
  244. package/dist/distillation/providers/google-adc.d.ts +0 -0
  245. package/dist/distillation/providers/google-adc.js +0 -0
  246. package/dist/distillation/providers/google-adc.js.map +0 -0
  247. package/dist/distillation/providers/minimax.d.ts +0 -0
  248. package/dist/distillation/providers/minimax.js +0 -0
  249. package/dist/distillation/providers/minimax.js.map +0 -0
  250. package/dist/distillation/providers/moonshot.d.ts +0 -0
  251. package/dist/distillation/providers/moonshot.js +0 -0
  252. package/dist/distillation/providers/moonshot.js.map +0 -0
  253. package/dist/distillation/providers/openai-compatible-factory.d.ts +0 -0
  254. package/dist/distillation/providers/openai-compatible-factory.js +0 -0
  255. package/dist/distillation/providers/openai-compatible-factory.js.map +0 -0
  256. package/dist/distillation/providers/openai-compatible.d.ts +0 -0
  257. package/dist/distillation/providers/openai-compatible.js +0 -0
  258. package/dist/distillation/providers/openai-compatible.js.map +0 -0
  259. package/dist/distillation/providers/openai.d.ts +0 -0
  260. package/dist/distillation/providers/openai.js +0 -0
  261. package/dist/distillation/providers/openai.js.map +0 -0
  262. package/dist/distillation/providers/openrouter.d.ts +0 -0
  263. package/dist/distillation/providers/openrouter.js +0 -0
  264. package/dist/distillation/providers/openrouter.js.map +0 -0
  265. package/dist/distillation/providers/registry.d.ts +0 -0
  266. package/dist/distillation/providers/registry.js +0 -0
  267. package/dist/distillation/providers/registry.js.map +0 -0
  268. package/dist/distillation/providers/siliconflow.d.ts +0 -0
  269. package/dist/distillation/providers/siliconflow.js +0 -0
  270. package/dist/distillation/providers/siliconflow.js.map +0 -0
  271. package/dist/distillation/providers/tencent-hunyuan.d.ts +0 -0
  272. package/dist/distillation/providers/tencent-hunyuan.js +0 -0
  273. package/dist/distillation/providers/tencent-hunyuan.js.map +0 -0
  274. package/dist/distillation/providers/types.d.ts +0 -0
  275. package/dist/distillation/providers/types.js +0 -0
  276. package/dist/distillation/providers/types.js.map +0 -0
  277. package/dist/distillation/providers/volcengine-ark.d.ts +0 -0
  278. package/dist/distillation/providers/volcengine-ark.js +0 -0
  279. package/dist/distillation/providers/volcengine-ark.js.map +0 -0
  280. package/dist/distillation/providers/zhipu.d.ts +0 -0
  281. package/dist/distillation/providers/zhipu.js +0 -0
  282. package/dist/distillation/providers/zhipu.js.map +0 -0
  283. package/dist/distillation/queue-worker.d.ts +0 -0
  284. package/dist/distillation/queue-worker.js +78 -9
  285. package/dist/distillation/queue-worker.js.map +1 -1
  286. package/dist/distillation/types.d.ts +0 -0
  287. package/dist/distillation/types.js +0 -0
  288. package/dist/distillation/types.js.map +0 -0
  289. package/dist/evaluation/benchmark-report.d.ts +0 -0
  290. package/dist/evaluation/benchmark-report.js +0 -0
  291. package/dist/evaluation/benchmark-report.js.map +0 -0
  292. package/dist/evaluation/benchmark-summary.d.ts +0 -0
  293. package/dist/evaluation/benchmark-summary.js +0 -0
  294. package/dist/evaluation/benchmark-summary.js.map +0 -0
  295. package/dist/evaluation/codex-lifecycle-validation.d.ts +60 -0
  296. package/dist/evaluation/codex-lifecycle-validation.js +233 -0
  297. package/dist/evaluation/codex-lifecycle-validation.js.map +1 -0
  298. package/dist/evaluation/hybrid-phase1-rollout-summary.d.ts +63 -0
  299. package/dist/evaluation/hybrid-phase1-rollout-summary.js +108 -0
  300. package/dist/evaluation/hybrid-phase1-rollout-summary.js.map +1 -0
  301. package/dist/evaluation/hybrid-phase3-gate-metrics.d.ts +26 -0
  302. package/dist/evaluation/hybrid-phase3-gate-metrics.js +23 -0
  303. package/dist/evaluation/hybrid-phase3-gate-metrics.js.map +1 -0
  304. package/dist/evaluation/openclaw-baseline.d.ts +8 -0
  305. package/dist/evaluation/openclaw-baseline.js +27 -0
  306. package/dist/evaluation/openclaw-baseline.js.map +1 -1
  307. package/dist/evaluation/openclaw-scenarios.d.ts +0 -0
  308. package/dist/evaluation/openclaw-scenarios.js +0 -0
  309. package/dist/evaluation/openclaw-scenarios.js.map +0 -0
  310. package/dist/experience-management/governance-observability.d.ts +13 -0
  311. package/dist/experience-management/governance-observability.js +37 -0
  312. package/dist/experience-management/governance-observability.js.map +1 -0
  313. package/dist/experience-management/node-lifecycle-governance.d.ts +8 -0
  314. package/dist/experience-management/node-lifecycle-governance.js +80 -0
  315. package/dist/experience-management/node-lifecycle-governance.js.map +1 -0
  316. package/dist/experience-management/task-management-signals.d.ts +29 -0
  317. package/dist/experience-management/task-management-signals.js +148 -0
  318. package/dist/experience-management/task-management-signals.js.map +1 -0
  319. package/dist/feedback/automatic-attribution.d.ts +0 -0
  320. package/dist/feedback/automatic-attribution.js +0 -0
  321. package/dist/feedback/automatic-attribution.js.map +0 -0
  322. package/dist/feedback/feedback-manager.d.ts +4 -1
  323. package/dist/feedback/feedback-manager.js +11 -22
  324. package/dist/feedback/feedback-manager.js.map +1 -1
  325. package/dist/feedback/harm-detector.d.ts +0 -0
  326. package/dist/feedback/harm-detector.js +0 -0
  327. package/dist/feedback/harm-detector.js.map +0 -0
  328. package/dist/feedback/state-transition.d.ts +6 -1
  329. package/dist/feedback/state-transition.js +14 -2
  330. package/dist/feedback/state-transition.js.map +1 -1
  331. package/dist/feedback/stats-updater.d.ts +0 -0
  332. package/dist/feedback/stats-updater.js +0 -0
  333. package/dist/feedback/stats-updater.js.map +0 -0
  334. package/dist/hybrid/capsule-builder.d.ts +23 -0
  335. package/dist/hybrid/capsule-builder.js +114 -0
  336. package/dist/hybrid/capsule-builder.js.map +1 -0
  337. package/dist/hybrid/explain-provider-client.d.ts +19 -0
  338. package/dist/hybrid/explain-provider-client.js +34 -0
  339. package/dist/hybrid/explain-provider-client.js.map +1 -0
  340. package/dist/hybrid/postmortem-provider-client.d.ts +19 -0
  341. package/dist/hybrid/postmortem-provider-client.js +34 -0
  342. package/dist/hybrid/postmortem-provider-client.js.map +1 -0
  343. package/dist/hybrid/rollout.d.ts +9 -0
  344. package/dist/hybrid/rollout.js +49 -0
  345. package/dist/hybrid/rollout.js.map +1 -0
  346. package/dist/hybrid/router.d.ts +4 -0
  347. package/dist/hybrid/router.js +62 -0
  348. package/dist/hybrid/router.js.map +1 -0
  349. package/dist/hybrid/types.d.ts +140 -0
  350. package/dist/{compiler → hybrid}/types.js +0 -0
  351. package/dist/{packs → hybrid}/types.js.map +1 -1
  352. package/dist/hybrid/validators.d.ts +5 -0
  353. package/dist/hybrid/validators.js +94 -0
  354. package/dist/hybrid/validators.js.map +1 -0
  355. package/dist/hybrid/worker-client.d.ts +61 -0
  356. package/dist/hybrid/worker-client.js +196 -0
  357. package/dist/hybrid/worker-client.js.map +1 -0
  358. package/dist/hybrid/workers/explain-decision-llm.d.ts +8 -0
  359. package/dist/hybrid/workers/explain-decision-llm.js +152 -0
  360. package/dist/hybrid/workers/explain-decision-llm.js.map +1 -0
  361. package/dist/hybrid/workers/explain-decision.d.ts +2 -0
  362. package/dist/hybrid/workers/explain-decision.js +40 -0
  363. package/dist/hybrid/workers/explain-decision.js.map +1 -0
  364. package/dist/hybrid/workers/postmortem-review-llm.d.ts +8 -0
  365. package/dist/hybrid/workers/postmortem-review-llm.js +398 -0
  366. package/dist/hybrid/workers/postmortem-review-llm.js.map +1 -0
  367. package/dist/hybrid/workers/postmortem-review.d.ts +2 -0
  368. package/dist/hybrid/workers/postmortem-review.js +66 -0
  369. package/dist/hybrid/workers/postmortem-review.js.map +1 -0
  370. package/dist/index.d.ts +0 -0
  371. package/dist/index.js +0 -0
  372. package/dist/index.js.map +0 -0
  373. package/dist/input/context-summary-adapter.d.ts +0 -0
  374. package/dist/input/context-summary-adapter.js +0 -0
  375. package/dist/input/context-summary-adapter.js.map +0 -0
  376. package/dist/input/input-adapter.d.ts +0 -0
  377. package/dist/input/input-adapter.js +2 -1
  378. package/dist/input/input-adapter.js.map +1 -1
  379. package/dist/input/outcome-resolver.d.ts +0 -0
  380. package/dist/input/outcome-resolver.js +5 -5
  381. package/dist/input/outcome-resolver.js.map +1 -1
  382. package/dist/input/scope-resolver.d.ts +0 -0
  383. package/dist/input/scope-resolver.js +0 -0
  384. package/dist/input/scope-resolver.js.map +0 -0
  385. package/dist/input/tasktype-resolver.d.ts +0 -0
  386. package/dist/input/tasktype-resolver.js +2 -0
  387. package/dist/input/tasktype-resolver.js.map +1 -1
  388. package/dist/input/tool-event-significance.d.ts +5 -0
  389. package/dist/input/tool-event-significance.js +7 -0
  390. package/dist/input/tool-event-significance.js.map +1 -0
  391. package/dist/install/claude-cli.d.ts +0 -0
  392. package/dist/install/claude-cli.js +0 -0
  393. package/dist/install/claude-cli.js.map +0 -0
  394. package/dist/install/claude-code-doctor.d.ts +8 -2
  395. package/dist/install/claude-code-doctor.js +54 -9
  396. package/dist/install/claude-code-doctor.js.map +1 -1
  397. package/dist/install/claude-code-installer.d.ts +0 -0
  398. package/dist/install/claude-code-installer.js +50 -1
  399. package/dist/install/claude-code-installer.js.map +1 -1
  400. package/dist/install/claude-marketplace-state.d.ts +14 -0
  401. package/dist/install/claude-marketplace-state.js +47 -0
  402. package/dist/install/claude-marketplace-state.js.map +1 -0
  403. package/dist/install/claude-runtime-target.d.ts +0 -0
  404. package/dist/install/claude-runtime-target.js +0 -0
  405. package/dist/install/claude-runtime-target.js.map +0 -0
  406. package/dist/install/codex-cli.d.ts +15 -0
  407. package/dist/install/codex-cli.js +55 -3
  408. package/dist/install/codex-cli.js.map +1 -1
  409. package/dist/install/codex-installer.d.ts +18 -0
  410. package/dist/install/codex-installer.js +91 -1
  411. package/dist/install/codex-installer.js.map +1 -1
  412. package/dist/install/codex-runtime-target.d.ts +0 -0
  413. package/dist/install/codex-runtime-target.js +0 -0
  414. package/dist/install/codex-runtime-target.js.map +0 -0
  415. package/dist/install/host-detection.d.ts +0 -0
  416. package/dist/install/host-detection.js +0 -0
  417. package/dist/install/host-detection.js.map +0 -0
  418. package/dist/install/openclaw-cli.d.ts +11 -0
  419. package/dist/install/openclaw-cli.js +0 -0
  420. package/dist/install/openclaw-cli.js.map +1 -1
  421. package/dist/install/openclaw-installer.d.ts +12 -0
  422. package/dist/install/openclaw-installer.js +198 -31
  423. package/dist/install/openclaw-installer.js.map +1 -1
  424. package/dist/install/public-install.d.ts +14 -4
  425. package/dist/install/public-install.js +20 -7
  426. package/dist/install/public-install.js.map +1 -1
  427. package/dist/install/registry-health.d.ts +0 -0
  428. package/dist/install/registry-health.js +0 -0
  429. package/dist/install/registry-health.js.map +0 -0
  430. package/dist/interaction/operational-actions-service.d.ts +0 -0
  431. package/dist/interaction/operational-actions-service.js +0 -0
  432. package/dist/interaction/operational-actions-service.js.map +0 -0
  433. package/dist/interaction/operational-service.d.ts +0 -0
  434. package/dist/interaction/operational-service.js +0 -0
  435. package/dist/interaction/operational-service.js.map +0 -0
  436. package/dist/interaction/repo-summary.d.ts +3 -17
  437. package/dist/interaction/repo-summary.js +10 -27
  438. package/dist/interaction/repo-summary.js.map +1 -1
  439. package/dist/interaction/service.d.ts +59 -95
  440. package/dist/interaction/service.js +505 -266
  441. package/dist/interaction/service.js.map +1 -1
  442. package/dist/interaction/state-artifact-service.d.ts +0 -0
  443. package/dist/interaction/state-artifact-service.js +0 -0
  444. package/dist/interaction/state-artifact-service.js.map +0 -0
  445. package/dist/maintenance/claude-validate-print.d.ts +0 -0
  446. package/dist/maintenance/claude-validate-print.js +0 -0
  447. package/dist/maintenance/claude-validate-print.js.map +0 -0
  448. package/dist/maintenance/embedding-smoke.d.ts +0 -0
  449. package/dist/maintenance/embedding-smoke.js +0 -0
  450. package/dist/maintenance/embedding-smoke.js.map +0 -0
  451. package/dist/maintenance/redistill-rule-nodes.d.ts +0 -0
  452. package/dist/maintenance/redistill-rule-nodes.js +0 -0
  453. package/dist/maintenance/redistill-rule-nodes.js.map +0 -0
  454. package/dist/maintenance/scope-merge.d.ts +0 -1
  455. package/dist/maintenance/scope-merge.js +0 -20
  456. package/dist/maintenance/scope-merge.js.map +1 -1
  457. package/dist/maintenance/warning-variant-cleanup.d.ts +0 -0
  458. package/dist/maintenance/warning-variant-cleanup.js +0 -0
  459. package/dist/maintenance/warning-variant-cleanup.js.map +0 -0
  460. package/dist/plugin/fixture-sanitizer.d.ts +0 -0
  461. package/dist/plugin/fixture-sanitizer.js +0 -0
  462. package/dist/plugin/fixture-sanitizer.js.map +0 -0
  463. package/dist/plugin/hooks/before-prompt-build.d.ts +1 -0
  464. package/dist/plugin/hooks/before-prompt-build.js +4 -1
  465. package/dist/plugin/hooks/before-prompt-build.js.map +1 -1
  466. package/dist/plugin/hooks/message-sent.d.ts +0 -0
  467. package/dist/plugin/hooks/message-sent.js +0 -0
  468. package/dist/plugin/hooks/message-sent.js.map +0 -0
  469. package/dist/plugin/hooks/tool-result-persist.d.ts +0 -0
  470. package/dist/plugin/hooks/tool-result-persist.js +0 -0
  471. package/dist/plugin/hooks/tool-result-persist.js.map +0 -0
  472. package/dist/plugin/openclaw-install-state.d.ts +39 -0
  473. package/dist/plugin/openclaw-install-state.js +24 -0
  474. package/dist/plugin/openclaw-install-state.js.map +1 -0
  475. package/dist/plugin/openclaw-plugin.d.ts +148 -0
  476. package/dist/plugin/openclaw-plugin.js +98 -7
  477. package/dist/plugin/openclaw-plugin.js.map +1 -1
  478. package/dist/plugin/openclaw-routine-interaction.d.ts +7 -0
  479. package/dist/plugin/openclaw-routine-interaction.js +301 -0
  480. package/dist/plugin/openclaw-routine-interaction.js.map +1 -0
  481. package/dist/plugin/openclaw-runtime-defaults.d.ts +16 -0
  482. package/dist/plugin/openclaw-runtime-defaults.js +16 -0
  483. package/dist/plugin/openclaw-runtime-defaults.js.map +1 -0
  484. package/dist/plugin/runtime-capture.d.ts +0 -0
  485. package/dist/plugin/runtime-capture.js +0 -0
  486. package/dist/plugin/runtime-capture.js.map +0 -0
  487. package/dist/plugin/runtime-helpers.d.ts +0 -0
  488. package/dist/plugin/runtime-helpers.js +0 -0
  489. package/dist/plugin/runtime-helpers.js.map +0 -0
  490. package/dist/runtime/service.d.ts +33 -6
  491. package/dist/runtime/service.js +427 -50
  492. package/dist/runtime/service.js.map +1 -1
  493. package/dist/store/logs/jsonl-logger.d.ts +0 -0
  494. package/dist/store/logs/jsonl-logger.js +0 -0
  495. package/dist/store/logs/jsonl-logger.js.map +0 -0
  496. package/dist/store/sqlite/db.d.ts +0 -0
  497. package/dist/store/sqlite/db.js +37 -0
  498. package/dist/store/sqlite/db.js.map +1 -1
  499. package/dist/store/sqlite/migrations.d.ts +0 -0
  500. package/dist/store/sqlite/migrations.js +0 -0
  501. package/dist/store/sqlite/migrations.js.map +0 -0
  502. package/dist/store/sqlite/repositories/candidate-repo.d.ts +0 -0
  503. package/dist/store/sqlite/repositories/candidate-repo.js +8 -2
  504. package/dist/store/sqlite/repositories/candidate-repo.js.map +1 -1
  505. package/dist/store/sqlite/repositories/distillation-job-repo.d.ts +0 -0
  506. package/dist/store/sqlite/repositories/distillation-job-repo.js +0 -0
  507. package/dist/store/sqlite/repositories/distillation-job-repo.js.map +0 -0
  508. package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.d.ts +11 -0
  509. package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.js +76 -0
  510. package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.js.map +1 -0
  511. package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.d.ts +11 -0
  512. package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.js +73 -0
  513. package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.js.map +1 -0
  514. package/dist/store/sqlite/repositories/injection-repo.d.ts +1 -0
  515. package/dist/store/sqlite/repositories/injection-repo.js +11 -0
  516. package/dist/store/sqlite/repositories/injection-repo.js.map +1 -1
  517. package/dist/store/sqlite/repositories/input-record-repo.d.ts +3 -0
  518. package/dist/store/sqlite/repositories/input-record-repo.js +35 -0
  519. package/dist/store/sqlite/repositories/input-record-repo.js.map +1 -1
  520. package/dist/store/sqlite/repositories/node-repo.d.ts +3 -0
  521. package/dist/store/sqlite/repositories/node-repo.js +62 -8
  522. package/dist/store/sqlite/repositories/node-repo.js.map +1 -1
  523. package/dist/store/sqlite/repositories/outcome-record-repo.d.ts +0 -0
  524. package/dist/store/sqlite/repositories/outcome-record-repo.js +0 -0
  525. package/dist/store/sqlite/repositories/outcome-record-repo.js.map +0 -0
  526. package/dist/store/sqlite/repositories/review-event-repo.d.ts +0 -0
  527. package/dist/store/sqlite/repositories/review-event-repo.js +0 -0
  528. package/dist/store/sqlite/repositories/review-event-repo.js.map +0 -0
  529. package/dist/store/sqlite/repositories/scope-repo.d.ts +0 -0
  530. package/dist/store/sqlite/repositories/scope-repo.js +0 -0
  531. package/dist/store/sqlite/repositories/scope-repo.js.map +0 -0
  532. package/dist/store/sqlite/repositories/stats-repo.d.ts +0 -0
  533. package/dist/store/sqlite/repositories/stats-repo.js +0 -0
  534. package/dist/store/sqlite/repositories/stats-repo.js.map +0 -0
  535. package/dist/store/sqlite/repositories/task-run-repo.d.ts +2 -0
  536. package/dist/store/sqlite/repositories/task-run-repo.js +18 -2
  537. package/dist/store/sqlite/repositories/task-run-repo.js.map +1 -1
  538. package/dist/store/sqlite/schema.sql +49 -49
  539. package/dist/store/vector/api-embedding-provider.d.ts +2 -0
  540. package/dist/store/vector/api-embedding-provider.js +23 -19
  541. package/dist/store/vector/api-embedding-provider.js.map +1 -1
  542. package/dist/store/vector/embeddings.d.ts +1 -1
  543. package/dist/store/vector/embeddings.js +26 -5
  544. package/dist/store/vector/embeddings.js.map +1 -1
  545. package/dist/store/vector/lancedb.d.ts +0 -0
  546. package/dist/store/vector/lancedb.js +0 -0
  547. package/dist/store/vector/lancedb.js.map +0 -0
  548. package/dist/store/vector/local-provider.d.ts +0 -0
  549. package/dist/store/vector/local-provider.js +0 -0
  550. package/dist/store/vector/local-provider.js.map +0 -0
  551. package/dist/store/vector/node-index.d.ts +0 -0
  552. package/dist/store/vector/node-index.js +0 -0
  553. package/dist/store/vector/node-index.js.map +0 -0
  554. package/dist/store/vector/provider-types.d.ts +0 -0
  555. package/dist/store/vector/provider-types.js +0 -0
  556. package/dist/store/vector/provider-types.js.map +0 -0
  557. package/dist/types/analyzer.d.ts +0 -0
  558. package/dist/types/analyzer.js +0 -0
  559. package/dist/types/analyzer.js.map +0 -0
  560. package/dist/types/domain.d.ts +166 -47
  561. package/dist/types/domain.js +0 -0
  562. package/dist/types/domain.js.map +0 -0
  563. package/dist/types/plugin.d.ts +3 -1
  564. package/dist/types/plugin.js +0 -0
  565. package/dist/types/plugin.js.map +0 -0
  566. package/dist/types/storage.d.ts +0 -0
  567. package/dist/types/storage.js +0 -0
  568. package/dist/types/storage.js.map +0 -0
  569. package/dist/utils/clock.d.ts +0 -0
  570. package/dist/utils/clock.js +0 -0
  571. package/dist/utils/clock.js.map +0 -0
  572. package/dist/utils/errors.d.ts +0 -0
  573. package/dist/utils/errors.js +0 -0
  574. package/dist/utils/errors.js.map +0 -0
  575. package/dist/utils/hashing.d.ts +0 -0
  576. package/dist/utils/hashing.js +0 -0
  577. package/dist/utils/hashing.js.map +0 -0
  578. package/dist/utils/ids.d.ts +0 -0
  579. package/dist/utils/ids.js +0 -0
  580. package/dist/utils/ids.js.map +0 -0
  581. package/dist/utils/text.d.ts +0 -0
  582. package/dist/utils/text.js +0 -0
  583. package/dist/utils/text.js.map +0 -0
  584. package/dist/version/package-version.d.ts +0 -0
  585. package/dist/version/package-version.js +0 -0
  586. package/dist/version/package-version.js.map +0 -0
  587. package/dist/version/remote-release.d.ts +0 -0
  588. package/dist/version/remote-release.js +0 -0
  589. package/dist/version/remote-release.js.map +0 -0
  590. package/docs/releases/v0.1.0.md +0 -0
  591. package/docs/releases/v0.1.1.md +0 -0
  592. package/docs/releases/v0.1.2.md +3 -3
  593. package/docs/releases/v0.1.3.md +95 -0
  594. package/docs/releases/v0.2.0.md +85 -0
  595. package/docs/user-guide.md +263 -133
  596. package/hooks/hooks.json +0 -0
  597. package/openclaw.plugin.json +81 -1
  598. package/package.json +25 -16
  599. package/plugins/claude-code-experienceengine/.claude-plugin/plugin.json +1 -1
  600. package/plugins/claude-code-experienceengine/.mcp.json +4 -3
  601. package/plugins/claude-code-experienceengine/hooks/hooks.json +0 -0
  602. package/plugins/claude-code-experienceengine/scripts/claude-hook.sh +30 -1
  603. package/plugins/claude-code-experienceengine/scripts/install-deps.sh +41 -6
  604. package/scripts/claude-plugin/claude-hook.sh +0 -0
  605. package/scripts/claude-plugin/install-deps.sh +0 -0
  606. package/dist/cli/commands/pack.d.ts +0 -1
  607. package/dist/cli/commands/pack.js +0 -321
  608. package/dist/cli/commands/pack.js.map +0 -1
  609. package/dist/compiler/agents-renderer.d.ts +0 -4
  610. package/dist/compiler/agents-renderer.js +0 -105
  611. package/dist/compiler/agents-renderer.js.map +0 -1
  612. package/dist/compiler/claude-renderer.d.ts +0 -2
  613. package/dist/compiler/claude-renderer.js +0 -40
  614. package/dist/compiler/claude-renderer.js.map +0 -1
  615. package/dist/compiler/codex-renderer.d.ts +0 -2
  616. package/dist/compiler/codex-renderer.js +0 -40
  617. package/dist/compiler/codex-renderer.js.map +0 -1
  618. package/dist/compiler/compiler.d.ts +0 -4
  619. package/dist/compiler/compiler.js +0 -87
  620. package/dist/compiler/compiler.js.map +0 -1
  621. package/dist/compiler/deployer.d.ts +0 -21
  622. package/dist/compiler/deployer.js +0 -64
  623. package/dist/compiler/deployer.js.map +0 -1
  624. package/dist/compiler/github-renderer.d.ts +0 -2
  625. package/dist/compiler/github-renderer.js +0 -63
  626. package/dist/compiler/github-renderer.js.map +0 -1
  627. package/dist/compiler/types.d.ts +0 -45
  628. package/dist/compiler/types.js.map +0 -1
  629. package/dist/interaction/pack-actions-service.d.ts +0 -59
  630. package/dist/interaction/pack-actions-service.js +0 -172
  631. package/dist/interaction/pack-actions-service.js.map +0 -1
  632. package/dist/packs/fs-registry.d.ts +0 -27
  633. package/dist/packs/fs-registry.js +0 -216
  634. package/dist/packs/fs-registry.js.map +0 -1
  635. package/dist/packs/index-sync.d.ts +0 -9
  636. package/dist/packs/index-sync.js +0 -54
  637. package/dist/packs/index-sync.js.map +0 -1
  638. package/dist/packs/types.d.ts +0 -55
  639. package/dist/packs/types.js +0 -2
  640. package/dist/store/sqlite/repositories/pack-repo.d.ts +0 -16
  641. package/dist/store/sqlite/repositories/pack-repo.js +0 -192
  642. package/dist/store/sqlite/repositories/pack-repo.js.map +0 -1
@@ -7,66 +7,40 @@ import { ExperienceInteractionService } from "../../interaction/service.js";
7
7
  import { ExperienceOperationalService } from "../../interaction/operational-service.js";
8
8
  import { ExperienceOperationalActionsService, } from "../../interaction/operational-actions-service.js";
9
9
  import { ExperienceStateArtifactService } from "../../interaction/state-artifact-service.js";
10
- import { ExperiencePackActionsService } from "../../interaction/pack-actions-service.js";
11
10
  import { ExperienceRuntimeService } from "../../runtime/service.js";
12
11
  import { fetchLatestGitHubReleaseStatus } from "../../version/remote-release.js";
13
- const NODE_STATES = ["candidate", "active", "cooling", "retired"];
12
+ import { createCodexActionRegistry } from "./action-registry.js";
13
+ import { createCodexBrokerFacade, executeCodexActionSchema, listCodexActionsSchema, prepareCodexActionSchema } from "./broker-tools.js";
14
+ const NODE_STATES = ["candidate", "priority_candidate", "active", "cooling", "retired"];
14
15
  const NODE_TYPES = ["strategy", "warning"];
15
16
  const EXPERIENCE_ADAPTERS = ["openclaw", "claude-code", "codex"];
16
17
  const HIGH_IMPACT_OPERATIONS = ["install", "repair", "upgrade"];
17
- const COMPILER_TARGETS = ["agents", "codex", "github", "claude"];
18
18
  const buildExperienceCapabilities = () => ({
19
- model: "agent-first",
20
- principles: [
21
- "Users should talk to the host agent instead of memorizing ee CLI commands.",
22
- "Low-risk read and preview operations should be direct MCP tools.",
23
- "High-risk write operations should use plan -> review -> confirm flows."
19
+ core_actions: [
20
+ "experienceengine_lookup_hints",
21
+ "experienceengine_explain_last_decision",
22
+ "experienceengine_record_tool_result",
23
+ "experienceengine_finalize_task",
24
+ "experienceengine_feedback_last",
25
+ "experienceengine_get_capabilities",
26
+ "experienceengine_doctor"
24
27
  ],
25
- packs: {
26
- directTools: [
27
- "experienceengine_pack_list",
28
- "experienceengine_pack_inspect",
29
- "experienceengine_pack_status",
30
- "experienceengine_pack_enable",
31
- "experienceengine_pack_disable"
32
- ],
33
- guardedTools: [
34
- "experienceengine_plan_pack_publish",
35
- "experienceengine_plan_pack_rollback",
36
- "experienceengine_execute_planned_pack_operation"
37
- ]
38
- },
39
- compiler: {
40
- directTools: [
41
- "experienceengine_pack_compile",
42
- "experienceengine_pack_deploy_preview"
43
- ],
44
- guardedTools: [
45
- "experienceengine_plan_pack_deploy",
46
- "experienceengine_execute_planned_pack_operation"
47
- ],
48
- targets: [...COMPILER_TARGETS]
49
- },
50
- prompts: [
51
- "experienceengine_review_repo_status",
52
- "experienceengine_review_pack_status",
53
- "experienceengine_prepare_pack_publish",
54
- "experienceengine_prepare_pack_rollback",
55
- "experienceengine_prepare_pack_deploy"
56
- ],
57
- resources: [
28
+ routine_read_surfaces: [
29
+ "experienceengine://doctor/{adapter}",
58
30
  "experienceengine://capabilities",
59
- "experienceengine://repo-summary",
60
- "experienceengine://packs",
61
- "experienceengine://pack/{id}",
62
31
  "experienceengine://last",
63
- "experienceengine://learning/summary"
32
+ "experienceengine://repo-summary"
33
+ ],
34
+ advanced_actions: [
35
+ "brokered admin actions",
36
+ "brokered maintenance actions",
37
+ "brokered inspect actions"
64
38
  ],
65
- cliFallbacks: [
39
+ high_risk_actions: [
66
40
  "install / repair / upgrade",
67
- "backup / export / import / rollback",
68
- "maintenance commands"
69
- ]
41
+ "backup / export / import / rollback"
42
+ ],
43
+ surface_model: "public core loop + public routine reads + brokered long-tail actions"
70
44
  });
71
45
  const createCodexRuntime = (options = {}) => {
72
46
  const paths = resolveExperienceEnginePaths({
@@ -81,7 +55,7 @@ const createCodexRuntime = (options = {}) => {
81
55
  }, {
82
56
  env: options.env ?? process.env,
83
57
  homeDir: options.homeDir
84
- }));
58
+ }), undefined, options.runtimeOptions);
85
59
  };
86
60
  const createCodexInteractionService = (options = {}) => {
87
61
  const paths = resolveExperienceEnginePaths({
@@ -96,9 +70,7 @@ const createCodexInteractionService = (options = {}) => {
96
70
  }, {
97
71
  env: options.env ?? process.env,
98
72
  homeDir: options.homeDir
99
- }), {
100
- packsDir: paths.packsDir
101
- });
73
+ }));
102
74
  };
103
75
  const createCodexOperationalService = (options = {}) => {
104
76
  if (!options.fetchImpl) {
@@ -117,11 +89,6 @@ const createCodexStateArtifactService = (options = {}) => options.stateArtifactS
117
89
  env: options.env ?? process.env,
118
90
  homeDir: options.homeDir
119
91
  });
120
- const createCodexPackActionsService = (options = {}) => options.packActionsService ??
121
- new ExperiencePackActionsService({
122
- env: options.env ?? process.env,
123
- homeDir: options.homeDir
124
- });
125
92
  const toTextToolResult = (result) => ({
126
93
  content: [
127
94
  {
@@ -130,6 +97,23 @@ const toTextToolResult = (result) => ({
130
97
  }
131
98
  ]
132
99
  });
100
+ const toNoticeAwareToolResult = (result) => ({
101
+ content: [
102
+ ...(result.notice
103
+ ? [
104
+ {
105
+ type: "text",
106
+ text: result.notice
107
+ }
108
+ ]
109
+ : []),
110
+ {
111
+ type: "text",
112
+ text: JSON.stringify(result ?? null, null, 2)
113
+ }
114
+ ],
115
+ structuredContent: result
116
+ });
133
117
  const toStructuredToolResult = (result) => ({
134
118
  content: [
135
119
  {
@@ -148,19 +132,6 @@ const toJsonResourceResult = (uri, result) => ({
148
132
  }
149
133
  ]
150
134
  });
151
- const parseRecentMode = (value) => {
152
- if (value === "all" || value === "injected") {
153
- return value;
154
- }
155
- throw new Error(`Unsupported recent mode: ${value}`);
156
- };
157
- const parsePositiveLimit = (value) => {
158
- const parsed = Number(value);
159
- if (!Number.isInteger(parsed) || parsed <= 0) {
160
- throw new Error(`Invalid positive limit: ${value}`);
161
- }
162
- return parsed;
163
- };
164
135
  const parseNodeState = (value) => {
165
136
  if (NODE_STATES.includes(value)) {
166
137
  return value;
@@ -186,11 +157,90 @@ const createJsonResourceLink = (uri, name, description) => ({
186
157
  mimeType: "application/json",
187
158
  description
188
159
  });
160
+ const summarizeActionReason = (scorecard) => {
161
+ if (scorecard.mode === "inject_conservative") {
162
+ if (scorecard.decisionReason === "ambiguous_same_family_candidate") {
163
+ return "ExperienceEngine found a promising same-family match and chose conservative injection instead of skipping.";
164
+ }
165
+ if (scorecard.decisionReason === "promising_candidate_quality") {
166
+ return "ExperienceEngine found a credible candidate, but kept the injection conservative until it has stronger runtime proof.";
167
+ }
168
+ return "ExperienceEngine chose conservative injection because the best match still needs more runtime evidence.";
169
+ }
170
+ if (scorecard.decisionReason === "mature_validated_candidate") {
171
+ return "A mature validated candidate cleared the fast path, so ExperienceEngine injected it normally.";
172
+ }
173
+ if (scorecard.decisionReason === "candidate_quality_positive") {
174
+ return "Candidate quality was strong enough to justify intervention for this task.";
175
+ }
176
+ if (scorecard.mode === "inject") {
177
+ return "ExperienceEngine injected the best available reusable guidance for this task.";
178
+ }
179
+ return undefined;
180
+ };
181
+ const summarizeTrust = (scorecard) => {
182
+ const primaryNode = scorecard.nodes?.[0];
183
+ if (!scorecard.riskLevel || !primaryNode?.state) {
184
+ return undefined;
185
+ }
186
+ const confidence = scorecard.confidence ? ` ${scorecard.confidence}-confidence` : "";
187
+ return `${scorecard.riskLevel}-risk${confidence} ${primaryNode.state} guidance with ${primaryNode.helped ?? 0} helped and ${primaryNode.harmed ?? 0} harmed signal(s).`;
188
+ };
189
+ const summarizeRetrievalNotes = (scorecard) => {
190
+ const notes = [];
191
+ if (scorecard.queryRewriteApplied) {
192
+ notes.push("Query rewrite preserved retrieval intent for this task.");
193
+ }
194
+ const rerankSource = scorecard.topCandidates?.[0]?.rerankSource;
195
+ if (rerankSource === "model") {
196
+ notes.push("Model reranking participated in the final ordering.");
197
+ }
198
+ if (scorecard.fastPathApplied) {
199
+ notes.push("A strong candidate fast path was used.");
200
+ }
201
+ const topCandidate = scorecard.topCandidates?.[0];
202
+ if (topCandidate?.retrievalReasons?.length) {
203
+ notes.push(`Top retrieval signals: ${topCandidate.retrievalReasons.slice(0, 2).join(", ")}.`);
204
+ }
205
+ if (topCandidate?.policyReasons?.length) {
206
+ notes.push(`Top policy signals: ${topCandidate.policyReasons.slice(0, 2).join(", ")}.`);
207
+ }
208
+ if (scorecard.rejectedCandidates?.length) {
209
+ notes.push(`Runner-up candidates withheld: ${scorecard.rejectedCandidates.map((candidate) => candidate.id).join(", ")}.`);
210
+ }
211
+ return notes;
212
+ };
213
+ const summarizeScorecard = (scorecard) => scorecard
214
+ ? {
215
+ mode: scorecard.mode,
216
+ riskLevel: scorecard.riskLevel,
217
+ recommendation: scorecard.recommendation,
218
+ actionReason: summarizeActionReason(scorecard),
219
+ trustSummary: summarizeTrust(scorecard),
220
+ retrievalNotes: summarizeRetrievalNotes(scorecard),
221
+ confidence: scorecard.confidence,
222
+ budgetClass: scorecard.budgetClass,
223
+ selectedCandidateIds: scorecard.selectedCandidateIds,
224
+ rejectedCandidates: scorecard.rejectedCandidates?.slice(0, 3).map((candidate) => ({
225
+ id: candidate.id,
226
+ reasonCodes: candidate.reasonCodes
227
+ })) ?? [],
228
+ reasons: scorecard.reasons?.slice(0, 2),
229
+ nodes: scorecard.nodes?.slice(0, 3).map((node) => ({
230
+ id: node.id,
231
+ state: node.state,
232
+ riskLevel: node.riskLevel,
233
+ helped: node.helped,
234
+ harmed: node.harmed
235
+ })) ?? []
236
+ }
237
+ : undefined;
189
238
  export const createCodexBehaviorLoop = (options = {}) => {
190
239
  const runtime = createCodexRuntime(options);
191
240
  return {
192
241
  async lookupHints(args) {
193
242
  const result = await runtime.beforePromptBuild({
243
+ host: "codex",
194
244
  sessionId: args.sessionId,
195
245
  cwd: args.cwd,
196
246
  userMessage: args.prompt,
@@ -201,7 +251,7 @@ export const createCodexBehaviorLoop = (options = {}) => {
201
251
  text: result.text,
202
252
  notice: result.notice,
203
253
  injectedNodeIds: result.input.injected_node_ids,
204
- scorecard: result.scorecard,
254
+ summary: summarizeScorecard(result.scorecard),
205
255
  deliveryMode: result.deliveryMode,
206
256
  delivered: result.delivered
207
257
  };
@@ -217,34 +267,35 @@ export const createCodexBehaviorLoop = (options = {}) => {
217
267
  status: args.status
218
268
  });
219
269
  return {
270
+ status: "recorded",
220
271
  toolName: event.tool_name,
221
- status: event.status,
222
- inputSummary: event.input_summary,
223
- outputSummary: event.output_summary,
224
- errorSignature: event.error_signature,
272
+ eventStatus: event.status,
273
+ hasErrorSignature: Boolean(event.error_signature),
225
274
  exitCode: event.exit_code
226
275
  };
227
276
  },
228
277
  async finalizeTask(args) {
229
278
  const input = await runtime.finalizeTask({
279
+ host: "codex",
230
280
  sessionId: args.sessionId,
231
281
  cwd: args.cwd,
232
- userMessage: args.prompt,
282
+ userMessage: args.prompt ?? "",
233
283
  taskSummary: args.prompt,
234
284
  contextSummary: args.contextSummary
235
285
  });
236
286
  return {
287
+ status: "finalized",
237
288
  taskType: input.task_type,
238
- taskSummary: input.task_summary,
239
289
  outcomeSignal: input.outcome_signal,
240
290
  injectedNodeIds: input.injected_node_ids,
291
+ recordedToolEvents: input.tool_events.length,
241
292
  feedbackHint: input.injected_node_ids.length > 0
242
293
  ? "If the injected guidance helped or harmed this task, call experienceengine_quick_feedback."
243
- : undefined,
244
- evidence: input.tool_events.map((event) => [event.tool_name, event.status, event.error_signature ?? event.output_summary]
245
- .filter(Boolean)
246
- .join(": "))
294
+ : undefined
247
295
  };
296
+ },
297
+ async waitForBackgroundLearning() {
298
+ await runtime.waitForBackgroundLearning();
248
299
  }
249
300
  };
250
301
  };
@@ -266,27 +317,6 @@ export const createCodexInteractionSurface = (options = {}) => {
266
317
  async inspectNode(args) {
267
318
  return interaction.inspectNode(args.nodeId);
268
319
  },
269
- async listPacks() {
270
- return interaction.listPacks();
271
- },
272
- async inspectPack(args) {
273
- return interaction.inspectPack(args.packId);
274
- },
275
- async enablePack(args) {
276
- return interaction.enablePack(args);
277
- },
278
- async disablePack(args) {
279
- return interaction.disablePack(args);
280
- },
281
- async inspectPackDeploymentStatus(args) {
282
- return interaction.inspectPackDeploymentStatus(args);
283
- },
284
- async compilePack(args) {
285
- return interaction.compilePack(args);
286
- },
287
- async deployPackPreview(args) {
288
- return interaction.deployPackPreview(args);
289
- },
290
320
  async listNodesByState(args) {
291
321
  return interaction.listNodesByState(args.state);
292
322
  },
@@ -299,6 +329,9 @@ export const createCodexInteractionSurface = (options = {}) => {
299
329
  async inspectRepoSummary(args = {}) {
300
330
  return interaction.inspectRepoSummary(args.cwd);
301
331
  },
332
+ async explainLastDecision(args) {
333
+ return interaction.explainLastDecision(args.cwd, args.userMessage);
334
+ },
302
335
  async feedbackLast(args) {
303
336
  return interaction.feedbackLast(args.feedback);
304
337
  },
@@ -328,11 +361,17 @@ export const createCodexMcpServer = (options = {}) => {
328
361
  const interactionSurface = createCodexInteractionSurface(options);
329
362
  const operationalSurface = createCodexOperationalService(options);
330
363
  const operationalActions = createCodexOperationalActionsService(options);
331
- const packActions = createCodexPackActionsService(options);
332
364
  const stateArtifacts = createCodexStateArtifactService(options);
365
+ const actionRegistry = createCodexActionRegistry({
366
+ interactionSurface,
367
+ operationalSurface,
368
+ operationalActions,
369
+ stateArtifacts
370
+ });
371
+ const brokerFacade = createCodexBrokerFacade(actionRegistry);
333
372
  const server = new McpServer({
334
373
  name: "experienceengine",
335
- version: "0.1.2"
374
+ version: "0.2.0"
336
375
  });
337
376
  server.registerResource("experienceengine_doctor", new ResourceTemplate("experienceengine://doctor/{adapter}", {
338
377
  list: undefined,
@@ -344,437 +383,36 @@ export const createCodexMcpServer = (options = {}) => {
344
383
  description: "Structured ExperienceEngine adapter health and installation state.",
345
384
  mimeType: "application/json"
346
385
  }, async (uri, variables) => toJsonResourceResult(uri.toString(), await operationalSurface.inspectDoctor(parseAdapter(String(variables.adapter)))));
347
- server.registerResource("experienceengine_updates_latest", new ResourceTemplate("experienceengine://updates/latest/{adapter}", {
348
- list: undefined,
349
- complete: {
350
- adapter: () => [...EXPERIENCE_ADAPTERS]
351
- }
352
- }), {
353
- title: "ExperienceEngine Latest Update State",
354
- description: "Latest release/update status for an ExperienceEngine adapter context.",
355
- mimeType: "application/json"
356
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await operationalSurface.checkUpdate(parseAdapter(String(variables.adapter)))));
357
- server.registerResource("experienceengine_backups", "experienceengine://backups", {
358
- title: "ExperienceEngine Backup Inventory",
359
- description: "Managed ExperienceEngine backups available for rollback or export review.",
360
- mimeType: "application/json"
361
- }, async (uri) => toJsonResourceResult(uri.toString(), stateArtifacts.listBackups()));
362
386
  server.registerResource("experienceengine_last", "experienceengine://last", {
363
387
  title: "ExperienceEngine Last Interaction",
364
388
  description: "The most recent persisted ExperienceEngine input record and any injected nodes.",
365
389
  mimeType: "application/json"
366
390
  }, async (uri) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectLast()));
367
- server.registerResource("experienceengine_recent", new ResourceTemplate("experienceengine://recent/{mode}/{limit}", {
368
- list: undefined,
369
- complete: {
370
- mode: () => ["all", "injected"],
371
- limit: () => ["5", "10", "20"]
372
- }
373
- }), {
374
- title: "ExperienceEngine Recent History",
375
- description: "Recent ExperienceEngine input records, optionally filtered to injected turns only.",
376
- mimeType: "application/json"
377
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectRecent({
378
- mode: parseRecentMode(String(variables.mode ?? "all")),
379
- limit: parsePositiveLimit(String(variables.limit ?? "10"))
380
- })));
381
391
  server.registerResource("experienceengine_capabilities", "experienceengine://capabilities", {
382
392
  title: "ExperienceEngine Capabilities",
383
- description: "Agent-first overview of ExperienceEngine MCP tools, guarded flows, prompts, and fallback boundaries.",
393
+ description: "Agent-first overview of ExperienceEngine MCP tools, routine reads, brokered actions, and fallback boundaries.",
384
394
  mimeType: "application/json"
385
395
  }, async (uri) => toJsonResourceResult(uri.toString(), buildExperienceCapabilities()));
386
396
  server.registerResource("experienceengine_repo_summary", "experienceengine://repo-summary", {
387
397
  title: "ExperienceEngine Repo Summary",
388
- description: "Repo-level ExperienceEngine summary for the current scope, including benchmark, packs, deployment, and next action.",
398
+ description: "Repo-level ExperienceEngine summary for the current scope, including benchmark and next action.",
389
399
  mimeType: "application/json"
390
400
  }, async (uri) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectRepoSummary()));
391
- server.registerResource("experienceengine_packs", "experienceengine://packs", {
392
- title: "ExperienceEngine Packs",
393
- description: "Published and draft local Experience Pack assets in the shared registry.",
394
- mimeType: "application/json"
395
- }, async (uri) => toJsonResourceResult(uri.toString(), await interactionSurface.listPacks()));
396
- server.registerResource("experienceengine_pack", new ResourceTemplate("experienceengine://pack/{id}", {
397
- list: undefined
398
- }), {
399
- title: "ExperienceEngine Pack Detail",
400
- description: "A single Experience Pack and its current version detail.",
401
- mimeType: "application/json"
402
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectPack({ packId: String(variables.id) })));
403
- server.registerResource("experienceengine_learning_summary", "experienceengine://learning/summary", {
404
- title: "ExperienceEngine Learning Summary",
405
- description: "Candidate, distillation, and formal node counts across the learning pipeline.",
406
- mimeType: "application/json"
407
- }, async (uri) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectLearningSummary()));
408
- server.registerResource("experienceengine_active_nodes", "experienceengine://nodes/active", {
409
- title: "ExperienceEngine Active Nodes",
410
- description: "All currently active ExperienceEngine nodes.",
411
- mimeType: "application/json"
412
- }, async (uri) => toJsonResourceResult(uri.toString(), await interactionSurface.listActiveNodes()));
413
- server.registerResource("experienceengine_node", new ResourceTemplate("experienceengine://node/{id}", {
414
- list: undefined
415
- }), {
416
- title: "ExperienceEngine Node Detail",
417
- description: "A single ExperienceEngine node by id.",
418
- mimeType: "application/json"
419
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await interactionSurface.inspectNode({ nodeId: String(variables.id) })));
420
- server.registerResource("experienceengine_nodes_by_state", new ResourceTemplate("experienceengine://nodes/state/{state}", {
421
- list: undefined,
422
- complete: {
423
- state: () => [...NODE_STATES]
424
- }
425
- }), {
426
- title: "ExperienceEngine Nodes By State",
427
- description: "ExperienceEngine nodes filtered by lifecycle state.",
428
- mimeType: "application/json"
429
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await interactionSurface.listNodesByState({
430
- state: parseNodeState(String(variables.state))
431
- })));
432
- server.registerResource("experienceengine_nodes_by_type", new ResourceTemplate("experienceengine://nodes/type/{type}", {
433
- list: undefined,
434
- complete: {
435
- type: () => [...NODE_TYPES]
436
- }
437
- }), {
438
- title: "ExperienceEngine Nodes By Type",
439
- description: "ExperienceEngine nodes filtered by node type.",
440
- mimeType: "application/json"
441
- }, async (uri, variables) => toJsonResourceResult(uri.toString(), await interactionSurface.listNodesByType({
442
- nodeType: parseNodeType(String(variables.type))
443
- })));
444
- server.registerPrompt("experienceengine_review_repo_status", {
445
- title: "ExperienceEngine Review Repo Status",
446
- description: "Guide the host agent to review the current repo's ExperienceEngine state before deciding what to do next."
447
- }, async () => ({
448
- messages: [
449
- {
450
- role: "user",
451
- content: {
452
- type: "text",
453
- text: "First read the experienceengine://repo-summary resource. Then call experienceengine_get_repo_summary if you need the structured form. Summarize the repo benchmark verdict, suggested mode, active packs, deploy status, and the most conservative next action."
454
- }
455
- }
456
- ]
457
- }));
458
- server.registerPrompt("experienceengine_review_capabilities", {
459
- title: "ExperienceEngine Review Capabilities",
460
- description: "Guide the host agent to review ExperienceEngine's agent-first MCP surface before operating packs or compiler targets."
461
- }, async () => ({
462
- messages: [
463
- {
464
- role: "user",
465
- content: {
466
- type: "text",
467
- text: "First read the experienceengine://capabilities resource. Then summarize which ExperienceEngine operations are direct low-risk tools, which require confirmation, and which CLI fallbacks remain outside the normal host-agent flow."
468
- }
469
- }
470
- ]
471
- }));
472
- server.registerPrompt("experienceengine_prepare_state_operation", {
473
- title: "ExperienceEngine Prepare State Operation",
474
- description: "Review a backup, export, import, or rollback plan before execution.",
475
- argsSchema: {
476
- operation: z.enum(["backup", "export", "import", "rollback"]),
477
- backupId: z.string().optional(),
478
- importPath: z.string().optional()
479
- }
480
- }, async ({ operation, backupId, importPath }) => {
481
- const planTool = operation === "backup"
482
- ? "experienceengine_plan_backup"
483
- : operation === "export"
484
- ? "experienceengine_plan_export"
485
- : operation === "import"
486
- ? "experienceengine_plan_import"
487
- : "experienceengine_plan_rollback";
488
- const suffix = operation === "rollback"
489
- ? ` with backupId=${backupId ?? "<backup-id>"}`
490
- : operation === "import"
491
- ? ` with importPath=${importPath ?? "<snapshot-path>"}`
492
- : "";
493
- return {
494
- messages: [
495
- {
496
- role: "user",
497
- content: {
498
- type: "text",
499
- text: `First call ${planTool}${suffix}. Review the returned summary, effects, and artifact path with the user. Only if the user explicitly confirms should you call experienceengine_execute_planned_state_operation with the returned planId and confirmationToken.`
500
- }
501
- }
502
- ]
503
- };
504
- });
505
- server.registerPrompt("experienceengine_prepare_operational_change", {
506
- title: "ExperienceEngine Prepare Operational Change",
507
- description: "Plan a high-impact ExperienceEngine install, repair, or upgrade before execution.",
508
- argsSchema: {
509
- adapter: z.enum(EXPERIENCE_ADAPTERS),
510
- operation: z.enum(HIGH_IMPACT_OPERATIONS)
511
- }
512
- }, async ({ adapter, operation }) => ({
513
- messages: [
514
- {
515
- role: "user",
516
- content: {
517
- type: "text",
518
- text: `First call experienceengine_plan_${operation} with adapter=${adapter}. Review the returned summary, effects, and commandHint with the user. Only if the user explicitly confirms should you call experienceengine_execute_planned_operation with the returned planId and confirmationToken.`
519
- }
520
- }
521
- ]
522
- }));
523
- server.registerPrompt("experienceengine_review_pack_status", {
524
- title: "ExperienceEngine Review Pack Status",
525
- description: "Guide the agent to inspect one pack, its compile state, and current repo deployment status.",
526
- argsSchema: {
527
- packId: z.string().min(1),
528
- target: z.enum(COMPILER_TARGETS),
529
- repoPath: z.string().min(1)
530
- }
531
- }, async ({ packId, target, repoPath }) => ({
532
- messages: [
533
- {
534
- role: "user",
535
- content: {
536
- type: "text",
537
- text: `Review the Experience Pack ${packId}. First call experienceengine_pack_inspect to inspect the pack itself. Then call experienceengine_pack_status with target=${target} and repoPath=${repoPath} to inspect whether the current repository is missing, up to date, or drifted. Summarize the pack state, compile state, deployment state, and the next recommended action.`
538
- }
539
- }
540
- ]
541
- }));
542
- server.registerPrompt("experienceengine_prepare_pack_publish", {
543
- title: "ExperienceEngine Prepare Pack Publish",
544
- description: "Guide the agent through the confirmation flow for publishing an Experience Pack.",
545
- argsSchema: {
546
- packId: z.string().min(1)
547
- }
548
- }, async ({ packId }) => ({
549
- messages: [
550
- {
551
- role: "user",
552
- content: {
553
- type: "text",
554
- text: `First call experienceengine_plan_pack_publish with packId=${packId}. Review the returned summary, effects, and commandHint with the user. Only if the user explicitly confirms should you call experienceengine_execute_planned_pack_operation with the returned planId and confirmationToken.`
555
- }
556
- }
557
- ]
558
- }));
559
- server.registerPrompt("experienceengine_prepare_pack_rollback", {
560
- title: "ExperienceEngine Prepare Pack Rollback",
561
- description: "Guide the agent through the confirmation flow for rolling an Experience Pack back to a selected version.",
562
- argsSchema: {
563
- packId: z.string().min(1),
564
- version: z.string().min(1)
565
- }
566
- }, async ({ packId, version }) => ({
567
- messages: [
568
- {
569
- role: "user",
570
- content: {
571
- type: "text",
572
- text: `First call experienceengine_plan_pack_rollback with packId=${packId} and version=${version}. Review the returned summary, effects, and commandHint with the user. Only if the user explicitly confirms should you call experienceengine_execute_planned_pack_operation with the returned planId and confirmationToken.`
573
- }
574
- }
575
- ]
576
- }));
577
- server.registerPrompt("experienceengine_prepare_pack_deploy", {
578
- title: "ExperienceEngine Prepare Pack Deploy",
579
- description: "Guide the agent through the confirmation flow for deploying a compiled Experience Pack into a repository.",
580
- argsSchema: {
581
- packId: z.string().min(1),
582
- target: z.enum(COMPILER_TARGETS),
583
- repoPath: z.string().min(1)
584
- }
585
- }, async ({ packId, target, repoPath }) => ({
586
- messages: [
587
- {
588
- role: "user",
589
- content: {
590
- type: "text",
591
- text: `First call experienceengine_plan_pack_deploy with packId=${packId}, target=${target}, and repoPath=${repoPath}. Review the returned summary, effects, and commandHint with the user. Only if the user explicitly confirms should you call experienceengine_execute_planned_pack_operation with the returned planId and confirmationToken.`
592
- }
593
- }
594
- ]
595
- }));
596
- server.registerPrompt("experienceengine_show_last_intervention", {
597
- title: "ExperienceEngine Show Last Intervention",
598
- description: "Review the most recent ExperienceEngine interaction and summarize what happened."
599
- }, async () => ({
600
- messages: [
601
- {
602
- role: "user",
603
- content: {
604
- type: "text",
605
- text: "Review the latest ExperienceEngine interaction. Summarize whether guidance was injected, which nodes were involved, and what outcome was recorded."
606
- }
607
- },
608
- {
609
- role: "user",
610
- content: createJsonResourceLink("experienceengine://last", "ExperienceEngine Last Interaction", "The latest persisted ExperienceEngine record and any resolved injected nodes.")
611
- }
612
- ]
613
- }));
614
- server.registerPrompt("experienceengine_review_recent_injected", {
615
- title: "ExperienceEngine Review Recent Injected",
616
- description: "Review recent ExperienceEngine turns that actually injected guidance.",
617
- argsSchema: {
618
- limit: z.string().optional()
619
- }
620
- }, async ({ limit }) => {
621
- const resolvedLimit = limit ? parsePositiveLimit(limit) : 5;
622
- const uri = `experienceengine://recent/injected/${resolvedLimit}`;
623
- return {
624
- messages: [
625
- {
626
- role: "user",
627
- content: {
628
- type: "text",
629
- text: `Review the ${resolvedLimit} most recent ExperienceEngine turns that injected guidance. Summarize recurring successful patterns and any harmful repeats.`
630
- }
631
- },
632
- {
633
- role: "user",
634
- content: createJsonResourceLink(uri, "ExperienceEngine Recent Injected History", "Recent ExperienceEngine records filtered to injected turns.")
635
- }
636
- ]
637
- };
638
- });
639
- server.registerPrompt("experienceengine_review_warning_nodes", {
640
- title: "ExperienceEngine Review Warning Nodes",
641
- description: "Review current warning nodes to assess whether they are still useful or noisy."
642
- }, async () => ({
643
- messages: [
644
- {
645
- role: "user",
646
- content: {
647
- type: "text",
648
- text: "Review the current ExperienceEngine warning nodes. Identify noisy or stale warnings, and call out any warning that appears to be over-firing or no longer useful."
649
- }
650
- },
651
- {
652
- role: "user",
653
- content: createJsonResourceLink("experienceengine://nodes/type/warning", "ExperienceEngine Warning Nodes", "All ExperienceEngine nodes currently classified as warning nodes.")
654
- }
655
- ]
656
- }));
657
- server.registerPrompt("experienceengine_pause_current_project", {
658
- title: "ExperienceEngine Pause Current Project",
659
- description: "Guide the agent to pause ExperienceEngine interventions for the current project.",
660
- argsSchema: {
661
- cwd: z.string().optional()
662
- }
663
- }, async ({ cwd }) => ({
664
- messages: [
665
- {
666
- role: "user",
667
- content: {
668
- type: "text",
669
- text: `Pause ExperienceEngine interventions for the current project${cwd ? ` at ${cwd}` : ""}. Confirm this action before calling the experienceengine_disable_scope tool, then summarize which scope was changed.`
670
- }
671
- }
672
- ]
673
- }));
674
- server.registerPrompt("experienceengine_resume_current_project", {
675
- title: "ExperienceEngine Resume Current Project",
676
- description: "Guide the agent to resume ExperienceEngine interventions for the current project.",
677
- argsSchema: {
678
- cwd: z.string().optional()
679
- }
680
- }, async ({ cwd }) => ({
681
- messages: [
682
- {
683
- role: "user",
684
- content: {
685
- type: "text",
686
- text: `Resume ExperienceEngine interventions for the current project${cwd ? ` at ${cwd}` : ""}. Confirm this action before calling the experienceengine_enable_scope tool, then summarize which scope was changed.`
687
- }
688
- }
689
- ]
690
- }));
691
- server.registerPrompt("experienceengine_mark_last_experience_helpful", {
692
- title: "ExperienceEngine Mark Last Experience Helpful",
693
- description: "Guide the agent to mark the last injected experience as helpful."
694
- }, async () => ({
695
- messages: [
696
- {
697
- role: "user",
698
- content: {
699
- type: "text",
700
- text: "Mark the last injected ExperienceEngine guidance as helpful. Confirm with the user if needed, then call the experienceengine_feedback_last tool with feedback=helped and summarize which nodes were updated."
701
- }
702
- }
703
- ]
704
- }));
705
- server.registerPrompt("experienceengine_mark_last_experience_harmful", {
706
- title: "ExperienceEngine Mark Last Experience Harmful",
707
- description: "Guide the agent to mark the last injected experience as harmful."
708
- }, async () => ({
709
- messages: [
710
- {
711
- role: "user",
712
- content: {
713
- type: "text",
714
- text: "Mark the last injected ExperienceEngine guidance as harmful. Confirm with the user if needed, then call the experienceengine_feedback_last tool with feedback=harmed and summarize which nodes were updated."
715
- }
716
- }
717
- ]
718
- }));
719
- server.registerTool("experienceengine_plan_backup", {
720
- title: "ExperienceEngine Plan Backup",
721
- description: "Create a structured plan for backing up ExperienceEngine-managed state."
722
- }, async () => toStructuredToolResult(stateArtifacts.planOperation({ operation: "backup" })));
723
- server.registerTool("experienceengine_plan_export", {
724
- title: "ExperienceEngine Plan Export",
725
- description: "Create a structured plan for exporting ExperienceEngine-managed state."
726
- }, async () => toStructuredToolResult(stateArtifacts.planOperation({ operation: "export" })));
727
- server.registerTool("experienceengine_plan_import", {
728
- title: "ExperienceEngine Plan Import",
729
- description: "Create a structured plan for importing an ExperienceEngine snapshot.",
730
- inputSchema: z.object({
731
- importPath: z.string().min(1)
732
- })
733
- }, async ({ importPath }) => toStructuredToolResult(stateArtifacts.planOperation({ operation: "import", importPath })));
734
- server.registerTool("experienceengine_plan_rollback", {
735
- title: "ExperienceEngine Plan Rollback",
736
- description: "Create a structured plan for rolling back ExperienceEngine state to a managed backup.",
737
- inputSchema: z.object({
738
- backupId: z.string().min(1)
739
- })
740
- }, async ({ backupId }) => toStructuredToolResult(stateArtifacts.planOperation({ operation: "rollback", backupId })));
741
- server.registerTool("experienceengine_execute_planned_state_operation", {
742
- title: "ExperienceEngine Execute Planned State Operation",
743
- description: "Execute a previously planned ExperienceEngine backup, export, import, or rollback after explicit confirmation.",
744
- inputSchema: z.object({
745
- planId: z.string().min(1),
746
- confirmationToken: z.string().min(1)
747
- })
748
- }, async ({ planId, confirmationToken }) => toStructuredToolResult(stateArtifacts.executePlannedOperation({ planId, confirmationToken })));
749
- server.registerTool("experienceengine_plan_install", {
750
- title: "ExperienceEngine Plan Install",
751
- description: "Create a structured plan for installing ExperienceEngine on a supported adapter.",
752
- inputSchema: z.object({
753
- adapter: z.enum(EXPERIENCE_ADAPTERS)
754
- })
755
- }, async ({ adapter }) => toStructuredToolResult(operationalActions.planOperation({ adapter, operation: "install" })));
756
- server.registerTool("experienceengine_plan_repair", {
757
- title: "ExperienceEngine Plan Repair",
758
- description: "Create a structured plan for repairing ExperienceEngine wiring on a supported adapter.",
759
- inputSchema: z.object({
760
- adapter: z.enum(EXPERIENCE_ADAPTERS)
761
- })
762
- }, async ({ adapter }) => toStructuredToolResult(operationalActions.planOperation({ adapter, operation: "repair" })));
763
- server.registerTool("experienceengine_plan_upgrade", {
764
- title: "ExperienceEngine Plan Upgrade",
765
- description: "Create a structured plan for upgrading ExperienceEngine on a supported adapter.",
766
- inputSchema: z.object({
767
- adapter: z.enum(EXPERIENCE_ADAPTERS)
768
- })
769
- }, async ({ adapter }) => toStructuredToolResult(operationalActions.planOperation({ adapter, operation: "upgrade" })));
770
- server.registerTool("experienceengine_execute_planned_operation", {
771
- title: "ExperienceEngine Execute Planned Operation",
772
- description: "Execute a previously planned high-impact ExperienceEngine operation after explicit user confirmation.",
773
- inputSchema: z.object({
774
- planId: z.string().min(1),
775
- confirmationToken: z.string().min(1)
776
- })
777
- }, async ({ planId, confirmationToken }) => toStructuredToolResult(operationalActions.executePlannedOperation({ planId, confirmationToken })));
401
+ server.registerTool("experienceengine_list_actions", {
402
+ title: "ExperienceEngine List Actions",
403
+ description: "List brokered EE long-tail actions without exposing full schemas.",
404
+ inputSchema: listCodexActionsSchema
405
+ }, async (args) => toStructuredToolResult(brokerFacade.listActions(args)));
406
+ server.registerTool("experienceengine_prepare_action", {
407
+ title: "ExperienceEngine Prepare Action",
408
+ description: "Read detailed metadata for one brokered EE action.",
409
+ inputSchema: prepareCodexActionSchema
410
+ }, async (args) => toStructuredToolResult(brokerFacade.prepareAction(args)));
411
+ server.registerTool("experienceengine_execute_action", {
412
+ title: "ExperienceEngine Execute Action",
413
+ description: "Execute one brokered EE action through the internal action registry.",
414
+ inputSchema: executeCodexActionSchema
415
+ }, async (args) => toStructuredToolResult(await brokerFacade.executeAction(args)));
778
416
  server.registerTool("experienceengine_doctor", {
779
417
  title: "ExperienceEngine Doctor",
780
418
  description: "Inspect structured ExperienceEngine adapter health and installation state.",
@@ -786,147 +424,39 @@ export const createCodexMcpServer = (options = {}) => {
786
424
  openWorldHint: false
787
425
  }
788
426
  }, async ({ adapter }) => toTextToolResult(await operationalSurface.inspectDoctor(adapter)));
789
- server.registerTool("experienceengine_check_update", {
790
- title: "ExperienceEngine Check Update",
791
- description: "Check structured ExperienceEngine release/update state for an adapter context.",
792
- inputSchema: z.object({
793
- adapter: z.enum(EXPERIENCE_ADAPTERS)
794
- }),
795
- annotations: {
796
- readOnlyHint: true,
797
- openWorldHint: true
798
- }
799
- }, async ({ adapter }) => toTextToolResult(await operationalSurface.checkUpdate(adapter)));
800
- server.registerTool("experienceengine_plan_pack_publish", {
801
- title: "ExperienceEngine Plan Pack Publish",
802
- description: "Create a structured confirmation plan for publishing an Experience Pack.",
803
- inputSchema: z.object({
804
- packId: z.string().min(1)
805
- })
806
- }, async ({ packId }) => toStructuredToolResult(packActions.planPublish(packId)));
807
- server.registerTool("experienceengine_plan_pack_rollback", {
808
- title: "ExperienceEngine Plan Pack Rollback",
809
- description: "Create a structured confirmation plan for rolling an Experience Pack back to an earlier version.",
810
- inputSchema: z.object({
811
- packId: z.string().min(1),
812
- version: z.string().min(1)
813
- })
814
- }, async ({ packId, version }) => toStructuredToolResult(packActions.planRollback(packId, version)));
815
- server.registerTool("experienceengine_plan_pack_deploy", {
816
- title: "ExperienceEngine Plan Pack Deploy",
817
- description: "Create a structured confirmation plan for deploying a compiled Experience Pack into a repository.",
818
- inputSchema: z.object({
819
- packId: z.string().min(1),
820
- version: z.string().optional(),
821
- target: z.enum(COMPILER_TARGETS),
822
- repoPath: z.string().min(1)
823
- })
824
- }, async ({ packId, version, target, repoPath }) => toStructuredToolResult(packActions.planDeploy(packId, target, repoPath, version)));
825
- server.registerTool("experienceengine_execute_planned_pack_operation", {
826
- title: "ExperienceEngine Execute Planned Pack Operation",
827
- description: "Execute a previously planned pack publish, rollback, or deploy after explicit confirmation.",
828
- inputSchema: z.object({
829
- planId: z.string().min(1),
830
- confirmationToken: z.string().min(1)
831
- })
832
- }, async ({ planId, confirmationToken }) => toStructuredToolResult(packActions.executePlannedOperation({ planId, confirmationToken })));
833
- server.registerTool("experienceengine_pack_list", {
834
- title: "ExperienceEngine Pack List",
835
- description: "List local Experience Packs available in the shared registry.",
427
+ server.registerTool("experienceengine_get_capabilities", {
428
+ title: "ExperienceEngine Capabilities",
429
+ description: "Read the current ExperienceEngine MCP capabilities, including direct tools, routine reads, brokered actions, and CLI-only fallbacks.",
836
430
  inputSchema: z.object({}),
837
431
  annotations: {
838
432
  readOnlyHint: true,
839
433
  openWorldHint: false
840
434
  }
841
- }, async () => toStructuredToolResult({ packs: await interactionSurface.listPacks() }));
842
- server.registerTool("experienceengine_pack_inspect", {
843
- title: "ExperienceEngine Pack Inspect",
844
- description: "Inspect one Experience Pack, including its current version, nodes, activations, and compiled artifacts.",
845
- inputSchema: z.object({
846
- packId: z.string().min(1)
847
- }),
848
- annotations: {
849
- readOnlyHint: true,
850
- openWorldHint: false
851
- }
852
- }, async ({ packId }) => toStructuredToolResult(await interactionSurface.inspectPack({ packId })));
853
- server.registerTool("experienceengine_pack_enable", {
854
- title: "ExperienceEngine Pack Enable",
855
- description: "Enable an Experience Pack for the current repository scope.",
856
- inputSchema: z.object({
857
- packId: z.string().min(1),
858
- cwd: z.string().optional()
859
- })
860
- }, async ({ packId, cwd }) => toStructuredToolResult(await interactionSurface.enablePack({ packId, cwd })));
861
- server.registerTool("experienceengine_pack_disable", {
862
- title: "ExperienceEngine Pack Disable",
863
- description: "Disable an Experience Pack for the current repository scope.",
864
- inputSchema: z.object({
865
- packId: z.string().min(1),
866
- cwd: z.string().optional()
867
- })
868
- }, async ({ packId, cwd }) => toStructuredToolResult(await interactionSurface.disablePack({ packId, cwd })));
869
- server.registerTool("experienceengine_pack_status", {
870
- title: "ExperienceEngine Pack Status",
871
- description: "Inspect whether a compiled Experience Pack target is missing, up to date, or drifted in a repository.",
435
+ }, async () => toStructuredToolResult(buildExperienceCapabilities()));
436
+ server.registerTool("experienceengine_explain_last_decision", {
437
+ title: "ExperienceEngine Explain Last Decision",
438
+ description: "Explain why the latest ExperienceEngine intervention matched or stayed quiet for the current workspace.",
872
439
  inputSchema: z.object({
873
- packId: z.string().min(1),
874
- version: z.string().optional(),
875
- target: z.enum(COMPILER_TARGETS),
876
- repoPath: z.string().min(1)
440
+ cwd: z.string().optional(),
441
+ userMessage: z.string().min(1)
877
442
  }),
878
443
  annotations: {
879
444
  readOnlyHint: true,
880
445
  openWorldHint: false
881
446
  }
882
- }, async ({ packId, version, target, repoPath }) => toStructuredToolResult(await interactionSurface.inspectPackDeploymentStatus({ packId, version, target, repoPath })));
883
- server.registerTool("experienceengine_pack_compile", {
884
- title: "ExperienceEngine Pack Compile",
885
- description: "Compile a published Experience Pack into a host-friendly artifact without deploying it.",
886
- inputSchema: z.object({
887
- packId: z.string().min(1),
888
- version: z.string().optional(),
889
- target: z.enum(COMPILER_TARGETS)
890
- })
891
- }, async ({ packId, version, target }) => toStructuredToolResult(await interactionSurface.compilePack({ packId, version, target })));
892
- server.registerTool("experienceengine_pack_deploy_preview", {
893
- title: "ExperienceEngine Pack Deploy Preview",
894
- description: "Preview where a compiled Experience Pack artifact would deploy and whether it would overwrite drifted content.",
895
- inputSchema: z.object({
896
- packId: z.string().min(1),
897
- version: z.string().optional(),
898
- target: z.enum(COMPILER_TARGETS),
899
- repoPath: z.string().min(1)
900
- })
901
- }, async ({ packId, version, target, repoPath }) => toStructuredToolResult(await interactionSurface.deployPackPreview({ packId, version, target, repoPath })));
902
- server.registerTool("experienceengine_get_repo_summary", {
903
- title: "ExperienceEngine Get Repo Summary",
904
- description: "Read the current repo-level ExperienceEngine summary for the active or specified cwd.",
905
- inputSchema: {
906
- cwd: z.string().optional()
907
- }
908
- }, async ({ cwd }) => toStructuredToolResult(await interactionSurface.inspectRepoSummary({ cwd })));
909
- server.registerTool("experienceengine_get_capabilities", {
910
- title: "ExperienceEngine Capabilities",
911
- description: "Read the current ExperienceEngine MCP capabilities, including direct tools, guarded flows, prompts, and CLI-only fallbacks.",
912
- inputSchema: z.object({}),
913
- annotations: {
914
- readOnlyHint: true,
915
- openWorldHint: false
916
- }
917
- }, async () => toStructuredToolResult(buildExperienceCapabilities()));
447
+ }, async ({ cwd, userMessage }) => toTextToolResult(await interactionSurface.explainLastDecision({ cwd, userMessage })));
918
448
  server.registerTool("experienceengine_lookup_hints", {
919
449
  title: "ExperienceEngine Lookup Hints",
920
- description: "Look up concise prior experience hints for the current coding task without assuming host lifecycle hooks.",
450
+ description: "Use once at task start for a real coding or debugging task to check whether ExperienceEngine has relevant prior guidance.",
921
451
  inputSchema: z.object({
922
452
  cwd: z.string().optional(),
923
453
  prompt: z.string().min(1),
924
454
  sessionId: z.string().optional()
925
455
  })
926
- }, async ({ cwd, prompt, sessionId }) => toTextToolResult(await behaviorLoop.lookupHints({ cwd, prompt, sessionId })));
456
+ }, async ({ cwd, prompt, sessionId }) => toNoticeAwareToolResult(await behaviorLoop.lookupHints({ cwd, prompt, sessionId })));
927
457
  server.registerTool("experienceengine_record_tool_result", {
928
458
  title: "ExperienceEngine Record Tool Result",
929
- description: "Record a Codex tool result into the active ExperienceEngine session before finalization.",
459
+ description: "Record only important tool outcomes that changed the task direction, especially notable shell, test, build, or edit results, before finalization.",
930
460
  inputSchema: z.object({
931
461
  sessionId: z.string().min(1),
932
462
  toolName: z.string().min(1),
@@ -939,31 +469,17 @@ export const createCodexMcpServer = (options = {}) => {
939
469
  }, async (args) => toTextToolResult(await behaviorLoop.recordToolResult(args)));
940
470
  server.registerTool("experienceengine_finalize_task", {
941
471
  title: "ExperienceEngine Finalize Task",
942
- description: "Finalize a Codex task after hint lookup and optional tool-result recording to persist outcomes and feedback.",
472
+ description: "Call at task end after hint lookup and any important tool-result recording to persist the learning loop outcome. Omit prompt when the task is unchanged from the earlier lookup in the same session.",
943
473
  inputSchema: z.object({
944
474
  sessionId: z.string().min(1),
945
475
  cwd: z.string().optional(),
946
- prompt: z.string().min(1),
476
+ prompt: z.string().min(1).optional(),
947
477
  contextSummary: z.string().optional()
948
478
  })
949
479
  }, async (args) => toTextToolResult(await behaviorLoop.finalizeTask(args)));
950
- server.registerTool("experienceengine_quick_feedback", {
951
- title: "ExperienceEngine Quick Feedback",
952
- description: "Record helped or harmed feedback for the last injected ExperienceEngine guidance using the shortest possible interaction path.",
953
- inputSchema: z.object({
954
- feedback: z.enum(["helped", "harmed"])
955
- }),
956
- outputSchema: z.object({
957
- status: z.enum(["updated", "not_found"]),
958
- feedback: z.enum(["helped", "harmed"]).optional(),
959
- nodeIds: z.array(z.string()).optional(),
960
- reason: z.enum(["last_injected_missing", "node_missing"]).optional(),
961
- nodeId: z.string().optional()
962
- })
963
- }, async ({ feedback }) => toStructuredToolResult(await interactionSurface.feedbackLast({ feedback })));
964
480
  server.registerTool("experienceengine_feedback_last", {
965
481
  title: "ExperienceEngine Feedback Last",
966
- description: "Record helped or harmed feedback for the last injected ExperienceEngine node set.",
482
+ description: "Record helped or harmed feedback after injected guidance for the last injected ExperienceEngine node set.",
967
483
  inputSchema: z.object({
968
484
  feedback: z.enum(["helped", "harmed"])
969
485
  }),
@@ -975,73 +491,6 @@ export const createCodexMcpServer = (options = {}) => {
975
491
  nodeId: z.string().optional()
976
492
  })
977
493
  }, async ({ feedback }) => toStructuredToolResult(await interactionSurface.feedbackLast({ feedback })));
978
- server.registerTool("experienceengine_feedback_node", {
979
- title: "ExperienceEngine Feedback Node",
980
- description: "Record helped or harmed feedback for a specific ExperienceEngine node.",
981
- inputSchema: z.object({
982
- nodeId: z.string().min(1),
983
- feedback: z.enum(["helped", "harmed"])
984
- }),
985
- outputSchema: z.object({
986
- status: z.enum(["updated", "not_found"]),
987
- feedback: z.enum(["helped", "harmed"]).optional(),
988
- nodeIds: z.array(z.string()).optional(),
989
- reason: z.enum(["last_injected_missing", "node_missing"]).optional(),
990
- nodeId: z.string().optional()
991
- })
992
- }, async ({ nodeId, feedback }) => toStructuredToolResult(await interactionSurface.feedbackNode({ nodeId, feedback })));
993
- server.registerTool("experienceengine_disable_scope", {
994
- title: "ExperienceEngine Disable Scope",
995
- description: "Disable ExperienceEngine interventions for the provided working directory scope.",
996
- inputSchema: z.object({
997
- cwd: z.string().optional()
998
- }),
999
- outputSchema: z.object({
1000
- scopeId: z.string(),
1001
- scopeName: z.string(),
1002
- rootPath: z.string().optional(),
1003
- isDisabled: z.boolean(),
1004
- changed: z.boolean()
1005
- })
1006
- }, async ({ cwd }) => toStructuredToolResult(await interactionSurface.disableScope({ cwd })));
1007
- server.registerTool("experienceengine_enable_scope", {
1008
- title: "ExperienceEngine Enable Scope",
1009
- description: "Enable ExperienceEngine interventions for the provided working directory scope.",
1010
- inputSchema: z.object({
1011
- cwd: z.string().optional()
1012
- }),
1013
- outputSchema: z.object({
1014
- scopeId: z.string(),
1015
- scopeName: z.string(),
1016
- rootPath: z.string().optional(),
1017
- isDisabled: z.boolean(),
1018
- changed: z.boolean()
1019
- })
1020
- }, async ({ cwd }) => toStructuredToolResult(await interactionSurface.enableScope({ cwd })));
1021
- server.registerTool("experienceengine_cool_node", {
1022
- title: "ExperienceEngine Cool Node",
1023
- description: "Move a specific ExperienceEngine node into cooling state.",
1024
- inputSchema: z.object({
1025
- nodeId: z.string().min(1)
1026
- }),
1027
- outputSchema: z.object({
1028
- status: z.enum(["updated", "not_found"]),
1029
- nodeId: z.string(),
1030
- state: z.enum(["candidate", "active", "cooling", "retired"]).optional()
1031
- })
1032
- }, async ({ nodeId }) => toStructuredToolResult(await interactionSurface.coolNode({ nodeId })));
1033
- server.registerTool("experienceengine_retire_node", {
1034
- title: "ExperienceEngine Retire Node",
1035
- description: "Retire a specific ExperienceEngine node so it is no longer injected.",
1036
- inputSchema: z.object({
1037
- nodeId: z.string().min(1)
1038
- }),
1039
- outputSchema: z.object({
1040
- status: z.enum(["updated", "not_found"]),
1041
- nodeId: z.string(),
1042
- state: z.enum(["candidate", "active", "cooling", "retired"]).optional()
1043
- })
1044
- }, async ({ nodeId }) => toStructuredToolResult(await interactionSurface.retireNode({ nodeId })));
1045
494
  return server;
1046
495
  };
1047
496
  export const runCodexMcpServer = async () => {