claude-smart 0.2.42 → 0.2.44

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 (402) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/README.md +1 -1
  3. package/bin/claude-smart.js +2 -2
  4. package/package.json +9 -3
  5. package/plugin/.claude-plugin/plugin.json +9 -3
  6. package/plugin/.codex-plugin/plugin.json +1 -1
  7. package/plugin/README.md +23 -3
  8. package/plugin/pyproject.toml +3 -3
  9. package/plugin/scripts/_lib.sh +91 -0
  10. package/plugin/scripts/backend-service.sh +51 -4
  11. package/plugin/scripts/cli.sh +3 -1
  12. package/plugin/scripts/codex-hook.js +72 -4
  13. package/plugin/scripts/dashboard-build.sh +1 -0
  14. package/plugin/scripts/dashboard-service.sh +1 -0
  15. package/plugin/scripts/ensure-plugin-root.sh +1 -0
  16. package/plugin/scripts/hook_entry.sh +6 -3
  17. package/plugin/scripts/smart-install.sh +3 -2
  18. package/plugin/src/README.md +57 -0
  19. package/plugin/src/claude_smart/context_format.py +11 -12
  20. package/plugin/src/claude_smart/cs_cite.py +26 -12
  21. package/plugin/src/claude_smart/ids.py +13 -5
  22. package/plugin/uv.lock +126 -5
  23. package/plugin/vendor/reflexio/.env.example +62 -0
  24. package/plugin/vendor/reflexio/LICENSE +201 -0
  25. package/plugin/vendor/reflexio/README.md +338 -0
  26. package/plugin/vendor/reflexio/pyproject.toml +274 -0
  27. package/plugin/vendor/reflexio/reflexio/README.md +184 -0
  28. package/plugin/vendor/reflexio/reflexio/__init__.py +166 -0
  29. package/plugin/vendor/reflexio/reflexio/benchmarks/__init__.py +1 -0
  30. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/README.md +109 -0
  31. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/__init__.py +1 -0
  32. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/backends.py +175 -0
  33. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/bench.py +642 -0
  34. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/embed_cache.py +330 -0
  35. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/report.py +317 -0
  36. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/report.md +43 -0
  37. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/results.json +4478 -0
  38. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/scenarios.py +134 -0
  39. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/seed.py +255 -0
  40. package/plugin/vendor/reflexio/reflexio/cli/README.md +287 -0
  41. package/plugin/vendor/reflexio/reflexio/cli/__init__.py +0 -0
  42. package/plugin/vendor/reflexio/reflexio/cli/__main__.py +56 -0
  43. package/plugin/vendor/reflexio/reflexio/cli/_client.py +86 -0
  44. package/plugin/vendor/reflexio/reflexio/cli/app.py +127 -0
  45. package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +265 -0
  46. package/plugin/vendor/reflexio/reflexio/cli/codex_auth.py +503 -0
  47. package/plugin/vendor/reflexio/reflexio/cli/commands/__init__.py +0 -0
  48. package/plugin/vendor/reflexio/reflexio/cli/commands/admin_cmd.py +65 -0
  49. package/plugin/vendor/reflexio/reflexio/cli/commands/agent_playbooks.py +503 -0
  50. package/plugin/vendor/reflexio/reflexio/cli/commands/api.py +114 -0
  51. package/plugin/vendor/reflexio/reflexio/cli/commands/auth.py +109 -0
  52. package/plugin/vendor/reflexio/reflexio/cli/commands/config_cmd.py +511 -0
  53. package/plugin/vendor/reflexio/reflexio/cli/commands/doctor.py +127 -0
  54. package/plugin/vendor/reflexio/reflexio/cli/commands/embeddings.py +53 -0
  55. package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +478 -0
  56. package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +303 -0
  57. package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +289 -0
  58. package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +964 -0
  59. package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +285 -0
  60. package/plugin/vendor/reflexio/reflexio/cli/commands/status_cmd.py +143 -0
  61. package/plugin/vendor/reflexio/reflexio/cli/commands/user_playbooks.py +373 -0
  62. package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +284 -0
  63. package/plugin/vendor/reflexio/reflexio/cli/errors.py +217 -0
  64. package/plugin/vendor/reflexio/reflexio/cli/log_format.py +247 -0
  65. package/plugin/vendor/reflexio/reflexio/cli/output.py +867 -0
  66. package/plugin/vendor/reflexio/reflexio/cli/paths.py +41 -0
  67. package/plugin/vendor/reflexio/reflexio/cli/run_services.py +391 -0
  68. package/plugin/vendor/reflexio/reflexio/cli/state.py +204 -0
  69. package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +96 -0
  70. package/plugin/vendor/reflexio/reflexio/cli/utils.py +329 -0
  71. package/plugin/vendor/reflexio/reflexio/client/__init__.py +3 -0
  72. package/plugin/vendor/reflexio/reflexio/client/cache.py +150 -0
  73. package/plugin/vendor/reflexio/reflexio/client/client.py +2613 -0
  74. package/plugin/vendor/reflexio/reflexio/defaults.py +23 -0
  75. package/plugin/vendor/reflexio/reflexio/integrations/__init__.py +0 -0
  76. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/.clawhubignore +7 -0
  77. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +274 -0
  78. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +517 -0
  79. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +473 -0
  80. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +2156 -0
  81. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +18 -0
  82. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +241 -0
  83. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +140 -0
  84. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +130 -0
  85. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +113 -0
  86. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +52 -0
  87. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +103 -0
  88. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +156 -0
  89. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +134 -0
  90. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +41 -0
  91. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +17 -0
  92. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +24 -0
  93. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +48 -0
  94. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +278 -0
  95. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +164 -0
  96. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +36 -0
  97. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +35 -0
  98. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +27 -0
  99. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +31 -0
  100. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +42 -0
  101. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +49 -0
  102. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +91 -0
  103. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +50 -0
  104. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tsconfig.json +16 -0
  105. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/types/openclaw.d.ts +230 -0
  106. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +13 -0
  107. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/README.md +120 -0
  108. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/TESTING.md +168 -0
  109. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package-lock.json +1657 -0
  110. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package.json +16 -0
  111. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/HEARTBEAT.md +6 -0
  112. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/README.md +84 -0
  113. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/SKILL.md +194 -0
  114. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/_meta.json +6 -0
  115. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/agents/reflexio-extractor.md +45 -0
  116. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/handler.ts +214 -0
  117. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/setup.ts +55 -0
  118. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/index.ts +327 -0
  119. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/consolidate.ts +233 -0
  120. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/dedup.ts +80 -0
  121. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/io.ts +155 -0
  122. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/openclaw-cli.ts +67 -0
  123. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/search.ts +33 -0
  124. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-playbook.ts +76 -0
  125. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-profile.ts +79 -0
  126. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/openclaw.plugin.json +46 -0
  127. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/package.json +18 -0
  128. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/README.md +36 -0
  129. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/full_consolidation.md +56 -0
  130. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/playbook_extraction.md +217 -0
  131. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/profile_extraction.md +132 -0
  132. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-consolidate/SKILL.md +33 -0
  133. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-embedded/SKILL.md +194 -0
  134. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/HOOK.md +18 -0
  135. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/architecture.md +49 -0
  136. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/comparison.md +31 -0
  137. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/future-work.md +47 -0
  138. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/porting-notes.md +52 -0
  139. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/install.sh +52 -0
  140. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/uninstall.sh +36 -0
  141. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/consolidate.test.ts +135 -0
  142. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/dedup.test.ts +104 -0
  143. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/io.test.ts +175 -0
  144. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/search.test.ts +66 -0
  145. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/smoke-test.ts +140 -0
  146. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-playbook.test.ts +93 -0
  147. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-profile.test.ts +174 -0
  148. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tsconfig.json +16 -0
  149. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/types/openclaw.d.ts +230 -0
  150. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/vitest.config.ts +7 -0
  151. package/plugin/vendor/reflexio/reflexio/lib/__init__.py +23 -0
  152. package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +310 -0
  153. package/plugin/vendor/reflexio/reflexio/lib/_base.py +225 -0
  154. package/plugin/vendor/reflexio/reflexio/lib/_config.py +83 -0
  155. package/plugin/vendor/reflexio/reflexio/lib/_dashboard.py +266 -0
  156. package/plugin/vendor/reflexio/reflexio/lib/_generation.py +176 -0
  157. package/plugin/vendor/reflexio/reflexio/lib/_interactions.py +334 -0
  158. package/plugin/vendor/reflexio/reflexio/lib/_operations.py +153 -0
  159. package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +545 -0
  160. package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +52 -0
  161. package/plugin/vendor/reflexio/reflexio/lib/_search.py +167 -0
  162. package/plugin/vendor/reflexio/reflexio/lib/_storage_labels.py +103 -0
  163. package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +288 -0
  164. package/plugin/vendor/reflexio/reflexio/lib/reflexio_lib.py +27 -0
  165. package/plugin/vendor/reflexio/reflexio/models/__init__.py +0 -0
  166. package/plugin/vendor/reflexio/reflexio/models/api_schema/__init__.py +0 -0
  167. package/plugin/vendor/reflexio/reflexio/models/api_schema/braintrust_schema.py +141 -0
  168. package/plugin/vendor/reflexio/reflexio/models/api_schema/common.py +41 -0
  169. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +3 -0
  170. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +1112 -0
  171. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +63 -0
  172. package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +487 -0
  173. package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +28 -0
  174. package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +83 -0
  175. package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +768 -0
  176. package/plugin/vendor/reflexio/reflexio/models/api_schema/service_schemas.py +9 -0
  177. package/plugin/vendor/reflexio/reflexio/models/api_schema/stall_state_schema.py +32 -0
  178. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/__init__.py +3 -0
  179. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +177 -0
  180. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +129 -0
  181. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/enums.py +25 -0
  182. package/plugin/vendor/reflexio/reflexio/models/api_schema/validators.py +333 -0
  183. package/plugin/vendor/reflexio/reflexio/models/config_schema.py +908 -0
  184. package/plugin/vendor/reflexio/reflexio/models/py.typed +0 -0
  185. package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +90 -0
  186. package/plugin/vendor/reflexio/reflexio/server/README.md +622 -0
  187. package/plugin/vendor/reflexio/reflexio/server/__init__.py +210 -0
  188. package/plugin/vendor/reflexio/reflexio/server/__main__.py +132 -0
  189. package/plugin/vendor/reflexio/reflexio/server/_auth.py +25 -0
  190. package/plugin/vendor/reflexio/reflexio/server/api.py +2868 -0
  191. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/README.md +34 -0
  192. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/account_api.py +143 -0
  193. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/health_api.py +91 -0
  194. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/pending_tool_call_api.py +572 -0
  195. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +66 -0
  196. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/publisher_api.py +562 -0
  197. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +50 -0
  198. package/plugin/vendor/reflexio/reflexio/server/api_endpoints/stall_state_api.py +100 -0
  199. package/plugin/vendor/reflexio/reflexio/server/cache/__init__.py +15 -0
  200. package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +208 -0
  201. package/plugin/vendor/reflexio/reflexio/server/correlation.py +46 -0
  202. package/plugin/vendor/reflexio/reflexio/server/llm/__init__.py +30 -0
  203. package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +359 -0
  204. package/plugin/vendor/reflexio/reflexio/server/llm/image_utils.py +55 -0
  205. package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +1871 -0
  206. package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +140 -0
  207. package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +479 -0
  208. package/plugin/vendor/reflexio/reflexio/server/llm/providers/__init__.py +1 -0
  209. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1122 -0
  210. package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_stream_parser.py +197 -0
  211. package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +338 -0
  212. package/plugin/vendor/reflexio/reflexio/server/llm/providers/local_embedding_provider.py +213 -0
  213. package/plugin/vendor/reflexio/reflexio/server/llm/providers/nomic_embedding_provider.py +288 -0
  214. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/__init__.py +6 -0
  215. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +187 -0
  216. package/plugin/vendor/reflexio/reflexio/server/llm/rerank/llm_reranker.py +148 -0
  217. package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +716 -0
  218. package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +179 -0
  219. package/plugin/vendor/reflexio/reflexio/server/prompt/__init__.py +0 -0
  220. package/plugin/vendor/reflexio/reflexio/server/prompt/_dispatchers.py +54 -0
  221. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/README.md +121 -0
  222. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation/v1.0.0.prompt.md +58 -0
  223. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation_with_comparison/v1.0.0.prompt.md +76 -0
  224. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/answer_synthesis/v1.5.2.prompt.md +88 -0
  225. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/compress_session_for_query/v1.3.0.prompt.md +31 -0
  226. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/document_expansion/v1.0.0.prompt.md +20 -0
  227. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.0.0.prompt.md +53 -0
  228. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.1.0.prompt.md +57 -0
  229. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.2.0.prompt.md +68 -0
  230. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.3.0.prompt.md +70 -0
  231. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.4.0.prompt.md +77 -0
  232. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.5.0.prompt.md +82 -0
  233. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +83 -0
  234. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.1.0.prompt.md +193 -0
  235. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +206 -0
  236. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0-deprecated.prompt.md +66 -0
  237. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0.prompt.md +43 -0
  238. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.1.0.prompt.md +46 -0
  239. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0-deprecated.prompt.md +64 -0
  240. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0.prompt.md +39 -0
  241. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.1.0.prompt.md +39 -0
  242. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.2.0.prompt.md +47 -0
  243. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.0.prompt.md +58 -0
  244. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.1.prompt.md +69 -0
  245. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +71 -0
  246. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.0.2.prompt.md +254 -0
  247. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.1.0.prompt.md +274 -0
  248. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.0.prompt.md +283 -0
  249. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.2.prompt.md +234 -0
  250. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +244 -0
  251. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v1.0.0.prompt.md +73 -0
  252. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v2.0.0.prompt.md +86 -0
  253. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.0.0.prompt.md +97 -0
  254. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.1.0.prompt.md +119 -0
  255. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.2.0.prompt.md +123 -0
  256. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +137 -0
  257. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.0.0.prompt.md +14 -0
  258. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.1.0.prompt.md +24 -0
  259. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +29 -0
  260. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.0.0.prompt.md +11 -0
  261. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.1.0.prompt.md +21 -0
  262. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.2.0.prompt.md +25 -0
  263. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.0.0.prompt.md +37 -0
  264. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.1.0.prompt.md +40 -0
  265. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.2.0.prompt.md +36 -0
  266. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v1.0.0.prompt.md +45 -0
  267. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v2.0.0.prompt.md +81 -0
  268. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v3.0.0.prompt.md +80 -0
  269. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate_expert/v1.0.0.prompt.md +34 -0
  270. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_deduplication/v1.0.0.prompt.md +116 -0
  271. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate/v1.0.0.prompt.md +33 -0
  272. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate_override/v1.0.0.prompt.md +16 -0
  273. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +140 -0
  274. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +160 -0
  275. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_main/v1.0.0.prompt.md +14 -0
  276. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/query_reformulation/v1.0.0.prompt.md +19 -0
  277. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/rerank_relevance/v1.1.0.prompt.md +44 -0
  278. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_comparison/v1.0.0.prompt.md +43 -0
  279. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_content_evaluation/v1.0.0.prompt.md +33 -0
  280. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/feedback_extraction_main_v1.jsonl +10 -0
  281. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/profile_update_main_v1.jsonl +10 -0
  282. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +280 -0
  283. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_schema.py +11 -0
  284. package/plugin/vendor/reflexio/reflexio/server/services/README.md +58 -0
  285. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/_eval_health.py +131 -0
  286. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +60 -0
  287. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_service.py +228 -0
  288. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +87 -0
  289. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluator.py +372 -0
  290. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/delayed_group_evaluator.py +156 -0
  291. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/group_evaluation_runner.py +336 -0
  292. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +471 -0
  293. package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +1668 -0
  294. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/__init__.py +0 -0
  295. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_cron.py +196 -0
  296. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_encryption.py +101 -0
  297. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/client.py +167 -0
  298. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/service.py +281 -0
  299. package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +179 -0
  300. package/plugin/vendor/reflexio/reflexio/server/services/configurator/config_storage.py +62 -0
  301. package/plugin/vendor/reflexio/reflexio/server/services/configurator/configurator.py +87 -0
  302. package/plugin/vendor/reflexio/reflexio/server/services/configurator/local_file_config_storage.py +187 -0
  303. package/plugin/vendor/reflexio/reflexio/server/services/configurator/test_config_storage.py +162 -0
  304. package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +112 -0
  305. package/plugin/vendor/reflexio/reflexio/server/services/embedding_text.py +62 -0
  306. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/__init__.py +0 -0
  307. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/distribution.py +33 -0
  308. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +126 -0
  309. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +192 -0
  310. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/hero_state.py +75 -0
  311. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/rule_attribution.py +97 -0
  312. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +515 -0
  313. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/shadow_aggregation.py +90 -0
  314. package/plugin/vendor/reflexio/reflexio/server/services/extraction/__init__.py +0 -0
  315. package/plugin/vendor/reflexio/reflexio/server/services/extraction/agent_run_records.py +91 -0
  316. package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +303 -0
  317. package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +25 -0
  318. package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +358 -0
  319. package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +138 -0
  320. package/plugin/vendor/reflexio/reflexio/server/services/extraction/prior_answer_search.py +217 -0
  321. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +535 -0
  322. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_scheduler.py +171 -0
  323. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +779 -0
  324. package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +1125 -0
  325. package/plugin/vendor/reflexio/reflexio/server/services/extractor_config_utils.py +94 -0
  326. package/plugin/vendor/reflexio/reflexio/server/services/extractor_interaction_utils.py +251 -0
  327. package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +702 -0
  328. package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +835 -0
  329. package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +89 -0
  330. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_aggregator.py +1388 -0
  331. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_consolidator.py +1045 -0
  332. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_extractor.py +436 -0
  333. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_generation_service.py +808 -0
  334. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_constants.py +28 -0
  335. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +362 -0
  336. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/__init__.py +24 -0
  337. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/assistant_webhook.py +246 -0
  338. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/gepa_adapter.py +291 -0
  339. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/judge.py +97 -0
  340. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +96 -0
  341. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +645 -0
  342. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/rollout.py +35 -0
  343. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scenario_resolver.py +93 -0
  344. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scheduler.py +174 -0
  345. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/__init__.py +26 -0
  346. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_document_expander.py +179 -0
  347. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_query_reformulator.py +297 -0
  348. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_deduplicator.py +772 -0
  349. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_extractor.py +462 -0
  350. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service.py +737 -0
  351. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +290 -0
  352. package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +17 -0
  353. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_extractor.py +247 -0
  354. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service.py +803 -0
  355. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +146 -0
  356. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/__init__.py +0 -0
  357. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +80 -0
  358. package/plugin/vendor/reflexio/reflexio/server/services/search/__init__.py +0 -0
  359. package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +756 -0
  360. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/__init__.py +1 -0
  361. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/judge.py +184 -0
  362. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +81 -0
  363. package/plugin/vendor/reflexio/reflexio/server/services/storage/constants.py +2 -0
  364. package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +11 -0
  365. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +154 -0
  366. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention_mixin.py +155 -0
  367. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +59 -0
  368. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +1298 -0
  369. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +1945 -0
  370. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +600 -0
  371. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +346 -0
  372. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +1378 -0
  373. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +747 -0
  374. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +263 -0
  375. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +193 -0
  376. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_share_links.py +166 -0
  377. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +217 -0
  378. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +153 -0
  379. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +384 -0
  380. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +71 -0
  381. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +235 -0
  382. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +170 -0
  383. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +677 -0
  384. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +250 -0
  385. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +154 -0
  386. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +130 -0
  387. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_share_links.py +93 -0
  388. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_stall_state.py +76 -0
  389. package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +572 -0
  390. package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +77 -0
  391. package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +116 -0
  392. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_manager.py +263 -0
  393. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +13 -0
  394. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/llm_model_setting.json +7 -0
  395. package/plugin/vendor/reflexio/reflexio/server/tracing.py +158 -0
  396. package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +113 -0
  397. package/plugin/vendor/reflexio/reflexio/server/uvicorn_logging.py +76 -0
  398. package/plugin/vendor/reflexio/reflexio/test_support/__init__.py +1 -0
  399. package/plugin/vendor/reflexio/reflexio/test_support/llm_fixtures.py +62 -0
  400. package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +242 -0
  401. package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +129 -0
  402. package/plugin/vendor/reflexio/reflexio/test_support/skip_decorators.py +43 -0
@@ -0,0 +1,134 @@
1
+ """
2
+ Canned query set and vocabulary for the retrieval latency benchmark.
3
+
4
+ The query set, vocabulary, and templates are frozen as module-level
5
+ constants so that benchmark runs are bit-for-bit reproducible across
6
+ machines and across time. Do not mutate.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ # 20 queries spanning short / long / keyword-heavy / semantic-heavy.
12
+ # Query diversity matters because hybrid search behavior depends on
13
+ # how many FTS tokens match vs how well the query vector aligns.
14
+ QUERIES: tuple[str, ...] = (
15
+ # short, keyword-heavy
16
+ "refund policy",
17
+ "shipping delay",
18
+ "cancel subscription",
19
+ "password reset",
20
+ "billing error",
21
+ # short, semantic
22
+ "user was frustrated with the agent",
23
+ "agent apologized and offered compensation",
24
+ "customer wants to speak to a manager",
25
+ "sales opportunity upsell",
26
+ "technical issue escalation",
27
+ # long, conversational
28
+ "the user complained that the previous agent had been rude and dismissive during a prior call",
29
+ "looking for playbooks where we recommend offering a discount when a customer threatens to churn",
30
+ "anything related to the enterprise plan negotiation playbook for high-value accounts",
31
+ "profiles of users who have reported repeated shipping problems in the last month",
32
+ # long, semantic
33
+ "what do we know about users who rely on the mobile app and have poor network conditions",
34
+ "situations where the agent should not offer a refund because policy prevents it",
35
+ "user asks about product roadmap and pricing changes",
36
+ # keyword-heavy, rare tokens
37
+ "api key rotation quota limit",
38
+ "webhook signature verification failure",
39
+ "gdpr data export request",
40
+ )
41
+
42
+
43
+ # Fixed small vocabulary used to build synthetic profiles and playbooks.
44
+ # Enough diversity for non-trivial BM25 scoring but not large enough to
45
+ # dominate memory at N=10_000.
46
+ VOCABULARY: tuple[str, ...] = (
47
+ "refund",
48
+ "shipping",
49
+ "cancel",
50
+ "subscription",
51
+ "password",
52
+ "billing",
53
+ "frustrated",
54
+ "apologized",
55
+ "manager",
56
+ "sales",
57
+ "technical",
58
+ "escalation",
59
+ "rude",
60
+ "dismissive",
61
+ "discount",
62
+ "churn",
63
+ "enterprise",
64
+ "negotiation",
65
+ "mobile",
66
+ "network",
67
+ "roadmap",
68
+ "pricing",
69
+ "policy",
70
+ "quota",
71
+ "webhook",
72
+ "gdpr",
73
+ "export",
74
+ "verification",
75
+ "signature",
76
+ "rotation",
77
+ "limit",
78
+ "profile",
79
+ "playbook",
80
+ "agent",
81
+ "user",
82
+ "request",
83
+ "session",
84
+ "context",
85
+ "history",
86
+ "interaction",
87
+ "feedback",
88
+ "resolution",
89
+ "complaint",
90
+ "praise",
91
+ "upgrade",
92
+ "downgrade",
93
+ "trial",
94
+ "payment",
95
+ "invoice",
96
+ "receipt",
97
+ "tax",
98
+ "shipping",
99
+ "delivery",
100
+ "tracking",
101
+ "return",
102
+ "exchange",
103
+ "warranty",
104
+ "bug",
105
+ "crash",
106
+ "error",
107
+ "timeout",
108
+ "latency",
109
+ "performance",
110
+ "slow",
111
+ "fast",
112
+ "reliable",
113
+ "consistent",
114
+ "intermittent",
115
+ "regression",
116
+ "feature",
117
+ )
118
+
119
+
120
+ # Templated sentences used to build synthetic playbook/profile content.
121
+ # Each template has at least one `{word}` slot so the synthetic text has
122
+ # real token variety across the corpus.
123
+ CONTENT_TEMPLATES: tuple[str, ...] = (
124
+ "The user asked about {word} and the agent should clarify policy details.",
125
+ "When the customer mentions {word}, confirm the account status first.",
126
+ "Escalate to a senior agent if the user repeats {word} after one attempt.",
127
+ "Offer a {word} to retain accounts showing churn risk indicators.",
128
+ "Capture the {word} and log it against the user's profile for follow-up.",
129
+ "The agent should proactively mention {word} during enterprise calls.",
130
+ "If {word} is unclear, ask a clarifying question before committing.",
131
+ "Document the {word} in the session notes with a timestamp.",
132
+ "Do not promise {word} without checking the internal knowledge base.",
133
+ "Recommend {word} as the next step when the user sounds uncertain.",
134
+ )
@@ -0,0 +1,255 @@
1
+ """
2
+ Deterministic synthetic corpus for the retrieval latency benchmark.
3
+
4
+ Builds ``UserProfile``, ``UserPlaybook``, and ``AgentPlaybook`` objects from
5
+ a fixed vocabulary and template set, then inserts them through the real
6
+ service-layer add methods (``Reflexio.add_user_profile`` et al.) so that the
7
+ storage index, FTS table, and vector index are exercised through the same
8
+ code paths that production uses.
9
+
10
+ Profiles and user playbooks are spread across a small fixed user pool so
11
+ that a per-user filter (``user_id``) still hits a non-trivial number of
12
+ rows — without that, profile search would always return at most one row
13
+ regardless of N.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import logging
19
+ import random
20
+ import uuid
21
+ from collections.abc import Iterable
22
+ from datetime import UTC, datetime
23
+
24
+ from reflexio.benchmarks.retrieval_latency.embed_cache import (
25
+ make_fake_document_embedder,
26
+ patch_storage_get_embedding,
27
+ )
28
+ from reflexio.benchmarks.retrieval_latency.scenarios import (
29
+ CONTENT_TEMPLATES,
30
+ VOCABULARY,
31
+ )
32
+ from reflexio.lib.reflexio_lib import Reflexio
33
+ from reflexio.models.api_schema.domain.entities import (
34
+ AddAgentPlaybookRequest,
35
+ AddUserPlaybookRequest,
36
+ AddUserProfileRequest,
37
+ AgentPlaybook,
38
+ UserPlaybook,
39
+ UserProfile,
40
+ )
41
+
42
+ logger = logging.getLogger(__name__)
43
+
44
+ # Small pool of user_ids — profiles and user-playbooks distribute across
45
+ # these so that per-user filters still touch a meaningful number of rows.
46
+ USER_POOL_SIZE = 10
47
+ # Small pool of agent versions / playbook names — gives playbook-name filters
48
+ # enough selectivity to look like real usage without being single-row lookups.
49
+ AGENT_VERSION_POOL_SIZE = 3
50
+ PLAYBOOK_NAME_POOL_SIZE = 5
51
+
52
+ # Per-entity RNG seeds. All derived from a single base so the entire corpus
53
+ # is reproducible from one number, but each entity type gets its own stream so
54
+ # they don't collide content with each other.
55
+ _BENCH_SEED_BASE = 42
56
+ _PROFILE_SEED = _BENCH_SEED_BASE
57
+ _USER_PLAYBOOK_SEED = _BENCH_SEED_BASE + 1
58
+ _AGENT_PLAYBOOK_SEED = _BENCH_SEED_BASE + 2
59
+
60
+ # Batch size used when sending profiles/playbooks through add_* — keeps
61
+ # request objects under a sensible size and amortizes storage transactions.
62
+ _SEED_BATCH_SIZE = 100
63
+
64
+
65
+ def _user_id(idx: int) -> str:
66
+ """
67
+ Deterministically map an object index to a user_id in the fixed pool.
68
+
69
+ Args:
70
+ idx (int): The sequential index of the object being generated.
71
+
72
+ Returns:
73
+ str: A user_id string of the form ``bench_user_{i}``.
74
+ """
75
+ return f"bench_user_{idx % USER_POOL_SIZE}"
76
+
77
+
78
+ def _agent_version(idx: int) -> str:
79
+ """
80
+ Deterministically map an object index to an agent_version.
81
+
82
+ Args:
83
+ idx (int): The sequential index of the object being generated.
84
+
85
+ Returns:
86
+ str: An agent_version string of the form ``bench_agent_v{i}``.
87
+ """
88
+ return f"bench_agent_v{idx % AGENT_VERSION_POOL_SIZE}"
89
+
90
+
91
+ def _playbook_name(idx: int) -> str:
92
+ """
93
+ Deterministically map an object index to a playbook_name.
94
+
95
+ Args:
96
+ idx (int): The sequential index of the object being generated.
97
+
98
+ Returns:
99
+ str: A playbook_name string of the form ``bench_playbook_{i}``.
100
+ """
101
+ return f"bench_playbook_{idx % PLAYBOOK_NAME_POOL_SIZE}"
102
+
103
+
104
+ def _content(rng: random.Random) -> str:
105
+ """
106
+ Build one line of synthetic content from the fixed vocabulary.
107
+
108
+ Picks a template and fills its single slot with a vocabulary word. Also
109
+ appends 3–8 extra vocabulary tokens to give BM25 some additional surface
110
+ area to match against.
111
+
112
+ Args:
113
+ rng (random.Random): Seeded RNG controlling all choices.
114
+
115
+ Returns:
116
+ str: A synthetic content string (typically 10–20 tokens).
117
+ """
118
+ template = rng.choice(CONTENT_TEMPLATES)
119
+ word = rng.choice(VOCABULARY)
120
+ extra_count = rng.randint(3, 8)
121
+ extras = " ".join(rng.choice(VOCABULARY) for _ in range(extra_count))
122
+ return f"{template.format(word=word)} {extras}"
123
+
124
+
125
+ def build_profiles(n: int) -> list[UserProfile]:
126
+ """
127
+ Build ``n`` deterministic synthetic ``UserProfile`` objects.
128
+
129
+ Args:
130
+ n (int): Number of profiles to generate.
131
+
132
+ Returns:
133
+ list[UserProfile]: Profiles spread across the fixed user pool. Each
134
+ has a fresh UUID profile_id, a synthetic content string, and a
135
+ current timestamp (fixed across a single run via ``rng`` for
136
+ determinism at the seeding step).
137
+ """
138
+ rng = random.Random(_PROFILE_SEED)
139
+ now = int(datetime.now(UTC).timestamp())
140
+ return [
141
+ UserProfile(
142
+ profile_id=f"bench_profile_{i}_{uuid.UUID(int=rng.getrandbits(128))}",
143
+ user_id=_user_id(i),
144
+ content=_content(rng),
145
+ last_modified_timestamp=now,
146
+ generated_from_request_id=f"bench_req_{i}",
147
+ )
148
+ for i in range(n)
149
+ ]
150
+
151
+
152
+ def build_user_playbooks(n: int) -> list[UserPlaybook]:
153
+ """
154
+ Build ``n`` deterministic synthetic ``UserPlaybook`` objects.
155
+
156
+ Args:
157
+ n (int): Number of user playbooks to generate.
158
+
159
+ Returns:
160
+ list[UserPlaybook]: Playbooks spread across the fixed user and
161
+ agent-version pools. ``user_playbook_id`` is left at the default
162
+ ``0`` so storage assigns fresh IDs during insertion.
163
+ """
164
+ rng = random.Random(_USER_PLAYBOOK_SEED)
165
+ return [
166
+ UserPlaybook(
167
+ user_id=_user_id(i),
168
+ agent_version=_agent_version(i),
169
+ playbook_name=_playbook_name(i),
170
+ request_id=f"bench_req_{i}",
171
+ content=_content(rng),
172
+ )
173
+ for i in range(n)
174
+ ]
175
+
176
+
177
+ def build_agent_playbooks(n: int) -> list[AgentPlaybook]:
178
+ """
179
+ Build ``n`` deterministic synthetic ``AgentPlaybook`` objects.
180
+
181
+ Args:
182
+ n (int): Number of agent playbooks to generate.
183
+
184
+ Returns:
185
+ list[AgentPlaybook]: Playbooks spread across the fixed agent-version
186
+ and playbook-name pools.
187
+ """
188
+ rng = random.Random(_AGENT_PLAYBOOK_SEED)
189
+ return [
190
+ AgentPlaybook(
191
+ agent_version=_agent_version(i),
192
+ playbook_name=_playbook_name(i),
193
+ content=_content(rng),
194
+ )
195
+ for i in range(n)
196
+ ]
197
+
198
+
199
+ def _batched[T](items: list[T], size: int) -> Iterable[list[T]]:
200
+ """
201
+ Yield contiguous batches of ``items`` with length up to ``size``.
202
+
203
+ Args:
204
+ items (list[T]): Input list to batch.
205
+ size (int): Maximum batch length.
206
+
207
+ Yields:
208
+ list[T]: Each batch in order.
209
+ """
210
+ for start in range(0, len(items), size):
211
+ yield items[start : start + size]
212
+
213
+
214
+ def seed_corpus(reflexio: Reflexio, storage: object, n: int) -> None:
215
+ """
216
+ Insert a full synthetic corpus into the given Reflexio instance.
217
+
218
+ Document embeddings are generated from a deterministic fake embedder
219
+ for the duration of this call — document vector *content* doesn't affect
220
+ query-time latency (only row count does), so the optimization trades
221
+ vector meaningfulness for seeding speed. Query-time retrieval is
222
+ expected to patch the storage with a real query embedding cache instead.
223
+
224
+ Args:
225
+ reflexio (Reflexio): Service-layer facade with storage wired up.
226
+ storage: The underlying ``BaseStorage`` instance to patch.
227
+ n (int): Number of each entity type to seed (profiles, user
228
+ playbooks, agent playbooks — ``3 * n`` total rows).
229
+ """
230
+ fake = make_fake_document_embedder()
231
+ with patch_storage_get_embedding(storage, fake):
232
+ logger.info("Seeding %d profiles / user_playbooks / agent_playbooks", n)
233
+ for batch in _batched(build_profiles(n), _SEED_BATCH_SIZE):
234
+ reflexio.add_user_profile(AddUserProfileRequest(user_profiles=batch))
235
+ for batch in _batched(build_user_playbooks(n), _SEED_BATCH_SIZE):
236
+ reflexio.add_user_playbook(AddUserPlaybookRequest(user_playbooks=batch))
237
+ for batch in _batched(build_agent_playbooks(n), _SEED_BATCH_SIZE):
238
+ reflexio.add_agent_playbook(AddAgentPlaybookRequest(agent_playbooks=batch))
239
+ logger.info("Seeding complete (n=%d)", n)
240
+
241
+
242
+ def pick_bench_user_id(query_idx: int) -> str:
243
+ """
244
+ Choose a user_id for profile/user-playbook search from the seeded pool.
245
+
246
+ Rotates through the pool by query index so successive queries aren't
247
+ always hitting the same user's rows.
248
+
249
+ Args:
250
+ query_idx (int): Index of the current query (0-based).
251
+
252
+ Returns:
253
+ str: A user_id that exists in the seeded corpus.
254
+ """
255
+ return f"bench_user_{query_idx % USER_POOL_SIZE}"
@@ -0,0 +1,287 @@
1
+ # Reflexio CLI
2
+
3
+ `reflexio` is a first-class CLI for running the Reflexio service, publishing interactions, exploring extracted profiles and playbooks, and wiring results into your own agent. Every command is also runnable as `python -m reflexio ...`.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Install & invoke](#install--invoke)
8
+ - [Global flags](#global-flags)
9
+ - [Quick Reference](#quick-reference)
10
+ - [Services](#services)
11
+ - [Publishing interactions](#publishing-interactions)
12
+ - [Search & context](#search--context)
13
+ - [Interactions](#interactions)
14
+ - [User profiles](#user-profiles)
15
+ - [Agent playbooks](#agent-playbooks)
16
+ - [User playbooks](#user-playbooks)
17
+ - [Config](#config)
18
+ - [Auth](#auth)
19
+ - [Diagnostics](#diagnostics)
20
+ - [Raw API access](#raw-api-access)
21
+ - [Common Workflows](#common-workflows)
22
+ - [Getting help](#getting-help)
23
+
24
+ ## Quick Reference
25
+
26
+ Most common commands at a glance:
27
+
28
+ | Task | Command |
29
+ |------|---------|
30
+ | Start server | `reflexio services start` |
31
+ | Publish conversation | `reflexio publish --user-id USER --data '...'` |
32
+ | Search everything | `reflexio search "query"` |
33
+ | List profiles | `reflexio user-profiles list --user-id USER` |
34
+ | List playbooks | `reflexio agent-playbooks list` |
35
+ | Check health | `reflexio status check` |
36
+ | Stop server | `reflexio services stop` |
37
+
38
+ ## Install & invoke
39
+
40
+ The CLI ships with the `reflexio` package. After `uv sync`:
41
+
42
+ ```shell
43
+ uv run reflexio --help
44
+ uv run reflexio --version
45
+ ```
46
+
47
+ ## Global flags
48
+
49
+ Available on every command (set on the root, before the subcommand):
50
+
51
+ | Flag | Env var | Purpose |
52
+ | -------------- | -------------------- | -------------------------------- |
53
+ | `--json` | — | Structured JSON output envelopes |
54
+ | `--server-url` | `REFLEXIO_URL` | Backend API URL |
55
+ | `--api-key` | `REFLEXIO_API_KEY` | API bearer token |
56
+ | `--version` | — | Show CLI version |
57
+
58
+ Example: `uv run reflexio --json search "refund policy"`.
59
+
60
+ ## Services
61
+
62
+ Start and stop the backend, docs server, and optional local embedding daemon.
63
+
64
+ ```shell
65
+ uv run reflexio services start # backend :8081, docs :8082
66
+ uv run reflexio services start --storage sqlite # sqlite (default) | supabase | postgres
67
+ uv run reflexio services start --backend-port 9000 --docs-port 9001
68
+ uv run reflexio services start --only backend --no-reload
69
+ uv run reflexio embeddings serve --port 8072 # OpenAI-compatible local embeddings
70
+ uv run reflexio services stop
71
+ uv run reflexio services stop --force # SIGKILL instead of SIGTERM
72
+ ```
73
+
74
+ When `REFLEXIO_EMBEDDING_PROVIDER=local_service` or
75
+ `CLAUDE_SMART_USE_LOCAL_EMBEDDING=1`, `services start --only backend` starts an
76
+ `embedding` service dependency automatically. The daemon exposes
77
+ `POST /v1/embeddings` and supports `local/nomic-embed-v1.5`,
78
+ `local/nomic-embed-text-v1.5`, and `local/minilm-l6-v2`. Local embedding
79
+ requests allow extra time for model cold start; override with
80
+ `REFLEXIO_EMBEDDING_SERVICE_TIMEOUT_MS` when needed.
81
+
82
+ ## Publishing interactions
83
+
84
+ The top-level `publish` shortcut is the fastest way to get a conversation into Reflexio. It forwards to `interactions publish` and supports three input modes: single-turn flags, inline JSON, and file/stdin payloads.
85
+
86
+ Reflexio learns most from interactions that contain a **signal** — a user correction, a stated preference, or an explicit choice between alternatives. Examples throughout this doc use that kind of content rather than trivial Q&A.
87
+
88
+ ### Mode 1 — Single-turn (shortcut flags)
89
+
90
+ `--user-message` / `--agent-response` wrap a single user turn and a single assistant turn. Use this for quick preference captures or smoke-tests. It is **hard-coded to exactly 2 turns** — use Mode 2 or 3 below for anything longer.
91
+
92
+ ```shell
93
+ uv run reflexio publish \
94
+ --user-id alice \
95
+ --user-message "Stop adding disclaimers and caveats. Give me the answer in one line." \
96
+ --agent-response "Understood — I'll drop the boilerplate from now on." \
97
+ --wait
98
+ ```
99
+
100
+ ### Mode 2 — Multi-turn via inline JSON (`--data`)
101
+
102
+ For real dialogues (3+ turns, tool calls, corrections mid-conversation), pass a JSON object whose `interactions` field is a list of `{role, content}` items. Each item becomes one turn, in order. Roles are `user` and `assistant`; `system` and `tool` turns are also accepted.
103
+
104
+ ```shell
105
+ uv run reflexio publish --user-id alice --wait --data '{
106
+ "interactions": [
107
+ {"role": "user", "content": "Deploy the payments service to us-east-1."},
108
+ {"role": "assistant", "content": "Starting deployment to us-east-1..."},
109
+ {"role": "user", "content": "Wait — production always runs in us-west-2. Never us-east-1."},
110
+ {"role": "assistant", "content": "Understood. Switching to us-west-2."},
111
+ {"role": "user", "content": "Good. And always confirm the region with me before deploying."},
112
+ {"role": "assistant", "content": "Noted. I'll confirm the region on every deploy going forward."}
113
+ ]
114
+ }'
115
+ ```
116
+
117
+ This single call can populate **both** a user profile (`production region is us-west-2`) and an agent playbook (`confirm deploy region before executing`), which is exactly the loop Reflexio is designed for.
118
+
119
+ You can also load inline JSON from a file with `@`: `--data @conversation.json`.
120
+
121
+ ### Mode 3 — JSON / JSONL file or stdin
122
+
123
+ For bulk publishing or conversations you already have on disk, point at a file. A `.json` file should be a single object (or a list of objects); a `.jsonl` file is one JSON object per line, one conversation per line.
124
+
125
+ ```shell
126
+ uv run reflexio publish --file conversations.jsonl --user-id alice --wait
127
+ cat conversations.jsonl | uv run reflexio publish --stdin --user-id alice
128
+ ```
129
+
130
+ Each payload object accepts the same fields as Mode 2 (`interactions`, and optionally per-payload overrides for `user_id`, `session_id`, `source`, `agent_version`). A payload's own `user_id` wins over the `--user-id` flag, so you can publish a mixed-user JSONL file in a single call.
131
+
132
+ ### Common flags
133
+
134
+ Apply to all three modes:
135
+
136
+ | Flag | Purpose |
137
+ | ------------------- | ----------------------------------------------------------------------- |
138
+ | `--wait` | Block until server-side extraction finishes (returns real counts). |
139
+ | `--session-id` | Group multiple `publish` calls into one session. |
140
+ | `--agent-version` | Tag the interaction with an agent version (used by playbook filtering). |
141
+ | `--source` | Free-form source tag (defaults to `cli`). |
142
+ | `--skip-aggregation`| Extract profiles/playbooks but skip playbook aggregation. |
143
+ | `--force-extraction`| Bypass all extraction gates (`stride_size`, cheap pre-filter, LLM `should_run`) and always run extractors. |
144
+
145
+ Full options via `uv run reflexio interactions publish --help`.
146
+
147
+ ## Search & context
148
+
149
+ Unified semantic search across profiles and playbooks:
150
+
151
+ ```shell
152
+ uv run reflexio search "deployment region"
153
+ uv run reflexio search "response style" --user-id alice --top-k 10 --threshold 0.5
154
+ ```
155
+
156
+ Fetch formatted context for injection into your own agent. Both `--user-id` and `--agent-version` are required — the command fails loudly otherwise to avoid producing a misleading bootstrap:
157
+
158
+ ```shell
159
+ uv run reflexio context --user-id alice --agent-version v1
160
+ uv run reflexio context --user-id alice --agent-version v1 --query "deploy workflow"
161
+ ```
162
+
163
+ ## Interactions
164
+
165
+ ```shell
166
+ uv run reflexio interactions list --user-id alice
167
+ uv run reflexio interactions search "deployment"
168
+ uv run reflexio interactions delete <interaction-id>
169
+ uv run reflexio interactions delete-all
170
+ ```
171
+
172
+ ## User profiles
173
+
174
+ ```shell
175
+ uv run reflexio user-profiles list --user-id alice
176
+ uv run reflexio user-profiles search "preferences"
177
+ uv run reflexio user-profiles add --user-id alice --data @profile.json
178
+ uv run reflexio user-profiles regenerate --user-id alice
179
+ uv run reflexio user-profiles delete <profile-id>
180
+ uv run reflexio user-profiles delete-all
181
+ ```
182
+
183
+ ## Agent playbooks
184
+
185
+ ```shell
186
+ uv run reflexio agent-playbooks list --agent-version v1
187
+ uv run reflexio agent-playbooks search "error handling"
188
+ uv run reflexio agent-playbooks aggregate --agent-version v1
189
+ uv run reflexio agent-playbooks update-status <playbook-id> --status approved
190
+ uv run reflexio agent-playbooks regenerate --agent-version v1
191
+ uv run reflexio agent-playbooks delete <playbook-id>
192
+ ```
193
+
194
+ ## User playbooks
195
+
196
+ ```shell
197
+ uv run reflexio user-playbooks list --user-id alice
198
+ uv run reflexio user-playbooks search "preferences" --user-id alice
199
+ uv run reflexio user-playbooks add --user-id alice --data @playbook.json
200
+ uv run reflexio user-playbooks update <playbook-id> --data @patch.json
201
+ uv run reflexio user-playbooks delete <playbook-id>
202
+ ```
203
+
204
+ ## Config
205
+
206
+ ```shell
207
+ uv run reflexio config show
208
+ uv run reflexio config set --data '{"api_key_config": {"openai": "sk-..."}}'
209
+ uv run reflexio config set --data @config.json
210
+ uv run reflexio config storage # show storage backend info
211
+ uv run reflexio config pull # pull server config to local file
212
+ ```
213
+
214
+ ## Auth
215
+
216
+ ```shell
217
+ uv run reflexio auth login --api-key $REFLEXIO_API_KEY --server-url http://localhost:8081
218
+ uv run reflexio auth status
219
+ uv run reflexio auth logout
220
+ ```
221
+
222
+ ## Diagnostics
223
+
224
+ ```shell
225
+ uv run reflexio status check # server health
226
+ uv run reflexio status whoami # resolved identity
227
+ uv run reflexio doctor check # env + connectivity diagnostics
228
+ uv run reflexio setup init # interactive setup wizard
229
+ ```
230
+
231
+ ## Raw API access
232
+
233
+ Escape hatch for calling any endpoint directly. Supports `GET`, `POST`, `DELETE`:
234
+
235
+ ```shell
236
+ uv run reflexio api GET /health
237
+ uv run reflexio api POST /api/get_agent_playbooks --data '{"agent_version": "v1"}'
238
+ uv run reflexio api POST /api/set_config --data @config.json
239
+ ```
240
+
241
+ ## Common Workflows
242
+
243
+ A typical end-to-end workflow: publish a conversation, verify that Reflexio extracted the right data, then browse the results.
244
+
245
+ ### 1. Start services
246
+
247
+ ```shell
248
+ uv run reflexio services start
249
+ ```
250
+
251
+ ### 2. Publish a conversation
252
+
253
+ ```shell
254
+ uv run reflexio publish --user-id alice --wait --data '{
255
+ "interactions": [
256
+ {"role": "user", "content": "Always use dark mode in the dashboard."},
257
+ {"role": "assistant", "content": "Noted — I will default to dark mode for you."}
258
+ ]
259
+ }'
260
+ ```
261
+
262
+ ### 3. Search to verify extraction
263
+
264
+ ```shell
265
+ uv run reflexio search "dark mode"
266
+ ```
267
+
268
+ You should see a profile entry reflecting the user's preference.
269
+
270
+ ### 4. Browse profiles and playbooks
271
+
272
+ ```shell
273
+ uv run reflexio user-profiles list --user-id alice
274
+ uv run reflexio user-playbooks list --user-id alice
275
+ uv run reflexio agent-playbooks list
276
+ ```
277
+
278
+ ## Getting help
279
+
280
+ Every command and subcommand supports `--help`:
281
+
282
+ ```shell
283
+ uv run reflexio --help
284
+ uv run reflexio user-profiles --help
285
+ uv run reflexio user-playbooks --help
286
+ uv run reflexio agent-playbooks --help
287
+ ```