claude-smart 0.2.45 → 0.2.47

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 (353) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/README.md +47 -10
  3. package/bin/claude-smart.js +535 -23
  4. package/package.json +22 -3
  5. package/plugin/.claude-plugin/plugin.json +4 -2
  6. package/plugin/.codex-plugin/plugin.json +1 -1
  7. package/plugin/README.md +27 -6
  8. package/plugin/commands/clear-all.md +1 -0
  9. package/plugin/commands/dashboard.md +1 -0
  10. package/plugin/commands/learn.md +1 -0
  11. package/plugin/commands/restart.md +1 -0
  12. package/plugin/commands/show.md +1 -0
  13. package/plugin/dashboard/app/configure/env/page.tsx +40 -14
  14. package/plugin/dashboard/app/configure/server/page.tsx +51 -1
  15. package/plugin/dashboard/app/layout.tsx +20 -0
  16. package/plugin/dashboard/app/preferences/[id]/page.tsx +8 -8
  17. package/plugin/dashboard/app/skills/project/[id]/page.tsx +7 -3
  18. package/plugin/dashboard/app/skills/shared/[id]/page.tsx +10 -3
  19. package/plugin/dashboard/lib/claude-settings-file.ts +20 -10
  20. package/plugin/dashboard/lib/reflexio-client.ts +16 -0
  21. package/plugin/dashboard/lib/status.ts +10 -3
  22. package/plugin/dashboard/lib/types.ts +18 -6
  23. package/plugin/hooks/codex-hooks.json +0 -1
  24. package/plugin/opencode/assistant-buffer.ts +108 -0
  25. package/plugin/opencode/dist/assistant-buffer.js +96 -0
  26. package/plugin/opencode/dist/internal.js +12 -0
  27. package/plugin/opencode/dist/payload.js +85 -0
  28. package/plugin/opencode/dist/server.mjs +232 -0
  29. package/plugin/opencode/internal.ts +18 -0
  30. package/plugin/opencode/package.json +3 -0
  31. package/plugin/opencode/payload.ts +90 -0
  32. package/plugin/opencode/server.mts +251 -0
  33. package/plugin/opencode/tsconfig.json +13 -0
  34. package/plugin/pyproject.toml +25 -4
  35. package/plugin/scripts/_lib.sh +5 -1
  36. package/plugin/scripts/backend-service.sh +22 -2
  37. package/plugin/scripts/ensure-plugin-root.sh +4 -4
  38. package/plugin/scripts/hook_entry.sh +1 -1
  39. package/plugin/scripts/opencode-claude-compat +4 -0
  40. package/plugin/scripts/opencode-claude-compat.cmd +3 -0
  41. package/plugin/scripts/opencode-claude-compat.js +225 -0
  42. package/plugin/scripts/smart-install.sh +17 -9
  43. package/plugin/src/README.md +1 -1
  44. package/plugin/src/claude_smart/cli.py +498 -12
  45. package/plugin/src/claude_smart/context_format.py +9 -9
  46. package/plugin/src/claude_smart/cs_cite.py +66 -19
  47. package/plugin/src/claude_smart/env_config.py +12 -4
  48. package/plugin/src/claude_smart/events/session_start.py +26 -7
  49. package/plugin/src/claude_smart/events/stop.py +1 -1
  50. package/plugin/src/claude_smart/ids.py +1 -1
  51. package/plugin/src/claude_smart/reflexio_adapter.py +5 -5
  52. package/plugin/src/claude_smart/runtime.py +7 -1
  53. package/plugin/uv.lock +5 -5
  54. package/plugin/vendor/reflexio/.env.example +54 -30
  55. package/plugin/vendor/reflexio/README.md +17 -11
  56. package/plugin/vendor/reflexio/pyproject.toml +13 -1
  57. package/plugin/vendor/reflexio/reflexio/README.md +4 -1
  58. package/plugin/vendor/reflexio/reflexio/cli/README.md +9 -7
  59. package/plugin/vendor/reflexio/reflexio/cli/__main__.py +10 -1
  60. package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +22 -5
  61. package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +34 -4
  62. package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +12 -7
  63. package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +13 -6
  64. package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +212 -52
  65. package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +15 -2
  66. package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +292 -22
  67. package/plugin/vendor/reflexio/reflexio/cli/log_format.py +29 -4
  68. package/plugin/vendor/reflexio/reflexio/cli/run_services.py +17 -8
  69. package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +13 -10
  70. package/plugin/vendor/reflexio/reflexio/cli/utils.py +44 -1
  71. package/plugin/vendor/reflexio/reflexio/client/client.py +154 -13
  72. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +135 -257
  73. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/bin/openclaw-smart.js +13 -0
  74. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/package.json +15 -0
  75. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/README.md +38 -0
  76. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +151 -110
  77. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +20 -10
  78. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +28 -6
  79. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/pyproject.toml +42 -0
  80. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/_lib.sh +371 -0
  81. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-log-runner.sh +33 -0
  82. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-service.sh +271 -0
  83. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/cli.sh +68 -0
  84. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/dashboard-open.sh +15 -0
  85. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/ensure-plugin-root.sh +84 -0
  86. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/hook_entry.sh +106 -0
  87. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/npm-cli.js +219 -0
  88. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/smart-install.sh +269 -0
  89. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/clear-all/SKILL.md +8 -0
  90. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/dashboard/SKILL.md +8 -0
  91. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/learn/SKILL.md +10 -0
  92. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +15 -44
  93. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/restart/SKILL.md +6 -0
  94. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/show/SKILL.md +8 -0
  95. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/cli.py +634 -0
  96. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_format.py +224 -0
  97. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_inject.py +79 -0
  98. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/__init__.py +0 -0
  99. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/after_tool_call.py +160 -0
  100. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/agent_end.py +187 -0
  101. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_prompt_build.py +69 -0
  102. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_tool_call.py +30 -0
  103. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_end.py +36 -0
  104. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_start.py +130 -0
  105. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/hook.py +131 -0
  106. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/ids.py +94 -0
  107. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/internal_call.py +75 -0
  108. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/oc_cite.py +196 -0
  109. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/optimizer_assistant.py +272 -0
  110. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/publish.py +96 -0
  111. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/query_compose.py +66 -0
  112. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/reflexio_adapter.py +336 -0
  113. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/runtime.py +47 -0
  114. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/stall_banner.py +61 -0
  115. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/state.py +323 -0
  116. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/__init__.py +0 -0
  117. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/__init__.py +0 -0
  118. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_e2e_session_loop.py +190 -0
  119. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_publish_to_local_reflexio_integration.py +112 -0
  120. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_recursion_guard_integration.py +86 -0
  121. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_search_inject_integration.py +144 -0
  122. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_cli.py +184 -0
  123. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_after_tool_call.py +142 -0
  124. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_agent_end.py +233 -0
  125. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_prompt_build.py +116 -0
  126. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_tool_call.py +35 -0
  127. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_end.py +47 -0
  128. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_start.py +109 -0
  129. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_hook_dispatch.py +117 -0
  130. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_ids.py +41 -0
  131. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_internal_call.py +50 -0
  132. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_oc_cite.py +88 -0
  133. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_publish.py +48 -0
  134. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_query_compose.py +48 -0
  135. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_reflexio_adapter.py +188 -0
  136. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_runtime.py +41 -0
  137. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_state.py +235 -0
  138. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/__mocks__/plugin-entry-stub.ts +6 -0
  139. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_npm_cli.test.ts +56 -0
  140. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_shim_dispatch.test.ts +171 -0
  141. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tsconfig.build.json +18 -0
  142. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{tsconfig.json → plugin/tsconfig.json} +2 -2
  143. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/uv.lock +3835 -0
  144. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/vitest.config.ts +18 -0
  145. package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +246 -10
  146. package/plugin/vendor/reflexio/reflexio/lib/_base.py +15 -0
  147. package/plugin/vendor/reflexio/reflexio/lib/_config.py +11 -4
  148. package/plugin/vendor/reflexio/reflexio/lib/_generation.py +17 -5
  149. package/plugin/vendor/reflexio/reflexio/lib/_lineage_parity_readers.py +187 -0
  150. package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +224 -21
  151. package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +1 -1
  152. package/plugin/vendor/reflexio/reflexio/lib/_search.py +52 -25
  153. package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +11 -1
  154. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +1 -0
  155. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +127 -38
  156. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +4 -0
  157. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/governance.py +117 -0
  158. package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +64 -41
  159. package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +19 -0
  160. package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +12 -5
  161. package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +97 -3
  162. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +5 -1
  163. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +5 -1
  164. package/plugin/vendor/reflexio/reflexio/models/config_schema.py +104 -7
  165. package/plugin/vendor/reflexio/reflexio/models/structured_output.py +148 -0
  166. package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +3 -3
  167. package/plugin/vendor/reflexio/reflexio/server/README.md +58 -33
  168. package/plugin/vendor/reflexio/reflexio/server/__init__.py +29 -5
  169. package/plugin/vendor/reflexio/reflexio/server/__main__.py +2 -2
  170. package/plugin/vendor/reflexio/reflexio/server/api.py +899 -103
  171. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +7 -0
  172. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +4 -2
  173. package/plugin/vendor/reflexio/reflexio/server/auth.py +90 -0
  174. package/plugin/vendor/reflexio/reflexio/server/billing_meter.py +173 -0
  175. package/plugin/vendor/reflexio/reflexio/server/billing_signals.py +64 -0
  176. package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +46 -16
  177. package/plugin/vendor/reflexio/reflexio/server/env_utils.py +65 -0
  178. package/plugin/vendor/reflexio/reflexio/server/extensions.py +213 -0
  179. package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +19 -4
  180. package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +264 -77
  181. package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +69 -7
  182. package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +4 -4
  183. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1 -1
  184. package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +75 -16
  185. package/plugin/vendor/reflexio/reflexio/server/llm/providers/openclaw_provider.py +280 -0
  186. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +12 -1
  187. package/plugin/vendor/reflexio/reflexio/server/llm/token_accounting.py +48 -0
  188. package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +107 -17
  189. package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +360 -4
  190. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +1 -1
  191. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.7.0.prompt.md +85 -0
  192. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +1 -1
  193. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.3.0.prompt.md +253 -0
  194. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +1 -1
  195. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.3.prompt.md +74 -0
  196. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +1 -1
  197. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.3.0.prompt.md +266 -0
  198. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.4.0.prompt.md +278 -0
  199. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +1 -1
  200. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.4.0.prompt.md +137 -0
  201. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +1 -1
  202. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.3.0.prompt.md +34 -0
  203. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +5 -12
  204. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +5 -12
  205. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.2.0.prompt.md +155 -0
  206. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/tagging/v1.0.0.prompt.md +23 -0
  207. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +89 -32
  208. package/plugin/vendor/reflexio/reflexio/server/services/README.md +28 -11
  209. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/README.md +22 -0
  210. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/__init__.py +1 -0
  211. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +4 -2
  212. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +1 -0
  213. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/components/__init__.py +7 -0
  214. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluator.py → components/evaluator.py} +3 -16
  215. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +28 -72
  216. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{group_evaluation_runner.py → runner.py} +12 -10
  217. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{delayed_group_evaluator.py → scheduler.py} +10 -2
  218. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluation_service.py → service.py} +36 -1
  219. package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +160 -0
  220. package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +5 -0
  221. package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +1 -1
  222. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/README.md +9 -0
  223. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/components/__init__.py +0 -0
  224. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{rule_attribution.py → components/rule_attribution.py} +10 -9
  225. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +15 -24
  226. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +238 -164
  227. package/plugin/vendor/reflexio/reflexio/server/services/extraction/README.md +31 -0
  228. package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +13 -3
  229. package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +3 -2
  230. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +32 -118
  231. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +47 -16
  232. package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +105 -23
  233. package/plugin/vendor/reflexio/reflexio/server/services/governance/config.py +52 -0
  234. package/plugin/vendor/reflexio/reflexio/server/services/governance/service.py +378 -0
  235. package/plugin/vendor/reflexio/reflexio/server/services/governance/subject_refs.py +34 -0
  236. package/plugin/vendor/reflexio/reflexio/server/services/lineage/__init__.py +0 -0
  237. package/plugin/vendor/reflexio/reflexio/server/services/lineage/gc_scheduler.py +219 -0
  238. package/plugin/vendor/reflexio/reflexio/server/services/lineage/resolve.py +98 -0
  239. package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +26 -0
  240. package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +18 -11
  241. package/plugin/vendor/reflexio/reflexio/server/services/playbook/aggregation_prompt_processing.py +100 -0
  242. package/plugin/vendor/reflexio/reflexio/server/services/playbook/components/__init__.py +5 -0
  243. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_aggregator.py → components/aggregator.py} +334 -178
  244. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_consolidator.py → components/consolidator.py} +168 -62
  245. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_extractor.py → components/extractor.py} +5 -1
  246. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_edit_apply.py +74 -0
  247. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +33 -3
  248. package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_generation_service.py → service.py} +121 -19
  249. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/README.md +10 -0
  250. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +2 -1
  251. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +178 -30
  252. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/README.md +9 -0
  253. package/plugin/vendor/reflexio/reflexio/server/services/profile/components/__init__.py +17 -0
  254. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_deduplicator.py → components/consolidator.py} +7 -6
  255. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_extractor.py → components/extractor.py} +31 -22
  256. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +6 -13
  257. package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_generation_service.py → service.py} +32 -50
  258. package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +4 -8
  259. package/plugin/vendor/reflexio/reflexio/server/services/reflection/components/__init__.py +7 -0
  260. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +12 -1
  261. package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_service.py → service.py} +36 -16
  262. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/recency.py +211 -0
  263. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +99 -6
  264. package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +36 -1
  265. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/README.md +8 -0
  266. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +1 -2
  267. package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +31 -0
  268. package/plugin/vendor/reflexio/reflexio/server/services/storage/governance_validation.py +681 -0
  269. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +9 -9
  270. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +16 -2
  271. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +4 -1
  272. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +644 -197
  273. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +106 -119
  274. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_governance.py +1965 -0
  275. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_lineage.py +630 -0
  276. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +38 -6
  277. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +31 -1369
  278. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +756 -210
  279. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +148 -34
  280. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +23 -9
  281. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +5 -2
  282. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/__init__.py +13 -0
  283. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_agent.py +952 -0
  284. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_eval_results.py +189 -0
  285. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_optimization.py +247 -0
  286. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_source_linkage.py +145 -0
  287. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_user.py +838 -0
  288. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +150 -23
  289. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +2 -8
  290. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +5 -0
  291. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +40 -57
  292. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_governance.py +148 -0
  293. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_lineage.py +215 -0
  294. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +20 -0
  295. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +4 -677
  296. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +134 -1
  297. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +62 -0
  298. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_retrieval_log.py +51 -0
  299. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +17 -0
  300. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/__init__.py +13 -0
  301. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_agent.py +365 -0
  302. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_eval_results.py +124 -0
  303. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_optimization.py +85 -0
  304. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_source_linkage.py +47 -0
  305. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_user.py +333 -0
  306. package/plugin/vendor/reflexio/reflexio/server/services/tagging/README.md +8 -0
  307. package/plugin/vendor/reflexio/reflexio/server/services/tagging/__init__.py +1 -0
  308. package/plugin/vendor/reflexio/reflexio/server/services/tagging/service.py +200 -0
  309. package/plugin/vendor/reflexio/reflexio/server/services/tagging/tagging_scheduler.py +149 -0
  310. package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +372 -34
  311. package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +2 -1
  312. package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +120 -1
  313. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +4 -0
  314. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/search_settings.json +5 -0
  315. package/plugin/vendor/reflexio/reflexio/server/tracing.py +30 -0
  316. package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +18 -0
  317. package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +61 -26
  318. package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +41 -4
  319. package/scripts/setup-claude-smart.sh +8 -3
  320. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +0 -517
  321. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +0 -473
  322. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +0 -2156
  323. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +0 -18
  324. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +0 -241
  325. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +0 -140
  326. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +0 -113
  327. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +0 -52
  328. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +0 -103
  329. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +0 -156
  330. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +0 -134
  331. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +0 -24
  332. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +0 -278
  333. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +0 -164
  334. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +0 -36
  335. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +0 -35
  336. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +0 -27
  337. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +0 -31
  338. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +0 -42
  339. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +0 -49
  340. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +0 -91
  341. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +0 -50
  342. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +0 -13
  343. package/plugin/vendor/reflexio/reflexio/server/_auth.py +0 -25
  344. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +0 -192
  345. package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +0 -303
  346. package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +0 -138
  347. package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +0 -1125
  348. /package/plugin/vendor/reflexio/reflexio/integrations/{__init__.py → openclaw/plugin/src/openclaw_smart/__init__.py} +0 -0
  349. /package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{types → plugin/types}/openclaw.d.ts +0 -0
  350. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{distribution.py → components/distribution.py} +0 -0
  351. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{hero_state.py → components/hero_state.py} +0 -0
  352. /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{shadow_aggregation.py → components/shadow_aggregation.py} +0 -0
  353. /package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_extractor.py → components/extractor.py} +0 -0
@@ -1,156 +0,0 @@
1
- // SQLite session buffer — persistent, crash-safe conversation store.
2
- import Database from "better-sqlite3";
3
- import * as fs from "node:fs";
4
- import * as path from "node:path";
5
-
6
- const MAX_CONTENT_LENGTH = 10_000;
7
-
8
- export interface Turn {
9
- id: number;
10
- session_id: string;
11
- role: string;
12
- content: string;
13
- timestamp: string;
14
- published: number;
15
- retry_count: number;
16
- }
17
-
18
- /** Smart truncation: preserve head + tail with marker, guaranteed <= maxLength. */
19
- export function smartTruncate(
20
- content: string,
21
- maxLength: number = MAX_CONTENT_LENGTH,
22
- ): string {
23
- if (!content || content.length <= maxLength) return content || "";
24
- // Use a fixed-width marker estimate to break the circular dependency
25
- // between marker length and truncated count.
26
- const markerTemplate = "\n\n[...truncated NNNNNNN chars...]\n\n"; // ~38 chars
27
- const budget = maxLength - markerTemplate.length;
28
- if (budget <= 0) return content.slice(0, maxLength);
29
- const headLen = Math.floor(budget * 0.8);
30
- const tailLen = budget - headLen;
31
- const truncated = content.length - headLen - tailLen;
32
- const marker = `\n\n[...truncated ${truncated} chars...]\n\n`;
33
- const result =
34
- tailLen <= 0
35
- ? content.slice(0, headLen) + marker
36
- : content.slice(0, headLen) + marker + content.slice(-tailLen);
37
- // Final safety clamp for edge cases (very large truncated counts exceeding reserved marker width)
38
- return result.length <= maxLength ? result : result.slice(0, maxLength);
39
- }
40
-
41
- /** Open (or create) the SQLite database and ensure schema exists. */
42
- export function openDb(dbPath: string): Database.Database {
43
- fs.mkdirSync(path.dirname(dbPath), { recursive: true, mode: 0o700 });
44
- const db = new Database(dbPath);
45
- db.pragma("journal_mode = WAL");
46
- db.exec(`
47
- CREATE TABLE IF NOT EXISTS turns (
48
- id INTEGER PRIMARY KEY AUTOINCREMENT,
49
- session_id TEXT NOT NULL,
50
- role TEXT NOT NULL,
51
- content TEXT NOT NULL,
52
- timestamp TEXT NOT NULL,
53
- published INTEGER DEFAULT 0,
54
- retry_count INTEGER DEFAULT 0
55
- );
56
- CREATE INDEX IF NOT EXISTS idx_session_published
57
- ON turns(session_id, published);
58
- `);
59
- try {
60
- db.exec("ALTER TABLE turns ADD COLUMN retry_count INTEGER DEFAULT 0");
61
- } catch {
62
- // Column already exists
63
- }
64
- return db;
65
- }
66
-
67
- /** Insert a single turn into the buffer. */
68
- export function insertTurn(
69
- db: Database.Database,
70
- sessionId: string,
71
- role: string,
72
- content: string,
73
- maxContentLength: number = MAX_CONTENT_LENGTH,
74
- ): void {
75
- const truncated = smartTruncate(content, maxContentLength);
76
- const now = new Date().toISOString();
77
- db.prepare(
78
- "INSERT INTO turns (session_id, role, content, timestamp) VALUES (?, ?, ?, ?)",
79
- ).run(sessionId, role, truncated, now);
80
- }
81
-
82
- /** Get unpublished turns for a session, respecting retry limit. */
83
- export function getUnpublished(
84
- db: Database.Database,
85
- sessionId: string,
86
- maxRetries: number,
87
- maxInteractions: number,
88
- ): Turn[] {
89
- return db
90
- .prepare(
91
- "SELECT * FROM turns WHERE session_id = ? AND published = 0 AND retry_count < ? ORDER BY id LIMIT ?",
92
- )
93
- .all(sessionId, maxRetries, maxInteractions) as Turn[];
94
- }
95
-
96
- /** Get distinct session IDs with unpublished turns (excluding current session). */
97
- export function getOldUnpublishedSessions(
98
- db: Database.Database,
99
- currentSessionId: string,
100
- maxRetries: number,
101
- limit: number,
102
- ): string[] {
103
- const rows = db
104
- .prepare(
105
- "SELECT session_id FROM turns WHERE published = 0 AND retry_count < ? AND session_id != ? GROUP BY session_id ORDER BY MIN(id) LIMIT ?",
106
- )
107
- .all(maxRetries, currentSessionId, limit) as { session_id: string }[];
108
- return rows.map((r) => r.session_id);
109
- }
110
-
111
- /** Count unpublished turns for a session. */
112
- export function countUnpublished(
113
- db: Database.Database,
114
- sessionId: string,
115
- ): number {
116
- const row = db
117
- .prepare(
118
- "SELECT COUNT(*) as count FROM turns WHERE session_id = ? AND published = 0",
119
- )
120
- .get(sessionId) as { count: number };
121
- return row.count;
122
- }
123
-
124
- /** Mark turns as in-flight (published=2) to prevent concurrent publish. */
125
- export function markInFlight(
126
- db: Database.Database,
127
- sessionId: string,
128
- maxId: number,
129
- maxRetries: number,
130
- ): void {
131
- db.prepare(
132
- "UPDATE turns SET published = 2 WHERE session_id = ? AND published = 0 AND retry_count < ? AND id <= ?",
133
- ).run(sessionId, maxRetries, maxId);
134
- }
135
-
136
- /** Mark in-flight turns as successfully published (scoped to batch). */
137
- export function markPublished(db: Database.Database, sessionId: string, maxId: number): void {
138
- db.prepare(
139
- "UPDATE turns SET published = 1 WHERE session_id = ? AND published = 2 AND id <= ?",
140
- ).run(sessionId, maxId);
141
- }
142
-
143
- /** Reset in-flight turns back to unpublished and increment retry count (scoped to batch). */
144
- export function markFailed(db: Database.Database, sessionId: string, maxId: number): void {
145
- db.prepare(
146
- "UPDATE turns SET published = 0, retry_count = retry_count + 1 WHERE session_id = ? AND published = 2 AND id <= ?",
147
- ).run(sessionId, maxId);
148
- }
149
-
150
- /** Delete published turns older than the given number of days. */
151
- export function cleanupOldTurns(db: Database.Database, days: number = 7): void {
152
- const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
153
- db.prepare(
154
- "DELETE FROM turns WHERE published = 1 AND timestamp < ?",
155
- ).run(cutoff);
156
- }
@@ -1,134 +0,0 @@
1
- // Multi-user identity resolution.
2
- //
3
- // Each Openclaw agent instance maps to a distinct Reflexio user.
4
- // Resolution chain: env var > session key agentId > openclaw.json > fallback.
5
- import * as fs from "node:fs";
6
- import * as os from "node:os";
7
- import * as path from "node:path";
8
-
9
- let _openclawConfig: Record<string, unknown> | null = null;
10
-
11
- /** Strip JSON5 line and block comments while respecting quoted strings. */
12
- export function stripJsonComments(raw: string): string {
13
- const result: string[] = [];
14
- let inBlockComment = false;
15
- for (const line of raw.split("\n")) {
16
- let out = "";
17
- let inString = false;
18
- let escape = false;
19
- let i = 0;
20
- while (i < line.length) {
21
- const ch = line[i];
22
- if (inBlockComment) {
23
- // Look for end of block comment
24
- if (ch === "*" && line[i + 1] === "/") {
25
- inBlockComment = false;
26
- i += 2;
27
- } else {
28
- i++;
29
- }
30
- continue;
31
- }
32
- if (escape) {
33
- escape = false;
34
- out += ch;
35
- i++;
36
- continue;
37
- }
38
- if (inString) {
39
- if (ch === "\\") {
40
- escape = true;
41
- out += ch;
42
- i++;
43
- continue;
44
- }
45
- if (ch === '"') {
46
- inString = false;
47
- out += ch;
48
- i++;
49
- continue;
50
- }
51
- out += ch;
52
- i++;
53
- continue;
54
- }
55
- // Outside string
56
- if (ch === '"') {
57
- inString = true;
58
- out += ch;
59
- i++;
60
- continue;
61
- }
62
- if (ch === "/" && line[i + 1] === "/") {
63
- // Line comment — rest of line is comment
64
- break;
65
- }
66
- if (ch === "/" && line[i + 1] === "*") {
67
- // Block comment start
68
- inBlockComment = true;
69
- i += 2;
70
- continue;
71
- }
72
- out += ch;
73
- i++;
74
- }
75
- result.push(out);
76
- }
77
- return result.join("\n");
78
- }
79
-
80
- /** Read and cache ~/.openclaw/openclaw.json (JSON5 — strip comments before parsing). */
81
- function loadOpenclawConfig(): Record<string, unknown> {
82
- if (_openclawConfig !== null) return _openclawConfig;
83
- try {
84
- const configPath = path.join(os.homedir(), ".openclaw", "openclaw.json");
85
- const raw = fs.readFileSync(configPath, "utf-8");
86
- const stripped = stripJsonComments(raw);
87
- _openclawConfig = JSON.parse(stripped);
88
- } catch {
89
- _openclawConfig = {};
90
- }
91
- return _openclawConfig!;
92
- }
93
-
94
- /**
95
- * Resolve the Reflexio user ID.
96
- *
97
- * @param sessionKey - The Openclaw session key from hook context.
98
- * @returns The resolved user ID string.
99
- */
100
- export function resolveUserId(sessionKey: string): string {
101
- // 1. Explicit env override
102
- if (process.env.REFLEXIO_USER_ID) return process.env.REFLEXIO_USER_ID;
103
-
104
- // 2. Extract agentId from session key (format: agent:<agentId>:<key>)
105
- const sessionMatch = sessionKey.match(/^agent:([^:]+):/);
106
- if (sessionMatch) return sessionMatch[1];
107
-
108
- // 3. Read openclaw.json
109
- const config = loadOpenclawConfig();
110
- const agents = config.agents as Record<string, unknown> | undefined;
111
- if (agents) {
112
- if (typeof agents.defaults === "string") return agents.defaults;
113
- if (Array.isArray(agents.list) && agents.list.length > 0) {
114
- const first = agents.list[0];
115
- if (first && typeof first === "object" && (first as Record<string, unknown>).name) {
116
- return (first as Record<string, unknown>).name as string;
117
- }
118
- if (typeof first === "string") return first;
119
- }
120
- }
121
-
122
- // 4. Fallback
123
- return "openclaw";
124
- }
125
-
126
- /** Resolve the agent version label. */
127
- export function resolveAgentVersion(): string {
128
- return process.env.REFLEXIO_AGENT_VERSION || "openclaw-agent";
129
- }
130
-
131
- /** Reset cached state — for testing only. */
132
- export function _resetCache(): void {
133
- _openclawConfig = null;
134
- }
@@ -1,24 +0,0 @@
1
- # Reflexio: Cross-Session Memory
2
-
3
- This agent uses Reflexio to remember corrections and preferences across sessions.
4
-
5
- ## How It Works
6
-
7
- A `before_prompt_build` hook automatically runs `reflexio search` on every message you receive. When relevant corrections or preferences exist, they are injected as context before your response.
8
-
9
- ## What You MUST Do
10
-
11
- 1. **When you see injected Reflexio context** — read it carefully and follow every instruction. Behavior Corrections tell you what to do differently. User Preferences tell you how the user works. Agent Playbooks are shared corrections from all instances.
12
-
13
- 2. **If no Reflexio context appears for a substantive task request** — run a manual search. Skip this for short or trivial messages (greetings, one-word replies, yes/no responses):
14
- ```
15
- reflexio search "<the user's task or request>"
16
- ```
17
-
18
- 3. **After user corrections** — once confirmed, call the `reflexio_publish` tool to flush the conversation to Reflexio immediately.
19
-
20
- 4. **Never mention Reflexio to the user** unless they ask about it. It should be invisible.
21
-
22
- 5. **If Reflexio is unavailable, proceed normally** — it enhances but never blocks your work. Never degrade the core agent experience because of Reflexio issues.
23
-
24
- 6. **Never ask the user to manage the Reflexio server** — infrastructure is the plugin's responsibility.
@@ -1,278 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Publishes the reflexio openclaw integration as a single ClawHub skill.
3
- #
4
- # Two modes:
5
- # 1) CLI publish — stages into a temp dir, generates top-level SKILL.md,
6
- # runs `bun clawhub skill publish`. Requires bun + an authed session.
7
- # 2) Stage-only — same staging + SKILL.md generation, but skips publish
8
- # and prints the staged path so you can drop it onto the web form at
9
- # https://clawhub.ai/publish-skill.
10
- #
11
- # Usage:
12
- # ./publish_clawhub.sh <semver> [changelog] # CLI publish
13
- # ./publish_clawhub.sh --stage-only # produce folder for web upload
14
- #
15
- # Prereqs:
16
- # - CLI mode: `bun clawhub login` done, `bun` on PATH
17
- # - Stage-only mode: just `rsync` and `python3` on PATH
18
-
19
- set -euo pipefail
20
-
21
- STAGE_ONLY=0
22
- if [[ "${1:-}" == "--stage-only" ]]; then
23
- STAGE_ONLY=1
24
- VERSION="0.0.0-staged"
25
- CHANGELOG=""
26
- else
27
- VERSION="${1:?usage: publish_clawhub.sh <semver> [changelog] | --stage-only}"
28
- if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.-]+)?$ ]]; then
29
- echo "error: version must be semver (got: $VERSION)" >&2
30
- exit 1
31
- fi
32
- CHANGELOG="${2:-Release $VERSION}"
33
- fi
34
-
35
- SRC="$(cd "$(dirname "$0")" && pwd)"
36
- STAGE="$(mktemp -d -t reflexio-clawhub-XXXXXX)"
37
- if (( STAGE_ONLY == 0 )); then
38
- trap 'rm -rf "$STAGE"' EXIT
39
- fi
40
-
41
- if (( STAGE_ONLY == 0 )); then
42
- if ! command -v bun >/dev/null 2>&1; then
43
- echo "error: bun not found on PATH (install from https://bun.sh)" >&2
44
- exit 1
45
- fi
46
-
47
- if ! bun clawhub whoami >/dev/null 2>&1; then
48
- echo "error: not logged in to clawhub. run: bun clawhub login" >&2
49
- exit 1
50
- fi
51
- fi
52
-
53
- echo "staging bundle → $STAGE"
54
- # Prune everything that shouldn't be in the published bundle. The web
55
- # uploader at clawhub.ai/publish-skill does NOT read .clawhubignore
56
- # (that's a CLI-only feature), so we pre-filter here and the same stage
57
- # dir works for both CLI publish and web drag-drop.
58
- rsync -a \
59
- --exclude='node_modules/' \
60
- --exclude='package-lock.json' \
61
- --exclude='.DS_Store' \
62
- --exclude='eval/' \
63
- --exclude='TESTING.md' \
64
- --exclude='publish_clawhub.sh' \
65
- --exclude='.clawhubignore' \
66
- "$SRC"/ "$STAGE"/
67
-
68
- echo "generating top-level SKILL.md from skill/SKILL.md"
69
- python3 - "$STAGE" <<'PY'
70
- import re
71
- import sys
72
- from pathlib import Path
73
-
74
- stage = Path(sys.argv[1])
75
- src_skill = stage / "skill" / "SKILL.md"
76
- body = src_skill.read_text()
77
-
78
- m = re.match(r"^---\n(.*?)\n---\n(.*)$", body, re.DOTALL)
79
- if not m:
80
- sys.exit(f"error: {src_skill} has no YAML frontmatter")
81
- orig_frontmatter, orig_body = m.group(1), m.group(2)
82
-
83
- # Pull the original description verbatim (multi-line safe).
84
- desc_match = re.search(
85
- r'^description:\s*"((?:[^"\\]|\\.)*)"', orig_frontmatter, re.MULTILINE
86
- )
87
- if not desc_match:
88
- sys.exit("error: could not find description in skill/SKILL.md frontmatter")
89
- description = desc_match.group(1)
90
-
91
- frontmatter = (
92
- "---\n"
93
- "name: reflexio\n"
94
- f'description: "{description}"\n'
95
- "metadata:\n"
96
- " openclaw:\n"
97
- " homepage: https://github.com/reflexio-ai/reflexio/tree/main/reflexio/integrations/openclaw\n"
98
- " emoji: 🧠\n"
99
- " requires:\n"
100
- " bins: [reflexio]\n"
101
- "---\n"
102
- )
103
-
104
- privacy = """
105
- ## Privacy & Data Collection — Read This First
106
-
107
- **This skill causes the agent to automatically capture conversations and
108
- forward them to a local Reflexio server for LLM-based extraction.** Read this
109
- before enabling — there are two distinct network hops and you need to
110
- understand both.
111
-
112
- ### Credential requirement (not declared in skill metadata)
113
-
114
- The skill's registry metadata declares no required environment variables and
115
- the hook reads none. **But the end-to-end system does require an LLM provider
116
- API key**, and you WILL be asked for one during First-Use Setup.
117
-
118
- - Step 2 of First-Use Setup below runs `reflexio setup openclaw`, which opens
119
- an **interactive wizard** prompting you to choose an LLM provider (OpenAI,
120
- Anthropic, Gemini, DeepSeek, OpenRouter, and several others) and paste an
121
- API key.
122
- - The key is stored in `~/.reflexio/.env` and read by the local Reflexio
123
- server during extraction. **The hook itself never reads the key** (the hook
124
- has no environment variable access and no filesystem config reads — both
125
- enforced in `handler.js`).
126
- - If you want fully offline operation, point the wizard at a local LLM
127
- (Ollama at `http://127.0.0.1:11434`, LM Studio, vLLM, etc.) instead of a
128
- hosted provider — the wizard accepts any LiteLLM-compatible base URL.
129
-
130
- **Why the metadata doesn't declare it:** ClawHub's `metadata.openclaw.requires.env`
131
- describes environment variables the hook's own code path reads. The hook is
132
- deliberately stateless at the credential level, so listing anything there
133
- would be inaccurate. The dependency is at the *backend server* level, one
134
- hop away. This disclosure is here instead of in the metadata because prose
135
- is the right place to explain the distinction.
136
-
137
- ### Network hops — two of them
138
-
139
- **Hop 1: the hook → the local Reflexio server (always localhost).**
140
- The hook is hard-pinned to `http://127.0.0.1:8081`. It communicates via native
141
- `fetch()` with no configuration knobs; the destination is a hardcoded constant
142
- in `handler.js`. It reads zero environment variables and zero configuration
143
- files. This hop cannot leave your machine.
144
-
145
- **Hop 2: the local Reflexio server → an LLM provider (may leave your
146
- machine).** The server uses an LLM provider (OpenAI, Anthropic, Gemini,
147
- DeepSeek, etc.) to extract playbooks and profiles from captured conversations.
148
- That provider is configured in `~/.reflexio/.env`. **If you configured an
149
- external provider, excerpts of your conversations will be sent to that
150
- provider** as part of extraction — trigger text, sample content, and enough
151
- context for the extractor to produce a useful summary. The primary full
152
- conversation text stays in your local SQLite database at `~/.reflexio/`, but
153
- the extracted summaries and illustrative excerpts traverse whatever the LLM
154
- provider's network path is.
155
-
156
- **If you want fully offline operation**, configure the local server to use a
157
- local LLM (Ollama, LM Studio, vLLM, etc.) before enabling this skill. Do not
158
- rely on the hook's localhost pinning as a privacy guarantee for the system as
159
- a whole — that only bounds the hook, not the server behind it.
160
-
161
- **What is captured:** full user and assistant messages; every tool call, input,
162
- and output (including failed tool calls and exact error strings); self-correction
163
- text from the assistant's own output. None of this is scrubbed for PII,
164
- credentials, file paths, or API outputs. If you work on sensitive tasks,
165
- disable the hook before starting them, or tell the agent mid-task.
166
-
167
- **How to disable:**
168
-
169
- - Per-session, stop automatic capture: `openclaw hooks disable reflexio-context`
170
- - Remove the integration entirely: `reflexio setup openclaw --uninstall`
171
- - Search-only mode (keep retrieval, drop auto-publish): edit `hook/handler.js`,
172
- remove the `command:stop` handler, and reinstall
173
- - Sensitive task: tell the agent "don't log this" — the workspace rule instructs
174
- it to stop all capture and search calls for the rest of the session
175
-
176
- **Transparency contract:** the agent is instructed to tell you Reflexio is
177
- active on the first turn of each session, disclose what is captured AND
178
- mention that the local server may forward excerpts to an LLM provider, and
179
- honor session-level opt-outs. This is enforced by
180
- `~/.openclaw/workspace/reflexio.md`. Edit that file if your deployment needs
181
- different rules (require explicit approval before every publish, offline-only,
182
- etc).
183
-
184
- Full data-handling details live in the **Privacy & Data Collection** section
185
- further down in this SKILL.md.
186
-
187
- ---
188
-
189
- """
190
-
191
- first_use = """
192
- ## First-Use Setup
193
-
194
- Run these commands the first time this skill is invoked. They are idempotent —
195
- skip if `reflexio` is already on PATH, the local Reflexio server is responding
196
- at `http://127.0.0.1:8081/health`, and `openclaw hooks list` shows
197
- `reflexio-context` as `ready`. **Only run them after reading the privacy
198
- disclosure above, and be aware that step 2 is interactive — it will prompt
199
- you to pick an LLM provider and paste an API key for the local server's
200
- extraction pipeline.**
201
-
202
- ```bash
203
- # 1. Install the reflexio CLI (pipx preferred; pip as fallback).
204
- command -v reflexio >/dev/null 2>&1 \\
205
- || pipx install reflexio-ai 2>/dev/null \\
206
- || pip install --user reflexio-ai
207
-
208
- # 2. INTERACTIVE: activates the hook, slash commands, and workspace rule in
209
- # OpenClaw. Also prompts you to choose an LLM provider and paste an API key,
210
- # which gets written to ~/.reflexio/.env. That key is what the local server
211
- # uses to extract playbooks from captured conversations. Point at a local LLM
212
- # (Ollama / LM Studio / vLLM) here if you want fully offline operation.
213
- # Before running this, tell the user what will be asked and why.
214
- reflexio setup openclaw
215
-
216
- # 3. Start the local Reflexio backend in the background. The hook talks to
217
- # this server via HTTP on 127.0.0.1:8081 — it will NOT start the server for
218
- # you. Tell the user you are doing this before running it.
219
- curl -sf --max-time 2 http://127.0.0.1:8081/health >/dev/null 2>&1 \\
220
- || (nohup reflexio services start --only backend --no-reload \\
221
- >> ~/.reflexio/logs/server.log 2>&1 & \\
222
- sleep 5)
223
- ```
224
-
225
- This installs:
226
-
227
- - `reflexio-context` hook — HTTP-only capture + per-message playbook
228
- injection (communicates only with `http://127.0.0.1:8081`)
229
- - `/reflexio-extract` slash command — publish session learnings mid-session
230
- - `/reflexio-aggregate` slash command — consolidate user playbooks into
231
- shared agent playbooks
232
- - `~/.openclaw/workspace/reflexio.md` — always-active behavioral rule
233
- (transparency + opt-out handling)
234
-
235
- If the local server is unreachable, the hook logs the error and the agent
236
- continues the user's task without Reflexio context that session.
237
-
238
- ---
239
-
240
- """
241
-
242
- (stage / "SKILL.md").write_text(frontmatter + privacy + first_use + orig_body)
243
- print(f"wrote {stage / 'SKILL.md'}")
244
- PY
245
-
246
- if (( STAGE_ONLY == 1 )); then
247
- cat <<EOF
248
-
249
- ─────────────────────────────────────────────────────────────
250
- Stage ready. Upload via web at https://clawhub.ai/publish-skill
251
-
252
- Drag this folder onto the drop zone:
253
- $STAGE
254
-
255
- Form values to use:
256
- Slug: reflexio
257
- Display name: Reflexio
258
- Version: <pick a semver, e.g. 1.0.0>
259
- Tags: latest
260
- Changelog: Initial release
261
-
262
- When done, delete the temp folder: rm -rf $STAGE
263
- ─────────────────────────────────────────────────────────────
264
- EOF
265
- exit 0
266
- fi
267
-
268
- echo "publishing to clawhub: slug=reflexio version=$VERSION"
269
- (
270
- cd "$STAGE"
271
- bun clawhub skill publish . \
272
- --slug reflexio \
273
- --version "$VERSION" \
274
- --tags latest \
275
- --changelog "$CHANGELOG"
276
- )
277
-
278
- echo "done. verify at https://clawhub.ai/skill/reflexio"