claude-smart 0.2.41 → 0.2.43

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 (396) hide show
  1. package/.claude-plugin/marketplace.json +17 -0
  2. package/README.md +1 -1
  3. package/bin/claude-smart.js +86 -48
  4. package/package.json +10 -3
  5. package/plugin/.claude-plugin/plugin.json +9 -3
  6. package/plugin/.codex-plugin/plugin.json +1 -1
  7. package/plugin/README.md +2 -2
  8. package/plugin/dashboard/next.config.ts +9 -1
  9. package/plugin/pyproject.toml +2 -2
  10. package/plugin/scripts/_lib.sh +91 -0
  11. package/plugin/scripts/backend-service.sh +46 -15
  12. package/plugin/scripts/cli.sh +29 -1
  13. package/plugin/scripts/codex-hook.js +72 -4
  14. package/plugin/scripts/dashboard-build.sh +1 -0
  15. package/plugin/scripts/dashboard-service.sh +1 -0
  16. package/plugin/scripts/ensure-plugin-root.sh +7 -14
  17. package/plugin/scripts/hook_entry.sh +1 -0
  18. package/plugin/scripts/smart-install.sh +18 -2
  19. package/plugin/src/claude_smart/cli.py +72 -38
  20. package/plugin/src/claude_smart/context_format.py +11 -12
  21. package/plugin/src/claude_smart/cs_cite.py +26 -12
  22. package/plugin/src/claude_smart/ids.py +13 -5
  23. package/plugin/uv.lock +1 -1
  24. package/plugin/vendor/reflexio/.env.example +53 -0
  25. package/plugin/vendor/reflexio/LICENSE +201 -0
  26. package/plugin/vendor/reflexio/README.md +338 -0
  27. package/plugin/vendor/reflexio/pyproject.toml +271 -0
  28. package/plugin/vendor/reflexio/reflexio/README.md +184 -0
  29. package/plugin/vendor/reflexio/reflexio/__init__.py +166 -0
  30. package/plugin/vendor/reflexio/reflexio/benchmarks/__init__.py +1 -0
  31. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/README.md +109 -0
  32. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/__init__.py +1 -0
  33. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/backends.py +175 -0
  34. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/bench.py +642 -0
  35. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/embed_cache.py +330 -0
  36. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/report.py +317 -0
  37. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/report.md +43 -0
  38. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/results.json +4478 -0
  39. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/scenarios.py +134 -0
  40. package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/seed.py +255 -0
  41. package/plugin/vendor/reflexio/reflexio/cli/README.md +287 -0
  42. package/plugin/vendor/reflexio/reflexio/cli/__init__.py +0 -0
  43. package/plugin/vendor/reflexio/reflexio/cli/__main__.py +56 -0
  44. package/plugin/vendor/reflexio/reflexio/cli/_client.py +86 -0
  45. package/plugin/vendor/reflexio/reflexio/cli/app.py +127 -0
  46. package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +266 -0
  47. package/plugin/vendor/reflexio/reflexio/cli/codex_auth.py +503 -0
  48. package/plugin/vendor/reflexio/reflexio/cli/commands/__init__.py +0 -0
  49. package/plugin/vendor/reflexio/reflexio/cli/commands/admin_cmd.py +65 -0
  50. package/plugin/vendor/reflexio/reflexio/cli/commands/agent_playbooks.py +503 -0
  51. package/plugin/vendor/reflexio/reflexio/cli/commands/api.py +114 -0
  52. package/plugin/vendor/reflexio/reflexio/cli/commands/auth.py +109 -0
  53. package/plugin/vendor/reflexio/reflexio/cli/commands/config_cmd.py +511 -0
  54. package/plugin/vendor/reflexio/reflexio/cli/commands/doctor.py +127 -0
  55. package/plugin/vendor/reflexio/reflexio/cli/commands/embeddings.py +53 -0
  56. package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +478 -0
  57. package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +303 -0
  58. package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +289 -0
  59. package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +961 -0
  60. package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +285 -0
  61. package/plugin/vendor/reflexio/reflexio/cli/commands/status_cmd.py +143 -0
  62. package/plugin/vendor/reflexio/reflexio/cli/commands/user_playbooks.py +373 -0
  63. package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +284 -0
  64. package/plugin/vendor/reflexio/reflexio/cli/errors.py +217 -0
  65. package/plugin/vendor/reflexio/reflexio/cli/log_format.py +247 -0
  66. package/plugin/vendor/reflexio/reflexio/cli/output.py +867 -0
  67. package/plugin/vendor/reflexio/reflexio/cli/paths.py +41 -0
  68. package/plugin/vendor/reflexio/reflexio/cli/run_services.py +391 -0
  69. package/plugin/vendor/reflexio/reflexio/cli/state.py +204 -0
  70. package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +96 -0
  71. package/plugin/vendor/reflexio/reflexio/cli/utils.py +329 -0
  72. package/plugin/vendor/reflexio/reflexio/client/__init__.py +3 -0
  73. package/plugin/vendor/reflexio/reflexio/client/cache.py +150 -0
  74. package/plugin/vendor/reflexio/reflexio/client/client.py +2613 -0
  75. package/plugin/vendor/reflexio/reflexio/defaults.py +23 -0
  76. package/plugin/vendor/reflexio/reflexio/integrations/__init__.py +0 -0
  77. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/.clawhubignore +7 -0
  78. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +274 -0
  79. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +517 -0
  80. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +473 -0
  81. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +2156 -0
  82. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +18 -0
  83. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +241 -0
  84. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +140 -0
  85. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +130 -0
  86. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +113 -0
  87. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +52 -0
  88. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +103 -0
  89. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +156 -0
  90. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +134 -0
  91. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +41 -0
  92. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +17 -0
  93. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +24 -0
  94. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +48 -0
  95. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +278 -0
  96. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +164 -0
  97. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +36 -0
  98. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +35 -0
  99. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +27 -0
  100. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +31 -0
  101. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +42 -0
  102. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +49 -0
  103. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +91 -0
  104. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +50 -0
  105. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tsconfig.json +16 -0
  106. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/types/openclaw.d.ts +230 -0
  107. package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +13 -0
  108. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/README.md +120 -0
  109. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/TESTING.md +168 -0
  110. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package-lock.json +1657 -0
  111. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package.json +16 -0
  112. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/HEARTBEAT.md +6 -0
  113. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/README.md +84 -0
  114. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/SKILL.md +194 -0
  115. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/_meta.json +6 -0
  116. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/agents/reflexio-extractor.md +45 -0
  117. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/handler.ts +214 -0
  118. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/setup.ts +55 -0
  119. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/index.ts +327 -0
  120. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/consolidate.ts +233 -0
  121. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/dedup.ts +80 -0
  122. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/io.ts +155 -0
  123. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/openclaw-cli.ts +67 -0
  124. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/search.ts +33 -0
  125. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-playbook.ts +76 -0
  126. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-profile.ts +79 -0
  127. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/openclaw.plugin.json +46 -0
  128. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/package.json +18 -0
  129. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/README.md +36 -0
  130. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/full_consolidation.md +56 -0
  131. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/playbook_extraction.md +217 -0
  132. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/profile_extraction.md +132 -0
  133. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-consolidate/SKILL.md +33 -0
  134. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-embedded/SKILL.md +194 -0
  135. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/HOOK.md +18 -0
  136. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/architecture.md +49 -0
  137. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/comparison.md +31 -0
  138. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/future-work.md +47 -0
  139. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/porting-notes.md +52 -0
  140. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/install.sh +52 -0
  141. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/uninstall.sh +36 -0
  142. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/consolidate.test.ts +135 -0
  143. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/dedup.test.ts +104 -0
  144. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/io.test.ts +175 -0
  145. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/search.test.ts +66 -0
  146. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/smoke-test.ts +140 -0
  147. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-playbook.test.ts +93 -0
  148. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-profile.test.ts +174 -0
  149. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tsconfig.json +16 -0
  150. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/types/openclaw.d.ts +230 -0
  151. package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/vitest.config.ts +7 -0
  152. package/plugin/vendor/reflexio/reflexio/lib/__init__.py +23 -0
  153. package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +310 -0
  154. package/plugin/vendor/reflexio/reflexio/lib/_base.py +225 -0
  155. package/plugin/vendor/reflexio/reflexio/lib/_config.py +83 -0
  156. package/plugin/vendor/reflexio/reflexio/lib/_dashboard.py +266 -0
  157. package/plugin/vendor/reflexio/reflexio/lib/_generation.py +176 -0
  158. package/plugin/vendor/reflexio/reflexio/lib/_interactions.py +334 -0
  159. package/plugin/vendor/reflexio/reflexio/lib/_operations.py +153 -0
  160. package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +545 -0
  161. package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +52 -0
  162. package/plugin/vendor/reflexio/reflexio/lib/_search.py +167 -0
  163. package/plugin/vendor/reflexio/reflexio/lib/_storage_labels.py +103 -0
  164. package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +288 -0
  165. package/plugin/vendor/reflexio/reflexio/lib/reflexio_lib.py +27 -0
  166. package/plugin/vendor/reflexio/reflexio/models/__init__.py +0 -0
  167. package/plugin/vendor/reflexio/reflexio/models/api_schema/__init__.py +0 -0
  168. package/plugin/vendor/reflexio/reflexio/models/api_schema/braintrust_schema.py +141 -0
  169. package/plugin/vendor/reflexio/reflexio/models/api_schema/common.py +41 -0
  170. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +3 -0
  171. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +1103 -0
  172. package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +63 -0
  173. package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +487 -0
  174. package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +28 -0
  175. package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +83 -0
  176. package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +766 -0
  177. package/plugin/vendor/reflexio/reflexio/models/api_schema/service_schemas.py +9 -0
  178. package/plugin/vendor/reflexio/reflexio/models/api_schema/stall_state_schema.py +32 -0
  179. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/__init__.py +3 -0
  180. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +177 -0
  181. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +129 -0
  182. package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/enums.py +25 -0
  183. package/plugin/vendor/reflexio/reflexio/models/api_schema/validators.py +280 -0
  184. package/plugin/vendor/reflexio/reflexio/models/config_schema.py +908 -0
  185. package/plugin/vendor/reflexio/reflexio/models/py.typed +0 -0
  186. package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +90 -0
  187. package/plugin/vendor/reflexio/reflexio/server/README.md +616 -0
  188. package/plugin/vendor/reflexio/reflexio/server/__init__.py +210 -0
  189. package/plugin/vendor/reflexio/reflexio/server/__main__.py +132 -0
  190. package/plugin/vendor/reflexio/reflexio/server/_auth.py +25 -0
  191. package/plugin/vendor/reflexio/reflexio/server/api.py +2714 -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 +540 -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 +110 -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 +1595 -0
  206. package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +112 -0
  207. package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +469 -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 +210 -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 +255 -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 +177 -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 +699 -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_extraction_context/v4.0.2.prompt.md +254 -0
  245. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.1.0.prompt.md +274 -0
  246. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.0.prompt.md +279 -0
  247. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v1.0.0.prompt.md +73 -0
  248. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v2.0.0.prompt.md +86 -0
  249. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.0.0.prompt.md +97 -0
  250. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.1.0.prompt.md +119 -0
  251. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.2.0.prompt.md +123 -0
  252. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +127 -0
  253. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.0.0.prompt.md +14 -0
  254. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.1.0.prompt.md +24 -0
  255. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +29 -0
  256. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.0.0.prompt.md +11 -0
  257. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.1.0.prompt.md +21 -0
  258. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.2.0.prompt.md +25 -0
  259. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.0.0.prompt.md +37 -0
  260. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.1.0.prompt.md +40 -0
  261. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.2.0.prompt.md +36 -0
  262. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v1.0.0.prompt.md +45 -0
  263. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v2.0.0.prompt.md +81 -0
  264. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v3.0.0.prompt.md +80 -0
  265. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate_expert/v1.0.0.prompt.md +34 -0
  266. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_deduplication/v1.0.0.prompt.md +116 -0
  267. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate/v1.0.0.prompt.md +33 -0
  268. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate_override/v1.0.0.prompt.md +16 -0
  269. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +140 -0
  270. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +160 -0
  271. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_main/v1.0.0.prompt.md +14 -0
  272. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/query_reformulation/v1.0.0.prompt.md +19 -0
  273. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/rerank_relevance/v1.1.0.prompt.md +44 -0
  274. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_comparison/v1.0.0.prompt.md +43 -0
  275. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_content_evaluation/v1.0.0.prompt.md +33 -0
  276. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/feedback_extraction_main_v1.jsonl +10 -0
  277. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/profile_update_main_v1.jsonl +10 -0
  278. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +280 -0
  279. package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_schema.py +11 -0
  280. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/_eval_health.py +131 -0
  281. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +60 -0
  282. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_service.py +228 -0
  283. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +87 -0
  284. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluator.py +372 -0
  285. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/delayed_group_evaluator.py +156 -0
  286. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/group_evaluation_runner.py +340 -0
  287. package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +471 -0
  288. package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +1626 -0
  289. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/__init__.py +0 -0
  290. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_cron.py +196 -0
  291. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_encryption.py +101 -0
  292. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/client.py +167 -0
  293. package/plugin/vendor/reflexio/reflexio/server/services/braintrust/service.py +281 -0
  294. package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +179 -0
  295. package/plugin/vendor/reflexio/reflexio/server/services/configurator/config_storage.py +62 -0
  296. package/plugin/vendor/reflexio/reflexio/server/services/configurator/configurator.py +87 -0
  297. package/plugin/vendor/reflexio/reflexio/server/services/configurator/local_file_config_storage.py +187 -0
  298. package/plugin/vendor/reflexio/reflexio/server/services/configurator/test_config_storage.py +162 -0
  299. package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +112 -0
  300. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/__init__.py +0 -0
  301. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/distribution.py +33 -0
  302. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +126 -0
  303. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +192 -0
  304. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/hero_state.py +75 -0
  305. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/rule_attribution.py +97 -0
  306. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +515 -0
  307. package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/shadow_aggregation.py +90 -0
  308. package/plugin/vendor/reflexio/reflexio/server/services/extraction/__init__.py +0 -0
  309. package/plugin/vendor/reflexio/reflexio/server/services/extraction/agent_run_records.py +91 -0
  310. package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +303 -0
  311. package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +25 -0
  312. package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +351 -0
  313. package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +138 -0
  314. package/plugin/vendor/reflexio/reflexio/server/services/extraction/prior_answer_search.py +217 -0
  315. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +468 -0
  316. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_scheduler.py +171 -0
  317. package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +777 -0
  318. package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +1125 -0
  319. package/plugin/vendor/reflexio/reflexio/server/services/extractor_config_utils.py +91 -0
  320. package/plugin/vendor/reflexio/reflexio/server/services/extractor_interaction_utils.py +251 -0
  321. package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +689 -0
  322. package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +835 -0
  323. package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +89 -0
  324. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_aggregator.py +1388 -0
  325. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_consolidator.py +960 -0
  326. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_extractor.py +436 -0
  327. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_generation_service.py +808 -0
  328. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_constants.py +28 -0
  329. package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +362 -0
  330. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/__init__.py +24 -0
  331. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/assistant_webhook.py +246 -0
  332. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/gepa_adapter.py +291 -0
  333. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/judge.py +97 -0
  334. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +96 -0
  335. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +645 -0
  336. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/rollout.py +35 -0
  337. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scenario_resolver.py +93 -0
  338. package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scheduler.py +174 -0
  339. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/__init__.py +26 -0
  340. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_document_expander.py +179 -0
  341. package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_query_reformulator.py +297 -0
  342. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_deduplicator.py +741 -0
  343. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_extractor.py +462 -0
  344. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service.py +734 -0
  345. package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +290 -0
  346. package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +17 -0
  347. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_extractor.py +247 -0
  348. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service.py +800 -0
  349. package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +146 -0
  350. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/__init__.py +0 -0
  351. package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +70 -0
  352. package/plugin/vendor/reflexio/reflexio/server/services/search/__init__.py +0 -0
  353. package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +671 -0
  354. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/__init__.py +1 -0
  355. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/judge.py +184 -0
  356. package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +81 -0
  357. package/plugin/vendor/reflexio/reflexio/server/services/storage/constants.py +2 -0
  358. package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +11 -0
  359. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +154 -0
  360. package/plugin/vendor/reflexio/reflexio/server/services/storage/retention_mixin.py +155 -0
  361. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +59 -0
  362. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +1253 -0
  363. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +1945 -0
  364. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +600 -0
  365. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +346 -0
  366. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +1378 -0
  367. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +747 -0
  368. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +263 -0
  369. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +193 -0
  370. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_share_links.py +166 -0
  371. package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +217 -0
  372. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +153 -0
  373. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +372 -0
  374. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +71 -0
  375. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +235 -0
  376. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +170 -0
  377. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +677 -0
  378. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +250 -0
  379. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +154 -0
  380. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +130 -0
  381. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_share_links.py +93 -0
  382. package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_stall_state.py +76 -0
  383. package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +568 -0
  384. package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +77 -0
  385. package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +116 -0
  386. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_manager.py +263 -0
  387. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +13 -0
  388. package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/llm_model_setting.json +7 -0
  389. package/plugin/vendor/reflexio/reflexio/server/tracing.py +158 -0
  390. package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +113 -0
  391. package/plugin/vendor/reflexio/reflexio/server/uvicorn_logging.py +76 -0
  392. package/plugin/vendor/reflexio/reflexio/test_support/__init__.py +1 -0
  393. package/plugin/vendor/reflexio/reflexio/test_support/llm_fixtures.py +62 -0
  394. package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +242 -0
  395. package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +129 -0
  396. package/plugin/vendor/reflexio/reflexio/test_support/skip_decorators.py +43 -0
@@ -0,0 +1,250 @@
1
+ from abc import abstractmethod
2
+
3
+ from reflexio.models.api_schema.domain import (
4
+ DeleteUserInteractionRequest,
5
+ DeleteUserProfileRequest,
6
+ Interaction,
7
+ Status,
8
+ UserProfile,
9
+ )
10
+ from reflexio.models.api_schema.retriever_schema import (
11
+ SearchInteractionRequest,
12
+ SearchUserProfileRequest,
13
+ )
14
+
15
+
16
+ class ProfileMixin:
17
+ """Mixin for profile and interaction CRUD methods."""
18
+
19
+ # read methods
20
+ @abstractmethod
21
+ def get_all_profiles(
22
+ self,
23
+ limit: int = 100,
24
+ status_filter: list[Status | None] | None = None,
25
+ ) -> list[UserProfile]:
26
+ raise NotImplementedError
27
+
28
+ @abstractmethod
29
+ def get_all_interactions(self, limit: int = 100) -> list[Interaction]:
30
+ raise NotImplementedError
31
+
32
+ @abstractmethod
33
+ def get_user_profile(
34
+ self,
35
+ user_id: str,
36
+ status_filter: list[Status | None] | None = None,
37
+ ) -> list[UserProfile]:
38
+ raise NotImplementedError
39
+
40
+ @abstractmethod
41
+ def get_user_interaction(self, user_id: str) -> list[Interaction]:
42
+ raise NotImplementedError
43
+
44
+ # create or update methods
45
+ @abstractmethod
46
+ def add_user_profile(self, user_id: str, user_profiles: list[UserProfile]) -> None:
47
+ """Add the user profile for a given user id."""
48
+ raise NotImplementedError
49
+
50
+ @abstractmethod
51
+ def add_user_interaction(self, user_id: str, interaction: Interaction) -> None:
52
+ raise NotImplementedError
53
+
54
+ @abstractmethod
55
+ def add_user_interactions_bulk(
56
+ self, user_id: str, interactions: list[Interaction]
57
+ ) -> None:
58
+ """Add multiple user interactions with batched embedding generation.
59
+
60
+ Args:
61
+ user_id: The user ID
62
+ interactions: List of interactions to add
63
+ """
64
+ raise NotImplementedError
65
+
66
+ # delete methods
67
+ @abstractmethod
68
+ def delete_user_interaction(self, request: DeleteUserInteractionRequest) -> None:
69
+ raise NotImplementedError
70
+
71
+ @abstractmethod
72
+ def delete_user_profile(self, request: DeleteUserProfileRequest) -> None:
73
+ raise NotImplementedError
74
+
75
+ @abstractmethod
76
+ def update_user_profile_by_id(
77
+ self, user_id: str, profile_id: str, new_profile: UserProfile
78
+ ) -> None:
79
+ raise NotImplementedError
80
+
81
+ @abstractmethod
82
+ def delete_all_interactions_for_user(self, user_id: str) -> None:
83
+ raise NotImplementedError
84
+
85
+ @abstractmethod
86
+ def delete_all_profiles_for_user(self, user_id: str) -> None:
87
+ raise NotImplementedError
88
+
89
+ @abstractmethod
90
+ def delete_all_profiles(self) -> None:
91
+ """Delete all profiles across all users."""
92
+ raise NotImplementedError
93
+
94
+ @abstractmethod
95
+ def delete_all_interactions(self) -> None:
96
+ """Delete all interactions across all users."""
97
+ raise NotImplementedError
98
+
99
+ @abstractmethod
100
+ def count_all_interactions(self) -> int:
101
+ """Count total interactions across all users.
102
+
103
+ Returns:
104
+ int: Total number of interactions
105
+ """
106
+ raise NotImplementedError
107
+
108
+ @abstractmethod
109
+ def count_all_profiles(self) -> int:
110
+ """Count total profiles across all users without hydrating rows.
111
+
112
+ Cheap alternative to ``len(get_all_profiles(...))`` — avoids
113
+ loading every profile row (including embedding BLOBs) just to
114
+ take a count. Used by publish-path diagnostics that snapshot
115
+ totals before and after a run.
116
+
117
+ Returns:
118
+ int: Total number of profiles across all users
119
+ """
120
+ raise NotImplementedError
121
+
122
+ @abstractmethod
123
+ def delete_oldest_interactions(self, count: int) -> int:
124
+ """Delete the oldest N interactions based on created_at timestamp.
125
+
126
+ Args:
127
+ count (int): Number of oldest interactions to delete
128
+
129
+ Returns:
130
+ int: Number of interactions actually deleted
131
+ """
132
+ raise NotImplementedError
133
+
134
+ @abstractmethod
135
+ def update_all_profiles_status(
136
+ self,
137
+ old_status: Status | None,
138
+ new_status: Status | None,
139
+ user_ids: list[str] | None = None,
140
+ ) -> int:
141
+ """Update all profiles with old_status to new_status atomically.
142
+
143
+ Args:
144
+ old_status: The current status to match (None for CURRENT)
145
+ new_status: The new status to set (None for CURRENT)
146
+ user_ids: Optional list of user_ids to filter updates. If None, updates all users.
147
+
148
+ Returns:
149
+ int: Number of profiles updated
150
+ """
151
+ raise NotImplementedError
152
+
153
+ @abstractmethod
154
+ def get_profiles_by_ids(
155
+ self,
156
+ user_id: str,
157
+ profile_ids: list[str],
158
+ status_filter: list[Status | None] | None = None,
159
+ ) -> list[UserProfile]:
160
+ """Fetch the subset of a user's profiles whose ids are in the list.
161
+
162
+ Server-side filter on (``user_id``, ``profile_id IN (...)``) so
163
+ callers (e.g. the reflection service resolving a small set of
164
+ cited profile ids) avoid scanning every profile for the user.
165
+
166
+ Args:
167
+ user_id (str): Owning user id.
168
+ profile_ids (list[str]): Profile ids to fetch. Empty list
169
+ returns ``[]`` without hitting storage.
170
+ status_filter (list[Status | None] | None): Statuses to
171
+ include. ``None`` (default) means CURRENT only — same
172
+ default as ``get_user_profile`` for consistency.
173
+
174
+ Returns:
175
+ list[UserProfile]: Matching profiles. Order is unspecified.
176
+ Ids that do not exist (or do not match the user / status
177
+ filter) are silently omitted.
178
+ """
179
+ raise NotImplementedError
180
+
181
+ @abstractmethod
182
+ def archive_profile_by_id(self, user_id: str, profile_id: str) -> bool:
183
+ """Atomically archive a single profile by id, only if currently CURRENT.
184
+
185
+ Flips the row's ``status`` from ``None`` (CURRENT) to
186
+ ``Status.ARCHIVED``. No-op when the profile does not exist or is
187
+ already non-current.
188
+
189
+ Args:
190
+ user_id (str): Owning user id.
191
+ profile_id (str): The profile id to archive.
192
+
193
+ Returns:
194
+ bool: True if a row was archived; False otherwise.
195
+ """
196
+ raise NotImplementedError
197
+
198
+ @abstractmethod
199
+ def delete_all_profiles_by_status(self, status: Status) -> int:
200
+ """Delete all profiles with the given status atomically.
201
+
202
+ Args:
203
+ status: The status of profiles to delete
204
+
205
+ Returns:
206
+ int: Number of profiles deleted
207
+ """
208
+ raise NotImplementedError
209
+
210
+ @abstractmethod
211
+ def get_user_ids_with_status(self, status: Status | None) -> list[str]:
212
+ """Get list of unique user_ids that have profiles with the given status.
213
+
214
+ Args:
215
+ status: The status to filter by (None for CURRENT)
216
+
217
+ Returns:
218
+ list[str]: List of unique user_ids
219
+ """
220
+ raise NotImplementedError
221
+
222
+ @abstractmethod
223
+ def delete_profiles_by_ids(self, profile_ids: list[str]) -> int:
224
+ """Delete profiles by their IDs.
225
+
226
+ Args:
227
+ profile_ids (list[str]): List of profile IDs to delete
228
+
229
+ Returns:
230
+ int: Number of profiles deleted
231
+ """
232
+ raise NotImplementedError
233
+
234
+ # Search methods
235
+ @abstractmethod
236
+ def search_interaction(
237
+ self,
238
+ search_interaction_request: SearchInteractionRequest,
239
+ query_embedding: list[float] | None = None,
240
+ ) -> list[Interaction]:
241
+ raise NotImplementedError
242
+
243
+ @abstractmethod
244
+ def search_user_profile(
245
+ self,
246
+ search_user_profile_request: SearchUserProfileRequest,
247
+ status_filter: list[Status | None] | None = None,
248
+ query_embedding: list[float] | None = None,
249
+ ) -> list[UserProfile]:
250
+ raise NotImplementedError
@@ -0,0 +1,154 @@
1
+ from abc import abstractmethod
2
+
3
+ from reflexio.models.api_schema.domain import Request
4
+ from reflexio.models.api_schema.internal_schema import (
5
+ RequestInteractionDataModel,
6
+ SessionDescriptor,
7
+ )
8
+
9
+
10
+ class RequestMixin:
11
+ """Mixin for request CRUD methods."""
12
+
13
+ @abstractmethod
14
+ def add_request(self, request: Request) -> None:
15
+ """Add a request to storage.
16
+
17
+ Args:
18
+ request: Request object to store
19
+ """
20
+ raise NotImplementedError
21
+
22
+ @abstractmethod
23
+ def get_request(self, request_id: str) -> Request | None:
24
+ """Get a request by its ID.
25
+
26
+ Args:
27
+ request_id: The request ID to retrieve
28
+
29
+ Returns:
30
+ Request object if found, None otherwise
31
+ """
32
+ raise NotImplementedError
33
+
34
+ @abstractmethod
35
+ def delete_request(self, request_id: str) -> None:
36
+ """Delete a request by its ID.
37
+
38
+ Args:
39
+ request_id: The request ID to delete
40
+ """
41
+ raise NotImplementedError
42
+
43
+ @abstractmethod
44
+ def delete_session(self, session_id: str) -> int:
45
+ """Delete all requests and interactions in a session.
46
+
47
+ Args:
48
+ session_id: The session ID to delete
49
+
50
+ Returns:
51
+ int: Number of requests deleted
52
+ """
53
+ raise NotImplementedError
54
+
55
+ @abstractmethod
56
+ def delete_all_requests(self) -> None:
57
+ """Delete all requests and their associated interactions."""
58
+ raise NotImplementedError
59
+
60
+ @abstractmethod
61
+ def delete_requests_by_ids(self, request_ids: list[str]) -> int:
62
+ """Delete requests and their associated interactions by request IDs.
63
+
64
+ Args:
65
+ request_ids (list[str]): List of request IDs to delete
66
+
67
+ Returns:
68
+ int: Number of requests deleted
69
+ """
70
+ raise NotImplementedError
71
+
72
+ @abstractmethod
73
+ def get_sessions(
74
+ self,
75
+ user_id: str | None = None,
76
+ request_id: str | None = None,
77
+ session_id: str | None = None,
78
+ start_time: int | None = None,
79
+ end_time: int | None = None,
80
+ top_k: int | None = 30,
81
+ offset: int = 0,
82
+ ) -> dict[str, list[RequestInteractionDataModel]]:
83
+ """Get requests with their associated interactions, grouped by session_id.
84
+
85
+ Args:
86
+ user_id (str, optional): User ID to filter requests.
87
+ request_id (str, optional): Specific request ID to retrieve
88
+ session_id (str, optional): Specific session ID to retrieve
89
+ start_time (int, optional): Start timestamp for filtering
90
+ end_time (int, optional): End timestamp for filtering
91
+ top_k (int, optional): Maximum number of requests to return
92
+ offset (int): Number of requests to skip for pagination. Defaults to 0.
93
+
94
+ Returns:
95
+ dict[str, list[RequestInteractionDataModel]]: Dictionary mapping session_id to list of RequestInteractionDataModel objects
96
+ """
97
+ raise NotImplementedError
98
+
99
+ @abstractmethod
100
+ def get_rerun_user_ids(
101
+ self,
102
+ user_id: str | None = None,
103
+ start_time: int | None = None,
104
+ end_time: int | None = None,
105
+ source: str | None = None,
106
+ agent_version: str | None = None,
107
+ ) -> list[str]:
108
+ """Get distinct user IDs that have matching requests for rerun workflows.
109
+
110
+ Args:
111
+ user_id (str, optional): Restrict to a specific user ID.
112
+ start_time (int, optional): Start timestamp for request filtering.
113
+ end_time (int, optional): End timestamp for request filtering.
114
+ source (str, optional): Restrict to requests from a source.
115
+ agent_version (str, optional): Restrict to requests with an agent version.
116
+
117
+ Returns:
118
+ list[str]: Distinct user IDs matching the filters.
119
+ """
120
+ raise NotImplementedError
121
+
122
+ @abstractmethod
123
+ def get_requests_by_session(self, user_id: str, session_id: str) -> list[Request]:
124
+ """Get all requests for a specific session.
125
+
126
+ Args:
127
+ user_id (str): User ID to filter requests
128
+ session_id (str): Session ID to filter by
129
+
130
+ Returns:
131
+ list[Request]: List of Request objects in the session
132
+ """
133
+ raise NotImplementedError
134
+
135
+ @abstractmethod
136
+ def get_session_ids_in_window(
137
+ self, from_ts: int, to_ts: int
138
+ ) -> list[SessionDescriptor]:
139
+ """Return one descriptor per distinct (user_id, session_id, agent_version, source) tuple with at least one request whose ``created_at`` falls inside ``[from_ts, to_ts]``.
140
+
141
+ A session that records requests under multiple ``agent_version`` or
142
+ ``source`` values within the window yields one descriptor per distinct
143
+ combination, so regen workers can invoke ``run_group_evaluation`` once
144
+ per (user, session, agent_version, source) tuple without conflating
145
+ runs from different agent versions.
146
+
147
+ Args:
148
+ from_ts (int): Inclusive lower bound (Unix seconds).
149
+ to_ts (int): Inclusive upper bound (Unix seconds).
150
+
151
+ Returns:
152
+ list[SessionDescriptor]: Deduped descriptors ordered by session_id.
153
+ """
154
+ raise NotImplementedError
@@ -0,0 +1,130 @@
1
+ """Storage interface for per-turn shadow comparison verdicts (F1).
2
+
3
+ Declares the methods every storage implementation MAY implement to expose the
4
+ ``shadow_comparison_verdicts`` table used by the per-turn Reflexio-vs-Shadow
5
+ comparison feature.
6
+
7
+ The default implementations raise :class:`NotImplementedError`. Concrete
8
+ backends that support the feature (currently :class:`SQLiteStorage`) override
9
+ these methods via their own mixin. Backends that don't (currently
10
+ :class:`DiskStorage`, :class:`SupabaseStorage` — added in later tasks) will
11
+ surface a clear ``NotImplementedError`` at call time rather than
12
+ ``AttributeError``.
13
+
14
+ This intentionally follows the :class:`StallStateMixin` precedent so adding
15
+ a new backend-optional feature does not break the instantiation contract of
16
+ existing backends.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from typing import TYPE_CHECKING
22
+
23
+ if TYPE_CHECKING:
24
+ from reflexio.models.api_schema.eval_overview_schema import (
25
+ ShadowComparisonVerdict,
26
+ )
27
+
28
+
29
+ class ShadowVerdictsMixin:
30
+ """Default no-op shadow_comparison_verdicts interface for storage backends.
31
+
32
+ Subclasses that support the feature must override every method. The
33
+ methods below raise :class:`NotImplementedError` so callers see a
34
+ clear error message naming the backend rather than ``AttributeError``.
35
+ """
36
+
37
+ def save_shadow_comparison_verdict(
38
+ self, verdict: ShadowComparisonVerdict
39
+ ) -> ShadowComparisonVerdict:
40
+ """Persist a verdict and return the row with the assigned ``verdict_id``.
41
+
42
+ Args:
43
+ verdict (ShadowComparisonVerdict): The verdict to persist. The
44
+ ``verdict_id`` field is ignored on save — storage assigns
45
+ the autoincrement key.
46
+
47
+ Returns:
48
+ ShadowComparisonVerdict: The same verdict with ``verdict_id``
49
+ replaced by the storage-assigned primary key.
50
+
51
+ Raises:
52
+ NotImplementedError: When the backend does not support shadow
53
+ comparison verdicts.
54
+ """
55
+ raise NotImplementedError(
56
+ f"{type(self).__name__} does not support shadow_comparison_verdicts"
57
+ )
58
+
59
+ def get_shadow_comparison_verdict(
60
+ self, verdict_id: int
61
+ ) -> ShadowComparisonVerdict | None:
62
+ """Fetch one verdict by its autoincrement primary key.
63
+
64
+ Args:
65
+ verdict_id (int): The storage-assigned key returned by
66
+ :meth:`save_shadow_comparison_verdict`.
67
+
68
+ Returns:
69
+ ShadowComparisonVerdict | None: The verdict if present, else
70
+ ``None``.
71
+
72
+ Raises:
73
+ NotImplementedError: When the backend does not support shadow
74
+ comparison verdicts.
75
+ """
76
+ raise NotImplementedError(
77
+ f"{type(self).__name__} does not support shadow_comparison_verdicts"
78
+ )
79
+
80
+ def get_shadow_comparison_verdicts(
81
+ self,
82
+ from_ts: int,
83
+ to_ts: int,
84
+ judge_prompt_version: str,
85
+ ) -> list[ShadowComparisonVerdict]:
86
+ """Fetch verdicts in ``[from_ts, to_ts]`` for one pinned prompt version.
87
+
88
+ Args:
89
+ from_ts (int): Inclusive lower bound of ``created_at``, in Unix
90
+ epoch seconds (UTC).
91
+ to_ts (int): Inclusive upper bound of ``created_at``, in Unix
92
+ epoch seconds (UTC).
93
+ judge_prompt_version (str): The pinned ``shadow_comparison``
94
+ prompt version. Filtering by this prevents rubric-mixing in
95
+ the dashboard headline metric — verdicts produced under an
96
+ older rubric stay in storage but do not contaminate the
97
+ current trend.
98
+
99
+ Returns:
100
+ list[ShadowComparisonVerdict]: Matching verdicts in chronological
101
+ order (ascending ``created_at``).
102
+
103
+ Raises:
104
+ NotImplementedError: When the backend does not support shadow
105
+ comparison verdicts.
106
+ """
107
+ raise NotImplementedError(
108
+ f"{type(self).__name__} does not support shadow_comparison_verdicts"
109
+ )
110
+
111
+ def delete_shadow_comparison_verdicts_by_session(self, session_id: str) -> int:
112
+ """Remove all verdicts for one session.
113
+
114
+ Used by the regen worker's delete-after-save pattern: a re-eval
115
+ run computes fresh verdicts, persists them, then clears the prior
116
+ ones to avoid double-counting.
117
+
118
+ Args:
119
+ session_id (str): The session whose verdicts should be removed.
120
+
121
+ Returns:
122
+ int: Number of rows deleted.
123
+
124
+ Raises:
125
+ NotImplementedError: When the backend does not support shadow
126
+ comparison verdicts.
127
+ """
128
+ raise NotImplementedError(
129
+ f"{type(self).__name__} does not support shadow_comparison_verdicts"
130
+ )
@@ -0,0 +1,93 @@
1
+ """Abstract ShareLink storage operations.
2
+
3
+ Each BaseStorage subclass (SQLite, Supabase, Postgres) must implement these methods.
4
+ Storage instances are org-scoped, so org_id is not a method parameter.
5
+ """
6
+
7
+ from abc import abstractmethod
8
+
9
+ from reflexio.models.api_schema.domain import ShareLink
10
+
11
+
12
+ class ShareLinkMixin:
13
+ """Mixin defining share link CRUD operations on a per-org data storage."""
14
+
15
+ @abstractmethod
16
+ def create_share_link(
17
+ self,
18
+ token: str,
19
+ resource_type: str,
20
+ resource_id: str,
21
+ expires_at: int | None,
22
+ created_by_email: str | None,
23
+ ) -> ShareLink:
24
+ """Create a new share link.
25
+
26
+ Args:
27
+ token (str): The share token (unique).
28
+ resource_type (str): Type of resource (e.g., "profile", "user_playbook").
29
+ resource_id (str): ID of the resource being shared.
30
+ expires_at (int | None): Optional Unix timestamp of expiration.
31
+ created_by_email (str | None): Optional email of creator.
32
+
33
+ Returns:
34
+ ShareLink: The created share link with id and created_at populated.
35
+ """
36
+ raise NotImplementedError
37
+
38
+ @abstractmethod
39
+ def get_share_link_by_token(self, token: str) -> ShareLink | None:
40
+ """Look up a share link by its token.
41
+
42
+ Args:
43
+ token (str): The share token.
44
+
45
+ Returns:
46
+ ShareLink | None: The share link if found, else None.
47
+ """
48
+ raise NotImplementedError
49
+
50
+ @abstractmethod
51
+ def get_share_link_by_resource(
52
+ self, resource_type: str, resource_id: str
53
+ ) -> ShareLink | None:
54
+ """Look up an existing share link for a specific resource (for dedup).
55
+
56
+ Args:
57
+ resource_type (str): Type of resource.
58
+ resource_id (str): ID of the resource.
59
+
60
+ Returns:
61
+ ShareLink | None: The existing share link if any, else None.
62
+ """
63
+ raise NotImplementedError
64
+
65
+ @abstractmethod
66
+ def get_share_links(self) -> list[ShareLink]:
67
+ """Return all share links for this org.
68
+
69
+ Returns:
70
+ list[ShareLink]: All share links, ordered by created_at ascending.
71
+ """
72
+ raise NotImplementedError
73
+
74
+ @abstractmethod
75
+ def delete_share_link(self, link_id: int) -> bool:
76
+ """Delete a share link by ID.
77
+
78
+ Args:
79
+ link_id (int): The share link ID.
80
+
81
+ Returns:
82
+ bool: True if deleted, False if not found.
83
+ """
84
+ raise NotImplementedError
85
+
86
+ @abstractmethod
87
+ def delete_all_share_links(self) -> int:
88
+ """Delete all share links for this org.
89
+
90
+ Returns:
91
+ int: Number of links deleted.
92
+ """
93
+ raise NotImplementedError
@@ -0,0 +1,76 @@
1
+ """Stall state interface for storage backends.
2
+
3
+ Declares the methods every storage implementation MUST implement to expose
4
+ the singleton stall_state row used by the credit-stall notification flow.
5
+
6
+ The default implementations raise :class:`NotImplementedError`. Concrete
7
+ backends that support the stall_state feature override these methods via
8
+ their own mixin. Backends without stall_state support will surface a clear
9
+ ``NotImplementedError`` at call time rather than ``AttributeError``.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from datetime import datetime
15
+ from typing import TYPE_CHECKING
16
+
17
+ if TYPE_CHECKING:
18
+ from reflexio.server.services.storage.sqlite_storage._stall_state import (
19
+ StallReason,
20
+ StallState,
21
+ )
22
+
23
+
24
+ class StallStateMixin:
25
+ """Default no-op stall_state interface for storage backends.
26
+
27
+ Subclasses that support the stall_state feature must override every method.
28
+ """
29
+
30
+ def get_stall_state(self) -> StallState:
31
+ """Return the current stall row.
32
+
33
+ Returns:
34
+ StallState: Current snapshot of the singleton stall row.
35
+
36
+ Raises:
37
+ NotImplementedError: When the backend does not support stall_state.
38
+ """
39
+ raise NotImplementedError(f"{type(self).__name__} does not support stall_state")
40
+
41
+ def upsert_stall_state(
42
+ self,
43
+ *,
44
+ reason: StallReason,
45
+ stalled_at: datetime,
46
+ reset_estimate: datetime | None,
47
+ error_message: str,
48
+ ) -> None:
49
+ """Mark the singleton as stalled with the given reason.
50
+
51
+ Args:
52
+ reason (StallReason): The stall reason discriminator.
53
+ stalled_at (datetime): When the stall was first detected.
54
+ reset_estimate (datetime | None): Estimated reset time, if known.
55
+ error_message (str): Raw error text for debugging.
56
+
57
+ Raises:
58
+ NotImplementedError: When the backend does not support stall_state.
59
+ """
60
+ raise NotImplementedError(f"{type(self).__name__} does not support stall_state")
61
+
62
+ def mark_stall_notified(self) -> None:
63
+ """Set ``notified_in_cc=1`` for the current stall.
64
+
65
+ Raises:
66
+ NotImplementedError: When the backend does not support stall_state.
67
+ """
68
+ raise NotImplementedError(f"{type(self).__name__} does not support stall_state")
69
+
70
+ def clear_stall_state(self) -> None:
71
+ """Mark the singleton clean — clears all stall fields atomically.
72
+
73
+ Raises:
74
+ NotImplementedError: When the backend does not support stall_state.
75
+ """
76
+ raise NotImplementedError(f"{type(self).__name__} does not support stall_state")